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: [Patch V2]: xcoff: fix 16 bit relative branches


On Jul 22, 2013, at 6:31 PM, Richard Sandiford wrote:

> Tristan Gingold <gingold@adacore.com> writes:
>> diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
>> index 9abe04d..3f60184 100644
>> --- a/bfd/coff-rs6000.c
>> +++ b/bfd/coff-rs6000.c
>> @@ -952,7 +952,7 @@ reloc_howto_type xcoff_howto_table[] =
>> 	 0xffff,		/* dst_mask */
>> 	 FALSE),		/* pcrel_offset */
>> 
>> -  /* Modifiable relative branch.  */
>> +  /* 0x14 Modifiable relative branch.  */
>>   HOWTO (R_RRTBI,		 /* type */
>> 	 1,			/* rightshift */
>> 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
>> @@ -1012,7 +1012,7 @@ reloc_howto_type xcoff_howto_table[] =
>> 	 0xffff,		/* dst_mask */
>> 	 FALSE),		/* pcrel_offset */
>> 
>> -  /* Modifiable branch absolute.  */
>> +  /* 0x18 Modifiable branch absolute.  */
>>   HOWTO (R_RBA,			/* type */
>> 	 0,			/* rightshift */
>> 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
>> @@ -1072,7 +1072,7 @@ reloc_howto_type xcoff_howto_table[] =
>> 	 0xffff,		/* dst_mask */
>> 	 FALSE),		/* pcrel_offset */
>> 
>> -  /* 16 bit Non modifiable absolute branch.  */
>> +  /* 0x1c: 16 bit Non modifiable absolute branch.  */
>>   HOWTO (R_BA,			/* type */
>> 	 0,			/* rightshift */
>> 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
> 
Hello,

> Wasn't sure whether this was part of the patch or just something you
> did for debugging.  If it's part of the patch, we should probably do
> it for all entries, and do it in coff64-rs6000.c too.

Yes, that was part of the patch, to read *_rtype2howto and
reloc_type_lookup more easily.  Added for all entries.

> Would you mind also adding "bnel" tests to xcoff-br16-1.s and
> xcoff-br16-2.s?  It sounds like they might have failed without your
> 0xffff->0xfffc change, whereas plain bne wouldn't be affected.

Added.

> Otherwise, OK for the bfd and testsuite changes, thanks.  I'll punt
> on the gas bits :-)

Here is the patch updated. I plan to commit it soon, unless someone
is against.

Thanks,
Tristan.

bfd/
	* coff-rs6000.c (xcoff_howto_table): Fix masks and pc_relative for
	R_RBR.  Add numbers in comments.
	(_bfd_xcoff_reloc_type_lookup): Handle BFD_RELOC_PPC_B16.
	* coff64-rs6000.c: Likewise.

gas/
	* config/tc-ppc.c (md_apply_fix): Adjust BFD_RELOC_PPC_B16 on
	xcoff targets.

gas/testsuite/
	* gas/ppc/test2xcoff32.s, gas/ppc/test2xcoff32.d: New files
	* gas/ppc/ppc.exp: Add new test.
	* gas/ppc/xcoff-br16-1.s, gas/ppc/xcoff-br16-1.d,
	gas/ppc/xcoff-br16-2.s, gas/ppc/xcoff-br16-2.d: New files
	* gas/ppc/aix.exp: Add new tests.

diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 9abe04d..309ea77 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -731,7 +731,7 @@ end:
 
 reloc_howto_type xcoff_howto_table[] =
 {
-  /* Standard 32 bit relocation.  */
+  /* 0x00: Standard 32 bit relocation.  */
   HOWTO (R_POS,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -746,7 +746,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 32 bit relocation, but store negative value.  */
+  /* 0x01: 32 bit relocation, but store negative value.  */
   HOWTO (R_NEG,			/* type */
 	 0,			/* rightshift */
 	 -2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -761,7 +761,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 32 bit PC relative relocation.  */
+  /* 0x02: 32 bit PC relative relocation.  */
   HOWTO (R_REL,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -776,7 +776,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit TOC relative relocation.  */
+  /* 0x03: 16 bit TOC relative relocation.  */
   HOWTO (R_TOC,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -791,7 +791,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* I don't really know what this is.  */
+  /* 0x04: I don't really know what this is.  */
   HOWTO (R_RTB,			/* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -806,7 +806,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* External TOC relative symbol.  */
+  /* 0x05: External TOC relative symbol.  */
   HOWTO (R_GL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -821,7 +821,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Local TOC relative symbol.	 */
+  /* 0x06: Local TOC relative symbol.	 */
   HOWTO (R_TCL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -838,7 +838,7 @@ reloc_howto_type xcoff_howto_table[] =
 
   EMPTY_HOWTO (7),
 
-  /* Non modifiable absolute branch.  */
+  /* 0x08: Non modifiable absolute branch.  */
   HOWTO (R_BA,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -855,7 +855,7 @@ reloc_howto_type xcoff_howto_table[] =
 
   EMPTY_HOWTO (9),
 
-  /* Non modifiable relative branch.  */
+  /* 0x0a: Non modifiable relative branch.  */
   HOWTO (R_BR,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -872,7 +872,7 @@ reloc_howto_type xcoff_howto_table[] =
 
   EMPTY_HOWTO (0xb),
 
-  /* Indirect load.  */
+  /* 0x0c: Indirect load.  */
   HOWTO (R_RL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -887,7 +887,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Load address.  */
+  /* 0x0d: Load address.  */
   HOWTO (R_RLA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -904,7 +904,7 @@ reloc_howto_type xcoff_howto_table[] =
 
   EMPTY_HOWTO (0xe),
 
-  /* Non-relocating reference.  Bitsize is 1 so that r_rsize is 0.  */
+  /* 0x0f: Non-relocating reference.  Bitsize is 1 so that r_rsize is 0.  */
   HOWTO (R_REF,			/* type */
 	 0,			/* rightshift */
 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -922,7 +922,7 @@ reloc_howto_type xcoff_howto_table[] =
   EMPTY_HOWTO (0x10),
   EMPTY_HOWTO (0x11),
 
-  /* TOC relative indirect load.  */
+  /* 0x12: TOC relative indirect load.  */
   HOWTO (R_TRL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -937,7 +937,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* TOC relative load address.  */
+  /* 0x13: TOC relative load address.  */
   HOWTO (R_TRLA,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -952,7 +952,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable relative branch.  */
+  /* 0x14: Modifiable relative branch.  */
   HOWTO (R_RRTBI,		 /* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -967,7 +967,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable absolute branch.  */
+  /* 0x15: Modifiable absolute branch.  */
   HOWTO (R_RRTBA,		 /* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -982,7 +982,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable call absolute indirect.  */
+  /* 0x16: Modifiable call absolute indirect.  */
   HOWTO (R_CAI,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -997,7 +997,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable call relative.  */
+  /* 0x17: Modifiable call relative.  */
   HOWTO (R_CREL,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1012,7 +1012,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x18: Modifiable branch absolute.  */
   HOWTO (R_RBA,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1027,7 +1027,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0x03fffffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x19: Modifiable branch absolute.  */
   HOWTO (R_RBAC,		/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1042,7 +1042,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch relative.  */
+  /* 0x1a: Modifiable branch relative.  */
   HOWTO (R_RBR,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1057,7 +1057,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0x03fffffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x1b: Modifiable branch absolute.  */
   HOWTO (R_RBRC,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1072,7 +1072,7 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit Non modifiable absolute branch.  */
+  /* 0x1c: 16 bit Non modifiable absolute branch.  */
   HOWTO (R_BA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1087,22 +1087,22 @@ reloc_howto_type xcoff_howto_table[] =
 	 0xfffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch relative.  */
+  /* 0x1d: Modifiable branch relative.  */
   HOWTO (R_RBR,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
 	 16,			/* bitsize */
-	 FALSE,			/* pc_relative */
+	 TRUE,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
 	 0,			/* special_function */
 	 "R_RBR_16",		/* name */
 	 TRUE,			/* partial_inplace */
-	 0xffff,		/* src_mask */
-	 0xffff,		/* dst_mask */
+	 0xfffc,		/* src_mask */
+	 0xfffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch relative.  */
+  /* 0x1e: Modifiable branch relative.  */
   HOWTO (R_RBA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1166,6 +1166,8 @@ _bfd_xcoff_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
     case BFD_RELOC_16:
       /* Note that this relocation is only internally used by gas.  */
       return &xcoff_howto_table[0xc];
+    case BFD_RELOC_PPC_B16:
+      return &xcoff_howto_table[0x1d];
     case BFD_RELOC_32:
     case BFD_RELOC_CTOR:
       return &xcoff_howto_table[0];
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 56a0d25..6c92e26 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -1373,7 +1373,7 @@ xcoff64_ppc_relocate_section (bfd *output_bfd,
 
 reloc_howto_type xcoff64_howto_table[] =
 {
-  /* Standard 64 bit relocation.  */
+  /* 0x00: Standard 64 bit relocation.  */
   HOWTO (R_POS,			/* type */
 	 0,			/* rightshift */
 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1388,7 +1388,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 MINUS_ONE,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 64 bit relocation, but store negative value.  */
+  /* 0x01: 64 bit relocation, but store negative value.  */
   HOWTO (R_NEG,			/* type */
 	 0,			/* rightshift */
 	 -4,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1403,7 +1403,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 MINUS_ONE,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 32 bit PC relative relocation.  */
+  /* 0x02: 32 bit PC relative relocation.  */
   HOWTO (R_REL,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1418,7 +1418,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit TOC relative relocation.  */
+  /* 0x03: 16 bit TOC relative relocation.  */
   HOWTO (R_TOC,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1433,7 +1433,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* I don't really know what this is.	*/
+  /* 0x04: I don't really know what this is.	*/
   HOWTO (R_RTB,			/* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1448,7 +1448,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* External TOC relative symbol.  */
+  /* 0x05: External TOC relative symbol.  */
   HOWTO (R_GL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1463,7 +1463,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Local TOC relative symbol.	 */
+  /* 0x06: Local TOC relative symbol.	 */
   HOWTO (R_TCL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1480,7 +1480,7 @@ reloc_howto_type xcoff64_howto_table[] =
 
   EMPTY_HOWTO (7),
 
-  /* Non modifiable absolute branch.  */
+  /* 0x08: Non modifiable absolute branch.  */
   HOWTO (R_BA,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1497,7 +1497,7 @@ reloc_howto_type xcoff64_howto_table[] =
 
   EMPTY_HOWTO (9),
 
-  /* Non modifiable relative branch.  */
+  /* 0x0a: Non modifiable relative branch.  */
   HOWTO (R_BR,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1514,7 +1514,7 @@ reloc_howto_type xcoff64_howto_table[] =
 
   EMPTY_HOWTO (0xb),
 
-  /* Indirect load.  */
+  /* 0x0c: Indirect load.  */
   HOWTO (R_RL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1529,7 +1529,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Load address.  */
+  /* 0x0d: Load address.  */
   HOWTO (R_RLA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1546,7 +1546,7 @@ reloc_howto_type xcoff64_howto_table[] =
 
   EMPTY_HOWTO (0xe),
 
-  /* Non-relocating reference.  Bitsize is 1 so that r_rsize is 0.  */
+  /* 0x0f: Non-relocating reference.  Bitsize is 1 so that r_rsize is 0.  */
   HOWTO (R_REF,			/* type */
 	 0,			/* rightshift */
 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1564,7 +1564,7 @@ reloc_howto_type xcoff64_howto_table[] =
   EMPTY_HOWTO (0x10),
   EMPTY_HOWTO (0x11),
 
-  /* TOC relative indirect load.  */
+  /* 0x12: TOC relative indirect load.  */
   HOWTO (R_TRL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1579,7 +1579,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* TOC relative load address.	 */
+  /* 0x13: TOC relative load address.	 */
   HOWTO (R_TRLA,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1594,7 +1594,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable relative branch.  */
+  /* 0x14: Modifiable relative branch.  */
   HOWTO (R_RRTBI,		/* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1609,7 +1609,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable absolute branch.  */
+  /* 0x15: Modifiable absolute branch.  */
   HOWTO (R_RRTBA,		/* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1624,7 +1624,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable call absolute indirect.	 */
+  /* 0x16: Modifiable call absolute indirect.	 */
   HOWTO (R_CAI,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1639,7 +1639,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable call relative.	*/
+  /* 0x17: Modifiable call relative.	*/
   HOWTO (R_CREL,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1654,7 +1654,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x18: Modifiable branch absolute.  */
   HOWTO (R_RBA,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1669,7 +1669,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0x03fffffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x19: Modifiable branch absolute.  */
   HOWTO (R_RBAC,		/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1684,7 +1684,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch relative.  */
+  /* 0x1a: Modifiable branch relative.  */
   HOWTO (R_RBR,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1699,7 +1699,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0x03fffffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x1b: Modifiable branch absolute.  */
   HOWTO (R_RBRC,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1714,6 +1714,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
+  /* 0x1c: Standard 32 bit relocation.  */
   HOWTO (R_POS,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1728,7 +1729,7 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit Non modifiable absolute branch.  */
+  /* 0x1d: 16 bit Non modifiable absolute branch.  */
   HOWTO (R_BA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1743,22 +1744,22 @@ reloc_howto_type xcoff64_howto_table[] =
 	 0xfffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch relative.  */
+  /* 0x1e: Modifiable branch relative.  */
   HOWTO (R_RBR,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
 	 16,			/* bitsize */
-	 FALSE,			/* pc_relative */
+	 TRUE,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
 	 0,			/* special_function */
 	 "R_RBR_16",		/* name */
 	 TRUE,			/* partial_inplace */
-	 0xffff,		/* src_mask */
-	 0xffff,		/* dst_mask */
+	 0xfffc,		/* src_mask */
+	 0xfffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x1f: Modifiable branch absolute.  */
   HOWTO (R_RBA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1829,6 +1830,8 @@ xcoff64_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
     case BFD_RELOC_16:
       /* Note that this relocation is only internally used by gas.  */
       return &xcoff64_howto_table[0xc];
+    case BFD_RELOC_PPC_B16:
+      return &xcoff64_howto_table[0x1e];
     case BFD_RELOC_32:
     case BFD_RELOC_CTOR:
       return &xcoff64_howto_table[0x1c];
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index 7aebda8..5c413d3 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -6417,9 +6417,9 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
       char *where;
       unsigned long insn;
 
-#ifdef OBJ_ELF
       switch (fixP->fx_r_type)
 	{
+#ifdef OBJ_ELF
 	  /* The following relocs can't be calculated by the assembler.
 	     Leave the field zero.  */
 	case BFD_RELOC_PPC_TPREL16:
@@ -6528,11 +6528,18 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 	case BFD_RELOC_PPC_TLSLD:
 	  fieldval = 0;
 	  break;
+#endif
+
+#ifdef OBJ_XCOFF
+	case BFD_RELOC_PPC_B16:
+	  /* Adjust the offset to the instruction boundary.  */
+	  fieldval += 2;
+	  break;
+#endif
 
 	default:
 	  break;
 	}
-#endif
 
 #ifdef OBJ_ELF
 /* powerpc uses RELA style relocs, so if emitting a reloc the field
diff --git a/gas/testsuite/gas/ppc/aix.exp b/gas/testsuite/gas/ppc/aix.exp
index 6dcfc4e..2789837 100644
--- a/gas/testsuite/gas/ppc/aix.exp
+++ b/gas/testsuite/gas/ppc/aix.exp
@@ -65,6 +65,8 @@ if [istarget powerpc-ibm-aix*] then {
     run_dump_test "textalign-xcoff-002"
     run_dump_test "xcoff-branch-1-32"
     run_dump_test "xcoff-branch-1-64"
+    run_dump_test "xcoff-br16-1"
+    run_dump_test "xcoff-br16-2"
 
     run_list_test "xcoff-ref-1"
 
diff --git a/gas/testsuite/gas/ppc/ppc.exp b/gas/testsuite/gas/ppc/ppc.exp
index fec714c..ba29261 100644
--- a/gas/testsuite/gas/ppc/ppc.exp
+++ b/gas/testsuite/gas/ppc/ppc.exp
@@ -31,6 +31,7 @@ if { [istarget powerpc64*-*-*] || [istarget *-*-elf64*]} then {
     run_list_test "range64" "-a64"
 } elseif { [istarget powerpc*-*aix*] } then {
     run_dump_test "test1xcoff32"
+    run_dump_test "test2xcoff32"
 } elseif { [istarget powerpc*-*-*bsd*] \
      || [istarget powerpc*-*-elf*] \
      || [istarget powerpc*-*-eabi*] \
diff --git a/gas/testsuite/gas/ppc/test2xcoff32.d b/gas/testsuite/gas/ppc/test2xcoff32.d
new file mode 100644
index 0000000..125d34a
--- /dev/null
+++ b/gas/testsuite/gas/ppc/test2xcoff32.d
@@ -0,0 +1,40 @@
+#objdump: -dr
+#as:
+#name: PowerPC Test 2, 32 bit XCOFF
+
+.*: +file format aixcoff-rs6000
+
+
+Disassembly of section .text:
+
+00000000 <.main>:
+   0:	7c 08 02 a6 	mflr    r0
+   4:	90 01 00 08 	st      r0,8\(r1\)
+   8:	93 c1 ff f8 	st      r30,-8\(r1\)
+   c:	93 e1 ff fc 	st      r31,-4\(r1\)
+  10:	94 21 ff c0 	stu     r1,-64\(r1\)
+  14:	3b e0 00 00 	lil     r31,0
+  18:	83 c2 00 00 	l       r30,0\(r2\)
+			1a: R_TOC	LC\.\.0-0x70
+  1c:	7f c3 f3 78 	mr      r3,r30
+  20:	7f e4 fb 78 	mr      r4,r31
+  24:	4b ff ff dd 	bl      0 <.main>
+			24: R_BR	.printf
+  28:	60 00 00 00 	oril    r0,r0,0
+  2c:	2f 9f 00 09 	cmpi    7,r31,9
+  30:	3b ff 00 01 	cal     r31,1\(r31\)
+  34:	40 9e ff e8 	bne     7,1c <\.main\+0x1c>
+  38:	38 60 00 00 	lil     r3,0
+  3c:	38 21 00 40 	cal     r1,64\(r1\)
+  40:	80 01 00 08 	l       r0,8\(r1\)
+  44:	7c 08 03 a6 	mtlr    r0
+  48:	83 c1 ff f8 	l       r30,-8\(r1\)
+  4c:	83 e1 ff fc 	l       r31,-4\(r1\)
+  50:	4e 80 00 20 	br
+  54:	60 00 00 00 	oril    r0,r0,0
+  58:	60 00 00 00 	oril    r0,r0,0
+  5c:	60 00 00 00 	oril    r0,r0,0
+
+00000060 <_t\.rw_>:
+  60:	25 64 0a 00 	dozi    r11,r4,2560
+	...
diff --git a/gas/testsuite/gas/ppc/test2xcoff32.s b/gas/testsuite/gas/ppc/test2xcoff32.s
new file mode 100644
index 0000000..7ac2bff
--- /dev/null
+++ b/gas/testsuite/gas/ppc/test2xcoff32.s
@@ -0,0 +1,42 @@
+	.csect .text[PR]
+	.extern .printf
+	.toc
+LC..1:
+	.tc LC..0[TC],LC..0
+	.csect .text[PR]
+	.align 2
+	.globl main
+	.globl .main
+	.csect main[DS]
+main:
+	.long .main, TOC[tc0], 0
+	.csect .text[PR]
+.main:
+	mflr 0
+	stw 0,8(1)
+	stw 30,-8(1)
+	stw 31,-4(1)
+	stwu 1,-64(1)
+	li 31,0
+	lwz 30,LC..1(2)
+L..2:
+	mr 3,30
+	mr 4,31
+	bl .printf
+	nop
+	cmpwi 7,31,9
+	addi 31,31,1
+	bne 7,L..2
+	li 3,0
+	addi 1,1,64
+	lwz 0,8(1)
+	mtlr 0
+	lwz 30,-8(1)
+	lwz 31,-4(1)
+	blr
+	
+	.csect _t.rw_[RO],4
+	.align 2
+LC..0:
+	.byte "%d"
+	.byte 10, 0
diff --git a/gas/testsuite/gas/ppc/xcoff-br16-1.d b/gas/testsuite/gas/ppc/xcoff-br16-1.d
new file mode 100644
index 0000000..5052279
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-br16-1.d
@@ -0,0 +1,20 @@
+#as: -a32
+#source: xcoff-br16-1.s
+#objdump: -P relocs -dr
+#name: XCOFF R_RBR/16 reloc test 1
+
+.*
+Relocations for \.text .*
+vaddr    sgn mod sz type  symndx symbol
+00000002  S      16 RBR   [0-9]      c
+00000006  S      16 RBR   [0-9]      c
+
+
+
+Disassembly of section \.text:
+
+00000000 <\.text>:
+   0:	40 82 00 00 	bne     0x0
+			2: R_RBR_16	c
+   4:	40 82 ff fd 	bnel    0x0
+			6: R_RBR_16	c
diff --git a/gas/testsuite/gas/ppc/xcoff-br16-1.s b/gas/testsuite/gas/ppc/xcoff-br16-1.s
new file mode 100644
index 0000000..f6b66e8
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-br16-1.s
@@ -0,0 +1,4 @@
+	.extern	c
+	bne	c
+	bnel	c
+
diff --git a/gas/testsuite/gas/ppc/xcoff-br16-2.d b/gas/testsuite/gas/ppc/xcoff-br16-2.d
new file mode 100644
index 0000000..173ed06
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-br16-2.d
@@ -0,0 +1,20 @@
+#as: -a32
+#source: xcoff-br16-2.s
+#objdump: -P relocs -dr
+#name: XCOFF R_RBR/16 reloc test 2
+
+.*
+Relocations for \.text .*
+vaddr    sgn mod sz type  symndx symbol
+00000002  S      16 RBR   [0-9]      c
+00000006  S      16 RBR   [0-9]      c
+
+
+
+Disassembly of section \.text:
+
+00000000 <\.text>:
+   0:	40 82 00 04 	bne     0x4
+			2: R_RBR_16	c
+   4:	40 82 00 01 	bnel    0x4
+			6: R_RBR_16	c
diff --git a/gas/testsuite/gas/ppc/xcoff-br16-2.s b/gas/testsuite/gas/ppc/xcoff-br16-2.s
new file mode 100644
index 0000000..41bbc48
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-br16-2.s
@@ -0,0 +1,3 @@
+	.extern	c
+	bne	c + 4
+	bnel	c + 4


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