This is the mail archive of the binutils@sourceware.org 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]

Re: powerpc gas complaints on @h, @ha, @l


On Tue, May 07, 2013 at 09:05:07AM +0930, Alan Modra wrote:
> 	(md_apply_fix): Set fx_no_overflow for assorted relocations.

That wasn't enough.  ppc_insert_operand checks unsigned fields for
unsigned values, causing a failure in the following testcase.

	. = 0x10
1:
	ori     3,3,(2f - 1b)@l
	ori     4,4,(1b - 2f)@l
	. = 0x10000
2:

So satisfy the field sign extension.  We don't want to avoid checking
entirely, because we want to catch low bit value errors.

	* config/tc-ppc.c (md_apply_fix): Sign extend fieldval under
	control of operand flag bits.

Index: gas/config/tc-ppc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.c,v
retrieving revision 1.196
diff -u -p -r1.196 tc-ppc.c
--- gas/config/tc-ppc.c	6 May 2013 23:36:48 -0000	1.196
+++ gas/config/tc-ppc.c	9 May 2013 03:53:29 -0000
@@ -6369,7 +6369,10 @@ md_apply_fix (fixS *fixP, valueT *valP, 
 	case BFD_RELOC_LO16_PCREL:
 	case BFD_RELOC_PPC_VLE_LO16A:
 	case BFD_RELOC_PPC_VLE_LO16D:
-	  fieldval = SEX16 (value);
+	  fieldval = value & 0xffff;
+	sign_extend_16:
+	  if ((operand->flags & PPC_OPERAND_SIGNED) != 0)
+	    fieldval = (fieldval ^ 0x8000) - 0x8000;
 	  fixP->fx_no_overflow = 1;
 	  break;
 
@@ -6380,9 +6383,8 @@ md_apply_fix (fixS *fixP, valueT *valP, 
 	case BFD_RELOC_HI16_PCREL:
 	case BFD_RELOC_PPC_VLE_HI16A:
 	case BFD_RELOC_PPC_VLE_HI16D:
-	  fieldval = SEX16 (PPC_HI (value));
-	  fixP->fx_no_overflow = 1;
-	  break;
+	  fieldval = PPC_HI (value);
+	  goto sign_extend_16;
 
 	case BFD_RELOC_HI16_S:
 	  if (fixP->fx_pcrel)
@@ -6391,38 +6393,33 @@ md_apply_fix (fixS *fixP, valueT *valP, 
 	case BFD_RELOC_HI16_S_PCREL:
 	case BFD_RELOC_PPC_VLE_HA16A:
 	case BFD_RELOC_PPC_VLE_HA16D:
-	  fieldval = SEX16 (PPC_HA (value));
-	  fixP->fx_no_overflow = 1;
-	  break;
+	  fieldval = PPC_HA (value);
+	  goto sign_extend_16;
 
 #ifdef OBJ_ELF
 	case BFD_RELOC_PPC64_HIGHER:
 	  if (fixP->fx_pcrel)
 	    goto bad_pcrel;
-	  fieldval = SEX16 (PPC_HIGHER (value));
-	  fixP->fx_no_overflow = 1;
-	  break;
+	  fieldval = PPC_HIGHER (value);
+	  goto sign_extend_16;
 
 	case BFD_RELOC_PPC64_HIGHER_S:
 	  if (fixP->fx_pcrel)
 	    goto bad_pcrel;
-	  fieldval = SEX16 (PPC_HIGHERA (value));
-	  fixP->fx_no_overflow = 1;
-	  break;
+	  fieldval = PPC_HIGHERA (value);
+	  goto sign_extend_16;
 
 	case BFD_RELOC_PPC64_HIGHEST:
 	  if (fixP->fx_pcrel)
 	    goto bad_pcrel;
-	  fieldval = SEX16 (PPC_HIGHEST (value));
-	  fixP->fx_no_overflow = 1;
-	  break;
+	  fieldval = PPC_HIGHEST (value);
+	  goto sign_extend_16;
 
 	case BFD_RELOC_PPC64_HIGHEST_S:
 	  if (fixP->fx_pcrel)
 	    goto bad_pcrel;
-	  fieldval = SEX16 (PPC_HIGHESTA (value));
-	  fixP->fx_no_overflow = 1;
-	  break;
+	  fieldval = PPC_HIGHESTA (value);
+	  goto sign_extend_16;
 
 	  /* The following relocs can't be calculated by the assembler.
 	     Leave the field zero.  */

-- 
Alan Modra
Australia Development Lab, IBM


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