Don't convert GOTPCREL relocation against large section
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 13 May 2016 17:59:32 +0000 (10:59 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 13 May 2016 18:07:02 +0000 (11:07 -0700)
bfd/

PR ld/20093
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Don't convert
GOTPCREL relocation against large section.

ld/

PR ld/20093
* testsuite/ld-x86-64/pr20093-1.d: New file.
* testsuite/ld-x86-64/pr20093-1.s: Likewise.
* testsuite/ld-x86-64/pr20093-2.d: Likewise.
* testsuite/ld-x86-64/pr20093-2.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr20093-1 and pr20093-2.

bfd/ChangeLog
bfd/elf64-x86-64.c
ld/ChangeLog
ld/testsuite/ld-x86-64/pr20093-1.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr20093-1.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr20093-2.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr20093-2.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index f13c248f636bd527d035a232dfd60e607ae963b3..9583ebd56b37bc5e1c93568248951db358fffebb 100644 (file)
@@ -1,8 +1,14 @@
+2016-05-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/20093
+       * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Don't convert
+       GOTPCREL relocation against large section.
+
 2016-05-13  Alan Modra  <amodra@gmail.com>
 
        * elf-m10300.c (_bfd_mn10300_elf_finish_dynamic_sections): Use
        linker dynamic sections in calculating size and address of
-       dynamic tags rather than using output sections.  Remove asserts.
+       dynamic tags rather than using output sections.  Remove asserts.
        * elf32-arm.c (elf32_arm_finish_dynamic_sections): Likewise.
        * elf32-cr16.c (_bfd_cr16_elf_finish_dynamic_sections): Likewise.
        * elf32-cris.c (elf_cris_finish_dynamic_sections): Likewise.
index 0bcd59dae541c857eb81d4d1e932f8caa429860c..9fc884e2d6e2ee5ac36b346ef6ab146c3f04d582 100644 (file)
@@ -1806,6 +1806,11 @@ elf_x86_64_convert_load_reloc (bfd *abfd, asection *sec,
        return TRUE;
     }
 
+  /* Don't convert GOTPCREL relocation against large section.  */
+  if (elf_section_data (tsec) !=  NULL
+      && (elf_section_flags (tsec) & SHF_X86_64_LARGE) != 0)
+    return TRUE;
+
   /* We can only estimate relocation overflow for R_X86_64_PC32.  */
   if (!to_reloc_pc32)
     goto convert;
index 6587105559f831de0d9a42a68961ffc974685f66..13f8c0b1a3beea66dc6583767f4aa4fcf2126cd2 100644 (file)
@@ -1,3 +1,12 @@
+2016-05-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/20093
+       * testsuite/ld-x86-64/pr20093-1.d: New file.
+       * testsuite/ld-x86-64/pr20093-1.s: Likewise.
+       * testsuite/ld-x86-64/pr20093-2.d: Likewise.
+       * testsuite/ld-x86-64/pr20093-2.s: Likewise.
+       * testsuite/ld-x86-64/x86-64.exp: Run pr20093-1 and pr20093-2.
+
 2016-05-13  Alan Modra  <amodra@gmail.com>
 
        * testsuite/ld-arm/arm-elf.exp: Adjust for arm-no-rel-plt now passing.
diff --git a/ld/testsuite/ld-x86-64/pr20093-1.d b/ld/testsuite/ld-x86-64/pr20093-1.d
new file mode 100644 (file)
index 0000000..de81443
--- /dev/null
@@ -0,0 +1,11 @@
+#as: --64
+#ld: -pie -melf_x86_64
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <_start>:
+[      ]*[a-f0-9]+:    48 8b 05 ([0-9a-f]{2} ){4} *    mov    0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
diff --git a/ld/testsuite/ld-x86-64/pr20093-1.s b/ld/testsuite/ld-x86-64/pr20093-1.s
new file mode 100644 (file)
index 0000000..c86a21e
--- /dev/null
@@ -0,0 +1,11 @@
+       .section        .lbss,"aw",@nobits
+foo1:
+       .space 1073741824
+       .space 1073741824
+       .space 1073741824
+       .text
+       .globl  _start
+       .type   _start, @function
+_start:
+       movq    foo1@GOTPCREL(%rip), %rax
+       .size   _start, .-_start
diff --git a/ld/testsuite/ld-x86-64/pr20093-2.d b/ld/testsuite/ld-x86-64/pr20093-2.d
new file mode 100644 (file)
index 0000000..de81443
--- /dev/null
@@ -0,0 +1,11 @@
+#as: --64
+#ld: -pie -melf_x86_64
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <_start>:
+[      ]*[a-f0-9]+:    48 8b 05 ([0-9a-f]{2} ){4} *    mov    0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
diff --git a/ld/testsuite/ld-x86-64/pr20093-2.s b/ld/testsuite/ld-x86-64/pr20093-2.s
new file mode 100644 (file)
index 0000000..cfbe9c2
--- /dev/null
@@ -0,0 +1,9 @@
+       .largecomm      foo1,1073741824,32
+       .largecomm      foo2,1073741824,32
+       .largecomm      foo3,1073741824,32
+       .text
+       .globl  _start
+       .type   _start, @function
+_start:
+       movq    foo1@GOTPCREL(%rip), %rax
+       .size   _start, .-_start
index d3990d076c07f97785a9bc0067779bfa0d4c590f..3f4d737bee9199aa731dd789852022c05db7bcee 100644 (file)
@@ -267,6 +267,8 @@ run_dump_test "pr19807-2c"
 run_dump_test "pr19807-2d"
 run_dump_test "pr19807-2e"
 run_dump_test "pr19969"
+run_dump_test "pr20093-1"
+run_dump_test "pr20093-2"
 
 if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
     return
This page took 0.047344 seconds and 4 git commands to generate.