aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2017-07-01 00:42:19 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2017-07-01 00:42:19 +0100
commitbbd27b7684baf424bdaa7f0a1d39a2cd5b0d6134 (patch)
tree10fc7d1266f601db4f36fe0b9cb92e73ee5bd508
parent9f00292e69635d48623372c7a3e390dc5d159a8f (diff)
MIPS/GAS: Use frag symbol/offset directly in fixup creation
There is no need to use a helper expression in the creation of fixups made from a frag's symbol and offset, because a simple `symbol+offset' expression can be handled directly, with the use of a `fix_new' rather than a `fix_new_exp' call. Rewrite `md_convert_frag' using `fix_new' then and remove all the unneeded helper expressions, simplifying code. gas/ * config/tc-mips.c (md_convert_frag): Rewrite `fix_new_exp' calls in terms of `fix_new'.
-rw-r--r--gas/ChangeLog5
-rw-r--r--gas/config/tc-mips.c77
2 files changed, 38 insertions, 44 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 7dad3418c7..94a6a68651 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,10 @@
2017-06-30 Maciej W. Rozycki <macro@imgtec.com>
+ * config/tc-mips.c (md_convert_frag): Rewrite `fix_new_exp'
+ calls in terms of `fix_new'.
+
+2017-06-30 Maciej W. Rozycki <macro@imgtec.com>
+
* config/tc-mips.c (md_convert_frag): Don't make a helper
expression symbol for `fix_new_exp' called with a non-zero
offset.
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 3682cd5b0d..a58c484f1f 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -18135,7 +18135,6 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
{
char *buf;
unsigned long insn;
- expressionS exp;
fixS *fixp;
buf = fragp->fr_literal + fragp->fr_fix;
@@ -18146,12 +18145,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
/* We generate a fixup instead of applying it right now
because, if there are linker relaxations, we're going to
need the relocations. */
- exp.X_op = O_symbol;
- exp.X_add_symbol = fragp->fr_symbol;
- exp.X_add_number = fragp->fr_offset;
-
- fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp, TRUE,
- BFD_RELOC_16_PCREL_S2);
+ fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+ fragp->fr_symbol, fragp->fr_offset,
+ TRUE, BFD_RELOC_16_PCREL_S2);
fixp->fx_file = fragp->fr_file;
fixp->fx_line = fragp->fr_line;
@@ -18267,12 +18263,10 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
/* j or jal. */
insn = (RELAX_BRANCH_LINK (fragp->fr_subtype)
? 0x0c000000 : 0x08000000);
- exp.X_op = O_symbol;
- exp.X_add_symbol = fragp->fr_symbol;
- exp.X_add_number = fragp->fr_offset;
- fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp,
- FALSE, BFD_RELOC_MIPS_JMP);
+ fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+ fragp->fr_symbol, fragp->fr_offset,
+ FALSE, BFD_RELOC_MIPS_JMP);
fixp->fx_file = fragp->fr_file;
fixp->fx_line = fragp->fr_line;
@@ -18285,12 +18279,10 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
/* lw/ld $at, <sym>($gp) R_MIPS_GOT16 */
insn = HAVE_64BIT_ADDRESSES ? 0xdf800000 : 0x8f800000;
insn |= at << OP_SH_RT;
- exp.X_op = O_symbol;
- exp.X_add_symbol = fragp->fr_symbol;
- exp.X_add_number = fragp->fr_offset;
- fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp,
- FALSE, BFD_RELOC_MIPS_GOT16);
+ fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+ fragp->fr_symbol, fragp->fr_offset,
+ FALSE, BFD_RELOC_MIPS_GOT16);
fixp->fx_file = fragp->fr_file;
fixp->fx_line = fragp->fr_line;
@@ -18304,8 +18296,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
insn = HAVE_64BIT_ADDRESSES ? 0x64000000 : 0x24000000;
insn |= at << OP_SH_RS | at << OP_SH_RT;
- fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp,
- FALSE, BFD_RELOC_LO16);
+ fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+ fragp->fr_symbol, fragp->fr_offset,
+ FALSE, BFD_RELOC_LO16);
fixp->fx_file = fragp->fr_file;
fixp->fx_line = fragp->fr_line;
@@ -18339,13 +18332,8 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
int type = RELAX_MICROMIPS_TYPE (fragp->fr_subtype);
bfd_boolean short_ds;
unsigned long insn;
- expressionS exp;
fixS *fixp;
- exp.X_op = O_symbol;
- exp.X_add_symbol = fragp->fr_symbol;
- exp.X_add_number = fragp->fr_offset;
-
fragp->fr_fix += fragp->fr_var;
/* Handle 16-bit branches that fit or are forced to fit. */
@@ -18355,11 +18343,13 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
because if there is linker relaxation, we're going to
need the relocations. */
if (type == 'D')
- fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 2, &exp, TRUE,
- BFD_RELOC_MICROMIPS_10_PCREL_S1);
+ fixp = fix_new (fragp, buf - fragp->fr_literal, 2,
+ fragp->fr_symbol, fragp->fr_offset,
+ TRUE, BFD_RELOC_MICROMIPS_10_PCREL_S1);
else if (type == 'E')
- fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 2, &exp, TRUE,
- BFD_RELOC_MICROMIPS_7_PCREL_S1);
+ fixp = fix_new (fragp, buf - fragp->fr_literal, 2,
+ fragp->fr_symbol, fragp->fr_offset,
+ TRUE, BFD_RELOC_MICROMIPS_7_PCREL_S1);
else
abort ();
@@ -18380,8 +18370,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
/* We generate a fixup instead of applying it right now,
because if there is linker relaxation, we're going to
need the relocations. */
- fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp, TRUE,
- BFD_RELOC_MICROMIPS_16_PCREL_S1);
+ fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+ fragp->fr_symbol, fragp->fr_offset,
+ TRUE, BFD_RELOC_MICROMIPS_16_PCREL_S1);
fixp->fx_file = fragp->fr_file;
fixp->fx_line = fragp->fr_line;
@@ -18518,8 +18509,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
/* j/jal/jals <sym> R_MICROMIPS_26_S1 */
insn = al ? jal : 0xd4000000;
- fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp, FALSE,
- BFD_RELOC_MICROMIPS_JMP);
+ fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+ fragp->fr_symbol, fragp->fr_offset,
+ FALSE, BFD_RELOC_MICROMIPS_JMP);
fixp->fx_file = fragp->fr_file;
fixp->fx_line = fragp->fr_line;
@@ -18542,8 +18534,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
insn = HAVE_64BIT_ADDRESSES ? 0xdc1c0000 : 0xfc1c0000;
insn |= at << MICROMIPSOP_SH_RT;
- fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp, FALSE,
- BFD_RELOC_MICROMIPS_GOT16);
+ fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+ fragp->fr_symbol, fragp->fr_offset,
+ FALSE, BFD_RELOC_MICROMIPS_GOT16);
fixp->fx_file = fragp->fr_file;
fixp->fx_line = fragp->fr_line;
@@ -18553,8 +18546,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
insn = HAVE_64BIT_ADDRESSES ? 0x5c000000 : 0x30000000;
insn |= at << MICROMIPSOP_SH_RT | at << MICROMIPSOP_SH_RS;
- fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp, FALSE,
- BFD_RELOC_MICROMIPS_LO16);
+ fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+ fragp->fr_symbol, fragp->fr_offset,
+ FALSE, BFD_RELOC_MICROMIPS_LO16);
fixp->fx_file = fragp->fr_file;
fixp->fx_line = fragp->fr_line;
@@ -18758,7 +18752,6 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
if (need_reloc)
{
bfd_reloc_code_real_type reloc = BFD_RELOC_NONE;
- expressionS exp;
fixS *fixp;
switch (type)
@@ -18775,13 +18768,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
_("unsupported relocation"));
else if (ext)
{
- exp.X_op = O_symbol;
- exp.X_add_symbol = fragp->fr_symbol;
- exp.X_add_number = fragp->fr_offset;
-
- fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp,
- TRUE, reloc);
-
+ fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+ fragp->fr_symbol, fragp->fr_offset,
+ TRUE, reloc);
fixp->fx_file = fragp->fr_file;
fixp->fx_line = fragp->fr_line;
}