diff --git a/arch/i386/reloc.h b/arch/i386/reloc.h index b52ef4024efce8e0af1dfcecaecb25a5fd8ea437..032f454bda5f2898f841f9bcb925976dd602166c 100644 --- a/arch/i386/reloc.h +++ b/arch/i386/reloc.h @@ -14,3 +14,10 @@ #define CRTJMP(pc,sp) __asm__ __volatile__( \ "mov %1,%%esp ; jmp *%0" : : "r"(pc), "r"(sp) : "memory" ) + +#define GETFUNCSYM(fp, sym, got) __asm__ ( \ + ".hidden " #sym "\n" \ + " call 1f\n" \ + "1: addl $" #sym "-.,(%%esp)\n" \ + " pop %0" \ + : "=r"(*fp) : : "memory" ) diff --git a/src/ldso/dlstart.c b/src/ldso/dlstart.c index 3aaa200fbbb5c55df7e1e5179ab1471df99c0d5e..eb919ab44b16a76d0118f43a8645b4f9fb8be813 100644 --- a/src/ldso/dlstart.c +++ b/src/ldso/dlstart.c @@ -74,6 +74,7 @@ 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]); @@ -85,6 +86,11 @@ void _dlstart_c(size_t *sp, size_t *dynv) 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