aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-03-13x86_64: Add atanh with FMASunil K Pandey5-0/+51
On SPR, it improves atanh bench performance by: Before After Improvement reciprocal-throughput 15.1715 14.8628 2% latency 57.1941 56.1883 2% Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-13elf: Canonicalize $ORIGIN in an explicit ld.so invocation [BZ 25263]Adhemerval Zanella13-74/+214
When an executable is invoked directly, we calculate $ORIGIN by calling readlink on /proc/self/exe, which the Linux kernel resolves to the target of any symlinks. However, if an executable is run through ld.so, we cannot use /proc/self/exe and instead use the path given as an argument. This leads to a different calculation of $ORIGIN, which is most notable in that it causes ldd to behave differently (e.g., by not finding a library) from directly running the program. To make the behavior consistent, take advantage of the fact that the kernel also resolves /proc/self/fd/ symlinks to the target of any symlinks in the same manner, so once we have opened the main executable in order to load it, replace the user-provided path with the result of calling readlink("/proc/self/fd/N"). (On non-Linux platforms this resolution does not happen and so no behavior change is needed.) The __fd_to_filename requires _fitoa_word and _itoa_word, which for 32-bits pulls a lot of definitions from _itoa.c (due _ITOA_NEEDED being defined). To simplify the build move the required function to a new file, _fitoa_word.c. Checked on x86_64-linux-gnu and i686-linux-gnu. Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com> Reviewed-by: Geoffrey Thomas <geofft@ldpreload.com> Tested-by: Geoffrey Thomas <geofft@ldpreload.com>
2025-03-13x86_64: Add sinh with FMASunil K Pandey5-0/+58
On SPR, it improves sinh bench performance by: Before After Improvement reciprocal-throughput 14.2017 11.815 17% latency 36.4917 35.2114 4% Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-13benchtests: Remove wrong snippet from 360cce0b06Adhemerval Zanella1-1/+0
2025-03-13x86_64: Add tanh with FMASunil K Pandey4-0/+49
On Skylake, it improves tanh bench performance by: Before After Improvement max 110.89 95.826 14% min 20.966 20.157 4% mean 30.9601 29.8431 4% Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-13nptl: Check if thread is already terminated in sigcancel_handler (BZ 32782)Adhemerval Zanella4-6/+83
The SIGCANCEL signal handler should not issue __syscall_do_cancel, which calls __do_cancel and __pthread_unwind, if the cancellation is already in proces (and libgcc unwind is not reentrant). Any cancellation signal received after is ignored. Checked on x86_64-linux-gnu and aarch64-linux-gnu. Tested-by: Aurelien Jarno <aurelien@aurel32.net> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-13nptl: PTHREAD_COND_INITIALIZER compatibility with pre-2.41 versions (bug 32786)Florian Weimer2-1/+3
The new initializer and struct layout does not initialize the __g_signals field in the old struct layout before the change in commit c36fc50781995e6758cae2b6927839d0157f213c ("nptl: Remove g_refs from condition variables"). Bring back fields at the end of struct __pthread_cond_s, so that they are again zero-initialized. Reviewed-by: Sam James <sam@gentoo.org>
2025-03-12getaddrinfo.c: support MPTCP (BZ #29609)zhenwei pi2-0/+29
There is a lack of MPTCP support from gaih_inet_typeproto array, add MPTCP entry. Signed-off-by: zhenwei pi <zhenwei.pi@linux.dev> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-03-12math: Refactor how to use libm-test-ulpsAdhemerval Zanella62-33869/+417
The current approach tracks math maximum supported errors by explicitly setting them per function and architecture. On newer implementations or new compiler versions, the file is updated with newer values if it shows higher results. The idea is to track the maximum known error, to update the manual with the obtained values. The constant libm-test-ulps shows little value, where it is usually a mechanical change done by the maintainer, for past releases it is usually ignored whether the ulp change resulted from a compiler regression, and the math tests already have a maximum ulp error that triggers a regression. It was shown by a recent update after the new acosf [1] implementation that is correctly rounded, where the libm-test-ulps was indeed from a compiler issue. This patch removes all arch-specific libm-test-ulps, adds system generic libm-test-ulps where applicable, and changes its semantics. The generic files now track specific implementation constraints, like if it is expected to be correctly rounded, or if the system-specific has different error expectations. Now multiple libm-test-ulps can be defined, and system-specific overrides generic implementation. This is for the case where arch-specific implementation might show worse precision than generic implementation, for instance, the cbrtf on i686. Regressions are only reported if the implementation shows larger errors than 9 ulps (13 for IBM long double) unless it is overridden by libm-test-ulps and the maximum error is not printed at the end of tests. The regen-ulps rule is also removed since it does not make sense to update the libm-test-ulps automatically. The manual error table is also removed, Paul Zimmermann and others have been tracking libm precision with a more comprehensive analysis for some releases; so link to his work instead. [1] https://sourceware.org/git/?p=glibc.git;a=commit;h=9cc9f8e11e8fb8f54f1e84d9f024917634a78201
2025-03-12Update syscall lists for Linux 6.13Joseph Myers26-2/+106
Linux 6.13 adds four new syscalls. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py.
2025-03-12Makefile: Clean up pthread_atfork integrationFlorian Weimer2-3/+1
Do not add the pthread_atfork routine again in nptl/Makefile, instead rely on sysdeps/pthread/Makefile for the integration (as this is the directory that contains the source file). In sysdeps/pthread/Makefile, add to static-only-routines. Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-12nptl: Include <stdbool.h> in tst-pthread_gettid_np.cFlorian Weimer1-0/+1
The test uses the while (true) construct.
2025-03-12Linux: Add new test misc/tst-sched_setattr-threadFlorian Weimer2-0/+117
The straightforward sched_getattr call serves as a test for bug 32781, too. Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-12Linux: Remove attribute access from sched_getattr (bug 32781)Florian Weimer1-1/+1
The GCC attribute expects an element count, not bytes.
2025-03-12Linux: Add the pthread_gettid_np function (bug 27880)Florian Weimer39-0/+171
Current Bionic has this function, with enhanced error checking (the undefined case terminates the process). Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-11elf: Test dlopen (NULL, RTLD_LAZY) from an ELF constructorFlorian Weimer5-0/+149
This call must not complete initialization of all shared objects in the global scope because the ELF constructor which makes the call likely has not finished initialization. Calling more constructors at this point would expose those to a partially constructed dependency. This completes the revert of commit 9897ced8e78db5d813166a7ccccfd5a ("elf: Run constructors on cyclic recursive dlopen (bug 31986)").
2025-03-11s390x: Regenerate ULPs.Stefan Liebler1-0/+20
Needed due to: "Implement C23 rsqrt" commit ID 77261698b4e938020a1b2032709a54d942ba330f Same max ulps as used for x86_64 in the mentioned commit.
2025-03-08math: Remove an extra semicolon in math function declarationsAurelien Jarno1-1/+1
Commit 6bc301672bfbd ("math: Remove __XXX math functions from installed math.h [BZ #32418]") left an extra semicolon after macro expansion. For instance the ceil declaration after expansion is: extern double ceil (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));; This chokes very naive parsers like gauche c-wrapper. Fix that by removing that extra semicolon in the macro. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-03-07nptl: extend test coverage for sched_yieldSergey Kolosov2-3/+38
We add sched_yield() API testing to the existing thread affinity test case because it allows us to test sched_yield() operation in the following scenarios: * On a main thread. * On multiple threads simultaneously. * On every CPU the system reports simultaneously. The ensures we exercise sched_yield() in as many scenarios as we would exercise calls to the affinity functions. Additionally, the test is improved by adding a semaphore to coordinate all the threads running, so that an early starter thread won't consume cpu resources that could be used to start the other threads. Co-authored-by: DJ Delorie <dj@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-03-07posix: Move environ helper variables next to environ definition (bug 32541)Florian Weimer4-3/+44
This helps with statically interposing getenv. Updates commit 7a61e7f557a97ab597d6fca5e2d1f13f65685c61 ("stdlib: Make getenv thread-safe in more cases"). Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-07Implement C23 rsqrtJoseph Myers50-2/+3865
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the rsqrt functions (1/sqrt(x)). The test inputs are taken from those for sqrt. Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-03-07Use binutils 2.44 branch and Linux 6.13 in build-many-glibcs.pyJoseph Myers1-2/+2
Tested with build-many-glibcs.py (host-libraries, compilers and glibcs builds).
2025-03-07elf: Fix handling of symbol versions which hash to zero (bug 29190)Florian Weimer9-6/+185
This was found through code inspection. No application impact is known. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-03-07configure: Fix spelling of -Wl,--no-error-execstack optionFlorian Weimer2-3/+3
BFD ld recognizes all -no-* options (with a single leading dash) unconditionally. Fixes commit a2bd5008a99032830add3e4005c25b61e3207112 ("Pass -Wl,--no-error-execstack for tests where -Wl,-z,execstack is used [PR32717]").
2025-03-06manual: Mark perror as MT-unsafe and update check-safety.shCarlos O'Donell2-25/+61
The manual marked perror as MT-safe, but then listed a remark indicating that it was unsafe because of a race between the function and access to stderr. The function is indeed MT-unsafe because of the unlocked access to stderr internals and bug 32730 has been filed to address this issue. The script manual/check-safety.sh should have caught this issue, but a missed escaping of "?" along with searching of all inputs again via "$@" resulted in a non-functional regexp. In order to avoid regressions we also update check-safety.sh. The script manual/check-safety.sh is updated in the following ways: * The MT-unsafe remarks in MT-safe context check is fixed. - It now detects the perror safety note mistake. * Comments updated indicating that we allow MT context marks to count for other contexts if they are related. - This is why commit ad9c4c536115ba38be3e63592a632709ec8209b4 failed and the failure is now understood as expected. * All checks now have verbose output. * Back reference based duplicate checks are removed. - They are too complex and don't cover all cases. No regressions on x86_64.
2025-03-07elf: Check if __attribute__ ((aligned (65536))) is supportedH.J. Lu3-5/+48
The BZ #32763 tests fail to build for MicroBlaze (which defines MAX_OFILE_ALIGNMENT to (32768*8) in GCC, so __attribute__ ((aligned (65536))) is unsupported). Add a configure-time check to enable BZ #32763 tests only if __attribute__ ((aligned (65536))) is supported. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2025-03-06htl: Make __pthread_create_internal directly call __pthread_sigmaskSamuel Thibault1-4/+1
__pthread_sigmask will already know to pass our current ss to __sigthreadmask.
2025-03-06htl: Make __pthread_sigmask directly call __sigthreadmaskSamuel Thibault2-3/+4
If no thread was created yet, __pthread_sigstate will not find our ss because self->kernel_thread is still nul, and then change the global sigstate instead of our sigstate! We can directly call __sigthreadmask and skip the (bogus) lookup step.
2025-03-06hurd: Consolidate signal mask changeSamuel Thibault5-103/+92
__pthread_sigstate and __sigprocmask were already the same, except for clear_pending.
2025-03-06static-pie: Skip the empty PT_LOAD segment at offset 0 [BZ #32763]H.J. Lu4-1/+56
As shown in https://sourceware.org/bugzilla/show_bug.cgi?id=25237 linker may generate an empty PT_LOAD segments at offset 0: Elf file type is EXEC (Executable file) Entry point 0x4000e8 There are 3 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000 0x00000000000000f0 0x00000000000000f0 R E 0x1000 LOAD 0x0000000000000000 0x0000000000410000 0x0000000000410000 0x0000000000000000 0x0000000000b5dce8 RW 0x10000 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 0x10 Section to Segment mapping: Segment Sections... 00 .text 01 .bss 02 Skip the empty PT_LOAD segment at offset 0 to support such binaries. This fixes BZ #32763. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2025-03-05sysdeps: linux: Add BTRFS_SUPER_MAGIC to pathconfRonan Pigott2-0/+4
btrfs has a 65535 maximum link count. Include this value in pathconf to give the real max link count for this filesystem. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-03-05linux: Prefix AT_HWCAP with 0x on LD_SHOW_AUXVAdhemerval Zanella1-4/+4
Suggested-by: Stefan Liebler <stli@linux.ibm.com> Reviewed-by: Stefan Liebler <stli@linux.ibm.com>
2025-03-05Remove dl-procinfo.hAdhemerval Zanella28-58/+0
powerpc was the only architecture with arch-specific hooks for LD_SHOW_AUXV, and with the information moved to ld diagnostics there is no need to keep the _dl_procinfo hook. Checked with a build for all affected ABIs. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
2025-03-05powerpc: Remove unused dl-procinfo.hAdhemerval Zanella6-131/+109
The _dl_string_platform is moved to hwcapinfo.h, since it is only used by hwcapinfo.c and test-get_hwcap internal test. Checked on powerpc64le-linux-gnu. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
2025-03-05powerpc: Move cache geometry information to ld diagnosticsAdhemerval Zanella2-66/+50
From LD_SHOW_AUXV output. Checked on powerpc64le-linux-gnu. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
2025-03-05powerpc: Move AT_HWCAP descriptions to ld diagnosticsAdhemerval Zanella8-211/+227
The ld.so diagnostics already prints AT_HWCAP values, but only in hexadecimal. To avoid duplicating the strings, consolidate the hwcap_names from cpu-features.h on a new file, dl-hwcap-info.h (and it also improves the hwcap string description with more values). For future AT_HWCAP3/AT_HWCAP4 extensions, it is just a matter to add them on dl-hwcap-info.c so both ld diagnostics and tunable filtering will parse the new values. Checked on powerpc64le-linux-gnu. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
2025-03-05benchtests: Add random strlen benchmarkWilco Dijkstra2-0/+195
Add a new randomized strlen test similar to bench-random-memcpy. Instead of repeating the same call to strlen over and over again, it times a large number of different strings. The distribution of the string length and alignment is based on SPEC2017. Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-03-05benchtests: Improve large memcpy/memset benchmarksWilco Dijkstra4-43/+14
Adjust sizes between 64KB and 16MB and iterations based on length. Remove incorrect uses of alloc_bufs since we're not interested in measuring Linux clear_page time. Use getpagesize() - 1 instead of 4095 when aligning within a page. Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-03-04manual: Explain sched_yield semantics with different schedulersSiddhesh Poyarekar1-9/+22
The manual entry for sched_yield mentions that the function call could be a nop if there are no other tasks with the same absolute priority. Expand the explanation to include example schedulers on Linux so that it's clear that sched_yield may not always result in a different task being scheduled. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-04Pass -Wl,--no-error-execstack for tests where -Wl,-z,execstack is used [PR32717]Sam James5-0/+49
When GNU Binutils is configured with --enable-error-execstack=yes, a handful of our tests which rely on -Wl,-z,execstack fail. Pass --Wl,--no-error-execstack to override the behaviour and get a warning instead. Bug: https://sourceware.org/PR32717 Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-03-03malloc: Add integrity check to largebin nextsizesBen Kallus1-0/+3
If attacker overwrites the bk_nextsize link in the first chunk of a largebin that later has a smaller chunk inserted into it, malloc will write a heap pointer into an attacker-controlled address [0]. This patch adds an integrity check to mitigate this attack. [0]: https://github.com/shellphish/how2heap/blob/master/glibc_2.39/large_bin_attack.c Signed-off-by: Ben Kallus <benjamin.p.kallus.gr@dartmouth.edu> Reviewed-by: DJ Delorie <dj@redhat.com>
2025-03-03libio: Clean up fputc/putc commentsSamuel Zeter1-3/+0
Remove duplicate comments in stdio.h Signed-off-by: Samuel Zeter <samuelzeter@gmail.com> Reviewed-by: Arjun Shankar <arjun@redhat.com>
2025-03-02htl: move pthread_once into libcSamuel Thibault8-8/+16
2025-02-28Remove unused dl-procinfo.hWilco Dijkstra29-724/+9
Remove unused _dl_hwcap_string defines. As a result many dl-procinfo.h headers can be removed. This also removes target specific _dl_procinfo implementations which only printed HWCAP strings using dl_hwcap_string. Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-02-28LoongArch: Optimize f{max,min}imum_mag_num{,f}Xi Ruoyao6-192/+78
Following the logic of the previous commits. Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2025-02-28LoongArch: Optimize f{max,min}imum_num{,f}Xi Ruoyao6-193/+78
Following the logic of the previous commits. Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2025-02-28LoongArch: Optimize f{max,min}imum_mag{,f}Xi Ruoyao4-120/+38
Following the logic of the previous commit. Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2025-02-28LoongArch: Optimize f{max,min}imum{,f}Xi Ruoyao4-88/+48
The code now looks like: fclass.s $fa2, $fa0 movfr2gr.s $t0, $fa2 slli.w $t0, $t0, 0x0 fclass.s $fa2, $fa1 movfr2gr.s $t1, $fa2 or $t0, $t0, $t1 andi $t0, $t0, 0x3 bnez $t0, 1f fmin.s $fa0, $fa0, $fa1 ret 1: fmul.s $fa0, $fa0, $fa1 ret This looks really bad, with expensive movfr2gr instructions, redundant sign-extensions and masking (arguably it's a compiler missed-optimzation), and a branch. Rewrite it with inline assembly: fcmp.cor.s $fcc0, $fa0, $fa0 fcmp.cor.s $fcc1, $fa1, $fa1 fsel $fa2, $fa0, $fa1, $fcc0 fsel $fa0, $fa1, $fa0, $fcc1 fmax.s $fa0, $fa2, $fa0 ret Note that we cannot make it more readable with "double a = __builtin_isnanf (x) ? y : x" because this C statement only happens to produce what we want with https://gcc.gnu.org/PR66462, if this bug is fixed in the future the generated code may change. Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2025-02-27AArch64: Use prefer_sve_ifuncs for SVE memsetWilco Dijkstra1-1/+1
Use prefer_sve_ifuncs for SVE memset just like memcpy. Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
2025-02-26sysdeps/ieee754: Fix remainder sign of zero for FE_DOWNWARD (BZ #32711)Sergei Zimmerman3-1/+11
Single-precision remainderf() and quad-precision remainderl() implementation derived from Sun is affected by an issue when the result is +-0. IEEE754 requires that if remainder(x, y) = 0, its sign shall be that of x regardless of the rounding direction. The implementation seems to have assumed that x - x = +0 in all rounding modes, which is not the case. When rounding direction is roundTowardNegative the sign of an exact zero sum (or difference) is −0. Regression tests that triggered this erroneous behavior are added to math/libm-test-remainder.inc. Tested for cross riscv64 and powerpc. Original fix by: Bruce Evans <bde@FreeBSD.org> in FreeBSD's a2ddfa5ea726c56dbf825763ad371c261b89b7c7. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>