History log of /seL4-test-master/projects/musllibc/src/internal/dynlink.h
Revision Date Author Comments
# 71392a91 06-Mar-2016 Rich Felker <dalias@aerifal.cx>

generalize mips-specific reloc code not to hard-code sym/type encoding

this change is made in preparation for adding the mips64 port, which
needs a 64-bit (and mips64-specific) form of the R_INFO macro, but
it's a better abstraction anyway.

based on part of the mips64 port patch by Mahesh Bodapati and Jaydeep
Patil of Imagination Technologies.


# c18d05f0 30-Jan-2016 Felix Fietkau <nbd@openwrt.org>

ldso: fix GDB dynamic linker info on MIPS

GDB is looking for a pointer to the ldso debug info in the data of the
..rld_map section.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>


# 9439ebd7 11-Nov-2015 Rich Felker <dalias@aerifal.cx>

fix dynamic loader library mapping for nommu systems

on linux/nommu, non-writable private mappings of files may actually
use memory shared with other processes or the fs cache. the old nommu
loader code (used when mmap with MAP_FIXED fails) simply wrote over
top of the original file mapping, possibly clobbering this shared
memory. no such breakage was observed in practice, but it should have
been possible.

the new code starts by mapping anonymous writable memory on archs that
might support nommu, then maps load segments over top of it, falling
back to read if MAP_FIXED fails. we use an anonymous map rather than a
writable file map to avoid reading more data from disk than needed.
since pages cannot be loaded lazily on fault, in case of large
data/bss, mapping the full file may read a lot of data that will
subsequently be thrown away when processing additional LOAD segments.
as a result, we cannot skip the first LOAD segment when operating in
this mode.

these changes affect only non-FDPIC nommu support.


# eaf7ab6e 22-Sep-2015 Rich Felker <dalias@aerifal.cx>

add real fdpic loading of shared libraries

previously, the normal ELF library loading code was used even for
fdpic, so only the kernel-loaded dynamic linker and main app could
benefit from separate placement of segments and shared text.


# 7a9669e9 21-Sep-2015 Rich Felker <dalias@aerifal.cx>

add general fdpic support in dynamic linker and arch support for sh

at this point not all functionality is complete. the dynamic linker
itself, and main app if it is also loaded by the kernel, take
advantage of fdpic and do not need constant displacement between
segments, but additional libraries loaded by the dynamic linker follow
normal ELF semantics for mapping still. this fully works, but does not
admit shared text on nommu.

in terms of actual functional correctness, dlsym's results are
presently incorrect for function symbols, RTLD_NEXT fails to identify
the caller correctly, and dladdr fails almost entirely.

with the dynamic linker entry point working, support for static pie is
automatically included, but linking the main application as ET_DYN
(pie) probably does not make sense for fdpic anyway. ET_EXEC is
equally relocatable but more efficient at representing relocations.


# eb567c12 17-Sep-2015 Rich Felker <dalias@aerifal.cx>

add fdpic structs and reloc types for dynamic linking


# 768b82c6 25-May-2015 Rich Felker <dalias@aerifal.cx>

move call to dynamic linker stage-3 into stage-2 function

this move eliminates a duplicate "by-hand" symbol lookup loop from the
stage-1 code and replaces it with a call to find_sym, which can be
used once we're in stage 2. it reduces the size of the stage 1 code,
which is helpful because stage 1 will become the crt start file for
static-PIE executables, and it will allow stage 3 to access stage 2's
automatic storage, which will be important in an upcoming commit.


# f3ddd173 13-Apr-2015 Rich Felker <dalias@aerifal.cx>

dynamic linker bootstrap overhaul

this overhaul further reduces the amount of arch-specific code needed
by the dynamic linker and removes a number of assumptions, including:

- that symbolic function references inside libc are bound at link time
via the linker option -Bsymbolic-functions.

- that libc functions used by the dynamic linker do not require
access to data symbols.

- that static/internal function calls and data accesses can be made
without performing any relocations, or that arch-specific startup
code handled any such relocations needed.

removing these assumptions paves the way for allowing libc.so itself
to be built with stack protector (among other things), and is achieved
by a three-stage bootstrap process:

1. relative relocations are processed with a flat function.
2. symbolic relocations are processed with no external calls/data.
3. main program and dependency libs are processed with a
fully-functional libc/ldso.

reduction in arch-specific code is achived through the following:

- crt_arch.h, used for generating crt1.o, now provides the entry point
for the dynamic linker too.

- asm is no longer responsible for skipping the beginning of argv[]
when ldso is invoked as a command.

- the functionality previously provided by __reloc_self for heavily
GOT-dependent RISC archs is now the arch-agnostic stage-1.

- arch-specific relocation type codes are mapped directly as macros
rather than via an inline translation function/switch statement.