Home | History | Annotate | Download | only in ld.elf_so
History log of /src/libexec/ld.elf_so/symbol.c
RevisionDateAuthorComments
 1.77  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.76  30-Jul-2023  riastradh branches: 1.76.2;
ld.elf_so: Split hash functions into a separate file.

This way we can test them in isolation.

No functional change intended.
 1.75  18-Apr-2023  christos Oops wrong mask.
 1.74  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.73  29-Feb-2020  kamil branches: 1.73.8;
Fix vax and mips build
 1.72  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.71  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.70  29-Feb-2020  kamil Separate matched symbol functionality out of _rtld_symlook_obj()

Simplifies the code and it will allow to use the matched symbol
functionality by other users.
 1.69  09-Aug-2017  joerg branches: 1.69.4; 1.69.6;
If a DF_1_NODELETE DSO has been removed from the DAG list, it still
needs to be able to resolve relocations against itself. As such, search
the referencing object explicitly last, if it hasn't been searched
before.
 1.68  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.67  01-Dec-2016  christos branches: 1.67.6;
Instead of using a function to resolve symbols that should be supplied by
the dynamic linker itself, use a version script that exposes them. From joerg@
 1.66  30-Nov-2016  christos 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.65  10-Aug-2014  matt branches: 1.65.6;
Don't provide __gnu_Unwind_Find_exidx if __ARM_DWARF_EH__ is defined
 1.64  21-Mar-2014  matt Don't resolve symbols to PLT entries on the VAX. It just causes a lot of
overhead.
 1.63  03-May-2013  skrll Remove trailing whitespace
 1.62  24-Apr-2013  matt Add support for PT_ARM_EXIDX and __gnu_Unwind_Find_exidx for libgcc's support
of the ARM EHABI.
 1.61  15-Aug-2012  matt branches: 1.61.2;
Add .init_array/.fini_array support (conditionalized on HAVE_INITFINI_ARRAY).
 1.60  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.59  25-Nov-2011  joerg branches: 1.59.4;
Replace if() NADA else if() NADA else continue logic with one explicit
block. Split out the MIPS handling to make it explicit and readable.
 1.58  13-Aug-2011  christos branches: 1.58.2;
printing the pathname of the shared object is much more useful than the
object's address.
 1.57  25-Jun-2011  nonaka PR/45015: ld.elf_so: support ELF symbol versioning
Applied latest patch.
 1.56  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.55  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.54  16-Oct-2010  skrll Implement dl_iterate_phdr.

Somewhat taken from FreeBSD. Manual page from OpenBSD.
 1.53  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.52  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.51  27-Feb-2010  roy Implement negative cache checks for symbol lookups.
Uses the Donelist idea from FreeBSD.
 1.50  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.49  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.48  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.47  04-Oct-2008  skrll branches: 1.47.4; 1.47.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.46  24-Jul-2008  matt Refactor common code to _rtld_relocate_plt_object to i386 and arm so they
act like the other versions.
In _rtld_bind, if the result is 0, call _rtld_die.
Initialize _rtld_sym_zero.st_value to -_rtld_objself.maprelocbase. Now when
the symbol is resolved, st_value + maprelocbase will equal 0 and the above
check in _rtld_bind will fire and a call to NULL will be avoided.
 1.45  23-Jul-2008  christos abort() if we are trying to use an undefined weak symbol from the plt. Remove
check from relocate_plt_object() since we cannot return _rtld_sym_zero anymore.
Code from gimpy.
 1.44  14-Jan-2008  yamt branches: 1.44.6;
constify
 1.43  26-Dec-2007  christos print the symbol we are seaching for [when debugging]
 1.42  23-Feb-2007  matt branches: 1.42.4;
Don't use cached results for plt lookups (nor save them).
 1.41  22-Feb-2007  matt Make the COMBRELOC support generic.
 1.40  13-Oct-2005  skrll branches: 1.40.4;
Correct the lookup order of _rtld_symlook_default and make
_rtld_find_symdef use _rtld_symlook_default.

This reduces the code size and means that dlsym(RTLD_DEFAULT,...) has the
correct lookup order.

Reviewed by kleink. Thanks.
 1.39  10-May-2005  chs in _rtld_is_exported(), use a function pointer type instead of Elf_Addr
so that hppa knows to do the plabel thang.
 1.38  11-Jan-2005  martin branches: 1.38.2;
Quote symbol names in a debug message (to make it easier to spot an empty
symbol name, a common failure mode)
 1.37  22-Oct-2004  skrll Add __RCSIDs.

OK'd by mycroft.
 1.36  18-Jul-2004  thorpej - Change the strong dlfcn names in libc to ___name, and make the __name
versions used by others in libc weak, so that we have:
name: weak
__name: weak
___name: strong
- Add __name strong aliases of the dlfcn names in ld.elf_so, so that we have:
name: strong
__name: strong

This allows ld.elf_so to self-resolve both the name and __name variants
of the dlfcn functions, the former being required for dlfcn support in
applications, the latter being required for dlfcn support in libc.

Fixes the problem described in:

http://mail-index.netbsd.org/tech-toolchain/2004/07/17/0000.html

Reviewed by Nick.
 1.35  07-Dec-2003  mrauch branches: 1.35.2;
Change the symbol lookup order to search RTLD_GLOBAL objects
before referencing object's DAG. This makes it possible for
C++ exceptions to work across shared libraries.

Patch taken from FreeBSD: src/libexec/rtld-elf/rtld.c: 1.67 -> 1.68,
committed there by kan@FreeBSD.org.
 1.34  21-Oct-2003  fvdl Don't use NULL for integers.
 1.33  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.32  05-Aug-2003  skrll KNF
 1.31  24-Jul-2003  skrll ANSIfy and de-__P().
 1.30  15-Jul-2003  skrll s/_rltd_obj_rtld/_rtld_objself/ in #ifdef notyet code.
 1.29  15-Jul-2003  skrll Whitespace
 1.28  30-May-2003  christos Add RTLD_FIRST, RTLD_NEXT, RTLD_DEFAULT, from FreeBSD
 1.27  24-Apr-2003  mycroft Back out previous change for now -- it needs more work.
 1.26  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.25  05-Oct-2002  mycroft Minor cleanup.
 1.24  04-Oct-2002  mycroft Recode _rtld_elf_hash() so it compiles better (at least on i386 and arm).
Still could be better on i386, but only written in assembler...
 1.23  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.22  24-Sep-2002  mycroft Add a comment about the function pointer nonsense.
 1.21  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.20  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.19  13-Sep-2002  mycroft If we match a symbol name, but it's undefined, do not continue searching the
hash chain.
 1.18  12-Sep-2002  mycroft Nuke -DRTLD_RELOCATE_SELF and `dodebug' from orbit.
 1.17  06-Sep-2002  mycroft Re-poison a lot of consts, now that the mark shite is gone.
 1.16  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.15  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.14  05-Sep-2002  mycroft Split MIPS relocation goo into mips_reloc.c.
 1.13  05-Sep-2002  junyoung Remove unused arguments of _rtld_find_symdef().
 1.12  01-Jun-2002  lukem SIMPLEQ rototill:
- implement SIMPLEQ_REMOVE(head, elm, type, field). whilst it's O(n),
this mirrors the functionality of SLIST_REMOVE() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE()
- remove the unnecessary elm arg from SIMPLEQ_REMOVE_HEAD().
this mirrors the functionality of SLIST_REMOVE_HEAD() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE_HEAD()
- remove notes about SIMPLEQ not supporting arbitrary element removal
- use SIMPLEQ_FOREACH() instead of home-grown for loops
- use SIMPLEQ_EMPTY() appropriately
- use SIMPLEQ_*() instead of accessing sqh_first,sqh_last,sqe_next directly
- reorder manual page; be consistent about how the types are listed
- other minor cleanups
 1.11  14-Oct-2001  rafal branches: 1.11.2;
Fix how underfined weak symbols are treated -- before, ld.so would do nothing
with them, rather than defaulting them to zero. This caused breakage with
the drawf EH stuff and init/fini code when they weren't used by the caller
(and hence the appropriate handlers were left undefined). Also fix an un-
initialized variable in symbol.c that only MIPS MD code tripped over.
 1.10  11-Oct-2000  dan format warning fixes from he, after testing on 64-bit elf (alpha)
 1.9  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.8  03-Jul-2000  matt shut gcc up about a bogus possibly used before initialized.
 1.7  10-Nov-1999  thorpej branches: 1.7.4;
Name consistencty nit: curmark -> _rtld_curmark
 1.6  10-Nov-1999  thorpej Some slight cosmetic cleanup.
 1.5  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.4  25-Oct-1999  kleink Update to match new SVR4-style definition names in <sys/exec_elf.h>.
 1.3  01-Mar-1999  christos branches: 1.3.2; 1.3.4;
KNF
 1.2  25-Mar-1998  mhitch Add support for mips.
 1.1  16-Dec-1996  cgd branches: 1.1.2;
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.1.2.1  08-May-1998  mycroft Sync with trunk, per request of mycroft.
 1.3.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.2.1  11-Oct-2000  he Apply patch (requested by he):
Print possible 64bit values with %ld and cast to u_long.
 1.7.4.3  09-Dec-2001  he Pull up revision 1.11 (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.7.4.2  16-Oct-2000  tv Pullup 1.10 [dan]:
format warning fixes from he, after testing on 64-bit elf (alpha)
 1.7.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.11.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.11.2.1  05-Sep-2003  tron Pull up revision 1.16 via patch (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.35.2.1  19-Jul-2004  tron Pull up revision 1.36 (requested by thorpej in ticket #676):
- Change the strong dlfcn names in libc to ___name, and make the __name
versions used by others in libc weak, so that we have:
name: weak
__name: weak
___name: strong
- Add __name strong aliases of the dlfcn names in ld.elf_so, so that
we have:
name: strong
__name: strong
This allows ld.elf_so to self-resolve both the name and __name variants
of the dlfcn functions, the former being required for dlfcn support in
applications, the latter being required for dlfcn support in libc.
Fixes the problem described in:
http://mail-index.netbsd.org/tech-toolchain/2004/07/17/0000.html
Reviewed by Nick.
 1.38.2.2  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.38.2.1  06-Dec-2005  tron Pull up following revision(s) (requested by oster in ticket #1012):
libexec/ld.elf_so/symbol.c: revision 1.39
in _rtld_is_exported(), use a function pointer type instead of Elf_Addr
so that hppa knows to do the plabel thang.
 1.40.4.1  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.42.4.2  23-Mar-2008  matt sync with HEAD
 1.42.4.1  09-Jan-2008  matt sync with HEAD
 1.44.6.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.47.10.1  21-Apr-2010  matt sync to netbsd-5
 1.47.4.3  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.47.4.2  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.47.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.58.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.58.2.2  30-Oct-2012  yamt sync with head
 1.58.2.1  17-Apr-2012  yamt sync with head
 1.59.4.1  22-Jan-2013  matt Pullup from HEAD:
Add .init_array/.fini_array support (conditionalized on HAVE_INITFINI_ARRAY).
 1.61.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.61.2.1  23-Jun-2013  tls resync from head
 1.65.6.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.67.6.3  09-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1886):

distrib/sets/lists/debug/mi 1.409 (patch)
distrib/sets/lists/tests/mi 1.1280 (patch)
libexec/ld.elf_so/Makefile 1.145-1.147 (patch)
libexec/ld.elf_so/hash.c 1.1
libexec/ld.elf_so/hash.h 1.1
libexec/ld.elf_so/reloc.c 1.118 (patch)
libexec/ld.elf_so/rtld.c 1.215 (patch)
libexec/ld.elf_so/rtld.h 1.145,1.147 (patch)
libexec/ld.elf_so/symbol.c 1.74-1.76 (patch)
tests/libexec/ld.elf_so/Makefile 1.21 (patch)
tests/libexec/ld.elf_so/t_hash.c 1.1

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.

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.67.6.2  31-Aug-2017  bouyer Pull up following revision(s) (requested by joerg in ticket #236):
libexec/ld.elf_so/symbol.c: revision 1.69
If a DF_1_NODELETE DSO has been removed from the DAG list, it still
needs to be able to resolve relocations against itself. As such, search
the referencing object explicitly last, if it hasn't been searched
before.
 1.67.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.69.6.1  11-Aug-2023  sborrill Pull up the following revisions(s) (requested by riastradh in ticket #1712):
distrib/sets/lists/debug/mi: revision 1.409 via patch
distrib/sets/lists/tests/mi: revision 1.1280 via patch
libexec/ld.elf_so/Makefile: revision 1.145-1.147 via patch
libexec/ld.elf_so/hash.c: revision 1.1 via patch
libexec/ld.elf_so/hash.h: revision 1.1 via patch
libexec/ld.elf_so/symbol.c: revision 1.74-1.76 via patch
tests/libexec/ld.elf_so/Makefile: revision 1.21 via patch
tests/libexec/ld.elf_so/t_hash.c: revision 1.1 via patch

ld.elf_so: Fix sysv elf hash on edge cases like `ZZZZZW9p' on LP64
platforms where long is 64-bit.
 1.69.4.1  08-Apr-2020  martin Merge changes from current as of 20200406
 1.73.8.1  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.76.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed