Home | History | Annotate | Download | only in ld.elf_so
History log of /src/libexec/ld.elf_so/rtld.h
RevisionDateAuthorComments
 1.150  02-May-2025  riastradh ld.elf_so: Narrow scope of -Wno-stack-protector.

Don't need it outside immediate _rtld_donelist_init callers.

PR lib/59388: ld.elf_so: -Wno-stack-protector applies too broadly
 1.149  02-May-2025  riastradh ld.elf_so: Implement RELR relocations.

The SHT_RELR-type .relr.dyn section, pointed to by the DT_RELR
dynamic tag, holds compressed R_*_RELATIVE-type relocations,
substantially reducing the disk space occupied by many programs.

This commit adds support in ld.elf_so for relocating dynamically
linked executables with RELR relocations.

Reference:

Rahul Chaudhry, `Re: Proposal for a new section type SHT_RELR',
generic-abi mailing list, 2018-02-07.

https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/Jnz1lgLJAgAJ
https://web.archive.org/web/20241213012330/https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/Jnz1lgLJAgAJ

Proposed on tech-userlevel:
https://mail-index.NetBSD.org/tech-userlevel/2025/04/27/msg014727.html

PR bin/59360: ld.elf_so(8): missing RELR support
 1.148  18-Apr-2025  riastradh ld.elf_so on alpha: Add support for secureplt.

ok thorpej

PR port-alpha/57511: ld.elf_so(1) does not support secure PLT for alpha
PR port-alpha/57717: Alpha linker generates LOAD segments (and
generates warnings about them)
 1.147  30-Jul-2023  riastradh ld.elf_so: Split hash functions into a separate file.

This way we can test them in isolation.

No functional change intended.
 1.146  04-Jun-2023  joerg 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.
 1.145  18-Apr-2023  christos 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.
 1.144  21-Jun-2022  skrll branches: 1.144.2;
Support ifunc on aarch64. The tests pass at least.
 1.143  21-Jun-2022  skrll Wrap long #if defined(...) || ... and sort. NFCI.
 1.142  04-Dec-2021  skrll 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(-)
: ----------------------------------------------------------------------
 1.141  21-Sep-2020  kamil 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.
 1.140  19-Apr-2020  joerg 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.
 1.139  16-Apr-2020  joerg 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.
 1.138  29-Feb-2020  kamil 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.
 1.137  29-Feb-2020  kamil 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.
 1.136  30-Dec-2018  christos branches: 1.136.2;
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.
 1.135  26-Nov-2018  joerg 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.
 1.134  17-Oct-2018  joerg 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.
 1.133  03-Apr-2018  joerg branches: 1.133.2;
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.
 1.132  09-Mar-2018  joerg Like Sparc, PowerPC can use IRELATIVE relocations in non-PLT sections.
 1.131  12-Aug-2017  joerg branches: 1.131.2;
Add sparc/sparc64 support for irelative relocations.
 1.130  10-Aug-2017  joerg Add IRELATIVE support for ARM, X86 and PowerPC.
 1.129  11-Jul-2017  joerg 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.
 1.128  09-Jul-2017  joerg Drop comments about symbol exporting, the relevant code is gone.
 1.127  19-Jun-2017  joerg 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.
 1.126  30-Nov-2016  christos branches: 1.126.6;
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.
 1.125  14-Jun-2016  christos branches: 1.125.2;
Add support for GNU RELRO headers from Matthias Weckbecker.
 1.124  19-Sep-2014  matt RISC-V support.
 1.123  27-Aug-2014  christos remove unused define
 1.122  26-Aug-2014  joerg Replace casts in the inline version of _rtld_call_function_void of
_rtld_call_function_addr with ifdef on RTLD_LOADER.
 1.121  26-Aug-2014  christos Introduce a cast to fix the build for Elf32 on _LP64.
 1.120  25-Aug-2014  joerg Add basic support for indirect functions. It allows providing a public
function symbol with an implementation choosen at run time.
Refactor calls to functions by address in ld.elf_so to create temporary
function descriptors on the stack, if the address is not leaked outside.

Limitations:
- no support for initialising static storage with function pointers
- no support for unnamed resolver functions

Inspired by FreeBSD's r228435 by kib@freebsd.org.
 1.119  23-Aug-2014  joerg Typo.
 1.118  10-Aug-2014  matt branches: 1.118.2;
Don't provide __gnu_Unwind_Find_exidx if __ARM_DWARF_EH__ is defined
 1.117  06-Mar-2014  matt More PPC64 changes.
Nothing to do for lazy bindings.
Record DT_PPC64_GLINK and make _rtld_bind return it.
When resolving a JMP_SLOT, copy the source function descriptor into the PLTGOT
 1.116  09-May-2013  christos convert to SIMPLEQ like the rest of the queues.
 1.115  06-May-2013  christos Fixed handling of DT_SONAME:

- add function to add name aliases for shared libraries loaded
XXX[1]: we don't add a name during load time, only when DT_SONAME
is present.
- search already loaded objects in load_by_name for an already
loaded object that matches our name and return it.
- add missing initialization and cleanup for obj->names
XXX[2]: should we make them SIMPLEQ?
- Add XXX in rtld.c about getting the name of an object.

NB: This makes the jdk work again without resorting to a hack of putting
the build path of libjvm.so into the run path (which is a security
problem).
XXX: Pullup-6?
 1.114  06-May-2013  skrll Trailing whitespace
 1.113  25-Apr-2013  matt Use __printflike and __dead instead of __attributes__
 1.112  25-Apr-2013  matt Only include unwind.h if _RTLD_SOURCE
 1.111  24-Apr-2013  matt Add support for PT_ARM_EXIDX and __gnu_Unwind_Find_exidx for libgcc's support
of the ARM EHABI.
 1.110  15-Aug-2012  matt branches: 1.110.2;
Add .init_array/.fini_array support (conditionalized on HAVE_INITFINI_ARRAY).
 1.109  13-Mar-2012  joerg Mark _rtld_debug_state as not to be inlined. Add an explicit instruction
barrier to prevent removal of calls to it.
 1.108  16-Feb-2012  joerg Add _dlauxinfo helper function to provide access to the ELF auxilary
vector. This can normally be found via __ps_strings, but libc is
initialised too early when linked dynamically and doesn't have access to
it yet, so provide an alternative mechanism via ld.elf_so.
Bump libc minor.
 1.107  02-Dec-2011  skrll branches: 1.107.4;
Restore backwards compatibility by removing unnecessary addition of
dlvsym to Obj_Entry.

Add some comments.
 1.106  25-Jun-2011  nonaka branches: 1.106.2;
PR/45015: ld.elf_so: support ELF symbol versioning
Applied latest patch.
 1.105  29-Mar-2011  joerg Block signals when using the exclusive lock.
 1.104  25-Mar-2011  joerg Add basic locking to ld.elf_so.
 1.103  12-Mar-2011  joerg Add TLS support for AMD64, i386 and SH3.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.102  10-Mar-2011  joerg Fix prototype for __tls_get_addr. Add a generic implementation of it
using __tls_get_addr. Update TLS notes.
 1.101  09-Mar-2011  joerg Add TLS support infrastructure. For dynamic binaries, ld.elf_so exports
_rtld_tls_allocate and _rtld_tls_free. libpthread uses this functions to
setup the thread private area of all new threads. ld.elf_so is
responsible for setting up the private area for the initial thread.
Similar functions are called from _libc_init for static binaries, using
dl_iterate_phdr to access the ELF Program Header.

Add test cases to exercise the different TLS storage models. Test cases
are compiled and installed on all platforms, but are skipped on
platforms not marked for TLS support.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.

It is inspired by the TLS support in FreeBSD by Doug Rabson and the
clean ups of the DragonFly port of the original FreeBSD modifications.
 1.100  25-Jan-2011  skrll Unbreak gdb by ensuring _rtld_debug_state is in the dynamic symbol table.

mmm 1 line diffs

mmm not breaking backwards compatibility for anything known/unknown or
public/private.
 1.99  16-Jan-2011  matt branches: 1.99.2;
Move powerpc gotptr to the end to preserve binary compatibility.
 1.98  16-Jan-2011  matt Add secure-plt support for powerpc to ld.elf_so. As part of this, we have to
stop calling into the GOT/_DYNAMIC since they are no longer executable.
 1.97  24-Dec-2010  skrll Add support for DF_1_BIND_NOW, DF_1_NODELETE and DF_1_NOOPEN marked
objects, and the RTLD_NODELETE and RTLD_NOLOAD flags to dlopen(3).

Mark libpthread as DF_1_NOOPEN and use it to test the functionality.

Somewhat taken from FreeBSD.

Fixes PR 42029.

OK from christos and joerg.
 1.96  05-Dec-2010  joerg Build ld.elf_so with -fvisibility=hidden. Exploit this for i386/x86_64
to simplify the assembler code.
 1.95  16-Oct-2010  skrll Implement dl_iterate_phdr.

Somewhat taken from FreeBSD. Manual page from OpenBSD.
 1.94  10-Oct-2010  christos restore binary compatibility for pre-2.0 binaries, requested by skrll and core.
 1.93  30-Sep-2010  skrll Introduce a new type Elf_Symindx for use in decoding the symbol hash table
section and allow this type to be overridden.

The ELF specification says it should always be uint32_t (Elf_Word), but
alpha decided to be different (not sure why). Define Elf_Symindx to be
uint64_t on alpha.

Alpha no longer uses non-standard definitions of Elf64_Sword and
Elf64_Word. Remove the ability to override these types.

Fixes ld.elf_so after Herculean effort from me and martin.
 1.92  06-Aug-2010  joerg Reduce header pollution for mdreloc.c. Make Obj_Entry argument of
_rtld_relocate_nonplt_objects non-const in preparation for TLS support.
 1.91  05-Apr-2010  joerg Use fast_remainder32 for the ELF hash. For the hot cache case, this
speeds up Firefox startup by over 2% on AMD64.
Limit hash table buckets to 32bit.
 1.90  18-Mar-2010  roy Use alloca(3) instead of local xmalloc for creating our DoneLists.
This allows threaded programs to use us a little better, PR lib/43005.
We need to disable SSP when using alloca.
 1.89  27-Feb-2010  roy Implement negative cache checks for symbol lookups.
Uses the Donelist idea from FreeBSD.
 1.88  17-Jan-2010  skrll Restore backwards compatibility for binaries referencing the main
Obj_Entry.
 1.87  16-Jan-2010  skrll Remove cargo cult dlinfo entry point.
 1.86  15-Jan-2010  skrll Put the dlopen,and friends entry points back.

They're needed by pre-2.0 binaries. Backward compatibiliity for these
was broken by another commit recently which I'll fix shortly.
 1.85  14-Jan-2010  skrll Remove the entry points for dlopen() and friends. They haven't been used
since Aug 2003.
 1.84  13-Jan-2010  christos PR/39240: Satoshi Suetake: Don't fail when attempting to resolve weak symbols
when we are doing immediate binding, leave them alone and they will be dealt
with later during lazy binding. From skrll@
 1.83  10-Jan-2010  skrll Reset the COMBRELOC cache Obj_Entry if it was freed.

Fixes PR 41482. Done slightly differently to the patch in the PR.
 1.82  17-Nov-2009  skrll Make _rtld_pagesz of type size_t.

Fixes round_down for alpha which made ldd(1) break.
 1.81  24-Sep-2009  pooka Add Solarisa-like dlinfo() interface to the ELF dynamic linker.
Implement RTLD_DI_LINKMAP which returns a pointer to the linkmap
chain at the given object. Other Solaris queries are currently
unimplemented.
 1.80  19-May-2009  christos warns=4
 1.79  04-Oct-2008  skrll branches: 1.79.4; 1.79.8; 1.79.10;
lib/39649: dlsym(3) does not follow dependencies

Pull across code from FreeBSD to do a search of the passed object and it's
NEEDED objects (dependencies).

Reviewed by gimpy.
 1.78  03-Jun-2008  ad Don't bother unmapping the ELF header unless it overlaps the first load
section.
 1.77  14-Jan-2008  yamt branches: 1.77.4; 1.77.6;
tabify
 1.76  07-Dec-2007  ad rtld changes for PR bin/37347:

- Apply patch from J.T. Conklin to execute .init/.fini functions in order.
- Support DF_1_INITFIRST and mark libc with DF_1_INITFIRST. Shared libs
should be recording a dependency on libc, but it's too late to do that.

Ok christos@.
 1.75  02-Sep-2007  joerg Don't define bool, false and true. Use stdbool.h.
 1.74  18-May-2007  christos branches: 1.74.4;
Support Solaris-like $ORIGIN etc. expansions in paths.
 1.73  22-May-2006  drochner branches: 1.73.4; 1.73.6;
sprinkle some __noreturn__ attributes, saves gcc4 warnings elsewhere
 1.72  21-Mar-2006  christos Coverity CID 2749: Fix another double free. Instead of removing that last
free() call, change the allocation policy to leave the responsibility for
allocation/freeing the pathname to _rtld_map_object(), instead of having
the caller allocate it and _rtld_map_object() free it. This simplifies the
code a lot and it is more efficient.
 1.71  05-Jul-2004  cube branches: 1.71.2;
Make ld.elf_so use the new sysctl API. That allows the user to give any
sysctl variable name in /etc/ld.so.conf. It also makes the ld.elf_so
binary slightly smaller (at least on i386), and has no impact on
performance.

Fixes PR 26100.
 1.70  12-Aug-2003  skrll Resolve dlsym(3) and friends directly so that dlsym(RTLD_NEXT,...) works.

Previously dlsym resolved to the version in crt0.o or libc which would
mean that the caller's shared object couldn't be determined correctly
using __builtin_return_address(0).

Mainly from FreeBSD, but adapted by me. Benefits of this solutions are:

- backward comptibility maintained
- existing broken binaries are fixed with a new ld.elf_so
- __mainprog_obj can be removed from crt0.o
- we do the same thing as FreeBSD

Fixes PR 22067.

OKed by Jason and Christos.
 1.69  24-Jul-2003  skrll ANSIfy and de-__P().
 1.68  30-May-2003  christos Add RTLD_FIRST, RTLD_NEXT, RTLD_DEFAULT, from FreeBSD
 1.67  24-Apr-2003  mycroft Back out previous change for now -- it needs more work.
 1.66  23-Apr-2003  mycroft Attempt to give dlsym() the same symbol-searching semantics as _rtld_bind().
Tested in a handful of cases.
Reviewed by: a dead silence
 1.65  05-Dec-2002  junyoung A bit speedup: in _rtld_load_object(), save the number of calls to
strcmp() by performing path name length comparison first. In the test
with Mozilla, the number was reduced to 1068 from 7182 (yes, we saved
6114 strcmp()!).
 1.64  14-Nov-2002  nathanw Remove "extern const chat *_rtld_error_message;". There is no such
variable, and never has been.
 1.63  04-Oct-2002  mycroft Rearrange _rtld_map_object() a little, so that we don't have to have the first
page of the object double-mapped. Not that it matters much, but someone was
whinging about it.
While I'm at it, nuke obj->phdr and obj->phsize; they're unused.
 1.62  03-Oct-2002  mycroft As seen on tech-userlevel...

There are several optimizations here:

1) Objects on _rtld_list_main do not participate in the DAG structures
at all. This is okay because all symbols must be resolvable at
link/load time, and _rtld_list_main is always searched first, so
any references from those objects must necessarily be resolved to
other objects on _rtld_list_main.

(Making this work completely required setting obj->main a bit
earlier; hence the RTLD_MAIN hack.)

2) Objects on _rtld_list_main are not put on _rtld_list_global,
preventing an extra search.

3) A bit is used to keep track of whether an object is on
_rtld_list_global, so we don't have to do a silly linear search.

4) A small attempt is made to prevent objects being put on the DAG
lists multiple times (using a silly linear search).

The sum of this appears to be a ~10% (.3s) reduction in Mozilla's
startup time on my 800MHz box.

Also, make sure _rtld_objmain->path is always set, just to make the
debug output nicer.
 1.61  03-Oct-2002  mycroft Do not put objects on _rtld_list_main on any DAG member list -- any symbol we
will have already been found during the _rtld_list_main walk, so there's no
point in doing it again.
 1.60  26-Sep-2002  mycroft Remove the `self' args to _rtld_relocate_objects() and
_rtld_relocate_nonplt_objects().
 1.59  25-Sep-2002  mycroft Push the _rtld_bind() interface into MD code -- it's just a trivial wrapper
anyway.
 1.58  25-Sep-2002  mycroft #if defined -> #ifdef
 1.57  24-Sep-2002  mycroft Put back the `in_plt' nonsense for now.
It turns out there is some deep-seated wackiness WRT function pointer
comparisons...
 1.56  24-Sep-2002  mycroft Remove the SVR4_LIBDIR madness.
 1.55  24-Sep-2002  junyoung Nuke PAGESIZE.
 1.54  24-Sep-2002  mycroft Use/require AT_PAGESZ on all platforms. (The kernel has exported it for ~3
years now.) Use _rtld_pagesz instead of getpagesize() to determine the page
size in our local malloc(). Saves a system call.

Also, since we're now relocated early, we don't need to be careful to avoid
globals, so most of the VARPSZ hacks are eliminated.
 1.53  23-Sep-2002  mycroft Several small changes that shave 7-8% off the simple-exec-loop test:

* Rename _rtld_find_library() to _rtld_load_library(). It now calls
_rtld_load_object() if necessary to actually load the object, rather
than having the caller do it. To do this, it also takes the `mode'
argument that gets passed to _rtld_load_object().

* On a related note, remove _rtld_check_library(), and instead call
_rtld_load_object() to instead try actually loading the object. We
save two extra namei's and a bunch of redundant work (almost
literally the same code) this way.

* In _rtld_map_object(), mmap(2) the first page read-only, rather than
read(2)ing it.

* In _rtld_symlook_obj(), compare the *second* character of the symbol
name before calling strcmp(). (This first character is too
frequently `_', and turns out to not be helpful, in libc.)

* Also in _rtld_symlook_obj(), remove the bogus STT_FUNC special case
-- this also allows removing the `in_plt' argument to
_rtld_symlook_list() and _rtld_symlook_obj().

Also:

* In _rtld_obj_from_addr(), rather than trying to look up `_end' in
the each object, instead use obj->mapsize as the upper bound.
 1.52  19-Sep-2002  junyoung Cosmetic changes.
 1.51  18-Sep-2002  junyoung _rtld_setup_pltgot() belongs to reloc.c.
 1.50  17-Sep-2002  junyoung Make immediate binding work again by actually implementing
_rtld_relocate_plt_objects(). Note that this is for i386 only;
any efforts to make it work on other platforms are left to
those who are using them...
 1.49  13-Sep-2002  mycroft Remove a dumb #ifdef -- if VARPSZ is not defined on sparc, the build will
bomb anyway.
 1.48  12-Sep-2002  mycroft Nuke -DRTLD_RELOCATE_SELF and `dodebug' from orbit.
 1.47  12-Sep-2002  mycroft Move another declaration that doesn't belong in MI source.
 1.46  12-Sep-2002  mycroft _rtld_bind_start() is not used in MI code, so declare it in the MD code.
 1.45  06-Sep-2002  mycroft Pass down an additional flag to _rtld_relocate_nonplt_objects() which
indicates whether we're relocating ld.elf_so itself. Use this in some places
rather than hackish tests on `dodebug'. (The Alpha and HPPA `dodebug' tests
were actually noops, because RTLD_RELOCATE_SELF is not set, and therefore
dodebug is always true.)
 1.44  06-Sep-2002  mycroft Introduce a new flag, `isdynamic', which is used to remember whether the
executable was of type ET_DYN. Use this instead of `mainprog' to determine
whether we need to do base-relative fixups of the PLT. (This allows loading
non-relocatable objects, should we desire to do that at some point...)
 1.43  06-Sep-2002  mycroft More const poisoning. Now the entire _rtld_bind() path useds a const Obj_Entry.
 1.42  06-Sep-2002  mycroft Re-poison a lot of consts, now that the mark shite is gone.
 1.41  06-Sep-2002  mycroft Split _rtld_relocate_plt_object() into two MD functions:
* _rtld_relocate_plt_lazy() fixes up all the relocs pointing to the PLT. (On
most platforms it just does a simple base-relative fixup; on SPARC it does
nothing.)
* _rtld_relocate_plt_object() does immediate binding for a PLT entry.
The basic gist is that this saves a bit of time on SPARC (where the iteration
through the pltrela table was gratuitous), and a little less time on all other
platforms. A whole lot of #ifdef'ed crap is moved out of reloc.c, too.

NOT tested on: hppa sh x86_64
 1.40  05-Sep-2002  mycroft Remove all of the `mark' code. This is responsible for the `undefined PLT
symbol' errors, probably because the increment gets interrupted occasionally by
a signal. In general, _rtld_bind() should not modify ANY internal state.
 1.39  05-Sep-2002  mycroft A few things:
* Pass a symbol number to _rtld_find_symdef(), not a r_info.
* Don't try to do a symbol lookup when we find an unsupported relocation;
instead get the symbol name from the referencing object's strtab.
* Add preliminary support for `-z combreloc'-style startup optimization on
i386, `#ifdef COMBRELOC'.
 1.38  05-Sep-2002  mycroft Rename _rtld_relocate_nonplt_object() to _rtld_relocate_nonplt_objects(),
and push the outer loop into it. This actually shaves a couple % off startup
time at least on PCs.
 1.37  05-Sep-2002  junyoung Remove unused arguments of _rtld_find_symdef().
 1.36  05-Sep-2002  mycroft Remove unused prototypes (including one for a non-existant function!).
 1.35  05-Sep-2002  mycroft Make _rtld_setup_pltgot() a consistent interface on all platforms.
 1.34  10-Jul-2002  fredette Add support for dynamic linking on HP PA-RISC.
 1.33  28-Dec-2001  lukem branches: 1.33.2;
- Allow RTLD_DEFAULT_LIBRARY_PATH to be overridden.
- If ${SHLIBDIR} != ${LIBDIR}, then set RTLD_DEFAULT_LIBRARY_PATH to
${SHLIBDIR}:${LIBDIR}
 1.32  14-Dec-2001  thorpej Add code to peek into the PLT and determine which PLT entry format
is being used.
 1.31  13-Dec-2001  thorpej Supply two lazy binding routines for Alpha: one that works with the
old PLT format, and one that works with the new.

XXX We currently always use _rtld_bind_start_old() in
_rtld_setup_alpha_pltgot(). We need to add code to peek
into one of the PLT entries to see which format it's in
and pick the correct binding routine.
 1.30  25-Apr-2001  kleink Sync with <sys/exec_elf.h> rev. 1.45: ElfNN_RelA -> ElfNN_Rela.
 1.29  10-Nov-2000  mycroft When dlopen()ing with RTLD_GLOBAL, also make dependent libraries RTLD_GLOBAL.
 1.28  10-Oct-2000  is Format string cleanups by sommerfeld.
 1.27  26-Jul-2000  mycroft Catch up with type changes. Also:
* Apply DT_PLTRELSZ to (one of) pltrel or pltrela *after* we've finished
parsing the headers, so we know which one.
* Fix sparc64 bogons. (It works now!)
 1.26  06-Jul-2000  christos fix non-portable bit-fields
 1.25  15-Apr-2000  erh branches: 1.25.4;
Cause ld.elf_so to find the symbols for __progname and environ and set them. If we wait until crt0 gets around to doing it it's too late for any library init functions.
 1.24  08-Feb-2000  scottb change first argument of dladdr to const.
 1.23  07-Feb-2000  scottb add hooks to support the dladdr function.
 1.22  15-Dec-1999  christos Do what the people want. Support full sysctl names.
 1.21  13-Dec-1999  christos Enable parsing and mapping of hardware dependent libraries in ld.so.conf
To be documented in the man page.
 1.20  05-Dec-1999  fredb More CL* fallout.
 1.19  10-Nov-1999  thorpej Name consistencty nit: curmark -> _rtld_curmark
 1.18  07-Nov-1999  mycroft More fallout.
 1.17  07-Nov-1999  mycroft Changes from msaitoh to fix local/global symbol confusion, and to fix weak
symbol support -- updated by me for elf.h changes.
 1.16  19-Aug-1999  christos branches: 1.16.4;
enable /etc/ld.so.conf processing
[reviewed by thorpej]
 1.15  01-Aug-1999  kleink Rearrange the shared library search path precedences to LD_LIBRARY_PATH >
runpath > built-in default; this is the behaviour of the SVR4 shared loader,
and gives users the opportunity to override the runpath. (Addresses a report
on current-users by John Kohl.)
 1.14  05-Jul-1999  thorpej Protect certain definitions from view by crt0, by wrapping them in
#ifdef _RTLD_SOURCE.

Should fix the "variable page size" build error of crt0 on the SPARC.
 1.13  22-Jun-1999  christos We need to compile with -DVARPSZ, because the sparc has a variable page
size depending on arch. Make it an error to compile without it. This
caused -lposix linked programs to fail.
 1.12  16-Jun-1999  kleink Turn bool, true and false into an enumeration and enumeration constants to
avoid integer promotion warnings.
 1.11  31-May-1999  kleink Implement LD_PRELOAD support.
 1.10  18-Apr-1999  ws Add code to use the kernel provided page size.
Enable this on the powerpc only for now.
 1.9  19-Mar-1999  kleink branches: 1.9.2;
Remove /usr/local/lib from RTLD_DEFAULT_LIBRARY_PATH; c.f. PR bin/7146.
 1.8  01-Mar-1999  christos KNF
 1.7  24-Feb-1999  christos Cleanup global variable access so rtld can be self relocating. Also KNF
reloc.c and move md sparc parts to arch/sparc/mdreloc.c
Now we don't need to load at address 0 on the i386 and the mips should be
trivial to fix.
 1.6  24-Nov-1998  tsubai Add powerpc support.
 1.5  01-Jul-1998  tv Allow PAGESIZE to be set via a -D option to cc (CLBYTES not a constant on
sparc; it is defined in terms of the kernel variable "nbpg")
 1.4  25-Mar-1998  mhitch Add support for mips.
 1.3  14-Feb-1997  cgd branches: 1.3.2;
don't include members of Struct_Obj_Entry conditionally.
 1.2  17-Dec-1996  cgd remove /usr/localelf/lib from default library path
 1.1  16-Dec-1996  cgd First cut at an ELF shared loader. Originally from John Polstra's FreeBSD elf
kit, then hacked on by Matt Thomas <matt@3am-software.com>, then by me (to
make it work with new versions of the toolchain, etc.). This runs, but it's
in serious need of cleaning and/or a fair bit of reworking. See the README
file for more information, and a list of things to do.
 1.3.2.1  08-May-1998  mycroft Sync with trunk, per request of mycroft.
 1.9.2.2  10-Oct-2000  he Pull up revision 1.28 (requested by is):
Format string cleanup.
 1.9.2.1  23-Jun-1999  perry pullup 1.10->1.11 (klienk): LD_PRELOAD support
 1.16.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.25.4.4  09-Dec-2001  he Pull up revisions 1.26,1.29 (requested by skrll):
Add init/fini section support in crtbegin and crtend, and introduce
support for DWARF2 exception handling. Fixes PR#12865, PR#13488,
PR#13489, and PR#13491. Also fix ld.elf_so to deal appropriately.
 1.25.4.3  01-May-2001  he Pull up revision 1.30 (requested by kleink):
Rename ElfNN_RelA to ElfNN_Rela, which is what SVR4 ABIs and the
rest of the world uses. Fixes PR#12274.
 1.25.4.2  17-Oct-2000  tv Pullup libexec string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.25.4.1  26-Jul-2000  mycroft Approved by thorpej:
Add support for sparc64, including MD code and variable page size support.
Modify some variable types to insure they are the correct width on sparc64.

basesrc/libexec/ld.elf_so/arch/sparc64/Makefile.inc 0 -> 1.1
basesrc/libexec/ld.elf_so/arch/sparc64/mdreloc.c 0 -> 1.3
basesrc/libexec/ld.elf_so/arch/sparc64/rtld_start.S 0 -> 1.2
basesrc/libexec/ld.elf_so/headers.c 1.6 -> 1.8
basesrc/libexec/ld.elf_so/reloc.c 1.26 -> 1.27
basesrc/libexec/ld.elf_so/reloc.c 1.29 -> 1.31
basesrc/libexec/ld.elf_so/rtld.c 1.34 -> 1.35
basesrc/libexec/ld.elf_so/rtld.c 1.36 -> 1.40
basesrc/libexec/ld.elf_so/rtld.h 1.26 -> 1.27
basesrc/libexec/ld.elf_so/symbol.c 1.7 -> 1.9
 1.33.2.2  28-May-2004  tron Apply patch (request by skrll in ticket #1702):
Bring "ld.elf_so" (mostly) in sync with NetBSD-current:
- MI and MD (e.g. under NetBSD-alpha) performance improvements
- RTLD_SELF, RTLD_NEXT, RTLD_DEFAULT support
- much better structured code
- closes PR bin/25464
 1.33.2.1  05-Sep-2003  tron Pull up revision 1.40 (requested by dmcmahill in ticket #1395):
Remove all of the `mark' code. This is responsible for the `undefined
PLT
symbol' errors, probably because the increment gets interrupted
occasionally by
a signal. In general, _rtld_bind() should not modify ANY internal
state.
 1.71.2.1  08-Oct-2008  bouyer Pull up following revision(s) (requested by jmcneill in ticket #1973):
libexec/ld.elf_so/symbol.c: revision 1.47
libexec/ld.elf_so/rtld.h: revision 1.79
libexec/ld.elf_so/rtld.c: revision 1.122
lib/39649: dlsym(3) does not follow dependencies
Pull across code from FreeBSD to do a search of the passed object and it's
NEEDED objects (dependencies).
Reviewed by gimpy.
 1.73.6.1  30-Sep-2007  wrstuden Catch up on netbsd-4 as of a few days ago.
 1.73.4.2  31-Oct-2008  snj Pull up following revision(s) (requested by jmcneill in ticket #1211):
libexec/ld.elf_so/symbol.c: revision 1.47
libexec/ld.elf_so/rtld.h: revision 1.79
libexec/ld.elf_so/rtld.c: revision 1.122
lib/39649: dlsym(3) does not follow dependencies
Pull across code from FreeBSD to do a search of the passed object and its
NEEDED objects (dependencies).
 1.73.4.1  27-Sep-2007  xtraeme Pull up following revision(s) (requested by joerg in ticket #889):
libexec/ld.elf_so/rtld.h: revision 1.75

Don't define bool, false and true. Use stdbool.h.
 1.74.4.3  23-Mar-2008  matt sync with HEAD
 1.74.4.2  09-Jan-2008  matt sync with HEAD
 1.74.4.1  06-Nov-2007  matt sync with HEAD
 1.77.6.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.77.4.1  17-Jun-2008  yamt sync with head.
 1.79.10.1  21-Apr-2010  matt sync to netbsd-5
 1.79.8.3  23-Jan-2010  bouyer Pull up following revision(s) (requested by skrll in ticket #1249):
libexec/ld.elf_so/rtld.h: revision 1.88
Restore backwards compatibility for binaries referencing the main
Obj_Entry.
 1.79.8.2  23-Jan-2010  bouyer Back out ticket 1249 for now, it may not be needed on netbsd-5-0.
 1.79.8.1  23-Jan-2010  bouyer Pull up following revision(s) (requested by skrll in ticket #1249):
libexec/ld.elf_so/rtld.h: revisions 1.87, 1.88
libexec/ld.elf_so/reloc.c: revision 1.101
Restore backwards compatibility for binaries referencing the main
Obj_Entry.
 1.79.4.4  17-Mar-2012  bouyer Pull up following revision(s) via patch (requested by skrll in ticket #1724):
rescue/list.ldd: revision 1.4
lib/libc/dlfcn/dlfcn_elf.c: revision 1.7
libexec/ld.elf_so/arch/mips/mips_reloc.c: revision 1.57
distrib/sets/lists/comp/mi: revision 1.1512
share/man/man3/Makefile: revision 1.56
libexec/ld.elf_so/arch/mips/mips_reloc.c: revision 1.58
usr.bin/ldd/ldd.c: revision 1.15
libexec/ld.elf_so/rtld.h: revision 1.84
share/man/man3/dl_iterate_phdr.3: revision 1.1
libexec/ld.elf_so/rtld.c: revision 1.129
libexec/ld.elf_so/arch/powerpc/ppc_reloc.c: revision 1.44
libexec/ld.elf_so/rtld.h: revision 1.89
libexec/ld.elf_so/arch/x86_64/mdreloc.c: revision 1.36
libexec/ld.elf_so/map_object.c: revision 1.41
libexec/ld.elf_so/arch/x86_64/mdreloc.c: revision 1.37
libexec/ld.elf_so/arch/sparc64/mdreloc.c: revision 1.46
include/link_elf.h: revision 1.10
libexec/ld.elf_so/arch/i386/mdreloc.c: revision 1.29
libexec/ld.elf_so/arch/vax/mdreloc.c: revision 1.26
libexec/ld.elf_so/arch/alpha/alpha_reloc.c: revision 1.34
libexec/ld.elf_so/arch/hppa/hppa_reloc.c: revision 1.31
libexec/ld.elf_so/arch/alpha/alpha_reloc.c: revision 1.35
libexec/ld.elf_so/Makefile: revision 1.94
libexec/ld.elf_so/arch/hppa/hppa_reloc.c: revision 1.32
libexec/ld.elf_so/Makefile: revision 1.95
libexec/ld.elf_so/arch/arm/mdreloc.c: revision 1.31
libexec/ld.elf_so/Makefile: revision 1.96
libexec/ld.elf_so/arch/arm/mdreloc.c: revision 1.32
libexec/ld.elf_so/reloc.c: revision 1.98
libexec/ld.elf_so/arch/arm/mdreloc.c: revision 1.33
sys/sys/exec_elf.h: revision 1.106
libexec/ld.elf_so/rtld.c: revision 1.130
libexec/ld.elf_so/load.c: revision 1.37
libexec/ld.elf_so/rtld.c: revision 1.131
libexec/ld.elf_so/load.c: revision 1.38
libexec/ld.elf_so/rtld.h: revision 1.90
libexec/ld.elf_so/headers.c: revision 1.36
libexec/ld.elf_so/rtld.h: revision 1.95
libexec/ld.elf_so/arch/i386/mdreloc.c: revision 1.30
libexec/ld.elf_so/arch/m68k/mdreloc.c: revision 1.25
libexec/ld.elf_so/symbol.c: revision 1.50
libexec/ld.elf_so/symbol.c: revision 1.51
libexec/ld.elf_so/arch/sparc/mdreloc.c: revision 1.43
libexec/ld.elf_so/symbol.c: revision 1.52
libexec/ld.elf_so/arch/sh3/mdreloc.c: revision 1.27
libexec/ld.elf_so/symbol.c: revision 1.54
PR/39240: Satoshi Suetake: Don't fail when attempting to resolve weak symbols
when we are doing immediate binding, leave them alone and they will be dealt
with later during lazy binding. From skrll@
Implement negative cache checks for symbol lookups.
Uses the Donelist idea from FreeBSD.
Use alloca(3) instead of local xmalloc for creating our DoneLists.
This allows threaded programs to use us a little better, PR lib/43005.
Implement dl_iterate_phdr.
Somewhat taken from FreeBSD. Manual page from OpenBSD.
 1.79.4.3  30-Jan-2010  snj Pull up following revision(s) (requested by skrll in ticket #1266):
libexec/ld.elf_so/map_object.c: revision 1.39
libexec/ld.elf_so/rtld.h: revision 1.83
libexec/ld.elf_so/symbol.c: revision 1.49
Reset the COMBRELOC cache Obj_Entry if it was freed.
Fixes PR 41482. Done slightly differently to the patch in the PR.
 1.79.4.2  23-Jan-2010  bouyer Pull up following revision(s) (requested by skrll in ticket #1249):
libexec/ld.elf_so/rtld.h: revisions 1.87, 1.88
libexec/ld.elf_so/reloc.c: revision 1.101
Restore backwards compatibility for binaries referencing the main
Obj_Entry.
 1.79.4.1  14-Oct-2009  sborrill Pull up the following revisions(s) (requested by pooka in ticket #1088):
include/dlfcn.h: revision 1.20
lib/libc/dlfcn/dlfcn_elf.c: revision 1.6
libexec/ld.elf_so/reloc.c: revision 1.97
libexec/ld.elf_so/rtld.c: revision 1.125
libexec/ld.elf_so/rtld.h: revision 1.81
libexec/ld.elf_so/symbol.c: revision 1.48

Add Solarisa-like dlinfo() interface to the ELF dynamic linker.
Implement RTLD_DI_LINKMAP which returns a pointer to the linkmap
chain at the given object. Other Solaris queries are currently
unimplemented.
 1.99.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.106.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.106.2.2  30-Oct-2012  yamt sync with head
 1.106.2.1  17-Apr-2012  yamt sync with head
 1.107.4.1  22-Jan-2013  matt Pullup from HEAD:
Add .init_array/.fini_array support (conditionalized on HAVE_INITFINI_ARRAY).
 1.110.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.110.2.1  23-Jun-2013  tls resync from head
 1.118.2.1  06-Mar-2016  martin Catch up to -current, via patch, requested by christos in ticket #1126:
 1.125.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.126.6.3  29-Aug-2017  bouyer Pull up following revision(s) (requested by joerg in ticket #127):
tests/libexec/ld.elf_so/h_thread_local_dtor.c: revision 1.1
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h: revision 1.17
lib/libc/stdlib/atexit.h: file removal
lib/libc/stdlib/exit.c: revision 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h: revision 1.8
lib/libc/stdlib/exit.c: revision 1.17
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.178
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h: revision 1.21
distrib/sets/lists/debug/shl.mi: revision 1.179
distrib/sets/lists/debug/mi: revision 1.219
lib/libpthread/pthread.c: revision 1.150
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h: revision 1.14
libexec/ld.elf_so/symbols.map: revision 1.2
include/dlfcn.h: revision 1.25
external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h: revision 1.23
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h: revision 1.18
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h: revision 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h: revision 1.17
distrib/sets/lists/tests/mi: revision 1.755
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h: revision 1.20
external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h: revision 1.20
lib/libc/dlfcn/dlfcn_elf.c: revision 1.14
tests/libexec/ld.elf_so/t_thread_local_dtor.sh: revision 1.1
tests/lib/libpthread/t_thread_local_dtor.sh: revision 1.1
lib/libc/stdlib/Makefile.inc: revision 1.93
lib/libc/include/atexit.h: revision 1.1
lib/libc/include/atexit.h: revision 1.2
external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.180
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h: revision 1.14
lib/libc/stdlib/cxa_thread_atexit.c: revision 1.1
tests/libexec/ld.elf_so/helper_dso3/h_helper_dso3.cpp: revision 1.1
tests/libexec/ld.elf_so/helper_dso3/Makefile: revision 1.1
external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h: revision 1.5
libexec/ld.elf_so/rtld.c: revision 1.185
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h: revision 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h: revision 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h: revision 1.12
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h: revision 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h: revision 1.19
tests/libexec/ld.elf_so/Makefile: revision 1.9
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h: revision 1.20
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h: revision 1.14
tests/lib/libpthread/h_thread_local_dtor.cpp: revision 1.1
distrib/sets/lists/tests/shl.mi: revision 1.11
tests/lib/libpthread/Makefile: revision 1.13
libexec/ld.elf_so/rtld.h: revision 1.129
external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h: revision 1.6
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.
Fix filename of new debug file
Add misising DEBUGLIB file
Avoid common declaration.
Drop TLS variant checks, emutls is enough for VAX and Sun2.
 1.126.6.2  24-Jul-2017  snj Pull up following revision(s) (requested by joerg in ticket #126):
libexec/ld.elf_so/rtld.h: revision 1.128
Drop comments about symbol exporting, the relevant code is gone.
 1.126.6.1  04-Jul-2017  martin Pull up following revision(s) (requested by joerg in ticket #64):
libexec/ld.elf_so/arch/arm/mdreloc.c: revision 1.40
libexec/ld.elf_so/arch/arm/mdreloc.c: revision 1.41
libexec/ld.elf_so/arch/hppa/hppa_reloc.c: revision 1.44
libexec/ld.elf_so/arch/riscv/mdreloc.c: revision 1.3
libexec/ld.elf_so/arch/aarch64/mdreloc.c: revision 1.3
libexec/ld.elf_so/arch/sparc64/mdreloc.c: revision 1.60
libexec/ld.elf_so/arch/m68k/mdreloc.c: revision 1.32
libexec/ld.elf_so/arch/sparc64/mdreloc.c: revision 1.61
libexec/ld.elf_so/arch/or1k/mdreloc.c: revision 1.2
libexec/ld.elf_so/arch/sparc/mdreloc.c: revision 1.50
libexec/ld.elf_so/arch/sh3/mdreloc.c: revision 1.33
libexec/ld.elf_so/arch/sh3/mdreloc.c: revision 1.34
libexec/ld.elf_so/arch/arm/mdreloc.c: revision 1.39
libexec/ld.elf_so/symbol.c: revision 1.68
libexec/ld.elf_so/arch/mips/mips_reloc.c: revision 1.66
libexec/ld.elf_so/arch/mips/mips_reloc.c: revision 1.67
libexec/ld.elf_so/arch/mips/mips_reloc.c: revision 1.68
libexec/ld.elf_so/arch/x86_64/mdreloc.c: revision 1.42
libexec/ld.elf_so/arch/powerpc/ppc_reloc.c: revision 1.54
libexec/ld.elf_so/Makefile: revision 1.137
libexec/ld.elf_so/arch/vax/mdreloc.c: revision 1.32
libexec/ld.elf_so/rtld.h: revision 1.127
libexec/ld.elf_so/arch/vax/mdreloc.c: revision 1.33
libexec/ld.elf_so/arch/i386/mdreloc.c: revision 1.38
libexec/ld.elf_so/arch/alpha/alpha_reloc.c: revision 1.42
libexec/ld.elf_so/map_object.c: revision 1.58
libexec/ld.elf_so/arch/sparc/mdreloc.c: revision 1.49
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.
Drop symbol number from default branch diagnostic, it isn't set at this
point and most likely not valid either.
Expand symnum, GCC's uninitialized used tracking is too imprecise.
Fix C&P bug. Deal with more MIPS hacks overriding def.
Add last_symnum, move up def and defobj.
Add back symnum, fix debug print.
Replace last use of r_type.
Fix indentation.
Fix indentation.
 1.131.2.5  18-Jan-2019  pgoyette Synch with HEAD
 1.131.2.4  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.131.2.3  20-Oct-2018  pgoyette Sync with head
 1.131.2.2  07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.131.2.1  15-Mar-2018  pgoyette Synch with HEAD
 1.133.2.3  21-Apr-2020  martin Sync with HEAD
 1.133.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.133.2.1  10-Jun-2019  christos Sync with HEAD
 1.136.2.2  04-Aug-2023  martin Pull up following revision(s), all via patch,
(requested by riastradh in ticket #1699):

distrib/sets/lists/tests/shl.mi: revision 1.14
distrib/sets/lists/tests/shl.mi: revision 1.15
distrib/sets/lists/tests/shl.mi: revision 1.16
tests/libexec/ld.elf_so/helper_def_static/h_def_static.c: revision 1.1
tests/libexec/ld.elf_so/helper_def_dynamic/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_def_dynamic/Makefile: revision 1.2
tests/libexec/ld.elf_so/helper_onlyuse_static/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_onlyuse_static/Makefile: revision 1.2
libexec/ld.elf_so/arch/mips/mips_reloc.c: revision 1.75
distrib/sets/lists/tests/mi: revision 1.1265
libexec/ld.elf_so/arch/sh3/mdreloc.c: revision 1.36
libexec/ld.elf_so/rtld.c: revision 1.214
tests/libexec/ld.elf_so/helper_onlydef_static/Makefile: revision 1.1
distrib/sets/lists/debug/mi: revision 1.400
tests/libexec/ld.elf_so/helper_onlydef_static/Makefile: revision 1.2
distrib/sets/lists/debug/mi: revision 1.401
distrib/sets/lists/debug/mi: revision 1.402
tests/libexec/ld.elf_so/helper_dso2/Makefile: revision 1.2
distrib/sets/lists/debug/mi: revision 1.403
tests/libexec/ld.elf_so/helper_symver_dso0/Makefile: revision 1.2
libexec/ld.elf_so/arch/x86_64/mdreloc.c: revision 1.48
distrib/sets/lists/debug/mi: revision 1.406
tests/libexec/ld.elf_so/helper_use_dynamic/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_use_dynamic/Makefile: revision 1.2
tests/libexec/ld.elf_so/helper_ifunc_dso/Makefile: revision 1.2
libexec/ld.elf_so/arch/sparc64/mdreloc.c: revision 1.70
libexec/ld.elf_so/arch/aarch64/mdreloc.c: revision 1.18
tests/libexec/ld.elf_so/helper_abuse_dynamic/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_abuse_dynamic/Makefile: revision 1.2
tests/libexec/ld.elf_so/Makefile: revision 1.13
libexec/ld.elf_so/arch/arm/mdreloc.c: revision 1.46
libexec/ld.elf_so/rtld.h: revision 1.146
tests/libexec/ld.elf_so/Makefile: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.306
tests/libexec/ld.elf_so/Makefile: revision 1.15
tests/libexec/ld.elf_so/helper_abuse_static/Makefile: revision 1.1
distrib/sets/lists/debug/shl.mi: revision 1.307
tests/libexec/ld.elf_so/Makefile: revision 1.16
tests/libexec/ld.elf_so/helper_abuse_static/Makefile: revision 1.2
distrib/sets/lists/debug/shl.mi: revision 1.308
tests/libexec/ld.elf_so/Makefile: revision 1.17
distrib/sets/lists/debug/shl.mi: revision 1.309
tests/libexec/ld.elf_so/Makefile: revision 1.18
tests/libexec/ld.elf_so/Makefile: revision 1.19
libexec/ld.elf_so/tls.c: revision 1.16
libexec/ld.elf_so/tls.c: revision 1.17
libexec/ld.elf_so/tls.c: revision 1.18
libexec/ld.elf_so/tls.c: revision 1.19
tests/libexec/ld.elf_so/helper_onlydef_static/h_onlydef_static.c: revision 1.1
tests/libexec/ld.elf_so/helper_use_static/h_use_static.c: revision 1.1
tests/libexec/ld.elf_so/helper_use_static/h_use_static.c: revision 1.2
tests/libexec/ld.elf_so/helper_def_static/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_def_static/Makefile: revision 1.2
libexec/ld.elf_so/arch/hppa/hppa_reloc.c: revision 1.50
distrib/sets/lists/debug/shl.mi: revision 1.310
libexec/ld.elf_so/README.TLS: revision 1.6
distrib/sets/lists/debug/shl.mi: revision 1.311
distrib/sets/lists/debug/shl.mi: revision 1.314
tests/libexec/ld.elf_so/helper_dso3/Makefile: revision 1.2
tests/libexec/ld.elf_so/helper_symver_dso1/Makefile: revision 1.4
libexec/ld.elf_so/arch/powerpc/ppc_reloc.c: revision 1.63
tests/libexec/ld.elf_so/helper_def_dynamic/h_def_dynamic.c: revision 1.1
tests/libexec/ld.elf_so/helper_onlydef/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_onlydef/Makefile: revision 1.2
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.10
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.11
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.12
libexec/ld.elf_so/map_object.c: revision 1.66
tests/libexec/ld.elf_so/helper.mk: revision 1.1
libexec/ld.elf_so/arch/sparc/mdreloc.c: revision 1.57
libexec/ld.elf_so/map_object.c: revision 1.67
tests/libexec/ld.elf_so/helper_onlydef/h_onlydef.c: revision 1.1
tests/libexec/ld.elf_so/helper_symver_dso2/Makefile: revision 1.4
tests/libexec/ld.elf_so/helper_use_static/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_use_static/Makefile: revision 1.2
tests/libexec/ld.elf_so/helper_use_static/Makefile: revision 1.3
tests/libexec/ld.elf_so/helper_use_dynamic/h_use_dynamic.c: revision 1.1
tests/libexec/ld.elf_so/helper_abuse_static/h_abuse_static.c: revision 1.1
libexec/ld.elf_so/arch/riscv/mdreloc.c: revision 1.9
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.1
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.2
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.3
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.4
tests/libexec/ld.elf_so/helper_onlyctor_dynamic/Makefile: revision 1.1
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.5
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.6
libexec/ld.elf_so/arch/m68k/mdreloc.c: revision 1.34
tests/libexec/ld.elf_so/helper_onlyctor_dynamic/Makefile: revision 1.2
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.7
libexec/ld.elf_so/arch/i386/mdreloc.c: revision 1.42
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.8
libexec/ld.elf_so/arch/i386/mdreloc.c: revision 1.43
libexec/ld.elf_so/arch/or1k/mdreloc.c: revision 1.4
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.9
tests/libexec/ld.elf_so/helper_onlyuse_dynamic/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_onlyuse_dynamic/Makefile: revision 1.2
tests/libexec/ld.elf_so/helper_abuse_dynamic/h_abuse_dynamic.c: revision 1.1
tests/libexec/ld.elf_so/helper_onlyctor_dynamic/h_onlyctor_dynamic.c: revision 1.1
tests/libexec/ld.elf_so/helper_onlyuse_static/h_onlyuse_static.c: revision 1.1
tests/libexec/ld.elf_so/helper_onlyuse_dynamic/h_onlyuse_dynamic.c: revision 1.1
tests/libexec/ld.elf_so/helper_dso1/Makefile: revision 1.2
distrib/sets/lists/tests/shl.mi: revision 1.12
distrib/sets/lists/tests/shl.mi: revision 1.13
libexec/ld.elf_so/arch/alpha/alpha_reloc.c: revision 1.44

ld.elf_so: New test for extern initial-exec TLS, PR toolchain/50277.

ld.elf_so: Fix extern TLS test to match PR toolchain/50277.
Now it's actually testing the problem.
ld.elf_so: Nix inadvertently committed private test program.
ld.elf_so: Fix set lists for MKDEBUG=yes builds with t_tls_extern.

ld.elf_so: Sprinkle tls debug messages.

ld.elf_so: Make tls alloc debug messages more detailed and greppable.

ld.elf_so: Test variations on PR toolchain/50277.

ld.elf_so: Test extern dynamic TLS too.

ld.elf_so: Factor out logic in TLS tests to make writing more easier.
No functional change intended.

ld.elf_so: Test TLS abuse of static def, dynamic use and vice versa.

ld.elf_so: Shorter test names.
No functional non-cosmetic change intended.

ld.elf_so: Separately test eager and lazy resolution of def tls ptr.
eager: before loading use library
lazy: after loading use library

Add recent ld.elf_so test helpers debug info
ld.elf_so: Add new files to debug/shl.mi.

ld.elf_so: tls_extern dynamic_defabuse_eager must xfail differently.
If a symbol has already been resolved as dynamic TLS, any library
that tries to use it as static TLS cannot be dlopened.

ld.elf_so: Test another edge case of mismatched TLS models.
One library defines a symbol and _doesn't_ use it, so it has no
indication of whether the symbol is for static TLS or dynamic TLS,
and then two other libraries use it in different ways.

ld.elf_so: Test dynamic-then-static abuse via ctor.

ld.elf_so: Fix missing tab in debug/shl.mi in last change.

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.
Avoid using uninitialized variable "symnum" when building with DEBUG
enabled by borrowing the rdbg_symname() macro from arch/x86_64.
ld.elf_so: Sprinkle more debug messages on dlopen and error.

PR pkg/57445

Fix MKDEBUGLIB build by adding these installed files to the debug
set list.

One could argue that these files are not of any use, so why install
them? I don't have a good argument either way, and this is (for
now) a simple work-around for PR bin/57455 Please feel free to
commit a different fix to avoid installing these files at all.

Fix markup of libh_ MKDEBUGLIB=yes only files

TLS variant I archs need to fudge the offset by the size of the TCB.
tests/libexec/ld.elf_so: Fix helper library makefiles.
1. Consolidate logic into a single helper.mk to reduce duplication.
2. Set NO* variables, not MK* variables which are reserved for user.
3. Avoid eager X!= in favour of lazy ${X:sh}.
4. Mark _g.a set list entries obsolete. Never should've been built!
PR misc/57462
 1.136.2.1  13-May-2020  martin Pull up following revision(s) (requested by chs in ticket #907):

libexec/ld.elf_so/rtld.c: revision 1.205
libexec/ld.elf_so/rtld.h: revision 1.140
libexec/ld.elf_so/symbols.map: revision 1.3
libexec/ld.elf_so/symbols.map: revision 1.4
lib/libc/gen/pthread_atfork.c: revision 1.13
lib/libc/gen/pthread_atfork.c: revision 1.14
libexec/ld.elf_so/rtld.h: revision 1.139
libexec/ld.elf_so/rtld.c: revision 1.204

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.

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.
 1.144.2.2  01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #300):

libexec/ld.elf_so/rtld.h: revision 1.145
libexec/ld.elf_so/symbol.c: revision 1.74
libexec/ld.elf_so/rtld.h: revision 1.147
libexec/ld.elf_so/symbol.c: revision 1.75
libexec/ld.elf_so/symbol.c: revision 1.76
tests/libexec/ld.elf_so/t_hash.c: revision 1.1
libexec/ld.elf_so/Makefile: revision 1.145
libexec/ld.elf_so/Makefile: revision 1.146
libexec/ld.elf_so/Makefile: revision 1.147
libexec/ld.elf_so/reloc.c: revision 1.118
distrib/sets/lists/tests/mi: revision 1.1280
libexec/ld.elf_so/rtld.c: revision 1.215
tests/libexec/ld.elf_so/Makefile: revision 1.21
libexec/ld.elf_so/hash.c: revision 1.1
libexec/ld.elf_so/hash.h: revision 1.1
distrib/sets/lists/debug/mi: revision 1.409

The SysV ABI specifies that the symbol hash function should return only 32
bits of hash. Unfortunately due to an implementation bug 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.

Oops wrong mask.

ld.elf_so: Split SRCS onto multiple lines.
Makes updates easier.
No functional change intended.

ld.elf_so: Sort SRCS.
No functional change intended.

ld.elf_so: Split hash functions into a separate file.
This way we can test them in isolation.
No functional change intended.

ld.elf_so: Add some known-answer tests for hash functions.

Make sure the testing mechanism detects the traditional overflow bug.
 1.144.2.1  01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #297):

distrib/sets/lists/tests/shl.mi: revision 1.14
distrib/sets/lists/tests/shl.mi: revision 1.15
distrib/sets/lists/tests/shl.mi: revision 1.16
tests/libexec/ld.elf_so/helper_def_static/h_def_static.c: revision 1.1
tests/libexec/ld.elf_so/helper_def_dynamic/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_def_dynamic/Makefile: revision 1.2
tests/libexec/ld.elf_so/helper_onlyuse_static/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_onlyuse_static/Makefile: revision 1.2
libexec/ld.elf_so/arch/mips/mips_reloc.c: revision 1.75
distrib/sets/lists/tests/mi: revision 1.1265
libexec/ld.elf_so/arch/sh3/mdreloc.c: revision 1.36
libexec/ld.elf_so/rtld.c: revision 1.214
tests/libexec/ld.elf_so/helper_onlydef_static/Makefile: revision 1.1
distrib/sets/lists/debug/mi: revision 1.400
tests/libexec/ld.elf_so/helper_onlydef_static/Makefile: revision 1.2
distrib/sets/lists/debug/mi: revision 1.401
distrib/sets/lists/debug/mi: revision 1.402
tests/libexec/ld.elf_so/helper_dso2/Makefile: revision 1.2
distrib/sets/lists/debug/mi: revision 1.403
tests/libexec/ld.elf_so/helper_symver_dso0/Makefile: revision 1.2
libexec/ld.elf_so/arch/x86_64/mdreloc.c: revision 1.48
distrib/sets/lists/debug/mi: revision 1.406
tests/libexec/ld.elf_so/helper_use_dynamic/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_use_dynamic/Makefile: revision 1.2
tests/libexec/ld.elf_so/helper_ifunc_dso/Makefile: revision 1.2
libexec/ld.elf_so/arch/sparc64/mdreloc.c: revision 1.70
libexec/ld.elf_so/arch/aarch64/mdreloc.c: revision 1.18
tests/libexec/ld.elf_so/helper_abuse_dynamic/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_abuse_dynamic/Makefile: revision 1.2
tests/libexec/ld.elf_so/Makefile: revision 1.13
libexec/ld.elf_so/arch/arm/mdreloc.c: revision 1.46
libexec/ld.elf_so/rtld.h: revision 1.146
tests/libexec/ld.elf_so/Makefile: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.306
tests/libexec/ld.elf_so/Makefile: revision 1.15
tests/libexec/ld.elf_so/helper_abuse_static/Makefile: revision 1.1
distrib/sets/lists/debug/shl.mi: revision 1.307
tests/libexec/ld.elf_so/Makefile: revision 1.16
tests/libexec/ld.elf_so/helper_abuse_static/Makefile: revision 1.2
distrib/sets/lists/debug/shl.mi: revision 1.308
tests/libexec/ld.elf_so/Makefile: revision 1.17
distrib/sets/lists/debug/shl.mi: revision 1.309
tests/libexec/ld.elf_so/Makefile: revision 1.18
tests/libexec/ld.elf_so/Makefile: revision 1.19
libexec/ld.elf_so/tls.c: revision 1.16
libexec/ld.elf_so/tls.c: revision 1.17
libexec/ld.elf_so/tls.c: revision 1.18
libexec/ld.elf_so/tls.c: revision 1.19
tests/libexec/ld.elf_so/helper_onlydef_static/h_onlydef_static.c: revision 1.1
tests/libexec/ld.elf_so/helper_use_static/h_use_static.c: revision 1.1
tests/libexec/ld.elf_so/helper_use_static/h_use_static.c: revision 1.2
tests/libexec/ld.elf_so/helper_def_static/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_def_static/Makefile: revision 1.2
libexec/ld.elf_so/arch/hppa/hppa_reloc.c: revision 1.50
distrib/sets/lists/debug/shl.mi: revision 1.310
libexec/ld.elf_so/README.TLS: revision 1.6
distrib/sets/lists/debug/shl.mi: revision 1.311
distrib/sets/lists/debug/shl.mi: revision 1.314
tests/libexec/ld.elf_so/helper_dso3/Makefile: revision 1.2
tests/libexec/ld.elf_so/helper_symver_dso1/Makefile: revision 1.4
libexec/ld.elf_so/arch/powerpc/ppc_reloc.c: revision 1.63
tests/libexec/ld.elf_so/helper_def_dynamic/h_def_dynamic.c: revision 1.1
tests/libexec/ld.elf_so/helper_onlydef/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_onlydef/Makefile: revision 1.2
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.10
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.11
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.12
libexec/ld.elf_so/map_object.c: revision 1.66
tests/libexec/ld.elf_so/helper.mk: revision 1.1
libexec/ld.elf_so/arch/sparc/mdreloc.c: revision 1.57
libexec/ld.elf_so/map_object.c: revision 1.67
tests/libexec/ld.elf_so/helper_onlydef/h_onlydef.c: revision 1.1
tests/libexec/ld.elf_so/helper_symver_dso2/Makefile: revision 1.4
tests/libexec/ld.elf_so/helper_use_static/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_use_static/Makefile: revision 1.2
tests/libexec/ld.elf_so/helper_use_static/Makefile: revision 1.3
tests/libexec/ld.elf_so/helper_use_dynamic/h_use_dynamic.c: revision 1.1
tests/libexec/ld.elf_so/helper_abuse_static/h_abuse_static.c: revision 1.1
libexec/ld.elf_so/arch/riscv/mdreloc.c: revision 1.9
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.1
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.2
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.3
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.4
tests/libexec/ld.elf_so/helper_onlyctor_dynamic/Makefile: revision 1.1
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.5
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.6
libexec/ld.elf_so/arch/m68k/mdreloc.c: revision 1.34
tests/libexec/ld.elf_so/helper_onlyctor_dynamic/Makefile: revision 1.2
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.7
libexec/ld.elf_so/arch/i386/mdreloc.c: revision 1.42
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.8
libexec/ld.elf_so/arch/i386/mdreloc.c: revision 1.43
libexec/ld.elf_so/arch/or1k/mdreloc.c: revision 1.4
tests/libexec/ld.elf_so/t_tls_extern.c: revision 1.9
tests/libexec/ld.elf_so/helper_onlyuse_dynamic/Makefile: revision 1.1
tests/libexec/ld.elf_so/helper_onlyuse_dynamic/Makefile: revision 1.2
tests/libexec/ld.elf_so/helper_abuse_dynamic/h_abuse_dynamic.c: revision 1.1
tests/libexec/ld.elf_so/helper_onlyctor_dynamic/h_onlyctor_dynamic.c: revision 1.1
tests/libexec/ld.elf_so/helper_onlyuse_static/h_onlyuse_static.c: revision 1.1
tests/libexec/ld.elf_so/helper_onlyuse_dynamic/h_onlyuse_dynamic.c: revision 1.1
tests/libexec/ld.elf_so/helper_dso1/Makefile: revision 1.2
distrib/sets/lists/tests/shl.mi: revision 1.12
distrib/sets/lists/tests/shl.mi: revision 1.13
libexec/ld.elf_so/arch/alpha/alpha_reloc.c: revision 1.44
(all via patch)

ld.elf_so: New test for extern initial-exec TLS, PR toolchain/50277.

ld.elf_so: Fix extern TLS test to match PR toolchain/50277.
Now it's actually testing the problem.
ld.elf_so: Nix inadvertently committed private test program.
ld.elf_so: Fix set lists for MKDEBUG=yes builds with t_tls_extern.

ld.elf_so: Sprinkle tls debug messages.

ld.elf_so: Make tls alloc debug messages more detailed and greppable.

ld.elf_so: Test variations on PR toolchain/50277.

ld.elf_so: Test extern dynamic TLS too.

ld.elf_so: Factor out logic in TLS tests to make writing more easier.
No functional change intended.

ld.elf_so: Test TLS abuse of static def, dynamic use and vice versa.

ld.elf_so: Shorter test names.
No functional non-cosmetic change intended.

ld.elf_so: Separately test eager and lazy resolution of def tls ptr.
eager: before loading use library
lazy: after loading use library

Add recent ld.elf_so test helpers debug info
ld.elf_so: Add new files to debug/shl.mi.

ld.elf_so: tls_extern dynamic_defabuse_eager must xfail differently.
If a symbol has already been resolved as dynamic TLS, any library
that tries to use it as static TLS cannot be dlopened.

ld.elf_so: Test another edge case of mismatched TLS models.
One library defines a symbol and _doesn't_ use it, so it has no
indication of whether the symbol is for static TLS or dynamic TLS,
and then two other libraries use it in different ways.

ld.elf_so: Test dynamic-then-static abuse via ctor.

ld.elf_so: Fix missing tab in debug/shl.mi in last change.

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.
Avoid using uninitialized variable "symnum" when building with DEBUG
enabled by borrowing the rdbg_symname() macro from arch/x86_64.
ld.elf_so: Sprinkle more debug messages on dlopen and error.
PR pkg/57445
Fix MKDEBUGLIB build by adding these installed files to the debug
set list.
XXX
One could argue that these files are not of any use, so why install
them? I don't have a good argument either way, and this is (for
now) a simple work-around for PR bin/57455 Please feel free to
commit a different fix to avoid installing these files at all.
Fix markup of libh_ MKDEBUGLIB=yes only files
TLS variant I archs need to fudge the offset by the size of the TCB.
tests/libexec/ld.elf_so: Fix helper library makefiles.
1. Consolidate logic into a single helper.mk to reduce duplication.
2. Set NO* variables, not MK* variables which are reserved for user.
3. Avoid eager X!= in favour of lazy ${X:sh}.
4. Mark _g.a set list entries obsolete. Never should've been built!
PR misc/57462

RSS XML Feed