This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bignums and .sleb128


I spent most of this morning chasing a bug in .sleb128 support.  After
I finished running around in circles and discovered that Richard Sandiford
had fixed it two weeks ago (thanks!) I compared the testcases I'd written
with the ones that he committed.  There were a couple of differences,
basically related to this comment from bignum.h:

 *      Bignums are >= 0.                                               *

So generating a sleb128 from one is pretty strange - the sign bit is
ambiguously handled.  To see what I mean, try the attached patch to the
testsuite; several of the new tests fail.  Richard's patch adds this:

  /* Add a sequence of sign bits if the top bit of X_add_number is not
     the sign of the original value.  */
  if ((exp->X_add_number < 0) != !exp->X_unsigned)
    generic_bignum[i++] = exp->X_unsigned ? 0 : LITTLENUM_MASK;

which is pretty similar to what I did, but violates the documentation and (I
think) the expectations of various other bits of gas.  If we're going to use
these semantics, at least the '-' case in operand() needs to be fixed.

I consider the current state "still very broken".  Should we try to fix this
(I can't even see where to start; O_big has percolated into lots of strange
places, so changing its semantics would be tricky)?  Otherwise, can we
reject the internally ambiguous constructs?

The tests:

Index: testsuite/gas/all/sleb128.d
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gas/testsuite/gas/all/sleb128.d,v
retrieving revision 1.2
diff -u -p -r1.2 sleb128.d
--- testsuite/gas/all/sleb128.d	24 Jan 2005 15:32:19 -0000	1.2
+++ testsuite/gas/all/sleb128.d	31 Jan 2005 19:21:44 -0000
@@ -52,6 +52,29 @@ Contents of section .data:
 # -0x100000000 :           111_0000 .....................................
 #    000000000 :           000_0000 0000_000 0_0000_00 00_0000_0 000_0000
 # -0x1000      :                             1_0000_00 00_0000_0
+#   fffffffff  :           111_1111 1111_111 1_1111_11 11_1111_1 111_1111 
+# 0xfffffff    : .................. 1111_111 1_1111_11 11_1111_1
 #
- 00.. 70808080 80808040 00000000 00000000 .*
+ 00.. 70808080 80808040 ffffffff ffffffff .*
+#
+# 0xfffffff    : 00_0000_1 111_1111 ............................
+#   fffffffff  :           111_1111 1111_111 1_1111_11 11_1111_1 111_1111 
+#   fffffffff  : 11_1111_1 111_1111 1111_111 1_1111_11 11_1111_1
+# 0xffffff     : 00_1111_1 111_1111 1111_111 1_1111_11
+#
+ 0... ff01ffff ffffffff ffffffff ffffff1f
+#
+#   fffffffff  :           000_0000 0000_000 0_0000_00 00_0000_0 000_0001
+# -0xfffffff   : 111_000_0 000_0000 0000_000 0_0000_00 00_0000_0
+#   fffffffff  :           000_0000 0000_000 0_0000_00 00_0000_0 000_0001
+#   fffffffff  : ..................................... 00_0000_0
+# -0xffffff    : .....................................
+#
+ 0... 81808080 80808080 80f08180 80808080 .*
+#
+#   fffffffff  :           ..............................................
+#   fffffffff  : 00_0000_0 000_0000 0000_000 0_0000_00 .........
+# -0xffffff    : 11_0000_0 000_0000 0000_000 0_0000_00
+#
+ 0... 80808080 80808060 00000000 00000000 .*
 #pass
Index: testsuite/gas/all/sleb128.s
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gas/testsuite/gas/all/sleb128.s,v
retrieving revision 1.1
diff -u -p -r1.1 sleb128.s
--- testsuite/gas/all/sleb128.s	19 Jan 2005 11:53:53 -0000	1.1
+++ testsuite/gas/all/sleb128.s	31 Jan 2005 18:51:59 -0000
@@ -19,4 +19,9 @@
 	.sleb128	-0x100000000
 	.sleb128	-0x1000000000000
 
+	.sleb128	0xffffffffffffffff
+	.sleb128	0xffffffffffffffffffffffff
+	.sleb128	-0xffffffffffffffff
+	.sleb128	-0xffffffffffffffffffffffff
+
 	.fill		32


-- 
Daniel Jacobowitz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]