diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2016-04-20 11:10:21 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2016-04-20 11:10:38 -0700 |
commit | 338c190a92871c063847caef51bdc066372d4550 (patch) | |
tree | de16361f5e3786665f3e4d55473860224f784656 /ld | |
parent | 6c739336e5aadd6670909059fba889f50caa9cea (diff) | |
download | gdb-338c190a92871c063847caef51bdc066372d4550.zip gdb-338c190a92871c063847caef51bdc066372d4550.tar.gz gdb-338c190a92871c063847caef51bdc066372d4550.tar.bz2 |
Check run-time R_X86_64_32 relocation overflow
Since elf_x86_64_check_relocs is called after opening all input files,
we can detect dynamic R_X86_64_32 relocation overflow there.
bfd/
PR ld/19969
* elf64-x86-64.c (check_relocs_failed): New.
(elf_x86_64_need_pic): Moved before elf_x86_64_check_relocs.
Support relocation agaist local symbol. Set check_relocs_failed.
(elf_x86_64_check_relocs): Use elf_x86_64_need_pic. Check
R_X86_64_32 relocation overflow.
(elf_x86_64_relocate_section): Skip if check_relocs failed.
Update one elf_x86_64_need_pic and remove one elf_x86_64_need_pic.
ld/
PR ld/19969
* testsuite/ld-x86-64/pr19969.d: New file.
* testsuite/ld-x86-64/pr19969a.S: Likewise.
* testsuite/ld-x86-64/pr19969b.S: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr19969 tests.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/pr19969.d | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/pr19969a.S | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/pr19969b.S | 14 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/x86-64.exp | 3 |
5 files changed, 36 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index ac908e5..efa69f9 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,13 @@ 2016-04-20 H.J. Lu <hongjiu.lu@intel.com> + PR ld/19969 + * testsuite/ld-x86-64/pr19969.d: New file. + * testsuite/ld-x86-64/pr19969a.S: Likewise. + * testsuite/ld-x86-64/pr19969b.S: Likewise. + * testsuite/ld-x86-64/x86-64.exp: Run pr19969 tests. + +2016-04-20 H.J. Lu <hongjiu.lu@intel.com> + * emulparams/elf32_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): New. * emulparams/elf_i386.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): diff --git a/ld/testsuite/ld-x86-64/pr19969.d b/ld/testsuite/ld-x86-64/pr19969.d new file mode 100644 index 0000000..c56af2f --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19969.d @@ -0,0 +1,4 @@ +#source: pr19969b.S +#as: --64 +#ld: -melf_x86_64 tmpdir/pr19969.so +#error: .*relocation R_X86_64_32 against symbol `foo' can not be used when making a shared object; recompile with -fPIC diff --git a/ld/testsuite/ld-x86-64/pr19969a.S b/ld/testsuite/ld-x86-64/pr19969a.S new file mode 100644 index 0000000..f318401 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19969a.S @@ -0,0 +1,7 @@ + .data + .align 4 + .global foo + .type foo, @object + .size foo, 4 +foo: + .long -1 diff --git a/ld/testsuite/ld-x86-64/pr19969b.S b/ld/testsuite/ld-x86-64/pr19969b.S new file mode 100644 index 0000000..eabeba2 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19969b.S @@ -0,0 +1,14 @@ + .text + .globl _start + .type _start, @function +_start: + movl foo_p(%rip), %eax + ret + .size _start, .-_start + .globl foo_p + .data + .align 4 + .type foo_p, @object + .size foo_p, 4 +foo_p: + .long foo diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 2dba81d..fbd39af 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -156,6 +156,8 @@ set x86_64tests { "--64" { dummy.s } {{readelf {-rW} pr19827.rd}} "pr19827"} {"Build pr19827.so" "-melf_x86_64 -shared -Bsymbolic" "" "--64" { pr19827a.S } {{readelf {-rW} pr19827.rd}} "pr19827.so"} + {"Build pr19969.so" "-melf_x86_64 -shared" "" + "--64" { pr19969a.S } {} "pr19969.so"} } # So as to avoid rewriting every last test case here in a nacl variant, @@ -262,6 +264,7 @@ run_dump_test "pr19807-2b" run_dump_test "pr19807-2c" run_dump_test "pr19807-2d" run_dump_test "pr19807-2e" +run_dump_test "pr19969" if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} { return |