public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <ian@cygnus.com>
To: pb@nexus.co.uk
Cc: gas2@cygnus.com
Subject: Re: gas patch for ARM
Date: Tue, 27 Jan 1998 09:35:00 -0000	[thread overview]
Message-ID: <199801271735.MAA02096@subrogation.cygnus.com> (raw)
In-Reply-To: <E0xx7x9-0005hQ-00@spring.nexus.co.uk>

   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:

      reply	other threads:[~1998-01-27  9:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-27  2:20 Philip Blundell
1998-01-27  9:35 ` Ian Lance Taylor [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199801271735.MAA02096@subrogation.cygnus.com \
    --to=ian@cygnus.com \
    --cc=gas2@cygnus.com \
    --cc=pb@nexus.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).