This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: GAS REGRESSION: .sleb128 tests
- From: Julian Brown <julian at codesourcery dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: <binutils at sourceware dot org>
- Date: Fri, 12 Apr 2013 15:42:04 +0100
- Subject: Re: GAS REGRESSION: .sleb128 tests
- References: <874nfcf21p dot fsf at redhat dot com>
On Fri, 12 Apr 2013 11:58:42 +0100
Nick Clifton <nickc@redhat.com> wrote:
> Hi Julian,
>
> I am seeing a lot of new regressions in the GAS testsuites for
> various targets:
> [...]
> Please could you have a look at these failures and either fix the
> tests so that they will work correctly or else arrange to skip the
> tests for the particular targets that are affected. If you do skip a
> target, please could you add a comment explaining why the test does
> not work on that particular target.
Here's a patch which fixes the targets you listed. Most of the problems
were just assembly syntax (some targets don't seem to like "." for
labels, some targets are fussier about tabs at the start of some
lines). I only needed to skip a test for tic4x and tic54x, since those
don't use 8-bit bytes and that messes up the dump output.
There was a real bug though -- SH does some of its own expression
processing, and that hadn't been modified to take into account the new
bit of precision. The change in the attached patch just mirrors a
similar change in expr.c from the previous patch, and seems to work
fine.
Tested with "make check" for gas for mmix-mmixware, rx-elf, sh-elf,
tic4x-coff, tic54x-coff, xtensa-elf, arm-elf and mips-linux -- all
sleb128 tests now pass.
OK to apply?
Thanks,
Julian
ChangeLog
gas/
* expr.c (add_to_result, subtract_from_result): Make global.
* expr.h (add_to_result, subtract_from_result): Add prototypes.
* config/tc-sh.c (sh_optimize_expr): Use add_to_result,
subtract_from_result to handle extra bit of precision for .sleb128
directive operands.
gas/testsuite/
* gas/all/gas.exp (sleb128-7): Don't run for tic4x, tic54x.
* gas/all/sleb128-2.s: Reformat, use _ at start of labels, remove
cruft.
* gas/all/sleb128-3.s: Likewise.
* gas/all/sleb128-4.s: Likewise.
* gas/all/sleb128-5.s: Likewise.
* gas/all/sleb128-7.s: Likewise.
? gas/testsuite/gas/all/sleb128-6.d.copy
? gas/testsuite/gas/all/sleb128-6.s.copy
Index: gas/expr.c
===================================================================
RCS file: /cvs/src/src/gas/expr.c,v
retrieving revision 1.93
diff -u -p -r1.93 expr.c
--- gas/expr.c 11 Apr 2013 10:54:13 -0000 1.93
+++ gas/expr.c 12 Apr 2013 14:06:42 -0000
@@ -1729,7 +1729,7 @@ operatorf (int *num_chars)
signed word values can be represented in an O_constant expression, which is
useful e.g. for .sleb128 directives. */
-static void
+void
add_to_result (expressionS *resultP, offsetT amount, int rhs_highbit)
{
valueT ures = resultP->X_add_number;
@@ -1745,7 +1745,7 @@ add_to_result (expressionS *resultP, off
/* Similarly, for subtraction. */
-static void
+void
subtract_from_result (expressionS *resultP, offsetT amount, int rhs_highbit)
{
valueT ures = resultP->X_add_number;
Index: gas/expr.h
===================================================================
RCS file: /cvs/src/src/gas/expr.h,v
retrieving revision 1.22
diff -u -p -r1.22 expr.h
--- gas/expr.h 11 Apr 2013 10:54:13 -0000 1.22
+++ gas/expr.h 12 Apr 2013 14:06:42 -0000
@@ -175,6 +175,8 @@ extern char get_symbol_end (void);
extern void expr_begin (void);
extern void expr_set_precedence (void);
extern void expr_set_rank (operatorT, operator_rankT);
+extern void add_to_result (expressionS *, offsetT, int);
+extern void subtract_from_result (expressionS *, offsetT, int);
extern segT expr (int, expressionS *, enum expr_mode);
extern unsigned int get_single_number (void);
extern symbolS *make_expr_symbol (expressionS * expressionP);
Index: gas/config/tc-sh.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sh.c,v
retrieving revision 1.140
diff -u -p -r1.140 tc-sh.c
--- gas/config/tc-sh.c 21 Mar 2012 08:58:40 -0000 1.140
+++ gas/config/tc-sh.c 12 Apr 2013 14:06:42 -0000
@@ -931,10 +931,11 @@ sh_optimize_expr (expressionS *l, operat
symbol_get_frag (r->X_add_symbol),
&frag_off))
{
- l->X_add_number -= r->X_add_number;
- l->X_add_number -= frag_off / OCTETS_PER_BYTE;
- l->X_add_number += (S_GET_VALUE (l->X_add_symbol)
- - S_GET_VALUE (r->X_add_symbol));
+ offsetT symval_diff = S_GET_VALUE (l->X_add_symbol)
+ - S_GET_VALUE (r->X_add_symbol);
+ subtract_from_result (l, r->X_add_number, r->X_extrabit);
+ subtract_from_result (l, frag_off / OCTETS_PER_BYTE, 0);
+ add_to_result (l, symval_diff, symval_diff < 0);
l->X_op = O_constant;
l->X_add_symbol = 0;
return 1;
Index: gas/testsuite/gas/all/gas.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/gas.exp,v
retrieving revision 1.81
diff -u -p -r1.81 gas.exp
--- gas/testsuite/gas/all/gas.exp 11 Apr 2013 10:54:13 -0000 1.81
+++ gas/testsuite/gas/all/gas.exp 12 Apr 2013 14:06:42 -0000
@@ -373,7 +373,10 @@ run_dump_test sleb128-2
run_dump_test sleb128-3
run_dump_test sleb128-4
run_dump_test sleb128-5
-run_dump_test sleb128-7
+# .byte is not 8 bits on either tic4x or tic54x
+if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] } {
+ run_dump_test sleb128-7
+}
# .byte is 32 bits on tic4x, and .p2align isn't supported on tic54x
# .space is different on hppa*-hpux.
Index: gas/testsuite/gas/all/sleb128-2.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/sleb128-2.s,v
retrieving revision 1.1
diff -u -p -r1.1 sleb128-2.s
--- gas/testsuite/gas/all/sleb128-2.s 11 Apr 2013 10:54:13 -0000 1.1
+++ gas/testsuite/gas/all/sleb128-2.s 12 Apr 2013 14:06:42 -0000
@@ -1,13 +1,10 @@
-.text
-.globl foo
-foo:
-.L1:
-.byte 0
-.byte 0
-.byte 0
-.L2:
+ .text
+_L1:
+ .byte 0
+ .byte 0
+ .byte 0
+_L2:
-.data
-bar:
-.sleb128 .L1 - .L2
-.byte 42
+ .data
+ .sleb128 _L1 - _L2
+ .byte 42
Index: gas/testsuite/gas/all/sleb128-3.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/sleb128-3.s,v
retrieving revision 1.1
diff -u -p -r1.1 sleb128-3.s
--- gas/testsuite/gas/all/sleb128-3.s 11 Apr 2013 10:54:13 -0000 1.1
+++ gas/testsuite/gas/all/sleb128-3.s 12 Apr 2013 14:06:42 -0000
@@ -1,4 +1,3 @@
-.data
-bar:
-.sleb128 100 - 200
-.byte 42
+ .data
+ .sleb128 100 - 200
+ .byte 42
Index: gas/testsuite/gas/all/sleb128-4.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/sleb128-4.s,v
retrieving revision 1.1
diff -u -p -r1.1 sleb128-4.s
--- gas/testsuite/gas/all/sleb128-4.s 11 Apr 2013 10:54:13 -0000 1.1
+++ gas/testsuite/gas/all/sleb128-4.s 12 Apr 2013 14:06:42 -0000
@@ -1,13 +1,10 @@
-.text
-.globl foo
-foo:
-.L1:
-.byte 0
-.byte 0
-.byte 0
-.L2:
+ .text
+_L1:
+ .byte 0
+ .byte 0
+ .byte 0
+_L2:
-.data
-bar:
-.sleb128 .L2 - .L1 + (1 << 31)
-.byte 42
+ .data
+ .sleb128 _L2 - _L1 + (1 << 31)
+ .byte 42
Index: gas/testsuite/gas/all/sleb128-5.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/sleb128-5.s,v
retrieving revision 1.1
diff -u -p -r1.1 sleb128-5.s
--- gas/testsuite/gas/all/sleb128-5.s 11 Apr 2013 10:54:13 -0000 1.1
+++ gas/testsuite/gas/all/sleb128-5.s 12 Apr 2013 14:06:42 -0000
@@ -1,13 +1,10 @@
-.text
-.globl foo
-foo:
-.L1:
-.byte 0
-.byte 0
-.byte 0
-.L2:
+ .text
+_L1:
+ .byte 0
+ .byte 0
+ .byte 0
+_L2:
-.data
-bar:
-.sleb128 .L1 - .L2 + 4
-.byte 42
+ .data
+ .sleb128 _L1 - _L2 + 4
+ .byte 42
Index: gas/testsuite/gas/all/sleb128-7.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/sleb128-7.s,v
retrieving revision 1.1
diff -u -p -r1.1 sleb128-7.s
--- gas/testsuite/gas/all/sleb128-7.s 11 Apr 2013 10:54:13 -0000 1.1
+++ gas/testsuite/gas/all/sleb128-7.s 12 Apr 2013 14:06:42 -0000
@@ -1,19 +1,16 @@
-.text
-.globl foo
-foo:
-.L1:
-.byte 0
-.byte 0
-.byte 0
-.L2:
+ .text
+_L1:
+ .byte 0
+ .byte 0
+ .byte 0
+_L2:
-.data
-bar:
-.sleb128 200+(.L2 - .L1)
-.byte 42
-.sleb128 200+(.L1 - .L2)
-.byte 42
-.sleb128 (.L2 - .L1)+200
-.byte 42
-.sleb128 (.L1 - .L2)+200
-.byte 42
+ .data
+ .sleb128 200+(_L2 - _L1)
+ .byte 42
+ .sleb128 200+(_L1 - _L2)
+ .byte 42
+ .sleb128 (_L2 - _L1)+200
+ .byte 42
+ .sleb128 (_L1 - _L2)+200
+ .byte 42