aboutsummaryrefslogtreecommitdiff
path: root/gas/config/tc-mips.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2017-05-03 00:05:15 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2017-05-03 00:15:56 +0100
commit82d808edbc7a06f706b82064cec6c3ed88f0c4be (patch)
tree6510e8c35632eba734ed8508067ca9f98f625fc8 /gas/config/tc-mips.c
parent3d8505928a06e00b05bb162c1ad0dd612c1c16af (diff)
downloadgdb-82d808edbc7a06f706b82064cec6c3ed88f0c4be.zip
gdb-82d808edbc7a06f706b82064cec6c3ed88f0c4be.tar.gz
gdb-82d808edbc7a06f706b82064cec6c3ed88f0c4be.tar.bz2
MIPS16/GAS: Fix absolute references with PC-relative synthetic instructions
Complement commit 88a7ef168927 ("MIPS16/GAS: Restore unsupported relocation diagnostics") and also propagate constant expressions, either already reduced from absolute symbol references or created from literals in the first place, used as a PC-relative operand with the MIPS16 LA, LW, DLA and LD synthetic instructions to relaxation, matching the way forward absolute symbol references have been handled as from the commit referred and letting relaxation produce any necessary relocations, if possible, for the absolute value requested to be reproduced at the run time. Call `symbol_append' for any expression symbol created for the purpose of MIPS16 relaxation as with constant expressions now propagated from earlier on such symbols may make it through and have R_MIPS16_PC16_S1 relocations emitted against, and therefore need to appear in the symbol table produced. gas/ * config/tc-mips.c (append_insn): Call `symbol_append' for any expression symbol created for MIPS16 relaxation. (match_mips16_insn): Don't encode a constant value as an immediate with a PC-relative operand. * testsuite/gas/mips/mips16-pcrel-absolute-1.d: New test. * testsuite/gas/mips/mips16-branch-absolute-1.d: New test. * testsuite/gas/mips/mips16-branch-absolute-2.d: New test. * testsuite/gas/mips/mips16-branch-absolute-addend-1.d: New test. * testsuite/gas/mips/mips16-branch-absolute-n32-1.d: New test. * testsuite/gas/mips/mips16-branch-absolute-n32-2.d: New test. * testsuite/gas/mips/mips16-branch-absolute-addend-n32-1.d: New test. * testsuite/gas/mips/mips16-branch-absolute-n64-1.d: New test. * testsuite/gas/mips/mips16-branch-absolute-n64-2.d: New test. * testsuite/gas/mips/mips16-branch-absolute-addend-n64-1.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-1.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-absolute-1.s: New test source. * testsuite/gas/mips/mips16-branch-absolute-1.s: New test source. * testsuite/gas/mips/mips16-branch-absolute-2.s: New test source. * testsuite/gas/mips/mips16-branch-absolute-addend-1.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-mips-elf/mips16-branch-absolute-1.d: New test. * testsuite/ld-mips-elf/mips16-branch-absolute-2.d: New test. * testsuite/ld-mips-elf/mips16-branch-absolute-addend-1.d: New test. * testsuite/ld-mips-elf/mips16-branch-absolute-n32-1.d: New test. * testsuite/ld-mips-elf/mips16-branch-absolute-n32-2.d: New test. * testsuite/ld-mips-elf/mips16-branch-absolute-addend-n32-1.d: New test. * testsuite/ld-mips-elf/mips16-branch-absolute-n64-1.d: New test. * testsuite/ld-mips-elf/mips16-branch-absolute-n64-2.d: New test. * testsuite/ld-mips-elf/mips16-branch-absolute-addend-n64-1.d: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'gas/config/tc-mips.c')
-rw-r--r--gas/config/tc-mips.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index fbf67a1..8c387ba 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -7419,6 +7419,7 @@ append_insn (struct mips_cl_insn *ip, expressionS *address_expr,
else
{
symbol = make_expr_symbol (address_expr);
+ symbol_append (symbol, symbol_lastP, &symbol_rootP, &symbol_lastP);
offset = 0;
}
add_relaxed_insn (ip, 4, 0,
@@ -8087,6 +8088,7 @@ match_mips16_insn (struct mips_cl_insn *insn, const struct mips_opcode *opcode,
const char *args;
const struct mips_operand *operand;
const struct mips_operand *ext_operand;
+ bfd_boolean pcrel = FALSE;
int required_insn_length;
struct mips_arg_info arg;
int relax_char;
@@ -8148,6 +8150,7 @@ match_mips16_insn (struct mips_cl_insn *insn, const struct mips_opcode *opcode,
}
else if (relax_char
&& offset_expr.X_op == O_constant
+ && !pcrel
&& calculate_reloc (*offset_reloc,
offset_expr.X_add_number,
&value))
@@ -8216,7 +8219,9 @@ match_mips16_insn (struct mips_cl_insn *insn, const struct mips_opcode *opcode,
if (!operand)
abort ();
- if (operand->type != OP_PCREL)
+ if (operand->type == OP_PCREL)
+ pcrel = TRUE;
+ else
{
ext_operand = decode_mips16_operand (c, TRUE);
if (operand != ext_operand)