This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[committed, PATCH] PR ld/20093: Don't convert GOTPCREL relocation against large section
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Fri, 13 May 2016 11:15:16 -0700
- Subject: [committed, PATCH] PR ld/20093: Don't convert GOTPCREL relocation against large section
- Authentication-results: sourceware.org; auth=none
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
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/elf64-x86-64.c | 5 +++++
ld/testsuite/ld-x86-64/pr20093-1.d | 11 +++++++++++
ld/testsuite/ld-x86-64/pr20093-1.s | 11 +++++++++++
ld/testsuite/ld-x86-64/pr20093-2.d | 11 +++++++++++
ld/testsuite/ld-x86-64/pr20093-2.s | 9 +++++++++
ld/testsuite/ld-x86-64/x86-64.exp | 2 ++
6 files changed, 49 insertions(+)
create mode 100644 ld/testsuite/ld-x86-64/pr20093-1.d
create mode 100644 ld/testsuite/ld-x86-64/pr20093-1.s
create mode 100644 ld/testsuite/ld-x86-64/pr20093-2.d
create mode 100644 ld/testsuite/ld-x86-64/pr20093-2.s
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 0bcd59d..e9964b0 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1805,6 +1805,11 @@ elf_x86_64_convert_load_reloc (bfd *abfd, asection *sec,
else
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)
diff --git a/ld/testsuite/ld-x86-64/pr20093-1.d b/ld/testsuite/ld-x86-64/pr20093-1.d
new file mode 100644
index 0000000..de81443
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20093-1.d
@@ -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
index 0000000..c86a21e
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20093-1.s
@@ -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
index 0000000..de81443
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20093-2.d
@@ -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
index 0000000..cfbe9c2
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20093-2.s
@@ -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
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index d3990d0..3f4d737 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -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
--
2.5.5