Home | History | Annotate | Download | only in mips
History log of /src/libexec/ld.elf_so/arch/mips/mips_reloc.c
RevisionDateAuthorComments
 1.78  30-Nov-2024  christos Create a new header lwp_private.h to contain _lwp_getprivate_fast,
_lwp_gettcb_fast, _lwp_settcb and remove them from mcontext.h, so that:
1. we don't need special hacks to hide them
2. we can include <lwp.h> where needed to get the necessary prototypes
without redefining them locally.
 1.77  06-Aug-2024  riastradh ld.elf_so(1): Cite reference for MIPS ELF relocations.

This doesn't cover everything -- it's missing the thread-local
storage relocations -- but it's a start.

PR lib/58455: Missing references for processor-specific ELF
relocation semantics
 1.76  03-Aug-2024  riastradh ld.elf_so(1): Nix trailing whitespace.

No functional change intended.
 1.75  04-Jun-2023  joerg branches: 1.75.2;
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.74  06-Mar-2021  christos branches: 1.74.6;
Don't or the got object in, just assign it. Fixes cc -mabi=64 hello.c -lcrypto
Now all 64 bit binaries work, and I tested that we did not break the 32 bit
ones
XXX: That 0x80000000 seems wrong for 64 bit stuff.
 1.73  03-Nov-2019  christos simplify pointer gymnastics that sprained gcc-8
 1.72  19-Jan-2018  christos branches: 1.72.4; 1.72.6;
don't forget to eat the high bits.
 1.71  25-Dec-2017  maya Fix typo in comment

from freebsd
 1.70  24-Dec-2017  maya fix debug build
 1.69  10-Aug-2017  joerg Add IRELATIVE support for ARM, X86 and PowerPC.
 1.68  21-Jun-2017  joerg Replace last use of r_type.
 1.67  20-Jun-2017  joerg Fix C&P bug. Deal with more MIPS hacks overriding def.
 1.66  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.65  20-Feb-2016  christos branches: 1.65.8;
where is already void *
 1.64  19-Feb-2016  macallan make debug code compile again
from christos
 1.63  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.62  25-Mar-2011  joerg branches: 1.62.22;
Add basic locking to ld.elf_so.
 1.61  15-Mar-2011  matt Add support for the MIPS TLS reloc types in shared libraries.
 1.60  24-Sep-2010  matt Make the GOT1_MASK 64-bit clean.
 1.59  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.58  14-Jan-2010  skrll Shut gcc up.
 1.57  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.56  14-Dec-2009  matt Merge from matt-nb5-mips64:
Add N32/N64 support for mips dynamic loader.
 1.55  29-Aug-2009  jmmv Remove trailing \n in calls to _rtld_error: a newline is automatically
added by a call to the function.
 1.54  20-May-2009  christos fix signed/unsigned comparisons and const cast away (untested)
 1.53  24-Jul-2008  matt branches: 1.53.4; 1.53.10;
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.52  28-Jun-2006  simonb branches: 1.52.20;
Fix unaligned loads and stores generated by gcc4. Problem described in
http://mail-index.NetBSD.org/tech-toolchain/2006/06/27/0001.html.
This cleaner version of the patch from Christos - thanks!
 1.51  03-Apr-2006  skrll Remove empty lines.
 1.50  04-Mar-2006  skrll Add LD_BIND_NOW support for mips.

This is the last arch to be done so remove the large ugly #if defined()
stuff in reloc.c.
 1.49  24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.48  20-Aug-2005  skrll Add __RCSID.
 1.47  07-Jun-2005  he Initialize a bunch of local variables in _rtld_relocate_nonplt_self().
Found by -Wuninitialized while compiling for newsmips.

Reviewed by lukem.
 1.46  15-Dec-2004  skrll Apply fixes from Charles:

- Fix how _rtld_relocate_nonplt_self deals with REL32 relocations.

- Change the assert so that it is correct for binutils 2.14 and 2.15.

There are still problems with the libraries generated with binutils 2.15,
but at least ld.elf_so doesn't crash.
 1.45  19-Nov-2003  simonb Restore handling of reloc entries that point to unaligned locations
that seems to have disappeared in rev 1.34.

Thanks to Jason Thorpe for suggesting where to look.
Fixes the simple test case in PR port-mips/23366.
 1.44  24-Sep-2003  mycroft Make the effect of the hack clearer.
 1.43  24-Sep-2003  mycroft One more tweak...
 1.42  24-Sep-2003  mycroft Make the comment a little more accurate.
 1.41  24-Sep-2003  mycroft Temporary workaround for some binutils/ld lossage. See the comment for more
information.
 1.40  26-Jul-2003  mrg include <string.h> or <stdlib.h> for all prototypes
 1.39  24-Jul-2003  skrll ANSIfy and de-__P().
 1.38  17-Jul-2003  skrll Correct the in_plt parameter of a couple of _rtld_find_symdef calls.

The mips_reloc.c case is a no-op as _rtld_symlook_obj ignores in_plt for
MIPS.

OK'ed by Charles.
 1.37  05-Oct-2002  mycroft Minor cleanup.
 1.36  26-Sep-2002  mycroft Add an iffy heuristic that allows us to do lazy binding with new objects, but
detect old objects and deal with them.
 1.35  25-Sep-2002  mycroft Minor cleanup, for clarity.
 1.34  25-Sep-2002  mycroft Resolve the GOT before doing relocations. Then, when doing relocations, for
symbols in the global part of the symbol table, use the updated GOT entry
rather than doing a lookup. (This provides the same effect as `-z combreloc'
on other platforms -- at most one lookup is done per symbol.)

Unfortunately, it is necessary to turn off lazy binding on MIPS. As the
comment says:

* XXX DANGER WILL ROBINSON!
* You might think this is stupid, as it intentionally
* defeats lazy binding -- and you'd be right.
* Unfortunately, for lazy binding to work right, we
* need to a way to force the GOT slots used for
* function pointers to be resolved immediately. This
* is supposed to be done automatically by the linker,
* by not outputting a PLT slot and setting st_value
* to 0, but GNU ld does not do so reliably.
 1.33  14-Sep-2002  thorpej It is possible for reloc entries to point to unaligned locations; handle
this.
 1.32  13-Sep-2002  mycroft In _rtld_bind_mips(), if the symbol is undefined, die.
 1.31  13-Sep-2002  mycroft Add an explanatory comment.
 1.30  13-Sep-2002  mycroft The sense of the SHN_ABS test has always been reversed. Fortunately nobody
ever tried to reference stuff like _DYNAMIC_LINK and _gp_disp in C code...
 1.29  13-Sep-2002  mycroft Put back the lazy binding. For some bizarre reason, the linker occasionally
does not create a PLT entry for a symbol, so we test st_value!=0 to see
whether we can do a PLT fixup.
 1.28  13-Sep-2002  mycroft Er, turn off lazy binding for the moment. It doesn't seem to be fully working.
 1.27  13-Sep-2002  mycroft Simplify the GOT relocation code somewhat.
 1.26  13-Sep-2002  mycroft Actually do lazy binding on this platform.
 1.25  13-Sep-2002  mycroft Remove an old comment.
 1.24  13-Sep-2002  mycroft _rtld_bind() is not used on MIPS. Should probably move it to MD code.
 1.23  12-Sep-2002  mycroft Nuke -DRTLD_RELOCATE_SELF and `dodebug' from orbit.
 1.22  12-Sep-2002  mycroft _rtld_bind_start() is not used in MI code, so declare it in the MD code.
 1.21  12-Sep-2002  mycroft Slight tweak.
 1.20  12-Sep-2002  mycroft The GOT is Elf_Addr[], not Elf_Word[]...
 1.19  12-Sep-2002  mycroft Clean up a little.
 1.18  12-Sep-2002  mycroft Move GOT relocation code from _rtld_setup_pltgot() to
_rtld_relocate_nonplt_objects(). Add GOT self-relocation in
_rtld_relocate_nonplt_self().
MIPS ld.elf_so can now relocate itself.
 1.17  12-Sep-2002  mycroft Snapshot of work to make MIPS ld.elf_so relocatable.
 1.16  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.15  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.14  06-Sep-2002  mycroft More const poisoning. Now the entire _rtld_bind() path useds a const Obj_Entry.
 1.13  06-Sep-2002  mycroft Re-poison a lot of consts, now that the mark shite is gone.
 1.12  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.11  05-Sep-2002  mycroft Partially fix up some debug printf()s that don't need to use defobj.
 1.10  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.9  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.8  05-Sep-2002  mycroft Split MIPS relocation goo into mips_reloc.c.
 1.7  05-Sep-2002  junyoung Remove unused arguments of _rtld_find_symdef().
 1.6  05-Sep-2002  mycroft Make _rtld_setup_pltgot() a consistent interface on all platforms.
 1.5  24-Nov-2001  rafal branches: 1.5.2;
Fix bug found by Izumi Tsutsui -- if _rtld_find_symdef returned NULL, the
runtime linker would crash. Restore behavior similar to version 1.3, where
the runtime linker continues on, ignoring the symbol.
 1.4  14-Oct-2001  rafal 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.3  07-Nov-1999  mycroft branches: 1.3.4;
Make this more likely to compile with ld.elf_so changes. (But this is
untested.)
 1.2  25-Oct-1999  kleink Update to match new SVR4-style definition names in <sys/exec_elf.h>.
 1.1  25-Mar-1998  mhitch branches: 1.1.2; 1.1.6;
Add support for mips.
 1.1.6.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.2.1  08-May-1998  mycroft Sync with trunk, per request of mycroft.
 1.3.4.1  09-Dec-2001  he Pull up revisions 1.4-1.5 (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.5.2.1  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.52.20.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.53.10.3  19-Aug-2010  matt Define the GOT1 mask in terms of Elf_Addr so that it won't truncate when
used with 64bit addresses.
 1.53.10.2  05-Sep-2009  matt Fix some BIG_ENDIAN botches.
 1.53.10.1  05-Sep-2009  matt Make ld.elf_so understand the "unique" way MIPS encodes 64 relocation entries.
With this change, dynamic N64 images with shared libraries work.
 1.53.4.2  19-Mar-2012  bouyer Apply patch, requested by skrll in ticket #1724
libexec/ld.elf_so/arch/mips/mips_reloc.c patch
fix gcc uninitialized warning
 1.53.4.1  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.62.22.1  06-Mar-2016  martin Catch up to -current, via patch, requested by christos in ticket #1126:
 1.65.8.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.72.6.1  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.72.4.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.74.6.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
 1.75.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed