diff options
author | Alan Modra <amodra@gmail.com> | 2022-06-12 16:29:05 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-06-14 10:03:55 +0930 |
commit | d712f2768ac5e71027657d85b921fc0e85d94bcd (patch) | |
tree | 5725d2e6d081faee5bc818e5c65af4dfa908a16d /gas/config | |
parent | 5f269b46201975658dc5f4218acc6d836fa12ab6 (diff) | |
download | gdb-d712f2768ac5e71027657d85b921fc0e85d94bcd.zip gdb-d712f2768ac5e71027657d85b921fc0e85d94bcd.tar.gz gdb-d712f2768ac5e71027657d85b921fc0e85d94bcd.tar.bz2 |
BFD_RELOC_MIPS_16
MIPS should not be using BFD_RELOC_16 for its R_MIPS_16 relocation,
since R_MIPS_16 specifies a 16-bit field in a 32-bit word.
BFD_RELOC_16, emitted by generic code to handle fixups on 16-bit data
directives, expects fixups to operate on the whole of a 16-bit word.
This patch corrects the problem by using BFD_RELOC_MIPS_16, a new bfd
reloc that is used to generate R_MIPS_16. BFD_RELOC_16 is handled in
md_apply_fix for cases where the fixup can be applied at assembly
time. Like BFD_RELOC_8, BFD_RELOC_16 now has no corresponding object
file relocation, and thus .half, .hword, .short and .dc.w must be
resolved at assembly time. BFD_RELOC_MIPS_REL16 is removed by this
patch since it isn't used.
PR 3243
PR 26542
* reloc.c (BFD_RELOC_MIPS_16): Rename from BFD_RELOC_MIPS_REL16.
* elf32-mips.c (mips_reloc_map): Map BFD_RELOC_MIPS_16 to R_MIPS_16.
* elf64-mips.c (mips_reloc_map): Likewise, delete BFD_RELOC_MIPS_REL16.
* elfn32-mips.c (mips_reloc_map): Likewise.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
gas/
* config/tc-mips.c (append_insn): Handle BFD_RELOC_MIPS_16.
(macro_build): Likewise.
(mips_percent_op <%half>): Generate BFD_RELOC_MIPS_16.
(md_apply_fix): Handle BFD_RELOC_16 and BFD_RELOC_MIPS_16 when fx_done.
ld/
* testsuite/ld-mips-elf/reloc-local-overflow.d,
* testsuite/ld-mips-elf/reloc-local-overflow.s: Rewrite.
Diffstat (limited to 'gas/config')
-rw-r--r-- | gas/config/tc-mips.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 9b895a6..406a04a 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -7919,7 +7919,7 @@ append_insn (struct mips_cl_insn *ip, expressionS *address_expr, || reloc_type[0] == BFD_RELOC_MIPS_HIGHEST || reloc_type[0] == BFD_RELOC_MIPS_HIGHER || reloc_type[0] == BFD_RELOC_MIPS_SCN_DISP - || reloc_type[0] == BFD_RELOC_MIPS_REL16 + || reloc_type[0] == BFD_RELOC_MIPS_16 || reloc_type[0] == BFD_RELOC_MIPS_RELGOT || reloc_type[0] == BFD_RELOC_MIPS16_GPREL || hi16_reloc_p (reloc_type[0]) @@ -9083,7 +9083,7 @@ macro_build (expressionS *ep, const char *name, const char *fmt, ...) || *r == BFD_RELOC_LO16 || *r == BFD_RELOC_MIPS_GOT_OFST || (mips_opts.micromips - && (*r == BFD_RELOC_16 + && (*r == BFD_RELOC_MIPS_16 || *r == BFD_RELOC_MIPS_GOT16 || *r == BFD_RELOC_MIPS_CALL16 || *r == BFD_RELOC_MIPS_GOT_HI16 @@ -14577,7 +14577,7 @@ static const struct percent_op_match mips_percent_op[] = {"%got", BFD_RELOC_MIPS_GOT16}, {"%gp_rel", BFD_RELOC_GPREL16}, {"%gprel", BFD_RELOC_GPREL16}, - {"%half", BFD_RELOC_16}, + {"%half", BFD_RELOC_MIPS_16}, {"%highest", BFD_RELOC_MIPS_HIGHEST}, {"%higher", BFD_RELOC_MIPS_HIGHER}, {"%neg", BFD_RELOC_MIPS_SUB}, @@ -15841,9 +15841,10 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) break; } - /* Handle BFD_RELOC_8, since it's easy. Punt on other bfd relocations - that have no MIPS ELF equivalent. */ - if (fixP->fx_r_type != BFD_RELOC_8) + /* Handle BFD_RELOC_8 and BFD_RELOC_16. Punt on other bfd + relocations that have no MIPS ELF equivalent. */ + if (fixP->fx_r_type != BFD_RELOC_8 + && fixP->fx_r_type != BFD_RELOC_16) { howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type); if (!howto) @@ -15853,7 +15854,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) gas_assert (fixP->fx_size == 2 || fixP->fx_size == 4 || fixP->fx_r_type == BFD_RELOC_8 - || fixP->fx_r_type == BFD_RELOC_16 || fixP->fx_r_type == BFD_RELOC_64 || fixP->fx_r_type == BFD_RELOC_CTOR || fixP->fx_r_type == BFD_RELOC_MIPS_SUB @@ -15958,7 +15958,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) case BFD_RELOC_MIPS_HIGHEST: case BFD_RELOC_MIPS_HIGHER: case BFD_RELOC_MIPS_SCN_DISP: - case BFD_RELOC_MIPS_REL16: case BFD_RELOC_MIPS_RELGOT: case BFD_RELOC_MIPS_JALR: case BFD_RELOC_HI16: @@ -16044,6 +16043,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) case BFD_RELOC_RVA: case BFD_RELOC_32: case BFD_RELOC_32_PCREL: + case BFD_RELOC_MIPS_16: case BFD_RELOC_16: case BFD_RELOC_8: /* If we are deleting this reloc entry, we must fill in the |