aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-08-26Rename new tst-sem17 test to tst-sem18release/2.39/masterJoseph Myers2-3/+3
As noted by Adhemerval, we already have a tst-sem17 in nptl. Tested for x86_64. (cherry picked from commit c7dcf594f4c52fa7e2cc76918c8aa9abb98e9625)
2025-08-26Avoid uninitialized result in sem_open when file does not existJoseph Myers3-0/+37
A static analyzer apparently reported an uninitialized use of the variable result in sem_open in the case where the file is required to exist but does not exist. The report appears to be correct; set result to SEM_FAILED in that case, and add a test for it. Note: the test passes for me even without the sem_open fix, I guess because result happens to get value SEM_FAILED (i.e. 0) when uninitialized. Tested for x86_64. (cherry picked from commit f745d78e2628cd5b13ca119ae0c0e21d08ad1906)
2025-08-26elf: handle addition overflow in _dl_find_object_update_1 [BZ #32245]Aurelien Jarno1-0/+8
The remaining_to_add variable can be 0 if (current_used + count) wraps, This is caught by GCC 14+ on hppa, which determines from there that target_seg could be be NULL when remaining_to_add is zero, which in turns causes a -Wstringop-overflow warning: In file included from ../include/atomic.h:49, from dl-find_object.c:20: In function '_dlfo_update_init_seg', inlined from '_dl_find_object_update_1' at dl-find_object.c:689:30, inlined from '_dl_find_object_update' at dl-find_object.c:805:13: ../sysdeps/unix/sysv/linux/hppa/atomic-machine.h:44:4: error: '__atomic_store_4' writing 4 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=] 44 | __atomic_store_n ((mem), (val), __ATOMIC_RELAXED); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dl-find_object.c:644:3: note: in expansion of macro 'atomic_store_relaxed' 644 | atomic_store_relaxed (&seg->size, new_seg_size); | ^~~~~~~~~~~~~~~~~~~~ In function '_dl_find_object_update': cc1: note: destination object is likely at address zero In practice, this is not possible as it represent counts of link maps. Link maps have sizes larger than 1 byte, so the sum of any two link map counts will always fit within a size_t without wrapping around. This patch therefore adds a check on remaining_to_add == 0 and tell GCC that this can not happen using __builtin_unreachable. Thanks to Andreas Schwab for the investigation. Closes: BZ #32245 Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Tested-by: John David Anglin <dave.anglin@bell.net> Reviewed-by: Florian Weimer <fweimer@redhat.com> (cherry picked from commit 6c915c73d08028987232f6dc718f218c61113240)
2025-08-20Optimize __libc_tsd_* thread variable accessFlorian Weimer3-5/+10
These variables are not exported, and libc.so TLS is initial-exec anyway. Declare these variables as hidden and use the initial-exec TLS model. Reviewed-by: Frédéric Bérat <fberat@redhat.com> (cherry picked from commit a894f04d877653bea1639fc9a4adf73bd9347bf4)
2025-08-19i386: Add GLIBC_ABI_GNU_TLS version [BZ #33221]H.J. Lu2-0/+14
On i386, programs and shared libraries with __thread usage may fail silently at run-time against glibc without the TLS run-time fix for: https://sourceware.org/bugzilla/show_bug.cgi?id=32996 Add GLIBC_ABI_GNU_TLS version to indicate that glibc has the working GNU TLS run-time. Linker can add the GLIBC_ABI_GNU_TLS version to binaries which depend on the working TLS run-time so that such programs and shared libraries will fail to load and run at run-time against libc.so without the GLIBC_ABI_GNU_TLS version, instead of fail silently at random. This fixes BZ #33221. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org> (cherry picked from commit ed1b7a5a489ab555a27fad9c101ebe2e1c1ba881)
2025-08-19i386: Also add GLIBC_ABI_GNU2_TLS version [BZ #33129]H.J. Lu4-14/+14
Since the GNU2 TLS run-time bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31372 affects both i386 and x86-64, also add GLIBC_ABI_GNU2_TLS version to i386 to indicate the working GNU2 TLS run-time. For x86-64, the additional GNU2 TLS run-time bug fix is needed for https://sourceware.org/bugzilla/show_bug.cgi?id=31501 Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org> (cherry picked from commit bd4628f3f18ac312408782eea450429c6f044860)
2025-08-19debug: Fix tst-longjmp_chk3 build failure on HurdFlorian Weimer1-0/+1
Explicitly include <unistd.h> for _exit and getpid. (cherry picked from commit 4836a9af89f1b4d482e6c72ff67e36226d36434c)
2025-08-19debug: Wire up tst-longjmp_chk3Florian Weimer2-4/+10
The test was added in commit ac8cc9e300a002228eb7e660df3e7b333d9a7414 without all the required Makefile scaffolding. Tweak the test so that it actually builds (including with dynamic SIGSTKSZ). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 4b7cfcc3fbfab55a1bbb32a2da69c048060739d6)
2025-08-18i386: Update ___tls_get_addr to preserve vector registersH.J. Lu25-169/+633
Compiler generates the following instruction sequence for dynamic TLS access: leal tls_var@tlsgd(,%ebx,1), %eax call ___tls_get_addr@PLT CALL instruction is transparent to compiler which assumes all registers, except for EFLAGS, AX, CX, and DX, are unchanged after CALL. But ___tls_get_addr is a normal function which doesn't preserve any vector registers. 1. Rename the generic __tls_get_addr function to ___tls_get_addr_internal. 2. Change ___tls_get_addr to a wrapper function with implementations for FNSAVE, FXSAVE, XSAVE and XSAVEC to save and restore all vector registers. 3. dl-tlsdesc-dynamic.h has: _dl_tlsdesc_dynamic: /* Like all TLS resolvers, preserve call-clobbered registers. We need two scratch regs anyway. */ subl $32, %esp cfi_adjust_cfa_offset (32) It is wrong to use movl %ebx, -28(%esp) movl %esp, %ebx cfi_def_cfa_register(%ebx) ... mov %ebx, %esp cfi_def_cfa_register(%esp) movl -28(%esp), %ebx to preserve EBX on stack. Fix it with: movl %ebx, 28(%esp) movl %esp, %ebx cfi_def_cfa_register(%ebx) ... mov %ebx, %esp cfi_def_cfa_register(%esp) movl 28(%esp), %ebx 4. Update _dl_tlsdesc_dynamic to call ___tls_get_addr_internal directly. 5. Add have-test-mtls-traditional to compile tst-tls23-mod.c with traditional TLS variant to verify the fix. 6. Define DL_RUNTIME_RESOLVE_REALIGN_STACK in sysdeps/x86/sysdep.h. This fixes BZ #32996. Co-Authored-By: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 848f0e46f03f22404ed9a8aabf3fd5ce8809a1be)
2025-08-18elf: Preserve _rtld_global layout for the release branchFlorian Weimer1-0/+2
Backporting commit 97017da5ef946c6d38c252f56c8cb7c205b732fa ("elf: Introduce _dl_debug_change_state") removed the _ns_debug member. Keep it to preseve struct layout.
2025-08-18elf: Compile _dl_debug_state separately (bug 33224)Florian Weimer3-11/+31
This ensures that the compiler will not inline it, so that debuggers which do not use the Systemtap probes can reliably set a breakpoint on it. Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org> Tested-by: Andreas K. Huettel <dilfridge@gentoo.org> (cherry picked from commit 620f0730f311635cd0e175a3ae4d0fc700c76366)
2025-08-18elf: Restore support for _r_debug interpositions and copy relocationsFlorian Weimer9-3/+94
The changes in commit a93d9e03a31ec14405cb3a09aa95413b67067380 ("Extend struct r_debug to support multiple namespaces [BZ #15971]") break the dyninst dynamic instrumentation tool. It brings its own definition of _r_debug (rather than a declaration). Furthermore, it turns out it is rather hard to use the proposed handshake for accessing _r_debug via DT_DEBUG. If applications want to access _r_debug, they can do so directly if the relevant code has been built as PIC. To protect against harm from accidental copy relocations due to linker relaxations, this commit restores copy relocation support by adjusting both copies if interposition or copy relocations are in play. Therefore, it is possible to use a hidden reference in ld.so to access _r_debug. Only perform the copy relocation initialization if libc has been loaded. Otherwise, the ld.so search scope can be empty, and the lookup of the _r_debug symbol mail fail. Reviewed-by: H.J. Lu <hjl.tools@gmail.com> (cherry picked from commit ea85e7d55087075376a29261e722e4fae14ecbe7)
2025-08-18elf: Introduce _dl_debug_change_stateFlorian Weimer6-15/+26
It combines updating r_state with the debugger notification. The second change to _dl_open introduces an additional debugger notification for dlmopen, but debuggers are expected to ignore it. Reviewed-by: H.J. Lu <hjl.tools@gmail.com> (cherry picked from commit 8329939a37f483a16013dd8af8303cbcb86d92cb)
2025-08-18elf: Introduce separate _r_debug_array variableFlorian Weimer2-43/+50
It replaces the ns_debug member of the namespaces. Previously, the base namespace had an unused ns_debug member. This change also fixes a concurrency issue: Now _dl_debug_initialize only updates r_next of the previous namespace's r_debug after the new r_debug is initialized, so that only the initialized version is observed. (Client code accessing _r_debug will benefit from load dependency tracking in CPUs even without explicit barriers.) Reviewed-by: H.J. Lu <hjl.tools@gmail.com> (cherry picked from commit 7278d11f3a0cd528188c719bab75575b0aea2c6e)
2025-08-18elf: 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)"). (cherry picked from commit d604f9c500570e80febfcc6a52b63a002b466f35)
2025-08-18elf: 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> (cherry picked from commit 46d31980943d8be2f421c1e3276b265c7552636e)
2025-08-18elf: Second ld.so relocation only if libc.so has been loadedFlorian Weimer5-34/+81
Commit 8f8dd904c4a2207699bb666f30acceb5209c8d3f (“elf: rtld_multiple_ref is always true”) removed some code that happened to enable compatibility with programs that do not link against libc.so. Such programs cannot call dlopen or any dynamic linker functions (except __tls_get_addr), so this is not really useful. Still ld.so should not crash with a null-pointer dereference or undefined symbol reference in these cases. In the main relocation loop, call _dl_relocate_object unconditionally because it already checks if the object has been relocated. If libc.so was loaded, self-relocate ld.so against it and call __rtld_mutex_init and __rtld_malloc_init_real to activate the full implementations. Those are available only if libc.so is there, so skip these initialization steps if libc.so is absent. Without libc.so, the global scope can be completely empty. This can cause ld.so self-relocation to fail because if it uses symbol-based relocations, which is why the second ld.so self-relocation is not performed if libc.so is missing. The previous concern regarding GOT updates through self-relocation no longer applies because function pointers are updated explicitly through __rtld_mutex_init and __rtld_malloc_init_real, and not through relocation. However, the second ld.so self-relocation is still delayed, in case there are other symbols being used. Fixes commit 8f8dd904c4a2207699bb666f30acceb5209c8d3f (“elf: rtld_multiple_ref is always true”). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 706209867f1ba89c458033408d419e92d8055f58)
2025-08-18elf: Reorder audit events in dlcose to match _dl_fini (bug 32066)Florian Weimer2-16/+37
This was discovered after extending elf/tst-audit23 to cover dlclose of the dlmopen namespace. Auditors already experience the new order during process shutdown (_dl_fini), so no LAV_CURRENT bump or backwards compatibility code seems necessary. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 495b96e064da605630a23092d1e484ade4bdc093)
2025-08-18elf: Call la_objclose for proxy link maps in _dl_fini (bug 32065)Florian Weimer2-3/+25
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit c4b160744cb39eca20dc36b39c7fa6e10352706c)
2025-08-18elf: Signal la_objopen for the proxy link map in dlmopen (bug 31985)Florian Weimer2-29/+40
Previously, the ld.so link map was silently added to the namespace. This change produces an auditing event for it. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 8f36b1469677afe37168f9af1b77402d7a70c673)
2025-08-18elf: Add the endswith function to <endswith.h>Florian Weimer1-0/+8
And include <stdbool.h> for a definition of bool. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit a20bc2f6233a726c7df8eaa332b6e498bd59321f)
2025-08-18elf: Update DSO list, write audit log to elf/tst-audit23.outFlorian Weimer1-5/+22
After commit 1d5024f4f052c12e404d42d3b5bfe9c3e9fd27c4 ("support: Build with exceptions and asynchronous unwind tables [BZ #30587]"), libgcc_s is expected to show up in the DSO list on 32-bit Arm. Do not update max_objs because vdso is not tracked (and which is the reason why the test currently passes even with libgcc_s present). Also write the log output from the auditor to standard output, for easier test debugging. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 4a50fdf8b2c1106b50cd9056b4c6f3a72cdeed5f)
2025-08-18elf: Switch to main malloc after final ld.so self-relocationFlorian Weimer6-16/+99
Before commit ee1ada1bdb8074de6e1bdc956ab19aef7b6a7872 ("elf: Rework exception handling in the dynamic loader [BZ #25486]"), the previous order called the main calloc to allocate a shadow GOT/PLT array for auditing support. This happened before libc.so.6 ELF constructors were run, so a user malloc could run without libc.so.6 having been initialized fully. One observable effect was that environ was NULL at this point. It does not seem to be possible at present to trigger such an allocation, but it seems more robust to delay switching to main malloc after ld.so self-relocation is complete. The elf/tst-rtld-no-malloc-audit test case fails with a 2.34-era glibc that does not have this fix. Reviewed-by: DJ Delorie <dj@redhat.com> (cherry picked from commit c1560f3f75c0e892b5522c16f91b4e303f677094)
2025-08-18elf: Introduce _dl_relocate_object_no_relroFlorian Weimer2-10/+21
And make _dl_protect_relro apply RELRO conditionally. Reviewed-by: DJ Delorie <dj@redhat.com> (cherry picked from commit f2326c2ec0a0a8db7bc7f4db8cce3002768fc3b6)
2025-08-18elf: Do not define consider_profiling, consider_symbind as macrosFlorian Weimer1-6/+2
This avoids surprises when refactoring the code if these identifiers are re-used later in the file. Reviewed-by: DJ Delorie <dj@redhat.com> (cherry picked from commit a79642204537dec8a1e1c58d1e0a074b3c624f46)
2025-08-18elf: rtld_multiple_ref is always trueFlorian Weimer1-56/+48
For a long time, libc.so.6 has dependend on ld.so, which means that there is a reference to ld.so in all processes, and rtld_multiple_ref is always true. In fact, if rtld_multiple_ref were false, some of the ld.so setup code would not run. Reviewed-by: DJ Delorie <dj@redhat.com> (cherry picked from commit 8f8dd904c4a2207699bb666f30acceb5209c8d3f)
2025-08-18Revert "elf: Run constructors on cyclic recursive dlopen (bug 31986)"Florian Weimer7-167/+7
This reverts commit 9897ced8e78db5d813166a7ccccfd5a42c69ef20. Adjust the test expectations in elf/tst-dlopen-auditdup-auditmod.c accordingly. (cherry picked from commit 95129e6b8fabdaa8cd8a4a5cc20be0f4cb0ba59f)
2025-08-18elf: Fix map_complete Systemtap probe in dl_open_workerFlorian Weimer1-1/+1
The refactoring did not take the change of variable into account. Fixes commit 43db5e2c0672cae7edea7c9685b22317eae25471 ("elf: Signal RT_CONSISTENT after relocation processing in dlopen (bug 31986)"). (cherry picked from commit ac73067cb7a328bf106ecd041c020fc61be7e087)
2025-08-18elf: Signal RT_CONSISTENT after relocation processing in dlopen (bug 31986)Florian Weimer5-15/+219
Previously, a la_activity audit event was generated before relocation processing completed. This does did not match what happened during initial startup in elf/rtld.c (towards the end of dl_main). It also caused various problems if an auditor tried to open the same shared object again using dlmopen: If it was the directly loaded object, it had a search scope associated with it, so the early exit in dl_open_worker_begin was taken even though the object was unrelocated. This caused the r_state == RT_CONSISTENT assert to fail. Avoidance of the assert also depends on reversing the order of r_state update and auditor event (already implemented in a previous commit). At the later point, args->map can be NULL due to failure, so use the assigned namespace ID instead if that is available. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 43db5e2c0672cae7edea7c9685b22317eae25471)
2025-08-18elf: Signal LA_ACT_CONSISTENT to auditors after RT_CONSISTENT switchFlorian Weimer3-13/+13
Auditors can call into the dynamic loader again if LA_ACT_CONSISTENT, and those recursive calls could observe r_state != RT_CONSISTENT. We should consider failing dlopen/dlmopen/dlclose if r_state != RT_CONSISTENT. The dynamic linker is probably not in a state in which it can handle reentrant calls. This needs further investigation. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit e096b7a1896886eb7dd2732ccbf1184b0eec9a63)
2025-08-18elf: Run constructors on cyclic recursive dlopen (bug 31986)Florian Weimer6-0/+165
This is conceptually similar to the reported bug, but does not depend on auditing. The fix is simple: just complete execution of the constructors. This exposed the fact that the link map for statically linked executables does not have l_init_called set, even though constructors have run. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 9897ced8e78db5d813166a7ccccfd5a42c69ef20)
2025-08-18ldconfig: Move endswithn into a new header fileAdam Sampson3-12/+36
is_gdb_python_file is doing a similar test, so it can use this helper function as well. Signed-off-by: Adam Sampson <ats@offog.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit ed2b8d3a866eb37e069f6a71bdf10421cd4c5e54)
2025-08-15x86-64: Add GLIBC_ABI_DT_X86_64_PLT [BZ #33212]H.J. Lu2-0/+14
When the linker -z mark-plt option is used to add DT_X86_64_PLT, DT_X86_64_PLTSZ and DT_X86_64_PLTENT, the r_addend field of the R_X86_64_JUMP_SLOT relocation stores the offset of the indirect branch instruction. However, glibc versions without the commit: commit f8587a61892cbafd98ce599131bf4f103466f084 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri May 20 19:21:48 2022 -0700 x86-64: Ignore r_addend for R_X86_64_GLOB_DAT/R_X86_64_JUMP_SLOT According to x86-64 psABI, r_addend should be ignored for R_X86_64_GLOB_DAT and R_X86_64_JUMP_SLOT. Since linkers always set their r_addends to 0, we can ignore their r_addends. Reviewed-by: Fangrui Song <maskray@google.com> won't ignore the r_addend value in the R_X86_64_JUMP_SLOT relocation. Such programs and shared libraries will fail at run-time randomly. Add GLIBC_ABI_DT_X86_64_PLT version to indicate that glibc is compatible with DT_X86_64_PLT. The linker can add the glibc GLIBC_ABI_DT_X86_64_PLT version dependency whenever -z mark-plt is passed to the linker. The resulting programs and shared libraries will fail to load at run-time against libc.so without the GLIBC_ABI_DT_X86_64_PLT version, instead of fail randomly. This fixes BZ #33212. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org> (cherry picked from commit 399384e0c8193e31aea014220ccfa24300ae5938)
2025-08-15x86-64: Add GLIBC_ABI_GNU2_TLS version [BZ #33129]H.J. Lu2-0/+14
Programs and shared libraries compiled with -mtls-dialect=gnu2 may fail silently at run-time against glibc without the GNU2 TLS run-time fix for: https://sourceware.org/bugzilla/show_bug.cgi?id=31372 Add GLIBC_ABI_GNU2_TLS version to indicate that glibc has the working GNU2 TLS run-time. Linker can add the GLIBC_ABI_GNU2_TLS version to binaries which depend on the working GNU2 TLS run-time: https://sourceware.org/bugzilla/show_bug.cgi?id=33130 so that such programs and shared libraries will fail to load and run at run-time against libc.so without the GLIBC_ABI_GNU2_TLS version, instead of fail silently at random. This fixes BZ #33129. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org> (cherry picked from commit 9df8fa397d515dc86ff5565f6c45625e672d539e)
2025-08-15libio: Test for fdopen memory leak without SEEK_END support (bug 31840)Florian Weimer2-2/+64
The bug report used /dev/mem, but /proc/self/mem works as well (if available). (cherry picked from commit d0106b6ae26c8cc046269358a77188105c99d5e3)
2025-08-15Remove memory leak in fdopen (bug 31840)Andreas Schwab2-1/+6
Deallocate the memory for the FILE structure when seeking to the end fails in append mode. Fixes: ea33158c96 ("Fix offset caching for streams and use it for ftell (BZ #16680)") (cherry picked from commit b2c3ee3724900975deaf5eae57640bb0c2d7315e)
2025-08-15math: Remove no-mathvec flagJoe Ramsay8-194/+189
More routines are to follow, some of which hit many failures in the current testsuite due to wrong sign of zero (mathvec routines are not required to get this right). Instead of disabling a large number of tests, change the failure condition such that, for vector routines, tests pass as long as computed == expected == 0.0, regardless of sign. Affected tests (vector tests for expm1, log1p, sin, tan and tanh) all still pass. (cherry picked from commit 939e770e0196ebd763cacc602421b76d62df0798)
2025-08-14Use TLS initial-exec model for __libc_tsd_CTYPE_* thread variables [BZ #33234]Jens Remus2-3/+4
Commit 10a66a8e421b ("Remove <libc-tsd.h>") removed the TLS initial-exec (IE) model attribute from the __libc_tsd_CTYPE_* thread variable declarations and definitions. Commit a894f04d8776 ("Optimize __libc_tsd_* thread variable access") restored it on declarations. Restore the TLS initial-exec model attribute on __libc_tsd_CTYPE_* thread variable definitions. This resolves test tst-locale1 failure on s390 32-bit, when using a GNU linker without the fix from GNU binutils commit aefebe82dc89 ("IBM zSystems: Fix offset relative to static TLS"). Reviewed-by: Florian Weimer <fweimer@redhat.com> (cherry picked from commit e5363e6f460c2d58809bf10fc96d70fd1ef8b5b2)
2025-08-14ctype: Fallback initialization of TLS using relocations (bug 19341, bug 32483)Florian Weimer7-3/+138
This ensures that the ctype data pointers in TLS are valid in secondary namespaces even without initialization via __ctype_init. Reviewed-by: Frédéric Bérat <fberat@redhat.com> (cherry picked from commit 2745db8dd3ec31045acd761b612516490085bc20)
2025-08-14Use proper extern declaration for _nl_C_LC_CTYPE_{class,toupper,tolower}Florian Weimer3-9/+6
The existing initializers already contain explicit casts. Keep them due to int/uint32_t mismatch. Reviewed-by: Frédéric Bérat <fberat@redhat.com> (cherry picked from commit e0c0f856f58ceb68800a964c36c15c606e7a8c4c)
2025-08-14Remove <libc-tsd.h>Florian Weimer11-97/+28
Use __thread variables directly instead. The macros do not save any typing. It seems unlikely that a future port will lack __thread variable support. Some of the __libc_tsd_* variables are referenced from assembler files, so keep their names. Previously, <libc-tls.h> included <tls.h>, which in turn included <errno.h>, so a few direct includes of <errno.h> are now required. Reviewed-by: Frédéric Bérat <fberat@redhat.com> (cherry picked from commit 10a66a8e421b09682b774c795ef1da402235dddc)
2025-08-14ctype: Reformat Makefile.Carlos O'Donell1-4/+13
Reflow and sort Makefile. Code generation changes present due to link order changes. No regressions on x86_64 and i686. (cherry picked from commit 12956e0a330e3d90fc196f7d7a047ce613f78920)
2025-08-14elf: Handle ld.so with LOAD segment gaps in _dl_find_object (bug 31943)Florian Weimer8-31/+283
Detect if ld.so not contiguous and handle that case in _dl_find_object. Set l_find_object_processed even for initially loaded link maps, otherwise dlopen of an initially loaded object adds it to _dlfo_loaded_mappings (where maps are expected to be contiguous), in addition to _dlfo_nodelete_mappings. Test elf/tst-link-map-contiguous-ldso iterates over the loader image, reading every word to make sure memory is actually mapped. It only does that if the l_contiguous flag is set for the link map. Otherwise, it finds gaps with mmap and checks that _dl_find_object does not return the ld.so mapping for them. The test elf/tst-link-map-contiguous-main does the same thing for the libc.so shared object. This only works if the kernel loaded the main program because the glibc dynamic loader may fill the gaps with PROT_NONE mappings in some cases, making it contiguous, but accesses to individual words may still fault. Test elf/tst-link-map-contiguous-libc is again slightly different because the dynamic loader always fills the gaps with PROT_NONE mappings, so a different form of probing has to be used. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 20681be149b9eb1b6c1f4246bf4bd801221c86cd)
2025-08-14elf: Extract rtld_setup_phdr function from dl_mainFlorian Weimer1-27/+32
Remove historic binutils reference from comment and update how this data is used by applications. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 2cac9559e06044ba520e785c151fbbd25011865f)
2025-08-14elf: Do not add a copy of _dl_find_object to libc.soFlorian Weimer4-7/+6
This reduces code size and dependencies on ld.so internals from libc.so. Fixes commit f4c142bb9fe6b02c0af8cfca8a920091e2dba44b ("arm: Use _dl_find_object on __gnu_Unwind_Find_exidx (BZ 31405)"). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 96429bcc91a14f71b177ddc5e716de3069060f2c)
2025-08-14arm: Use _dl_find_object on __gnu_Unwind_Find_exidx (BZ 31405)Adhemerval Zanella4-57/+10
Instead of __dl_iterate_phdr. On ARM dlfo_eh_frame/dlfo_eh_count maps to PT_ARM_EXIDX vaddr start / length. On a Neoverse N1 machine with 160 cores, the following program: $ cat test.c #include <stdlib.h> #include <pthread.h> #include <assert.h> enum { niter = 1024, ntimes = 128, }; static void * tf (void *arg) { int a = (int) arg; for (int i = 0; i < niter; i++) { void *p[ntimes]; for (int j = 0; j < ntimes; j++) p[j] = malloc (a * 128); for (int j = 0; j < ntimes; j++) free (p[j]); } return NULL; } int main (int argc, char *argv[]) { enum { nthreads = 16 }; pthread_t t[nthreads]; for (int i = 0; i < nthreads; i ++) assert (pthread_create (&t[i], NULL, tf, (void *) i) == 0); for (int i = 0; i < nthreads; i++) { void *r; assert (pthread_join (t[i], &r) == 0); assert (r == NULL); } return 0; } $ arm-linux-gnueabihf-gcc -fsanitize=address test.c -o test Improves from ~15s to 0.5s. Checked on arm-linux-gnueabihf. (cherry picked from commit f4c142bb9fe6b02c0af8cfca8a920091e2dba44b)
2025-08-11AArch64: Improve codegen in SVE log1pLuna Lamb1-19/+65
Improves memory access, reformat evaluation scheme to pack coefficients. 5% improvement in throughput microbenchmark on Neoverse V1. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com> (cherry picked from commit da196e6134ede64728006518352d75b6c3902fec)
2025-08-11AArch64: Optimize inverse trig functionsDylan Fleming13-411/+599
Improve performance of Inverse trig functions by altering how coefficients are loaded. Performance improvement on Neoverse V1: SVE acos 14% AdvSIMD acos 6% AdvSIMD asin 6% SVE asin 5% AdvSIMD asinf 2% AdvSIMD atanf 22% SVE atanf 20% SVE atan 11% AdvSIMD atan 5% SVE atan2 7% SVE atan2f 4% AdvSIMD atan2f 3% AdvSIMD atan2 2% Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com> (cherry picked from commit 1e84509e0041c0a83997aba602a585bb3b8285f0)
2025-08-11AArch64: Avoid memset ifunc in cpu-features.c [BZ #33112]Wilco Dijkstra1-0/+1
During early startup memcpy or memset must not be called since many targets use ifuncs for them which won't be initialized yet. Security hardening may use -ftrivial-auto-var-init=zero which inserts calls to memset. Redirect memset to memset_generic by including dl-symbol-redir-ifunc.h in cpu-features.c. This fixes BZ #33112. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 681a24ae4d0cb8ed92de98b4da660308840b09ba)
2025-07-24posix: Fix double-free after allocation failure in regcomp (bug 33185)Florian Weimer4-1/+181
If a memory allocation failure occurs during bracket expression parsing in regcomp, a double-free error may result. Reported-by: Anastasia Belova <abelova@astralinux.ru> Co-authored-by: Paul Eggert <eggert@cs.ucla.edu> Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org> (cherry picked from commit 7ea06e994093fa0bcca0d0ee2c1db271d8d7885d)