1. 22 4月, 2014 2 次提交
    • R
      micro-optimize some startup code for size · 9b52ab1c
      Rich Felker 提交于
      moving the call to __init_ssp from __init_security to __init_libc
      makes __init_security a leaf function, which allows the compiler to
      make it smaller. __init_libc is already non-leaf, and the additional
      call makes no difference to the amount of register spillage.
      
      in addition, it really made no sense for the call to __init_ssp to be
      buried inside __init_security rather than parallel with other init
      functions.
      9b52ab1c
    • R
      allow zoneinfo-path-relative filenames with no slashes in TZ variable · 5c4f11d9
      Rich Felker 提交于
      since the form TZ=name is reserved for POSIX-form time zone strings,
      TZ=:name needs to be used when the zoneinfo filename is in the
      top-level zoneinfo directory and therefore does not contain a slash.
      previously the leading colon was merely dropped, making it impossible
      to access such zones without a full absolute pathname.
      
      changes based on patch by Timo Teräs.
      5c4f11d9
  2. 20 4月, 2014 1 次提交
  3. 19 4月, 2014 1 次提交
  4. 18 4月, 2014 1 次提交
  5. 17 4月, 2014 1 次提交
    • R
      add options when explicitly invoking dynamic loader · de45164e
      Rich Felker 提交于
      so far the options are --library-path and --preload which override the
      corresponding environment variables, and --list which forces the
      behavior of ldd even if the invocation name is not ldd. both the
      two-arg form and the one-arg form using an equals sign are supported.
      
      based loosely on a patch proposed by Rune.
      de45164e
  6. 16 4月, 2014 8 次提交
    • R
      release 1.1.0 · b1ef8067
      Rich Felker 提交于
      b1ef8067
    • R
      add working vdso clock_gettime support, including static linking · 58e75db4
      Rich Felker 提交于
      the vdso symbol lookup code is based on the original 2011 patch by
      Nicholas J. Kain, with some streamlining, pointer arithmetic fixes,
      and one symbol version matching fix.
      
      on the consumer side (clock_gettime), per-arch macros for the
      particular symbol name and version to lookup are added in
      syscall_arch.h, and no vdso code is pulled in on archs which do not
      define these macros. at this time, vdso is enabled only on x86_64.
      
      the vdso support at the dynamic linker level is no longer useful to
      libc, but is left in place for the sake of debuggers (which may need
      the vdso in the link map to find its functions) and possibly use with
      dlsym.
      58e75db4
    • R
      fix deadlock race in pthread_once · 0d0c2f40
      Rich Felker 提交于
      at the end of successful pthread_once, there was a race window during
      which another thread calling pthread_once would momentarily change the
      state back from 2 (finished) to 1 (in-progress). in this case, the
      status was immediately changed back, but with no wake call, meaning
      that waiters which arrived during this short window could block
      forever. there are two possible fixes. one would be adding the wake to
      the code path where it was missing. but it's better just to avoid
      reverting the status at all, by using compare-and-swap instead of
      swap.
      0d0c2f40
    • S
      fix RLIMIT_ constants for mips · fcea534e
      Szabolcs Nagy 提交于
      The mips arch is special in that it uses different RLIMIT_
      numbers than other archs, so allow bits/resource.h to override
      the default RLIMIT_ numbers (empty on all archs except mips).
      Reported by orc.
      fcea534e
    • R
      96315d27
    • R
      add namespace-protected name for sysinfo function · de20a8ff
      Rich Felker 提交于
      it will be needed to implement some things in sysconf, and the syscall
      can't easily be used directly because the x32 syscall uses the wrong
      structure layout. the l (uncreative, for "linux") prefix is used since
      the symbol name __sysinfo is already taken for AT_SYSINFO from the aux
      vector.
      
      the way the x32 override of this function works is also changed to be
      simpler and avoid the useless jump instruction.
      de20a8ff
    • R
      in sysconf, use getrlimit function rather than raw syscall for rlimits · 6cf7d17f
      Rich Felker 提交于
      the syscall is deprecated (replaced by prlimit64) and does not work
      correctly on x32. this change mildly increases size, but is likely
      needed anyway for newer archs that might omit deprecated syscalls.
      6cf7d17f
    • R
      avoid linear-time if/else special cases in sysconf · 233767b4
      Rich Felker 提交于
      the previous handling of cases that could not fit in the 16-bit table
      or which required non-constant results was extremely ugly and could
      not scale. the new code remaps these keys into a contiguous range
      that's efficient for a switch statement.
      233767b4
  7. 15 4月, 2014 2 次提交
  8. 12 4月, 2014 2 次提交
    • R
      use hidden visibility rather than protected for syscall internals · 83c98aac
      Rich Felker 提交于
      the use of visibility at all is purely an optimization to avoid the
      need for the caller to load the GOT register or similar to prepare for
      a call via the PLT. there is no reason for these symbols to be
      externally visible, so hidden works just as well as protected, and
      using protected visibility is undesirable due to toolchain bugs and
      the lack of testing it receives.
      
      in particular, GCC's microblaze target is known to generate symbolic
      relocations in the GOT for functions with protected visibility. this
      in turn results in a dynamic linker which crashes under any nontrivial
      usage that requires making a syscall before symbolic relocations are
      processed.
      83c98aac
    • S
      math: fix aliasing violation in long double wrappers · 73c870ed
      Szabolcs Nagy 提交于
      modfl and sincosl were passing long double* instead of double*
      to the wrapped double precision functions (on archs where long
      double and double have the same size).
      This is fixed now by using temporaries (this is not optimized
      to a single branch so the generated code is a bit bigger).
      Found by Morten Welinder.
      73c870ed
  9. 10 4月, 2014 1 次提交
    • T
      fix search past the end of haystack in memmem · 6fbdeff0
      Timo Teräs 提交于
      to optimize the search, memchr is used to find the first occurrence of
      the first character of the needle in the haystack before switching to
      a search for the full needle. however, the number of characters
      skipped by this first step were not subtracted from the haystack
      length, causing memmem to search past the end of the haystack.
      6fbdeff0
  10. 08 4月, 2014 1 次提交
    • R
      fix printf rounding with %g for some corner case midpoints · e94d0692
      Rich Felker 提交于
      the subsequent rounding code assumes the end pointer (z) accurately
      reflects the end of significance in the decimal expansion, but for
      certain large integers, spurious trailing zero slots were left behind
      when applying the binary exponent.
      
      issue reported by Morten Welinder; the analysis of the cause was
      performed by nsz, who also proposed this change.
      e94d0692
  11. 07 4月, 2014 6 次提交
    • R
      fix arm atomic asm register constraint · efe07b0f
      Rich Felker 提交于
      the "m" constraint could give a memory reference with an offset that's
      not compatible with ldrex/strex, so the arm-specific "Q" constraint is
      needed instead.
      efe07b0f
    • R
      use inline atomics and thread pointer on arm models supporting them · 1974bffa
      Rich Felker 提交于
      this is perhaps not the optimal implementation; a_cas still compiles
      to nested loops due to the different interface contracts of the kuser
      helper cas function (whose contract this patch implements) and the
      a_cas function (whose contract mimics the x86 cmpxchg). fixing this
      may be possible, but it's more complicated and thus deferred until a
      later time.
      
      aside from improving performance and code size, this patch also
      provides a means of producing binaries which can run on hardened
      kernels where the kuser helpers have been disabled. however, at
      present this requires producing binaries for armv6k or later, which
      will not run on older cpus. a real solution to the problem of kernels
      that omit the kuser helpers would be runtime detection, so that
      universal binaries which run on all arm cpu models can also be
      compatible with all kernel hardening profiles. robust detection
      however is a much harder problem, and will be addressed at a later
      time.
      1974bffa
    • R
      add getauxval function · 21ada94c
      Rich Felker 提交于
      in a sense this implementation is incomplete since it doesn't provide
      the HWCAP_* macros for use with AT_HWCAP, which is perhaps the most
      important intended usage case for getauxval. they will be added at a
      later time.
      21ada94c
    • R
      fix failure of printf %g to strip trailing zeros in some cases · 89740868
      Rich Felker 提交于
      the code to strip trailing zeros was only looking in the last slot for
      up to 9 zeros, assuming that the rounding code had already removed
      fully-zero slots from the end. however, this ignored cases where the
      rounding code did not run at all, which occur when the value being
      printed is exactly representable in the requested precision.
      
      the simplest solution is to move the code that strips trailing zero
      slots to run unconditionally, immediately after rounding, rather than
      as the last step of rounding.
      89740868
    • R
      fix carry into uninitialized slots during printf floating point rounding · 109048e0
      Rich Felker 提交于
      in cases where rounding caused a carry, the slot into which the carry
      was taking place was unconditionally treated as valid, despite the
      possibility that it could be a new slot prior to the beginning of the
      existing non-rounded number. in theory this could lead to unbounded
      runaway carry, but in order for that to happen, the whole
      uninitialized buffer would need to have been pre-filled with 32-bit
      integer values greater than or equal to 999999999.
      
      patch based on proposed fix by Morten Welinder, who also discovered
      and reported the bug.
      109048e0
    • R
      remove some cruft from libc/tls init code · 7e8b0761
      Rich Felker 提交于
      7e8b0761
  12. 05 4月, 2014 1 次提交
  13. 03 4月, 2014 5 次提交
    • R
      add __sigsetjmp ABI-compat alias for sigsetjmp · b9b2db2f
      Rich Felker 提交于
      b9b2db2f
    • S
      remove struct elem entirely from hsearch.c · 141d3b5c
      sin 提交于
      There are two changes here, both of which make sense to be done in a
      single patch:
      
      - Remove hash from struct elem and compute it at runtime wherever
        necessary.
      - Eliminate struct elem and use ENTRY directly.
      
      As a result we cut down on the memory usage as each element in the
      hash table now contains only an ENTRY not an ENTRY + size_t for the
      hash. The downside is that the hash needs to be computed at runtime.
      141d3b5c
    • S
      implement hcreate_r, hdestroy_r and hsearch_r · fe1ba7db
      sin 提交于
      the size and alignment of struct hsearch_data are matched to the glibc
      definition for binary compatibility. the members of the structure do
      not match, which should not be a problem as long as applications
      correctly treat the structure as opaque.
      
      unlike the glibc implementation, this version of hcreate_r does not
      require the caller to zero-fill the structure before use.
      fe1ba7db
    • R
      avoid malloc failure for small requests when brk can't be extended · 54463033
      Rich Felker 提交于
      this issue mainly affects PIE binaries and execution of programs via
      direct invocation of the dynamic linker binary: depending on kernel
      behavior, in these cases the initial brk may be placed at at location
      where it cannot be extended, due to conflicting adjacent maps.
      
      when brk fails, mmap is used instead to expand the heap. in order to
      avoid expensive bookkeeping for managing fragmentation by merging
      these new heap regions, the minimum size for new heap regions
      increases exponentially in the number of regions. this limits the
      number of regions, and thereby the number of fixed fragmentation
      points, to a quantity which is logarithmic with respect to the size of
      virtual address space and thus negligible. the exponential growth is
      tuned so as to avoid expanding the heap by more than approximately 50%
      of its current total size.
      54463033
    • R
      fix microblaze syscall register clobbers · 91d5aa06
      Rich Felker 提交于
      the kernel entry point for syscalls on microblaze nominally saves and
      restores all registers, and testing on qemu always worked since qemu
      behaves this way too. however, the real kernel treats r3:r4 as a
      potential 64-bit return value from the syscall function, and copies
      both over top of the saved registers before returning to userspace.
      thus, we need to treat r4 as always-clobbered.
      91d5aa06
  14. 26 3月, 2014 5 次提交
  15. 25 3月, 2014 3 次提交
    • R
      fix pointer type mismatch and misplacement of const · 689e0e6b
      Rich Felker 提交于
      689e0e6b
    • T
      fix confstr return value · 0a8d9828
      Timo Teräs 提交于
      per the specification, the terminating null byte is counted.
      0a8d9828
    • R
      always initialize thread pointer at program start · dab441ae
      Rich Felker 提交于
      this is the first step in an overhaul aimed at greatly simplifying and
      optimizing everything dealing with thread-local state.
      
      previously, the thread pointer was initialized lazily on first access,
      or at program startup if stack protector was in use, or at certain
      random places where inconsistent state could be reached if it were not
      initialized early. while believed to be fully correct, the logic was
      fragile and non-obvious.
      
      in the first phase of the thread pointer overhaul, support is retained
      (and in some cases improved) for systems/situation where loading the
      thread pointer fails, e.g. old kernels.
      
      some notes on specific changes:
      
      - the confusing use of libc.main_thread as an indicator that the
        thread pointer is initialized is eliminated in favor of an explicit
        has_thread_pointer predicate.
      
      - sigaction no longer needs to ensure that the thread pointer is
        initialized before installing a signal handler (this was needed to
        prevent a situation where the signal handler caused the thread
        pointer to be initialized and the subsequent sigreturn cleared it
        again) but it still needs to ensure that implementation-internal
        thread-related signals are not blocked.
      
      - pthread tsd initialization for the main thread is deferred in a new
        manner to minimize bloat in the static-linked __init_tp code.
      
      - pthread_setcancelstate no longer needs special handling for the
        situation before the thread pointer is initialized. it simply fails
        on systems that cannot support a thread pointer, which are
        non-conforming anyway.
      
      - pthread_cleanup_push/pop now check for missing thread pointer and
        nop themselves out in this case, so stdio no longer needs to avoid
        the cancellable path when the thread pointer is not available.
      
      a number of cases remain where certain interfaces may crash if the
      system does not support a thread pointer. at this point, these should
      be limited to pthread interfaces, and the number of such cases should
      be fewer than before.
      dab441ae