Skip to content

Commit

Permalink
helper variable into .data.rel.ro. Simplify the code. Extend
Browse files Browse the repository at this point in the history
	comment to explain prelinking.
  • Loading branch information
Ulrich Drepper committed Jul 31, 2005
1 parent 9600951 commit 943525d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
2005-07-31 Ulrich Drepper <drepper@redhat.com>

* sysdeps/x86_64/dl-machine.h (elf_machine_load_address): Move
helper variable into .data.rel.ro. Remove unnecessary label.
helper variable into .data.rel.ro. Simplify the code. Extend
comment to explain prelinking.

2005-07-31 Andreas Jaeger <aj@suse.de>

Expand Down
17 changes: 10 additions & 7 deletions sysdeps/x86_64/dl-machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ elf_machine_dynamic (void)
static inline Elf64_Addr __attribute__ ((unused))
elf_machine_load_address (void)
{
register Elf64_Addr addr, tmp;
Elf64_Addr addr;

/* The easy way is just the same as on x86:
leaq _dl_start, %0
Expand All @@ -66,15 +66,18 @@ elf_machine_load_address (void)
Instead we store the address of _dl_start in the data section
and compare it with the current value that we can get via
an RIP relative addressing mode. */

asm ("movq 1f(%%rip), %1\n"
"leaq _dl_start(%%rip), %0\n\t"
"subq %1, %0\n\t"
an RIP relative addressing mode. Note that this is the address
of _dl_start before any relocation performed at runtime. In case
the binary is prelinked the resulting "address" is actually a
load offset which is zero if the binary was loaded at the address
it is prelinked for. */

asm ("leaq _dl_start(%%rip), %0\n\t"
"subq 1f(%%rip), %0\n\t"
".section\t.data.rel.ro\n"
"1:\t.quad _dl_start\n\t"
".previous\n\t"
: "=r" (addr), "=r" (tmp) : : "cc");
: "=r" (addr) : : "cc");

return addr;
}
Expand Down

0 comments on commit 943525d

Please sign in to comment.