diff options
author | Rich Felker <dalias@aerifal.cx> | 2015-09-17 08:05:34 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2015-09-17 08:16:24 +0000 |
commit | 6fc30c2493fcfedec89e45088bea87766a1e3286 (patch) | |
tree | a059ede244f68ba98f678c84b5bcabf49a44c75b /src | |
parent | 12b0b7d8eab5ec428b779d83bd3c6edad2f31993 (diff) | |
download | musl-6fc30c2493fcfedec89e45088bea87766a1e3286.tar.gz musl-6fc30c2493fcfedec89e45088bea87766a1e3286.tar.bz2 musl-6fc30c2493fcfedec89e45088bea87766a1e3286.tar.xz musl-6fc30c2493fcfedec89e45088bea87766a1e3286.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/ldso/dlstart.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/ldso/dlstart.c b/src/ldso/dlstart.c index eb919ab4..a968baab 100644 --- a/src/ldso/dlstart.c +++ b/src/ldso/dlstart.c @@ -9,6 +9,14 @@ #include "crt_arch.h" +#ifndef GETFUNCSYM +#define GETFUNCSYM(fp, sym, got) do { \ + __attribute__((__visibility__("hidden"))) void sym(); \ + static void (*static_func_ptr)() = sym; \ + __asm__ __volatile__ ( "" : "+m"(static_func_ptr) : : "memory"); \ + *(fp) = static_func_ptr; } while(0) +#endif + __attribute__((__visibility__("hidden"))) void _dlstart_c(size_t *sp, size_t *dynv) { @@ -74,23 +82,9 @@ void _dlstart_c(size_t *sp, size_t *dynv) *rel_addr = (size_t)base + rel[2]; } -#ifndef GETFUNCSYM - const char *strings = (void *)(base + dyn[DT_STRTAB]); - const Sym *syms = (void *)(base + dyn[DT_SYMTAB]); - - /* Call dynamic linker stage-2, __dls2 */ - for (i=0; ;i++) { - const char *s = strings + syms[i].st_name; - if (s[0]=='_' && s[1]=='_' && s[2]=='d' - && s[3]=='l' && s[4]=='s' && s[5]=='2' && !s[6]) - break; - } - ((stage2_func)(base + syms[i].st_value))(base, sp); -#else stage2_func dls2; GETFUNCSYM(&dls2, __dls2, base+dyn[DT_PLTGOT]); dls2(base, sp); -#endif } #endif |