2c2fa1
commit a47622ac1badbd906c7533ef6011b6bb021271ee
2c2fa1
Author: Alan Modra <amodra@gmail.com>
2c2fa1
Date:   Sat Jun 7 12:09:04 2014 +0930
2c2fa1
2c2fa1
    Allow both signed and unsigned fields in PowerPC cmpli insn
2c2fa1
    
2c2fa1
    There are legitimate reasons to allow a signed value in a cmpli insn
2c2fa1
    field, for example to test for a "stw r1,lock@sdarel(r13)" instruction
2c2fa1
    in user code, a kernel might use
2c2fa1
            subis r3,r3,STW_R1_0R13@ha      # subtract off high part
2c2fa1
            cmplwi r3,lock@sdarel           # is low part accessing lock?
2c2fa1
    Since the lock@sdarel may take a range of -32768 to 32767,
2c2fa1
    the allowed range of cmpli immediate must be at least [-32768,65535].
2c2fa1
    
2c2fa1
    bfd/
2c2fa1
            * elf32-ppc.c (ppc_elf_relocate_section): Treat field of cmpli
2c2fa1
            insn as a bitfield; Use complain_overflow_bitfield.
2c2fa1
            * elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
2c2fa1
    opcodes/
2c2fa1
            * ppc-opc.c (UISIGNOPT): Define and use with cmpli.
2c2fa1
    gas/
2c2fa1
            * config/tc-ppc.c (ppc_insert_operand): Handle PPC_OPERAND_SIGNOPT
2c2fa1
            on unsigned fields.  Comment on PPC_OPERAND_SIGNOPT signed fields
2c2fa1
            in 64-bit mode.
2c2fa1
    gold/
2c2fa1
            * powerpc.cc (relocate): Treat field of cmpli insn as a bitfield.
2c2fa1
2c2fa1
### a/bfd/ChangeLog
2c2fa1
### b/bfd/ChangeLog
2c2fa1
## -1,3 +1,9 @@
2c2fa1
+2014-06-07  Alan Modra  <amodra@gmail.com>
2c2fa1
+
2c2fa1
+	* elf32-ppc.c (ppc_elf_relocate_section): Treat field of cmpli
2c2fa1
+	insn as a bitfield; Use complain_overflow_bitfield.
2c2fa1
+	* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
2c2fa1
+
2c2fa1
 2014-06-05  Joel Brobecker  <brobecker@adacore.com>
2c2fa1
 
2c2fa1
 	* development.sh: New file.
2c2fa1
--- a/bfd/elf32-ppc.c
2c2fa1
+++ b/bfd/elf32-ppc.c
2c2fa1
@@ -9147,10 +9147,11 @@ ppc_elf_relocate_section (bfd *output_bfd,
2c2fa1
 	      unsigned int insn;
2c2fa1
 
2c2fa1
 	      insn = bfd_get_32 (input_bfd, contents + (rel->r_offset & ~3));
2c2fa1
-	      if ((insn & (0x3f << 26)) == 28u << 26 /* andi */
2c2fa1
-		  || (insn & (0x3f << 26)) == 24u << 26 /* ori */
2c2fa1
-		  || (insn & (0x3f << 26)) == 26u << 26 /* xori */
2c2fa1
-		  || (insn & (0x3f << 26)) == 10u << 26 /* cmpli */)
2c2fa1
+	      if ((insn & (0x3f << 26)) == 10u << 26 /* cmpli */)
2c2fa1
+		complain = complain_overflow_bitfield;
2c2fa1
+	      else if ((insn & (0x3f << 26)) == 28u << 26 /* andi */
2c2fa1
+		       || (insn & (0x3f << 26)) == 24u << 26 /* ori */
2c2fa1
+		       || (insn & (0x3f << 26)) == 26u << 26 /* xori */)
2c2fa1
 		complain = complain_overflow_unsigned;
2c2fa1
 	    }
2c2fa1
 	  if (howto->complain_on_overflow != complain)
2c2fa1
--- a/bfd/elf64-ppc.c
2c2fa1
+++ b/bfd/elf64-ppc.c
2c2fa1
@@ -14648,14 +14648,15 @@ ppc64_elf_relocate_section (bfd *output_bfd,
2c2fa1
 	  enum complain_overflow complain = complain_overflow_signed;
2c2fa1
 
2c2fa1
 	  insn = bfd_get_32 (input_bfd, contents + (rel->r_offset & ~3));
2c2fa1
-	  if (howto->rightshift == 0
2c2fa1
-	      ? ((insn & (0x3f << 26)) == 28u << 26 /* andi */
2c2fa1
-		 || (insn & (0x3f << 26)) == 24u << 26 /* ori */
2c2fa1
-		 || (insn & (0x3f << 26)) == 26u << 26 /* xori */
2c2fa1
-		 || (insn & (0x3f << 26)) == 10u << 26 /* cmpli */)
2c2fa1
-	      : ((insn & (0x3f << 26)) == 29u << 26 /* andis */
2c2fa1
-		 || (insn & (0x3f << 26)) == 25u << 26 /* oris */
2c2fa1
-		 || (insn & (0x3f << 26)) == 27u << 26 /* xoris */))
2c2fa1
+	  if ((insn & (0x3f << 26)) == 10u << 26 /* cmpli */)
2c2fa1
+	    complain = complain_overflow_bitfield;
2c2fa1
+	  else if (howto->rightshift == 0
2c2fa1
+		   ? ((insn & (0x3f << 26)) == 28u << 26 /* andi */
2c2fa1
+		      || (insn & (0x3f << 26)) == 24u << 26 /* ori */
2c2fa1
+		      || (insn & (0x3f << 26)) == 26u << 26 /* xori */)
2c2fa1
+		   : ((insn & (0x3f << 26)) == 29u << 26 /* andis */
2c2fa1
+		      || (insn & (0x3f << 26)) == 25u << 26 /* oris */
2c2fa1
+		      || (insn & (0x3f << 26)) == 27u << 26 /* xoris */))
2c2fa1
 	    complain = complain_overflow_unsigned;
2c2fa1
 	  if (howto->complain_on_overflow != complain)
2c2fa1
 	    {
2c2fa1
### a/opcodes/ChangeLog
2c2fa1
### b/opcodes/ChangeLog
2c2fa1
## -1,3 +1,7 @@
2c2fa1
+2014-06-07  Alan Modra  <amodra@gmail.com>
2c2fa1
+
2c2fa1
+	* ppc-opc.c (UISIGNOPT): Define and use with cmpli.
2c2fa1
+
2c2fa1
 2014-06-05  Joel Brobecker  <brobecker@adacore.com>
2c2fa1
 
2c2fa1
 	* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
2c2fa1
--- a/opcodes/ppc-opc.c
2c2fa1
+++ b/opcodes/ppc-opc.c
2c2fa1
@@ -654,8 +654,11 @@ const struct powerpc_operand powerpc_operands[] =
2c2fa1
 #define UI TO + 1
2c2fa1
   { 0xffff, 0, NULL, NULL, 0 },
2c2fa1
 
2c2fa1
+#define UISIGNOPT UI + 1
2c2fa1
+  { 0xffff, 0, NULL, NULL, PPC_OPERAND_SIGNOPT },
2c2fa1
+
2c2fa1
   /* The IMM field in an SE_IM5 instruction.  */
2c2fa1
-#define UI5 UI + 1
2c2fa1
+#define UI5 UISIGNOPT + 1
2c2fa1
   { 0x1f, 4, NULL, NULL, 0 },
2c2fa1
 
2c2fa1
   /* The OIMM field in an SE_OIM5 instruction.  */
2c2fa1
@@ -3500,10 +3503,10 @@ const struct powerpc_opcode powerpc_opcodes[] = {
2c2fa1
 
2c2fa1
 {"dozi",	OP(9),		OP_MASK,     M601,	PPCNONE,	{RT, RA, SI}},
2c2fa1
 
2c2fa1
-{"cmplwi",	OPL(10,0),	OPL_MASK,    PPCCOM,	PPCNONE,	{OBF, RA, UI}},
2c2fa1
-{"cmpldi",	OPL(10,1),	OPL_MASK,    PPC64,	PPCNONE,	{OBF, RA, UI}},
2c2fa1
-{"cmpli",	OP(10),		OP_MASK,     PPC,	PPCNONE,	{BF, L, RA, UI}},
2c2fa1
-{"cmpli",	OP(10),		OP_MASK,     PWRCOM,	PPC,		{BF, RA, UI}},
2c2fa1
+{"cmplwi",	OPL(10,0),	OPL_MASK,    PPCCOM,	PPCNONE,	{OBF, RA, UISIGNOPT}},
2c2fa1
+{"cmpldi",	OPL(10,1),	OPL_MASK,    PPC64,	PPCNONE,	{OBF, RA, UISIGNOPT}},
2c2fa1
+{"cmpli",	OP(10),		OP_MASK,     PPC,	PPCNONE,	{BF, L, RA, UISIGNOPT}},
2c2fa1
+{"cmpli",	OP(10),		OP_MASK,     PWRCOM,	PPC,		{BF, RA, UISIGNOPT}},
2c2fa1
 
2c2fa1
 {"cmpwi",	OPL(11,0),	OPL_MASK,    PPCCOM,	PPCNONE,	{OBF, RA, SI}},
2c2fa1
 {"cmpdi",	OPL(11,1),	OPL_MASK,    PPC64,	PPCNONE,	{OBF, RA, SI}},