This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
PATCH: Sign extend relocation result to 64bit forR_X86_64_DTPOFF64/R_X86_64_TPOFF64
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 8 May 2012 09:48:09 -0700
- Subject: PATCH: Sign extend relocation result to 64bit forR_X86_64_DTPOFF64/R_X86_64_TPOFF64
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
X32 uses the smae GOT layout and R_X86_64_DTPOFF64/R_X86_64_TPOFF64
relocations as x86-64. This patch sign extends relocation result to
64bit for R_X86_64_DTPOFF64 and R_X86_64_TPOFF64. Tested on
Linux/x86-64. OK to install?
Thanks.
H.J.
---
* sysdeps/x86_64/dl-machine.h (elf_machine_rela): For x32, sign
extend relocation result to 64bit for R_X86_64_DTPOFF64 and
R_X86_64_TPOFF64.
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index d1906a4..4b45df0 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -328,7 +328,13 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
/* During relocation all TLS symbols are defined and used.
Therefore the offset is already correct. */
if (sym != NULL)
+# ifdef __ILP32__
+ *(Elf64_Sxword *) reloc_addr
+ = (Elf64_Sxword)
+ ((Elf32_Sword) (sym->st_value + reloc->r_addend));
+# else
*reloc_addr = sym->st_value + reloc->r_addend;
+# endif
# endif
break;
case R_X86_64_TLSDESC:
@@ -378,8 +384,15 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
/* We know the offset of the object the symbol is contained in.
It is a negative value which will be added to the
thread pointer. */
+# ifdef __ILP32__
+ *(Elf64_Sxword *) reloc_addr
+ = (Elf64_Sxword)
+ ((Elf32_Sword) (sym->st_value + reloc->r_addend
+ - sym_map->l_tls_offset));
+# else
*reloc_addr = (sym->st_value + reloc->r_addend
- sym_map->l_tls_offset);
+# endif
}
break;
# endif