summaryrefslogtreecommitdiff
path: root/gas/config/tc-mips.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2017-01-18 18:18:21 +0000
committerMaciej W. Rozycki <macro@imgtec.com>2017-01-18 18:24:08 +0000
commit9e009953a54bfbf79d83f37797f846c923aeea43 (patch)
tree3832acbc43881dc71d29edff5e1c96249df13e70 /gas/config/tc-mips.c
parentc13a63b04677906020ee72a28d5869d979e36a6f (diff)
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/config/tc-mips.c')
-rw-r--r--gas/config/tc-mips.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 79958c83b6..1487e73b85 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -1353,7 +1353,7 @@ static void s_mips_stab (int);
static void s_mips_weakext (int);
static void s_mips_file (int);
static void s_mips_loc (int);
-static bfd_boolean pic_need_relax (symbolS *, asection *);
+static bfd_boolean pic_need_relax (symbolS *);
static int relaxed_branch_length (fragS *, asection *, int);
static int relaxed_micromips_16bit_branch_length (fragS *, asection *, int);
static int relaxed_micromips_32bit_branch_length (fragS *, asection *, int);
@@ -4267,6 +4267,8 @@ mips_move_text_labels (void)
mips_move_labels (seg_info (now_seg)->label_list, TRUE);
}
+/* Duplicate the test for LINK_ONCE sections as in `adjust_reloc_syms'. */
+
static bfd_boolean
s_is_linkonce (symbolS *sym, segT from_seg)
{
@@ -14895,7 +14897,7 @@ mips_frob_file (void)
constants; we'll report an error for those later. */
if (got16_reloc_p (l->fixp->fx_r_type)
&& !(l->fixp->fx_addsy
- && pic_need_relax (l->fixp->fx_addsy, l->seg)))
+ && pic_need_relax (l->fixp->fx_addsy)))
continue;
/* Check quickly whether the next fixup happens to be a matching %lo. */
@@ -17115,7 +17117,7 @@ nopic_need_relax (symbolS *sym, int before_relaxing)
/* Return true if the given symbol should be considered local for SVR4 PIC. */
static bfd_boolean
-pic_need_relax (symbolS *sym, asection *segtype)
+pic_need_relax (symbolS *sym)
{
asection *symsec;
@@ -17140,7 +17142,6 @@ pic_need_relax (symbolS *sym, asection *segtype)
return (!bfd_is_und_section (symsec)
&& !bfd_is_abs_section (symsec)
&& !bfd_is_com_section (symsec)
- && !s_is_linkonce (sym, segtype)
/* A global or weak symbol is treated as external. */
&& (!S_IS_WEAK (sym) && !S_IS_EXTERNAL (sym)));
}
@@ -17579,7 +17580,7 @@ md_estimate_size_before_relax (fragS *fragp, asection *segtype)
if (mips_pic == NO_PIC)
change = nopic_need_relax (fragp->fr_symbol, 0);
else if (mips_pic == SVR4_PIC)
- change = pic_need_relax (fragp->fr_symbol, segtype);
+ change = pic_need_relax (fragp->fr_symbol);
else if (mips_pic == VXWORKS_PIC)
/* For vxworks, GOT16 relocations never have a corresponding LO16. */
change = 0;