From: Richard Sandiford Date: Fri, 21 Feb 2003 10:28:27 +0000 (+0000) Subject: * config/tc-mips.c (prev_reloc_op_frag): New variable. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=64bdfcaf0d1a419402fe5cc8fcd0bafb92c6b5c7;p=binutils-gdb.git * config/tc-mips.c (prev_reloc_op_frag): New variable. (macro): Check it to decide whether a new frag is needed. (my_getSmallExpression): Set it. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index be50f0dc5a7..d887b70e530 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2003-02-21 Richard Sandiford + + * config/tc-mips.c (prev_reloc_op_frag): New variable. + (macro): Check it to decide whether a new frag is needed. + (my_getSmallExpression): Set it. + 2003-02-20 jmc * cgen.c: Fix typo: intial -> initial. diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 4c0052bec7f..e075cc9cf55 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -555,6 +555,11 @@ struct mips_hi_fixup static struct mips_hi_fixup *mips_hi_fixup_list; +/* The frag containing the last explicit relocation operator. + Null if explicit relocations have not been used. */ + +static fragS *prev_reloc_op_frag; + /* Map normal MIPS register numbers to mips16 register numbers. */ #define X ILLEGAL_REG @@ -4106,10 +4111,13 @@ macro (ip) #2. This would confuse tc_gen_reloc, which expects the relocations for #2 to be the last for that frag. - If it looks like this situation could happen, put the macro - in a new frag. */ - if (mips_hi_fixup_list != 0 - && mips_hi_fixup_list->fixp->fx_frag == frag_now) + Also, if tc_gen_reloc sees certain relocations in a variant frag, + it assumes that they belong to a relaxable macro. We mustn't put + other uses of such relocations into a variant frag. + + To avoid both problems, finish the current frag it contains a + %reloc() operator. The macro then goes into a new frag. */ + if (prev_reloc_op_frag == frag_now) { frag_wane (frag_now); frag_new (0); @@ -10103,9 +10111,14 @@ my_getSmallExpression (ep, reloc, str) expr_end = str; - reloc[0] = BFD_RELOC_LO16; - for (i = 0; i < reloc_index; i++) - reloc[i] = reversed_reloc[reloc_index - 1 - i]; + if (reloc_index == 0) + reloc[0] = BFD_RELOC_LO16; + else + { + prev_reloc_op_frag = frag_now; + for (i = 0; i < reloc_index; i++) + reloc[i] = reversed_reloc[reloc_index - 1 - i]; + } return reloc_index; } diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index c9be2ed14ac..58d8f0c6ef8 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-02-21 Richard Sandiford + + * gas/mips/elf-rel14.[sd]: New test. + * gas/mips/mips.exp: Run it. + 2003-02-07 Richard Sandiford * gas/mips/rel12.[sd], gas/mips/rel13.[sd]: New tests. diff --git a/gas/testsuite/gas/mips/elf-rel14.d b/gas/testsuite/gas/mips/elf-rel14.d new file mode 100644 index 00000000000..b6aec52e882 --- /dev/null +++ b/gas/testsuite/gas/mips/elf-rel14.d @@ -0,0 +1,18 @@ +#as: -march=mips1 -mabi=32 -KPIC +#objdump: -M gpr-names=numeric -dr +#name: MIPS ELF reloc 14 + +.*: file format .* + +Disassembly of section \.text: + +0+00 : + 0: 8f840000 lw \$4,0\(\$28\) + 0: R_MIPS_CALL16 bar + 4: 8f850000 lw \$5,0\(\$28\) + 4: R_MIPS_GOT16 \.text + 8: 00000000 nop + c: 24a50014 addiu \$5,\$5,20 + c: R_MIPS_LO16 \.text + 10: 24c60001 addiu \$6,\$6,1 + \.\.\. diff --git a/gas/testsuite/gas/mips/elf-rel14.s b/gas/testsuite/gas/mips/elf-rel14.s new file mode 100644 index 00000000000..2edd5b39f8b --- /dev/null +++ b/gas/testsuite/gas/mips/elf-rel14.s @@ -0,0 +1,10 @@ + .ent foo +foo: + lw $4,%call16(bar)($28) + la $5,.L1 + # Insert an instruction that doesn't use $5 to avoid a spurious + # nop after the previous load macro. + addiu $6,$6,1 +.L1: + .space 32 + .end foo diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp index 9d950a4d57c..eaf7d37e1d5 100644 --- a/gas/testsuite/gas/mips/mips.exp +++ b/gas/testsuite/gas/mips/mips.exp @@ -610,6 +610,7 @@ if { [istarget mips*-*-*] } then { } run_dump_test "elf-rel12" run_dump_test "elf-rel13" + run_dump_test "elf-rel14" run_dump_test "${tmips}${el}empic" run_dump_test "empic2" run_dump_test "empic3_e"