diff options
author | Maciej W. Rozycki <macro@imgtec.com> | 2017-01-18 18:18:21 +0000 |
---|---|---|
committer | Maciej W. Rozycki <macro@imgtec.com> | 2017-01-18 18:24:08 +0000 |
commit | 9e009953a54bfbf79d83f37797f846c923aeea43 (patch) | |
tree | 3832acbc43881dc71d29edff5e1c96249df13e70 /gas/testsuite | |
parent | c13a63b04677906020ee72a28d5869d979e36a6f (diff) | |
download | gdb-9e009953a54bfbf79d83f37797f846c923aeea43.zip gdb-9e009953a54bfbf79d83f37797f846c923aeea43.tar.gz gdb-9e009953a54bfbf79d83f37797f846c923aeea43.tar.bz2 |
PR gas/20649: MIPS: Fix GOT16/LO16 reloc pairing with comdat sections
Correct a regression from commit 8614eeee67f9 ("Traditional MIPS
patches"), <https://sourceware.org/ml/binutils/2000-07/msg00018.html>,
which caused symbols in linkonce or what is these days known as comdat
sections to be treated as external for the purpose of PIC relocation
generation even if their binding remains STB_LOCAL. This in turn
disabled GOT16/LO16 relocation pairing with references to such symbols,
as no complementing LO16 relocation is expected for external GOT16
references in the o32 ABI, which ultimately leads to link errors, e.g.:
ld: comdat-reloc.o: Can't find matching LO16 reloc against `foo' for R_MIPS_GOT16 at 0x24 in section `.text.bar[bar]'
as with the LD test case included with this change.
Revert the special case for symbols in comdat sections then, making code
actually match `adjust_reloc_syms' as indicated in its explanatory
comment, and adjust calling code accordingly. Also bring back the
corresponding description of what now is `s_is_linkonce', lost with
commit 5f0fe04bc550 ("Improved MIPS16/MIPS32 code intermixing for
gas."), <https://www.sourceware.org/ml/binutils/2006-07/msg00039.html>.
gas/
PR gas/20649
* config/tc-mips.c (pic_need_relax): Don't check for linkonce
symbols, remove the `segtype' parameter.
(mips_frob_file, md_estimate_size_before_relax): Adjust
accordingly.
(s_is_linkonce): Add an explanatory comment.
* testsuite/gas/mips/comdat-reloc.d: New test.
* testsuite/gas/mips/comdat-reloc.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new test.
ld/
PR gas/20649
* testsuite/ld-mips-elf/mips-elf.exp: Add PIC comdat GOT16/LO16
relocation pairing link test.
Diffstat (limited to 'gas/testsuite')
-rw-r--r-- | gas/testsuite/gas/mips/comdat-reloc.d | 31 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/comdat-reloc.s | 38 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips.exp | 2 |
3 files changed, 71 insertions, 0 deletions
diff --git a/gas/testsuite/gas/mips/comdat-reloc.d b/gas/testsuite/gas/mips/comdat-reloc.d new file mode 100644 index 0000000..12d092a --- /dev/null +++ b/gas/testsuite/gas/mips/comdat-reloc.d @@ -0,0 +1,31 @@ +#readelf: -gr +#name: MIPS ELF o32 PIC comdat GOT16/LO16 relocation pairing +#as: -32 -mno-pdr + +# Make sure the orphan GOT16 relocation is paired with LO16 for a local +# symbol in a comdat section, i.e. rather than this: +# +# 00000014 00000509 R_MIPS_GOT16 00000000 foo +# 00000020 00000506 R_MIPS_LO16 00000000 foo +# 0000001c 00000509 R_MIPS_GOT16 00000000 foo +# +# we have this: +# +# 00000014 00000509 R_MIPS_GOT16 00000000 foo +# 00000024 00000509 R_MIPS_GOT16 00000000 foo +# 0000001c 00000506 R_MIPS_LO16 00000000 foo + +#... +COMDAT group section \[.....\] `\.group' \[bar\] contains .+ sections: + \[Index\] Name + \[.....\] \.text\.foo + \[.....\] \.text\.bar +#... +Relocation section '\.rel\.text\.bar' at offset .+ contains .+ entries: + Offset Info Type Sym\.Value Sym\. Name +00000000 ......05 R_MIPS_HI16 00000000 _gp_disp +00000004 ......06 R_MIPS_LO16 00000000 _gp_disp +00000014 ......09 R_MIPS_GOT16 00000000 foo +00000024 ......09 R_MIPS_GOT16 00000000 foo +0000001c ......06 R_MIPS_LO16 00000000 foo +#pass diff --git a/gas/testsuite/gas/mips/comdat-reloc.s b/gas/testsuite/gas/mips/comdat-reloc.s new file mode 100644 index 0000000..be972bd --- /dev/null +++ b/gas/testsuite/gas/mips/comdat-reloc.s @@ -0,0 +1,38 @@ + .abicalls + + .section .text.foo, "axG", @progbits, bar, comdat + .align 2 + .ent foo + .type foo, @function +foo: + .frame $sp, 0, $31 + .mask 0x00000000, 0 + .fmask 0x00000000, 0 + jr $31 + .end foo + .size foo, . - foo + + .section .text.bar, "axG", @progbits, bar, comdat + .align 2 + .globl bar + .ent bar + .type bar, @function +bar: + .frame $sp, 0, $31 + .mask 0x00000000, 0 + .fmask 0x00000000, 0 + .set noreorder + .cpload $25 + .set reorder + beqz $4, 1f + .set noreorder + lw $2, %got(foo)($28) +0: + jr $31 + addiu $2, $2, %lo(foo) +1: + b 0b + lw $2, %got(foo)($28) + .set reorder + .end bar + .size bar, . - bar diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp index 6a1aa6c..106bd7b 100644 --- a/gas/testsuite/gas/mips/mips.exp +++ b/gas/testsuite/gas/mips/mips.exp @@ -1168,6 +1168,8 @@ if { [istarget mips*-*-vxworks*] } { } run_list_test_arches "elf-rel30" "-32" [mips_arch_list_all] + run_dump_test "comdat-reloc" + run_dump_test "${tmips}mips${el}16-e" run_dump_test "${tmips}mips${el}16-f" |