This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Patch to fix recent MIPS gas reloc breakage
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: binutils at sources dot redhat dot com
- Cc: echristo at redhat dot com
- Date: 07 Feb 2003 13:41:01 +0000
- Subject: Patch to fix recent MIPS gas reloc breakage
Brown paper bag time ;(. The first of my two recent gas
patches broke newlib because we no longer accepted things like:
lw $4,((10 + 4) * 4)($4)
Thanks to Graham for the heads-up.
The problem was that my_getSmallExpression() was eating all
leading open brackets, regardless of whether they belonged
to reloc expressions. I _knew_ that that "break" meant trouble...
Patch tested on mips64-elf (binutils, gas, ld), no regressions. I'm
running a mips64-elf gcc test as well: so far newlib & libgloss have
built successfully. OK to install if the gcc tests pass?
Really sorry for the breakage.
Richard
* config/tc-mips.c (my_getSmallExpression): Rework bracket handling.
testsuite/
* gas/mips/expr1.[sd]: New test.
* gas/mips/mips.exp: Run it.
Index: config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.190
diff -c -d -p -F^[(a-zA-Z0-9_^#] -r1.190 tc-mips.c
*** config/tc-mips.c 2 Feb 2003 19:37:20 -0000 1.190
--- config/tc-mips.c 7 Feb 2003 13:13:10 -0000
*************** my_getSmallExpression (ep, reloc, str)
*** 10020,10055 ****
{
bfd_reloc_code_real_type reversed_reloc[3];
size_t reloc_index, i;
! int bracket_depth;
!
! reloc_index = 0;
! bracket_depth = 0;
/* Search for the start of the main expression, recoding relocations
! in REVERSED_RELOC. */
! for (;;)
{
! if (*str == '(')
! bracket_depth++, str++;
! else if (*str == ' ' || *str == '\t')
! str++;
! else if (*str == '%'
! && reloc_index < (HAVE_NEWABI ? 3 : 1)
! && parse_relocation (&str, &reversed_reloc[reloc_index]))
! reloc_index++;
! else
! break;
}
! my_getExpression (ep, str);
str = expr_end;
/* Match every open bracket. */
! while (bracket_depth > 0 && (*str == ')' || *str == ' ' || *str == '\t'))
if (*str++ == ')')
! bracket_depth--;
! if (bracket_depth > 0)
as_bad ("unclosed '('");
expr_end = str;
--- 10018,10057 ----
{
bfd_reloc_code_real_type reversed_reloc[3];
size_t reloc_index, i;
! int crux_depth, str_depth;
! char *crux;
/* Search for the start of the main expression, recoding relocations
! in REVERSED_RELOC. End the loop with CRUX pointing to the start
! of the main expression and with CRUX_DEPTH containing the number
! of open brackets at that point. */
! reloc_index = -1;
! str_depth = 0;
! do
{
! reloc_index++;
! crux = str;
! crux_depth = str_depth;
!
! /* Skip over whitespace and brackets, keeping count of the number
! of brackets. */
! while (*str == ' ' || *str == '\t' || *str == '(')
! if (*str++ == '(')
! str_depth++;
}
+ while (*str == '%'
+ && reloc_index < (HAVE_NEWABI ? 3 : 1)
+ && parse_relocation (&str, &reversed_reloc[reloc_index]));
! my_getExpression (ep, crux);
str = expr_end;
/* Match every open bracket. */
! while (crux_depth > 0 && (*str == ')' || *str == ' ' || *str == '\t'))
if (*str++ == ')')
! crux_depth--;
! if (crux_depth > 0)
as_bad ("unclosed '('");
expr_end = str;
Index: testsuite/gas/mips/mips.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.59
diff -c -d -p -F^[(a-zA-Z0-9_^#] -r1.59 mips.exp
*** testsuite/gas/mips/mips.exp 2 Feb 2003 19:37:20 -0000 1.59
--- testsuite/gas/mips/mips.exp 7 Feb 2003 13:13:10 -0000
*************** if { [istarget mips*-*-*] } then {
*** 618,623 ****
--- 618,624 ----
run_dump_test "${tmips}mips${el}16-f"
}
run_dump_test "elf-consthilo"
+ run_dump_test "expr1"
}
if $has_newabi {
*** /dev/null Thu Apr 11 15:25:15 2002
--- testsuite/gas/mips/expr1.d Fri Feb 7 13:12:22 2003
***************
*** 0 ****
--- 1,19 ----
+ #as: -march=mips2 -mabi=32
+ #objdump: -M gpr-names=numeric -dr
+ #name: MIPS expression 1
+
+ .*: file format .*
+
+ Disassembly of section \.text:
+
+ 0+00 <foo>:
+ 0: 8c840000 lw \$4,0\(\$4\)
+ 0: R_MIPS_LO16 foo
+ 4: 8c840038 lw \$4,56\(\$4\)
+ 8: 8c840008 lw \$4,8\(\$4\)
+ 8: R_MIPS_LO16 foo
+ c: 8c840008 lw \$4,8\(\$4\)
+ c: R_MIPS_LO16 foo
+ 10: 8c840008 lw \$4,8\(\$4\)
+ 10: R_MIPS_LO16 foo
+ \.\.\.
*** /dev/null Thu Apr 11 15:25:15 2002
--- testsuite/gas/mips/expr1.s Fri Feb 7 13:08:24 2003
***************
*** 0 ****
--- 1,10 ----
+ .globl foo
+ .ent foo
+ foo:
+ lw $4,%lo(foo)($4)
+ lw $4,((10 + 4) * 4)($4)
+ lw $4,%lo (2 * 4) + foo($4)
+ lw $4,%lo((2 * 4) + foo)($4)
+ lw $4,(((%lo ((2 * 4) + foo))))($4)
+ .space 64
+ .end foo