1. 02 7月, 2014 3 次提交
  2. 30 6月, 2014 2 次提交
    • R
      fix regression in mips dynamic linker · 2d8cc92a
      Rich Felker 提交于
      this issue caused the address of functions in shared libraries to
      resolve to their PLT thunks in the main program rather than their
      correct addresses. it was observed causing crashes, though the
      mechanism of the crash was not thoroughly investigated. since the
      issue is very subtle, it calls for some explanation:
      
      on all well-behaved archs, GOT entries that belong to the PLT use a
      special relocation type, typically called JMP_SLOT, so that the
      dynamic linker can avoid having the jump destinations for the PLT
      resolve to PLT thunks themselves (they also provide a definition for
      the symbol, which must be used whenever the address of the function is
      taken so that all DSOs see the same address).
      
      however, the traditional mips PIC ABI lacked such a JMP_SLOT
      relocation type, presumably because, due to the way PIC works, the
      address of the PLT thunk was never needed and could always be ignored.
      
      prior to commit adf94c19, the mips
      version of reloc.h contained a hack that caused all symbol lookups to
      be treated like JMP_SLOT, inhibiting undefined symbols from ever being
      used to resolve symbolic relocations. this hack goes all the way back
      to commit babf8201, when the mips
      dynamic linker was first made usable.
      
      during the recent refactoring to eliminate arch-specific relocation
      processing (commit adf94c19), this
      hack was overlooked and no equivalent functionality was provided in
      the new code.
      
      fixing the problem is not as simple as adding back an equivalent hack,
      since there is now also a "non-PIC ABI" that can be used for the main
      executable, which actually does use a PLT. the closest thing to
      official documentation I could find for this ABI is nonpic.txt,
      attached to Message-ID: 20080701202236.GA1534@caradoc.them.org, which
      can be found in the gcc mailing list archives and elsewhere. per this
      document, undefined symbols corresponding to PLT thunks have the
      STO_MIPS_PLT bit set in the symbol's st_other field. thus, I have
      added an arch-specific rule for mips, applied at the find_sym level
      rather than the relocation level, to reject undefined symbols with the
      STO_MIPS_PLT bit clear.
      
      the previous hack of treating all mips relocations as JMP_SLOT-like,
      rather than rejecting the unwanted symbols in find_sym, probably also
      caused dlsym to wrongly return PLT thunks in place of the correct
      address of a function under at least some conditions. this should now
      be fixed, at least for global-scope symbol lookups.
      2d8cc92a
    • R
      fix regression in dynamic linker error reporting · 9a4ad022
      Rich Felker 提交于
      due to a mistake when refactoring the error printing for the dynamic
      linker (commit 7c73cacd), all messages
      were suppressed and replaced by blank lines.
      9a4ad022
  3. 26 6月, 2014 4 次提交
  4. 25 6月, 2014 1 次提交
  5. 24 6月, 2014 1 次提交
  6. 22 6月, 2014 5 次提交
    • R
      add __sysv_signal abi-compat alias for the signal function · 6ce1fade
      Rich Felker 提交于
      it should be noted that the "real" __sysv_signal, which we do not
      implement, is semantically different from signal. references to
      __sysv_signal arise in code built against glibc under certain
      combinations of feature test macros, and are almost surely
      unintentional since the legacy sysv signal behavior has fundamental
      race conditions that cannot be worked around and which make it
      impossible to use safely.
      6ce1fade
    • R
      add __xmknod and __xmknodat abi-compat functions · 1fd0f6e3
      Rich Felker 提交于
      these are put alongside the similar functions for __xstat, etc. in
      __xstat.c to avoid bloating the number of source files.
      1fd0f6e3
    • R
      consolidate __xstat abi-compat functions into a single source file · 76f2bcc7
      Rich Felker 提交于
      these are mostly intended for use with dynamic linking (although they
      can also be used statically with object files compiled against glibc
      headers), so having them broken down into separate source files to
      optimize for static linking is unlikely to be worth the cost having
      more files in the source tree (which contributes to libc.a overhead,
      compile time, link time, ar/linker command line size exhaustion, and
      so on).
      76f2bcc7
    • R
      implement fmtmsg function · 5474a346
      Rich Felker 提交于
      contributed by Isaac Dunham. this seems to be the last interface that
      was missing for complete POSIX 2008 base + XSI coverage.
      5474a346
    • R
  7. 21 6月, 2014 2 次提交
    • R
      remove hack in syslog.h that resulted in aliasing violations · 70d9c303
      Rich Felker 提交于
      this issue affected the prioritynames and facilitynames arrays which
      are only provided when requested (usually by syslogd implementations)
      and which are presently defined as compound literals. the aliasing
      violation seems to have been introduced as a workaround for bad
      behavior by gcc's -Wwrite-strings option, but it caused compilers to
      completely optimize out the contents of prioritynames and
      facilitynames since, under many usage cases, the aliasing rules prove
      that the contents are never accessed.
      70d9c303
    • R
      remove optimization-inhibiting behavior from configure's --enable-debug · 4ad3588c
      Rich Felker 提交于
      this behavior turned out to be counter-intuitive to users and in any
      case it's unnecessary. optimization can be disabled explicitly using
      the --disable-optimize option, or both can be achieved without any
      enable/disable options by passing CFLAGS="-O0 -g".
      4ad3588c
  8. 20 6月, 2014 5 次提交
  9. 19 6月, 2014 6 次提交
    • R
      separate __tls_get_addr implementation from dynamic linker/init_tls · 5ba238e1
      Rich Felker 提交于
      such separation serves multiple purposes:
      
      - by having the common path for __tls_get_addr alone in its own
        function with a tail call to the slow case, code generation is
        greatly improved.
      
      - by having __tls_get_addr in it own file, it can be replaced on a
        per-arch basis as needed, for optimization or ABI-specific purposes.
      
      - by removing __tls_get_addr from __init_tls.c, a few bytes of code
        are shaved off of static binaries (which are unlikely to use this
        function unless the linker messed up).
      5ba238e1
    • R
      add tlsdesc support for i386 · 4e0b4a5d
      Rich Felker 提交于
      4e0b4a5d
    • R
      optimize i386 ___tls_get_addr asm · 880c479f
      Rich Felker 提交于
      880c479f
    • R
      change dynamic TLS installation strategy to optimize access · e75b16cf
      Rich Felker 提交于
      previously, accesses to dynamic TLS had to check two conditions before
      being able to use a dtv slot: (1) that the module index was within the
      bounds of the current dtv size, and (2) that the dynamic tls for the
      requested module index was already installed in the dtv.
      
      this commit changes the installation strategy so that, whenever an
      attempt is made to access dynamic TLS that's not yet installed in the
      dtv, the dynamic TLS for all lower-index modules is also installed.
      thus it provides a new invariant: if a given module index is within
      the bounds of the current dtv size, we automatically know that its TLS
      is installed and directly available. the requirement that the second
      condition (above) be checked is eliminated.
      e75b16cf
    • R
      add arch-generic support for tlsdesc relocations to dynamic linker · 9d15d5e7
      Rich Felker 提交于
      this code is non-functional without further changes to link up the
      arch-specific reloc types for tlsdesc and add asm implementations of
      __tlsdesc_static and __tlsdesc_dynamic.
      9d15d5e7
    • R
      fix incorrect comparison loop condition in memmem · cef0f289
      Rich Felker 提交于
      the logic for this loop was copied from null-terminated-string logic
      in strstr without properly adapting it to work with explicit lengths.
      
      presumably this error could result in false negatives (wrongly
      comparing past the end of the needle/haystack), false positives
      (stopping comparison early when the needle contains null bytes), and
      crashes (from runaway reads past the end of mapped memory).
      cef0f289
  10. 18 6月, 2014 4 次提交
    • R
      reduce code duplication in dynamic linker error paths · 7c73cacd
      Rich Felker 提交于
      eventually this should help making dlerror thread-safe too.
      7c73cacd
    • R
      refactor to remove arch-specific relocation code from dynamic linker · adf94c19
      Rich Felker 提交于
      this was one of the main instances of ugly code duplication: all archs
      use basically the same types of relocations, but roughly equivalent
      logic was duplicated for each arch to account for the different naming
      and numbering of relocation types and variation in whether REL or RELA
      records are used.
      
      as an added bonus, both REL and RELA are now supported on all archs,
      regardless of which is used by the standard toolchain.
      adf94c19
    • R
      fix powerpc dynamic linker thread-pointer-relative relocations · 94cf991b
      Rich Felker 提交于
      processing of R_PPC_TPREL32 was ignoring the addend provided by the
      RELA-style relocation and instead using the inline value as the
      addend. this presumably broke dynamic-linked access to initial TLS in
      cases where the addend was nonzero.
      94cf991b
    • R
      multiple fixes to sh (superh) dynamic linker relocations · f4cc2760
      Rich Felker 提交于
      the following issues are fixed:
      
      - R_SH_REL32 was adding the load address of the module being relocated
        to the result. this seems to have been a mistake in the original
        port, since it does not match other dynamic linker implementations
        and since adding a difference between two addresses (the symbol
        value and the relocation address) to a load address does not make
        sense.
      
      - R_SH_TLS_DTPMOD32 was wrongly accepting an inline addend (i.e. using
        += rather than = on *reloc_addr) which makes no sense; addition is
        not an operation that's defined on module ids.
      
      - R_SH_TLS_DTPOFF32 and R_SH_TLS_TPOFF32 were wrongly using inline
        addends rather than the RELA-provided addends.
      
      in addition, handling of R_SH_GLOB_DAT, R_SH_JMP_SLOT, and R_SH_DIR32
      are merged to all honor the addend. the first two should not need it
      for correct usage generated by toolchains, but other dynamic linkers
      allow addends here, and it simplifies the code anyway.
      
      these issues were spotted while reviewing the code for the purpose of
      refactoring this part of the dynamic linker. no testing was performed.
      f4cc2760
  11. 16 6月, 2014 1 次提交
    • R
      dynamic linker: permit error returns from arch-specific reloc function · bfa09700
      Rich Felker 提交于
      the immediate motivation is supporting TLSDESC relocations which
      require allocation and thus may fail (unless we pre-allocate), but
      this mechanism should also be used for throwing an error on
      unsupported or invalid relocation types, and perhaps in certain cases,
      for reporting when a relocation is not satisfiable.
      bfa09700
  12. 14 6月, 2014 1 次提交
  13. 12 6月, 2014 1 次提交
  14. 11 6月, 2014 1 次提交
    • R
      fail configure on --enable-shared if -Bsymbolic-functions doesn't work · d79b2778
      Rich Felker 提交于
      previously, a warning was issued in this case no matter what, even if
      --disable-shared was used. now, the default for --enable-shared is
      changed from "yes" to "auto", and the warning is issued by default,
      but becomes an error if --enable-shared is used, and the test is
      suppressed completely if --disable-shared is used.
      d79b2778
  15. 10 6月, 2014 3 次提交
    • R
      simplify errno implementation · ac31bf27
      Rich Felker 提交于
      the motivation for the errno_ptr field in the thread structure, which
      this commit removes, was to allow the main thread's errno to keep its
      address when lazy thread pointer initialization was used. &errno was
      evaluated prior to setting up the thread pointer and stored in
      errno_ptr for the main thread; subsequently created threads would have
      errno_ptr pointing to their own errno_val in the thread structure.
      
      since lazy initialization was removed, there is no need for this extra
      level of indirection; __errno_location can simply return the address
      of the thread's errno_val directly. this does cause &errno to change,
      but the change happens before entry to application code, and thus is
      not observable.
      ac31bf27
    • R
      replace all remaining internal uses of pthread_self with __pthread_self · df15168c
      Rich Felker 提交于
      prior to version 1.1.0, the difference between pthread_self (the
      public function) and __pthread_self (the internal macro or inline
      function) was that the former would lazily initialize the thread
      pointer if it was not already initialized, whereas the latter would
      crash in this case. since lazy initialization is no longer supported,
      use of pthread_self no longer makes sense; it simply generates larger,
      slower code.
      df15168c
    • R
      add thread-pointer support for pre-2.6 kernels on i386 · 64e32287
      Rich Felker 提交于
      such kernels cannot support threads, but the thread pointer is also
      important for other purposes, most notably stack protector. without a
      valid thread pointer, all code compiled with stack protector will
      crash. the same applies to any use of thread-local storage by
      applications or libraries.
      
      the concept of this patch is to fall back to using the modify_ldt
      syscall, which has been around since linux 1.0, to setup the gs
      segment register. since the kernel does not have a way to
      automatically assign ldt entries, use of slot zero is hard-coded. if
      this fallback path is used, __set_thread_area returns a positive value
      (rather than the usual zero for success, or negative for error)
      indicating to the caller that the thread pointer was successfully set,
      but only for the main thread, and that thread creation will not work
      properly. the code in __init_tp has been changed accordingly to record
      this result for later use by pthread_create.
      64e32287