History log of /netbsd-current/libexec/ld.elf_so/arch/sparc/mdreloc.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.58 24-Sep-2023 martin

Fix debug code


# 1.57 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.56 02-Jun-2023 andvar

follow the steps of Andrew Doran (ad) commit and fix more s/loose/lose/ typos.
also s/beyound/beyond/ and few others along the way, mainly in comments.


Revision tags: netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407
# 1.55 03-Apr-2018 joerg

branches: 1.55.4; 1.55.12;
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.


Revision tags: pgoyette-compat-0330
# 1.54 29-Mar-2018 joerg

Move the complex logic for dynamically writing branches from ld.elf_so
into a header for reuse in crt0.o for static ifunc support. Change the
existing logic for sparc64 to use the Bicc variant of ba,a as it allows
+-8MB displacement compared to the BPcc variant's +-1MB. Teach the sparc
variant the same trick for using ba,a and not sethi+jmp when possible.


# 1.53 25-Mar-2018 joerg

Don't skip PLT processing for the main binary. It can still contain
ifunc references.


Revision tags: pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.52 12-Aug-2017 joerg

branches: 1.52.2;
Add sparc/sparc64 support for irelative relocations.


# 1.51 10-Aug-2017 joerg

Add IRELATIVE support for ARM, X86 and PowerPC.


Revision tags: perseant-stdc-iso10646-base
# 1.50 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.49 15-Jun-2017 joerg

Fix indentation.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.48 25-Aug-2014 joerg

branches: 1.48.8;
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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.47 31-Mar-2011 nakayama

branches: 1.47.22;
Add missing comma.


# 1.46 30-Mar-2011 martin

Add support for TLS relocations


# 1.45 25-Mar-2011 joerg

Add basic locking to ld.elf_so.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.44 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.43 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@


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.42 16-Mar-2009 lukem

Fix const issues (cast const pointers to "const uint8_t *" instead of "caddr_t")

NOTE: change based on ../i386/mdreloc.c 1.27
XXX: not compile tested


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 24-Jul-2008 matt

branches: 1.41.4; 1.41.6;
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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.40 28-Apr-2008 martin

branches: 1.40.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 20-May-2006 mrg

branches: 1.39.18;
in _rtld_bind() initialise result to appease GCC4.


# 1.38 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.37 20-Aug-2005 skrll

Add __RCSID.


# 1.36 15-Aug-2005 skrll

KNF


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.35 09-Jan-2005 martin

Add LD_BIND_NOW support for sparc and remove some relocation types that
are not supposed to happen in 32bit code.
From Nick Hudson.


# 1.34 05-Jan-2005 martin

Add support for unaligned relocs on sparc, from PR 26858.
Should also fix PR 25901 and PR 18296.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.33 24-Jul-2003 skrll

branches: 1.33.4;
ANSIfy and de-__P().


Revision tags: fvdl_fs64_base
# 1.32 26-Sep-2002 mycroft

Remove the `self' args to _rtld_relocate_objects() and
_rtld_relocate_nonplt_objects().


# 1.31 26-Sep-2002 mycroft

Remove a meaningless bit from a rdbg().


# 1.30 26-Sep-2002 mycroft

Make the stack frame 96 bytes, like GCC does.


# 1.29 26-Sep-2002 mycroft

Tweak the save instruction in the PLT stub rather than adding an instruction
to the binder entry stub...


# 1.28 25-Sep-2002 mycroft

For consistency, use Elf_Word* to point to code, not Elf_Addr*.


# 1.27 25-Sep-2002 mycroft

Push the _rtld_bind() interface into MD code -- it's just a trivial wrapper
anyway.


# 1.26 12-Sep-2002 mycroft

Nuke -DRTLD_RELOCATE_SELF and `dodebug' from orbit.


# 1.25 12-Sep-2002 mycroft

_rtld_bind_start() is not used in MI code, so declare it in the MD code.


# 1.24 11-Sep-2002 mycroft

Do the _rtld_relocate_nonplt_self() thing for SPARC.


# 1.23 09-Sep-2002 mycroft

Nuke RTLD_RELOCATE_SELF for SPARC.


# 1.22 06-Sep-2002 mycroft

Expand the comment about the R_TYPE(RELATIVE) special-case, as it's not quite
obvious from the code. Also, just do it all the time, as an optimization.


# 1.21 06-Sep-2002 mycroft

Make the reloc tables const.


# 1.20 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.19 06-Sep-2002 mycroft

Re-poison a lot of consts, now that the mark shite is gone.


# 1.18 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.17 06-Sep-2002 mycroft

Repair a slight biff I made earlier -- do not exit the loop in
_rtld_relocate_nonplt_objects() early.


# 1.16 05-Sep-2002 mycroft

Partially fix up some debug printf()s that don't need to use defobj.


# 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

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.13 05-Sep-2002 mycroft

Split _rtld_relocate_nonplt_object() into separate MD files.


# 1.12 05-Sep-2002 junyoung

Remove unused arguments of _rtld_find_symdef().


# 1.11 05-Sep-2002 mycroft

Make _rtld_setup_pltgot() a consistent interface on all platforms.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.10 25-Apr-2001 kleink

branches: 1.10.2;
Sync with <sys/exec_elf.h> rev. 1.45: ElfNN_RelA -> ElfNN_Rela.


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.9 07-Nov-1999 mycroft

branches: 1.9.4;
Make this more likely to compile with ld.elf_so changes. (But this is
untested.)


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.8 01-Mar-1999 christos

branches: 1.8.6;
fix rdbg macro args.


# 1.7 01-Mar-1999 christos

KNF


# 1.6 27-Feb-1999 pk

* Make changing the PLT slot entry (lazy function binding) thread-safe.
* Insert `iflush' instructions for the patched words in PLT entries.


# 1.5 27-Feb-1999 pk

Add comment on the necessity of having to look at implicit memory addends
even though the sparc architecture uses `Elf_Rela' structures exclusively.


# 1.4 27-Feb-1999 pk

Target bitmask for RELOC_RELATIVE should be a full word.
Also for RELOC_RELATIVEs, add in the memory contents in addition to r_addend.


# 1.3 26-Feb-1999 christos

Relative relocations should use addend.


# 1.2 26-Feb-1999 pk

Take care of `load address relative' relocations.
Ignore JMP_SLOTs in non-plt relocations.


# 1.1 24-Feb-1999 christos

Work in progress (does not work yet).


# 1.57 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.56 02-Jun-2023 andvar

follow the steps of Andrew Doran (ad) commit and fix more s/loose/lose/ typos.
also s/beyound/beyond/ and few others along the way, mainly in comments.


Revision tags: netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407
# 1.55 03-Apr-2018 joerg

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.


Revision tags: pgoyette-compat-0330
# 1.54 29-Mar-2018 joerg

Move the complex logic for dynamically writing branches from ld.elf_so
into a header for reuse in crt0.o for static ifunc support. Change the
existing logic for sparc64 to use the Bicc variant of ba,a as it allows
+-8MB displacement compared to the BPcc variant's +-1MB. Teach the sparc
variant the same trick for using ba,a and not sethi+jmp when possible.


# 1.53 25-Mar-2018 joerg

Don't skip PLT processing for the main binary. It can still contain
ifunc references.


Revision tags: pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.52 12-Aug-2017 joerg

branches: 1.52.2;
Add sparc/sparc64 support for irelative relocations.


# 1.51 10-Aug-2017 joerg

Add IRELATIVE support for ARM, X86 and PowerPC.


Revision tags: perseant-stdc-iso10646-base
# 1.50 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.49 15-Jun-2017 joerg

Fix indentation.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.48 25-Aug-2014 joerg

branches: 1.48.8;
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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.47 31-Mar-2011 nakayama

branches: 1.47.22;
Add missing comma.


# 1.46 30-Mar-2011 martin

Add support for TLS relocations


# 1.45 25-Mar-2011 joerg

Add basic locking to ld.elf_so.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.44 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.43 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@


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.42 16-Mar-2009 lukem

Fix const issues (cast const pointers to "const uint8_t *" instead of "caddr_t")

NOTE: change based on ../i386/mdreloc.c 1.27
XXX: not compile tested


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 24-Jul-2008 matt

branches: 1.41.4; 1.41.6;
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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.40 28-Apr-2008 martin

branches: 1.40.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 20-May-2006 mrg

branches: 1.39.18;
in _rtld_bind() initialise result to appease GCC4.


# 1.38 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.37 20-Aug-2005 skrll

Add __RCSID.


# 1.36 15-Aug-2005 skrll

KNF


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.35 09-Jan-2005 martin

Add LD_BIND_NOW support for sparc and remove some relocation types that
are not supposed to happen in 32bit code.
From Nick Hudson.


# 1.34 05-Jan-2005 martin

Add support for unaligned relocs on sparc, from PR 26858.
Should also fix PR 25901 and PR 18296.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.33 24-Jul-2003 skrll

branches: 1.33.4;
ANSIfy and de-__P().


Revision tags: fvdl_fs64_base
# 1.32 26-Sep-2002 mycroft

Remove the `self' args to _rtld_relocate_objects() and
_rtld_relocate_nonplt_objects().


# 1.31 26-Sep-2002 mycroft

Remove a meaningless bit from a rdbg().


# 1.30 26-Sep-2002 mycroft

Make the stack frame 96 bytes, like GCC does.


# 1.29 26-Sep-2002 mycroft

Tweak the save instruction in the PLT stub rather than adding an instruction
to the binder entry stub...


# 1.28 25-Sep-2002 mycroft

For consistency, use Elf_Word* to point to code, not Elf_Addr*.


# 1.27 25-Sep-2002 mycroft

Push the _rtld_bind() interface into MD code -- it's just a trivial wrapper
anyway.


# 1.26 12-Sep-2002 mycroft

Nuke -DRTLD_RELOCATE_SELF and `dodebug' from orbit.


# 1.25 12-Sep-2002 mycroft

_rtld_bind_start() is not used in MI code, so declare it in the MD code.


# 1.24 11-Sep-2002 mycroft

Do the _rtld_relocate_nonplt_self() thing for SPARC.


# 1.23 09-Sep-2002 mycroft

Nuke RTLD_RELOCATE_SELF for SPARC.


# 1.22 06-Sep-2002 mycroft

Expand the comment about the R_TYPE(RELATIVE) special-case, as it's not quite
obvious from the code. Also, just do it all the time, as an optimization.


# 1.21 06-Sep-2002 mycroft

Make the reloc tables const.


# 1.20 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.19 06-Sep-2002 mycroft

Re-poison a lot of consts, now that the mark shite is gone.


# 1.18 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.17 06-Sep-2002 mycroft

Repair a slight biff I made earlier -- do not exit the loop in
_rtld_relocate_nonplt_objects() early.


# 1.16 05-Sep-2002 mycroft

Partially fix up some debug printf()s that don't need to use defobj.


# 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

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.13 05-Sep-2002 mycroft

Split _rtld_relocate_nonplt_object() into separate MD files.


# 1.12 05-Sep-2002 junyoung

Remove unused arguments of _rtld_find_symdef().


# 1.11 05-Sep-2002 mycroft

Make _rtld_setup_pltgot() a consistent interface on all platforms.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.10 25-Apr-2001 kleink

branches: 1.10.2;
Sync with <sys/exec_elf.h> rev. 1.45: ElfNN_RelA -> ElfNN_Rela.


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.9 07-Nov-1999 mycroft

branches: 1.9.4;
Make this more likely to compile with ld.elf_so changes. (But this is
untested.)


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.8 01-Mar-1999 christos

branches: 1.8.6;
fix rdbg macro args.


# 1.7 01-Mar-1999 christos

KNF


# 1.6 27-Feb-1999 pk

* Make changing the PLT slot entry (lazy function binding) thread-safe.
* Insert `iflush' instructions for the patched words in PLT entries.


# 1.5 27-Feb-1999 pk

Add comment on the necessity of having to look at implicit memory addends
even though the sparc architecture uses `Elf_Rela' structures exclusively.


# 1.4 27-Feb-1999 pk

Target bitmask for RELOC_RELATIVE should be a full word.
Also for RELOC_RELATIVEs, add in the memory contents in addition to r_addend.


# 1.3 26-Feb-1999 christos

Relative relocations should use addend.


# 1.2 26-Feb-1999 pk

Take care of `load address relative' relocations.
Ignore JMP_SLOTs in non-plt relocations.


# 1.1 24-Feb-1999 christos

Work in progress (does not work yet).


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407
# 1.55 03-Apr-2018 joerg

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.


Revision tags: pgoyette-compat-0330
# 1.54 29-Mar-2018 joerg

Move the complex logic for dynamically writing branches from ld.elf_so
into a header for reuse in crt0.o for static ifunc support. Change the
existing logic for sparc64 to use the Bicc variant of ba,a as it allows
+-8MB displacement compared to the BPcc variant's +-1MB. Teach the sparc
variant the same trick for using ba,a and not sethi+jmp when possible.


# 1.53 25-Mar-2018 joerg

Don't skip PLT processing for the main binary. It can still contain
ifunc references.


Revision tags: pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.52 12-Aug-2017 joerg

branches: 1.52.2;
Add sparc/sparc64 support for irelative relocations.


# 1.51 10-Aug-2017 joerg

Add IRELATIVE support for ARM, X86 and PowerPC.


Revision tags: perseant-stdc-iso10646-base
# 1.50 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.49 15-Jun-2017 joerg

Fix indentation.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.48 25-Aug-2014 joerg

branches: 1.48.8;
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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.47 31-Mar-2011 nakayama

branches: 1.47.22;
Add missing comma.


# 1.46 30-Mar-2011 martin

Add support for TLS relocations


# 1.45 25-Mar-2011 joerg

Add basic locking to ld.elf_so.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.44 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.43 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@


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.42 16-Mar-2009 lukem

Fix const issues (cast const pointers to "const uint8_t *" instead of "caddr_t")

NOTE: change based on ../i386/mdreloc.c 1.27
XXX: not compile tested


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 24-Jul-2008 matt

branches: 1.41.4; 1.41.6;
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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.40 28-Apr-2008 martin

branches: 1.40.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 20-May-2006 mrg

branches: 1.39.18;
in _rtld_bind() initialise result to appease GCC4.


# 1.38 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.37 20-Aug-2005 skrll

Add __RCSID.


# 1.36 15-Aug-2005 skrll

KNF


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.35 09-Jan-2005 martin

Add LD_BIND_NOW support for sparc and remove some relocation types that
are not supposed to happen in 32bit code.
From Nick Hudson.


# 1.34 05-Jan-2005 martin

Add support for unaligned relocs on sparc, from PR 26858.
Should also fix PR 25901 and PR 18296.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.33 24-Jul-2003 skrll

branches: 1.33.4;
ANSIfy and de-__P().


Revision tags: fvdl_fs64_base
# 1.32 26-Sep-2002 mycroft

Remove the `self' args to _rtld_relocate_objects() and
_rtld_relocate_nonplt_objects().


# 1.31 26-Sep-2002 mycroft

Remove a meaningless bit from a rdbg().


# 1.30 26-Sep-2002 mycroft

Make the stack frame 96 bytes, like GCC does.


# 1.29 26-Sep-2002 mycroft

Tweak the save instruction in the PLT stub rather than adding an instruction
to the binder entry stub...


# 1.28 25-Sep-2002 mycroft

For consistency, use Elf_Word* to point to code, not Elf_Addr*.


# 1.27 25-Sep-2002 mycroft

Push the _rtld_bind() interface into MD code -- it's just a trivial wrapper
anyway.


# 1.26 12-Sep-2002 mycroft

Nuke -DRTLD_RELOCATE_SELF and `dodebug' from orbit.


# 1.25 12-Sep-2002 mycroft

_rtld_bind_start() is not used in MI code, so declare it in the MD code.


# 1.24 11-Sep-2002 mycroft

Do the _rtld_relocate_nonplt_self() thing for SPARC.


# 1.23 09-Sep-2002 mycroft

Nuke RTLD_RELOCATE_SELF for SPARC.


# 1.22 06-Sep-2002 mycroft

Expand the comment about the R_TYPE(RELATIVE) special-case, as it's not quite
obvious from the code. Also, just do it all the time, as an optimization.


# 1.21 06-Sep-2002 mycroft

Make the reloc tables const.


# 1.20 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.19 06-Sep-2002 mycroft

Re-poison a lot of consts, now that the mark shite is gone.


# 1.18 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.17 06-Sep-2002 mycroft

Repair a slight biff I made earlier -- do not exit the loop in
_rtld_relocate_nonplt_objects() early.


# 1.16 05-Sep-2002 mycroft

Partially fix up some debug printf()s that don't need to use defobj.


# 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

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.13 05-Sep-2002 mycroft

Split _rtld_relocate_nonplt_object() into separate MD files.


# 1.12 05-Sep-2002 junyoung

Remove unused arguments of _rtld_find_symdef().


# 1.11 05-Sep-2002 mycroft

Make _rtld_setup_pltgot() a consistent interface on all platforms.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.10 25-Apr-2001 kleink

branches: 1.10.2;
Sync with <sys/exec_elf.h> rev. 1.45: ElfNN_RelA -> ElfNN_Rela.


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.9 07-Nov-1999 mycroft

branches: 1.9.4;
Make this more likely to compile with ld.elf_so changes. (But this is
untested.)


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.8 01-Mar-1999 christos

branches: 1.8.6;
fix rdbg macro args.


# 1.7 01-Mar-1999 christos

KNF


# 1.6 27-Feb-1999 pk

* Make changing the PLT slot entry (lazy function binding) thread-safe.
* Insert `iflush' instructions for the patched words in PLT entries.


# 1.5 27-Feb-1999 pk

Add comment on the necessity of having to look at implicit memory addends
even though the sparc architecture uses `Elf_Rela' structures exclusively.


# 1.4 27-Feb-1999 pk

Target bitmask for RELOC_RELATIVE should be a full word.
Also for RELOC_RELATIVEs, add in the memory contents in addition to r_addend.


# 1.3 26-Feb-1999 christos

Relative relocations should use addend.


# 1.2 26-Feb-1999 pk

Take care of `load address relative' relocations.
Ignore JMP_SLOTs in non-plt relocations.


# 1.1 24-Feb-1999 christos

Work in progress (does not work yet).


# 1.52 12-Aug-2017 joerg

Add sparc/sparc64 support for irelative relocations.


# 1.51 10-Aug-2017 joerg

Add IRELATIVE support for ARM, X86 and PowerPC.


Revision tags: perseant-stdc-iso10646-base
# 1.50 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.49 15-Jun-2017 joerg

Fix indentation.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.48 25-Aug-2014 joerg

branches: 1.48.8;
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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.47 31-Mar-2011 nakayama

branches: 1.47.22;
Add missing comma.


# 1.46 30-Mar-2011 martin

Add support for TLS relocations


# 1.45 25-Mar-2011 joerg

Add basic locking to ld.elf_so.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.44 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.43 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@


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.42 16-Mar-2009 lukem

Fix const issues (cast const pointers to "const uint8_t *" instead of "caddr_t")

NOTE: change based on ../i386/mdreloc.c 1.27
XXX: not compile tested


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 24-Jul-2008 matt

branches: 1.41.4; 1.41.6;
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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.40 28-Apr-2008 martin

branches: 1.40.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 20-May-2006 mrg

branches: 1.39.18;
in _rtld_bind() initialise result to appease GCC4.


# 1.38 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.37 20-Aug-2005 skrll

Add __RCSID.


# 1.36 15-Aug-2005 skrll

KNF


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.35 09-Jan-2005 martin

Add LD_BIND_NOW support for sparc and remove some relocation types that
are not supposed to happen in 32bit code.
From Nick Hudson.


# 1.34 05-Jan-2005 martin

Add support for unaligned relocs on sparc, from PR 26858.
Should also fix PR 25901 and PR 18296.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.33 24-Jul-2003 skrll

branches: 1.33.4;
ANSIfy and de-__P().


Revision tags: fvdl_fs64_base
# 1.32 26-Sep-2002 mycroft

Remove the `self' args to _rtld_relocate_objects() and
_rtld_relocate_nonplt_objects().


# 1.31 26-Sep-2002 mycroft

Remove a meaningless bit from a rdbg().


# 1.30 26-Sep-2002 mycroft

Make the stack frame 96 bytes, like GCC does.


# 1.29 26-Sep-2002 mycroft

Tweak the save instruction in the PLT stub rather than adding an instruction
to the binder entry stub...


# 1.28 25-Sep-2002 mycroft

For consistency, use Elf_Word* to point to code, not Elf_Addr*.


# 1.27 25-Sep-2002 mycroft

Push the _rtld_bind() interface into MD code -- it's just a trivial wrapper
anyway.


# 1.26 12-Sep-2002 mycroft

Nuke -DRTLD_RELOCATE_SELF and `dodebug' from orbit.


# 1.25 12-Sep-2002 mycroft

_rtld_bind_start() is not used in MI code, so declare it in the MD code.


# 1.24 11-Sep-2002 mycroft

Do the _rtld_relocate_nonplt_self() thing for SPARC.


# 1.23 09-Sep-2002 mycroft

Nuke RTLD_RELOCATE_SELF for SPARC.


# 1.22 06-Sep-2002 mycroft

Expand the comment about the R_TYPE(RELATIVE) special-case, as it's not quite
obvious from the code. Also, just do it all the time, as an optimization.


# 1.21 06-Sep-2002 mycroft

Make the reloc tables const.


# 1.20 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.19 06-Sep-2002 mycroft

Re-poison a lot of consts, now that the mark shite is gone.


# 1.18 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.17 06-Sep-2002 mycroft

Repair a slight biff I made earlier -- do not exit the loop in
_rtld_relocate_nonplt_objects() early.


# 1.16 05-Sep-2002 mycroft

Partially fix up some debug printf()s that don't need to use defobj.


# 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

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.13 05-Sep-2002 mycroft

Split _rtld_relocate_nonplt_object() into separate MD files.


# 1.12 05-Sep-2002 junyoung

Remove unused arguments of _rtld_find_symdef().


# 1.11 05-Sep-2002 mycroft

Make _rtld_setup_pltgot() a consistent interface on all platforms.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.10 25-Apr-2001 kleink

branches: 1.10.2;
Sync with <sys/exec_elf.h> rev. 1.45: ElfNN_RelA -> ElfNN_Rela.


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.9 07-Nov-1999 mycroft

branches: 1.9.4;
Make this more likely to compile with ld.elf_so changes. (But this is
untested.)


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.8 01-Mar-1999 christos

branches: 1.8.6;
fix rdbg macro args.


# 1.7 01-Mar-1999 christos

KNF


# 1.6 27-Feb-1999 pk

* Make changing the PLT slot entry (lazy function binding) thread-safe.
* Insert `iflush' instructions for the patched words in PLT entries.


# 1.5 27-Feb-1999 pk

Add comment on the necessity of having to look at implicit memory addends
even though the sparc architecture uses `Elf_Rela' structures exclusively.


# 1.4 27-Feb-1999 pk

Target bitmask for RELOC_RELATIVE should be a full word.
Also for RELOC_RELATIVEs, add in the memory contents in addition to r_addend.


# 1.3 26-Feb-1999 christos

Relative relocations should use addend.


# 1.2 26-Feb-1999 pk

Take care of `load address relative' relocations.
Ignore JMP_SLOTs in non-plt relocations.


# 1.1 24-Feb-1999 christos

Work in progress (does not work yet).


# 1.51 10-Aug-2017 joerg

Add IRELATIVE support for ARM, X86 and PowerPC.


Revision tags: perseant-stdc-iso10646-base
# 1.50 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.49 15-Jun-2017 joerg

Fix indentation.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.48 25-Aug-2014 joerg

branches: 1.48.8;
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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.47 31-Mar-2011 nakayama

branches: 1.47.22;
Add missing comma.


# 1.46 30-Mar-2011 martin

Add support for TLS relocations


# 1.45 25-Mar-2011 joerg

Add basic locking to ld.elf_so.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.44 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.43 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@


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.42 16-Mar-2009 lukem

Fix const issues (cast const pointers to "const uint8_t *" instead of "caddr_t")

NOTE: change based on ../i386/mdreloc.c 1.27
XXX: not compile tested


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 24-Jul-2008 matt

branches: 1.41.4; 1.41.6;
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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.40 28-Apr-2008 martin

branches: 1.40.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 20-May-2006 mrg

branches: 1.39.18;
in _rtld_bind() initialise result to appease GCC4.


# 1.38 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.37 20-Aug-2005 skrll

Add __RCSID.


# 1.36 15-Aug-2005 skrll

KNF


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.35 09-Jan-2005 martin

Add LD_BIND_NOW support for sparc and remove some relocation types that
are not supposed to happen in 32bit code.
From Nick Hudson.


# 1.34 05-Jan-2005 martin

Add support for unaligned relocs on sparc, from PR 26858.
Should also fix PR 25901 and PR 18296.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.33 24-Jul-2003 skrll

branches: 1.33.4;
ANSIfy and de-__P().


Revision tags: fvdl_fs64_base
# 1.32 26-Sep-2002 mycroft

Remove the `self' args to _rtld_relocate_objects() and
_rtld_relocate_nonplt_objects().


# 1.31 26-Sep-2002 mycroft

Remove a meaningless bit from a rdbg().


# 1.30 26-Sep-2002 mycroft

Make the stack frame 96 bytes, like GCC does.


# 1.29 26-Sep-2002 mycroft

Tweak the save instruction in the PLT stub rather than adding an instruction
to the binder entry stub...


# 1.28 25-Sep-2002 mycroft

For consistency, use Elf_Word* to point to code, not Elf_Addr*.


# 1.27 25-Sep-2002 mycroft

Push the _rtld_bind() interface into MD code -- it's just a trivial wrapper
anyway.


# 1.26 12-Sep-2002 mycroft

Nuke -DRTLD_RELOCATE_SELF and `dodebug' from orbit.


# 1.25 12-Sep-2002 mycroft

_rtld_bind_start() is not used in MI code, so declare it in the MD code.


# 1.24 11-Sep-2002 mycroft

Do the _rtld_relocate_nonplt_self() thing for SPARC.


# 1.23 09-Sep-2002 mycroft

Nuke RTLD_RELOCATE_SELF for SPARC.


# 1.22 06-Sep-2002 mycroft

Expand the comment about the R_TYPE(RELATIVE) special-case, as it's not quite
obvious from the code. Also, just do it all the time, as an optimization.


# 1.21 06-Sep-2002 mycroft

Make the reloc tables const.


# 1.20 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.19 06-Sep-2002 mycroft

Re-poison a lot of consts, now that the mark shite is gone.


# 1.18 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.17 06-Sep-2002 mycroft

Repair a slight biff I made earlier -- do not exit the loop in
_rtld_relocate_nonplt_objects() early.


# 1.16 05-Sep-2002 mycroft

Partially fix up some debug printf()s that don't need to use defobj.


# 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

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.13 05-Sep-2002 mycroft

Split _rtld_relocate_nonplt_object() into separate MD files.


# 1.12 05-Sep-2002 junyoung

Remove unused arguments of _rtld_find_symdef().


# 1.11 05-Sep-2002 mycroft

Make _rtld_setup_pltgot() a consistent interface on all platforms.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.10 25-Apr-2001 kleink

branches: 1.10.2;
Sync with <sys/exec_elf.h> rev. 1.45: ElfNN_RelA -> ElfNN_Rela.


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.9 07-Nov-1999 mycroft

branches: 1.9.4;
Make this more likely to compile with ld.elf_so changes. (But this is
untested.)


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.8 01-Mar-1999 christos

branches: 1.8.6;
fix rdbg macro args.


# 1.7 01-Mar-1999 christos

KNF


# 1.6 27-Feb-1999 pk

* Make changing the PLT slot entry (lazy function binding) thread-safe.
* Insert `iflush' instructions for the patched words in PLT entries.


# 1.5 27-Feb-1999 pk

Add comment on the necessity of having to look at implicit memory addends
even though the sparc architecture uses `Elf_Rela' structures exclusively.


# 1.4 27-Feb-1999 pk

Target bitmask for RELOC_RELATIVE should be a full word.
Also for RELOC_RELATIVEs, add in the memory contents in addition to r_addend.


# 1.3 26-Feb-1999 christos

Relative relocations should use addend.


# 1.2 26-Feb-1999 pk

Take care of `load address relative' relocations.
Ignore JMP_SLOTs in non-plt relocations.


# 1.1 24-Feb-1999 christos

Work in progress (does not work yet).


# 1.50 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.49 15-Jun-2017 joerg

Fix indentation.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.48 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.47 31-Mar-2011 nakayama

branches: 1.47.22;
Add missing comma.


# 1.46 30-Mar-2011 martin

Add support for TLS relocations


# 1.45 25-Mar-2011 joerg

Add basic locking to ld.elf_so.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.44 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.43 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@


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.42 16-Mar-2009 lukem

Fix const issues (cast const pointers to "const uint8_t *" instead of "caddr_t")

NOTE: change based on ../i386/mdreloc.c 1.27
XXX: not compile tested


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 24-Jul-2008 matt

branches: 1.41.4; 1.41.6;
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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.40 28-Apr-2008 martin

branches: 1.40.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 20-May-2006 mrg

branches: 1.39.18;
in _rtld_bind() initialise result to appease GCC4.


# 1.38 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.37 20-Aug-2005 skrll

Add __RCSID.


# 1.36 15-Aug-2005 skrll

KNF


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.35 09-Jan-2005 martin

Add LD_BIND_NOW support for sparc and remove some relocation types that
are not supposed to happen in 32bit code.
From Nick Hudson.


# 1.34 05-Jan-2005 martin

Add support for unaligned relocs on sparc, from PR 26858.
Should also fix PR 25901 and PR 18296.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.33 24-Jul-2003 skrll

branches: 1.33.4;
ANSIfy and de-__P().


Revision tags: fvdl_fs64_base
# 1.32 26-Sep-2002 mycroft

Remove the `self' args to _rtld_relocate_objects() and
_rtld_relocate_nonplt_objects().


# 1.31 26-Sep-2002 mycroft

Remove a meaningless bit from a rdbg().


# 1.30 26-Sep-2002 mycroft

Make the stack frame 96 bytes, like GCC does.


# 1.29 26-Sep-2002 mycroft

Tweak the save instruction in the PLT stub rather than adding an instruction
to the binder entry stub...


# 1.28 25-Sep-2002 mycroft

For consistency, use Elf_Word* to point to code, not Elf_Addr*.


# 1.27 25-Sep-2002 mycroft

Push the _rtld_bind() interface into MD code -- it's just a trivial wrapper
anyway.


# 1.26 12-Sep-2002 mycroft

Nuke -DRTLD_RELOCATE_SELF and `dodebug' from orbit.


# 1.25 12-Sep-2002 mycroft

_rtld_bind_start() is not used in MI code, so declare it in the MD code.


# 1.24 11-Sep-2002 mycroft

Do the _rtld_relocate_nonplt_self() thing for SPARC.


# 1.23 09-Sep-2002 mycroft

Nuke RTLD_RELOCATE_SELF for SPARC.


# 1.22 06-Sep-2002 mycroft

Expand the comment about the R_TYPE(RELATIVE) special-case, as it's not quite
obvious from the code. Also, just do it all the time, as an optimization.


# 1.21 06-Sep-2002 mycroft

Make the reloc tables const.


# 1.20 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.19 06-Sep-2002 mycroft

Re-poison a lot of consts, now that the mark shite is gone.


# 1.18 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.17 06-Sep-2002 mycroft

Repair a slight biff I made earlier -- do not exit the loop in
_rtld_relocate_nonplt_objects() early.


# 1.16 05-Sep-2002 mycroft

Partially fix up some debug printf()s that don't need to use defobj.


# 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

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.13 05-Sep-2002 mycroft

Split _rtld_relocate_nonplt_object() into separate MD files.


# 1.12 05-Sep-2002 junyoung

Remove unused arguments of _rtld_find_symdef().


# 1.11 05-Sep-2002 mycroft

Make _rtld_setup_pltgot() a consistent interface on all platforms.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.10 25-Apr-2001 kleink

branches: 1.10.2;
Sync with <sys/exec_elf.h> rev. 1.45: ElfNN_RelA -> ElfNN_Rela.


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.9 07-Nov-1999 mycroft

branches: 1.9.4;
Make this more likely to compile with ld.elf_so changes. (But this is
untested.)


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.8 01-Mar-1999 christos

branches: 1.8.6;
fix rdbg macro args.


# 1.7 01-Mar-1999 christos

KNF


# 1.6 27-Feb-1999 pk

* Make changing the PLT slot entry (lazy function binding) thread-safe.
* Insert `iflush' instructions for the patched words in PLT entries.


# 1.5 27-Feb-1999 pk

Add comment on the necessity of having to look at implicit memory addends
even though the sparc architecture uses `Elf_Rela' structures exclusively.


# 1.4 27-Feb-1999 pk

Target bitmask for RELOC_RELATIVE should be a full word.
Also for RELOC_RELATIVEs, add in the memory contents in addition to r_addend.


# 1.3 26-Feb-1999 christos

Relative relocations should use addend.


# 1.2 26-Feb-1999 pk

Take care of `load address relative' relocations.
Ignore JMP_SLOTs in non-plt relocations.


# 1.1 24-Feb-1999 christos

Work in progress (does not work yet).


# 1.49 15-Jun-2017 joerg

Fix indentation.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.48 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.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.47 31-Mar-2011 nakayama

branches: 1.47.22;
Add missing comma.


# 1.46 30-Mar-2011 martin

Add support for TLS relocations


# 1.45 25-Mar-2011 joerg

Add basic locking to ld.elf_so.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.44 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.43 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@


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.42 16-Mar-2009 lukem

Fix const issues (cast const pointers to "const uint8_t *" instead of "caddr_t")

NOTE: change based on ../i386/mdreloc.c 1.27
XXX: not compile tested


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 24-Jul-2008 matt

branches: 1.41.4; 1.41.6;
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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.40 28-Apr-2008 martin

branches: 1.40.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 20-May-2006 mrg

branches: 1.39.18;
in _rtld_bind() initialise result to appease GCC4.


# 1.38 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.37 20-Aug-2005 skrll

Add __RCSID.


# 1.36 15-Aug-2005 skrll

KNF


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.35 09-Jan-2005 martin

Add LD_BIND_NOW support for sparc and remove some relocation types that
are not supposed to happen in 32bit code.
From Nick Hudson.


# 1.34 05-Jan-2005 martin

Add support for unaligned relocs on sparc, from PR 26858.
Should also fix PR 25901 and PR 18296.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.33 24-Jul-2003 skrll

branches: 1.33.4;
ANSIfy and de-__P().


Revision tags: fvdl_fs64_base
# 1.32 26-Sep-2002 mycroft

Remove the `self' args to _rtld_relocate_objects() and
_rtld_relocate_nonplt_objects().


# 1.31 26-Sep-2002 mycroft

Remove a meaningless bit from a rdbg().


# 1.30 26-Sep-2002 mycroft

Make the stack frame 96 bytes, like GCC does.


# 1.29 26-Sep-2002 mycroft

Tweak the save instruction in the PLT stub rather than adding an instruction
to the binder entry stub...


# 1.28 25-Sep-2002 mycroft

For consistency, use Elf_Word* to point to code, not Elf_Addr*.


# 1.27 25-Sep-2002 mycroft

Push the _rtld_bind() interface into MD code -- it's just a trivial wrapper
anyway.


# 1.26 12-Sep-2002 mycroft

Nuke -DRTLD_RELOCATE_SELF and `dodebug' from orbit.


# 1.25 12-Sep-2002 mycroft

_rtld_bind_start() is not used in MI code, so declare it in the MD code.


# 1.24 11-Sep-2002 mycroft

Do the _rtld_relocate_nonplt_self() thing for SPARC.


# 1.23 09-Sep-2002 mycroft

Nuke RTLD_RELOCATE_SELF for SPARC.


# 1.22 06-Sep-2002 mycroft

Expand the comment about the R_TYPE(RELATIVE) special-case, as it's not quite
obvious from the code. Also, just do it all the time, as an optimization.


# 1.21 06-Sep-2002 mycroft

Make the reloc tables const.


# 1.20 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.19 06-Sep-2002 mycroft

Re-poison a lot of consts, now that the mark shite is gone.


# 1.18 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.17 06-Sep-2002 mycroft

Repair a slight biff I made earlier -- do not exit the loop in
_rtld_relocate_nonplt_objects() early.


# 1.16 05-Sep-2002 mycroft

Partially fix up some debug printf()s that don't need to use defobj.


# 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

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.13 05-Sep-2002 mycroft

Split _rtld_relocate_nonplt_object() into separate MD files.


# 1.12 05-Sep-2002 junyoung

Remove unused arguments of _rtld_find_symdef().


# 1.11 05-Sep-2002 mycroft

Make _rtld_setup_pltgot() a consistent interface on all platforms.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.10 25-Apr-2001 kleink

branches: 1.10.2;
Sync with <sys/exec_elf.h> rev. 1.45: ElfNN_RelA -> ElfNN_Rela.


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.9 07-Nov-1999 mycroft

branches: 1.9.4;
Make this more likely to compile with ld.elf_so changes. (But this is
untested.)


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.8 01-Mar-1999 christos

branches: 1.8.6;
fix rdbg macro args.


# 1.7 01-Mar-1999 christos

KNF


# 1.6 27-Feb-1999 pk

* Make changing the PLT slot entry (lazy function binding) thread-safe.
* Insert `iflush' instructions for the patched words in PLT entries.


# 1.5 27-Feb-1999 pk

Add comment on the necessity of having to look at implicit memory addends
even though the sparc architecture uses `Elf_Rela' structures exclusively.


# 1.4 27-Feb-1999 pk

Target bitmask for RELOC_RELATIVE should be a full word.
Also for RELOC_RELATIVEs, add in the memory contents in addition to r_addend.


# 1.3 26-Feb-1999 christos

Relative relocations should use addend.


# 1.2 26-Feb-1999 pk

Take care of `load address relative' relocations.
Ignore JMP_SLOTs in non-plt relocations.


# 1.1 24-Feb-1999 christos

Work in progress (does not work yet).