This is the mail archive of the gas2@sourceware.cygnus.com mailing list for the gas2 project.


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

Re: gas patch for ARM


   Date: Tue, 27 Jan 1998 10:09:11 +0000
   From: Philip Blundell <pb@nexus.co.uk>

   The following patch makes ADR instructions work correctly when
   cross-assembling for the ARM from a machine with a word size greater
   than 32 bits.

The way in which functions in tc-arm.c return either FAIL or a
meaningful value makes me nervous.  I think that decades of bugs in
handling the return type of getchar indicate the problems with this
sort of return value.

Also, using int to avoid a 32/64 bit problem looks wrong, since it
appears to assume that int is a 32 bit value.  In this case it is
probably correct, but rather than check in the code that looks wrong
at first glance, I checked in the appended patch instead.

Ian

Index: config/tc-arm.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/config/tc-arm.c,v
retrieving revision 1.38
diff -u -r1.38 tc-arm.c
--- tc-arm.c	1997/12/16 09:23:39	1.38
+++ tc-arm.c	1998/01/27 17:32:02
@@ -5036,6 +5036,7 @@
 {
   offsetT value = *val;
   offsetT newval;
+  unsigned int newimm;
   unsigned long temp;
   int sign;
   char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
@@ -5072,21 +5073,21 @@
   switch (fixP->fx_r_type)
     {
     case BFD_RELOC_ARM_IMMEDIATE:
-      newval = validate_immediate (value);
+      newimm = validate_immediate (value);
       temp = md_chars_to_number (buf, INSN_SIZE);
 
       /* If the instruction will fail, see if we can fix things up by
 	 changing the opcode.  */
-      if (newval == FAIL
-	  && (newval = negate_data_op (&temp, value)) == FAIL)
+      if (newimm == (unsigned int) FAIL
+	  && (newimm = negate_data_op (&temp, value)) == (unsigned int) FAIL)
 	{
 	  as_bad_where (fixP->fx_file, fixP->fx_line,
 			"invalid constant after fixup\n");
 	  break;
 	}
 
-      newval |= (temp & 0xfffff000);
-      md_number_to_chars (buf, newval, INSN_SIZE);
+      newimm |= (temp & 0xfffff000);
+      md_number_to_chars (buf, (valueT) newimm, INSN_SIZE);
       break;
 
      case BFD_RELOC_ARM_OFFSET_IMM: