diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2018-03-08 06:36:40 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2018-03-08 06:36:52 -0800 |
commit | 347a87745eab23d8427349787bde4a938a1e8c3e (patch) | |
tree | 61bd3dccb63977b684ce6097e55953e3dd3c3de6 /ld | |
parent | bd5dea8822e515faf305690ca5c5281132d95587 (diff) | |
download | gdb-347a87745eab23d8427349787bde4a938a1e8c3e.zip gdb-347a87745eab23d8427349787bde4a938a1e8c3e.tar.gz gdb-347a87745eab23d8427349787bde4a938a1e8c3e.tar.bz2 |
x86: Treat relocation against IFUNC symbol as FUNC
When resolving a relocation against IFUNC symbol in a SHT_NOTE section
without SHF_ALLOC, we treat it as relocation against FUNC symbol since
it needs the address of IFUNC symbol, not the address returned by IFUNC
function.
bfd/
PR ld/22929
* elf32-i386.c (elf_i386_relocate_section): Treat relocation
against IFUNC symbol in SHT_NOTE section without SHF_ALLOC as
relocation against FUNC symbol.
* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
ld/
PR ld/22929
* testsuite/ld-i386/i386.exp: Run PR ld/22929 test.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr22929.d: New file.
* testsuite/ld-i386/pr22929.s: Likewise.
* testsuite/ld-x86-64/pr22929.d: Likewise.
* testsuite/ld-x86-64/pr22929.s: Likewise.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/i386.exp | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/pr22929.d | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/pr22929.s | 21 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/pr22929.d | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/pr22929.s | 21 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/x86-64.exp | 1 |
7 files changed, 76 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index a65b824..f37bdab 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,13 @@ +2018-03-08 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/22929 + * testsuite/ld-i386/i386.exp: Run PR ld/22929 test. + * testsuite/ld-x86-64/x86-64.exp: Likewise. + * testsuite/ld-i386/pr22929.d: New file. + * testsuite/ld-i386/pr22929.s: Likewise. + * testsuite/ld-x86-64/pr22929.d: Likewise. + * testsuite/ld-x86-64/pr22929.s: Likewise. + 2018-03-07 Max Filippov <jcmvbkbc@gmail.com> * emulparams/elf32xtensa.sh (COMMONPAGESIZE): Define. diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 240850a..243c0a5 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -459,6 +459,7 @@ run_dump_test "pr22115-1c" run_dump_test "pr22115-1d" run_dump_test "pr22135" run_dump_test "pr22782" +run_dump_test "pr22929" if { !([istarget "i?86-*-linux*"] || [istarget "i?86-*-gnu*"] diff --git a/ld/testsuite/ld-i386/pr22929.d b/ld/testsuite/ld-i386/pr22929.d new file mode 100644 index 0000000..099880e --- /dev/null +++ b/ld/testsuite/ld-i386/pr22929.d @@ -0,0 +1,11 @@ +#as: --32 +#ld: -melf_i386 -shared +#readelf: -r --wide -s + +There are no relocations in this file. +#... +Symbol table '.symtab' contains [0-9]+ entries: + Num: Value Size Type Bind Vis Ndx Name +#... +[ \t]+[a-f0-9]+: [a-f0-9]+ +1 IFUNC +GLOBAL DEFAULT +[a-f0-9]+ +foo +#... diff --git a/ld/testsuite/ld-i386/pr22929.s b/ld/testsuite/ld-i386/pr22929.s new file mode 100644 index 0000000..3fa3dc9 --- /dev/null +++ b/ld/testsuite/ld-i386/pr22929.s @@ -0,0 +1,21 @@ + .text + .globl foo + .type foo, %gnu_indirect_function +foo: + ret + .size foo, .-foo + .pushsection .gnu.build.attributes, "", %note + .dc.l 6 # size of name + .dc.l 16 # descsz = sizeof (addresses) + .dc.l 0x101 # type = FUNC + .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0 # name (numeric: -fstack-protector status) + .dc.b 0, 0 # Padding + .dc.a foo + .dc.a foo_end # description (symbol name) + .popsection + +foo_end: + .section .rodata.cst4,"aM",@progbits,4 + .align 4 +.LC0: + .long 1065353216 diff --git a/ld/testsuite/ld-x86-64/pr22929.d b/ld/testsuite/ld-x86-64/pr22929.d new file mode 100644 index 0000000..537b396 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr22929.d @@ -0,0 +1,11 @@ +#as: --64 +#ld: -melf_x86_64 -shared +#readelf: -r --wide -s + +There are no relocations in this file. +#... +Symbol table '.symtab' contains [0-9]+ entries: + Num: Value Size Type Bind Vis Ndx Name +#... +[ \t]+[a-f0-9]+: [a-f0-9]+ +1 IFUNC +GLOBAL DEFAULT +[a-f0-9]+ +foo +#... diff --git a/ld/testsuite/ld-x86-64/pr22929.s b/ld/testsuite/ld-x86-64/pr22929.s new file mode 100644 index 0000000..3fa3dc9 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr22929.s @@ -0,0 +1,21 @@ + .text + .globl foo + .type foo, %gnu_indirect_function +foo: + ret + .size foo, .-foo + .pushsection .gnu.build.attributes, "", %note + .dc.l 6 # size of name + .dc.l 16 # descsz = sizeof (addresses) + .dc.l 0x101 # type = FUNC + .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0 # name (numeric: -fstack-protector status) + .dc.b 0, 0 # Padding + .dc.a foo + .dc.a foo_end # description (symbol name) + .popsection + +foo_end: + .section .rodata.cst4,"aM",@progbits,4 + .align 4 +.LC0: + .long 1065353216 diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 02aa38a..5a06947 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -605,6 +605,7 @@ run_dump_test "pr20253-5a" run_dump_test "pr20253-5b" run_dump_test "tlsdesc2" run_dump_test "pr22048" +run_dump_test "pr22929" proc undefined_weak {cflags ldflags} { set testname "Undefined weak symbol" |