This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[committed, PATCH] PR ld/20550: Resolve size relocation with copy relocation
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Tue, 6 Sep 2016 13:35:47 -0700
- Subject: [committed, PATCH] PR ld/20550: Resolve size relocation with copy relocation
- Authentication-results: sourceware.org; auth=none
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
We can resolve size relocation against symbol which needs copy relocation
when building executable.
H.J.
---
bfd/
PR ld/20550
* elf64-x86-64.c (elf_x86_64_relocate_section): Resolve size
relocation with copy relocation when building executable.
ld/
PR ld/20550
* testsuite/ld-x86-64/pr20550a.s: New file.
* testsuite/ld-x86-64/pr20550b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp (x86_64tests): Add tests for
PR ld/20550.
---
bfd/elf64-x86-64.c | 4 +++-
ld/testsuite/ld-x86-64/pr20550a.s | 6 ++++++
ld/testsuite/ld-x86-64/pr20550b.s | 10 ++++++++++
ld/testsuite/ld-x86-64/x86-64.exp | 6 ++++++
4 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 ld/testsuite/ld-x86-64/pr20550a.s
create mode 100644 ld/testsuite/ld-x86-64/pr20550b.s
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index c8bbed8..9a6a5c7 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -4818,7 +4818,9 @@ direct:
&& (h->needs_copy
|| eh->needs_copy
|| h->root.type == bfd_link_hash_undefined)
- && IS_X86_64_PCREL_TYPE (r_type))
+ && (IS_X86_64_PCREL_TYPE (r_type)
+ || r_type == R_X86_64_SIZE32
+ || r_type == R_X86_64_SIZE64))
&& (h == NULL
|| ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
&& !resolved_to_zero)
diff --git a/ld/testsuite/ld-x86-64/pr20550a.s b/ld/testsuite/ld-x86-64/pr20550a.s
new file mode 100644
index 0000000..4430398
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20550a.s
@@ -0,0 +1,6 @@
+ .text
+ .global _start
+_start:
+ movabsq $strings@SIZE, %rdx
+ .section .data.rel,"aw",@progbits
+ .quad strings
diff --git a/ld/testsuite/ld-x86-64/pr20550b.s b/ld/testsuite/ld-x86-64/pr20550b.s
new file mode 100644
index 0000000..fbc482a
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20550b.s
@@ -0,0 +1,10 @@
+ .globl strings
+ .section .rodata
+.LC0:
+ .string "test"
+ .section .data.rel.local,"aw",@progbits
+ .align 8
+ .type strings, @object
+ .size strings, 8
+strings:
+ .quad .LC0
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index c24eeea..c84bdf1 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -207,6 +207,12 @@ set x86_64tests {
"--64" { pr19827a.S } {{readelf {-rW} pr19827.rd}} "pr19827.so"}
{"Build pr19969.so" "-melf_x86_64 -shared" ""
"--64" { pr19969a.S } {} "pr19969.so"}
+ {"Build pr20550a.o" "" ""
+ "--64" { pr20550a.s }}
+ {"Build pr20550b.so" "-melf_x86_64 -shared" ""
+ "--64" { pr20550b.s } {} "pr20550b.so"}
+ {"Build pr20550" "-melf_x86_64 -pie tmpdir/pr20550a.o tmpdir/pr20550b.so" ""
+ "--64" { dummy.s } {} "pr20550"}
}
# So as to avoid rewriting every last test case here in a nacl variant,
--
2.7.4