This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [patch] MIPS/ELF: %call_r/%got_r operators for relocation override
- From: "Maciej W. Rozycki" <macro at ds2 dot pg dot gda dot pl>
- To: Richard Sandiford <rsandifo at redhat dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Thu, 28 Aug 2003 22:46:14 +0200 (MET DST)
- Subject: Re: [patch] MIPS/ELF: %call_r/%got_r operators for relocation override
- Organization: Technical University of Gdansk
On 28 Aug 2003, Richard Sandiford wrote:
> Yeah, I see your point. It probably would be bad faith to just remove
> the old functionality without something to replace it.
Here is a patch. I did some preliminary testing and the results seem
good. I'll do some more testing and prepare some tests for the testsuite,
but I'm now sending the patch for comments. This is both for 2.14 and the
trunk.
gas/ChangeLog:
2003-08-29 Maciej W. Rozycki <macro@ds2.pg.gda.pl>
* config/tc-mips.c (macro): Handle new macros: "lca" and "dlca"
for loading addresses using CALL relocations.
include/ChangeLog:
2003-08-29 Maciej W. Rozycki <macro@ds2.pg.gda.pl>
* opcode/mips.h: Define new enum members, M_LCA_AB and M_DLCA_AB.
opcodes/ChangeLog:
2003-08-29 Maciej W. Rozycki <macro@ds2.pg.gda.pl>
* mips-opc.c (mips_builtin_opcodes): Handle new macros: "lca" and
"dlca".
Maciej
--
+ Maciej W. Rozycki, Technical University of Gdansk, Poland +
+--------------------------------------------------------------+
+ e-mail: macro@ds2.pg.gda.pl, PGP key available +
binutils-2.14-mips-lca.patch
diff -up --recursive --new-file binutils-2.14.macro/gas/config/tc-mips.c binutils-2.14/gas/config/tc-mips.c
--- binutils-2.14.macro/gas/config/tc-mips.c 2003-06-02 20:35:25.000000000 +0000
+++ binutils-2.14/gas/config/tc-mips.c 2003-08-27 21:48:11.000000000 +0000
@@ -4174,6 +4174,7 @@ macro (ip)
int coproc = 0;
int lr = 0;
int imm = 0;
+ int call = 0;
offsetT maxnum;
int off;
bfd_reloc_code_real_type r;
@@ -4873,9 +4874,15 @@ macro (ip)
macro_build ((char *) NULL, &icnt, (expressionS *) NULL, s2, "d", dreg);
return;
+ case M_DLCA_AB:
+ dbl = 1;
+ case M_LCA_AB:
+ call = 1;
+ goto do_la;
case M_DLA_AB:
dbl = 1;
case M_LA_AB:
+ do_la:
/* Load the address of a symbol into a register. If breg is not
zero, we then add a base register to it. */
@@ -5058,7 +5065,7 @@ macro (ip)
/* If this is a reference to an external symbol, and there
is no constant, we want
lw $tempreg,<sym>($gp) (BFD_RELOC_MIPS_GOT16)
- or if tempreg is PIC_CALL_REG
+ or for lca or if tempreg is PIC_CALL_REG
lw $tempreg,<sym>($gp) (BFD_RELOC_MIPS_CALL16)
For a local symbol, we want
lw $tempreg,<sym>($gp) (BFD_RELOC_MIPS_GOT16)
@@ -5088,7 +5095,7 @@ macro (ip)
expr1.X_add_number = offset_expr.X_add_number;
offset_expr.X_add_number = 0;
frag_grow (32);
- if (expr1.X_add_number == 0 && tempreg == PIC_CALL_REG)
+ if (expr1.X_add_number == 0 && (call || tempreg == PIC_CALL_REG))
lw_reloc_type = (int) BFD_RELOC_MIPS_CALL16;
macro_build ((char *) NULL, &icnt, &offset_expr,
HAVE_32BIT_ADDRESSES ? "lw" : "ld",
@@ -5193,7 +5200,7 @@ macro (ip)
constant, or local symbol (*), with or without a
constant, we want
lw $tempreg,<sym>($gp) (BFD_RELOC_MIPS_GOT_DISP)
- or if tempreg is PIC_CALL_REG
+ or for lca or if tempreg is PIC_CALL_REG
lw $tempreg,<sym>($gp) (BFD_RELOC_MIPS_CALL16)
If we have a small constant, and this is a reference to
@@ -5213,7 +5220,8 @@ macro (ip)
instruction. */
frag_grow (28);
- if (offset_expr.X_add_number == 0 && tempreg == PIC_CALL_REG)
+ if (offset_expr.X_add_number == 0
+ && (call || tempreg == PIC_CALL_REG))
lw_reloc_type = (int) BFD_RELOC_MIPS_CALL16;
if (offset_expr.X_add_number)
{
@@ -5326,7 +5334,7 @@ macro (ip)
lui $tempreg,<sym> (BFD_RELOC_MIPS_GOT_HI16)
addu $tempreg,$tempreg,$gp
lw $tempreg,<sym>($tempreg) (BFD_RELOC_MIPS_GOT_LO16)
- or if tempreg is PIC_CALL_REG
+ or for lca or if tempreg is PIC_CALL_REG
lui $tempreg,<sym> (BFD_RELOC_MIPS_CALL_HI16)
addu $tempreg,$tempreg,$gp
lw $tempreg,<sym>($tempreg) (BFD_RELOC_MIPS_CALL_LO16)
@@ -5369,7 +5377,7 @@ macro (ip)
gpdel = 4;
else
gpdel = 0;
- if (expr1.X_add_number == 0 && tempreg == PIC_CALL_REG)
+ if (expr1.X_add_number == 0 && (call || tempreg == PIC_CALL_REG))
{
lui_reloc_type = (int) BFD_RELOC_MIPS_CALL_HI16;
lw_reloc_type = (int) BFD_RELOC_MIPS_CALL_LO16;
@@ -5546,7 +5554,7 @@ macro (ip)
lui $tempreg,<sym> (BFD_RELOC_MIPS_GOT_HI16)
add $tempreg,$tempreg,$gp
lw $tempreg,<sym>($tempreg) (BFD_RELOC_MIPS_GOT_LO16)
- or if tempreg is PIC_CALL_REG
+ or for lca or if tempreg is PIC_CALL_REG
lui $tempreg,<sym> (BFD_RELOC_MIPS_CALL_HI16)
add $tempreg,$tempreg,$gp
lw $tempreg,<sym>($tempreg) (BFD_RELOC_MIPS_CALL_LO16)
@@ -5578,7 +5586,7 @@ macro (ip)
expr1.X_add_number = offset_expr.X_add_number;
offset_expr.X_add_number = 0;
- if (expr1.X_add_number == 0 && tempreg == PIC_CALL_REG)
+ if (expr1.X_add_number == 0 && (call || tempreg == PIC_CALL_REG))
{
lui_reloc_type = (int) BFD_RELOC_MIPS_CALL_HI16;
lw_reloc_type = (int) BFD_RELOC_MIPS_CALL_LO16;
diff -up --recursive --new-file binutils-2.14.macro/include/opcode/mips.h binutils-2.14/include/opcode/mips.h
--- binutils-2.14.macro/include/opcode/mips.h 2003-04-09 00:12:24.000000000 +0000
+++ binutils-2.14/include/opcode/mips.h 2003-08-27 21:26:54.000000000 +0000
@@ -545,6 +545,7 @@ enum
M_DIVU_3,
M_DIVU_3I,
M_DLA_AB,
+ M_DLCA_AB,
M_DLI,
M_DMUL,
M_DMUL_I,
@@ -570,6 +571,7 @@ enum
M_LB_AB,
M_LBU_A,
M_LBU_AB,
+ M_LCA_AB,
M_LD_A,
M_LD_OB,
M_LD_AB,
diff -up --recursive --new-file binutils-2.14.macro/opcodes/mips-opc.c binutils-2.14/opcodes/mips-opc.c
--- binutils-2.14.macro/opcodes/mips-opc.c 2003-01-01 01:06:13.000000000 +0000
+++ binutils-2.14/opcodes/mips-opc.c 2003-08-27 21:25:29.000000000 +0000
@@ -508,6 +508,7 @@ const struct mips_opcode mips_builtin_op
{"divu", "d,v,t", 0, (int) M_DIVU_3, INSN_MACRO, I1 },
{"divu", "d,v,I", 0, (int) M_DIVU_3I, INSN_MACRO, I1 },
{"dla", "t,A(b)", 0, (int) M_DLA_AB, INSN_MACRO, I3 },
+{"dlca", "t,A(b)", 0, (int) M_DLCA_AB, INSN_MACRO, I3 },
{"dli", "t,j", 0x24000000, 0xffe00000, WR_t, I3 }, /* addiu */
{"dli", "t,i", 0x34000000, 0xffe00000, WR_t, I3 }, /* ori */
{"dli", "t,I", 0, (int) M_DLI, INSN_MACRO, I3 },
@@ -623,6 +624,7 @@ const struct mips_opcode mips_builtin_op
{"lb", "t,A(b)", 0, (int) M_LB_AB, INSN_MACRO, I1 },
{"lbu", "t,o(b)", 0x90000000, 0xfc000000, LDD|RD_b|WR_t, I1 },
{"lbu", "t,A(b)", 0, (int) M_LBU_AB, INSN_MACRO, I1 },
+{"lca", "t,A(b)", 0, (int) M_LCA_AB, INSN_MACRO, I1 },
{"ld", "t,o(b)", 0xdc000000, 0xfc000000, WR_t|RD_b, I3 },
{"ld", "t,o(b)", 0, (int) M_LD_OB, INSN_MACRO, I1 },
{"ld", "t,A(b)", 0, (int) M_LD_AB, INSN_MACRO, I1 },