This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] MIPS/GAS: Add missing label annotation to PIC pseudo-ops
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: Richard Sandiford <rdsandiford at googlemail dot com>
- Cc: <binutils at sourceware dot org>
- Date: Mon, 18 Feb 2013 15:00:09 +0000
- Subject: [PATCH] MIPS/GAS: Add missing label annotation to PIC pseudo-ops
Hi,
Another issue that came out in microMIPS PLT testing. We have a bunch of
pseud-ops used in the PIC mode that produce code. But none of them
actually requests any preceding label to be annotated for ISA bit setting
in the microMIPS mode. As a result code elsewhere decides they produce
data and keeps the ISA bit cleared. This in turn causes broken code,
e.g.:
.abicalls
.set micromips
.globl fun
.ent fun
fun:
.cplocal $v0
.cpsetup $t9, $zero, fun
daddiu $sp, $sp, -16
[...]
.end fun
will cause fun to be output as a standard MIPS symbol and any function
calls made to it will break.
This bug managed to escape unnoticed, because we didn't do much with
NewABI microMIPS support and with .cpload used on o32 we usually cover
this bug, because the pseudo-op is usually wrapped into a local .set
noreorder/.set reorder block and .set noreorder already triggers code for
label annotation. However this:
.abicalls
.set micromips
.set noreorder
.globl fun
.ent fun
fun:
.cpload $t9
addiu $sp, $sp, -32
[...]
.end fun
is actually valid code and there's nothing before .cpload to cause the
required label annotation. Local labels are of course also affected.
The change below implements the missing bits. No regressions across the
usual 25 MIPS targets. OK to apply?
2013-02-18 Maciej W. Rozycki <macro@codesourcery.com>
gas/
* config/tc-mips.c (s_cpload): Call mips_mark_labels and set
mips_assembling_insn appropriately.
(s_cpsetup, s_cprestore, s_cpreturn, s_cpadd): Likewise.
Maciej
binutils-gas-umips-picop-label.diff
Index: binutils-fsf-trunk-quilt/gas/config/tc-mips.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/gas/config/tc-mips.c 2013-02-17 07:01:48.055496697 +0000
+++ binutils-fsf-trunk-quilt/gas/config/tc-mips.c 2013-02-17 07:07:46.854516818 +0000
@@ -16621,6 +16621,9 @@ s_cpload (int ignore ATTRIBUTE_UNUSED)
/* In ELF, this symbol is implicitly an STT_OBJECT symbol. */
symbol_get_bfdsym (ex.X_add_symbol)->flags |= BSF_OBJECT;
+ mips_mark_labels ();
+ mips_assembling_insn = TRUE;
+
macro_start ();
macro_build_lui (&ex, mips_gp_register);
macro_build (&ex, "addiu", "t,r,j", mips_gp_register,
@@ -16630,6 +16633,7 @@ s_cpload (int ignore ATTRIBUTE_UNUSED)
mips_gp_register, reg);
macro_end ();
+ mips_assembling_insn = FALSE;
demand_empty_rest_of_line ();
}
@@ -16706,6 +16710,9 @@ s_cpsetup (int ignore ATTRIBUTE_UNUSED)
SKIP_WHITESPACE ();
expression (&ex_sym);
+ mips_mark_labels ();
+ mips_assembling_insn = TRUE;
+
macro_start ();
if (mips_cpreturn_register == -1)
{
@@ -16753,6 +16760,8 @@ s_cpsetup (int ignore ATTRIBUTE_UNUSED)
macro_end ();
+ mips_assembling_insn = FALSE;
+
demand_empty_rest_of_line ();
}
@@ -16810,11 +16819,15 @@ s_cprestore (int ignore ATTRIBUTE_UNUSED
ex.X_op_symbol = NULL;
ex.X_add_number = mips_cprestore_offset;
+ mips_mark_labels ();
+ mips_assembling_insn = TRUE;
+
macro_start ();
macro_build_ldst_constoffset (&ex, ADDRESS_STORE_INSN, mips_gp_register,
SP, HAVE_64BIT_ADDRESSES);
macro_end ();
+ mips_assembling_insn = FALSE;
demand_empty_rest_of_line ();
}
@@ -16845,6 +16858,9 @@ s_cpreturn (int ignore ATTRIBUTE_UNUSED)
return;
}
+ mips_mark_labels ();
+ mips_assembling_insn = TRUE;
+
macro_start ();
if (mips_cpreturn_register == -1)
{
@@ -16860,6 +16876,7 @@ s_cpreturn (int ignore ATTRIBUTE_UNUSED)
mips_cpreturn_register, 0);
macro_end ();
+ mips_assembling_insn = FALSE;
demand_empty_rest_of_line ();
}
@@ -17039,12 +17056,16 @@ s_cpadd (int ignore ATTRIBUTE_UNUSED)
return;
}
+ mips_mark_labels ();
+ mips_assembling_insn = TRUE;
+
/* Add $gp to the register named as an argument. */
macro_start ();
reg = tc_get_register (0);
macro_build (NULL, ADDRESS_ADD_INSN, "d,v,t", reg, reg, mips_gp_register);
macro_end ();
+ mips_assembling_insn = FALSE;
demand_empty_rest_of_line ();
}