| #
eeb15e76 |
| 30-Jul-2023 |
riastradh <riastradh@NetBSD.org> |
ld.elf_so: Split hash functions into a separate file.
This way we can test them in isolation.
No functional change intended.
|
| #
3caa8dc7 |
| 04-Jun-2023 |
joerg <joerg@NetBSD.org> |
Fix interactions of initial-exec TLS model and dlopen
(1) If an initial-exec relocation was used for a non-local symbol (i.e. the definition of the symbol is in a different DSO), the computation of
Fix interactions of initial-exec TLS model and dlopen
(1) If an initial-exec relocation was used for a non-local symbol (i.e. the definition of the symbol is in a different DSO), the computation of the static TLS offset used the wrong DSO. This would effectively mean the wrong address was computed (PR toolchain/50277, PR pkg/57445).
Fix this by forcing the computation of the correct DSO (the one defining the symbol).
This code uses __UNCONST to avoid the vast interface changes for this special case.
(2) If symbols from a DSO loaded via dlopen are used with both global-dynamic/local-dynamic and initial-exec relocations AND a initial-exec relocation was resolved first in a thread, a split brain situation could exist where the dynamic relocations would use one memory block (separate allocation) and the initial-exec relocations the static per-thread TLS space.
(3) If the initial-exec relocation in (2) is seen after any thread has already used a GD/LD allocation, bail out. Since IE relocations are used only in the GOT, this will prevent the dlopen. This is a bit more aggressive than necessary, but a full blown reference counting doesn't seem to be justified.
show more ...
|
| #
5eb59300 |
| 18-Apr-2023 |
christos <christos@NetBSD.org> |
The SysV ABI specifies that the symbol hash function should return only 32 bits of hash. Unfortunately due to an implementation bu and the fact that the return type is unsigned long which is 64 bits
The SysV ABI specifies that the symbol hash function should return only 32 bits of hash. Unfortunately due to an implementation bu and the fact that the return type is unsigned long which is 64 bits in LP64, this can fail in some cases: "\xff\x0f\x0f\x0f\x0f\x0f\x12". See: https://maskray.me/blog/2023-04-12-elf-hash-function From Ed Maste @ FreeBSD: https://cgit.freebsd.org/src/commit/\ ?id=29e3a06510823edbb91667d21f530d3ec778116d Need to write Unit Tests for this.
show more ...
|
| #
f927c76a |
| 21-Jun-2022 |
skrll <skrll@NetBSD.org> |
Support ifunc on aarch64. The tests pass at least.
|
| #
810da4c4 |
| 21-Jun-2022 |
skrll <skrll@NetBSD.org> |
Wrap long #if defined(...) || ... and sort. NFCI.
|
| #
45f12ca2 |
| 04-Dec-2021 |
skrll <skrll@NetBSD.org> |
Restore the fptr_t type of {init,fini}{,_array} that was removed when initial support for indirect functions was added. This fixes {init,fini}_array support on hppa where each member of the array is
Restore the fptr_t type of {init,fini}{,_array} that was removed when initial support for indirect functions was added. This fixes {init,fini}_array support on hppa where each member of the array is (already) a plabel.
Discussed with joerg.
4 files changed, 29 insertions(+), 39 deletions(-) : ----------------------------------------------------------------------
show more ...
|
| #
f3656ffa |
| 21-Sep-2020 |
kamil <kamil@NetBSD.org> |
Upgrade the SVR4 RTLD r_debug protocol to version 1
Changes: - Add a new field r_ldbase in the r_debug struct. - Set r_version to 1.
This harmonizes the support with OpenBSD and Linux. FreeBSD us
Upgrade the SVR4 RTLD r_debug protocol to version 1
Changes: - Add a new field r_ldbase in the r_debug struct. - Set r_version to 1.
This harmonizes the support with OpenBSD and Linux. FreeBSD uses version 0 (or no version). Solaris uses version 2 that is not implemented elsewhere and relies on SVR4 specific design and interfaces.
Update the code comments as r_debug and link_map is used by other software than GDB, namely: sanitizers, rump, LLDB.
show more ...
|
| #
25a494ec |
| 19-Apr-2020 |
joerg <joerg@NetBSD.org> |
Rename __atomic_fork to __locked_fork and give it &errno as argument. rtld and libc use different storage, so the initial version would incorrectly report the failure reason for fork().
There is sti
Rename __atomic_fork to __locked_fork and give it &errno as argument. rtld and libc use different storage, so the initial version would incorrectly report the failure reason for fork().
There is still a small race condition inside ld.elf_so as it doesn't use thread-safe errno internally, but that's a more contained internal issue.
show more ...
|
| #
11954c74 |
| 16-Apr-2020 |
joerg <joerg@NetBSD.org> |
Introduce intermediate locking for fork, so that the dynamic linker is in a consistent state. This most importantly avoids races between dlopen and friends and fork, potentially resulting in dead loc
Introduce intermediate locking for fork, so that the dynamic linker is in a consistent state. This most importantly avoids races between dlopen and friends and fork, potentially resulting in dead locks in the child when it itself tries to acquire locks.
show more ...
|
| #
e8e47701 |
| 29-Feb-2020 |
kamil <kamil@NetBSD.org> |
Implement DT_GNU_HASH
DT_GNU_HASH serves the same purpose as DT_HASH, however it is a distinct and faster apprach implemented and designed in the GNU toolchain in 2006.
DT_GNU_HASH is preferred whe
Implement DT_GNU_HASH
DT_GNU_HASH serves the same purpose as DT_HASH, however it is a distinct and faster apprach implemented and designed in the GNU toolchain in 2006.
DT_GNU_HASH is preferred whenever available.
Original GNU benchmarks claim 50% faster dynamic linking time. https://www.sourceware.org/ml/binutils/2006-06/msg00418.html
Code based on FreeBSD and OpenBSD, both were based on DragonFlyBSD.
show more ...
|
| #
4e9bea3d |
| 29-Feb-2020 |
kamil <kamil@NetBSD.org> |
Implement and integrate GNU Hashing function
Define Elf_Hash struct that contains ELF/SYSV and GNU hash checksum. Implement _rtld_gnu_hash() for DT_GNU_HASH. Adapt existing code to compute all Elf_H
Implement and integrate GNU Hashing function
Define Elf_Hash struct that contains ELF/SYSV and GNU hash checksum. Implement _rtld_gnu_hash() for DT_GNU_HASH. Adapt existing code to compute all Elf_Hash types, instead of only the ELF/SYSV one. Rename _rtld_elf_hash() to _rtld_sysv_hash() to match the GNU toolchain terminology.
_rtld_gnu_hash() uses Dan Bernstein's string hash function posted eons ago on comp.lang.c.
show more ...
|
| #
61268f23 |
| 30-Dec-2018 |
christos <christos@NetBSD.org> |
binutils 2.31.1 can put copy relocations in the relro segment. Delay protecting the relro segment for the main object until copy relocations are done.
|
| #
335f313f |
| 26-Nov-2018 |
joerg <joerg@NetBSD.org> |
Now that lib/csu no longer uses the object handle, drop the magic and version field from the internal object. It is kept in the legacy version of the main object.
|
| #
4312beab |
| 17-Oct-2018 |
joerg <joerg@NetBSD.org> |
Move compatibility for pre-2.0 ELF binaries into separate file. Early ELF binaries defined dlopen and friends in crt0.o by using function pointers in the object handle passed from rtld. This contract
Move compatibility for pre-2.0 ELF binaries into separate file. Early ELF binaries defined dlopen and friends in crt0.o by using function pointers in the object handle passed from rtld. This contract wastes space when many shared objects are allocated and ties dynamic linker and rest of the system tightly together. Fake the entry points in a static object and restrict them to the platforms that had working ELF support at the time. Keep the magic and version field used by modern crt0.o for all architectures. The checks will be removed from crt0.o in a follow-up step.
show more ...
|
| #
f80c3669 |
| 03-Apr-2018 |
joerg <joerg@NetBSD.org> |
Rework ifunc support to address a number of short comings: - Move to a shared _rtld_call_ifunc for rel and rela architectures - Architectures using rel format must patch IRELATIVE non-PLT relocatio
Rework ifunc support to address a number of short comings: - Move to a shared _rtld_call_ifunc for rel and rela architectures - Architectures using rel format must patch IRELATIVE non-PLT relocations like RELATIVE in additition to the later ifunc handling - Consistently record the delta to the end of the relocation group for non-PLT IRELATIVE relocations
Hidden ifunc is now supported on all ifunc platforms, even when using -fno-plt. The combination of -fno-plt and relro is broken due to incorrect GNU ld output though.
show more ...
|
| #
64156cba |
| 09-Mar-2018 |
joerg <joerg@NetBSD.org> |
Like Sparc, PowerPC can use IRELATIVE relocations in non-PLT sections.
|
| #
610e531e |
| 12-Aug-2017 |
joerg <joerg@NetBSD.org> |
Add sparc/sparc64 support for irelative relocations.
|
| #
e78cfb8e |
| 10-Aug-2017 |
joerg <joerg@NetBSD.org> |
Add IRELATIVE support for ARM, X86 and PowerPC.
|
| #
e5678be8 |
| 11-Jul-2017 |
joerg <joerg@NetBSD.org> |
Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This functions are used for destructors of thread_local objects.
If a pending destructor exists, prevent unloading of shared objects. Intr
Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This functions are used for destructors of thread_local objects.
If a pending destructor exists, prevent unloading of shared objects. Introduce __dl_cxa_refcount interface for this purpose. When the last reference is gone and the object has been dlclose'd before, the unloading is finalized.
Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists on providing __cxa_thread_atexit as direct wrapper without further patching.
show more ...
|
| #
88b39733 |
| 09-Jul-2017 |
joerg <joerg@NetBSD.org> |
Drop comments about symbol exporting, the relevant code is gone.
|
| #
e45d4ba0 |
| 19-Jun-2017 |
joerg <joerg@NetBSD.org> |
Replace COMBREL with just-in-time check in _rtld_relocate_nonplt_objects.
The COMBREL logic predates thread-safety of the dynamic linker and breaks the use of shared locks for the common symbol look
Replace COMBREL with just-in-time check in _rtld_relocate_nonplt_objects.
The COMBREL logic predates thread-safety of the dynamic linker and breaks the use of shared locks for the common symbol lookup case. It is unlikely to provide any benefit for lazy binding or PLT lookups, so provide equivalent functionality in the non-PLT relocation handling loop by checking if the symbol used by the current relocation is the same as the one used during the last lookup. No inter-object cachine is done as it is also unlikely to be benefical.
Testing with Firefox startup on AMD64 shows a small performance gain by the new method.
show more ...
|
| #
d32757ce |
| 30-Nov-2016 |
christos <christos@NetBSD.org> |
Emulate the standard symbol search order in dlsym() i.e. resolve weak or not found symbols that are in the dynamic linker list of exported symbols from the dynamic linker itself.
|
| #
0e6265fc |
| 14-Jun-2016 |
christos <christos@NetBSD.org> |
Add support for GNU RELRO headers from Matthias Weckbecker.
|
| #
463829e4 |
| 19-Sep-2014 |
matt <matt@NetBSD.org> |
RISC-V support.
|
| #
94e1a899 |
| 27-Aug-2014 |
christos <christos@NetBSD.org> |
remove unused define
|