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]

Re: tc-m68k.c portability patch


Alan Modra <alan@SPRI.Levels.UniSA.Edu.Au> writes:

|> On 5 May 2001, Andreas Schwab wrote:
|> 
|> > 	* config/tc-m68k.c (md_convert_frag_1): Don't set fx_pcrel_adjust
|> > 	to a negative number.
|> 
|> OK I suppose.  I've never liked that particular trick in tc-m68k.c, and
|> feel it would be better to assign -1 to fx_pcrel_adjust, then explicitly
|> sign extend the (possibly unsigned) char where it is used.  ie. instead of
|> 
|>   adjust = fixP->fx_pcrel_adjust;
|>   if (adjust == 64)
|>     adjust = -1;
|> 
|> write
|> 
|>   adjust = ((fixP->fx_pcrel_adjust & 0xff) ^ 0x80) - 0x80;

I'm now checking in the appended patch.

|> and similarly in tc_gen_reloc.  If you feel so motivated, consider such a
|> patch pre-approved.  You know what you're doing with m68k, in fact I
|> reckon you should put your hand up to be binutils m68k maintainer.  ;-)

The only problem with this is that I currently don't have a real m68k
machine, so I can only test via cross compiling.

Andreas.

-- 
Andreas Schwab                                  "And now for something
SuSE Labs                                        completely different."
Andreas.Schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
Index: tc-m68k.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68k.c,v
retrieving revision 1.20
diff -u -a -u -r1.20 tc-m68k.c
--- tc-m68k.c	2001/05/08 13:13:56	1.20
+++ tc-m68k.c	2001/05/08 17:50:23
@@ -968,8 +968,9 @@
     reloc->addend = fixp->fx_addnumber;
   else
     reloc->addend = (section->vma
-		     + (fixp->fx_pcrel_adjust == 64
-			? -1 : fixp->fx_pcrel_adjust)
+		     /* Explicit sign extension in case char is
+			unsigned.  */
+		     + ((fixp->fx_pcrel_adjust & 0xff) ^ 0x80) - 0x80
 		     + fixp->fx_addnumber
 		     + md_pcrel_from (fixp));
 #endif
@@ -2546,11 +2547,7 @@
 	  switch (s[1])
 	    {
 	    case 'B':
-	      /* The pc_fix argument winds up in fx_pcrel_adjust,
-                 which is a char, and may therefore be unsigned.  We
-                 want to pass -1, but we pass 64 instead, and convert
-                 back in md_pcrel_from.  */
-	      add_fix ('B', &opP->disp, 1, 64);
+	      add_fix ('B', &opP->disp, 1, -1);
 	      break;
 	    case 'W':
 	      add_fix ('w', &opP->disp, 1, 0);
@@ -7041,9 +7038,9 @@
 {
   int adjust;
 
-  /* Because fx_pcrel_adjust is a char, and may be unsigned, we store
-     -1 as 64.  */
-  adjust = fixP->fx_pcrel_adjust;
+  /* Because fx_pcrel_adjust is a char, and may be unsigned, we explicitly
+     sign extend the value here.  */
+  adjust = ((fixP->fx_pcrel_adjust & 0xff) ^ 0x80) - 0x80;
   if (adjust == 64)
     adjust = -1;
   return fixP->fx_where + fixP->fx_frag->fr_address - adjust;

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