about summary refs log tree commit diff
path: root/sysdeps
Commit message (Collapse)AuthorAgeFilesLines
* nptl: Eliminate <smp.h> and __is_smpFlorian Weimer2020-11-133-78/+20
| | | | | | | | | | | Most systems are SMP, so optimizing for the UP case is no longer approriate. A dynamic check based on the kernel identification has been only implemented for i386 anyway. To disable adaptive mutexes on sh, define DEFAULT_ADAPTIVE_COUNT as zero for this architecture. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* powerpc: Eliminate UP macro conditionalsFlorian Weimer2020-11-133-14/+5
| | | | | | The macro is never defined. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* x86: Remove UP macro. Define LOCK_PREFIX unconditionally.Florian Weimer2020-11-135-35/+5
| | | | | | | The UP macro is never defined. Also define LOCK_PREFIX unconditionally, to the same string. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* alpha: Remove UP preprocessor conditionalsFlorian Weimer2020-11-131-10/+4
| | | | | | The macro is never defined. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* hurd: Make sure signals get startedSamuel Thibault2020-11-131-3/+3
| | | | | | Now that _hurd_libc_proc_init is idempotent, we can always call it, independently of the __libc_multiple_libcs test which may not match whether signals should be started or not.
* powerpc: Add optimized stpncpy for POWER9Raphael M Zinsly2020-11-126-2/+135
| | | | | | | Add stpncpy support into the POWER9 strncpy. Reviewed-by: Matheus Castanho <msc@linux.ibm.com> Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
* powerpc: Add optimized strncpy for POWER9Raphael M Zinsly2020-11-125-1/+391
| | | | | | | | Similar to the strcpy P9 optimization, this version uses VSX to improve performance. Reviewed-by: Matheus Castanho <msc@linux.ibm.com> Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
* hurd: Move {,f,l}xstat{,at} and xmknod{at} to compat symbolsSamuel Thibault2020-11-1125-188/+510
| | | | | | We do not actually need them, so we can move their implementations into the standard {,f,l}stat{,at} variants and only keep compatibility wrappers.
* hurd: Notify the proc server later during initializationSamuel Thibault2020-11-112-0/+6
| | | | | | Notifying the proc server is an involved task, and unleashes various signal handling etc. so we have to do this after e.g. ifunc relocations are completed.
* htl: Initialize laterSamuel Thibault2020-11-116-116/+29
| | | | | | | | Since htl does not actually need a stack switch, we can initialize it like nptl is, avoiding all sorts of startup issues with ifunc. More precisely, htl defines __pthread_initialize_minimal instead of the elder _cthread_init_routine. We can then drop the stack switching dances.
* htl: Fix spurious symbols in namespacesSamuel Thibault2020-11-115-5/+5
| | | | | pthread_attr_{{get,set}stack{addr,size},setstack} were defining a strong alias for no reason, turning them to weak.
* Use O_CLOEXEC in sysconf [BZ #26791]Maximilian Krüger2020-11-111-1/+1
| | | | | If sysconf is used in multithreaded processes, various filedescriptors may leak due to missing O_CLOEXEC. This commit adds the flag.
* struct _Unwind_Exception alignment should not depend on compiler flagsFlorian Weimer2020-11-111-9/+15
| | | | | | | | | | | | __attribute__((__aligned__)) selects an alignment that depends on the micro-architecture selected by GCC flags. Enabling vector extensions may increase the allignment. This is a problem when building glibc as a collection of ELF multilibs with different GCC flags because ld.so and libc.so/libpthread.so/&c may end up with a different layout of struct pthread because of the changing offset of its struct _Unwind_Exception field. Tested-By: Matheus Castanho <msc@linux.ibm.com>
* hurd: keep only required PLTs in ld.soSamuel Thibault2020-11-117-26/+6
| | | | | | | | | | | | | | | | | | | | | We need NO_RTLD_HIDDEN because of the need for PLT calls in ld.so. See Roland's comment in https://sourceware.org/bugzilla/show_bug.cgi?id=15605 "in the Hurd it's crucial that calls like __mmap be the libc ones instead of the rtld-local ones after the bootstrap phase, when the dynamic linker is being used for dlopen and the like." We used to just avoid all hidden use in the rtld ; this commit switches to keeping only those that should use PLT calls, i.e. essentially those defined in sysdeps/mach/hurd/dl-sysdep.c: __assert_fail __assert_perror_fail __*stat64 _exit This fixes a few startup issues, notably the call to __tunable_get_val that is made before PLTs are set up.
* hurd: Add missing startup callsSamuel Thibault2020-11-111-0/+16
| | | | | | DL_SYSDEP_INIT and DL_PLATFORM_INIT were not getting called, leading to missing x86 platform tuning, now mandatory with 0f09154c6400 ("x86: Initialize CPU info via IFUNC relocation [BZ 26203]")
* riscv: Get cache information through sysconfZong Li2020-11-101-0/+100
| | | | | | | | Add support to query cache information on RISC-V through sysconf() function. The cache information had been added in AUX vector of RISC-V architecture in Linux kernel v.5.10-rc1. Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com> Acked-by: Palmer Dabbelt <palmerdabbelt@google.com>
* RISC-V: Add _dl_start_user.Jim Wilson2020-11-101-1/+3
| | | | | | | | | | | | | This is required for the debugglibc.sh script to work. Tested by successfully using this patched script, and a riscv64-linux testsuite run. We could perhaps call RTLD_EPILOGUE for ENTRY_POINT before calling RTLD_PROLOGUE for _dl_start_user, but I don't think it matters. OK? Jim
* linux: Allow adjtime with NULL argument [BZ #26833]Adhemerval Zanella2020-11-091-3/+8
| | | | | | | | | | | The adjtime interface allows return the amount of time remaining from any previous adjustment that has not yet been completed by passing a NULL as first argument. This was introduced with y2038 support 0308077e3a. Checked on i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* aarch64: Add unwind information to _start (bug 26853)Florian Weimer2020-11-091-4/+3
| | | | | | | This adds CFI directives which communicate that the stack ends with this function. Fixes bug 26853.
* bsd unlockpt: unlockpt needs to fail with EINVAL, not ENOTTYSamuel Thibault2020-11-081-1/+6
| | | | | The EINVAL error code is mandated by POSIX, while ptsname_r returns ENOTTY, so we need to translate.
* Rearrange bsd_getpt vs bsd_openpt and implement posix_openpt on BSDSamuel Thibault2020-11-071-10/+8
| | | | | | | | | * sysdeps/unix/bsd/getpt.c (__getpt): Add oflag parameter, pass it to the _open call and rename to... (__bsd_openpt): ... new function. (__getpt): Reimplement on top of __bsd_openpt. (__posix_openpt): Replace stub with implementation on top of __bsd_openpt. (posix_openpt): Remove stub warning.
* msg: Remove redundant #include <sys/msg.h> headerLukasz Majewski2020-11-046-6/+0
| | | | | | | | | The #include <sys/msg.h> is redundant as we do not use message specific types for issuing syscalls to handle msg and shm. Only msgctl requires this header. Build tests: ./src/scripts/build-many-glibcs.py glibcs
* aarch64: Add variant PCS lazy binding test [BZ #26798]Szabolcs Nagy2020-11-025-0/+288
| | | | | | | | | | | This test fails without bug 26798 fixed because some integer registers likely get clobbered by lazy binding and variant PCS only allows x16 and x17 to be clobbered at call time. The test requires binutils 2.32.1 or newer for handling variant PCS symbols. SVE registers are not covered by this test, to avoid the complexity of handling multiple compile- and runtime feature support cases.
* aarch64: Fix DT_AARCH64_VARIANT_PCS handling [BZ #26798]Szabolcs Nagy2020-11-021-8/+4
| | | | | | | | | | | | | The variant PCS support was ineffective because in the common case linkmap->l_mach.plt == 0 but then the symbol table flags were ignored and normal lazy binding was used instead of resolving the relocs early. (This was a misunderstanding about how GOT[1] is setup by the linker.) In practice this mainly affects SVE calls when the vector length is more than 128 bits, then the top bits of the argument registers get clobbered during lazy binding. Fixes bug 26798.
* hurd: Correct 'ethenet' spellingJonny Grant2020-10-311-1/+1
| | | | Signed-off-by: Jonny Grant <jg@jguk.org>
* Avoid -Wstringop-overflow warning in pthread_cleanup_push macrosJoseph Myers2020-10-301-10/+27
| | | | | | | | | | | | | | | | | | | | | GCC 11 introduces a -Wstringop-overflow warning for calls to functions with an array argument passed as a pointer to memory not large enough for that array. This includes the __sigsetjmp calls from pthread_cleanup_push macros, because those use a structure in __pthread_unwind_buf_t, which has a common initial subsequence with jmp_buf but does not include the saved signal mask; this is OK in this case because the second argument to __sigsetjmp is 0 so the signal mask is not accessed. To avoid this warning, use a function alias __sigsetjmp_cancel with first argument an array of exactly the type used in the calls to the function, if using GCC 11 or later. With older compilers, continue to use __sigsetjmp with a cast, to avoid any issues with compilers predating the returns_twice attribute not applying the same special handling to __sigsetjmp_cancel as to __sigsetjmp. Tested with build-many-glibcs.py for arm-linux-gnueabi that this fixes the testsuite build failures.
* elf: Unify old and new format cache handling code in ld.soFlorian Weimer2020-10-301-4/+13
| | | | | | | struct file_entry_new starts with the fields of struct file_entry, so the code can be shared if the size computation is made dynamic. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* x86: Restore processing of cache size tunables in init_cacheinfoFlorian Weimer2020-10-281-8/+4
| | | | | Fixes and partially reverts commit 59803e81f96b479c17f583b31eac44b5 ("x86: Optimizing memcpy for AMD Zen architecture.").
* x86: Optimizing memcpy for AMD Zen architecture.Sajan Karumanchi2020-10-281-6/+26
| | | | | | | | | | | | | | Modifying the shareable cache '__x86_shared_cache_size', which is a factor in computing the non-temporal threshold parameter '__x86_shared_non_temporal_threshold' to optimize memcpy for AMD Zen architectures. In the existing implementation, the shareable cache is computed as 'L3 per thread, L2 per core'. Recomputing this shareable cache as 'L3 per CCX(Core-Complex)' has brought in performance gains. As per the large bench variant results, this patch also addresses the regression problem on AMD Zen architectures. Reviewed-by: Premachandra Mallappa <premachandra.mallappa@amd.com>
* Hurd: Fix ftime buildAdhemerval Zanella2020-10-271-0/+54
| | | | | | | | It does not provide __clock_gettime64, the ftime y2038 support is moved to a Linux specific implementation. Checked with a build for i686-linux-gnu and on x86_64-linux and i686-linux-gnu.
* Add IP_RECVERR_RFC4884 and IPV6_RECVERR_RFC4884 from Linux 5.9.Joseph Myers2020-10-271-0/+2
| | | | | | | Add the new constants IP_RECVERR_RFC4884 and IPV6_RECVERR_RFC4884 from Linux 5.9 to bits/in.h. Tested for x86_64.
* Reinstate ftime and add deprecate message on ftime usageAdhemerval Zanella2020-10-271-0/+1
| | | | | | | This patch revert "Move ftime to a compatibility symbol" (commit 14633d3e568eb9770a7e5046eff257113e0453fb). Checked on x86_64-linux-gnu and i686-linux-gnu.
* Update kernel version to 5.9 in tst-mman-consts.py.Joseph Myers2020-10-261-1/+1
| | | | | | | | This patch updates the kernel version in the test tst-mman-consts.py to 5.9. (There are no new MAP_* constants covered by this test in 5.9 that need any other header changes.) Tested with build-many-glibcs.py.
* Update syscall lists for Linux 5.9.Joseph Myers2020-10-2326-2/+28
| | | | | | | | Linux 5.9 has one new syscall, close_range. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py.
* y2038: nptl: Provide __futex_clock_wait_bitset64 to support 64 bit bitsetLukasz Majewski2020-10-212-1/+52
| | | | | | | | | | | | | | | The commit: "y2038: nptl: Convert pthread_mutex_{clock|timed}lock to support 64 bit" SHA1: 29e9874a048f47e2d46c40253036c8d2de921548 introduced support for 64 bit timeouts. Unfortunately, it was missing the code for bitset - i.e. lll_futex_clock_wait_bitset C preprocessor macro was used. As a result the 64 bit struct __timespec64 was coerced to 32 bit struct timespec and regression visible as timeout was observed (nptl/tst-robust10 on s390). Reported-by: Stefan Liebler <stli@linux.ibm.com> Tested-by: Stefan Liebler <stli@linux.ibm.com>
* C-SKY: Make dynamic linker's name compitable with the older gcc.Cooper Qu2020-10-211-9/+26
| | | | | | | | | | | | | | __CSKY_HARD_FLOAT_ABI__ was added on gcc 11 to specify whether -mfloat-abi=hard is set. On older gcc, the float ABI is defined solely with __CSKY_HARD_FLOAT__. If __CSKY_HARD_FLOAT__ is set, it can be either a hard-float ABI (gcc older than 11, or gcc11 -mfloat-abi=hard (__CSKY_HARD_FLOAT_ABI__ is set) or -mfloat-abi=softfp (__CSKY_HARD_FLOAT_ABI__ is not set). To be compatible with older gcc, use __CSKY_HARD_FLOAT_FPU_SF__ identify if -mfloat-abi is supported, because it is added to gcc at the same time as -mfloat-abi. Reviewed-by: Mao Han <han_mao@linux.alibaba.com> Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
* Revert "C-SKY:Fix dynamic linker's name when mfloat-abi=softfp."Mao Han2020-10-201-1/+1
| | | | This reverts commit 7449320983b664aba506d7674ea0ce142dd3d4ed.
* Move vtimes to a compatibility symbolAdhemerval Zanella2020-10-191-1/+0
| | | | | | | | | | | | | | I couldn't pinpoint which standard has added it, but no other POSIX system supports it and/or no longer provide it. The 'struct vtimes' also has a lot of drawbacks due its limited internal type size. I couldn't also see find any project that actually uses this symbol, either in some dignostic way (such as sanitizer). So I think it should be safer to just move to compat symbol, instead of deprecated. The idea it to avoid new ports to export such broken interface (riscv32 for instance). Checked on x86_64-linux-gnu and i686-linux-gnu.
* y2038: linux: Provide __time64 implementationLukasz Majewski2020-10-193-3/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the glibc the time function can use vDSO (on power and x86 the USE_IFUNC_TIME is defined), time syscall or 'default' time() from ./time/time.c (as a fallback). In this patch the last function (time) has been refactored and moved to ./sysdeps/unix/sysv/linux/time.c to be Linux specific. The new __time64 explicit 64 bit function for providing 64 bit value of seconds after epoch (by internally calling __clock_gettime64) has been introduced. Moreover, a 32 bit version - __time has been refactored to internally use __time64. The __time is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary check for time_t potential overflow. The iFUNC vDSO direct call optimization has been removed from both i686 and powerpc32 (USE_IFUNC_TIME is not defined for those architectures anymore). The Linux kernel does not provide a y2038 safe implementation of time neither it plans to provide it in the future, __clock_gettime64 should be used instead. Keeping support for this optimization would require to handle another build permutation (!__ASSUME_TIME64_SYSCALLS && USE_IFUNC_TIME which adds more complexity and has limited use (since the idea is to eventually have a y2038 safe glibc build). Build tests: ./src/scripts/build-many-glibcs.py glibcs Run-time tests: - Run specific tests on ARM/x86 32bit systems (qemu): https://github.com/lmajewski/meta-y2038 and run tests: https://github.com/lmajewski/y2038-tests/commits/master Above tests were performed with Y2038 redirection applied as well as without to test proper usage of both __time64 and __time. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* C-SKY:Fix dynamic linker's name when mfloat-abi=softfp.Cooper Qu2020-10-191-1/+1
| | | | | | | | The dynamic linker should be chosen according to float abi, the predefined macro __CSKY_HARD_FLOAT__ stand for architecure not abi. Reviewed-by: Mao Han <han_mao@linux.alibaba.com>
* x86: Initialize CPU info via IFUNC relocation [BZ 26203]H.J. Lu2020-10-169-865/+949
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | X86 CPU features in ld.so are initialized by init_cpu_features, which is invoked by DL_PLATFORM_INIT from _dl_sysdep_start. But when ld.so is loaded by static executable, DL_PLATFORM_INIT is never called. Also x86 cache info in libc.o and libc.a is initialized by a constructor which may be called too late. Since some fields in _rtld_global_ro in ld.so are initialized by dynamic relocation, we can also initialize x86 CPU features in _rtld_global_ro in ld.so and cache info in libc.so by initializing dummy function pointers in ld.so and libc.so via IFUNC relocation. Key points: 1. IFUNC is always supported, independent of --enable-multi-arch or --disable-multi-arch. Linker generates IFUNC relocations from input IFUNC objects and ld.so performs IFUNC relocations. 2. There are no IFUNC dependencies in ld.so before dynamic relocation have been performed, 3. The x86 CPU features in ld.so is initialized by DL_PLATFORM_INIT in dynamic executable and by IFUNC relocation in dlopen in static executable. 4. The x86 cache info in libc.o is initialized by IFUNC relocation. 5. In libc.a, both x86 CPU features and cache info are initialized from ARCH_INIT_CPU_FEATURES, not by IFUNC relocation, before __libc_early_init is called. Note: _dl_x86_init_cpu_features can be called more than once from DL_PLATFORM_INIT and during relocation in ld.so.
* linux: Add __readdir_unlockedAdhemerval Zanella2020-10-162-67/+29
| | | | | | And use it on readdir_r implementation. Checked on i686-linux-gnu.
* linux: Simplify opendir buffer allocationAdhemerval Zanella2020-10-161-33/+18
| | | | | | | | | The fallback allocation is removed, so the possible size constraint should be analyzed just once; __alloc_dir assumes that 'statp' argument is non-null, and the max_buffer_size move to close its used. Checked on x86_64-linux-gnu and i686-linux-gnu.
* linux: Move posix dir implementations to LinuxAdhemerval Zanella2020-10-1614-309/+462
| | | | | | | | | | | | | This generic implementation already expects a getdents API which is Linux specific. It also allows simplify it by assuming _DIRENT_HAVE_D_RECLEN and _DIRENT_HAVE_D_OFF support. The readdir are also expanded on each required implementation, futher fixes and improvements will make parametrize the implementation more complex. Checked on x86_64-linux-gnu, i686-linux-gnu, and with a build for all affected ABIs.
* linux: Add 64-bit time_t support for wait3Adhemerval Zanella2020-10-161-0/+44
| | | | | | | | It basically calls the 64-bit time_t wait4 internal symbol. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Move ftime to a compatibility symbolAdhemerval Zanella2020-10-161-1/+0
| | | | | | | | | | It was made deprecated on 2.31, so it moves to compat symbol after two releases. It was also removed from exported symbol for riscv32 (since ABI will be supported on for 2.33). Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* linux: Fix time64 support for futimesatAdhemerval Zanella2020-10-162-54/+6
| | | | | | | | | | | | The generic implementation does not support time64 and the default one return overflow for invalid tv_sec with UTIME_NOW / UTIME_OMIT (which is valid since tv_sec in such cases is ignored by the kernel). Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski <lukma@denx.de>
* linux: Use INTERNAL_SYSCALL on fstatat{64}Adhemerval Zanella2020-10-164-28/+34
| | | | | | | | | | | | | | | | | | | Although not required by the standards, some code expects that a successful stat call should not set errno. However since aa03f722f3b99 'linux: Add {f}stat{at} y2038 support', on 32-bit systems with 32-bit time_t supporrt, stat implementation will first issues __NR_statx and if it fails with ENOSYS issue the system stat syscall. On architecture running on kernel without __NR_statx support the first call will set the errno to ENOSYS, even when the following stat syscall might not fail. This patch fixes by using INTERNAL_SYSCALL and only setting the errno value when function returns. Checked on i686-linux-gnu, x86_64-linux-gnu, sparc64-linux-gnu, sparcv9-linux-gnu, powerpc64-linux-gnu, powerpc64le-linux-gnu, arm-linux-gnueabihf, and aarch64-linux-gnu.
* sysvipc: Fix tst-sysvshm-linux on x32Adhemerval Zanella2020-10-151-4/+5
| | | | | | | | | The Linux shminfo fields are '__syscall_ulong_t' (which is 64-bit for x32). This patch fixes the test to compare againt the correct type and to only clamp the value if '__syscall_ulong_t' is the same size of 'unsigned long int'. Checked on x86_64-linux-gnu-x32.
* x86/CET: Update vfork to prevent child returnH.J. Lu2020-10-154-71/+113
| | | | | | | | | Child of vfork should either call _exit or one of the exec family of functions. But normally there is nothing to prevent child of vfork from return of the vfork-calling function. Simpilfy x86 vfork when shadow stack is in use to introduce mismatched shadow stack in child of vfork to trigger SIGSEGV when the child returns from the function in which vfork was called.