sign extension break sleb128 tests on m68k

Alan Modra amodra@bigpond.net.au
Tue Mar 1 04:26:00 GMT 2005


When building with a 64-bit bfd, sleb128 and quad tests fail on m68k
targets, because something like

 .sleb128 0x80000000

has the constant sign extendend due to a peculiarity of m68k gas (grep
for TARGET_WORD_SIZE) as if you'd written

 .sleb128 0xffffffff80000000

Richard's recent change to .sleb128 made it treat both of these
constants as unsigned, so they are different values.  Does anyone know
why this patch was applied?

Thu Apr 13 14:34:36 1995  Torbjorn Granlund  <tege@adder.cygnus.com>

	* config/tc-m68k.c (m68k_init_after_args): Test for m68360.
	(md_parse_option): Likewise.
	(md_show_usage): Mention m68360.
	* config/tc-m68k.h (TARGET_WORD_SIZE): Define.
	(TARGET_ARCH): Define.

	* expr.c (integer_constant): If TARGET_WORD_SIZE is defined,
	sign-extend appropriately.

Presumably it too was concerned with building 32-bit m68k binutils with
a 64-bit bfd, but unfortunately no testcase was added.  So I don't know
whether the hack is still needed.  Failing any good reason being found,
I propose the following:

	* expr.c (integer_constant): Remove TARGET_WORD_SIZE hack.
	* config/tc-m68k.h (TARGET_WORD_SIZE): Delete.

Index: gas/expr.c
===================================================================
RCS file: /cvs/src/src/gas/expr.c,v
retrieving revision 1.53
diff -u -p -r1.53 expr.c
--- gas/expr.c	1 Mar 2005 02:00:14 -0000	1.53
+++ gas/expr.c	1 Mar 2005 03:03:00 -0000
@@ -609,10 +609,6 @@ integer_constant (int radix, expressionS
       else
 	{
 	  expressionP->X_op = O_constant;
-#ifdef TARGET_WORD_SIZE
-	  /* Sign extend NUMBER.  */
-	  number |= (-(number >> (TARGET_WORD_SIZE - 1))) << (TARGET_WORD_SIZE - 1);
-#endif
 	  expressionP->X_add_number = number;
 	  input_line_pointer--;	/* Restore following character.  */
 	}			/* Really just a number.  */
Index: gas/config/tc-m68k.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68k.h,v
retrieving revision 1.15
diff -u -p -r1.15 tc-m68k.h
--- gas/config/tc-m68k.h	26 Jan 2004 18:09:30 -0000	1.15
+++ gas/config/tc-m68k.h	1 Mar 2005 03:03:11 -0000
@@ -206,7 +206,6 @@ extern int m68k_parse_long_option PARAMS
 
 #define md_operand(x)
 
-#define TARGET_WORD_SIZE 32
 #define TARGET_ARCH bfd_arch_m68k
 
 extern struct relax_type md_relax_table[];


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list