[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Xcoff relocation types not supported?
From: |
Nick Clifton |
Subject: |
Re: Xcoff relocation types not supported? |
Date: |
03 May 2002 10:27:21 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1 |
Hi Alan, Hi Jason, Hi Tom,
> Current CVS mainline binutils assembles your test file OK, but
> objdump bombs when trying to display relocs. :-(
>
> BFD: BFD 2.12.90 20020502 internal error, aborting at
> /src/binutils-current/bfd/coff-rs6000.c line 976 in _bfd_xcoff_rtype2howto
Indeed it does. This is because _bfd_xcoff_rtype2howto() selects the
32-bit R_BA reloc instead of the 16-bit one. The patch below fixes
this.
Tom - any objections to my applying this patch (branch & mainline) ?
Cheers
Nick
2002-05-03 Nick Clifton <address@hidden>
* coff-rs6000.c (xcoff_howto_table): Move 64-bit R_POS entry
and 16-bit R_BA entry to ....
(xcoff_64bit_r_pos_howto_table): here and ...
(xcoff_16bit_r_ba_howto_table): here.
(_bfd_xcoff_rtype2howto): Detect attempts to select the 64-bit
R_POS or 16-bit R_BA reloc and choose the appropriate
alternative table.
Use ARRAY_SIZE macro from libiberty.h
Index: bfd/coff-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-rs6000.c,v
retrieving revision 1.37
diff -c -3 -p -w -r1.37 coff-rs6000.c
*** bfd/coff-rs6000.c 28 Apr 2002 14:34:38 -0000 1.37
--- bfd/coff-rs6000.c 3 May 2002 09:23:55 -0000
*************** Foundation, Inc., 59 Temple Place - Suit
*** 35,40 ****
--- 35,41 ----
#include "coff/rs6000.h"
#include "libcoff.h"
#include "libxcoff.h"
+ #include "libiberty.h"
extern boolean _bfd_xcoff_mkobject PARAMS ((bfd *));
extern boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));
*************** reloc_howto_type xcoff_howto_table[] =
*** 920,926 ****
--- 921,930 ----
0xffff, /* src_mask */
0xffff, /* dst_mask */
false), /* pcrel_offset */
+ };
+ reloc_howto_type xcoff_64bit_r_pos_howto_table[] =
+ {
HOWTO (R_POS, /* type */
0, /* rightshift */
4, /* size (0 = byte, 1 = short, 2 = long) */
*************** reloc_howto_type xcoff_howto_table[] =
*** 934,939 ****
--- 938,947 ----
MINUS_ONE, /* src_mask */
MINUS_ONE, /* dst_mask */
false), /* pcrel_offset */
+ };
+
+ reloc_howto_type xcoff_16bit_r_ba_howto_table[] =
+ {
/* 16 bit Non modifiable absolute branch. */
HOWTO (R_BA, /* type */
*************** _bfd_xcoff_rtype2howto (relent, internal
*** 959,969 ****
relent->howto = xcoff_howto_table + internal->r_type;
/* Check for relocs we don't know of. */
! if (internal->r_type
! >= sizeof (xcoff_howto_table) / sizeof (xcoff_howto_table[0]))
abort ();
if (internal->r_type != relent->howto->type)
abort ();
/* The r_size field of an XCOFF reloc encodes the bitsize of the
relocation, as well as indicating whether it is signed or not.
--- 967,984 ----
relent->howto = xcoff_howto_table + internal->r_type;
/* Check for relocs we don't know of. */
! if (internal->r_type >= ARRAY_SIZE (xcoff_howto_table))
abort ();
if (internal->r_type != relent->howto->type)
abort ();
+
+ /* Catch a couple of special cases. */
+ if (internal->r_type == R_BA
+ && internal->r_size == 15)
+ relent->howto = xcoff_16bit_r_ba_howto_table;
+ else if (internal->r_type == R_POS
+ && internal->r_size == 63)
+ relent->howto = xcoff_64bit_r_pos_howto_table;
/* The r_size field of an XCOFF reloc encodes the bitsize of the
relocation, as well as indicating whether it is signed or not.