1. 17 7月, 2014 2 次提交
    • R
      work around constant folding bug 61144 in gcc 4.9.0 and 4.9.1 · a6adb2bc
      Rich Felker 提交于
      previously we detected this bug in configure and issued advice for a
      workaround, but this turned out not to work. since then gcc 4.9.0 has
      appeared in several distributions, and now 4.9.1 has been released
      without a fix despite this being a wrong code generation bug which is
      supposed to be a release-blocker, per gcc policy.
      
      since the scope of the bug seems to affect only data objects (rather
      than functions) whose definitions are overridable, and there are only
      a very small number of these in musl, I am just changing them from
      const to volatile for the time being. simply removing the const would
      be sufficient to make gcc 4.9.1 work (the non-const case was
      inadvertently fixed as part of another change in gcc), and this would
      also be sufficient with 4.9.0 if we forced -O0 on the affected files
      or on the whole build. however it's cleaner to just remove all the
      broken compiler detection and use volatile, which will ensure that
      they are never constant-folded. the quality of a non-broken compiler's
      output should not be affected except for the fact that these objects
      are no longer const and thus possibly add a few bytes to data/bss.
      
      this change can be reconsidered and possibly reverted at some point in
      the future when the broken gcc versions are no longer relevant.
      a6adb2bc
    • R
      simplify __stdio_exit static linking logic · c463e11e
      Rich Felker 提交于
      the purpose of this logic is to avoid linking __stdio_exit unless any
      stdio reads (which might require repositioning the file offset at exit
      time) or writes (which might require flushing at exit time) could have
      been performed.
      
      previously, exit called two wrapper functions for __stdio_exit named
      __flush_on_exit and __seek_on_exit. both of these functions actually
      performed both tasks (seek and flushing) by calling the underlying
      __stdio_exit. in order to avoid doing this twice, an overridable data
      object __towrite_used was used to cause __seek_on_exit to act as a nop
      when __towrite was linked.
      
      now, exit only makes one call, directly to __stdio_exit. this is
      satisfiable by a weak dummy definition in exit.c, but the real
      definition is pulled in by either __toread.c or __towrite.c through
      their referencing a symbol which is defined only in __stdio_exit.c.
      c463e11e
  2. 12 7月, 2014 4 次提交
    • R
      implement the LOG_CONS option in syslog · 781f26bc
      Rich Felker 提交于
      this was previously a no-op, somewhat intentionally, because I failed
      to understand that it only has an effect when sending to the logging
      facility fails and thus is not the nuisance that it would be if always
      sent output to the console.
      781f26bc
    • R
      suppress early syslog return when log socket cannot be opened · a64a045d
      Rich Felker 提交于
      this behavior is no longer valid in general, and was never necessary.
      if the LOG_PERROR option is set, output to stderr could still succeed.
      also, when the LOG_CONS option is added, it will need syslog to
      proceed even if opening the log socket fails.
      a64a045d
    • R
      implement the LOG_PERROR option in syslog · b8c4cf61
      Rich Felker 提交于
      this is a nonstandard feature, but easy and inexpensive to add. since
      the corresponding macro has always been defined in our syslog.h, it
      makes sense to actually support it. applications may reasonably be
      using the presence of the macro to assume that the feature is
      supported.
      
      the behavior of omitting the 'header' part of the log message does not
      seem to be well-documented, but matches other implementations (at
      least glibc) which have this option.
      
      based on a patch by Clément Vasseur, but simplified using %n.
      b8c4cf61
    • C
      fix the %m specifier in syslog · da271181
      Clément Vasseur 提交于
      errno must be saved upon vsyslog entry, otherwise its value could be
      changed by some libc function before reaching the %m handler in
      vsnprintf.
      da271181
  3. 11 7月, 2014 2 次提交
  4. 09 7月, 2014 1 次提交
    • R
      fix typo in microblaze setjmp asm · 72967368
      Rich Felker 提交于
      r24 was wrongly being saved at a misaligned offset of 30 rather than
      the correct offset of 40 in the jmp_buf. the exact effects of this
      error have not been studied, but it's clear that the value of r24 was
      lost across setjmp/longjmp and the saved values of r21 and/or r22 may
      also have been corrupted.
      72967368
  5. 07 7月, 2014 2 次提交
  6. 06 7月, 2014 2 次提交
    • R
      fix multiple issues in legacy function getpass · ea496d6c
      Rich Felker 提交于
      1. failure to output a newline after the password is read
      2. fd leaks via missing FD_CLOEXEC
      3. fd leaks via failure-to-close when any of the standard streams are
         closed at the time of the call
      4. wrongful fallback to use of stdin when opening /dev/tty fails
      5. wrongful use of stderr rather than /dev/tty for prompt
      6. failure to report error reading password
      ea496d6c
    • R
      eliminate use of cached pid from thread structure · 83dc6eb0
      Rich Felker 提交于
      the main motivation for this change is to remove the assumption that
      the tid of the main thread is also the pid of the process. (the value
      returned by the set_tid_address syscall was used to fill both fields
      despite it semantically being the tid.) this is historically and
      presently true on linux and unlikely to change, but it conceivably
      could be false on other systems that otherwise reproduce the linux
      syscall api/abi.
      
      only a few parts of the code were actually still using the cached pid.
      in a couple places (aio and synccall) it was a minor optimization to
      avoid a syscall. caching could be reintroduced, but lazily as part of
      the public getpid function rather than at program startup, if it's
      deemed important for performance later. in other places (cancellation
      and pthread_kill) the pid was completely unnecessary; the tkill
      syscall can be used instead of tgkill. this is actually a rather
      subtle issue, since tgkill is supposedly a solution to race conditions
      that can affect use of tkill. however, as documented in the commit
      message for commit 7779dbd2, tgkill
      does not actually solve this race; it just limits it to happening
      within one process rather than between processes. we use a lock that
      avoids the race in pthread_kill, and the use in the cancellation
      signal handler is self-targeted and thus not subject to tid reuse
      races, so both are safe regardless of which syscall (tgkill or tkill)
      is used.
      83dc6eb0
  7. 03 7月, 2014 5 次提交
    • R
      properly pass current locale to *_l functions when used internally · 4c48501e
      Rich Felker 提交于
      this change is presently non-functional since the callees do not yet
      use their locale argument for anything.
      4c48501e
    • R
      consolidate str[n]casecmp_l into str[n]casecmp source files · 7424ac58
      Rich Felker 提交于
      this is mainly done for consistency with the ctype functions and to
      declutter the src/locale directory.
      7424ac58
    • R
      consolidate *_l ctype/wctype functions into their non-_l source files · d89fdec5
      Rich Felker 提交于
      the main practical purposes of this commit are to remove a huge amount
      of clutter from the src/locale directory, to cut down on the length of
      the $(AR) and $(LD) command lines, and to reduce the amount of space
      wasted by object file headers in the static libc.a. build time may
      also be reduced, though this has not been measured.
      
      as an additional justification, if there ever were a need for the
      behavior of these functions to vary by locale, it would be necessary
      for the non-_l versions to call the _l versions, so that linking the
      former without the latter would not be possible anyway.
      d89fdec5
    • R
      add locale framework · 0bc03091
      Rich Felker 提交于
      this commit adds non-stub implementations of setlocale, duplocale,
      newlocale, and uselocale, along with the data structures and minimal
      code needed for representing the active locale on a per-thread basis
      and optimizing the common case where thread-local locale settings are
      not in use.
      
      at this point, the data structures only contain what is necessary to
      represent LC_CTYPE (a single flag) and LC_MESSAGES (a name for use in
      finding message translation files). representation for the other
      categories will be added later; the expectation is that a single
      pointer will suffice for each.
      
      for LC_CTYPE, the strings "C" and "POSIX" are treated as special; any
      other string is accepted and treated as "C.UTF-8". for other
      categories, any string is accepted after being truncated to a maximum
      supported length (currently 15 bytes). for LC_MESSAGES, the name is
      kept regardless of whether libc itself can use such a message
      translation locale, since applications using catgets or gettext should
      be able to use message locales libc is not aware of. for other
      categories, names which are not successfully loaded as locales (which,
      at present, means all names) are treated as aliases for "C". setlocale
      never fails.
      
      locale settings are not yet used anywhere, so this commit should have
      no visible effects except for the contents of the string returned by
      setlocale.
      0bc03091
    • R
      fix failure of wide printf/scanf functions to set wide orientation · 984c25b7
      Rich Felker 提交于
      in some cases, these functions internally call a byte-based input or
      output function before calling getwc/putwc, so they cannot rely on the
      latter to set the orientation.
      984c25b7
  8. 02 7月, 2014 4 次提交
  9. 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
  10. 26 6月, 2014 4 次提交
  11. 25 6月, 2014 1 次提交
  12. 24 6月, 2014 1 次提交
  13. 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
  14. 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
  15. 20 6月, 2014 3 次提交