aboutsummaryrefslogtreecommitdiff
path: root/elf
AgeCommit message (Collapse)AuthorFilesLines
46 hourself: Handle ld.so with LOAD segment gaps in _dl_find_object (bug 31943)Florian Weimer7-32/+280
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>
46 hourself: 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>
6 dayself: 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>
9 dayself: Check SFrame on tst-dl_find_object.cAdhemerval Zanella1-0/+14
If SFrame is enable check if DLFO_FLAG_SFRAME is set (since sframe support is added by default) and if dlfo_sframe has the expected value. Checked on aarch64-linux-gnu and x86_64-linux-gnu. Reviewed-by: Sam James <sam@gentoo.org>
2025-07-18elf: Initialize GLRO (dl_read_only_area) after static dlopen (bug 33139)Florian Weimer2-1/+2
The _dl_read_only_area function in the uninitialized ld.so after static dlopen is not able to find anything. Instead, we need to redirect to the code from the statically linked main program. Fixes commit d60fffe28a46b2a41fc308c1804ff02375d27408 ("debug: Improve '%n' fortify detection (BZ 30932)"). Reviewed-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
2025-07-14elf: Add SFrame support to _dl_find_object functionClaudiu Zissulescu1-13/+39
The SFrame provides information to be able to do stack trace is now well defined and implemented in Binutils 2.41. The format simply contains enough information to be able to do stack trace given a program counter (PC) value, the stack pointer, and the frame pointer. The SFrame information is stored in a .sframe ELF section, which is loaded into its own PT_GNU_SFRAME segment. We consider for this support SFrame version 2. This patch adds the bits to _dl_find_object to recognize and store in struct dl_find_object the necessary info about SFrame section. Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-07-09elf: Remove now pointless empty ld.so.conf files in single testsAndreas K. Hüttel3-6/+0
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-07-05elf: Restore support for _r_debug interpositions and copy relocationsFlorian Weimer7-3/+88
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>
2025-07-05elf: Introduce _dl_debug_change_stateFlorian Weimer5-13/+14
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>
2025-07-05elf: Introduce separate _r_debug_array variableFlorian Weimer1-41/+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>
2025-07-01elf: Add DL_ADDRESS_WITHOUT_RELOC [BZ #33088]H.J. Lu1-5/+4
Add DL_ADDRESS_WITHOUT_RELOC to force an address into a general purpose register to prevent loading it into a vector register directly before run-time relocation. This is an updated fix for BZ #33088. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-06-26elf: Add missing DSO dependencies for tst-rtld-no-malloc-{audit,preload}Florian Weimer1-0/+2
Fixes commit c1560f3f75c0e892b5522c16f91b4e303f677094 ("elf: Switch to main malloc after final ld.so self-relocation"). Reviewed-by: Frédéric Bérat <fberat@redhat.com>
2025-06-19x86: Update tst-gnu2-tls2 testsH.J. Lu1-2/+2
Update tst-gnu2-tls2 tests to set XMM0...XMM7 to all 1s in malloc to verify that XMM registers are preserved when _dl_tlsdesc_dynamic is called by clearing vectors with zeroed XMM registers before _dl_tlsdesc_dynamic and using these XMM registers to clear vectors after _dl_tlsdesc_dynamic. This improves the BZ #31372 test. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2025-06-19i386: Update ___tls_get_addr to preserve vector registersH.J. Lu4-0/+187
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>
2025-06-16elf: Add optimization barrier for __ehdr_start and _endH.J. Lu1-0/+3
rtld.c has extern const ElfW(Ehdr) __ehdr_start attribute_hidden; ... _dl_rtld_map.l_map_start = (ElfW(Addr)) &__ehdr_start; _dl_rtld_map.l_map_end = (ElfW(Addr)) _end; As https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120653 shows, compiler may generate run-time relocation on __ehdr_start with movq .LC0(%rip), %xmm0 ... .section .data.rel.ro.local,"aw" .align 8 .LC0: .quad __ehdr_start This won't work before run-time relocation is finished in rtld.c. Add optimization barrier to prevent run-time relocations against __ehdr_start and _end. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2025-06-15elf: Remove the unused _etext declarationH.J. Lu1-1/+0
Since commit 53df2ce6885da3d0e89e87dca7b095622296014f Author: Florian Weimer <fweimer@redhat.com> Date: Fri Sep 8 13:02:06 2023 +0200 elf: Remove unused l_text_end field from struct link_map removed the only reference to _etext, also remove the unused _etext declaration. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-06-04Makefile: Avoid $(objpfx)/ in makefilesFlorian Weimer1-6/+6
If paths with both $(objpfx)/ and $(objpfx) (which already includes a trailing slash) appear during the build, this can trigger unexpected rebuilds, or incorrect concurrent rebuilds.
2025-06-02elf: Fix UB on _dl_map_object_from_fdAdhemerval Zanella1-1/+1
On 32-bit architecture ubsan triggers: UBSAN: Undefined behaviour in dl-load.c:1345:54 pointer index expression with base 0x00612508 overflowed to 0xf7c3a508 Use explicit uintptr_t operation instead. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-28Update RISC-V relocationsAndreas Schwab1-9/+8
Update the list of RISC-V relocations from the ELF psABI as of June 2024. It removes binutils-internal only relocations that were never part of actual object files. The GNU_VTINHERIT and GNU_VTENTRY relocations were never used because the corresponding GCC option -fvtable-gc was never supported on RISC-V.
2025-05-27malloc: Fix malloc init orderWilco Dijkstra1-3/+3
__ptmalloc_init was called too early in __libc_early_init: it uses __libc_initial which is not set yet. Fix this by moving initialization to the end of __libc_early_init. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-22Fix error reporting (false negatives) in SGID testsFlorian Weimer3-38/+5
And simplify the interface of support_capture_subprogram_self_sgid. Use the existing framework for temporary directories (now with mode 0700) and directory/file deletion. Handle all execution errors within support_capture_subprogram_self_sgid. In particular, this includes test failures because the invoked program did not exit with exit status zero. Existing tests that expect exit status 42 are adjusted to use zero instead. In addition, fix callers not to call exit (0) with test failures pending (which may mask them, especially when running with --direct). Fixes commit 35fc356fa3b4f485bd3ba3114c9f774e5df7d3c2 ("elf: Fix subprocess status handling for tst-dlopen-sgid (bug 32987)"). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-05-21elf: Fix subprocess status handling for tst-dlopen-sgid (bug 32987)Florian Weimer1-2/+10
This should really move into support_capture_subprogram_self_sgid. Reviewed-by: Sam James <sam@gentoo.org>
2025-05-20elf: Test case for bug 32976 (CVE-2025-4802)Florian Weimer3-0/+109
Check that LD_LIBRARY_PATH is ignored for AT_SECURE statically linked binaries, using support_capture_subprogram_self_sgid. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-05-19AArch64: Cleanup PAC and BTIWilco Dijkstra1-3/+1
Now we finally support modern GCC and binutils, it's time for a cleanup. Use PAC and BTI instructions unconditionally and use proper assembler syntax. Remove the PR target/94791 strip_pac workarounds for buggy GCCs. Remove the PAC/BTI configure checks - always emit GNU property notes on assembly files. Change cfi_window_save to the correct cfi_negate_ra_state unwind directive. Reviewed-by: Matthieu Longo <matthieu.longo@arm.com>
2025-05-12malloc: Improve malloc initializationWilco Dijkstra1-0/+4
Move malloc initialization to __libc_early_init. Use a hidden __ptmalloc_init for initialization and a weak call to avoid pulling in the system malloc in a static binary. All previous initialization checks can now be removed. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-05S390: Add new s390 platform z17.Stefan Liebler2-0/+16
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-28nptl: Fix pthread_getattr_np when modules with execstack are allowed (BZ 32897)Adhemerval Zanella3-4/+4
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-22Add NT_ARM_GCS and NT_RISCV_TAGGED_ADDR_CTRL from Linux 6.13 to elf.hJoseph Myers1-0/+3
Linux 6.13 adds new ELF note types NT_ARM_GCS and NT_RISCV_TAGGED_ADDR_CTRL. Add these to glibc's elf.h. Tested for x86_64.
2025-04-08elf: Extend glibc.rtld.execstack tunable to force executable stack (BZ 32653)Adhemerval Zanella8-9/+59
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-03-31elf: Fix tst-origin build when toolchain defaults to --as-needed (BZ 32823)John David Anglin1-1/+2
Checked on aarch64-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-21elf: Use +nolink-deps to add make-only dependency for tst-originFlorian Weimer1-1/+4
The tst-origin test must link against liborigin-mod.so. Correct build order depends on a makefile rule dependency on $(objpfx)liborigin-mod.so. Use +nolink-deps to remvoe this dependency from the linker command line. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-03-21debug: Improve '%n' fortify detection (BZ 30932)Adhemerval Zanella3-0/+88
The 7bb8045ec0 path made the '%n' fortify check ignore EMFILE errors while trying to open /proc/self/maps, and this added a security issue where EMFILE can be attacker-controlled thus making it ineffective for some cases. The EMFILE failure is reinstated but with a different error message. Also, to improve the false positive of the hardening for the cases where no new files can be opened, the _dl_readonly_area now uses _dl_find_object to check if the memory area is within a writable ELF segment. The procfs method is still used as fallback. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Arjun Shankar <arjun@redhat.com>
2025-03-21Remove eloop-threshold.hAdhemerval Zanella1-3/+2
On both Linux and Hurd the __eloop_threshold() is always a constant (40 and 32 respectively), so there is no need to always call __sysconf (_SC_SYMLOOP_MAX) for Linux case (!SYMLOOP_MAX). To avoid a name clash with gnulib, rename the new file min-eloop-threshold.h. Checked on x86_64-linux-gnu and with a build for x86_64-gnu. Reviewed-by: DJ Delorie <dj@redhat.com>
2025-03-18elf: Fix tst-origin make rulesAdhemerval Zanella1-10/+3
The tst-origin build can fail with: /usr/bin/ld: [...]libc.so: undefined reference to `__tunable_is_initialized@GLIBC_PRIVATE' Since the custom link invocation links against system glibc instead of the built one. The only requirement is to avoid liborigin.so linked with a full path, which is the default for --enable-hardcoded-path-in-tests. There is no need to use a custom rule. Checked on x86_64-linux-gnu.
2025-03-17elf: Fix tst-origin make rulesAdhemerval Zanella1-3/+7
Add tests-special before include Rules and compile liborigin.os with MODULE_NAME set to testsuite instead of libc.
2025-03-13elf: Canonicalize $ORIGIN in an explicit ld.so invocation [BZ 25263]Adhemerval Zanella6-0/+123
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-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-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-07elf: Check if __attribute__ ((aligned (65536))) is supportedH.J. Lu1-4/+8
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-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-05Remove dl-procinfo.hAdhemerval Zanella7-7/+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-04Pass -Wl,--no-error-execstack for tests where -Wl,-z,execstack is used [PR32717]Sam James1-0/+6
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-02-24AArch64: Remove AARCH64_R macroWilco Dijkstra1-13/+0
Remove AArch64_R relocation macro. Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-02-13elf: Keep using minimal malloc after early DTV resize (bug 32412)Florian Weimer4-0/+117
If an auditor loads many TLS-using modules during startup, it is possible to trigger DTV resizing. Previously, the DTV was marked as allocated by the main malloc afterwards, even if the minimal malloc was still in use. With this change, _dl_resize_dtv marks the resized DTV as allocated with the minimal malloc. The new test reuses TLS-using modules from other auditing tests. Reviewed-by: DJ Delorie <dj@redhat.com>
2025-02-05elf: Build dl-tls.o with early startup symbol redirectionsFlorian Weimer1-0/+6
This is required when building for powerpc64le POWER8 with GCC 8 at least. Fixes commit cbd9fd236981717d3d4ee942986ea912e9707c32 ("Consolidate TLS block allocation for static binaries with ld.so"). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-02-02elf: Use _dl_find_object instead of _dl_find_dso_for_object in dlopenFlorian Weimer1-2/+4
The _dl_find_object function uses a binary search and is faster if there are many objects.
2025-02-02elf: Add fast path to dlopen for fully-opened mapsFlorian Weimer1-5/+31
If the map is already fully open (has matching flags and its own scope allocated), it is not necessary to unprotected memory during dlopen.
2025-02-02elf: Determine the caller link map in _dl_openFlorian Weimer1-28/+19
No functional change expected. This is in preparation of adding a fast path to dlopen in case no link map changes are required.
2025-02-02elf: Merge __dl_libc_freemem into __rtld_libc_freeresFlorian Weimer2-107/+101
The functions serve very similar purposes. The advantage of __rtld_libc_freeres is that it is located within ld.so, so it is more natural to poke at link map internals there. This slightly regresses cleanup capabilities for statically linked binaries. If that becomes a problem, we should start calling __rtld_libc_freeres from __libc_freeres (perhaps after renaming it).
2025-02-02elf: Add l_soname accessor function for DT_SONAME valuesFlorian Weimer5-56/+35
It's not necessary to introduce temporaries because the compiler is able to evaluate l_soname just once in constracts like: l_soname (l) != NULL && strcmp (l_soname (l), LIBC_SO) != 0