This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [GLIBC][AARCH64]Rewrite elf_machine_load_address using _DYNAMIC symbol


On 04/11/16 21:24, Roland McGrath wrote:
> On many or perhaps all machines, elf_machine_load_address could now be
> implemented purely in C by using a link-time trick.
> 
> In C, just:
> 
> 	static inline ElfW(Addr) __attribute__ ((unused))
> 	elf_machine_load_address (void)
> 	{
> 	  extern const char _BASE[] __attribute__ ((visibility ("hidden")));
> 	  return (ElfW(Addr)) _BASE;
> 	}
> 
> Then add a trivial input linker script to the ld.so link:
> 
> 	PROVIDE_HIDDEN(_BASE = 0);
> 
> I know this works for x86_64 and aarch64, and does not require a load.
> (On x86_64 it's a single lea; on aarch64 it's a single adr+add pair.)
> 

this is less maintenance work, because code can be shared,
but it is not a portable solution: it relies on linker
scripts and on the compiler not doing anything silly.

i think asm is preferable, unless we know that all
supported linkers handle this on all targets.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]