This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Why is _dl_relocate_static_pie linked into crt1.o?
On 07/05/2018 02:24 PM, Andreas Schwab wrote:
On Jul 05 2018, Florian Weimer <fweimer@redhat.com> wrote:
I assume the intent here is that other code can be shared between PIE and
non-PIE executables. However, it's not clear to me why the symbol
_dl_relocate_static_pie has to be used in the address calculation.
Which address calculation?
This code in sysdeps/m68k/dl-machine.h (arm has something similar):
/* Return the run-time load address of the shared object. */
static inline Elf32_Addr
elf_machine_load_address (void)
{
Elf32_Addr addr;
#ifdef SHARED
asm (PCREL_OP ("lea", "_dl_start", "%0", "%0", "%%pc") "\n\t"
"sub.l _dl_start@GOT.w(%%a5), %0"
: "=a" (addr));
#else
asm (PCREL_OP ("lea", "_dl_relocate_static_pie", "%0", "%0", "%%pc")
"\n\t"
"sub.l _dl_relocate_static_pie@GOT.w(%%a5), %0"
: "=a" (addr));
#endif
return addr;
}
If there's another symbol which is present in shared and static-PIE
builds alike, wouldn't that avoid the need for defining
_dl_relocate_static_pie in shared builds?
I don't understand the reference to shared builds. crt0.o isn't used in
shared libraries either.
elf_machine_load_address is used in elf/dl-reloc-static-pie.c and in
elf/rtld.c. I assume that _dl_relocate_static_pie was stuck into crt1.o
to satisfy the elf/rtld.c reference.
Thanks,
Florian