| Commit message (Expand) | Author | Files | Lines |
| 2015-09-22 | move calls to application init functions after crt1 entry point•••this change is needed to be compatible with fdpic, where some of the
main application's relocations may be performed as part of the crt1
entry point. if we call init functions before passing control, these
relocations will not yet have been performed, and the init code will
potentially make use of invalid pointers.
conceptually, no code provided by the application or third-party
libraries should run before the application entry point. the
difference is not observable to programs using the crt1 we provide,
but it could come into play if custom entry point code is used, so
it's better to be doing this right anyway.
| Rich Felker | 2 | -1/+8 |
| 2015-09-22 | fix breakage in non-fdpic dynamic linker init/fini processing•••a mistaken #ifdef instead of #if caused conversion of code addresses
to function descriptors to be performed even on non-fdpic.
| Rich Felker | 1 | -1/+1 |
| 2015-09-22 | fix resolving interp string address on fdpic ldd command | Rich Felker | 1 | -2/+1 |
| 2015-09-22 | 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.
| Rich Felker | 3 | -9/+59 |
| 2015-09-22 | try to suppress linking libc.so if there are undefined symbols•••this is always an error and usually results from failure to find/link
the compiler runtime library, but it could also result from
implementation errors in libc, using functions that don't (yet) exist.
either way the resulting libc.so will crash mysteriously at runtime.
the crash happens too early to produce a meaningful error, so these
crashes are very confusing to users and waste a lot of debugging time.
this commit should ensure that they do not happen.
| Rich Felker | 1 | -0/+6 |
| 2015-09-22 | remove configure's suppression of enable sh/fdpic shared library build | Rich Felker | 1 | -1/+0 |
| 2015-09-22 | size-optimize sh/fdpic dynamic entry point•••the __fdpic_fixup code is not needed for ET_DYN executables, which
instead use reloctions, so we can omit it from the dynamic linker and
static-pie entry point and save some code size.
| Rich Felker | 1 | -0/+4 |
| 2015-09-22 | work around breakage in sh/fdpic __unmapself function•••the C implementation of __unmapself used for potentially-nommu sh
assumed CRTJMP takes a function descriptor rather than a code address;
however, the actual dynamic linker needs a code address, and so commit
7a9669e977e5f750cf72ccbd2614f8b72ce02c4c changed the definition of the
macro in reloc.h. this commit puts the old macro back in a place where
it only affects __unmapself.
this is an ugly workaround and should be cleaned up at some point, but
at least it's well isolated.
| Rich Felker | 1 | -0/+5 |
| 2015-09-22 | 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.
| Rich Felker | 5 | -17/+214 |
| 2015-09-21 | factor symbol counting out of dladdr as its own function•••the fdpic code will need to count symbols, and it may be useful
elsewhere in the future too. counting is trivial as long as sysv hash
is present, but for gnu-hash-only libraries it's complex.
the behavior of the count is changed slightly: we now include symbols
that are not accessible by the gnu hash table in the count. this may
make dladdr slightly slower. if this is a problem, dladdr can subtract
out the part that should not be accessible. unlike in the old code,
subtracting this out is easy even in the fast path where sysv hash is
available too.
| Rich Felker | 1 | -19/+20 |
| 2015-09-21 | simplify dlstart code by using integer type for base address | Rich Felker | 1 | -8/+7 |
| 2015-09-17 | refactor some more dynamic linker load address computations•••these were just missed in the previous commits.
| Rich Felker | 1 | -7/+7 |
| 2015-09-17 | remove some useless casts in dynamic linker | Rich Felker | 1 | -2/+2 |
| 2015-09-17 | add fdpic structs and reloc types for dynamic linking | Rich Felker | 1 | -0/+16 |
| 2015-09-17 | further refactoring of dynamic linker load address computations•••these are in do_relocs. the first one was omitted in commit
301335a80b85f12c018e4acf1a2c28615e119f8d because it slightly changes
code (using dso->base rather than cached local var base) and would
have prevented easy verification. the other was an oversight.
| Rich Felker | 1 | -2/+2 |
| 2015-09-17 | begin refactoring load address computations in dynamic linker•••for ordinary ELF with fixed segment displacements, load address
computation is simply adding the base load address. but for FDPIC,
each segment has its own load address, and virtual addresses need to
be adjusted according to the segment they fall in. abstracting this
computation is the first step to making the dynamic linker ready for
FDPIC.
for this first commit, a macro is used rather than a function in order
to facilitate correctness checking. I have verified that the generated
code does not change on my i386 build.
| Rich Felker | 1 | -19/+22 |
| 2015-09-17 | remove old dlstart stage-2 symbolic lookup code; add new generic•••this new generic version of the stage-2 function lookup should work
for any arch where static data is accessible via got-relative or
pc-relative addressing, using approximately the technique described in
the log message for commit 2907afb8dbd4c1d34825c3c9bd2b41564baca210.
since all the mips-like archs that need got slots fo access static
data have already transitioned to the new stage chaining scheme, the
old dynamic symbol lookup code is now removed.
aarch64, arm, and sh have not yet transitioned; with this commit, they
are now using the new generic code.
| Rich Felker | 1 | -14/+8 |
| 2015-09-17 | new dlstart stage-2 chaining for x86_64 and x32 | Rich Felker | 2 | -0/+10 |
| 2015-09-17 | new dlstart stage-2 chaining for powerpc | Rich Felker | 1 | -0/+9 |
| 2015-09-17 | new dlstart stage-2 chaining for or1k | Rich Felker | 1 | -0/+9 |
| 2015-09-17 | new dlstart stage-2 chaining for mips | Rich Felker | 1 | -0/+15 |
| 2015-09-17 | new dlstart stage-2 chaining for microblaze | Rich Felker | 1 | -0/+7 |
| 2015-09-17 | 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.
| Rich Felker | 2 | -0/+13 |
| 2015-09-17 | remove attribute((const)) from pthread_self and errno location decls•••this attribute was applied to pthread_self and the functions providing
the locations for errno and h_errno as an optimization; however, it is
subtly incorrect. as specified, it means the return value will always
be the same, which is not true; it varies per-thread.
this attribute also implies that the function does not depend on any
state, and that calls to it can safely be reordered across any other
code. however such reordering is unsafe for these functions: they
break when reordered before initialization of the thread pointer. such
breakage was actually observed when compiled by libfirm/cparser.
to some extent the reordering problem could be solved with strong
compiler barriers between the stages of early startup code, but the
specified meaning of of attribute((const)) is sufficiently strong that
a compiler would theoretically be justified inserting gratuitous calls
to attribute((const)) const functions at random locations (e.g. to
save the value in static storage for later use).
this reverts commit cbf35978a9870fb1f5c73a852c986d4fcca6c2d4.
| Rich Felker | 3 | -9/+0 |
| 2015-09-15 | add format argument attributes to gettext function prototypes•••their absence completely breaks format string warnings in programs
with gettext message translations: -Wformat gives no results, and
-Wformat-nonliteral produces spurious warnings.
with gcc, the problem manifests only in standards-conforming profiles;
otherwise gcc sets these attributes by default for the gettext family.
with clang, the problem always manifests; clang has no such defaults.
| Khem Raj | 1 | -6/+14 |
| 2015-09-15 | reindent powerpc's bits/termios.h to be consistent with other archs | Felix Janda | 1 | -140/+138 |
| 2015-09-15 | fix namespace violations in aarch64/bits/termios.h•••in analogy with commit a627eb35864d5c29a3c3300dfe83745ab1e7a00f
| Felix Janda | 1 | -7/+7 |
| 2015-09-12 | add sh fdpic subarch variants•••with this commit it should be possible to produce a working
static-linked fdpic libc and application binaries for sh.
the changes in reloc.h are largely unused at this point since dynamic
linking is not supported, but the CRTJMP macro is used one place
outside of dynamic linking, in __unmapself.
| Rich Felker | 2 | -1/+20 |
| 2015-09-12 | add fdpic version of entry point code for sh•••this version of the entry point is only suitable for static linking in
ET_EXEC form. neither dynamic linking nor pie is supported yet. at
some point in the future the fdpic and non-fdpic versions of this code
may be unified but for now it's easiest to work with them separately.
| Rich Felker | 1 | -0/+29 |