This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[committed] MIPS gas dropping symbol offsets
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: 06 Dec 2003 14:08:58 +0000
- Subject: [committed] MIPS gas dropping symbol offsets
mips64-linux-gnu-as -mxgot would sometimes drop the constant from:
lw reg,sym+const
This was because it was recording the constant in frag_now _before_
allocating room for the macro.
Fixing this uncovered problems in the testsuite. elf-rel-xgot-n32.d
and elf-rel-xgot-n64.d were expecting:
lw $5,dl1+34($5)
to be assembled as:
lw $5,dl1($5)
Patch tested on mips64{,el}-linux-gnu, installed as obvious.
Richard
gas/
* config/tc-mips.c (macro): Switch misordered call to frag_grow()
and setting of tc_fr_offset.
gas/testsuite/
* gas/mips/elf-rel16.[sd]: New test.
* gas/mips/mips.exp: Run it.
* gas/mips/elf-rel-xgot-n32.d: Fix addends for "lw $5,dl1+34($5)".
* gas/mips/elf-rel-xgot-n64.d: Likewise.
Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.239
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.239 tc-mips.c
*** gas/config/tc-mips.c 22 Nov 2003 02:35:30 -0000 1.239
--- gas/config/tc-mips.c 6 Dec 2003 13:38:22 -0000
*************** macro (struct mips_cl_insn *ip)
*** 6348,6360 ****
lw $tempreg,<sym>($gp) (BFD_RELOC_MIPS_GOT_PAGE)
<op> $treg,<sym>($tempreg) (BFD_RELOC_MIPS_GOT_OFST) */
assert (offset_expr.X_op == O_symbol);
frag_now->tc_frag_data.tc_fr_offset =
expr1.X_add_number = offset_expr.X_add_number;
offset_expr.X_add_number = 0;
if (expr1.X_add_number < -0x8000
|| expr1.X_add_number >= 0x8000)
as_bad (_("PIC code offset overflow (max 16 signed bits)"));
- frag_grow (36);
macro_build (NULL, &icnt, &offset_expr, "lui", "t,u", tempreg,
BFD_RELOC_MIPS_GOT_HI16);
macro_build (NULL, &icnt, NULL, ADDRESS_ADD_INSN, "d,v,t",
--- 6348,6360 ----
lw $tempreg,<sym>($gp) (BFD_RELOC_MIPS_GOT_PAGE)
<op> $treg,<sym>($tempreg) (BFD_RELOC_MIPS_GOT_OFST) */
assert (offset_expr.X_op == O_symbol);
+ frag_grow (36);
frag_now->tc_frag_data.tc_fr_offset =
expr1.X_add_number = offset_expr.X_add_number;
offset_expr.X_add_number = 0;
if (expr1.X_add_number < -0x8000
|| expr1.X_add_number >= 0x8000)
as_bad (_("PIC code offset overflow (max 16 signed bits)"));
macro_build (NULL, &icnt, &offset_expr, "lui", "t,u", tempreg,
BFD_RELOC_MIPS_GOT_HI16);
macro_build (NULL, &icnt, NULL, ADDRESS_ADD_INSN, "d,v,t",
Index: gas/testsuite/gas/mips/elf-rel-xgot-n32.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/elf-rel-xgot-n32.d,v
retrieving revision 1.3
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.3 elf-rel-xgot-n32.d
*** gas/testsuite/gas/mips/elf-rel-xgot-n32.d 1 Sep 2003 17:36:47 -0000 1.3
--- gas/testsuite/gas/mips/elf-rel-xgot-n32.d 6 Dec 2003 13:38:22 -0000
*************** 0000048c <fn\+0x48c> 00b12821 addu a1,a
*** 442,451 ****
00000490 <fn\+0x490> 8ca50000 lw a1,0\(a1\)
490: R_MIPS_GOT_OFST \.data\+0xc0
00000494 <fn\+0x494> 8f810000 lw at,0\(gp\)
! 494: R_MIPS_GOT_PAGE \.data\+0xb4
00000498 <fn\+0x498> 00250821 addu at,at,a1
0000049c <fn\+0x49c> 8c250000 lw a1,0\(at\)
! 49c: R_MIPS_GOT_OFST \.data\+0xb4
000004a0 <fn\+0x4a0> 8f810000 lw at,0\(gp\)
4a0: R_MIPS_GOT_PAGE \.data\+0xec
000004a4 <fn\+0x4a4> 00250821 addu at,at,a1
--- 442,451 ----
00000490 <fn\+0x490> 8ca50000 lw a1,0\(a1\)
490: R_MIPS_GOT_OFST \.data\+0xc0
00000494 <fn\+0x494> 8f810000 lw at,0\(gp\)
! 494: R_MIPS_GOT_PAGE \.data\+0xd6
00000498 <fn\+0x498> 00250821 addu at,at,a1
0000049c <fn\+0x49c> 8c250000 lw a1,0\(at\)
! 49c: R_MIPS_GOT_OFST \.data\+0xd6
000004a0 <fn\+0x4a0> 8f810000 lw at,0\(gp\)
4a0: R_MIPS_GOT_PAGE \.data\+0xec
000004a4 <fn\+0x4a4> 00250821 addu at,at,a1
Index: gas/testsuite/gas/mips/elf-rel-xgot-n64.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/elf-rel-xgot-n64.d,v
retrieving revision 1.2
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.2 elf-rel-xgot-n64.d
*** gas/testsuite/gas/mips/elf-rel-xgot-n64.d 1 Sep 2003 17:36:47 -0000 1.2
--- gas/testsuite/gas/mips/elf-rel-xgot-n64.d 6 Dec 2003 13:38:22 -0000
*************** 0000000000000490 <fn\+0x490> dca50000 l
*** 726,739 ****
490: R_MIPS_NONE \*ABS\*\+0xc0
490: R_MIPS_NONE \*ABS\*\+0xc0
0000000000000494 <fn\+0x494> df810000 ld at,0\(gp\)
! 494: R_MIPS_GOT_PAGE \.data\+0xb4
! 494: R_MIPS_NONE \*ABS\*\+0xb4
! 494: R_MIPS_NONE \*ABS\*\+0xb4
0000000000000498 <fn\+0x498> 0025082d daddu at,at,a1
000000000000049c <fn\+0x49c> dc250000 ld a1,0\(at\)
! 49c: R_MIPS_GOT_OFST \.data\+0xb4
! 49c: R_MIPS_NONE \*ABS\*\+0xb4
! 49c: R_MIPS_NONE \*ABS\*\+0xb4
00000000000004a0 <fn\+0x4a0> df810000 ld at,0\(gp\)
4a0: R_MIPS_GOT_PAGE \.data\+0xec
4a0: R_MIPS_NONE \*ABS\*\+0xec
--- 726,739 ----
490: R_MIPS_NONE \*ABS\*\+0xc0
490: R_MIPS_NONE \*ABS\*\+0xc0
0000000000000494 <fn\+0x494> df810000 ld at,0\(gp\)
! 494: R_MIPS_GOT_PAGE \.data\+0xd6
! 494: R_MIPS_NONE \*ABS\*\+0xd6
! 494: R_MIPS_NONE \*ABS\*\+0xd6
0000000000000498 <fn\+0x498> 0025082d daddu at,at,a1
000000000000049c <fn\+0x49c> dc250000 ld a1,0\(at\)
! 49c: R_MIPS_GOT_OFST \.data\+0xd6
! 49c: R_MIPS_NONE \*ABS\*\+0xd6
! 49c: R_MIPS_NONE \*ABS\*\+0xd6
00000000000004a0 <fn\+0x4a0> df810000 ld at,0\(gp\)
4a0: R_MIPS_GOT_PAGE \.data\+0xec
4a0: R_MIPS_NONE \*ABS\*\+0xec
Index: gas/testsuite/gas/mips/mips.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.80
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.80 mips.exp
*** gas/testsuite/gas/mips/mips.exp 18 Nov 2003 21:22:55 -0000 1.80
--- gas/testsuite/gas/mips/mips.exp 6 Dec 2003 13:38:22 -0000
*************** if { [istarget mips*-*-*] } then {
*** 663,668 ****
--- 663,669 ----
if $has_newabi {
run_dump_test "elf-rel15"
+ run_dump_test "elf-rel16"
run_dump_test "elf-rel-got-n32"
run_dump_test "elf-rel-xgot-n32"
*** /dev/null Tue Jun 17 23:06:41 2003
--- gas/testsuite/gas/mips/elf-rel16.d Sat Dec 6 13:33:09 2003
***************
*** 0 ****
--- 1,14 ----
+ #objdump: -dr
+ #as: -mabi=n32 -mips3 -xgot -KPIC
+
+ .*: file format .*
+
+ Disassembly of section \.text:
+
+ 00000000 <.*>:
+ \.\.\.
+ .*: 8f840000 lw a0,0\(gp\)
+ .*: R_MIPS_GOT_PAGE \.rodata\+0x8
+ .*: dc840000 ld a0,0\(a0\)
+ .*: R_MIPS_GOT_OFST \.rodata\+0x8
+ \.\.\.
*** /dev/null Tue Jun 17 23:06:41 2003
--- gas/testsuite/gas/mips/elf-rel16.s Sat Dec 6 13:29:22 2003
***************
*** 0 ****
--- 1,8 ----
+ .rept 0x3e0
+ nop
+ .endr
+ ld $4,foo+8
+ .space 16
+ .section .rodata
+ foo:
+ .word 1,2,3,4