1. 30 Sep, 2017 7 commits
  2. 29 Sep, 2017 11 commits
    • Joseph Myers's avatar
      Use libm_alias_double for some dbl-64 functions. · 1e2bffd0
      Joseph Myers authored
      Continuing the move of libm aliases to common macros that can create
      _FloatN / _FloatNx aliases in future, this patch converts some dbl-64
      functions to using libm_alias_double, thereby eliminating the need for
      some ldbl-opt wrappers.
      
      This patch deliberately limits what functions are converted so that it
      can be verified by comparison of stipped binaries.  Specifically, atan
      and tan are excluded because they first need converting to being weak
      aliases; fma is omitted as it has additional complications with
      versions in other directories (removing the ldbl-opt version can
      e.g. cause the ldbl-128 version to be used instead of dbl-64); and
      functions that have both dbl-64/wordsize-64 and ldbl-opt versions are
      excluded because ldbl-opt currently always wraps dbl-64 function
      versions, so changing those will result in platforms using both
      ldbl-opt and dbl-64/wordsize-64 (i.e. alpha) starting to use the
      dbl-64/wordsize-64 versions of those functions (which is good, as an
      optimization, but still best separated from the present patch to get
      better validation).
      
      Tested for x86_64, and tested with build-many-glibcs.py that installed
      stripped shared libraries are unchanged by the patch.
      
      	* sysdeps/ieee754/dbl-64/s_asinh.c: Include <libm-alias-double.h>.
      	(asinh): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_cbrt.c: Include <libm-alias-double.h>.
      	(cbrt): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_copysign.c: Include
      	<libm-alias-double.h>.
      	(copysign): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_erf.c: Include <libm-alias-double.h>.
      	(erf): Define using libm_alias_double.
      	(erfc): Likewise.
      	* sysdeps/ieee754/dbl-64/s_expm1.c: Include <libm-alias-double.h>.
      	(expm1): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_fabs.c: Include <libm-alias-double.h>.
      	(fabs): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_fromfp.c (fromfp): Define using
      	libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_fromfp_main.c: Include
      	<libm-alias-double.h>.
      	* sysdeps/ieee754/dbl-64/s_fromfpx.c (fromfpx): Define using
      	libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_getpayload.c: Include
      	<libm-alias-double.h>.
      	(getpayload): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_llrint.c: Include
      	<libm-alias-double.h>.
      	(llrint): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_lrint.c: Include <libm-alias-double.h>.
      	(lrint): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_nextup.c: Include
      	<libm-alias-double.h>.
      	(nextup): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_roundeven.c: Include
      	<libm-alias-double.h>.
      	(roundeven): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_setpayload.c (setpayload): Define using
      	libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_setpayload_main.c: Include
      	<libm-alias-double.h>.
      	* sysdeps/ieee754/dbl-64/s_setpayloadsig.c (setpayloadsig): Define
      	using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_sin.c: Include <libm-alias-double.h>.
      	(cos): Define using libm_alias_double.
      	(sin): Likewise.
      	* sysdeps/ieee754/dbl-64/s_sincos.c: Include
      	<libm-alias-double.h>.
      	(sincos): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_tanh.c: Include <libm-alias-double.h>.
      	(tanh): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_totalorder.c: Include
      	<libm-alias-double.h>.
      	(totalorder): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_totalordermag.c: Include
      	<libm-alias-double.h>.
      	(totalordermag): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_ufromfp.c (ufromfp): Define using
      	libm_alias_double.
      	* sysdeps/ieee754/dbl-64/s_ufromfpx.c (ufromfpx): Define using
      	libm_alias_double.
      	* sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c: Include
      	<libm-alias-double.h>.
      	(getpayload): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c: Include
      	<libm-alias-double.h>.
      	(roundeven): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c: Include
      	<libm-alias-double.h>.
      	* sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c: Include
      	<libm-alias-double.h>.
      	(totalorder): Define using libm_alias_double.
      	* sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c: Include
      	<libm-alias-double.h>.
      	(totalordermag): Define using libm_alias_double.
      	* sysdeps/ieee754/ldbl-opt/s_copysign.c (copysignl): Only define
      	libc compat symbol here.
      	* sysdeps/ieee754/ldbl-opt/s_asinh.c: Remove file.
      	* sysdeps/ieee754/ldbl-opt/s_cbrt.c: Likewise.
      	* sysdeps/ieee754/ldbl-opt/s_erf.c: Likewise.
      	* sysdeps/ieee754/ldbl-opt/s_expm1.c: Likewise.
      	* sysdeps/ieee754/ldbl-opt/s_fabs.c: Likewise.
      	* sysdeps/ieee754/ldbl-opt/s_llrint.c: Likewise.
      	* sysdeps/ieee754/ldbl-opt/s_lrint.c: Likewise.
      	* sysdeps/ieee754/ldbl-opt/s_sin.c: Likewise.
      	* sysdeps/ieee754/ldbl-opt/s_sincos.c: Likewise.
      	* sysdeps/ieee754/ldbl-opt/s_tanh.c: Likewise.
      1e2bffd0
    • H.J. Lu's avatar
      arm: Update elf_machine_load_address for static PIE · 8172aad9
      H.J. Lu authored
      When --enable-static-pie is used to configure glibc, we need to use
      _dl_relocate_static_pie to compute load address in static PIE.
      
      	* sysdeps/arm/dl-machine.h (elf_machine_load_address): Use
      	_dl_relocate_static_pie instead of _dl_start to compute load
      	address in static PIE.  Return 0 if _DYNAMIC is undefined for
      	static executable.
      8172aad9
    • H.J. Lu's avatar
      mips: Update elf_machine_load_address for static PIE · 54464e74
      H.J. Lu authored
      mips uses a local label to compute load address, which works with static
      PIE.  We just need to return 0 if _DYNAMIC is undefined for static
      executable.
      
      	* sysdeps/mips/dl-machine.h (elf_machine_dynamic): Return 0 if
      	_DYNAMIC is undefined for static executable.
      54464e74
    • H.J. Lu's avatar
      arm: Check PIC instead of SHARED in start.S · f6c5e5bc
      H.J. Lu authored
      Since start.o may be compiled as PIC, we should check PIC instead of
      SHARED.
      
      	* sysdeps/arm/start.S (_start): Check PIC instead of SHARED.
      f6c5e5bc
    • Joseph Myers's avatar
      Update x86_64 libm-test-ulps. · 2f92505d
      Joseph Myers authored
      	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
      2f92505d
    • Wilco Dijkstra's avatar
      Use fabs(f/l) rather than __fabs · bd8d53bb
      Wilco Dijkstra authored
      A few math functions still use __fabs(f/l) rather than fabs, which
      means they won't be inlined. Rename them so they are inlined.
      Also add -fno-builtin-fabsl to nofpu powerpc makefile to work around
      BZ #29253.
      
      	* sysdeps/ieee754/dbl-64/e_lgamma_r.c
      	(__ieee754_lgamma_r): Use fabs rather than __fabs.
      	* sysdeps/ieee754/dbl-64/e_log10.c (__ieee754_log10): Likewise.
      	* sysdeps/ieee754/dbl-64/e_log2.c (__ieee754_log2): Likewise.
      	* sysdeps/ieee754/flt-32/e_lgammaf_r.c
      	(__ieee754_lgammaf_r): Use fabsf rather than __fabsf.
      	* sysdeps/ieee754/flt-32/e_log10f.c (__ieee754_log10f): Likewise.
      	* sysdeps/ieee754/flt-32/e_log2f.c (__ieee754_log2f): Likewise.
      	* sysdeps/ieee754/ldbl-128/e_lgammal_r.c
      	(__ieee754_lgammal_r): Use fabsl rather than __fabsl.
      	* sysdeps/ieee754/ldbl-128/e_log10l.c (__ieee754_log10l): Likewise.
      	* sysdeps/ieee754/ldbl-128/e_log2l.c (__ieee754_log2l): Likewise.
      	* sysdeps/ieee754/ldbl-128ibm/e_lgammal_r.c
      	(__ieee754_lgammal_r): Use fabsl rather than __fabsl.
      	* sysdeps/ieee754/ldbl-128ibm/e_log10l.c (__ieee754_log10l): Likewise.
      	* sysdeps/ieee754/ldbl-128ibm/e_log2l.c (__ieee754_log2l): Likewise.
      	* sysdeps/powerpc/nofpu/Makefile: Add -fno-builtin-fabsl for BZ #29253.
      bd8d53bb
    • Wilco Dijkstra's avatar
      Remove old cimag inlines · fffb1507
      Wilco Dijkstra authored
      Remove old cimag inlines that are only used in GCC 2.96 or older.
      
      	* math/bits/cmathcalls.h (cimag): Remove inline.
      	(creal): Remove inline.
      	(conj): Remove inline.
      fffb1507
    • Szabolcs Nagy's avatar
      New generic powf · 4ea49f4c
      Szabolcs Nagy authored
      without wrapper on aarch64:
      powf reciprocal-throughput: 4.2x faster
      powf latency: 2.6x faster
      old worst-case error: 1.11 ulp
      new worst-case error: 0.82 ulp
      aarch64 .text size: -780 bytes
      aarch64 .rodata size: +144 bytes
      
      powf(x,y) is implemented as exp2(y*log2(x)) with the same algorithms
      that are used in exp2f and log2f, except that the log2f polynomial is
      larger for extra precision and its output (and exp2f input) may be
      scaled by a power of 2 (POWF_SCALE) to simplify the argument reduction
      step of exp2 (possible when efficient round and convert toint operation
      is available).
      
      The special case handling tries to minimize the checks in the hot path.
      When the input of exp2_inline is checked, int arithmetics is used as
      that was faster on the tested aarch64 cores.
      
      	* math/Makefile (type-float-routines): Add e_powf_log2_data.
      	* sysdeps/ieee754/flt-32/e_powf.c: New implementation.
      	* sysdeps/ieee754/flt-32/e_powf_log2_data.c: New file.
      	* sysdeps/ieee754/flt-32/math_config.h (__powf_log2_data): Define.
      	(issignalingf_inline): Likewise.
      	(POWF_LOG2_TABLE_BITS): Likewise.
      	(POWF_LOG2_POLY_ORDER): Likewise.
      	(POWF_SCALE_BITS): Likewise.
      	(POWF_SCALE): Likewise.
      	* sysdeps/i386/fpu/e_powf_log2_data.c: New file.
      	* sysdeps/ia64/fpu/e_powf_log2_data.c: New file.
      	* sysdeps/m68k/m680x0/fpu/e_powf_log2_data.c: New file.
      4ea49f4c
    • Szabolcs Nagy's avatar
      New generic log2f · 875c76c7
      Szabolcs Nagy authored
      Similar to the new logf: double precision arithmetics and a small
      lookup table is used. The argument reduction step is the same as in
      the new logf.
      
      without wrapper on aarch64:
      log2f reciprocal-throughput: 2.3x faster
      log2f latency: 2.1x faster
      old worst case error: 1.72 ulp
      new worst case error: 0.75 ulp
      aarch64 .text size: -252 bytes
      aarch64 .rodata size: +244 bytes
      
      	* math/Makefile (type-float-routines): Add e_log2f_data.
      	* sysdeps/ieee754/flt-32/e_log2f.c: New implementation.
      	* sysdeps/ieee754/flt-32/e_log2f_data.c: New file.
      	* sysdeps/ieee754/flt-32/math_config.h (__log2f_data): Define.
      	(LOG2F_TABLE_BITS, LOG2F_POLY_ORDER): Define.
      	* sysdeps/i386/fpu/e_log2f_data.c: New file.
      	* sysdeps/ia64/fpu/e_log2f_data.c: New file.
      	* sysdeps/m68k/m680x0/fpu/e_log2f_data.c: New file.
      875c76c7
    • Szabolcs Nagy's avatar
      missed ChangeLog entry · 90c42e40
      Szabolcs Nagy authored
      90c42e40
    • Szabolcs Nagy's avatar
      New generic logf · bf27d397
      Szabolcs Nagy authored
      without wrapper on aarch64:
      logf reciprocal-throughput: 2.2x faster
      logf latency: 1.9x faster
      old worst case error: 0.89 ulp
      new worst case error: 0.82 ulp
      aarch64 .text size: -356 bytes
      aarch64 .rodata size: +240 bytes
      
      Uses double precision arithmetics and a lookup table to allow smaller
      polynomial and avoid the use of division.
      
      Data is in a separate translation unit with fixed layout to prevent the
      compiler generating suboptimal literal access.
      
      Errors are handled inline according to POSIX rules, but this patch
      keeps the wrapper with SVID compatible error handling.
      
      Needs libm-test-ulps adjustment for clogf in non-nearest rounding mode.
      
      	* math/Makefile (type-float-routines): Add e_logf_data.
      	* sysdeps/ieee754/flt-32/e_logf.c: New implementation.
      	* sysdeps/ieee754/flt-32/e_logf_data.c: New file.
      	* sysdeps/ieee754/flt-32/math_config.h (__logf_data): Define.
      	(LOGF_TABLE_BITS, LOGF_POLY_ORDER): Define.
      	* sysdeps/i386/fpu/e_logf_data.c: New file.
      	* sysdeps/ia64/fpu/e_logf_data.c: New file.
      	* sysdeps/m68k/m680x0/fpu/e_logf_data.c: New file.
      bf27d397
  3. 28 Sep, 2017 6 commits
    • H.J. Lu's avatar
      x86: Allow undefined _DYNAMIC in static executable · 4088d8dd
      H.J. Lu authored
      When --enable-static-pie is used to build static PIE, _DYNAMIC is used
      to compute the load address of static PIE.  But _DYNAMIC is undefined
      when creating static executable.  This patch makes _DYNAMIC weak in PIE
      libc.a so that it can be undefined.
      
      	* sysdeps/i386/dl-machine.h (elf_machine_load_address): Allow
      	undefined _DYNAMIC in PIE libc.a.
      	* sysdeps/x86_64/dl-machine.h (elf_machine_load_address):
      	Likewse.
      4088d8dd
    • Wilco Dijkstra's avatar
      Remove ancient __signbit inlines · 4d3693ec
      Wilco Dijkstra authored
      Remove __signbit inlines from mathinline.h.  Math.h already uses
      the builtin when supported, so additional inlines are only used
      on pre 4.0 GCCs.  Similarly remove ancient copysign and fabs
      inlines.
      
      	* sysdeps/alpha/fpu/bits/mathinline.h: Delete file.
      	* sysdeps/ia64/fpu/bits/mathinline.h: Delete file.
      	* sysdeps/m68k/coldfire/fpu/bits/mathinline.h: Delete file.
      	* sysdeps/m68k/m680x0/fpu/bits/mathinline.h: (__signbitf): Remove.
      	(__signbit): Remove.
      	(__signbitl): Remove.
      	* sysdeps/powerpc/bits/mathinline.h (__signbitf): Remove.
      	(__signbit): Remove.
      	(__signbitl): Remove.
      	* sysdeps/s390/fpu/bits/mathinline.h: (__signbitf): Remove.
      	(__signbit): Remove.
      	(__signbitl): Remove
      	* sysdeps/sparc/fpu/bits/mathinline.h (__signbitf): Remove.
      	(__signbit): Remove.
      	(__signbitl): Remove.
      	* sysdeps/tile/bits/mathinline.h: Delete file.
      	* sysdeps/x86/fpu/bits/mathinline.h (__signbitf): Remove.
      	(__signbit): Remove.
      	(__signbitl): Remove.
      4d3693ec
    • Wilco Dijkstra's avatar
      Simplify C99 isgreater macros · 1e6d0723
      Wilco Dijkstra authored
      Simplify the C99 isgreater macros.  Although some support was added
      in GCC 2.97, not all targets added support until GCC 3.1.  Therefore
      only use the builtins in math.h from GCC 3.1 onwards, and defer to
      generic macros otherwise.  Improve the generic isunordered macro
      to use compares rather than call fpclassify twice - this is not only
      faster but also correct for signaling NaNs.
      
      	* math/math.h: Improve handling of C99 isgreater macros.
      	* sysdeps/alpha/fpu/bits/mathinline.h: Remove isgreater macros.
      	* sysdeps/m68k/m680x0/fpu/bits/mathinline.h: Likewise.
      	* sysdeps/powerpc/bits/mathinline.h: Likewise.
      	* sysdeps/sparc/fpu/bits/mathinline.h: Likewise.
      	* sysdeps/x86/fpu/bits/mathinline.h: Likewise.
      1e6d0723
    • Szabolcs Nagy's avatar
      AArch64: update libm-test-ulps · b2f03cf3
      Szabolcs Nagy authored
      Update for new expf and logf.
      
      	* sysdeps/aarch64/libm-test-ulps: Update.
      b2f03cf3
    • Joseph Myers's avatar
      Fix nearbyint arithmetic moved before feholdexcept (bug 22225). · f124cb38
      Joseph Myers authored
      In <https://sourceware.org/ml/libc-alpha/2013-05/msg00722.html> I
      remarked on the possibility of arithmetic in various nearbyint
      implementations being scheduled before feholdexcept calls, resulting
      in spurious "inexact" exceptions.
      
      I'm now actually observing this occurring in glibc built for ARM with
      GCC 7 (in fact, both copies of the same addition/subtraction sequence
      being combined and moved out before the conditionals and
      feholdexcept/fesetenv pairs), resulting in test failures.
      
      This patch makes the nearbyint implementations with this particular
      feholdexcept / arithmetic / fesetenv pattern consistently use
      math_opt_barrier on the function argument when first used in
      arithmetic, and also consistently use math_force_eval before fesetenv
      (the latter was generally already done, but the dbl-64/wordsize-64
      implementation used math_opt_barrier instead, and as
      math_opt_barrier's intended effect is through its output value being
      used, such a use that doesn't use the return value is suspect).
      
      Tested for x86_64 (--disable-multi-arch so more of these
      implementations get used), and for ARM in a configuration where I saw
      the problem scheduling.
      
      	[BZ #22225]
      	* sysdeps/ieee754/dbl-64/s_nearbyint.c (__nearbyint): Use
      	math_opt_barrier on argument when doing arithmetic on it.
      	* sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c (__nearbyint):
      	Likewise.  Use math_force_eval not math_opt_barrier after
      	arithmetic.
      	* sysdeps/ieee754/flt-32/s_nearbyintf.c (__nearbyintf): Use
      	math_opt_barrier on argument when doing arithmetic on it.
      	* sysdeps/ieee754/ldbl-128/s_nearbyintl.c (__nearbyintl):
      	Likewise.
      f124cb38
    • H.J. Lu's avatar
      Update sysdeps/unix/sysv/linux/ifaddrs.c · 7edd0691
      H.J. Lu authored
      Fix
      
      ../sysdeps/unix/sysv/linux/ifaddrs.c:835:27: error: ‘getifaddrs’ aliased to undefined symbol ‘__getifaddrs’
       weak_alias (__getifaddrs, getifaddrs)
                                 ^
      ../sysdeps/unix/sysv/linux/ifaddrs.c:844:28: error: ‘freeifaddrs’ aliased to undefined symbol ‘__freeifaddrs’
       weak_alias (__freeifaddrs, freeifaddrs)
      
      caused by
      
      commit 4009ddc6
      Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
      Date:   Thu Sep 28 00:19:18 2017 +0200
      
          hurd: Fix `getifaddrs' and `freeifaddrs' symbol exposition
      
      	* sysdeps/unix/sysv/linux/ifaddrs.c (__getifaddrs): Add
      	libc_hidden_def.
      	(__freeifaddrs): Likewise.
      7edd0691
  4. 27 Sep, 2017 4 commits
    • Samuel Thibault's avatar
      hurd: Fix `getifaddrs' and `freeifaddrs' symbol exposition · 4009ddc6
      Samuel Thibault authored
      from `freeaddrinfo'.
      
      `getifaddrs' and `freeifaddrs' are not in POSIX, they should not be
      exposed along `freeaddrinfo' (through `__check_pf') which is POSIX.
      
      	* include/ifaddrs.h (__getifaddrs, __freeifaddrs): New declarations,
      	and use libc_hidden_def on them.
      	* inet/ifaddrs.c (__getifaddrs, __freeifaddrs): Use libc_hidden_def on
      	them.
      	* sysdeps/gnu/ifaddrs.c (__getifaddrs, __freeifaddrs): Likewise.
      	* inet/check_pf.c (__check_pf): Use __getifaddrs and __freeifaddrs
      	instead of getifaddrs and freeifaddrs.
      4009ddc6
    • Samuel Thibault's avatar
      hurd: Fix `seekdir' symbol exposition from `rewinddir' · 64a4af28
      Samuel Thibault authored
      `seekdir' is MISC || XOPEN, it should not be exposed along `rewinddir' which
      is POSIX.
      
      	* include/dirent.h (__seekdir): New declaration.
      	* sysdeps/mach/hurd/seekdir.c (seekdir): Rename to __seekdir and
      	redefine as weak alias.
      	* sysdeps/mach/hurd/rewinddir.c (__rewinddir): Use __seekdir instead
      	of seekdir.
      64a4af28
    • Samuel Thibault's avatar
      hurd: Fix `revoke' symbol exposition from `unlockpt' · 52a1f181
      Samuel Thibault authored
      `revoke' is MISC only, it should not be exposed along `unlockpt' which is
      XOPEN.
      
      	* include/unistd.h (__revoke): New declaration.
      	* misc/revoke.c (revoke): Rename to __revoke, and redefine as weak
      	alias.
      	* sysdeps/mach/hurd/revoke.c (revoke): Likewise.
      	* sysdeps/unix/bsd/unlockpt.c (unlockpt): Use __revoke instead of
      	revoke.
      52a1f181
    • Samuel Thibault's avatar
      hurd: Fix dirfd symbol exposition from ftw · 2c7bbfaf
      Samuel Thibault authored
      dirfd is XOPEN2K8 only, it should not be exposed along ftw which is earlier.
      
      	* include/dirent.h (__dirfd): New declaration.
      	* dirent/dirfd.c (dirfd): Rename to __dirfd, and redefine as weak
      	alias.
      	* sysdeps/posix/dirfd/dirfd.c (dirfd): Likewise.
      	* sysdeps/mach/hurd/dirfd.c (dirfd): Likewise.
      	* io/ftw.c (open_dir_stream, ftw_dir): Use __dirfd instead of dirfd.
      2c7bbfaf
  5. 26 Sep, 2017 12 commits
    • H.J. Lu's avatar
      Mark __dso_handle as hidden [BZ #18822] · 825adeee
      H.J. Lu authored
      Since __dso_handle is always defined by either crtbegin.o from GCC or
      dso_handle.c, it should be marked as hidden and be passed directly.
      
      	[BZ #18822]
      	* dlfcn/modatexit.c (foo): Remove __dso_handle check.
      	* dlfcn/modcxaatexit.c: Include <dso_handle.h>.
      	(__dso_handle): Remove declaration.
      	* dlfcn/tstatexit.c (__dso_handle): Removed.
      	(main): Don't check __dso_handle.
      	* dlfcn/tstcxaatexit.c (__dso_handle): Removed.
      	(main): Don't check __dso_handle.
      	* include/dso_handle.h: New file.
      	* malloc/mtrace.c: Include <dso_handle.h>.
      	(mtrace): Pass __dso_handle directly.
      	* nptl/pthread_atfork.c: Include <dso_handle.h>.
      	(__dso_handle): Remove declaration.
      	(__pthread_atfork): Pass __dso_handle directly.
      	* nptl/tst-atfork2mod.c: Include <dso_handle.h>.
      	(__dso_handle): Removed.
      	* posix/wordexp-test.c: Include <dso_handle.h>.
      	(__dso_handle): Remove declaration.
      	(__app_register_atfork): Pass __dso_handle directly.
      	* stdlib/at_quick_exit.c: Include <dso_handle.h>.
      	(__dso_handle): Remove declaration.
      	(at_quick_exit): Pass __dso_handle directly.
      	* stdlib/atexit.c: Include <dso_handle.h>.
      	(__dso_handle): Remove declaration.
      	(atexit): Pass __dso_handle directly.
      	* stdlib/tst-tls-atexit-lib.c: Include <dso_handle.h>.
      	(__dso_handle): Removed.
      825adeee
    • Joseph Myers's avatar
      Fix make-syscalls.sh VDSO support for GCC 8. · bfb0deb3
      Joseph Myers authored
      sysdeps/unix/make-syscalls.sh has support, used only by x32, for
      generating IFUNCs for kernel VDSO symbols.  This support creates
      IFUNCs by setting symbol types manually, which is bad for debug info
      and does not work with current GCC mainline because it results in
      errors from the checks on types of function aliases.
      
      This patch fixes it to use the common __ifunc macro, which uses the
      ifunc attribute when available and so works with GCC mainline.  Note
      however that the original error resulted from an indirect inclusion of
      a header declaring __gettimeofday from the generated sources, and
      using __ifunc now relies on such an indirect inclusion remaining as it
      means use of __typeof to determine the correct types.  If glibc's
      headers change in such a way as to remove that indirect inclusion, it
      will become necessary to change the syscalls.list syntax for VDSO
      syscalls so the name of the header to include can be specified.
      
      Tested (compilation only) with build-many-glibcs.py that this fixes
      the build for x32 with GCC mainline.
      
      	* sysdeps/unix/make-syscalls.sh: Use __ifunc to define symbols
      	using VDSO.
      bfb0deb3
    • Alexey Makhalov's avatar
      Fix range check in do_tunable_update_val · cebcb9f8
      Alexey Makhalov authored
      Current implementation of tunables does not set arena_max and arena_test
      values. Any value provided by glibc.malloc.arena_max and
      glibc.malloc.arena_test parameters is ignored.
      
      These tunables have minval value set to 1 (see elf/dl-tunables.list file)
      and undefined maxval value. In that case default value (which is 0. see
      scripts/gen-tunables.awk) is being used to set maxval.
      
      For instance, generated tunable_list[] entry for arena_max is:
      (gdb) p *cur
      $1 = {name = 0x7ffff7df6217 "glibc.malloc.arena_max",
       type = {type_code = TUNABLE_TYPE_SIZE_T, min = 1, max = 0},
        val = {numval = 0, strval = 0x0}, initialized = false,
         security_level = TUNABLE_SECLEVEL_SXID_IGNORE,
          env_alias = 0x7ffff7df622e "MALLOC_ARENA_MAX"}
      
      As a result, any value of glibc.malloc.arena_max is ignored by
      TUNABLE_SET_VAL_IF_VALID_RANGE macro
        __type min = (__cur)->type.min;                    <- initialized to 1
        __type max = (__cur)->type.max;                    <- initialized to 0!
        if (min == max)                                    <- false
          {
            min = __default_min;
            max = __default_max;
          }
        if ((__type) (__val) >= min && (__type) (val) <= max)  <- false
          {
            (__cur)->val.numval = val;
            (__cur)->initialized = true;
          }
      
      Assigning correct min/max values at a build time fixes a problem.
      Plus, a bit of optimization: Setting of default min/max values for the
      given type at a run time might be eliminated.
      
      	* elf/dl-tunables.c (do_tunable_update_val): Range checking fix.
      	* scripts/gen-tunables.awk: Set unspecified minval and/or maxval
      	values to correct default value for given type.
      cebcb9f8
    • H.J. Lu's avatar
      Skip PT_DYNAMIC segment with p_filesz == 0 [BZ #22101] · 592d5c75
      H.J. Lu authored
      ELF objects generated with "objcopy --only-keep-debug" have
      
      Type     Offset  VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
      DYNAMIC  0x0+e28 0x0+200e40 0x0+200e40 0x0+    0x0+1a0 RW  0x8
      
      with 0 file size. ld.so should skip such PT_DYNAMIC segments.
      
      Without a PT_DYNAMIC segment the loading of the shared object will
      fail, and therefore ldd on such objects will also fail instead of
      crashing. This provides better diagnostics for tooling that is
      attempting to inspect the invalid shared objects which may just
      contain debug information.
      
      	[BZ #22101]
      	* elf/Makefile (tests): Add tst-debug1.
      	($(objpfx)tst-debug1): New.
      	($(objpfx)tst-debug1.out): Likewise.
      	($(objpfx)tst-debug1mod1.so): Likewise.
      	* elf/dl-load.c (_dl_map_object_from_fd): Skip PT_DYNAMIC segment
      	with p_filesz == 0.
      	* elf/tst-debug1.c: New file.
      Reviewed-by: 's avatarCarlos O'Donell <carlos@redhat.com>
      592d5c75
    • Joseph Myers's avatar
      Use generic __ifunc for SPARC. · 2d9193f2
      Joseph Myers authored
      glibc fails to build with GCC mainline for SPARC because of the use of
      manually-created IFUNCs, which fail the tests of compatibility of
      function alias types.  This patch changes sparc-ifunc.h to use the
      generic __ifunc in defining sparc_libm_ifunc.  The generic __ifunc can
      use the GCC ifunc attribute when available, so ensuring
      type-correctness as well as better debug info than when setting symbol
      types in asm statements.
      
      Note that for this to fix the build with GCC mainline the GCC patch
      <https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01779.html>, or
      building GCC with --enable-gnu-indirect-function, is also needed.
      
      Tested (compilation only) with build-many-glibcs.py (sparc64-linux-gnu
      and sparcv9-linux-gnu, with GCC 8 with the above patch, and also with
      GCC 7).
      
      	* sysdeps/sparc/sparc-ifunc.h [!__ASSEMBLER__] (sparc_libm_ifunc):
      	Define using __ifunc.
      2d9193f2
    • Tulio Magno Quites Machado Filho's avatar
      powerpc: Regenerate ULPs for expf() and exp2f() · 4c5a7a02
      Tulio Magno Quites Machado Filho authored
      Remove all entries for expf() and exp2f() and regenerate them.
      
      	* sysdeps/powerpc/fpu/libm-test-ulps: Regenerate expf() and
      	exp2f() values.
      4c5a7a02
    • Joseph Myers's avatar
      Fix ia64 executable stack default (bug 22156). · 12ef66c4
      Joseph Myers authored
      As per https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01220.html ia64
      defaults to non-executable stacks in the Linux kernel (furthermore,
      the use of function descriptors means that trampolines for nested
      function pointers never need an executable stack).  glibc however
      defines DEFAULT_STACK_PERMS to include PF_X for that architecture,
      meaning (a) elf/check-execstack fails and (b) (from code inspection,
      not tested, but this is why I think this is a user-visible bug) thread
      stacks are unnecessarily mapped with execute permission.  This patch
      fixes the DEFAULT_STACK_PERMS definition in question.
      
      Tested (compilation only) with build-many-glibcs.py for ia64.  This
      fixes the check-execstack failure.
      
      	[BZ #22156]
      	* sysdeps/ia64/stackinfo.h (DEFAULT_STACK_PERMS): Likewise.
      12ef66c4
    • Florian Weimer's avatar
      resolv/Makefile: Fix typo in comment · 44dade71
      Florian Weimer authored
      44dade71
    • Florian Weimer's avatar
      resolv/nss_dns/dns-host.c: Fix typo in comment · eaca16f1
      Florian Weimer authored
      And only the resolv/map*.h actually contain implementations.
      eaca16f1
    • Adhemerval Zanella's avatar
      scratch_buffer: use union for internal buffer · 5f9f31ad
      Adhemerval Zanella authored
      Problem reported by Florian Weimer [1] and solution suggested by
      Andreas Schwab [2].  It also set the same buffer size independent
      of architecture max_align_t size.
      
      Checked on x86_64-linux-gnu and i686-linux-gnu.
      
      	* lib/malloc/scratch_buffer.h (struct scratch_buffer):
      	Use an union instead of a max_align_t array for __space,
      	so that __space is the same size on all platforms.
      	* malloc/scratch_buffer_grow_preserve.c
      	(__libc_scratch_buffer_grow_preserve): Likewise.
      
      [1] https://sourceware.org/ml/libc-alpha/2017-09/msg00693.html
      [2] https://sourceware.org/ml/libc-alpha/2017-09/msg00695.html
      5f9f31ad
    • Adhemerval Zanella's avatar
      posix: Add compat glob symbol to not follow dangling symbols · ccf970c7
      Adhemerval Zanella authored
      This patch follows commit 5554304f (posix: Allow glob to match dangling
      symlinks [BZ #866]) by adding a compat symbol that follow previous
      semantic of not following dangling symlinks and thus avoiding call
      gl_lstat with GLOB_ALTDIRFUNC.
      
      It avoids failure with old binaries that not set the alternate function
      pointer for lstat (GNUmake for instance).  The following scenario, for
      instance, fails with current GNUmake because glibc will access unitialized
      memory when calling gl_lstat:
      
        $ cat src/t/t.c
        int main ()
        {
          return 0;
        }
        $ cat Makefile
        SRC = $(wildcard src/*/t.c)
        OBJ = $(patsubst src/%.c, obj/%.o, $(SRC))
      
        prog:           $(OBJ)
                        $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) $(OBJ) -o prog
      
        obj/%.o:        src/%.c
                        $(CC) $(CFLAGS) -c $< -o $@
        $ make
      
      This works as expected with the patch applied.  Since it is for generic
      ABI, default compat symbols are added with override for Linux due LFS.
      Now we have two compat symbols for glob on Linux:
      
        1. sysdeps/unix/sysv/linux/oldglob.c which implements glob64 with
           the old dirent layout.  For this implementation I also set it to
           not follow dangling symlinks (which is the safest path).
      
        2. sysdeps/unix/sysv/linux/glob{64}-lstat-compat.c which implements
           the compat symbol for dangling symlinks.  As for generic glob,
           the implementation uses XSTAT_IS_XSTAT64 to define whether
           both __glob_lstat_compat and __glob64_lstat_compat should be
           different implementations.  For archictures that define
           XSTAT_IS_XSTAT64, __glob_lstat_compat is aliased to
           __glob64_lstat_compat.
      
        3. sysdeps/unix/sysv/linux/alpha/oldglob.c with a different glob_t
           layout.  As for 1. this patch changes it to not follow dangling
           symlinks.
      
      The patch also bumps _GNU_GLOB_INTERFACE_VERSION to 2 to advertise the
      new semantic.  On GNUmake, for instance, it will force to it use its
      internal glob implementation instead and avoiding triggering the same
      failure on builds against newer GLIBCs.
      
      Checked on x86_64-linux-gnu and i686-linux-gnu.  I also checked
      with a build against the major ABIs required to check for the abilist.
      
      The changes should also work on gnulib (I run gnulib-tool.py check glob
      and it shown no regressions).
      
      	[BZ #22183]
      	* include/gnu-versions.h (_GNU_GLOB_INTERFACE_VERSION): Increase
      	version to 2.
      	* posix/Makefile (routines): Add glob-lstat-compat and
      	glob64-lstat-compat.
      	* posix/Versions (GLIBC_2.27, glob, glob64): Add symbol version.
      	* posix/glob-lstat-compat.c: New file.
      	* posix/glob64-lstat-compat.c: Likewise.
      	* posix/tst-glob_lstat_compat.c: Likewise.
      	* sysdeps/unix/sysv/linux/glob-lstat-compat.c: Likewise.
      	* sysdeps/unix/sysv/linux/alpha/glob-lstat-compat.c: Likewise.
      	* sysdeps/unix/sysv/linux/glob64-lstat-compat.c: Likewise.
      	* sysdeps/unix/sysv/linux/alpha/glob.c: Remove file.
      	* posix/glob.c (glob_lstat): New function.
      	(glob): Rename to __glob and add versioned symbol to 2.27.
      	(glob_in_dir): Use glob_lstat.
      	* posix/glob64.c (glob64): Add GLOB_ATTRIBUTE.
      	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/glob.c (glob): Add versioned symbol for
      	2.27.
      	* sysdeps/unix/sysv/linux/glob64.c (glob64): Likewise.
      	* sysdeps/unix/sysv/linux/oldglob.c (GLOB_NO_LSTAT): Define.
      	* sysdeps/unix/sysv/linux/alpha/oldglob.c (__old_glob): Do not use
      	gl_lstat on glob call.
      	* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add GLIBC_2.27 glob
      	and glob64 symbols.
      	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
      	Likewise.
      	* sysdeps/unix/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
      	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
      ccf970c7
    • H.J. Lu's avatar
      Update configure.ac for binutils 2.25 · b4396163
      H.J. Lu authored
      Commit 073e8fa7 requires binutils 2.25
      or later to build glibc:
      
      	* configure.ac (AS): Require binutils 2.25 or later.
      	(LD): Likewise.
      
      But it only updated LD version check in configure.ac.  This patch adds
      the missing AS version check.
      
      	* configure.ac (AS): Require binutils 2.25 or later.
      	* configure: Regenerated.
      b4396163