aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
AgeCommit message (Collapse)AuthorFilesLines
2025-05-12hurd: Make rename refuse trailing slashes [BZ #32570]Samuel Thibault1-3/+16
As tested by Gnulib's renameatu module. Reported by Collin Funk on https://sourceware.org/bugzilla/show_bug.cgi?id=32570
2025-05-09Implement C23 compoundnJoseph Myers39-2/+242
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the compoundn functions, which compute (1+X) to the power Y for integer Y (and X at least -1). The integer exponent has type long long int in C23; it was intmax_t in TS 18661-4, and as with other interfaces changed after their initial appearance in the TS, I don't think we need to support the original version of the interface. Note that these functions are "compoundn" with a trailing "n", *not* "compound" (CORE-MATH has the wrong name, for example). As with pown, I strongly encourage searching for worst cases for ulps error for these implementations (necessarily non-exhaustively, given the size of the input space). I also expect a custom implementation for a given format could be much faster as well as more accurate (I haven't tested or benchmarked the CORE-MATH implementation for binary32); this is one of the more complicated and less efficient functions to implement in a type-generic way. As with exp2m1 and exp10m1, this showed up places where the powerpc64le IFUNC setup is not as self-contained as one might hope (in this case, without the changes specific to powerpc64le, there were undefined references to __GI___expf128). Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-05-09hurd: Fix tst-stack2 test build on HurdAdhemerval Zanella1-0/+1
It requires $(shared-thread-library). Fixes 0c342594237. Checked on a i686-gnu build.
2025-05-06powerpc: Remove POWER7 strncasecmp optimizationAdhemerval Zanella12-270/+4
These routines are not extensively used (gnulib documentation even recommend use a replacement [1]), and there is already a POWER8 version that uses proper vectorized instructions. [1] https://www.gnu.org/software/gnulib/manual/gnulib.html#C-strings Checked with a build for some powerpc variations. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
2025-05-05S390: Add new s390 platform z17.Stefan Liebler10-56/+233
The glibc-hwcaps subdirectories are extended by "z17". Libraries are loaded if the z17 facility bits are active: - Miscellaneous-instruction-extensions facility 4 - Vector-enhancements-facility 3 - Vector-Packed-Decimal-Enhancement Facility 3 - CPU: Concurrent-Functions Facility tst-glibc-hwcaps.c is extended in order to test z17 via new marker6. In case of running on a z17 with a kernel not recognizing z17 yet, AT_PLATFORM will be z900 but vector-bit in AT_HWCAP is set. This situation is now recognized and this testcase does not fail. A fatal glibc error is dumped if glibc was build with architecture level set for z17, but run on an older machine (See dl-hwcap-check.h). Note, you might get an SIGILL before this check if you don't use: configure --with-rtld-early-cflags=-march=<older-machine> ld.so --list-diagnostics now also dumps information about s390.cpu_features. Independent from z17, the s390x kernel won't introduce new HWCAP-Bits if there is no special handling needed in kernel itself. For z17, we don't have new HWCAP flags, but have to check the facility bits retrieved by stfle-instruction. Instead of storing all the stfle-bits (currently four 64bit values) in the cpu_features struct, we now only store those bits, which are needed within glibc itself. Note that we have this list twice, one with original values and the other one which can be filtered with GLIBC_TUNABLES=glibc.cpu.hwcaps. Those new fields are stored in so far reserved space in cpu_features struct. Thus processes started in between the update of glibc package and we e.g. have a new ld.so and an old libc.so, won't crash. The glibc internal ifunc-resolvers would not select the best optimized variant. The users of stfle-bits are also updated: - parsing of GLIBC_TUNABLES=glibc.cpu.hwcaps - glibc internal ifunc-resolvers - __libc_ifunc_impl_list - sysconf
2025-04-29math: Fix UB on sinpif (BZ 32925)Adhemerval Zanella1-4/+4
The left shift overflows for 'int', use uint32_t instead. It syncs with CORE-MATH commit bbfabd99. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-04-29math: Fix UB on erfcf (BZ 32924)Adhemerval Zanella1-2/+2
The left shift overflows for 'int', use uint64_t instead. It syncs with CORE-MATH commit d0a2be200cbc1344d800d9ef0ebee9ad67dd3ad8. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-04-29math: Fix UB on cospif (BZ 32923)Adhemerval Zanella1-3/+3
The left shift overflows for 'int', use uint32_t instead. It syncs with CORE-MATH commit bbfabd993a71b049c210b0febfd06d18369fadc1. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-04-29math: Fix UB on cbrtf (BZ 32922)Adhemerval Zanella1-3/+3
The left shift overflows for 'int64_t', use unsigned instead. It syncs with CORE-MATH commit f7c7408d1749ec2859ea249495af699359ae559b. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-04-29math: Fix UB on sinhf (BZ 32921)Adhemerval Zanella1-3/+3
The left shift overflows for 'int', use uint64_t instead. It syncs with CORE-MATH commit bbfabd99. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-04-29math: Fix UB on logf (BZ 32920)Adhemerval Zanella1-1/+1
The left shift overflows for 'int', use a literal instead. It syncs with OPTIMIZED-ROUTINES commit 0f87f607b976820ef41fe64d004fe67dc7af8236. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-04-29math: Fix UB on coshf (BZ 32919)Adhemerval Zanella1-3/+3
The left shift overflows for 'int', use uint64_t instead. It syncs with CORE-MATH commit 4d6192d2. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-04-29math: Fix UB on atanhf (BZ 32918)Adhemerval Zanella1-2/+2
The left shift overflows for 'int', use unsigned instead. It syncs with CORE-MATH commit 4d6192d2. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-04-28nptl: Fix pthread_getattr_np when modules with execstack are allowed (BZ 32897)Adhemerval Zanella6-9/+100
The BZ 32653 fix (12a497c716f0a06be5946cabb8c3ec22a079771e) kept the stack pointer zeroing from make_main_stack_executable on _dl_make_stack_executable. However, previously the 'stack_endp' pointed to temporary variable created before the call of _dl_map_object_from_fd; while now we use the __libc_stack_end directly. Since pthread_getattr_np relies on correct __libc_stack_end, if _dl_make_stack_executable is called (for instance, when glibc.rtld.execstack=2 is set) __libc_stack_end will be set to zero, and the call will always fail. The __libc_stack_end zero was used a mitigation hardening, but since 52a01100ad011293197637e42b5be1a479a2f4ae it is used solely on pthread_getattr_np code. So there is no point in zeroing anymore. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Sam James <sam@gentoo.org>
2025-04-28RISC-V: Use builtin for ffs and ffsll while supported extension availableJulian Zhu1-0/+10
Hardware ctz instructions are available in the RISC-V Zbb and XTheadBb extension. With special `-march` flags defined, we can generate more simplified code compared to the generic implementation of `ffs`/`ffsll`. Signed-off-by: Julian Zhu <julian.oerv@isrc.iscas.ac.cn> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-04-25linux/termio: remove <termio.h> and struct termioH. Peter Anvin5-46/+0
The <termio.h> interface is absolutely ancient: it was obsoleted by <termios.h> already in the first version of POSIX (1988) and thus predates the very first version of Linux. Unfortunately, some constant macros are used both by <termio.h> and <termios.h>; particularly problematic is the baud rate constants since the termio interface *requires* that the baud rate is set via an enumeration as part of c_cflag. In preparation of revamping the termios interface to support the arbitrary baud rate capability that the Linux kernel has supported since 2008, remove <termio.h> in the hope that no one still uses this archaic interface. Note that there is no actual code in glibc to support termio: it is purely an unabstracted ioctl() interface. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-04-22elf: tst-audit10: split AVX512F code into dedicated functions [BZ #32882]Aurelien Jarno2-55/+55
"Recent" GCC versions (since commit fc62716fe8d1, backported to stable branches) emit a vzeroupper instruction at the end of functions containing AVX instructions. This causes the tst-audit10 test to fail on CPUs lacking AVX instructions, despite the AVX512F check. The crash occurs in the pltenter function of tst-auditmod10b.c. Fix that by moving the code guarded by the check_avx512 function into specific functions using the target ("avx512f") attribute. Note that since commit 5359c3bc91cc ("x86-64: Remove compiler -mavx512f check") it is safe to assume that the compiler has AVX512F support, thus the __AVX512F__ checks can be dropped. Tested on non-AVX, AVX2 and AVX512F machines. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-04-22Add AT_* constants from Linux 6.12Joseph Myers1-0/+2
Linux 6.12 adds AT_RENAME_* aliases for RENAME_* flags for renameat2, and also AT_HANDLE_MNT_ID_UNIQUE. Add the first set of aliases to stdio.h alongside the RENAME_* names, and AT_HANDLE_MNT_ID_UNIQUE to bits/fcntl-linux.h. Tested for x86_64.
2025-04-21hurd: Make symlink return EEXIST on existing target directorySamuel Thibault1-1/+1
8ef17919509e ("hurd: Fix EINVAL error on linking to a slash-trailing path [BZ #32569]) made symlink return ENOTDIR, but the gnulib testsuite does not recognize it for such a situation, and EEXIST is indeed more comprehensible to users.
2025-04-21hurd: Clear FP exceptions before calling signal handlerSamuel Thibault1-4/+10
This avoids SIGFPE handlers (or code longjmp-ed to) getting disturbed by the exception that generated it. Note: gcc's unwinding depends on the rpc_wait_trampoline/trampoline exact code, so we here avoid breaking it.
2025-04-21hurd: Do not check for xstate level if it was not initializedSamuel Thibault1-1/+1
If __thread_get_state failed, there is no xstate level to check. ok is 0 already and the memory exists, but better not read uninitialized memory.
2025-04-21hurd: Do not restore xstate when it is not initializedSamuel Thibault2-34/+40
If the process has never used fp before getting a signal, xstate is set (and thus the x87 state is not initialized) but xstate->initialized is still 0, and we should not restore anything.
2025-04-20hurd: Make *utime*s catch invalid times [BZ #32802, BZ #32803]Samuel Thibault3-12/+66
2025-04-18hurd: save xstate during signal handlingLuca Dariz5-25/+134
* hurd/Makefile: add new tests * hurd/test-sig-rpc-interrupted.c: check xstate save and restore in the case where a signal is delivered to a thread which is waiting for an rpc. This test implements the rpc interruption protocol used by the hurd servers. It was so far passing on Debian thanks to the local-intr-msg-clobber.diff patch, which is now obsolete. * hurd/test-sig-xstate.c: check xstate save and restore in the case where a signal is delivered to a running thread, making sure that the xstate is modified in the signal handler. * hurd/test-xstate.h: add helpers to test xstate * sysdeps/mach/hurd/i386/bits/sigcontext.h: add xstate to the sigcontext structure. + sysdeps/mach/hurd/i386/sigreturn.c: restore xstate from the saved context * sysdeps/mach/hurd/x86/trampoline.c: save xstate if supported. Otherwise we fall back to the previous behaviour of ignoring xstate. * sysdeps/mach/hurd/x86_64/bits/sigcontext.h: add xstate to the sigcontext structure. * sysdeps/mach/hurd/x86_64/sigreturn.c: restore xstate from the saved context Signed-off-by: Luca Dariz <luca@orpolo.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Message-ID: <20250319171118.142163-1-luca@orpolo.org>
2025-04-18hurd: Check return value of mach_port_mod_refs() in the dup routine of fcntl()Zhaoming Luo2-28/+87
Message-ID: <20250310084409.24177-1-zhmingluo@163.com>
2025-04-15aarch64: Add back non-temporal load/stores from oryon-1's memsetAndrew Pinski1-0/+26
I misunderstood the recommendation from the hardware team about non-temporal load/stores. It is still recommended to use them in memset for large sizes. It was not recommended for their use with device memory and memset is already not valid to be used with device memory. This reverts commit e6590f0c86632c36c9a784cf96075f4be2e920d2. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-04-15aarch64: Add back non-temporal load/stores from oryon-1's memcpyAndrew Pinski1-0/+40
I misunderstood the recommendation from the hardware team about non-temporal load/stores. It is still recommended to use them in memcpy for large sizes. It was not recommended for their use with device memory and memcpy is already not valid to be use with device memory. This reverts commit eb5eeb47403e0a91de834868e501b4d62b8d2cb9. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-04-14Fix spelling mistake "succsefully" -> "successfully"Colin Ian King1-1/+1
There is a spelling mistake in a puts statement. Fix it. Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-04-12x86: Detect Intel Diamond RapidsH.J. Lu1-0/+12
Detect Intel Diamond Rapids and tune it similar to Intel Granite Rapids. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
2025-04-11x86: Handle unknown Intel processor with default tuningSunil K Pandey1-144/+143
Enable default tuning for unknown Intel processor. Tested on x86, no regression. Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-10x86: Add ARL/PTL/CWF model detection supportSunil K Pandey1-0/+10
- Add ARROWLAKE model detection. - Add PANTHERLAKE model detection. - Add CLEARWATERFOREST model detection. IntelĀ® Architecture Instruction Set Extensions Programming Reference https://cdrdv2.intel.com/v1/dl/getContent/671368 Section 1.2. No regression, validated model detection on SDE. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-10powerpc: Remove relocation cache flush code for power64Florian Weimer1-15/+0
This is only needed for -mno-secure-plt, and this linkage mode is not supported with powerpc64 and powerp64le. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
2025-04-09math: Fix up THREEp96 constant in expf128 [BZ #32411]Jakub Jelinek1-1/+1
As mentioned by the reporter in a pull request against gcc-mirror, the THREEp96 constant in e_expl.c is incorrect, it is actually 0x3.p+94f128 rather than 0x3.p+96f128. The algorithm uses that to compute the t2 integer (tval2), by whose delta it adjusts the x+xl pair and then in the result uses the precomputed exp value for that entry. Using 0x3.p+94f128 rather than 0x3.p+96f128 results in tval2 sometimes being one smaller, sometimes one larger than the desired value, thus can mean the x+xl pair after adjustment will be larger in absolute value than it should be. DesWursters created a test program for this https://github.com/DesWurstes/comparefloats and his results were total: 1135000000 not_equal: 4322 earlier_score: 674 later_score: 3648 I've modified this so with https://sourceware.org/bugzilla/show_bug.cgi?id=32411#c3 so that it actually tests pseudo-random _Float128 values with range (-16384.,16384) with strong bias on values larger than 0.0002 in absolute value (so that tval1/tval2 aren't zero most of the time) and that gave total: 10000000000 not_equal: 29861 earlier_score: 4606 later_score: 25255 So, in both cases, in most cases the change doesn't result in any differences, and in those rare cases where does, about 85% have smaller ulp than without the patch. Additionally I've tried https://sourceware.org/bugzilla/show_bug.cgi?id=32411#c4 and in 2 billion iterations it didn't find any case where x+xl after the adjustments without this change would be smaller in absolute value compared to x+xl after the adjustments with this change. Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-04-08elf: Extend glibc.rtld.execstack tunable to force executable stack (BZ 32653)Adhemerval Zanella1-0/+13
From the bug report [1], multiple programs still require to dlopen shared libraries with either missing PT_GNU_STACK or with the executable bit set. Although, in some cases, it seems to be a hard-craft assembly source without the required .note.GNU-stack marking (so the static linker is forced to set the stack executable if the ABI requires it), other cases seem that the library uses trampolines [2]. Unfortunately, READ_IMPLIES_EXEC is not an option since on some ABIs (x86_64), the kernel clears the bit, making it unsupported. To avoid reinstating the broken code that changes stack permission on dlopen (0ca8785a28), this patch extends the glibc.rtld.execstack tunable to allow an option to force an executable stack at the program startup. The tunable is a security issue because it defeats the PT_GNU_STACK hardening. It has the slight advantage of making it explicit by the caller, and, as for other tunables, this is disabled for setuid binaries. A tunable also allows us to eventually remove it, but from previous experiences, it would require some time. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=32653 [2] https://github.com/conda-forge/ctng-compiler-activation-feedstock/issues/143 Reviewed-by: Sam James <sam@gentoo.org>
2025-04-08stdlib: Implement C2Y uabs, ulabs, ullabs and uimaxabsLenard Mollenkopf34-0/+136
C2Y adds unsigned versions of the abs functions (see C2Y draft N3467 and proposal N3349). Tested for x86_64. Signed-off-by: Lenard Mollenkopf <glibc@lenardmollenkopf.de>
2025-04-05x86: Optimize xstate size calculationSunil K Pandey2-56/+24
Scan xstate IDs up to the maximum supported xstate ID. Remove the separate AMX xstate calculation. Instead, exclude the AMX space from the start of TILECFG to the end of TILEDATA in xsave_state_size. Completed validation on SKL/SKX/SPR/SDE and compared xsave state size with "ld.so --list-diagnostics" option, no regression. Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
2025-04-02stdlib: Fix qsort memory leak if callback throws (BZ 32058)Adhemerval Zanella3-4/+22
If the input buffer exceeds the stack auxiliary buffer, qsort will malloc a temporary one to call mergesort. Since C++ standard does allow the callback comparison function to throw [1], the glibc implementation can potentially leak memory. The fixes uses a pthread_cleanup_combined_push and pthread_cleanup_combined_pop, so it can work with and without exception enables. The qsort code path that calls malloc now requires some extra setup and a call to __pthread_cleanup_push anmd __pthread_cleanup_pop (which should be ok since they just setup some buffer state). Checked on x86_64-linux-gnu. [1] https://timsong-cpp.github.io/cppwp/n4950/alg.c.library#4 Reviewed-by: DJ Delorie <dj@redhat.com>
2025-04-02sysdeps: powerpc: restore -mlong-double-128 checkSam James2-0/+117
We mistakenly dropped the check in 27b96e069aad17cefea9437542180bff448ac3a0; there's some other checks which we *can* drop, but let's worry about that later. Fixes the build on ppc64le where GCC is configured with --with-long-double-format=ieee. Reviewed-by: Andreas Schwab <schwab@suse.de>
2025-04-01Update syscall lists for Linux 6.14Joseph Myers1-2/+2
Linux 6.14 has no new syscalls. Update the version number in syscall-names.list to reflect that it is still current for 6.14. Tested with build-many-glibcs.py.
2025-03-31x86: Link tst-gnu2-tls2-x86-noxsave{,c,xsavec} with libpthreadFlorian Weimer1-0/+3
This fixes a test build failure on Hurd. Fixes commit 145097dff170507fe73190e8e41194f5b5f7e6bf ("x86: Use separate variable for TLSDESC XSAVE/XSAVEC state size (bug 32810)"). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-03-31Raise the minimum GCC version to 12.1 [BZ #32539]H.J. Lu4-175/+0
For all Linux distros with glibc 2.40 which I can find, GCC 14.2 is used to compile glibc 2.40: OS GCC URL AOSC 14.2.0 https://aosc.io/ Arch Linux 14.2.0 https://archlinux.org/ ArchPOWER 14.2.0 https://archlinuxpower.org/ Artix 14.2.0 https://artixlinux.org/ Debian 14.2.0 https://www.debian.org/ Devuan 14.2.0 https://www.devuan.org/ Exherbo 14.2.0 https://www.exherbolinux.org/ Fedora 14.2.1 https://fedoraproject.org/ Gentoo 14.2.1 https://gentoo.org/ Kali Linux 14.2.0 https://www.kali.org/ KaOS 14.2.0 https://kaosx.us/ LiGurOS 14.2.0 https://liguros.gitlab.io/ Mageia 14.2.0 https://www.mageia.org/en/ Manjaro 14.2.0 https://manjaro.org/ NixOS 14.2.0 https://nixos.org/ openmamba 14.2.0 https://openmamba.org/ OpenMandriva 14.2.0 https://openmandriva.org/ openSUSE 14.2.0 https://www.opensuse.org/ Parabola 14.2.0 https://www.parabola.nu/ PLD Linux 14.2.0 https://pld-linux.org/ PureOS 14.2.0 https://pureos.net/ Raspbian 14.2.0 http://raspbian.org/ Slackware 14.2.0 http://www.slackware.com/ Solus 14.2.0 https://getsol.us/ T2 SDE 14.2.0 http://t2sde.org/ Ubuntu 14.2.0 https://www.ubuntu.com/ Wikidata 14.2.0 https://wikidata.org/ Support older versions of GCC to build glibc 2.42: 1. Need to work around bugs in older versions of GCC. 2. Can't use the new features in newer versions of GCC, which may be required for new features, like _Float16 which requires GCC 12.1 or above, in glibc, The main benefit of supporting older versions of GCC is easier backport of bug fixes to the older releases of glibc, which can be mitigated by avoiding incompatible features in newer versions of GCC for critical bug fixes. Require GCC 12.1 or newer to build. Remove GCC version check for PowerPC and s390x. TEST_CC and TEST_CXX can be used to test the glibc build with the older versions of GCC. For glibc developers who are using Linux OSes which don't come with GCC 12.1 or newer, they should build and install GCC 12.1 or newer to work on glibc. This fixes BZ #32539. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2025-03-31Fix typo in commentYLK2-2/+2
2025-03-31aarch64: Fix _dl_tlsdesc_dynamic unwind for pac-ret (BZ 32612)Adhemerval Zanella4-12/+100
When libgcc is built with pac-ret, it requires to autenticate the unwinding frame based on CFI information. The _dl_tlsdesc_dynamic uses a custom calling convention, where it is responsible to save and restore all registers it might use (even volatile). The pac-ret support added by 1be3d6eb823d8b952fa54b7bbc90cbecb8981380 was added only on the slow-path, but the fast path also adds DWARF Register Rule Instruction (cfi_adjust_cfa_offset) since it requires to save/restore some auxiliary register. It seems that this is not fully supported neither by libgcc nor AArch64 ABI [1]. Instead, move paciasp/autiasp to function prologue/epilogue to be used on both fast and slow paths. I also corrected the _dl_tlsdesc_dynamic comment description, it was copied from i386 implementation without any adjustment. Checked on aarch64-linux-gnu with a toolchain built with --enable-standard-branch-protection on a system with pac-ret support. [1] https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#id1 Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
2025-03-29x86: Use separate variable for TLSDESC XSAVE/XSAVEC state size (bug 32810)Florian Weimer9-8/+40
Previously, the initialization code reused the xsave_state_full_size member of struct cpu_features for the TLSDESC state size. However, the tunable processing code assumes that this member has the original XSAVE (non-compact) state size, so that it can use its value if XSAVEC is disabled via tunable. This change uses a separate variable and not a struct member because the value is only needed in ld.so and the static libc, but not in libc.so. As a result, struct cpu_features layout does not change, helping a future backport of this change. Fixes commit 9b7091415af47082664717210ac49d51551456ab ("x86-64: Update _dl_tlsdesc_dynamic to preserve AMX registers"). Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-29x86: Skip XSAVE state size reset if ISA level requires XSAVEFlorian Weimer1-0/+5
If we have to use XSAVE or XSAVEC trampolines, do not adjust the size information they need. Technically, it is an operator error to try to run with -XSAVE,-XSAVEC on such builds, but this change here disables some unnecessary code with higher ISA levels and simplifies testing. Related to commit befe2d3c4dec8be2cdd01a47132e47bdb7020922 ("x86-64: Don't use SSE resolvers for ISA level 3 or above"). Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-28stdio-common: Reject real data w/o exponent digits in scanf [BZ #12701]Maciej W. Rozycki36-2332/+2332
Reject invalid formatted scanf real input data the exponent part of which is comprised of an exponent introducing character, optionally followed by a sign, and with no actual digits following. Such data is a prefix of, but not a matching input sequence and it is required by ISO C to cause a matching failure. Currently a matching success is instead incorrectly produced along with the conversion result according to the input significand read and the exponent of zero, with the significand and the exponent part wholly consumed from input. Correct an invalid `tstscanf.c' test accordingly that expects a matching success for input data provided in the ISO C standard as an example for a matching failure. Enable input data that causes test failures without this fix in place. Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-28stdio-common: Reject significand prefixes in scanf [BZ #12701]Maciej W. Rozycki12-504/+504
Reject invalid formatted scanf real input data that is comprised of a hexadecimal prefix, optionally preceded by a sign, and with no actual digits following owing to the field width restriction in effect. Such data is a prefix of, but not a matching input sequence and it is required by ISO C to cause a matching failure. Currently a matching success is instead incorrectly produced along with the conversion result of zero, with the prefix wholly consumed from input. Where the end of input is marked by the end-of-file condition rather than the field width restriction in effect a matching failure is already correctly produced. Enable input data that causes test failures without this fix in place. Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-28stdio-common: Reject integer prefixes in scanf [BZ #12701]Maciej W. Rozycki16-960/+960
Reject invalid formatted scanf integer input data that is comprised of a binary or hexadecimal prefix, optionally preceded by a sign, and with no actual digits following. Such data is a prefix of, but not a matching input sequence and it is required by ISO C to cause a matching failure. Currently a matching success is instead incorrectly produced along with the conversion result of zero, with the prefix wholly consumed from input. Enable input data that causes test failures without this fix in place. Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-28stdio-common: Add scanf long double data for Intel/Motorola 80-bit formatMaciej W. Rozycki10-0/+4873
Add Makefile infrastructure, a format-specific test skeleton providing a data comparison implementation that ignores bits of data representation in memory that do not participate in holding floating-point data, and `long double' real input data for targets using the Intel/Motorola 80-bit format. Keep input data disabled and referring to BZ #12701 for entries that are are currently incorrectly accepted as valid data, such as '0e', '0e+', '0x', '0x8p', '0x0p-', etc. Reviewed-by: Joseph Myers <josmyers@redhat.com>
2025-03-27Implement C23 pownJoseph Myers41-4/+256
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the pown functions, which are like pow but with an integer exponent. That exponent has type long long int in C23; it was intmax_t in TS 18661-4, and as with other interfaces changed after their initial appearance in the TS, I don't think we need to support the original version of the interface. The test inputs are based on the subset of test inputs for pow that use integer exponents that fit in long long. As the first such template implementation that saves and restores the rounding mode internally (to avoid possible issues with directed rounding and intermediate overflows or underflows in the wrong rounding mode), support also needed to be added for using SET_RESTORE_ROUND* in such template function implementations. This required math-type-macros-float128.h to include <fenv_private.h>, so it can tell whether SET_RESTORE_ROUNDF128 is defined. In turn, the include order with <fenv_private.h> included before <math_private.h> broke loongarch builds, showing up that sysdeps/loongarch/math_private.h is really a fenv_private.h file (maybe implemented internally before the consistent split of those headers in 2018?) and needed to be renamed to fenv_private.h to avoid errors with duplicate macro definitions if <math_private.h> is included after <fenv_private.h>. The underlying implementation uses __ieee754_pow functions (called more than once in some cases, where the exponent does not fit in the floating type). I expect a custom implementation for a given format, that only handles integer exponents but handles larger exponents directly, could be faster and more accurate in some cases. I encourage searching for worst cases for ulps error for these implementations (necessarily non-exhaustively, given the size of the input space). Tested for x86_64 and x86, and with build-many-glibcs.py.