1. 20 4月, 2018 4 次提交
    • R
      reintroduce hardening against partially-replaced allocator · b4b1e103
      Rich Felker 提交于
      commit 618b18c7 removed the previous
      detection and hardening since it was incorrect. commit
      72141795 already handled all that
      remained for hardening the static-linked case. in the dynamic-linked
      case, have the dynamic linker check whether malloc was replaced and
      make that information available.
      
      with these changes, the properties documented in commit
      c9f415d7 are restored: if calloc is
      not provided, it will behave as malloc+memset, and any of the
      memalign-family functions not provided will fail with ENOMEM.
      b4b1e103
    • R
      return chunks split off by memalign using __bin_chunk instead of free · 72141795
      Rich Felker 提交于
      this change serves multiple purposes:
      
      1. it ensures that static linking of memalign-family functions will
      pull in the system malloc implementation, thereby causing link errors
      if an attempt is made to link the system memalign functions with a
      replacement malloc (incomplete allocator replacement).
      
      2. it eliminates calls to free that are unpaired with allocations,
      which are confusing when setting breakpoints or tracing execution.
      
      as a bonus, making __bin_chunk external may discourage aggressive and
      unnecessary inlining of it.
      72141795
    • R
      23389b19
    • A
      remove a_ctz_l from arch specific atomic_arch.h · 0c6abb58
      Andre McCurdy 提交于
      Update atomic.h to provide a_ctz_l in all cases (atomic_arch.h should
      now only provide a_ctz_32 and/or a_ctz_64).
      
      The generic version of a_ctz_32 now takes advantage of a_clz_32 if
      available and the generic a_ctz_64 now makes use of a_ctz_32.
      0c6abb58
  2. 25 2月, 2018 1 次提交
    • R
      use idiomatic safe form for FUNLOCK macro · 455bd824
      Rich Felker 提交于
      previously this macro used an odd if/else form instead of the more
      idiomatic do/while(0), making it unsafe against omission of trailing
      semicolon. the omission would make the following statement conditional
      instead of producing an error.
      455bd824
  3. 06 2月, 2018 1 次提交
    • R
      document pthread structure ABI constraints in comments · cc7c300d
      Rich Felker 提交于
      in the original submission of the patch that became commit
      7c709f2d, and in subsequent reading of
      it by others, it was not clear that the new member had to be inserted
      before canary_at_end, or that inserting it at that location was safe.
      add comments to document.
      cc7c300d
  4. 03 2月, 2018 1 次提交
  5. 10 1月, 2018 2 次提交
    • J
      revise the definition of multiple basic locks in the code · 32482f61
      Jens Gustedt 提交于
      In all cases this is just a change from two volatile int to one.
      32482f61
    • J
      new lock algorithm with state and congestion count in one atomic int · 47d0bcd4
      Jens Gustedt 提交于
      A variant of this new lock algorithm has been presented at SAC'16, see
      https://hal.inria.fr/hal-01304108. A full version of that paper is
      available at https://hal.inria.fr/hal-01236734.
      
      The main motivation of this is to improve on the safety of the basic lock
      implementation in musl. This is achieved by squeezing a lock flag and a
      congestion count (= threads inside the critical section) into a single
      int. Thereby an unlock operation does exactly one memory
      transfer (a_fetch_add) and never touches the value again, but still
      detects if a waiter has to be woken up.
      
      This is a fix of a use-after-free bug in pthread_detach that had
      temporarily been patched. Therefore this patch also reverts
      
               c1e27367
      
      This is also the only place where internal knowledge of the lock
      algorithm is used.
      
      The main price for the improved safety is a little bit larger code.
      
      Under high congestion, the scheduling behavior will be different
      compared to the previous algorithm. In that case, a successful
      put-to-sleep may appear out of order compared to the arrival in the
      critical section.
      47d0bcd4
  6. 30 8月, 2017 1 次提交
    • S
      add a_clz_64 helper function · 06fbefd1
      Szabolcs Nagy 提交于
      counts leading zero bits of a 64bit int, undefined on zero input.
      (has nothing to do with atomics, added to atomic.h so target specific
      helper functions are together.)
      
      there is a logarithmic generic implementation and another in terms of
      a 32bit a_clz_32 on targets where that's available.
      06fbefd1
  7. 05 7月, 2017 1 次提交
    • J
      unify the use of FUTEX_PRIVATE · d906fa31
      Jens Gustedt 提交于
      The flag 1<<7 is used in several places for different purposes that are
      not always easy to distinguish. Mark those usages that correspond to the
      flag that is used by the kernel for futexes.
      d906fa31
  8. 22 3月, 2017 1 次提交
    • R
      increase limit on locale name length from 15 to 23 bytes · e6917ece
      Rich Felker 提交于
      the old limit was one byte too short to support locale names of the
      form xx_XX.UTF-8@modifier where modifier is more than 3 bytes, a form
      which various real-world locale names take. the problem could be
      avoided by omitting the useless ".UTF-8" part, but users may need to
      have it present when operating on mixed-libc systems or when it will
      be carried over (e.g. across ssh) to other systems.
      
      the new limit is chosen sufficient for existing/reasonable locale
      names while still keeping the size of setlocale's static buffer small.
      
      also add locale_impl.h to the Makefile's list of headers which force
      rebuild of source files, to prevent dangerously inconsistent object
      files from getting used after this change.
      e6917ece
  9. 13 1月, 2017 1 次提交
    • R
      fix crashes in x32 __tls_get_addr · 1f53e7d0
      rofl0r 提交于
      x32 has another gratuitous difference to all other archs:
      it passes an array of 64bit values to __tls_get_addr().
      usually it is an array of size_t.
      1f53e7d0
  10. 05 1月, 2017 1 次提交
    • R
      treat base 1 as an error in strtol-family functions · 809ff8cf
      Rich Felker 提交于
      ISO C and POSIX only specify behavior for base arguments of 0 and
      2-36; POSIX mandates an EINVAL error for unsupported bases. it's not
      clear that there's a requirement for implementations not to "support"
      additional bases as an extension, but "base 1" did not work in any
      meaningful way anyway, so it should be considered unsupported and thus
      an error.
      809ff8cf
  11. 07 12月, 2016 1 次提交
  12. 12 11月, 2016 3 次提交
    • B
      add s390x port · 15094943
      Bobby Bingham 提交于
      15094943
    • B
      treat null vdso base same as missing · 54482898
      Bobby Bingham 提交于
      On s390x, the kernel provides AT_SYSINFO_EHDR, but sets it to zero, if the
      program being run does not have a program interpreter.  This causes
      problems when running the dynamic linker directly.
      54482898
    • R
      generalize ELF hash table types not to assume 32-bit entries · b418ea1b
      Rich Felker 提交于
      alpha and s390x gratuitously use 64-bit entries (wasting 2x space and
      cache utilization) despite the values always being 32-bit.
      
      based on patch by Bobby Bingham, with changes suggested by Alexander
      Monakov to use the public Elf_Symndx type from link.h (and make it
      properly variable by arch) rather than adding new internal
      infrastructure for handling the type.
      b418ea1b
  13. 09 11月, 2016 1 次提交
    • R
      fix build regression on archs with variable page size · 4078a5c3
      Rich Felker 提交于
      commit 31fb174d used
      DEFAULT_GUARD_SIZE from pthread_impl.h in a static initializer,
      breaking build on archs where its definition, PAGE_SIZE, is not a
      constant. instead, just define DEFAULT_GUARD_SIZE as 4096, the minimal
      page size on any arch we support. pthread_create rounds up to whole
      pages anyway, so defining it to 1 would also work, but a moderately
      meaningful value is nicer to programs that use
      pthread_attr_getguardsize on default-initialized attribute objects.
      4078a5c3
  14. 21 10月, 2016 3 次提交
    • R
      fix minor problem in previous strtod non-nearest rounding bug fix · e314258e
      Rich Felker 提交于
      commit 6ffdc457 set lnz in the code
      path for non-zero digits after a huge string of zeros, but the
      assignment of dc to lnz truncates if the value of dc does not fit in
      int; this is possible for some pathologically long inputs, either via
      strings on 64-bit systems or via scanf-family functions.
      
      instead, simply set lnz to match the point at which we add the
      artificial trailing 1 bit to simulate nonzero digits after a huge
      run of zeros.
      e314258e
    • S
      fix strtod int optimization in non-nearest rounding mode · 6ffdc457
      Szabolcs Nagy 提交于
      the mid-sized integer optimization relies on lnz set up properly
      to mark the last non-zero decimal digit, but this was not done
      if the non-zero digit lied outside the KMAX digits of the base
      10^9 number representation.
      
      so if the fractional part was a very long list of zeros (>2048*9 on
      x86) followed by non-zero digits then the integer optimization could
      kick in discarding the tiny non-zero fraction which can mean wrong
      result on non-nearest rounding mode.
      
      strtof, strtod and strtold were all affected.
      6ffdc457
    • S
      fix strtod and strtof rounding with many trailing zeros · d184a09e
      Szabolcs Nagy 提交于
      in certain cases excessive trailing zeros could cause incorrect
      rounding from long double to double or float in decfloat.
      
      e.g. in strtof("9444733528689243848704.000000", 0) the argument
      is 0x1.000001p+73, exactly halfway between two representible floats,
      this incorrectly got rounded to 0x1.000002p+73 instead of 0x1p+73,
      but with less trailing 0 the rounding was fine.
      
      the fix makes sure that the z index always points one past the last
      non-zero digit in the base 10^9 representation, this way trailing
      zeros don't affect the rounding logic.
      d184a09e
  15. 12 8月, 2016 1 次提交
    • R
      fix pread/pwrite syscall calling convention on sh · 7cc3a28e
      Rich Felker 提交于
      despite sh not generally using register-pair alignment for 64-bit
      syscall arguments, there are arch-specific versions of the syscall
      entry points for pread and pwrite which include a dummy argument for
      alignment before the 64-bit offset argument.
      7cc3a28e
  16. 09 5月, 2016 1 次提交
  17. 18 4月, 2016 1 次提交
  18. 07 3月, 2016 2 次提交
    • R
      add mips64 port · 83933573
      Rich Felker 提交于
      patch by Mahesh Bodapati and Jaydeep Patil of Imagination
      Technologies.
      83933573
    • R
      generalize mips-specific reloc code not to hard-code sym/type encoding · 71392a91
      Rich Felker 提交于
      this change is made in preparation for adding the mips64 port, which
      needs a 64-bit (and mips64-specific) form of the R_INFO macro, but
      it's a better abstraction anyway.
      
      based on part of the mips64 port patch by Mahesh Bodapati and Jaydeep
      Patil of Imagination Technologies.
      71392a91
  19. 24 2月, 2016 1 次提交
  20. 11 2月, 2016 1 次提交
    • R
      fix line-buffered flush omission for odd usage of putc-family functions · 416d1c7a
      Rich Felker 提交于
      as specified, the int argument providing the character to write is
      converted to type unsigned char. for the actual write to buffer,
      conversion happened implicitly via the assignment operator; however,
      the logic to check whether the argument was a newline used the
      original int value. thus usage such as putchar('\n'+0x100) failed to
      produce a flush.
      416d1c7a
  21. 31 1月, 2016 1 次提交
  22. 27 1月, 2016 1 次提交
    • S
      change the internal socketcall selection logic · a5e133bf
      Szabolcs Nagy 提交于
      only use SYS_socketcall if SYSCALL_USE_SOCKETCALL is defined
      internally, otherwise use direct syscalls.
      
      this commit does not change the current behaviour, it is
      preparation for adding direct syscall numbers for i386.
      a5e133bf
  23. 22 1月, 2016 2 次提交
    • R
    • R
      refactor internal atomic.h · 1315596b
      Rich Felker 提交于
      rather than having each arch provide its own atomic.h, there is a new
      shared atomic.h in src/internal which pulls arch-specific definitions
      from arc/$(ARCH)/atomic_arch.h. the latter can be extremely minimal,
      defining only a_cas or new ll/sc type primitives which the shared
      atomic.h will use to construct everything else.
      
      this commit avoids making heavy changes to the individual archs'
      atomic implementations. definitions which are identical or
      near-identical to what the new shared atomic.h would produce have been
      removed, but otherwise the changes made are just hooking up the
      arch-specific files to the new infrastructure. major changes to take
      advantage of the new system will come in subsequent commits.
      1315596b
  24. 21 1月, 2016 1 次提交
  25. 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
  26. 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
  27. 12 11月, 2015 2 次提交
    • R
      eliminate use of SHARED macro to suppress visibility attributes · 8a8fdf63
      Rich Felker 提交于
      this is the first and simplest stage of removal of the SHARED macro,
      which will eventually allow libc.a and libc.so to be produced from the
      same object files.
      
      the original motivation for these #ifdefs which are now being removed
      was to allow building a static-only libc using a compiler that does
      not support visibility. however, SHARED was the wrong condition to
      test for this anyway; various assembly-language sources refer to
      hidden symbols and declare them with the .hidden directive, making it
      wrong to define the referenced symbols as non-hidden. if there is a
      need in the future to build libc using compilers that lack visibility,
      support could be moved to the build system or perhaps the __PIC__
      macro could be checked instead of SHARED.
      8a8fdf63
    • 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
  28. 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