diff options
author | Maciej W. Rozycki <macro@imgtec.com> | 2017-04-24 20:15:31 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@imgtec.com> | 2017-04-26 13:17:07 +0100 |
commit | 23ec1e32b1ab714649a7c25e49b5d721fe3bd3db (patch) | |
tree | 86f02a16d136cb6895ca179e1ba5d9e8dda7ccc7 /ld | |
parent | c46cec3a8cfe02fbe0f6c67ba53abc5369c5c659 (diff) | |
download | gdb-23ec1e32b1ab714649a7c25e49b5d721fe3bd3db.zip gdb-23ec1e32b1ab714649a7c25e49b5d721fe3bd3db.tar.gz gdb-23ec1e32b1ab714649a7c25e49b5d721fe3bd3db.tar.bz2 |
PR ld/21334: Always call `_bfd_elf_link_renumber_dynsyms' if required
Complement commit e17b0c351f0b ("MIPS/BFD: Respect the ELF gABI dynamic
symbol table sort requirement") and correct an inconsistency in dynamic
symbol accounting data causing an assertion failure in the MIPS backend:
ld: BFD (GNU Binutils) 2.28.51.20170330 assertion fail
../../binutils-gdb/bfd/elfxx-mips.c:3860
in the course of making a GOT entry in a static binary to satisfy a GOT
relocation present in input, due to the local dynamic symbol count not
having been established.
To do so let backends request `_bfd_elf_link_renumber_dynsyms' to be
always called, rather than where a dynamic binary is linked only, and
then make this request in the MIPS backend.
bfd/
PR ld/21334
* elf-bfd.h (elf_backend_data): Add `always_renumber_dynsyms'
member.
* elfxx-target.h [!elf_backend_always_renumber_dynsyms]
(elf_backend_always_renumber_dynsyms): Define.
(elfNN_bed): Initialize `always_renumber_dynsyms' member.
* elfxx-mips.h (elf_backend_always_renumber_dynsyms): Define.
* elflink.c (bfd_elf_size_dynamic_sections): Also call
`_bfd_elf_link_renumber_dynsyms' if the backend has requested
it.
(bfd_elf_size_dynsym_hash_dynstr): Likewise.
ld/
PR ld/21334
* testsuite/ld-mips-elf/pr21334.dd: New test.
* testsuite/ld-mips-elf/pr21334.gd: New test.
* testsuite/ld-mips-elf/pr21334.ld: New test linker script.
* testsuite/ld-mips-elf/pr21334.s: New test source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/mips-elf.exp | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr21334.dd | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr21334.gd | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr21334.ld | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr21334.s | 20 |
6 files changed, 69 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index ed3797e..93165f2 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,12 @@ +2017-04-26 Maciej W. Rozycki <macro@imgtec.com> + + PR ld/21334 + * testsuite/ld-mips-elf/pr21334.dd: New test. + * testsuite/ld-mips-elf/pr21334.gd: New test. + * testsuite/ld-mips-elf/pr21334.ld: New test linker script. + * testsuite/ld-mips-elf/pr21334.s: New test source. + * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests. + 2017-04-24 H.J. Lu <hongjiu.lu@intel.com> * testsuite/ld-x86-64/no-plt.exp: Also check no-plt-1e.nd. diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 3ef9963..f824e7c 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -1129,3 +1129,13 @@ if { $linux_gnu } { "export-$class-ref"]] } } + +# PR ld/21334 GOT relocation in static binary test. +run_ld_link_tests [list \ + [list \ + "PR ld/21233 MIPS GOT16 relocation in static binary" \ + "$abi_ldflags(o32) -e foo -T pr21334.ld" "" "$abi_asflags(o32)" \ + {pr21334.s} \ + {{objdump {-d --prefix-addresses} pr21334.dd} \ + {readelf -A pr21334.gd}} \ + "pr21334"]] diff --git a/ld/testsuite/ld-mips-elf/pr21334.dd b/ld/testsuite/ld-mips-elf/pr21334.dd new file mode 100644 index 0000000..01c3718 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr21334.dd @@ -0,0 +1,10 @@ +.*: +file format .*mips.* + +Disassembly of section \.text: +[0-9a-f]+ <[^>]*> lui gp,0x1 +[0-9a-f]+ <[^>]*> addiu gp,gp,-32736 +[0-9a-f]+ <[^>]*> addu gp,gp,t9 +[0-9a-f]+ <[^>]*> lw v0,-32744\(gp\) +[0-9a-f]+ <[^>]*> jr ra +[0-9a-f]+ <[^>]*> addiu v0,v0,4 + \.\.\. diff --git a/ld/testsuite/ld-mips-elf/pr21334.gd b/ld/testsuite/ld-mips-elf/pr21334.gd new file mode 100644 index 0000000..c8467ee --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr21334.gd @@ -0,0 +1,11 @@ +Static GOT: + Canonical gp value: 00008020 + + Reserved entries: + Address Access Value + 00000030 -32752\(gp\) 00000000 + 00000034 -32748\(gp\) 80000000 + + Local entries: + Address Access Value + 00000038 -32744\(gp\) 00000000 diff --git a/ld/testsuite/ld-mips-elf/pr21334.ld b/ld/testsuite/ld-mips-elf/pr21334.ld new file mode 100644 index 0000000..5fb94bd --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr21334.ld @@ -0,0 +1,9 @@ +SECTIONS +{ + .text : { *(.text) } + HIDDEN (_gp = ALIGN (16) + 0x7ff0); + .got : { *(.got) } + .symtab : { *(.symtab) } + .strtab : { *(.strtab) } + /DISCARD/ : { *(*) } +} diff --git a/ld/testsuite/ld-mips-elf/pr21334.s b/ld/testsuite/ld-mips-elf/pr21334.s new file mode 100644 index 0000000..d62c18c --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr21334.s @@ -0,0 +1,20 @@ + .abicalls + .text + .set noreorder + .globl foo + .ent foo +foo: + .frame $sp, 0, $31 + .mask 0x00000000, 0 + .fmask 0x00000000, 0 + .cpload $25 + lw $2, %got(bar)($28) + jr $31 + addiu $2, $2, 4 + .end foo + .weak bar + .hidden bar + +# Force some (non-delay-slot) zero bytes, to make 'objdump' print ... + .align 4, 0 + .space 16 |