1. 13 9月, 2018 1 次提交
  2. 06 9月, 2018 1 次提交
    • R
      define and use internal macros for hidden visibility, weak refs · 9b95fd09
      Rich Felker 提交于
      this cleans up what had become widespread direct inline use of "GNU C"
      style attributes directly in the source, and lowers the barrier to
      increased use of hidden visibility, which will be useful to recovering
      some of the efficiency lost when the protected visibility hack was
      dropped in commit dc2f368e, especially
      on archs where the PLT ABI is costly.
      9b95fd09
  3. 20 6月, 2018 1 次提交
    • R
      add m68k port · f81e44a0
      Rich Felker 提交于
      three ABIs are supported: the default with 68881 80-bit fpu format and
      results returned in floating point registers, softfloat-only with the
      same format, and coldfire fpu with IEEE single/double only. only the
      first is tested at all, and only under qemu which has fpu emulation
      bugs.
      
      basic functionality smoke tests have been performed for the most
      common arch-specific breakage via libc-test and qemu user-level
      emulation. some sysvipc failures remain, but are shared with other big
      endian archs and will be fixed separately.
      f81e44a0
  4. 03 6月, 2018 1 次提交
    • S
      fix TLS layout of TLS variant I when there is a gap above TP · 610c5a85
      Szabolcs Nagy 提交于
      In TLS variant I the TLS is above TP (or above a fixed offset from TP)
      but on some targets there is a reserved gap above TP before TLS starts.
      
      This matters for the local-exec tls access model when the offsets of
      TLS variables from the TP are hard coded by the linker into the
      executable, so the libc must compute these offsets the same way as the
      linker.  The tls offset of the main module has to be
      
      	alignup(GAP_ABOVE_TP, main_tls_align).
      
      If there is no TLS in the main module then the gap can be ignored
      since musl does not use it and the tls access models of shared
      libraries are not affected.
      
      The previous setup only worked if (tls_align & -GAP_ABOVE_TP) == 0
      (i.e. TLS did not require large alignment) because the gap was
      treated as a fixed offset from TP.  Now the TP points at the end
      of the pthread struct (which is aligned) and there is a gap above
      it (which may also need alignment).
      
      The fix required changing TP_ADJ and __pthread_self on affected
      targets (aarch64, arm and sh) and in the tlsdesc asm the offset to
      access the dtv changed too.
      610c5a85
  5. 12 4月, 2017 1 次提交
    • R
      fix dl_iterate_phdr in static PIE binaries · b3751c32
      Rich Felker 提交于
      analogous to commit 5bf7eba2, use of
      AT_PHDR/PT_PHDR does not actually work to find the program base, and
      the method with _DYNAMIC vs PT_DYNAMIC must be used as an alternative.
      
      patch by Shiz, along with testing to confirm that this fixes unwinding
      in static PIE.
      b3751c32
  6. 15 3月, 2017 1 次提交
  7. 16 2月, 2017 1 次提交
  8. 09 5月, 2016 1 次提交
  9. 18 4月, 2016 1 次提交
  10. 07 3月, 2016 1 次提交
    • R
      add mips64 port · 83933573
      Rich Felker 提交于
      patch by Mahesh Bodapati and Jaydeep Patil of Imagination
      Technologies.
      83933573
  11. 26 1月, 2016 9 次提交
  12. 22 1月, 2016 2 次提交
  13. 29 11月, 2015 1 次提交
    • S
      ldso: fix the dtv update logic in __tls_get_new · 12978acb
      Szabolcs Nagy 提交于
      if two or more threads accessed tls in a dso that was loaded after
      the threads were created, then __tls_get_new could do out-of-bound
      memory access (leading to segfault).
      
      accidentally byte count was used instead of element count when
      the new dtv pointer was computed. (dso->new_dtv is (void**).)
      
      it is rare that the same dso provides dtv for several threads,
      the crash was not observed in practice, but possible to trigger.
      12978acb
  14. 20 11月, 2015 1 次提交
    • R
      remove undef weak refs to init/fini array symbols in libc.so · 19caa25d
      Rich Felker 提交于
      commit ad1cd43a eliminated
      preprocessor-level omission of references to the init/fini array
      symbols from object files going into libc.so. the references are weak,
      and the intent was that the linker would resolve them to zero in
      libc.so, but instead it leaves undefined references that could be
      satisfied at runtime. normally these references would be harmless,
      since the code using them does not even get executed, but some older
      binutils versions produce a linking error: when linking a program
      against libc.so, ld first tries to use the hidden init/fini array
      symbols produced by the linker script to satisfy the references in
      libc.so, then produces an error because the definitions are hidden.
      
      ideally ld would have already provided definitions of these symbols
      when linking libc.so, but the linker script for -shared omits them.
      
      to avoid this situation, the dynamic linker now provides its own dummy
      definitions of the init/fini array symbols for libc.so. since they are
      hidden, everything binds at ld time and no references remain in the
      dynamic symbol table. with modern binutils and --gc-sections, both
      the dummy empty array objects and the code referencing them get
      dropped at link time, anyway.
      
      the _init and _fini symbols are also switched back to using weak
      definitions rather than weak references since the latter behave
      somewhat problematically in general, and the weak definition approach
      was known to work well.
      19caa25d
  15. 16 11月, 2015 1 次提交
    • R
      use private maps even for read-only segments of FDPIC libraries · 5fe38516
      Rich Felker 提交于
      the nommu kernel shares memory when it can anyway for private
      read-only maps, but semantically the map should be private. this can
      make a difference when debugging breakpoints are to be used, in which
      case the kernel may need to ensure that the mapping is not shared.
      
      the new behavior matches how the kernel FDPIC loader maps the main
      program and/or program interpreter (dynamic linker) binary.
      5fe38516
  16. 13 11月, 2015 2 次提交
    • R
      remove use of SHARED macro in dynamic linker version reporting · 9e0a317d
      Rich Felker 提交于
      also fix visibility of the glue function used.
      9e0a317d
    • R
      unify static and dynamic linked implementations of thread-local storage · d56460c9
      Rich Felker 提交于
      this both allows removal of some of the main remaining uses of the
      SHARED macro and clears one obstacle to static-linked dlopen support,
      which may be added at some point in the future.
      
      specialized single-TLS-module versions of __copy_tls and __reset_tls
      are removed and replaced with code adapted from their dynamic-linked
      versions, capable of operating on a whole chain of TLS modules, and
      use of the dynamic linker's DSO chain (which contains large struct dso
      objects) by these functions is replaced with a new chain of struct
      tls_module objects containing only the information needed for
      implementing TLS. this may also yield some performance benefit
      initializing TLS for a new thread when a large number of modules
      without TLS have been loaded, since since there is no need to walk
      structures for modules without TLS.
      d56460c9
  17. 12 11月, 2015 2 次提交
    • R
      unify static and dynamic libc init/fini code paths · ad1cd43a
      Rich Felker 提交于
      use weak definitions that the dynamic linker can override instead of
      preprocessor conditionals on SHARED so that the same libc start and
      exit code can be used for both static and dynamic linking.
      ad1cd43a
    • R
      fix dynamic loader library mapping for nommu systems · 9439ebd7
      Rich Felker 提交于
      on linux/nommu, non-writable private mappings of files may actually
      use memory shared with other processes or the fs cache. the old nommu
      loader code (used when mmap with MAP_FIXED fails) simply wrote over
      top of the original file mapping, possibly clobbering this shared
      memory. no such breakage was observed in practice, but it should have
      been possible.
      
      the new code starts by mapping anonymous writable memory on archs that
      might support nommu, then maps load segments over top of it, falling
      back to read if MAP_FIXED fails. we use an anonymous map rather than a
      writable file map to avoid reading more data from disk than needed.
      since pages cannot be loaded lazily on fault, in case of large
      data/bss, mapping the full file may read a lot of data that will
      subsequently be thrown away when processing additional LOAD segments.
      as a result, we cannot skip the first LOAD segment when operating in
      this mode.
      
      these changes affect only non-FDPIC nommu support.
      9439ebd7
  18. 10 11月, 2015 1 次提交
    • R
      explicitly assemble all arm asm sources as UAL · 4e73d121
      Rich Felker 提交于
      these files are all accepted as legacy arm syntax when producing arm
      code, but legacy syntax cannot be used for producing thumb2 with
      access to the full ISA. even after switching to UAL, some asm source
      files contain instructions which are not valid in thumb mode, so these
      will need to be addressed separately.
      4e73d121
  19. 29 10月, 2015 1 次提交
    • R
      fix missing bss handling in FDPIC ELF loader · fead7e3f
      Rich Felker 提交于
      when a library being loaded has bss (i.e. data segment with
      p_memsz>p_filesz), this region needs to be zeroed with a combination
      of memset and/or mmap. the regular ELF loader always did this but the
      FDPIC code path omitted it, leading to objects in bss having
      uninitialized/junk contents.
      fead7e3f
  20. 16 10月, 2015 2 次提交
    • R
      fix dladdr treatment of function descriptors for fdpic · bde0b4b9
      Rich Felker 提交于
      when determining which module an address belongs to, all function
      descriptor ranges must be checked first, in case the allocated memory
      falls inside another module's memory range.
      
      dladdr itself must also check addresses against function descriptors
      before doing a best-match search against the symbol table. even when
      doing the latter (e.g. for code addresses obtained from mcontext_t),
      also check whether the best-match was a function, and if so, replace
      the result with a function descriptor address. which is the nominal
      "base address" of the function and which the caller needs if it
      intends to subsequently call the matching function.
      bde0b4b9
    • R
      fix visibility mismatch in dynamic linker stage 2 function definition · bc9b6ea0
      Rich Felker 提交于
      since commits 2907afb8 and
      6fc30c24, __dls2 is no longer called
      via symbol lookup, but instead uses relative addressing that needs to
      be resolved at link time. on some linker versions, and/or if
      -Bsymbolic-functions is not used, the linker may leave behind a
      dynamic relocation, which is not suitable for bootstrapping the
      dynamic linker, if the reference to __dls2 is marked hidden but the
      definition is not actually hidden. correcting the definition to use
      hidden visibility fixes the problem.
      
      the static-PIE entry point rcrt1 was likewise affected and is also
      fixed by this patch.
      bc9b6ea0
  21. 23 9月, 2015 6 次提交
    • R
      fix dlsym RTLD_NEXT behavior for fdpic · 6c5cad2a
      Rich Felker 提交于
      lookup the dso an address falls in based on the loadmap and not just a
      base/length. fix the main app's fake loadmap used when loaded by a
      non-fdpic-aware loader so that it does not cover the whole memory
      space.
      
      function descriptor addresses are also matched for future use by
      dladdr, but reverse lookups of function descriptors via dladdr have
      not been implemented yet. some revisions may be needed in the future
      once reclaim_gaps supports fdpic, so that function descriptors
      allocated in reclaimed heap space do not get detected as belonging to
      the module whose gaps they were allocated in.
      6c5cad2a
    • R
      fix dlsym lookup of function symbols on fdpic · d47d9a50
      Rich Felker 提交于
      previously these resolved to the code address rather than the address
      of the function descriptor.
      
      the conditions for accepting or rejecting symbols are quite
      inconsistent between the different points in the dynamic linker code
      where such decisions are made. this commit attempts to be at least as
      correct as anything already there, but does not improve consistency.
      it has been tested to correctly avoid symbols that are merely
      references to functions defined in other modules, at least in simple
      usage, but at some point all symbol lookup logic should be reviewed
      and refactored/unified.
      d47d9a50
    • R
      move calls to application init functions after crt1 entry point · c87a5210
      Rich Felker 提交于
      this change is needed to be compatible with fdpic, where some of the
      main application's relocations may be performed as part of the crt1
      entry point. if we call init functions before passing control, these
      relocations will not yet have been performed, and the init code will
      potentially make use of invalid pointers.
      
      conceptually, no code provided by the application or third-party
      libraries should run before the application entry point. the
      difference is not observable to programs using the crt1 we provide,
      but it could come into play if custom entry point code is used, so
      it's better to be doing this right anyway.
      c87a5210
    • R
      fix breakage in non-fdpic dynamic linker init/fini processing · 78f43029
      Rich Felker 提交于
      a mistaken #ifdef instead of #if caused conversion of code addresses
      to function descriptors to be performed even on non-fdpic.
      78f43029
    • R
      30fdc06b
    • R
      add real fdpic loading of shared libraries · eaf7ab6e
      Rich Felker 提交于
      previously, the normal ELF library loading code was used even for
      fdpic, so only the kernel-loaded dynamic linker and main app could
      benefit from separate placement of segments and shared text.
      eaf7ab6e
  22. 22 9月, 2015 2 次提交
    • R
      add general fdpic support in dynamic linker and arch support for sh · 7a9669e9
      Rich Felker 提交于
      at this point not all functionality is complete. the dynamic linker
      itself, and main app if it is also loaded by the kernel, take
      advantage of fdpic and do not need constant displacement between
      segments, but additional libraries loaded by the dynamic linker follow
      normal ELF semantics for mapping still. this fully works, but does not
      admit shared text on nommu.
      
      in terms of actual functional correctness, dlsym's results are
      presently incorrect for function symbols, RTLD_NEXT fails to identify
      the caller correctly, and dladdr fails almost entirely.
      
      with the dynamic linker entry point working, support for static pie is
      automatically included, but linking the main application as ET_DYN
      (pie) probably does not make sense for fdpic anyway. ET_EXEC is
      equally relocatable but more efficient at representing relocations.
      7a9669e9
    • R
      factor symbol counting out of dladdr as its own function · 3958144e
      Rich Felker 提交于
      the fdpic code will need to count symbols, and it may be useful
      elsewhere in the future too. counting is trivial as long as sysv hash
      is present, but for gnu-hash-only libraries it's complex.
      
      the behavior of the count is changed slightly: we now include symbols
      that are not accessible by the gnu hash table in the count. this may
      make dladdr slightly slower. if this is a problem, dladdr can subtract
      out the part that should not be accessible. unlike in the old code,
      subtracting this out is easy even in the fast path where sysv hash is
      available too.
      3958144e