History log of /seL4-refos-master/libs/libmuslc/arch/i386_sel4/reloc.h
Revision Date Author Comments
# 2907afb8 17-Sep-2015 Rich Felker <dalias@aerifal.cx>

introduce new symbol-lookup-free rcrt1/dlstart stage chaining

previously, the call into stage 2 was made by looking up the symbol
name "__dls2" (which was chosen short to be easy to look up) from the
dynamic symbol table. this was no problem for the dynamic linker,
since it always exports all its symbols. in the case of the static pie
entry point, however, the dynamic symbol table does not contain the
necessary symbol unless -rdynamic/-E was used when linking. this
linking requirement is a major obstacle both to practical use of
static-pie as a nommu binary format (since it greatly enlarges the
file) and to upstream toolchain support for static-pie (adding -E to
default linking specs is not reasonable).

this patch replaces the runtime symbolic lookup with a link-time
lookup via an inline asm fragment, which reloc.h is responsible for
providing. in this initial commit, the asm is provided only for i386,
and the old lookup code is left in place as a fallback for archs that
have not yet transitioned.

modifying crt_arch.h to pass the stage-2 function pointer as an
argument was considered as an alternative, but such an approach would
not be compatible with fdpic, where it's impossible to compute
function pointers without already having performed relocations. it was
also deemed desirable to keep crt_arch.h as simple/minimal as
possible.

in principle, archs with pc-relative or got-relative addressing of
static variables could instead load the stage-2 function pointer from
a static volatile object. that does not work for fdpic, and is not
safe against reordering on mips-like archs that use got slots even for
static functions, but it's a valid on i386 and many others, and could
provide a reasonable default implementation in the future.


# 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.


# 048a4e72 26-Aug-2014 Adrian Danis <Adrian.Danis@nicta.com.au>

Port muslc to seL4 build system and environment. Defines custom 'seL4' architectures for ARM and i386


# 4e0b4a5d 19-Jun-2014 Rich Felker <dalias@aerifal.cx>

add tlsdesc support for i386


# adf94c19 18-Jun-2014 Rich Felker <dalias@aerifal.cx>

refactor to remove arch-specific relocation code from dynamic linker

this was one of the main instances of ugly code duplication: all archs
use basically the same types of relocations, but roughly equivalent
logic was duplicated for each arch to account for the different naming
and numbering of relocation types and variation in whether REL or RELA
records are used.

as an added bonus, both REL and RELA are now supported on all archs,
regardless of which is used by the standard toolchain.


# bfa09700 16-Jun-2014 Rich Felker <dalias@aerifal.cx>

dynamic linker: permit error returns from arch-specific reloc function

the immediate motivation is supporting TLSDESC relocations which
require allocation and thus may fail (unless we pre-allocate), but
this mechanism should also be used for throwing an error on
unsupported or invalid relocation types, and perhaps in certain cases,
for reporting when a relocation is not satisfiable.


# f389c498 18-Jul-2013 Rich Felker <dalias@aerifal.cx>

make the dynamic linker find its path file relative to its own location

prior to this change, using a non-default syslibdir was impractical on
systems where the ordinary library paths contain musl-incompatible
library files. the file containing search paths was always taken from
/etc, which would either correspond to a system-wide musl
installation, or fail to exist at all, resulting in searching of the
default library path.

the new search strategy is safe even for suid programs because the
pathname used comes from the PT_INTERP header of the program being
run, rather than any external input.

as part of this change, I have also begun differentiating the names of
arch variants that differ by endianness or floating point calling
convention. the corresponding changes in the build system and and gcc
wrapper script (to use an alternate dynamic linker name) for these
configurations have not yet been made.


# 9c74856a 04-Oct-2012 Rich Felker <dalias@aerifal.cx>

dynamic-linked TLS support for everything but dlopen'd libs

currently, only i386 is tested. x86_64 and arm should probably work.
the necessary relocation types for mips and microblaze have not been
added because I don't understand how they're supposed to work, and I'm
not even sure if it's defined yet on microblaze. I may be able to
reverse engineer the requirements out of gcc/binutils output.


# 32de61e8 25-Jun-2011 Rich Felker <dalias@aerifal.cx>

fix some symbol resolution issues in dynamic linker

1. search was wrongly beginning with lib itself rather than dso head
2. inconsistent resolution of function pointers for functions in plt


# 568b8075 24-Jun-2011 Rich Felker <dalias@aerifal.cx>

proper path searching for dynamic linker

first, use $LD_LIBRARY_PATH unless suid. if that fails, read path from
/etc/ld-musl-$ARCH.path and fallback to a builtin default.


# 51e2d831 18-Jun-2011 Rich Felker <dalias@aerifal.cx>

experimental dynamic linker!

some notes:
- library search path is hard coded
- x86_64 code is untested and may not work
- dlopen/dlsym is not yet implemented
- relocations in read-only memory won't work