about summary refs log tree commit diff
path: root/elf/Makefile
Commit message (Collapse)AuthorAgeFilesLines
* elf: Also compile dl-misc.os with $(rtld-early-cflags)H.J. Lu2024-04-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also compile dl-misc.os with $(rtld-early-cflags) to avoid Program received signal SIGILL, Illegal instruction. 0x00007ffff7fd36ea in _dl_strtoul (nptr=nptr@entry=0x7fffffffe2c9 "2", endptr=endptr@entry=0x7fffffffd728) at dl-misc.c:156 156 bool positive = true; (gdb) bt #0 0x00007ffff7fd36ea in _dl_strtoul (nptr=nptr@entry=0x7fffffffe2c9 "2", endptr=endptr@entry=0x7fffffffd728) at dl-misc.c:156 #1 0x00007ffff7fdb1a9 in tunable_initialize ( cur=cur@entry=0x7ffff7ffbc00 <tunable_list+2176>, strval=strval@entry=0x7fffffffe2c9 "2", len=len@entry=1) at dl-tunables.c:131 #2 0x00007ffff7fdb3a2 in parse_tunables (valstring=<optimized out>) at dl-tunables.c:258 #3 0x00007ffff7fdb5d9 in __GI___tunables_init (envp=0x7fffffffdd58) at dl-tunables.c:288 #4 0x00007ffff7fe44c3 in _dl_sysdep_start ( start_argptr=start_argptr@entry=0x7fffffffdcb0, dl_main=dl_main@entry=0x7ffff7fe5f80 <dl_main>) at ../sysdeps/unix/sysv/linux/dl-sysdep.c:110 #5 0x00007ffff7fe5cae in _dl_start_final (arg=0x7fffffffdcb0) at rtld.c:494 #6 _dl_start (arg=0x7fffffffdcb0) at rtld.c:581 #7 0x00007ffff7fe4b38 in _start () (gdb) when setting GLIBC_TUNABLES in glibc compiled with APX. Reviewed-by: Florian Weimer <fweimer@redhat.com> (cherry picked from commit 049b7684c912dd32b67b1b15b0f43bf07d5f512e)
* elf: Introduce to _dl_call_finiFlorian Weimer2023-09-111-0/+1
| | | | | | | | | | This consolidates the destructor invocations from _dl_fini and dlclose. Remove the micro-optimization that avoids calling _dl_call_fini if they are no destructors (as dlclose is quite expensive anyway). The debug log message is now printed unconditionally. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Smoke-test ldconfig -p against system /etc/ld.so.cacheFlorian Weimer2023-02-081-0/+6
| | | | | | | | | The test is sufficient to detect the ldconfig bug fixed in commit 9fe6f6363886aae6b2b210cae3ed1f5921299083 ("elf: Fix 64 time_t support for installed statically binaries"). Reviewed-by: Carlos O'Donell <carlos@redhat.com> (cherry picked from commit 9fd63e35371b9939e9153907c6a753e6960b68ad)
* elf: Run tst-audit-tlsdesc, tst-audit-tlsdesc-dlopen everywhereFlorian Weimer2022-09-131-16/+6
| | | | | | | | | | | | | | The test is valid for all TLS models, but we want to make a reasonable effort to test the GNU2 model specifically. For example, aarch64 defaults to GNU2, but does not have -mtls-dialect=gnu2, and the test was not run there. Suggested-by: Martin Coufal <mcoufal@redhat.com> (cherry picked from commit dd2315a866a4ac2b838ea1cb10c5ea1c35d51a2f) Fixes early backport commit 924e4f3eaa502ce82fccf8537f021a796d158771 ("elf: Call __libc_early_init for reused namespaces (bug 29528)"); it had a wrong conflict resolution.
* elf: Call __libc_early_init for reused namespaces (bug 29528)Florian Weimer2022-08-301-0/+25
| | | | | | | | | | | | libc_map is never reset to NULL, neither during dlclose nor on a dlopen call which reuses the namespace structure. As a result, if a namespace is reused, its libc is not initialized properly. The most visible result is a crash in the <ctype.h> functions. To prevent similar bugs on namespace reuse from surfacing, unconditionally initialize the chosen namespace to zero using memset. (cherry picked from commit d0e357ff45a75553dee3b17ed7d303bfa544f6fe)
* elf: Rename tst-audit26 to tst-audit28Florian Weimer2022-07-081-5/+5
| | | | | | tst-audit26 and tst-audit27 are already used by aarch64. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* grep: egrep -> grep -E, fgrep -> grep -FSam James2022-06-051-1/+1
| | | | | | | | | | | Newer versions of GNU grep (after grep 3.7, not inclusive) will warn on 'egrep' and 'fgrep' invocations. Convert usages within the tree to their expanded non-aliased counterparts to avoid irritating warnings during ./configure and the test suite. Signed-off-by: Sam James <sam@gentoo.org> Reviewed-by: Fangrui Song <maskray@google.com>
* dlsym: Make RTLD_NEXT prefer default version definition [BZ #14932]Fangrui Song2022-05-271-0/+7
| | | | | | | | | | | | | When the first object providing foo defines both foo@v1 and foo@@v2, dlsym(RTLD_NEXT, "foo") returns foo@v1 while dlsym(RTLD_DEFAULT, "foo") returns foo@@v2. The issue is that RTLD_DEFAULT uses the DL_LOOKUP_RETURN_NEWEST flag while RTLD_NEXT doesn't. Fix the RTLD_NEXT branch to use DL_LOOKUP_RETURN_NEWEST. Note: the new behavior matches FreeBSD rtld. Future sanitizers will not need to add versioned interceptors like https://reviews.llvm.org/D96348 Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Add tests for the dl hash funcs (_dl_new_hash and _dl_elf_hash)Noah Goldstein2022-05-231-0/+1
| | | | | If we want to further optimize the functions tests are needed. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* Enable DT_RELR in glibc shared libraries and PIEs automaticallyH.J. Lu2022-05-181-1/+4
| | | | | | Enable DT_RELR in glibc shared libraries and position independent executables (PIE) automatically if linker supports -z pack-relative-relocs. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* csu: Implement and use _dl_early_allocate during static startupFlorian Weimer2022-05-161-0/+19
| | | | | | | | | | | This implements mmap fallback for a brk failure during TLS allocation. scripts/tls-elf-edit.py is updated to support the new patching method. The script no longer requires that in the input object is of ET_DYN type. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Use __ehdr_start rather than _begin in _dl_start_finalAlan Modra2022-04-281-2/+1
| | | | | | | | | | __ehdr_start is already used in rltld.c:dl_main, and can serve the same purpose as _begin. Besides tidying the code, using linker defined section relative symbols rather than "-defsym _begin=0" better reflects the intent of _dl_start_final use of _begin, which is to refer to the load address of ld.so rather than absolute address zero. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* elf: Fix DFS sorting algorithm for LD_TRACE_LOADED_OBJECTS with missing ↵Adhemerval Zanella2022-04-271-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libraries (BZ #28868) On _dl_map_object the underlying file is not opened in trace mode (in other cases where the underlying file can't be opened, _dl_map_object quits with an error). If there any missing libraries being processed, they will not be considered on final nlist size passed on _dl_sort_maps later in the function. And it is then used by _dl_sort_maps_dfs on the stack allocated working maps: 222 /* Array to hold RPO sorting results, before we copy back to maps[]. */ 223 struct link_map *rpo[nmaps]; 224 225 /* The 'head' position during each DFS iteration. Note that we start at 226 one past the last element due to first-decrement-then-store (see the 227 bottom of above dfs_traversal() routine). */ 228 struct link_map **rpo_head = &rpo[nmaps]; However while transversing the 'l_initfini' on dfs_traversal it will still consider the l_faked maps and thus update rpo more times than the allocated working 'rpo', overflowing the stack object. As suggested in bugzilla, one option would be to avoid sorting the maps for trace mode. However I think ignoring l_faked object does make sense (there is one less constraint to call the sorting function), it allows a slight less stack usage for trace, and it is slight simpler solution. The tests does trigger the stack overflow, however I tried to make it more generic to check different scenarios or missing objects. Checked on x86_64-linux-gnu. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* elf: Add more DT_RELR testsH.J. Lu2022-04-261-3/+73
| | | | | | | | Verify that: 1. A DT_RELR shared library without DT_NEEDED works. 2. A DT_RELR shared library without DT_VERNEED works. 3. A DT_RELR shared library without libc.so on DT_NEEDED works.
* elf: Support DT_RELR relative relocation format [BZ #27924]Fangrui Song2022-04-261-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PIE and shared objects usually have many relative relocations. In 2017/2018, SHT_RELR/DT_RELR was proposed on https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/GxjM0L-PBAAJ ("Proposal for a new section type SHT_RELR") and is a pre-standard. RELR usually takes 3% or smaller space than R_*_RELATIVE relocations. The virtual memory size of a mostly statically linked PIE is typically 5~10% smaller. --- Notes I will not include in the submitted commit: Available on https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/maskray/relr "pre-standard": even Solaris folks are happy with the refined generic-abi proposal. Cary Coutant will apply the change https://sourceware.org/pipermail/libc-alpha/2021-October/131781.html This patch is simpler than Chrome OS's glibc patch and makes ELF_DYNAMIC_DO_RELR available to all ports. I don't think the current glibc implementation supports ia64 in an ELFCLASS32 container. That said, the style I used is works with an ELFCLASS32 container for 64-bit machine if ElfW(Addr) is 64-bit. * Chrome OS folks have carried a local patch since 2018 (latest version: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/refs/heads/main/sys-libs/glibc/files/local/glibc-2.32). I.e. this feature has been battle tested. * Android bionic supports 2018 and switched to DT_RELR==36 in 2020. * The Linux kernel has supported CONFIG_RELR since 2019-08 (https://git.kernel.org/linus/5cf896fb6be3effd9aea455b22213e27be8bdb1d). * A musl patch (by me) exists but is not applied: https://www.openwall.com/lists/musl/2019/03/06/3 * rtld-elf from FreeBSD 14 will support DT_RELR. I believe upstream glibc should support DT_RELR to benefit all Linux distributions. I filed some feature requests to get their attention: * Gentoo: https://bugs.gentoo.org/818376 * Arch Linux: https://bugs.archlinux.org/task/72433 * Debian https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=996598 * Fedora https://bugzilla.redhat.com/show_bug.cgi?id=2014699 As of linker support (to the best of my knowledge): * LLD support DT_RELR. * https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/refs/heads/main/sys-devel/binutils/files/ has a gold patch. * GNU ld feature request https://sourceware.org/bugzilla/show_bug.cgi?id=27923 Changes from the original patch: 1. Check the linker option, -z pack-relative-relocs, which add a GLIBC_ABI_DT_RELR symbol version dependency on the shared C library if it provides a GLIBC_2.XX symbol version. 2. Change make variale to have-dt-relr. 3. Rename tst-relr-no-pie to tst-relr-pie for --disable-default-pie. 4. Use TEST_VERIFY in tst-relr.c. 5. Add the check-tst-relr-pie.out test to check for linker generated libc.so version dependency on GLIBC_ABI_DT_RELR. 6. Move ELF_DYNAMIC_DO_RELR before ELF_DYNAMIC_DO_REL.
* Add GLIBC_ABI_DT_RELR for DT_RELR supportH.J. Lu2022-04-261-2/+12
| | | | | | | | | | | | | | | | | | | | The EI_ABIVERSION field of the ELF header in executables and shared libraries can be bumped to indicate the minimum ABI requirement on the dynamic linker. However, EI_ABIVERSION in executables isn't checked by the Linux kernel ELF loader nor the existing dynamic linker. Executables will crash mysteriously if the dynamic linker doesn't support the ABI features required by the EI_ABIVERSION field. The dynamic linker should be changed to check EI_ABIVERSION in executables. Add a glibc version, GLIBC_ABI_DT_RELR, to indicate DT_RELR support so that the existing dynamic linkers will issue an error on executables with GLIBC_ABI_DT_RELR dependency. When there is a DT_VERNEED entry with libc.so on DT_NEEDED, issue an error if there is a DT_RELR entry without GLIBC_ABI_DT_RELR dependency. Support __placeholder_only_for_empty_version_map as the placeholder symbol used only for empty version map to generate GLIBC_ABI_DT_RELR without any symbols.
* dlfcn: Do not use rtld_active () to determine ld.so state (bug 29078)Florian Weimer2022-04-261-0/+6
| | | | | | | | | | | | | | | | | | | | When audit modules are loaded, ld.so initialization is not yet complete, and rtld_active () returns false even though ld.so is mostly working. Instead, the static dlopen hook is used, but that does not work at all because this is not a static dlopen situation. Commit 466c1ea15f461edb8e3ffaf5d86d708876343bbf ("dlfcn: Rework static dlopen hooks") moved the hook pointer into _rtld_global_ro, which means that separate protection is not needed anymore and the hook pointer can be checked directly. The guard for disabling libio vtable hardening in _IO_vtable_check should stay for now. Fixes commit 8e1472d2c1e25e6eabc2059170731365f6d5b3d1 ("ld.so: Examine GLRO to detect inactive loader [BZ #20204]"). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Default to --with-default-link=no (bug 25812)Florian Weimer2022-04-221-0/+33
| | | | | | | | | This is necessary to place the libio vtables into the RELRO segment. New tests elf/tst-relro-ldso and elf/tst-relro-libc are added to verify that this is what actually happens. The new tests fail on ia64 due to lack of (default) RELRO support inbutils, so they are XFAILed there.
* scripts: Add glibcelf.py moduleFlorian Weimer2022-04-221-0/+7
| | | | | | | | | | | | | | | | Hopefully, this will lead to tests that are easier to maintain. The current approach of parsing readelf -W output using regular expressions is not necessarily easier than parsing the ELF data directly. This module is still somewhat incomplete (e.g., coverage of relocation types and versioning information is missing), but it is sufficient to perform basic symbol analysis or program header analysis. The EM_* mapping for architecture-specific constant classes (e.g., SttX86_64) is not yet implemented. The classes are defined for the benefit of elf/tst-glibcelf.py. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* S390: Add new s390 platform z16.Stefan Liebler2022-04-141-0/+8
| | | | | | | | | | | | | | The new IBM z16 is added to platform string array. The macro _DL_PLATFORMS_COUNT is incremented. _dl_hwcaps_subdir is extended by "z16" if HWCAP_S390_VXRS_PDE2 is set. HWCAP_S390_NNPA is not tested in _dl_hwcaps_subdirs_active as those instructions may be replaced or removed in future. tst-glibc-hwcaps.c is extended in order to test z16 via new marker5. A fatal glibc error is dumped if glibc was build with architecture level set for z16, but run on an older machine. (See dl-hwcap-check.h)
* Linux: Consolidate auxiliary vector parsing (redo)Florian Weimer2022-02-281-0/+5
| | | | | | | | | | | And optimize it slightly. This is commit 8c8510ab2790039e58995ef3a22309582413d3ff revised. In _dl_aux_init in elf/dl-support.c, use an explicit loop and -fno-tree-loop-distribute-patterns to avoid memset. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* build: Properly generate .d dependency files [BZ #28922]H.J. Lu2022-02-251-0/+3
| | | | | | | | | | | | | 1. Also generate .d dependency files for $(tests-container) and $(tests-printers). 2. elf: Add tst-auditmod17.os to extra-test-objs. 3. iconv: Add tst-gconv-init-failure-mod.os to extra-test-objs. 4. malloc: Rename extra-tests-objs to extra-test-objs. 5. linux: Add tst-sysconf-iov_max-uapi.o to extra-test-objs. 6. x86_64: Add tst-x86_64mod-1.o, tst-platformmod-2.o, test-libmvec.o, test-libmvec-avx.o, test-libmvec-avx2.o and test-libmvec-avx512f.o to extra-test-objs. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* elf: Remove prelink supportAdhemerval Zanella2022-02-101-16/+0
| | | | | | | | | | | | | Prelinked binaries and libraries still work, the dynamic tags DT_GNU_PRELINKED, DT_GNU_LIBLIST, DT_GNU_CONFLICT just ignored (meaning the process is reallocated as default). The loader environment variable TRACE_PRELINKING is also removed, since it used solely on prelink. Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* hppa: Fix bind-now audit (BZ #28857)Adhemerval Zanella2022-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | On hppa, a function pointer returned by la_symbind is actually a function descriptor has the plabel bit set (bit 30). This must be cleared to get the actual address of the descriptor. If the descriptor has been bound, the first word of the descriptor is the physical address of theA function, otherwise, the first word of the descriptor points to a trampoline in the PLT. This patch also adds a workaround on tests because on hppa (and it seems to be the only ABI I have see it), some shared library adds a dynamic PLT relocation to am empty symbol name: $ readelf -r elf/tst-audit25mod1.so [...] Relocation section '.rela.plt' at offset 0x464 contains 6 entries: Offset Info Type Sym.Value Sym. Name + Addend 00002008 00000081 R_PARISC_IPLT 508 [...] It breaks some assumptions on the test, where a symbol with an empty name ("") is passed on la_symbind. Checked on x86_64-linux-gnu and hppa-linux-gnu.
* elf: Replace tst-audit24bmod2.so with tst-audit24bmod2H.J. Lu2022-02-061-1/+1
| | | | | | | | Replace tst-audit24bmod2.so with tst-audit24bmod2 to silence: make[2]: Entering directory '/export/gnu/import/git/gitlab/x86-glibc/elf' Makefile:2201: warning: overriding recipe for target '/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/elf/tst-audit24bmod2.so' ../Makerules:765: warning: ignoring old recipe for target '/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/elf/tst-audit24bmod2.so'
* Fix elf/tst-audit25a with default bind now toolchainsSzabolcs Nagy2022-02-021-0/+1
| | | | | This test relies on lazy binding for the executable so request that explicitly in case the toolchain defaults to bind now.
* elf: Issue la_symbind for bind-now (BZ #23734)Adhemerval Zanella2022-02-011-1/+88
| | | | | | | | | | | | | | | | | | | | | | | The audit symbind callback is not called for binaries built with -Wl,-z,now or when LD_BIND_NOW=1 is used, nor the PLT tracking callbacks (plt_enter and plt_exit) since this would change the expected program semantics (where no PLT is expected) and would have performance implications (such as for BZ#15533). LAV_CURRENT is also bumped to indicate the audit ABI change (where la_symbind flags are set by the loader to indicate no possible PLT trace). To handle powerpc64 ELFv1 function descriptor, _dl_audit_symbind requires to know whether bind-now is used so the symbol value is updated to function text segment instead of the OPD (for lazy binding this is done by PPC64_LOAD_FUNCPTR on _dl_runtime_resolve). Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, powerpc64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* elf: Fix initial-exec TLS access on audit modules (BZ #28096)Adhemerval Zanella2022-02-011-0/+8
| | | | | | | | | | | | | | | | | For audit modules and dependencies with initial-exec TLS, we can not set the initial TLS image on default loader initialization because it would already be set by the audit setup. However, subsequent thread creation would need to follow the default behaviour. This patch fixes it by setting l_auditing link_map field not only for the audit modules, but also for all its dependencies. This is used on _dl_allocate_tls_init to avoid the static TLS initialization at load time. Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* elf: Add la_activity during application exitAdhemerval Zanella2022-02-011-0/+7
| | | | | | | | | | la_activity is not called during application exit, even though la_objclose is. Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Fix elf/loadfail test build dependenciesSzabolcs Nagy2022-01-281-1/+3
| | | | | | | | | | There was no direct or indirect make dependency on testobj3.so so the test could fail with /B/elf/loadfail: failed to load shared object: testobj3.so: cannot open shared object file: No such file or directory Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Fix glibc 2.34 ABI omission (missing GLIBC_2.34 in dynamic loader)Florian Weimer2022-01-271-0/+1
| | | | | | | | | | | | | The glibc 2.34 release really should have added a GLIBC_2.34 symbol to the dynamic loader. With it, we could move functions such as dlopen or pthread_key_create that work on process-global state into the dynamic loader (once we have fixed a longstanding issue with static linking). Without the GLIBC_2.34 symbol, yet another new symbol version would be needed because old glibc will fail to load binaries due to the missing symbol version in ld.so that newly linked programs will require. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* Guard tst-valgrind-smoke.out with run-built-testsMark Wielaard2022-01-261-0/+2
| | | | | | Prevent tst-valgrind-smoke from running when run-built-tests is not yes. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Replace tst-p_alignmod1-editX with a python scriptAdhemerval Zanella2022-01-261-10/+4
| | | | | | | | This avoid the cross-compiling breakage when the test should not run ($(run-built-tests) equal to no). Checked on x86_64-linux-gnu and i686-linux-gnu as well with a cross compile to aarch64-linux-gnu and powerpc64-linux-gnu.
* elf: Add a test for PT_LOAD segments with invalid p_align [BZ #28688]H.J. Lu2022-01-241-0/+9
| | | | | | | Build tst-p_alignmod3.so with 256 byte page size and verify that it is rejected with a proper error message. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Add a test for PT_LOAD segments with p_align == 1 [BZ #28688]H.J. Lu2022-01-241-0/+13
| | | | | | | | Add tst-p_alignmod2-edit to edit the copy of tst-p_alignmod-base.so to set p_align of the first PT_LOAD segment to 1 and verify that the shared library can be loaded normally. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Add a test for PT_LOAD segments with mixed p_align [BZ #28676]H.J. Lu2022-01-241-0/+17
| | | | | | | | Add tst-p_alignmod1-edit to edit the copy of tst-p_alignmod-base.so to reduce p_align of the first PT_LOAD segment by half and verify that the shared library is mapped with the maximum p_align of all PT_LOAD segments. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Add and use link-test-modules-rpath-link [BZ #28455]H.J. Lu2022-01-241-0/+7
| | | | | | | | | | | | | DT_RUNPATH is only used to find the immediate dependencies of the executable or shared object containing the DT_RUNPATH entry: 1. Define link-test-modules-rpath-link if $(build-hardcoded-path-in-tests) is yes. 2. Use $(link-test-modules-rpath-link) in build-module-helper so that test modules can dlopen modules with DT_RUNPATH. 3. Add a test to show why link-test-modules-rpath-link is needed. This partially fixes BZ #28455.
* Add valgrind smoke testAlexandra Hájková2022-01-221-0/+7
| | | | | | | | | | Check if whether valgrind is available in the test environment. If not, skip the test. Run smoke tests with valgrind to verify dynamic loader. First, check if algrind works with the system ld.so in the test environment. Then run the actual test inside the test environment, using the just build ld.so and new libraries. Co-authored-by: Mark Wielaard <mark@klomp.org>
* elf: Move _dl_setup_hash to its own fileFlorian Weimer2022-01-181-0/+2
| | | | | | | | | And compile it with the early CFLAGS. _dl_setup_hash is called very early for the ld.so link map, so it should be compiled differently. Reviewed-by: Stefan Liebler <stli@linux.ibm.com> Tested-by: Stefan Liebler <stli@linux.ibm.com>
* elf: Reinstate tst-audit17Adhemerval Zanella2022-01-171-0/+1
| | | | | 9926f6e2eeb3 ("elf: Skip tst-auditlogmod-* if the linker doesn't support --depaudit [BZ #28 151]") dropped the test by mistake.
* Add --with-rtld-early-cflags configure optionFlorian Weimer2022-01-141-0/+8
| | | | | Reviewed-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* elf: Split dl-printf.c from dl-misc.cFlorian Weimer2022-01-141-0/+1
| | | | | | | This allows to use different compiler flags for the diagnostics code. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* elf/Makefile: Reflow and sort most variable assignmentsFlorian Weimer2022-01-141-102/+318
| | | | Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* elf: Add a comment after trailing backslashesH.J. Lu2022-01-041-0/+4
|
* elf: Also try DT_RUNPATH for LD_AUDIT dlopen [BZ #28455]H.J. Lu2022-01-041-3/+8
| | | | | | | | | | | DT_RUNPATH is only used to find the immediate dependencies of the executable or shared object containing the DT_RUNPATH entry. Update LD_AUDIT dlopen call to try the DT_RUNPATH entry of the executable. Add tst-audit14a, which is copied from tst-audit14, to DT_RUNPATH and build tst-audit14 with -Wl,--disable-new-dtags to test DT_RPATH. This partially fixes BZ #28455.
* elf: Fix tst-linkall-static link when pthread is not in libcSamuel Thibault2022-01-041-0/+4
| | | | In that case we want to link in libanl.a, thus providing getaddrinfo_a.
* elf: Sort tests and modules-namesH.J. Lu2022-01-031-147/+405
| | | | Sort tests and modules-names to reduce future conflicts.
* Remove stale reference to libanl.aAdhemerval Zanella2022-01-031-1/+0
| | | | | Since dbb949f53d4 ("resolv: Move libanl into libc (if libpthread is in libc)") libanl.a is empty, so linking against it no longer necessary.
* Update copyright dates with scripts/update-copyrightsPaul Eggert2022-01-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 7061 files FOO. I then removed trailing white space from math/tgmath.h, support/tst-support-open-dev-null-range.c, and sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following obscure pre-commit check failure diagnostics from Savannah. I don't know why I run into these diagnostics whereas others evidently do not. remote: *** 912-#endif remote: *** 913: remote: *** 914- remote: *** error: lines with trailing whitespace found ... remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
* elf: Add _dl_find_object functionFlorian Weimer2021-12-281-4/+51
| | | | | | | | | | | | | | | | | | | | | | | | | It can be used to speed up the libgcc unwinder, and the internal _dl_find_dso_for_object function (which is used for caller identification in dlopen and related functions, and in dladdr). _dl_find_object is in the internal namespace due to bug 28503. If libgcc switches to _dl_find_object, this namespace issue will be fixed. It is located in libc for two reasons: it is necessary to forward the call to the static libc after static dlopen, and there is a link ordering issue with -static-libgcc and libgcc_eh.a because libc.so is not a linker script that includes ld.so in the glibc build tree (so that GCC's internal -lc after libgcc_eh.a does not pick up ld.so). It is necessary to do the i386 customization in the sysdeps/x86/bits/dl_find_object.h header shared with x86-64 because otherwise, multilib installations are broken. The implementation uses software transactional memory, as suggested by Torvald Riegel. Two copies of the supporting data structures are used, also achieving full async-signal-safety. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>