This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[committed] Fix frag undergrowth in mips_build_jalr
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Mon, 12 Jan 2004 09:43:25 +0000
- Subject: [committed] Fix frag undergrowth in mips_build_jalr
The code that adds an R_MIPS_JALR reloc will make sure that the current
frag has enough room for the jalr itself, but it doesn't account for the
delay slot. Thus the call to macro_build() can start a new frag and the
address cached in "f" will be wrong.
The symptom is an out-of-range reloc error for the second "jalr"
in the attached testcase.
Tested on mips64-linux-gnu, installed as obvious.
Richard
gas/
* config/tc-mips.c (macro_build_jalr): When adding an R_MIPS_JALR
reloc, reserve space for the delay slot as well as the jalr itself.
gas/testsuite/
* gas/mips/elf-rel18.[sd]: New test.
* gas/mips/mips.exp: Run it.
Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.244
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.244 tc-mips.c
*** gas/config/tc-mips.c 9 Jan 2004 02:34:04 -0000 1.244
--- gas/config/tc-mips.c 12 Jan 2004 09:29:16 -0000
*************** macro_build_jalr (int icnt, expressionS
*** 3169,3175 ****
if (HAVE_NEWABI)
{
! frag_grow (4);
f = frag_more (0);
}
macro_build (NULL, &icnt, NULL, "jalr", "d,s", RA, PIC_CALL_REG);
--- 3169,3175 ----
if (HAVE_NEWABI)
{
! frag_grow (8);
f = frag_more (0);
}
macro_build (NULL, &icnt, NULL, "jalr", "d,s", RA, PIC_CALL_REG);
Index: gas/testsuite/gas/mips/mips.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.82
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.82 mips.exp
*** gas/testsuite/gas/mips/mips.exp 18 Dec 2003 10:23:10 -0000 1.82
--- gas/testsuite/gas/mips/mips.exp 12 Jan 2004 09:29:16 -0000
*************** if { [istarget mips*-*-*] } then {
*** 671,676 ****
--- 671,679 ----
run_dump_test "elf-rel-xgot-n64"
}
run_dump_test "elf-rel17"
+ if $has_newabi {
+ run_dump_test "elf-rel18"
+ }
run_dump_test "${tmips}${el}empic"
run_dump_test "empic2"
Index: gas/testsuite/gas/mips/elf-rel18.d
===================================================================
RCS file: gas/testsuite/gas/mips/elf-rel18.d
diff -N gas/testsuite/gas/mips/elf-rel18.d
*** gas/testsuite/gas/mips/elf-rel18.d 1 Jan 1970 00:00:00 -0000
--- gas/testsuite/gas/mips/elf-rel18.d 12 Jan 2004 09:29:16 -0000
***************
*** 0 ****
--- 1,9 ----
+ #readelf: --relocs
+ #as: -mabi=n32 -KPIC
+
+ Relocation section '\.rela\.text' at offset .* contains 4 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+ 00000ed0 .* R_MIPS_CALL16 00000000 foo \+ 0
+ 00000ed4 .* R_MIPS_JALR 00000000 foo \+ 0
+ 00000edc .* R_MIPS_CALL16 00000000 foo \+ 0
+ 00000ee0 .* R_MIPS_JALR 00000000 foo \+ 0
Index: gas/testsuite/gas/mips/elf-rel18.s
===================================================================
RCS file: gas/testsuite/gas/mips/elf-rel18.s
diff -N gas/testsuite/gas/mips/elf-rel18.s
*** gas/testsuite/gas/mips/elf-rel18.s 1 Jan 1970 00:00:00 -0000
--- gas/testsuite/gas/mips/elf-rel18.s 12 Jan 2004 09:29:16 -0000
***************
*** 0 ****
--- 1,5 ----
+ .rept 0x3b4
+ nop
+ .endr
+ jal foo
+ jal foo