aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/x86_64
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2002-06-25 12:32:52 +0000
committerAndreas Jaeger <aj@suse.de>2002-06-25 12:32:52 +0000
commit6c2b2a1987dcbe5b1a5071fcc271d647ae3da55b (patch)
treed33445d559a78af59a2115973976d75add236220 /sysdeps/x86_64
parent05ae4d6ad95c139aacbc16ed6b50a24678d01bf8 (diff)
downloadglibc-6c2b2a1987dcbe5b1a5071fcc271d647ae3da55b.zip
glibc-6c2b2a1987dcbe5b1a5071fcc271d647ae3da55b.tar.gz
glibc-6c2b2a1987dcbe5b1a5071fcc271d647ae3da55b.tar.bz2
* sysdeps/x86-64/dl-machine.h (elf_machine_load_address): Rewrite
to not use 32-bit pc relative relocations. (elf_machine_dynamic): Likewise.
Diffstat (limited to 'sysdeps/x86_64')
-rw-r--r--sysdeps/x86_64/dl-machine.h53
1 files changed, 47 insertions, 6 deletions
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index 2e2eb9f..3f113f8 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -39,9 +39,12 @@ elf_machine_matches_host (const Elf64_Ehdr *ehdr)
static inline Elf64_Addr __attribute__ ((unused))
elf_machine_dynamic (void)
{
- register Elf64_Addr addr;
+ Elf64_Addr addr;
+
+ /* This works because we have our GOT address available in the small PIC
+ model. */
+ addr = (Elf64_Addr) &_DYNAMIC;
- asm ("leaq _DYNAMIC, %0\n" : "=r" (addr));
return addr;
}
@@ -52,10 +55,25 @@ elf_machine_load_address (void)
{
register Elf64_Addr addr, tmp;
- asm ("leaq _dl_start, %0\n"
- "leaq _dl_start(%%rip), %1\n"
- "subq %0, %1\n"
- : "=r" (tmp), "=r" (addr) : : "cc");
+ /* The easy way is just the same as on x86:
+ leaq _dl_start, %0
+ leaq _dl_start(%%rip), %1
+ subq %0, %1
+ but this does not work with binutils since we then have
+ a R_X86_64_32S relocation in a shared lib.
+
+ 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 .L1(%%rip), %1\n"
+ "0:\tleaq _dl_start(%%rip), %0\n\t"
+ "subq %1, %0\n\t"
+ ".section\t.data\n"
+ ".L1:\t.quad _dl_start\n\t"
+ ".previous\n\t"
+ : "=r" (addr), "=r" (tmp) : : "cc");
+
return addr;
}
@@ -367,10 +385,33 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
break;
case R_X86_64_32:
*(unsigned int *) reloc_addr = value + reloc->r_addend;
+ if (value + reloc->r_addend > UINT_MAX)
+ {
+ const char *strtab;
+
+ strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
+
+ _dl_error_printf ("\
+%s: Symbol `%s' causes overflow in R_X86_64_32 relocation\n",
+ rtld_progname ?: "<program name unknown>",
+ strtab + refsym->st_name);
+ }
break;
case R_X86_64_PC32:
*(unsigned int *) reloc_addr = value + reloc->r_addend
- (Elf64_Addr) reloc_addr;
+ if (value + reloc->r_addend - (Elf64_Addr) reloc_addr
+ != (unsigned int)(value + reloc->r_addend - (Elf64_Addr) reloc_addr))
+ {
+ const char *strtab;
+
+ strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
+
+ _dl_error_printf ("\
+%s: Symbol `%s' causes overflow in R_X86_64_PC32 relocation\n",
+ rtld_progname ?: "<program name unknown>",
+ strtab + refsym->st_name);
+ }
break;
case R_X86_64_COPY:
if (sym == NULL)