aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2014-12-02 15:14:28 -0800
committerH.J. Lu <hjl.tools@gmail.com>2014-12-02 15:19:25 -0800
commit9a926d55ab4b6667f6c35b518d59b902fe490d9d (patch)
tree65a4ca69cf169316c6fcfe5f02abe413ac5e75f0 /ld
parent5da3ffc99d0ec7d0770b4fcf8830ffe05d39b1b8 (diff)
downloadgdb-9a926d55ab4b6667f6c35b518d59b902fe490d9d.zip
gdb-9a926d55ab4b6667f6c35b518d59b902fe490d9d.tar.gz
gdb-9a926d55ab4b6667f6c35b518d59b902fe490d9d.tar.bz2
X86-64: Allow copy relocs for building PIE
This patch allows copy relocs for non-GOT pc-relative relocation in PIE. bfd/ * elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Always allow copy relocs for building executables. (elf_x86_64_check_relocs): Allow copy relocs for non-GOT pc-relative relocation in shared object. (elf_x86_64_adjust_dynamic_symbol): Allocate copy relocs for PIE. (elf_x86_64_relocate_section): Don't copy a pc-relative relocation into the output file if the symbol needs copy reloc. ld/testsuite/ * ld-x86-64/copyreloc-lib.c: New file. * ld-x86-64/copyreloc-main.c: Likewise. * ld-x86-64/copyreloc-main.out: Likewise. * ld-x86-64/copyreloc-main1.rd: Likewise. * ld-x86-64/copyreloc-main2.rd: Likewise. * ld-x86-64/x86-64.exp: Run copyreloc tests.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ChangeLog10
-rw-r--r--ld/testsuite/ld-x86-64/copyreloc-lib.c1
-rw-r--r--ld/testsuite/ld-x86-64/copyreloc-main.c7
-rw-r--r--ld/testsuite/ld-x86-64/copyreloc-main.out0
-rw-r--r--ld/testsuite/ld-x86-64/copyreloc-main1.rd3
-rw-r--r--ld/testsuite/ld-x86-64/copyreloc-main2.rd4
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp32
7 files changed, 57 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index de784f7..70201ad 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2014-12-02 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ld-x86-64/copyreloc-lib.c: New file.
+ * ld-x86-64/copyreloc-main.c: Likewise.
+ * ld-x86-64/copyreloc-main.out: Likewise.
+ * ld-x86-64/copyreloc-main1.rd: Likewise.
+ * ld-x86-64/copyreloc-main2.rd: Likewise.
+
+ * ld-x86-64/x86-64.exp: Run copyreloc tests.
+
2014-12-02 Andrew Bennett <andrew.bennett@imgtec.com>
* ld-mips-elf/mips-elf.exp: Add undefined weak overflow
diff --git a/ld/testsuite/ld-x86-64/copyreloc-lib.c b/ld/testsuite/ld-x86-64/copyreloc-lib.c
new file mode 100644
index 0000000..cbbc5e2
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/copyreloc-lib.c
@@ -0,0 +1 @@
+int a_glob = 2;
diff --git a/ld/testsuite/ld-x86-64/copyreloc-main.c b/ld/testsuite/ld-x86-64/copyreloc-main.c
new file mode 100644
index 0000000..430eefb
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/copyreloc-main.c
@@ -0,0 +1,7 @@
+extern int a_glob;
+
+int
+main (void)
+{
+ return a_glob != 2;
+}
diff --git a/ld/testsuite/ld-x86-64/copyreloc-main.out b/ld/testsuite/ld-x86-64/copyreloc-main.out
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/copyreloc-main.out
diff --git a/ld/testsuite/ld-x86-64/copyreloc-main1.rd b/ld/testsuite/ld-x86-64/copyreloc-main1.rd
new file mode 100644
index 0000000..dcb52dc
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/copyreloc-main1.rd
@@ -0,0 +1,3 @@
+#...
+[0-9a-f ]+R_X86_64_COPY+[0-9a-f ]+ +a_glob \+ 0
+#...
diff --git a/ld/testsuite/ld-x86-64/copyreloc-main2.rd b/ld/testsuite/ld-x86-64/copyreloc-main2.rd
new file mode 100644
index 0000000..d78ea2f
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/copyreloc-main2.rd
@@ -0,0 +1,4 @@
+#failif
+#...
+[0-9a-f ]+R_X86_64_NONE.*
+#...
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 886469b..91c9dd9 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -392,6 +392,30 @@ if { [isnative] && [which $CC] != 0 } {
{{readelf {-Wr} plt-main.rd}} \
"plt-main" \
] \
+ [list \
+ "Build copyreloc-lib.so" \
+ "-shared" \
+ "-fPIC" \
+ { copyreloc-lib.c } \
+ {} \
+ "copyreloc-lib.so" \
+ ] \
+ [list \
+ "Build copyreloc-main with PIE without -fPIE (1)" \
+ "tmpdir/copyreloc-lib.so -pie" \
+ "" \
+ { copyreloc-main.c } \
+ {{readelf {-Wr} copyreloc-main1.rd}} \
+ "copyreloc-main" \
+ ] \
+ [list \
+ "Build copyreloc-main with PIE without -fPIE (2)" \
+ "tmpdir/copyreloc-lib.so -pie" \
+ "" \
+ { copyreloc-main.c } \
+ {{readelf {-Wr} copyreloc-main2.rd}} \
+ "copyreloc-main" \
+ ] \
]
run_ld_link_exec_tests [] [list \
@@ -414,6 +438,14 @@ if { [isnative] && [which $CC] != 0 } {
"plt-main.out" \
"-fPIC" \
] \
+ [list \
+ "Run copyreloc-main with PIE without -fPIE" \
+ "tmpdir/copyreloc-lib.so -pie" \
+ "" \
+ { copyreloc-main.c } \
+ "copyreloc-main" \
+ "copyreloc-main.out" \
+ ] \
]
if { [istarget "x86_64-*-linux*"] \