about summary refs log tree commit diff
path: root/sysdeps/generic
Commit message (Collapse)AuthorAgeFilesLines
* Remove stat wrapper functions, move them to exported symbolsAdhemerval Zanella2020-10-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | This patch removes the stat, stat64, lstat, lstat64, fstat, fstat64, fstatat, and fstatat64 static wrapper and add the symbol on the libc with the expected names. Both the prototypes of the internal symbol linked by the static wrappers and the inline redirectors are also removed from the installed sys/stat.h header file. The wrapper implementation license LGPL exception is also removed since it is no longer statically linked to binaries. Internally the _STAT_VER* definitions are moved to a arch-specific xstatver.h file. The internal defines that redirects internals {f}stat{at} to their {f}xstat{at} counterparts are removed for Linux (!NO_RTLD_HIDDEN). Hurd still requires them since {f}stat{at} pulls extra objects that makes the loader build fail otherwise (I haven't dig into why exactly). Checked with a build for all affected ABIs. I also checked on x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* elf: Do not pass GLRO(dl_platform), GLRO(dl_platformlen) to _dl_important_hwcapsFlorian Weimer2020-10-091-6/+6
| | | | | | | In the current code, the function can easily obtain the information on its own. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Record whether paths come from LD_LIBRARY_PATH or --library-pathFlorian Weimer2020-10-081-2/+4
| | | | | | This allows more precise LD_DEBUG diagnostics. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Implement _dl_writeFlorian Weimer2020-10-071-0/+6
| | | | | | | | The generic version is parallel to _dl_writev. It cannot use _dl_writev directly because the errno value needs to be obtained under a lock. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Linux: Remove rseq supportFlorian Weimer2020-07-161-26/+0
| | | | | | | | | | | | | | | | | | The kernel ABI is not finalized, and there are now various proposals to change the size of struct rseq, which would make the glibc ABI dependent on the version of the kernels used for building glibc. This is of course not acceptable. This reverts commit 48699da1c468543ade14777819bd1b4d652709de ("elf: Support at least 32-byte alignment in static dlopen"), commit 8f4632deb3545b2949cec5454afc3cb21a0024ea ("Linux: rseq registration tests"), commit 6e29cb3f61ff5432c78a1c84b0d9b123a350ab36 ("Linux: Use rseq in sched_getcpu if available"), and commit 0c76fc3c2b346dc5401dc055d97d4279632b0fb3 ("Linux: Perform rseq registration at C startup and thread creation"), resolving the conflicts introduced by the ARC port and the TLS static surplus changes. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* rtld: Avoid using up static TLS surplus for optimizations [BZ #25051]Szabolcs Nagy2020-07-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | On some targets static TLS surplus area can be used opportunistically for dynamically loaded modules such that the TLS access then becomes faster (TLSDESC and powerpc TLS optimization). However we don't want all surplus TLS to be used for this optimization because dynamically loaded modules with initial-exec model TLS can only use surplus TLS. The new contract for surplus static TLS use is: - libc.so can have up to 192 bytes of IE TLS, - other system libraries together can have up to 144 bytes of IE TLS. - Some "optional" static TLS is available for opportunistic use. The optional TLS is now tunable: rtld.optional_static_tls, so users can directly affect the allocated static TLS size. (Note that module unloading with dlclose does not reclaim static TLS. After the optional TLS runs out, TLS access is no longer optimized to use static TLS.) The default setting of rtld.optional_static_tls is 512 so the surplus TLS is 3*192 + 4*144 + 512 = 1664 by default, the same as before. Fixes BZ #25051. Tested on aarch64-linux-gnu and x86_64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* rtld: Account static TLS surplus for audit modulesSzabolcs Nagy2020-07-081-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | The new static TLS surplus size computation is surplus_tls = 192 * (nns-1) + 144 * nns + 512 where nns is controlled via the rtld.nns tunable. This commit accounts audit modules too so nns = rtld.nns + audit modules. rtld.nns should only include the namespaces required by the application, namespaces for audit modules are accounted on top of that so audit modules don't use up the static TLS that is reserved for the application. This allows loading many audit modules without tuning rtld.nns or using up static TLS, and it fixes FAIL: elf/tst-auditmany Note that DL_NNS is currently a hard upper limit for nns, and if rtld.nns + audit modules go over the limit that's a fatal error. By default rtld.nns is 4 which allows 12 audit modules. Counting the audit modules is based on existing audit string parsing code, we cannot use GLRO(dl_naudit) before the modules are actually loaded.
* rtld: Add rtld.nns tunable for the number of supported namespacesSzabolcs Nagy2020-07-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TLS_STATIC_SURPLUS is 1664 bytes currently which is not enough to support DL_NNS (== 16) number of dynamic link namespaces, if we assume 192 bytes of TLS are reserved for libc use and 144 bytes are reserved for other system libraries that use IE TLS. A new tunable is introduced to control the number of supported namespaces and to adjust the surplus static TLS size as follows: surplus_tls = 192 * (rtld.nns-1) + 144 * rtld.nns + 512 The default is rtld.nns == 4 and then the surplus TLS size is the same as before, so the behaviour is unchanged by default. If an application creates more namespaces than the rtld.nns setting allows, then it is not guaranteed to work, but the limit is not checked. So existing usage will continue to work, but in the future if an application creates more than 4 dynamic link namespaces then the tunable will need to be set. In this patch DL_NNS is a fixed value and provides a maximum to the rtld.nns setting. Static linking used fixed 2048 bytes surplus TLS, this is changed so the same contract is used as for dynamic linking. With static linking DL_NNS == 1 so rtld.nns tunable is forced to 1, so by default the surplus TLS is reduced to 144 + 512 = 656 bytes. This change is not expected to cause problems. Tested on aarch64-linux-gnu and x86_64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* rtld: Clean up PT_NOTE and add PT_GNU_PROPERTY handlingSzabolcs Nagy2020-07-082-12/+15
| | | | | | | | | | | | | | | | | | | | | | Add generic code to handle PT_GNU_PROPERTY notes. Invalid content is ignored, _dl_process_pt_gnu_property is always called after PT_LOAD segments are mapped and it has no failure modes. Currently only one NT_GNU_PROPERTY_TYPE_0 note is handled, which contains target specific properties: the _dl_process_gnu_property hook is called for each property. The old _dl_process_pt_note and _rtld_process_pt_note differ in how the program header is read. The old _dl_process_pt_note is called before PT_LOAD segments are mapped and _rtld_process_pt_note is called after PT_LOAD segments are mapped. The old _rtld_process_pt_note is removed and _dl_process_pt_note is always called after PT_LOAD segments are mapped and now it has no failure modes. The program headers are scanned backwards so that PT_NOTE can be skipped if PT_GNU_PROPERTY exists. Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* string: Use tls-internal on strerror_lAdhemerval Zanella2020-07-072-0/+2
| | | | | | | | | | The buffer allocation uses the same strategy of strsignal. Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* string: Remove old TLS usage on strsignalAdhemerval Zanella2020-07-074-0/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The per-thread state is refactored two use two strategies: 1. The default one uses a TLS structure, which will be placed in the static TLS space (using __thread keyword). 2. Linux allocates via struct pthread and access it through THREAD_* macros. The default strategy has the disadvantage of increasing libc.so static TLS consumption and thus decreasing the possible surplus used in some scenarios (which might be mitigated by BZ#25051 fix). It is used only on Hurd, where accessing the thread storage in the in single thread case is not straightforward (afaiu, Hurd developers could correct me here). The fallback static allocation used for allocation failure is also removed: defining its size is problematic without synchronizing with translated messages (to avoid partial translation) and the resulting usage is not thread-safe. Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* signal: Move sys_siglist to a compat symbolAdhemerval Zanella2020-07-072-0/+48
| | | | | | | | | | | | | | | | | | | The symbol was deprecated by strsignal and its usage imposes issues such as copy relocations. Its internal name is changed to __sys_siglist and __sys_sigabbrev to avoid static linking usage. The compat code is also refactored, since both Linux and Hurd usage the same strategy: export the same array with different object sizes. The libSegfault change avoids calling strsignal on the SIGFAULT signal handler (the current usage is already sketchy, adding a call that potentially issue locale internal function is even sketchier). Checked on x86_64-linux-gnu and i686-linux-gnu. I also run a check-abi on all affected platforms. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Add the __libc_single_threaded variableFlorian Weimer2020-07-061-0/+1
| | | | | | | | | | | | | | The variable is placed in libc.so, and it can be true only in an outer libc, not libcs loaded via dlmopen or static dlopen. Since thread creation from inner namespaces does not work, pthread_create can update __libc_single_threaded directly. Using __libc_early_init and its initial flag, implementation of this variable is very straightforward. A future version may reset the flag during fork (but not in an inner namespace), or after joining all threads except one. Reviewed-by: DJ Delorie <dj@redhat.com>
* Linux: Perform rseq registration at C startup and thread creationMathieu Desnoyers2020-07-061-0/+26
| | | | | | | | | | | | | | | | | | | Register rseq TLS for each thread (including main), and unregister for each thread (excluding main). "rseq" stands for Restartable Sequences. See the rseq(2) man page proposed here: https://lkml.org/lkml/2018/9/19/647 Those are based on glibc master branch commit 3ee1e0ec5c. The rseq system call was merged into Linux 4.18. The TLS_STATIC_SURPLUS define is increased to leave additional room for dlopen'd initial-exec TLS, which keeps elf/tst-auditmany working. The increase (76 bytes) is larger than 32 bytes because it has not been increased in quite a while. The cost in terms of additional TLS storage is quite significant, but it will also obscure some initial-exec-related dlopen failures.
* elf: Include <stddef.h> (for size_t), <sys/stat.h> in <ldconfig.h>Florian Weimer2020-06-251-0/+2
| | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* math: Decompose math-use-builtins.hAdhemerval Zanella2020-06-2210-45/+50
| | | | | | | | | | | Each symbol definitions are moved on a separated file and it cover all symbol type definitions (float, double, long double, and float128). It allows to set support for architectures without the boiler place of copying default values. Checked with a build on the affected ABIs.
* Update HP_TIMING_NOW for _ISOMAC in sysdeps/generic/hp-timing.hH.J. Lu2020-06-051-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | commit e9698175b0b60407db1e89bcf29437ab224bca0b Author: Lukasz Majewski <lukma@denx.de> Date: Mon Mar 16 08:31:41 2020 +0100 y2038: Replace __clock_gettime with __clock_gettime64 breaks benchtests with sysdeps/generic/hp-timing.h: In file included from ./bench-timing.h:23, from ./bench-skeleton.c:25, from /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45: ./bench-skeleton.c: In function ‘main’: ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known 37 | struct __timespec64 tv; \ | ^~ Define HP_TIMING_NOW with clock_gettime in sysdeps/generic/hp-timing.h if _ISOMAC is defined. Don't define __clock_gettime in bench-timing.h since it is no longer needed. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* ieee754: provide gcc builtins based generic fma functionsVineet Gupta2020-06-031-0/+5
| | | | Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* ieee754: provide gcc builtins based generic sqrt functionsVineet Gupta2020-06-031-0/+3
| | | | Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Hurd: Use __sigmask in favor of deprecated sigmaskFlorian Weimer2020-05-281-2/+2
| | | | | | | | | This fixes various build errors due to deprecation warnings. Fixes commit 02802fafcf6e11ea3f998f685035ffe568dfddeb ("signal: Deprecate additional legacy signal handling functions"). Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* elf: Turn _dl_printf, _dl_error_printf, _dl_fatal_printf into functionsFlorian Weimer2020-05-251-12/+7
| | | | | | | | | | | | | | This change makes it easier to set a breakpoint on these calls. This also addresses the issue that including <ldsodefs.h> without <unistd.h> does not result usable _dl_*printf macros because of the use of the STD*_FILENO macros there. (The private symbol for _dl_fatal_printf will go away again once the exception handling implementation is unified between libc and ld.so.) Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: Replace __clock_gettime with __clock_gettime64Lukasz Majewski2020-05-202-4/+4
| | | | | | | | | | | | The __clock_gettime internal function is not supporting 64 bit time on architectures with __WORDSIZE == 32 and __TIMESIZE != 64 (like e.g. ARM 32 bit). The __clock_gettime64 function shall be used instead in the glibc itself as it supports 64 bit time on those systems. This patch does not bring any changes to systems with __WORDSIZE == 64 as for them the __clock_gettime64 is aliased to __clock_gettime (in ./include/time.h).
* elf: Implement __libc_early_initFlorian Weimer2020-04-241-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function is defined in libc.so, and the dynamic loader calls right after relocation has been finished, before any ELF constructors or the preinit function is invoked. It is also used in the static build for initializing parts of the static libc. To locate __libc_early_init, a direct symbol lookup function is used, _dl_lookup_direct. It does not search the entire symbol scope and consults merely a single link map. This function could also be used to implement lookups in the vDSO (as an optimization). A per-namespace variable (libc_map) is added for locating libc.so, to avoid repeated traversals of the search scope. It is similar to GL(dl_initfirst). An alternative would have been to thread a context argument from _dl_open down to _dl_map_object_from_fd (where libc.so is identified). This could have avoided the global variable, but the change would be larger as a result. It would not have been possible to use this to replace GL(dl_initfirst) because that global variable is used to pass the function pointer past the stack switch from dl_main to the main program. Replacing that requires adding a new argument to _dl_init, which in turn needs changes to the architecture-specific libc.so startup code written in assembler. __libc_early_init should not be used to replace _dl_var_init (as it exists today on some architectures). Instead, _dl_lookup_direct should be used to look up a new variable symbol in libc.so, and that should then be initialized from the dynamic loader, immediately after the object has been loaded in _dl_map_object_from_fd (before relocation is run). This way, more IFUNC resolvers which depend on these variables will work. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* elf: Introduce <elf_machine_sym_no_match.h>Florian Weimer2020-04-241-0/+34
| | | | | | | | | | | MIPS needs to ignore certain existing symbols during symbol lookup. The old scheme uses the ELF_MACHINE_SYM_NO_MATCH macro, with an inline function, within its own header, with a sysdeps override for MIPS. This allows re-use of the function from another file (without having to include <dl-machine.h> or providing the default definition for ELF_MACHINE_SYM_NO_MATCH). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* ldbl-128ibm-compat: Provide ieee128 symbols to narrow functionsTulio Magno Quites Machado Filho2020-02-201-0/+32
| | | | | | | | | | Move the narrow math aliasing macros into a new sysdep header file math-narrow-alias-float128.h. Then, provide an override header to supply the necessary changes to supply the *ieee128 aliases of these symbols. This adds ieee128 aliases for faddl, fdivl, fmull, fsubl, daddl, ddivl, dmull, dsubl.
* Introduce <elf-initfini.h> and ELF_INITFINI for all architecturesFlorian Weimer2020-02-183-0/+76
| | | | | | | | | | | | | | | | This supersedes the init_array sysdeps directory. It allows us to check for ELF_INITFINI in both C and assembler code, and skip DT_INIT and DT_FINI processing completely on newer architectures. A new header file is needed because <dl-machine.h> is incompatible with assembler code. <sysdep.h> is compatible with assembler code, but it cannot be included in all assembler files because on some architectures, it redefines register names, and some assembler files conflict with that. <elf-initfini.h> is replicated for legacy architectures which need DT_INIT/DT_FINI support. New architectures follow the generic default and disable it.
* mips: Fix bracktrace result for signal framesAdhemerval Zanella2020-02-181-0/+30
| | | | | | | | | | | | | | | | MIPS fallback code handle a frame where its FDE can not be obtained (for instance a signal frame) by reading the kernel allocated signal frame and adding '2' to the value of 'sc_pc' [1]. The added value is used to recognize an end of an EH region on mips16 [2]. The fix adjust the obtained signal frame value and remove the libgcc added value by checking if the previous frame is a signal frame one. Checked with backtrace and tst-sigcontext-get_pc tests on mips-linux-gnu and mips64-linux-gnu. [1] libgcc/config/mips/linux-unwind.h from gcc code. [2] gcc/config/mips/mips.h from gcc code. */
* <fd_to_filename.h>: Add type safety and port to HurdFlorian Weimer2020-02-182-8/+37
| | | | | | | | | The new type struct fd_to_filename makes the allocation of the backing storage explicit. Hurd uses /dev/fd, not /proc/self/fd. Co-Authored-By: Paul Eggert <eggert@cs.ucla.edu>
* ld.so: Do not export free/calloc/malloc/realloc functions [BZ #25486]Florian Weimer2020-02-151-6/+0
| | | | | | | | | | | | | | | | | | | Exporting functions and relying on symbol interposition from libc.so makes the choice of implementation dependent on DT_NEEDED order, which is not what some compiler drivers expect. This commit replaces one magic mechanism (symbol interposition) with another one (preprocessor-/compiler-based redirection). This makes the hand-over from the minimal malloc to the full malloc more explicit. Removing the ABI symbols is backwards-compatible because libc.so is always in scope, and the dynamic loader will find the malloc-related symbols there since commit f0b2132b35248c1f4a80f62a2c38cddcc802aa8c ("ld.so: Support moving versioned symbols between sonames [BZ #24741]"). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* powerpc: Move cache line size to rtld_global_roTulio Magno Quites Machado Filho2020-01-171-0/+21
| | | | | | | | | | | | | | GCC 10.0 enabled -fno-common by default and this started to point that __cache_line_size had been implemented in 2 different places: loader and libc. In order to avoid this duplication, the libc variable has been removed and the loader variable is moved to rtld_global_ro. File sysdeps/unix/sysv/linux/powerpc/dl-auxv.h has been added in order to reuse code for both static and dynamic linking scenarios. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* elf: Move vDSO setup to rtld (BZ#24967)Adhemerval Zanella2020-01-034-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | This patch moves the vDSO setup from libc to loader code, just after the vDSO link_map setup. For static case the initialization is moved to _dl_non_dynamic_init instead. Instead of using the mangled pointer, the vDSO data is set as attribute_relro (on _rtld_global_ro for shared or _dl_vdso_* for static). It is read-only even with partial relro. It fixes BZ#24967 now that the vDSO pointer is setup earlier than malloc interposition is called. Also, vDSO calls should not be a problem for static dlopen as indicated by BZ#20802. The vDSO pointer would be zero-initialized and the syscall will be issued instead. Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, s390x-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. I also run some tests on mips. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* Add libm_alias_finite for _finite symbolsWilco Dijkstra2020-01-031-2/+3
| | | | | | | | | | | | | | | | | | | This patch adds a new macro, libm_alias_finite, to define all _finite symbol. It sets all _finite symbol as compat symbol based on its first version (obtained from the definition at built generated first-versions.h). The <fn>f128_finite symbols were introduced in GLIBC 2.26 and so need special treatment in code that is shared between long double and float128. It is done by adding a list, similar to internal symbol redifinition, on sysdeps/ieee754/float128/float128_private.h. Alpha also needs some tricky changes to ensure we still emit 2 compat symbols for sqrt(f). Passes buildmanyglibc. Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* Update copyright dates with scripts/update-copyrights.Joseph Myers2020-01-01128-128/+128
|
* Fix return code for __libc_signal_* functionsAdhemerval Zanella2019-12-271-6/+6
| | | | | | | | The functions do not fail regardless of the argument value. Also, for Linux the return value is not correct on some platforms due the missing usage of INTERNAL_SYSCALL_ERROR_P / INTERNAL_SYSCALL_ERRNO macros. Checked on x86_64-linux-gnu, i686-linux-gnu, and sparc64-linux-gnu.
* Remove __waitpid_nocancelAdhemerval Zanella2019-12-191-2/+0
| | | | | | | | | It enables and disables cancellation with pthread_setcancelstate before calling the waitpid. It simplifies the waitpid implementation for architectures that do not provide either __NR_waitpid or __NR_wait4. Checked on x86_64-linux-gnu.
* Use GCC builtins for copysign functions if desired.Stefan Liebler2019-12-111-0/+9
| | | | | | | | | | | | This patch is always using the corresponding GCC builtin for copysignf, copysign, and is using the builtin for copysignl, copysignf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. Altough the long double version is enabled by default we still need the macro and the alternative implementation as the _Float128 version of the builtin is not available with all supported GCC versions. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Use GCC builtins for round functions if desired.Stefan Liebler2019-12-111-0/+5
| | | | | | | | | | | | This patch is using the corresponding GCC builtin for roundf, round, roundl and roundf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Use GCC builtins for trunc functions if desired.Stefan Liebler2019-12-111-0/+5
| | | | | | | | | | | | This patch is using the corresponding GCC builtin for truncf, trunc, truncl and truncf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Use GCC builtins for ceil functions if desired.Stefan Liebler2019-12-111-0/+5
| | | | | | | | | | | | This patch is using the corresponding GCC builtin for ceilf, ceil, ceill and ceilf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Use GCC builtins for floor functions if desired.Stefan Liebler2019-12-111-0/+5
| | | | | | | | | | | | This patch is using the corresponding GCC builtin for floorf, floor, floorl and floorf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Use GCC builtins for rint functions if desired.Stefan Liebler2019-12-111-0/+5
| | | | | | | | | | | | This patch is using the corresponding GCC builtin for rintf, rint, rintl and rintf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Use GCC builtins for nearbyint functions if desired.Stefan Liebler2019-12-111-0/+29
| | | | | | | | | | | | This patch is using the corresponding GCC builtin for nearbyintf, nearbyint, nearbintl and nearbyintf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Avoid late dlopen failure due to scope, TLS slotinfo updates [BZ #25112]Florian Weimer2019-11-271-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | This change splits the scope and TLS slotinfo updates in dlopen into two parts: one to resize the data structures, and one to actually apply the update. The call to add_to_global_resize in dl_open_worker is moved before the demarcation point at which no further memory allocations are allowed. _dl_add_to_slotinfo is adjusted to make the list update optional. There is some optimization possibility here because we could grow the slotinfo list of arrays in a single call, one the largest TLS modid is known. This commit does not fix the fatal meory allocation failure in _dl_update_slotinfo. Ideally, this error during dlopen should be recoverable. The update order of scopes and TLS data structures is retained, although it appears to be more correct to fully initialize TLS first, and then expose symbols in the newly loaded objects via the scope update. Tested on x86_64-linux-gnu. Change-Id: I240c58387dabda3ca1bcab48b02115175fa83d6c
* Avoid late failure in dlopen in global scope update [BZ #25112]Florian Weimer2019-11-271-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | The call to add_to_global in dl_open_worker happens after running ELF constructors for new objects. At this point, proper recovery from malloc failure would be quite complicated: We would have to run the ELF destructors and close all opened objects, something that we currently do not do. Instead, this change splits add_to_global into two phases, add_to_global_resize (which can raise an exception, called before ELF constructors run), and add_to_global_update (which cannot, called after ELF constructors). A complication arises due to recursive dlopen: After the inner dlopen consumes some space, the pre-allocation in the outer dlopen may no longer be sufficient. A new member in the namespace structure, _ns_global_scope_pending_adds keeps track of the maximum number of objects that need to be added to the global scope. This enables the inner add_to_global_resize call to take into account the needs of an outer dlopen. Most code in the dynamic linker assumes that the number of global scope entries fits into an unsigned int (matching the r_nlist member of struct r_scop_elem). Therefore, change the type of _ns_global_scope_alloc to unsigned int (from size_t), and add overflow checks. Change-Id: Ie08e2f318510d5a6a4bcb1c315f46791b5b77524
* Enable inlining issignalingf within glibcPaul A. Clarke2019-11-211-29/+0
| | | | | | | | | issignalingf is a very small function used in some areas where better performance (and smaller code) might be helpful. Create inline implementation for issignalingf. Reviewed-by: Joseph Myers <joseph@codesourcery.com>
* Introduce DL_LOOKUP_FOR_RELOCATE flag for _dl_lookup_symbol_xFlorian Weimer2019-11-211-0/+3
| | | | | | | | | | This will allow changes in dependency processing during non-lazy binding, for more precise processing of NODELETE objects: During initial relocation in dlopen, the fate of NODELETE objects is still unclear, so objects which are depended upon by NODELETE objects cannot immediately be marked as NODELETE. Change-Id: Ic7b94a3f7c4719a00ca8e6018088567824da0658
* Enhance _dl_catch_exception to allow disabling exception handlingFlorian Weimer2019-11-161-1/+3
| | | | | | | | | | | | In some cases, it is necessary to introduce noexcept regions where raised dynamic loader exceptions (e.g., from lazy binding) are fatal, despite being nested in a code region with an active exception handler. This change enhances _dl_catch_exception with to provide such a capability. The existing function is reused, so that it is not necessary to introduce yet another function with a similar purpose. Change-Id: Iec1bf642ff95a349fdde8040e9baf851ac7b8904
* Avoid zero-length array at the end of struct link_map [BZ #25097]Florian Weimer2019-11-151-4/+13
| | | | | | | | | | | | l_audit ends up as an internal array with _rtld_global, and GCC 10 warns about this. This commit does not change the layout of _rtld_global, so it is suitable for backporting. Future changes could allocate more of the audit state dynamically and remove it from always-allocated data structures, to optimize the common case of inactive auditing. Change-Id: Ic911100730f9124d4ea977ead8e13cee64b84d45
* Introduce link_map_audit_state accessor functionFlorian Weimer2019-11-151-1/+7
| | | | | | | | | | | | To improve GCC 10 compatibility, it is necessary to remove the l_audit zero-length array from the end of struct link_map. In preparation of that, this commit introduces an accessor function for the audit state, so that it is possible to change the representation of the audit state without adjusting the code that accesses it. Tested on x86_64-linux-gnu. Built on i686-gnu. Change-Id: Id815673c29950fc011ae5301d7cde12624f658df
* slotinfo in struct dtv_slotinfo_list should be flexible array [BZ #25097]Florian Weimer2019-11-121-1/+1
| | | | | | | | | GCC 10 will warn about subscribing inner length zero arrays. Use a GCC extension in csu/libc-tls.c to allocate space for the static_slotinfo variable. Adjust nptl_db so that the type description machinery does not attempt to determine the size of the flexible array member slotinfo. Change-Id: I51be146a7857186a4ede0bb40b332509487bdde8