aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-08-12 19:42:39 +0000
committerH.J. Lu <hjl.tools@gmail.com>2011-08-12 19:42:39 +0000
commit64d25c44142091760a88c3bc8235c99ddc8cbfa1 (patch)
treebee81faf532630f32ba3f987d195f28fc708ddf0 /bfd
parent091c2a968ae5dd0a46174ffa0dfcd61a2423ba1f (diff)
downloadgdb-64d25c44142091760a88c3bc8235c99ddc8cbfa1.zip
gdb-64d25c44142091760a88c3bc8235c99ddc8cbfa1.tar.gz
gdb-64d25c44142091760a88c3bc8235c99ddc8cbfa1.tar.bz2
Add R_X86_64_RELATIVE64 and handle R_X86_64_64 for x32.
bfd/ 2011-08-12 H.J. Lu <hongjiu.lu@intel.com> PR ld/13082 * elf64-x86-64.c (x86_64_elf_howto_table): Add R_X86_64_RELATIVE64. (elf_x86_64_relocate_section): Treat R_X86_64_64 like R_X86_64_32 and zero-extend it to 64bit if addend is zero for x32. Generate R_X86_64_RELATIVE64 for x32. include/elf/ 2011-08-12 H.J. Lu <hongjiu.lu@intel.com> PR ld/13082 * x86-64.h (R_X86_64_RELATIVE64): New. ld/testsuite/ 2011-08-12 H.J. Lu <hongjiu.lu@intel.com> PR ld/13082 * ld-x86-64/pr13082-1.s: New. * ld-x86-64/pr13082-1a.d: Likewise. * ld-x86-64/pr13082-1b.d: Likewise. * ld-x86-64/pr13082-2.s: Likewise. * ld-x86-64/pr13082-2a.d: Likewise. * ld-x86-64/pr13082-2b.d: Likewise. * ld-x86-64/pr13082-3.s: Likewise. * ld-x86-64/pr13082-3a.d: Likewise. * ld-x86-64/pr13082-3b.d: Likewise. * ld-x86-64/pr13082-4.s: Likewise. * ld-x86-64/pr13082-4a.d: Likewise. * ld-x86-64/pr13082-4b.d: Likewise. * ld-x86-64/pr13082-5.s: Likewise. * ld-x86-64/pr13082-5a.d: Likewise. * ld-x86-64/pr13082-5b.d: Likewise. * ld-x86-64/pr13082-6.s: Likewise. * ld-x86-64/pr13082-6a.d: Likewise. * ld-x86-64/pr13082-6b.d: Likewise. * ld-x86-64/x86-64.exp: Run pr13082-[1-6][ab].
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/elf64-x86-64.c21
2 files changed, 29 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c811179..f76cf77 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2011-08-12 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/13082
+ * elf64-x86-64.c (x86_64_elf_howto_table): Add R_X86_64_RELATIVE64.
+ (elf_x86_64_relocate_section): Treat R_X86_64_64 like R_X86_64_32
+ and zero-extend it to 64bit if addend is zero for x32. Generate
+ R_X86_64_RELATIVE64 for x32.
+
2011-08-09 Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
* bfd-in.h (bfd_elf32_arm_set_target_relocs): Update prototype.
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 7b92097..238c7bd 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -164,6 +164,9 @@ static reloc_howto_type x86_64_elf_howto_table[] =
HOWTO(R_X86_64_IRELATIVE, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
bfd_elf_generic_reloc, "R_X86_64_IRELATIVE", FALSE, MINUS_ONE,
MINUS_ONE, FALSE),
+ HOWTO(R_X86_64_RELATIVE64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
+ bfd_elf_generic_reloc, "R_X86_64_RELATIVE64", FALSE, MINUS_ONE,
+ MINUS_ONE, FALSE),
/* We have a gap in the reloc numbers here.
R_X86_64_standard counts the number up to this point, and
@@ -3083,6 +3086,16 @@ elf_x86_64_relocate_section (bfd *output_bfd,
if (info->relocatable)
continue;
+ if (rel->r_addend == 0
+ && r_type == R_X86_64_64
+ && !ABI_64_P (output_bfd))
+ {
+ /* For x32, treat R_X86_64_64 like R_X86_64_32 and zero-extend
+ it to 64bit if addend is zero. */
+ r_type = R_X86_64_32;
+ memset (contents + rel->r_offset + 4, 0, 4);
+ }
+
/* Since STT_GNU_IFUNC symbol must go through PLT, we handle
it here if it is defined in a non-shared object. */
if (h != NULL
@@ -3597,6 +3610,14 @@ elf_x86_64_relocate_section (bfd *output_bfd,
outrel.r_info = htab->r_info (0, R_X86_64_RELATIVE);
outrel.r_addend = relocation + rel->r_addend;
}
+ else if (r_type == R_X86_64_64
+ && !ABI_64_P (output_bfd))
+ {
+ relocate = TRUE;
+ outrel.r_info = htab->r_info (0,
+ R_X86_64_RELATIVE64);
+ outrel.r_addend = relocation + rel->r_addend;
+ }
else
{
long sindx;