about summary refs log tree commit diff
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* elf: Clean up GLIBC_PRIVATE exports of internal libdl symbolsFlorian Weimer2021-07-071-16/+14
| | | | | | | | They are no longer needed after everything has been moved into libc. The _dl_vsym test has to be removed because the symbol cannot be used outside libc anymore. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* resolv: Move libanl into libc (if libpthread is in libc)Florian Weimer2021-07-021-0/+4
| | | | | | | | | | The symbols gai_cancel, gai_error, gai_suspend, getaddrinfo_a, __gai_suspend_time64 were moved using scripts/move-symbol-to-libc.py. For Hurd (which remains !PTHREAD_IN_LIBC), a few #define redirects had to be added because several pthread functions are not available under __. (Linux uses __ prefixes for most hidden aliases, and has to in some cases to avoid linknamespace issues.)
* Fix extra PLT reference in libc.so due to __glob64_time64 if build with gcc ↵Stefan Liebler2021-07-011-0/+1
| | | | | | | | | | | | | | | | 7.5 on 32bit. Starting with recent commit 84f7ce84474c1648ce96884f1c91ca7b97ca3fc2 "posix: Add glob64 with 64-bit time_t support", elf/check-localplt fails due to extra PLT reference __glob64_time64 in __glob64_time64 itself. This is observable with gcc 7.5 on x86_64 with -m32 or s390x with -m31. E.g. if build with gcc 10, gcc is generating a call to __glob64_time64.localalias. This patch is adding a hidden version of __glob64_time64 in the same way as for __globfree64_time64.
* login: Move libutil into libcFlorian Weimer2021-06-302-2/+6
| | | | | | | | | | | | | | | | The symbols forkpty, login, login_tty, logout, logwtmp, openpty were moved using scripts/move-symbol-to-libc.py. This is a single commit because most of the symbols are tied together via forkpty, for example. Several changes to use hidden prototypes are needed. This commit also updates pseudoterminal terminology on modified lines. For 390 (31-bit), this commit follows the existing style for the compat symbol version creation. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* login: Rework hidden prototypes for __setutent, __utmpname, __endutentFlorian Weimer2021-06-301-3/+6
| | | | | | | Replace attribute_hidden with a regular combination of libc_hidden_proto and libc_hidden_def. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* login: Hidden prototypes for _getpt, __ptsname_r, grantpt, unlockptFlorian Weimer2021-06-301-0/+6
| | | | Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Linux: Move timer_settime, __timer_settime64 from librt to libcFlorian Weimer2021-06-281-1/+5
| | | | | | | | | | | | | | | The symbols were moved using scripts/move-symbol-to-libc.py. The way the ABI intransition is implemented is changed with this commit: the implementation is now consolidated in one file with a TIMER_T_WAS_INT_COMPAT check. The shared librt is now empty, so this commit adds a placeholder symbol at the base version, GLIBC_2.2, and potentially at the GLIBC_2.3.3 version as well (the leftover from the int/timer_t ABI transition). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Linux: Move timer_gettime, __timer_gettime64 from librt to libcFlorian Weimer2021-06-281-1/+5
| | | | | | | | | | The symbols were moved using scripts/move-symbol-to-libc.py. The way the ABI intransition is implemented is changed with this commit: the implementation is now consolidated in one file with a TIMER_T_WAS_INT_COMPAT check. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* math: redirect roundeven functionShen-Ta Hsieh2021-06-271-1/+1
| | | | | | | This patch redirect roundeven function for futhermore changes. Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* Linux: Move mq_send, mq_timedsend, __mq_timedsend_time64 to libcFlorian Weimer2021-06-251-6/+6
| | | | | | The symbols were moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
* Linux: Move mq_receive, mq_timedreceive, __mq_timedreceive_time64 to libcFlorian Weimer2021-06-251-3/+9
| | | | | | The symbols were moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
* Linux: Move mq_notify from librt to libcFlorian Weimer2021-06-252-0/+7
| | | | | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. An explicit call from fork into the mq_notify implementation replaces the previous use of pthread_atfork. Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
* Linux: Move mq_setattr from librt to libcFlorian Weimer2021-06-251-0/+7
| | | | | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. To introduce the proper symbol versioning, the implementation of the system call wrapper us moved to a C file. Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
* Linux: Move aio_suspend, aio_suspend64, __aio_suspend_time64 to libcFlorian Weimer2021-06-251-0/+4
| | | | | | | | | | | The symbols were moved using scripts/move-symbol-to-libc.py. There is a minor oddity here: This is generic code shared with Hurd, and Hurd does not have time64 support. This is why the versioned_symbol export for __aio_suspend_time64 is restricted to the PTHREAD_IN_LIBC code. Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
* posix: Consolidate fork implementationAdhemerval Zanella2021-06-241-0/+2
| | | | | | | | | | | | | | | | The Linux nptl implementation is used as base for generic fork implementation to handle the internal locks and mutexes. The system specific bits are moved a new internal _Fork symbol. (This new implementation will be used to provide a async-signal-safe _Fork now that POSIX has clarified that fork might not be async-signal-safe [1]). For Hurd it means that the __nss_database_fork_prepare_parent and __nss_database_fork_subprocess will be run in a slight different order. [1] https://austingroupbugs.net/view.php?id=62
* linux: Only use 64-bit syscall if required for selectAdhemerval Zanella2021-06-221-0/+5
| | | | | | | | | | | | | | | | | For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall if the provided timeout fits in a 32-bit one. The 64-bit usage should be rare since the timeout is a relative one. This also avoids the need to use supports_time64() (which breaks the usage case of live migration like CRIU or similar). It also fixes an issue on 32-bit select call for !__ASSUME_PSELECT (microblase with older kernels only) where the expected timeout is a 'struct timeval' instead of 'struct timespec'. Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel (with and without --enable-kernel=5.1) and on x86_64-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Use 64 bit time_t stat internallyAdhemerval Zanella2021-06-222-4/+4
| | | | | | | | | | For the legacy ABI with supports 32-bit time_t it calls the 64-bit time directly, since the LFS symbols calls the 64-bit time_t ones internally. Checked on i686-linux-gnu and x86_64-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Add hidden prototypes for fsync, fdatasyncFlorian Weimer2021-06-221-0/+2
| | | | Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* io: Add ftw64 with 64-bit time_t supportAdhemerval Zanella2021-06-151-0/+18
| | | | | | | | | | | Similar to fts, ftw routines passes a stat pointer that might differ of size and layout when 64-bit time API is used. Checked on i686-linux-gnu and x86_64-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* io: Add fts64 with 64-bit time_t supportAdhemerval Zanella2021-06-151-0/+51
| | | | | | | | | | | Similar to glob, fts routines passes a stat pointer that might differ of size and layout when 64-bit time API is used. Checked on i686-linux-gnu and x86_64-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* posix: Add glob64 with 64-bit time_t supportAdhemerval Zanella2021-06-151-0/+28
| | | | | | | | | | | The glob might pass a different stat struct for gl_stat and gl_lstat when GLOB_ALTDIRFUNC is used. This requires add a new 64-bit time version that also uses 64-bit time stat functions. Checked on i686-linux-gnu and x86_64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* y2038: Add support for 64-bit time on legacy ABIsAdhemerval Zanella2021-06-152-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A new build flag, _TIME_BITS, enables the usage of the newer 64-bit time symbols for legacy ABI (where 32-bit time_t is default). The 64 bit time support is only enabled if LFS (_FILE_OFFSET_BITS=64) is also used. Different than LFS support, the y2038 symbols are added only for the required ABIs (armhf, csky, hppa, i386, m68k, microblaze, mips32, mips64-n32, nios2, powerpc32, sparc32, s390-32, and sh). The ABIs with 64-bit time support are unchanged, both for symbol and types redirection. On Linux the full 64-bit time support requires a minimum of kernel version v5.1. Otherwise, the 32-bit fallbacks are used and might results in error with overflow return code (EOVERFLOW). The i686-gnu does not yet support 64-bit time. This patch exports following rediretions to support 64-bit time: * libc: adjtime adjtimex clock_adjtime clock_getres clock_gettime clock_nanosleep clock_settime cnd_timedwait ctime ctime_r difftime fstat fstatat futimens futimes futimesat getitimer getrusage gettimeofday gmtime gmtime_r localtime localtime_r lstat_time lutimes mktime msgctl mtx_timedlock nanosleep nanosleep ntp_gettime ntp_gettimex ppoll pselec pselect pthread_clockjoin_np pthread_cond_clockwait pthread_cond_timedwait pthread_mutex_clocklock pthread_mutex_timedlock pthread_rwlock_clockrdlock pthread_rwlock_clockwrlock pthread_rwlock_timedrdlock pthread_rwlock_timedwrlock pthread_timedjoin_np recvmmsg sched_rr_get_interval select sem_clockwait semctl semtimedop sem_timedwait setitimer settimeofday shmctl sigtimedwait stat thrd_sleep time timegm timerfd_gettime timerfd_settime timespec_get utime utimensat utimes utimes wait3 wait4 * librt: aio_suspend mq_timedreceive mq_timedsend timer_gettime timer_settime * libanl: gai_suspend Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* time: Add 64-bit time support for getdateAdhemerval Zanella2021-06-152-3/+11
| | | | | | | | | | | | The getdate is basically a wrapper localtime and mktime. The 64-bit time support is done calling the 64-bit internal functions, there is no need to add a new symbol version. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS}Adhemerval Zanella2021-06-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | The recvmsg handling is more complicated because it requires check the returned kernel control message and make some convertions. For !__ASSUME_TIME64_SYSCALLS it converts the first 32-bit time SO_TIMESTAMP or SO_TIMESTAMPNS and appends it to the control buffer if has extra space or returns MSG_CTRUNC otherwise. The 32-bit time field is kept as-is. Calls with __TIMESIZE=32 will see the converted 64-bit time control messages as spurious control message of unknown type. Calls with __TIMESIZE=64 running on pre-time64 kernels will see the original message as a spurious control ones of unknown typ while running on kernel with native 64-bit time support will only see the time64 version of the control message. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Implement raise in terms of pthread_killAdhemerval Zanella2021-06-091-0/+5
| | | | | | | | | | | | | | | | Now that pthread_kill is provided by libc.so it is possible to implement the generic POSIX implementation as 'pthread_kill(pthread_self(), sig)'. For Linux implementation, pthread_kill read the targeting TID from the TCB. For raise, this it not possible because it would make raise fail when issue after vfork (where creates the resulting process has a different TID from the parent, but its TCB is not updated as for pthread_create). To make raise use pthread_kill, it is make usable from vfork by getting the target thread id through gettid syscall. Checked on x86_64-linux-gnu and aarch64-linux-gnu.
* dlfcn: Rework static dlopen hooksFlorian Weimer2021-06-031-17/+14
| | | | | | | | | | | | | | Consolidate all hooks structures into a single one. There are no static dlopen ABI concerns because glibc 2.34 already comes with substantial ABI-incompatible changes in this area. (Static dlopen requires the exact same dynamic glibc version that was used for static linking.) The new approach uses a pointer to the hooks structure into _rtld_global_ro and initalizes it in __rtld_static_init. This avoids a back-and-forth with various callback functions. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: Cleanups after -ldl is no longer requiredFlorian Weimer2021-06-031-18/+0
| | | | | | | | | | | | This commit removes the ELF constructor and internal variables from dlfcn/dlfcn.c. The file now serves the same purpose as nptl/libpthread-compat.c, so it is renamed to dlfcn/libdl-compat.c. The use of libdl-shared-only-routines ensures that libdl.a is empty. This commit adjusts the test suite not to use $(libdl). The libdl.so symbolic link is no longer installed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: Move dlopen into libcFlorian Weimer2021-06-031-2/+1
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: Move dlvsym into libcFlorian Weimer2021-06-031-3/+3
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: Move dlinfo into libcFlorian Weimer2021-06-031-1/+1
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: Move dladdr1 into libcFlorian Weimer2021-06-031-2/+1
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: Move dlmopen into libcFlorian Weimer2021-06-031-6/+6
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: Move dlsym into libcFlorian Weimer2021-06-031-2/+2
| | | | | | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. In elf/Makefile, remove the $(libdl) dependency from testobj1.so because it the unused libdl DSO now causes elf/tst-unused-deps to fail. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: Move dladdr into libcFlorian Weimer2021-06-031-2/+1
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: Move dlclose into libcFlorian Weimer2021-06-031-2/+5
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: Move dlerror into libcFlorian Weimer2021-06-021-5/+3
| | | | | | | | | | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. There is a minor functionality enhancement: dlerror now sets errno if it was set as part of the exception. (This is the result of using %m in asprintf, to avoid the strerror PLT call.) The previous errno value upon function return was unpredictable. Documenting this as a feature is premature; we need to make sure that the error codes are meaningful when they are set by the dynamic loader. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Update floating-point feature test macro handling for C2XJoseph Myers2021-06-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ISO C2X has made some changes to the handling of feature test macros related to features from the floating-point TSes, and to exactly what such features are present in what headers, that require corresponding changes in glibc. * For the few features that were controlled by __STDC_WANT_IEC_60559_BFP_EXT__ (and the corresponding DFP macro) in C2X, there is now instead a new feature test macro __STDC_WANT_IEC_60559_EXT__ covering both binary and decimal FP. This controls CR_DECIMAL_DIG in <float.h> (provided by GCC; I implemented support for the new feature test macro for GCC 11) and the totalorder and payload functions in <math.h>. C2X no longer says anything about __STDC_WANT_IEC_60559_BFP_EXT__ (so it's appropriate for that macro to continue to enable exactly the features from TS 18661-1). * The SNAN macros for each floating-point type have moved to <float.h> (and been renamed in the process). Thus, the copies in <math.h> should only be defined for __STDC_WANT_IEC_60559_BFP_EXT__, not for C2X. * The fmaxmag and fminmag functions have been removed (replaced by new functions for the new min/max operations in IEEE 754-2019). Thus those should also only be declared for __STDC_WANT_IEC_60559_BFP_EXT__. * The _FloatN / _FloatNx handling for the last two points in glibc is trickier, since __STDC_WANT_IEC_60559_TYPES_EXT__ is still in C2X (the integration of TS 18661-3 as an Annex, that is, which hasn't yet been merged into the C standard git repository but has been accepted by WG14), so C2X with that macro should not declare some things that are declared for older standards with that macro. The approach taken here is to provide the declarations (when __STDC_WANT_IEC_60559_TYPES_EXT__ is enabled) only when (defined __USE_GNU || !__GLIBC_USE (ISOC2X)), so if C2X features are enabled then those declarations (that are only in TS 18661-3 and not in C2X) will only be provided if _GNU_SOURCE is defined as well. Thus _GNU_SOURCE remains a superset of the TS features as well as of C2X. Some other somewhat related changes in C2X are not addressed here. There's an open proposal not to include the fmin and fmax functions for the _FloatN / _FloatNx types, given the new min/max operations, which could be handled like the previous point if adopted. And the fromfp functions have been changed to return a result in floating type rather than intmax_t / uintmax_t; my inclination there is to treat that like that change of totalorder type (new symbol versions etc. for the ABI change; old versions become compat symbols and are no longer supported as an API). Tested for x86_64 and x86.
* Add cast_to_pointer to cast an integer to void * pointerH.J. Lu2021-05-221-0/+3
|
* nptl: Move pthread_create, thrd_create into libcFlorian Weimer2021-05-211-1/+5
| | | | | | | | | | | | | | | | | | | The symbols were moved using scripts/move-symbol-to-libc.py. The libpthread placeholder symbols need some changes because some symbol versions have gone away completely. But __errno_location@@GLIBC_2.0 still exists, so the GLIBC_2.0 version is still there. The internal __pthread_create symbol now points to the correct function, so the sysdeps/nptl/thrd_create.c override is no longer necessary. There was an issue how the hidden alias of pthread_getattr_default_np was defined, so this commit cleans up that aspects and removes the GLIBC_PRIVATE export altogether. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* hurd: Add execveatSamuel Thibault2021-05-181-0/+2
|
* Add C2X timespec_getresJoseph Myers2021-05-171-0/+6
| | | | | | | | | | | | | | | | | | | ISO C2X adds a timespec_getres function alongside the C11 timespec_get, with functionality similar to that of POSIX clock_getres (including allowing a NULL pointer to be passed to the function). Implement this function for glibc, similarly to the implementation of timespec_get. This includes a basic test like that of timespec_get, but no documentation in the manual, given that TIME_UTC and timespec_get aren't documented in the manual at all. The handling of 64-bit time follows that in timespec_get; people maintaining patch series for 64-bit time will need to update them accordingly (to export __timespec_getres64, redirect calls in time.h and run the test for _TIME_BITS=64). Tested for x86_64 and x86, and (previous version; only testcase differs) with build-many-glibcs.py.
* Enable support for GCC 11 -Wmismatched-dealloc.Martin Sebor2021-05-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | To help detect common kinds of memory (and other resource) management bugs, GCC 11 adds support for the detection of mismatched calls to allocation and deallocation functions. At each call site to a known deallocation function GCC checks the set of allocation functions the former can be paired with and, if the two don't match, issues a -Wmismatched-dealloc warning (something similar happens in C++ for mismatched calls to new and delete). GCC also uses the same mechanism to detect attempts to deallocate objects not allocated by any allocation function (or pointers past the first byte into allocated objects) by -Wfree-nonheap-object. This support is enabled for built-in functions like malloc and free. To extend it beyond those, GCC extends attribute malloc to designate a deallocation function to which pointers returned from the allocation function may be passed to deallocate the allocated objects. Another, optional argument designates the positional argument to which the pointer must be passed. This change is the first step in enabling this extended support for Glibc.
* linux: implement ttyname as a wrapper around ttyname_r.Érico Nogueira2021-05-071-2/+2
| | | | | | | | | | | | | Big win in binary size and avoids duplicating the logic in multiple places. On x86_64, dropped from 1883206 to 1881790, a 1416 byte decrease. Also changed logic to track if ttyname_buf has been allocated by checking if it's NULL instead of tracking buflen as an additional variable. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* linux: Use sched_getaffinity for __get_nprocs (BZ #27645)Adhemerval Zanella2021-05-071-0/+8
| | | | | | | | Both the sysfs and procfs parsing (through GET_NPROCS_PARSER) are removed in favor the syscall. The initial scratch buffer should fit to most of the common usage (1024 bytes with maps to 8192 CPUs). Checked on x86_64-linux-gnu and aarch64-linux-gnu.
* nptl: Move pthread_barrier_init into libcFlorian Weimer2021-05-061-0/+3
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move sem_close, sem_open into libcFlorian Weimer2021-05-052-0/+2
| | | | | | | | | | | The symbols were moved using move-symbol-to-libc.py. Both functions are moved at the same time because they depend on internal functions in sysdeps/pthread/sem_routines.c, which are moved in this commit as well. Additional hidden prototypes are required to avoid check-localplt failures. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: dlerror needs to call free from the base namespace [BZ #24773]Florian Weimer2021-04-211-2/+0
| | | | | | | | | | | | Calling free directly may end up freeing a pointer allocated by the dynamic loader using malloc from libc.so in the base namespace using the allocator from libc.so in a secondary namespace, which results in crashes. This commit redirects the free call through GLRO and the dynamic linker, to reach the correct namespace. It also cleans up the dlerror handling along the way, so that pthread_setspecific is no longer needed (which avoids triggering bug 24774).
* nptl: Move __pthread_unwind_next into libcFlorian Weimer2021-04-211-2/+2
| | | | | | | | | | | | | | | | | | | It's necessary to stub out __libc_disable_asynccancel and __libc_enable_asynccancel via rtld-stubbed-symbols because the new direct references to the unwinder result in symbol conflicts when the rtld exception handling from libc is linked in during the construction of librtld.map. unwind-forcedunwind.c is merged into unwind-resume.c. libc now needs the functions that were previously only used in libpthread. The GLIBC_PRIVATE exports of __libc_longjmp and __libc_siglongjmp are no longer needed, so switch them to hidden symbols. The symbol __pthread_unwind_next has been moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
* Set the retain attribute on _elf_set_element if CC supports [BZ #27492]Fangrui Song2021-04-161-4/+10
| | | | | | | | | | | | | | | | | | | | | | So that text_set_element/data_set_element/bss_set_element defined variables will be retained by the linker. Note: 'used' and 'retain' are orthogonal: 'used' makes sure the variable will not be optimized out; 'retain' prevents section garbage collection if the linker support SHF_GNU_RETAIN. GNU ld 2.37 and LLD 13 will support -z start-stop-gc which allow C identifier name sections to be GCed even if there are live __start_/__stop_ references. Without the change, there are some static linking problems, e.g. _IO_cleanup (libio/genops.c) may be discarded by ld --gc-sections, so stdout is not flushed on exit. Note: GCC may warning 'retain' attribute ignored while __has_attribute(retain) is 1 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587). Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* linux: Normalize and return timeout on select (BZ #27651)Adhemerval Zanella2021-04-121-0/+5
| | | | | | | | | | | | | | | | | | | | The commit 2433d39b697, which added time64 support to select, changed the function to use __NR_pselect6 (or __NR_pelect6_time64) on all architectures. However, on architectures where the symbol was implemented with __NR_select the kernel normalizes the passed timeout instead of return EINVAL. For instance, the input timeval { 0, 5000000 } is interpreted as { 5, 0 }. And as indicated by BZ #27651, this semantic seems to be expected and changing it results in some performance issues (most likely the program does not check the return code and keeps issuing select with unormalized tv_usec argument). To avoid a different semantic depending whether which syscall the architecture used to issue, select now always normalize the timeout input. This is a slight change for some ABIs (for instance aarch64). Checked on x86_64-linux-gnu and i686-linux-gnu.