Avoid using the global offset table to get the address of _DYNAMIC in

rtld.  When _DYNAMIC is referenced normally from C the global offset
table is used implicitly, but newer versions of binutils don't initialize
it statically in the binary, so this doesn't work until rtld is relocated,
which _DYNAMIC is needed for...  So, as on other systems with the same
problem, we disassemble a call instruction to _DYNAMIC in order to get
its address.
This commit is contained in:
Jake Burkholder 2003-07-04 00:05:15 +00:00
parent 53dc6459d7
commit d037213487
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=117211
2 changed files with 18 additions and 1 deletions

View File

@ -37,7 +37,7 @@
struct Struct_Obj_Entry;
/* Return the address of the .dynamic section in the dynamic linker. */
#define rtld_dynamic(obj) ((Elf_Dyn *)(((char *)&_DYNAMIC) + (vm_offset_t)(obj)->relocbase))
Elf_Dyn *rtld_dynamic(const struct Struct_Obj_Entry *);
Elf_Addr reloc_jmpslot(Elf_Addr *, Elf_Addr,
const struct Struct_Obj_Entry *,

View File

@ -67,6 +67,23 @@ ENTRY(.rtld_start)
mov %l0, %o0
END(.rtld_start)
/*
* Find the address of _DYNAMIC by disassembling a call instruction to it.
* Binutils may not fill in the GOT as expected on other architectures.
*/
ENTRY(rtld_dynamic)
save %sp, -CCFSZ, %sp
call 1f
nop
call _DYNAMIC + 8
1: lduw [%o7 + 8], %o0
sll %o0, 2, %o0
sra %o0, 0, %o0
ret
restore %o0, %o7, %o0
END(rtld_dynamic)
/*
* We have two separate entry points to the runtime linker.
* I'm implementing this following the SPARC v9 ABI spec.