From: Julian Brown Date: Mon, 15 Apr 2013 10:30:23 +0000 (+0000) Subject: gas/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4455e9adedb85db6c3125a546f85ad70fef1c25d;p=binutils-gdb.git 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/all/sleb128-2.d: Handle data sections named $DATA$. * gas/all/sleb128-3.d: Likewise. * gas/all/sleb128-4.d: Likewise. * gas/all/sleb128-5.d: Likewise. * gas/all/sleb128-7.d: Likewise. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index ca37956272c..6d3c152ba16 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,11 @@ +2013-04-15 Julian Brown + + * 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. + 2013-04-10 Julian Brown * read.c (convert_to_bignum): Add sign parameter. Use it diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c index 4db1a091360..6b7bd5a3594 100644 --- a/gas/config/tc-sh.c +++ b/gas/config/tc-sh.c @@ -931,10 +931,11 @@ sh_optimize_expr (expressionS *l, operatorT op, expressionS *r) 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; diff --git a/gas/expr.c b/gas/expr.c index 64011b497de..c4b2b756bae 100644 --- a/gas/expr.c +++ b/gas/expr.c @@ -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, offsetT amount, int rhs_highbit) /* Similarly, for subtraction. */ -static void +void subtract_from_result (expressionS *resultP, offsetT amount, int rhs_highbit) { valueT ures = resultP->X_add_number; diff --git a/gas/expr.h b/gas/expr.h index d2cb7fd50ff..438ac0dcc13 100644 --- a/gas/expr.h +++ b/gas/expr.h @@ -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); diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 5db53c8bc8e..546c2ab14ae 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,18 @@ +2013-04-15 Julian Brown + + * 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/all/sleb128-2.d: Handle data sections named $DATA$. + * gas/all/sleb128-3.d: Likewise. + * gas/all/sleb128-4.d: Likewise. + * gas/all/sleb128-5.d: Likewise. + * gas/all/sleb128-7.d: Likewise. + 2013-04-10 Julian Brown * gas/all/sleb128-2.s: New test. diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp index c85d918ee3f..709b448701e 100644 --- a/gas/testsuite/gas/all/gas.exp +++ b/gas/testsuite/gas/all/gas.exp @@ -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. diff --git a/gas/testsuite/gas/all/sleb128-2.d b/gas/testsuite/gas/all/sleb128-2.d index f3d052d4eca..cce0b4c0334 100644 --- a/gas/testsuite/gas/all/sleb128-2.d +++ b/gas/testsuite/gas/all/sleb128-2.d @@ -1,7 +1,7 @@ -#objdump : -s -j .data +#objdump : -s -j .data -j "\$DATA\$" #name : .sleb128 tests (2) .*: .* -Contents of section \.data: +Contents of section (\.data|\$DATA\$): .* 7d2a.* diff --git a/gas/testsuite/gas/all/sleb128-2.s b/gas/testsuite/gas/all/sleb128-2.s index 49c52af1ffa..94f7afefba4 100644 --- a/gas/testsuite/gas/all/sleb128-2.s +++ b/gas/testsuite/gas/all/sleb128-2.s @@ -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 diff --git a/gas/testsuite/gas/all/sleb128-3.d b/gas/testsuite/gas/all/sleb128-3.d index ffb3a26e8ed..deb48a69a49 100644 --- a/gas/testsuite/gas/all/sleb128-3.d +++ b/gas/testsuite/gas/all/sleb128-3.d @@ -1,7 +1,7 @@ -#objdump : -s -j .data +#objdump : -s -j .data -j "\$DATA\$" #name : .sleb128 tests (3) .*: .* -Contents of section \.data: +Contents of section (\.data|\$DATA\$): .* 9c7f2a.* diff --git a/gas/testsuite/gas/all/sleb128-3.s b/gas/testsuite/gas/all/sleb128-3.s index 8aa80268cff..66d0a2570a9 100644 --- a/gas/testsuite/gas/all/sleb128-3.s +++ b/gas/testsuite/gas/all/sleb128-3.s @@ -1,4 +1,3 @@ -.data -bar: -.sleb128 100 - 200 -.byte 42 + .data + .sleb128 100 - 200 + .byte 42 diff --git a/gas/testsuite/gas/all/sleb128-4.d b/gas/testsuite/gas/all/sleb128-4.d index 80c99ab4354..0c56696d8e1 100644 --- a/gas/testsuite/gas/all/sleb128-4.d +++ b/gas/testsuite/gas/all/sleb128-4.d @@ -1,7 +1,7 @@ -#objdump : -s -j .data +#objdump : -s -j .data -j "\$DATA\$" #name : .sleb128 tests (4) .*: .* -Contents of section \.data: +Contents of section (\.data|\$DATA\$): .* 83808080 082a.* diff --git a/gas/testsuite/gas/all/sleb128-4.s b/gas/testsuite/gas/all/sleb128-4.s index a2d9d82d1bf..1bc561f6972 100644 --- a/gas/testsuite/gas/all/sleb128-4.s +++ b/gas/testsuite/gas/all/sleb128-4.s @@ -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 diff --git a/gas/testsuite/gas/all/sleb128-5.d b/gas/testsuite/gas/all/sleb128-5.d index 1e3924246ad..0accfb5a6e8 100644 --- a/gas/testsuite/gas/all/sleb128-5.d +++ b/gas/testsuite/gas/all/sleb128-5.d @@ -1,7 +1,7 @@ -#objdump : -s -j .data +#objdump : -s -j .data -j "\$DATA\$" #name : .sleb128 tests (5) .*: .* -Contents of section \.data: +Contents of section (\.data|\$DATA\$): .* 012a.* diff --git a/gas/testsuite/gas/all/sleb128-5.s b/gas/testsuite/gas/all/sleb128-5.s index 64e5793823b..b31725efeaf 100644 --- a/gas/testsuite/gas/all/sleb128-5.s +++ b/gas/testsuite/gas/all/sleb128-5.s @@ -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 diff --git a/gas/testsuite/gas/all/sleb128-7.d b/gas/testsuite/gas/all/sleb128-7.d index 805ee4db75a..6fcbdefe6e9 100644 --- a/gas/testsuite/gas/all/sleb128-7.d +++ b/gas/testsuite/gas/all/sleb128-7.d @@ -1,7 +1,7 @@ -#objdump : -s -j .data +#objdump : -s -j .data -j "\$DATA\$" #name : .sleb128 tests (7) .*: .* -Contents of section \.data: +Contents of section (\.data|\$DATA\$): .* cb012ac5 012acb01 2ac5012a.* diff --git a/gas/testsuite/gas/all/sleb128-7.s b/gas/testsuite/gas/all/sleb128-7.s index 323689bc9a3..090217fd697 100644 --- a/gas/testsuite/gas/all/sleb128-7.s +++ b/gas/testsuite/gas/all/sleb128-7.s @@ -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