1. 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
  2. 26 3月, 2014 5 次提交
  3. 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
  4. 24 3月, 2014 2 次提交
    • R
      reduce static linking overhead from TLS support by inlining mmap syscall · 98221c36
      Rich Felker 提交于
      the external mmap function is heavy because it has to handle error
      reporting that the kernel cannot do, and has to do some locking for
      arcane race-condition-avoidance purposes. for allocating initial TLS,
      we do not need any of that; the raw syscall suffices.
      
      on i386, this change shaves off 13% of the size of .text for the empty
      program.
      98221c36
    • R
      include header that declares __syscall_ret where it's defined · 30c1205a
      Rich Felker 提交于
      in general, we aim to always include the header that's declaring a
      function before defining it so that the compiler can check that
      prototypes match.
      
      additionally, the internal syscall.h declares __syscall_ret with a
      visibility attribute to improve code generation for shared libc (to
      prevent gratuitous GOT-register loads). this declaration should be
      visible at the point where __syscall_ret is defined, too, or the
      inconsistency could theoretically lead to problems at link-time.
      30c1205a
  5. 20 3月, 2014 6 次提交
  6. 19 3月, 2014 8 次提交
  7. 18 3月, 2014 2 次提交
    • R
      make configure accept alternate gcc tuples for x32 · f162c064
      Rich Felker 提交于
      the previous pattern required "x32" to be used as the second field of
      the gcc tuple, which is usually reserved for vendor use and not
      appropriate as an ABI specifier. with this change, putting "x32" at
      the end of the tuple, the way ABI specifiers are normally done, is
      also permitted.
      f162c064
    • R
      x32: fix struct statfs · 797f9a32
      rofl0r 提交于
      the omission of the padding was uncovered by the latest regression
      statvfs regression test added to libc-test.
      797f9a32
  8. 17 3月, 2014 2 次提交
    • R
      fix negated error codes from ptsname_r · 66193171
      Rich Felker 提交于
      the incorrect error codes also made their way into errno when
      __ptsname_r was called by plain ptsname, which reports errors via
      errno rather than a return value.
      66193171
    • B
      superh: fix dynamic linking of __fpscr_values · 611eabd4
      Bobby Bingham 提交于
      Applications ended up with copy relocations for this array, which
      resulted in libc's references to this array pointing to the
      application's copy.  The dynamic linker, however, can require this array
      before the application is relocated, and therefore before the
      application's copy of this array is initialized.  This resulted in
      garbage being loaded into FPSCR before executing main, which violated
      the ABI.
      
      We fix this by putting the array in crt1 and making the libc copy
      private.  This prevents libc's reference to the array from pointing to
      an uninitialized copy in the application.
      611eabd4
  9. 14 3月, 2014 1 次提交
    • R
      semctl: fix UB causing crashes on powerpc · 2b47a7af
      rofl0r 提交于
      it's UB to fetch variadic args when none are passed, and this caused
      real crashes on ppc due to its calling convention, which defines that
      for variadic functions aggregate types be passed as pointers.
      the assignment caused that pointer to get dereferenced, resulting in
      a crash.
      2b47a7af
  10. 13 3月, 2014 1 次提交
    • S
      fix statfs struct on mips · 7673acd3
      Szabolcs Nagy 提交于
      The mips statfs struct layout is different than on other archs, so the
      statfs, fstatfs, statvfs and fstatvfs APIs were broken on mips.
      Now the ordering is fixed, the types are kept consistent with other archs.
      7673acd3
  11. 12 3月, 2014 4 次提交
    • S
      fix semid_ds structure on mips · 3ceb89ed
      Szabolcs Nagy 提交于
      This used to be broken when all archs had the same semid_ds definition:
      there is no padding around the time_t members on mips.
      3ceb89ed
    • R
      fix socket.h struct msghdr member types on powerpc · 514c2dd2
      Rich Felker 提交于
      these were incorrectly copied from the kernel, whose ABI matches the
      POSIX requirements but with the wrong underlying types and wrong
      signedness.
      514c2dd2
    • R
      fix sysvipc structures on powerpc · ad66ae93
      Rich Felker 提交于
      these have been wrong for a long time and were never detected or
      corrected. powerpc needs some gratuitous extra padding/reserved slots
      in ipc_perm, big-endian ordering for the padding of time_t slots that
      was intended by the kernel folks to allow a transition to 64-bit
      time_t, and some minor gratuitous reordering of struct members.
      ad66ae93
    • R
      move struct semid_ds to from shared sys/sem.h to bits · f6e2f7e1
      Rich Felker 提交于
      the definition was found to be incorrect at least for powerpc, and
      fixing this cleanly requires making the definition arch-specific. this
      will allow cleaning up the definition for other archs to make it more
      specific, and reversing some of the ugliness (time_t hacks) introduced
      with the x32 port.
      
      this first commit simply copies the existing definition to each arch
      without any changes. this is intentional, to make it easier to review
      changes made on a per-arch basis.
      f6e2f7e1
  12. 10 3月, 2014 1 次提交