This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
[PATCH] bfd_target_xcoff_flavour
- To: binutils at sourceware dot cygnus dot com
- Subject: [PATCH] bfd_target_xcoff_flavour
- From: "Nick Duffek <Nick Duffek"<nsd at cygnus dot com>
- Date: Fri, 12 May 2000 19:25:29 GMT
GDB needs to distinguish between COFF and XCOFF files. Previously, this
was done using the following self-described kludge:
int xcoff = strcmp (bfd_get_target (abfd), "aixcoff-rs6000") ||
strcmp (bfd_get_target (abfd), "xcoff-powermac");
That doesn't work as-is for XCOFF64, whose target name is
"aixcoff64-rs6000". Rather than add another special case, it seemed
better to un-kludge it and create bfd_target_xcoff_flavour.
The appended patch does that, and removes several similar uses of strcmp()
in bfd source files.
Is it okay to apply this patch?
Nick Duffek
nsd@cygnus.com
Index: bfd/bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.11
diff -u -r1.11 bfd-in.h
--- bfd/bfd-in.h 2000/05/05 18:12:53 1.11
+++ bfd/bfd-in.h 2000/05/05 21:31:32
@@ -489,6 +489,9 @@
#define bfd_get_format(abfd) ((abfd)->format)
#define bfd_get_target(abfd) ((abfd)->xvec->name)
#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
+#define bfd_family_coff(abfd) \
+ (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
+ bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
#define bfd_header_big_endian(abfd) \
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.45
diff -u -r1.45 bfd-in2.h
--- bfd/bfd-in2.h 2000/05/05 18:12:53 1.45
+++ bfd/bfd-in2.h 2000/05/05 21:31:37
@@ -489,6 +489,9 @@
#define bfd_get_format(abfd) ((abfd)->format)
#define bfd_get_target(abfd) ((abfd)->xvec->name)
#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
+#define bfd_family_coff(abfd) \
+ (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
+ bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
#define bfd_header_big_endian(abfd) \
@@ -3053,6 +3056,7 @@
bfd_target_aout_flavour,
bfd_target_coff_flavour,
bfd_target_ecoff_flavour,
+ bfd_target_xcoff_flavour,
bfd_target_elf_flavour,
bfd_target_ieee_flavour,
bfd_target_nlm_flavour,
Index: bfd/coffgen.c
===================================================================
RCS file: /cvs/src/src/bfd/coffgen.c,v
retrieving revision 1.13
diff -u -r1.13 coffgen.c
--- bfd/coffgen.c 2000/04/26 15:09:43 1.13
+++ bfd/coffgen.c 2000/05/05 21:31:39
@@ -525,7 +525,7 @@
{
asymbol *q_maybe = *p;
- if (bfd_asymbol_flavour (q_maybe) == bfd_target_coff_flavour)
+ if (bfd_family_coff (bfd_asymbol_bfd (q_maybe)))
{
coff_symbol_type *q = coffsymbol (q_maybe);
@@ -564,7 +564,7 @@
bfd *ignore_abfd ATTRIBUTE_UNUSED;
asymbol *symbol;
{
- if (bfd_asymbol_flavour (symbol) != bfd_target_coff_flavour)
+ if (!bfd_family_coff (bfd_asymbol_bfd (symbol)))
return (coff_symbol_type *) NULL;
if (bfd_asymbol_bfd (symbol)->tdata.coff_obj_data == (coff_data_type *) NULL)
@@ -2200,7 +2200,7 @@
*line_ptr = 0;
/* Don't try and find line numbers in a non coff file */
- if (abfd->xvec->flavour != bfd_target_coff_flavour)
+ if (!bfd_family_coff (abfd))
return false;
if (cof == NULL)
Index: bfd/cofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/cofflink.c,v
retrieving revision 1.15
diff -u -r1.15 cofflink.c
--- bfd/cofflink.c 2000/03/01 19:40:53 1.15
+++ bfd/cofflink.c 2000/05/05 21:31:43
@@ -894,8 +894,7 @@
for (p = o->link_order_head; p != NULL; p = p->next)
{
if (p->type == bfd_indirect_link_order
- && (bfd_get_flavour (p->u.indirect.section->owner)
- == bfd_target_coff_flavour))
+ && bfd_family_coff (p->u.indirect.section->owner))
{
sub = p->u.indirect.section->owner;
if (! bfd_coff_link_output_has_begun (sub, & finfo))
Index: bfd/cpu-ns32k.c
===================================================================
RCS file: /cvs/src/src/bfd/cpu-ns32k.c,v
retrieving revision 1.2
diff -u -r1.2 cpu-ns32k.c
--- bfd/cpu-ns32k.c 1999/07/12 10:28:58 1.2
+++ bfd/cpu-ns32k.c 2000/05/05 21:31:44
@@ -290,8 +290,7 @@
reloc_entry->address += input_section->output_offset;
/* WTF?? */
- if (abfd->xvec->flavour == bfd_target_coff_flavour
- && strcmp (abfd->xvec->name, "aixcoff-rs6000") != 0)
+ if (abfd->xvec->flavour == bfd_target_coff_flavour)
{
#if 1
/* For m68k-coff, the addend was being subtracted twice during
Index: bfd/reloc.c
===================================================================
RCS file: /cvs/src/src/bfd/reloc.c,v
retrieving revision 1.23
diff -u -r1.23 reloc.c
--- bfd/reloc.c 2000/05/02 00:12:46 1.23
+++ bfd/reloc.c 2000/05/05 21:31:46
@@ -728,9 +728,6 @@
/* WTF?? */
if (abfd->xvec->flavour == bfd_target_coff_flavour
- && strcmp (abfd->xvec->name, "aixcoff-rs6000") != 0
- && strcmp (abfd->xvec->name, "aixcoff64-rs6000") != 0
- && strcmp (abfd->xvec->name, "xcoff-powermac") != 0
&& strcmp (abfd->xvec->name, "coff-Intel-little") != 0
&& strcmp (abfd->xvec->name, "coff-Intel-big") != 0)
{
@@ -1125,9 +1122,6 @@
/* WTF?? */
if (abfd->xvec->flavour == bfd_target_coff_flavour
- && strcmp (abfd->xvec->name, "aixcoff-rs6000") != 0
- && strcmp (abfd->xvec->name, "aixcoff64-rs6000") != 0
- && strcmp (abfd->xvec->name, "xcoff-powermac") != 0
&& strcmp (abfd->xvec->name, "coff-Intel-little") != 0
&& strcmp (abfd->xvec->name, "coff-Intel-big") != 0)
{
Index: bfd/targets.c
===================================================================
RCS file: /cvs/src/src/bfd/targets.c,v
retrieving revision 1.20
diff -u -r1.20 targets.c
--- bfd/targets.c 2000/05/02 11:18:33 1.20
+++ bfd/targets.c 2000/05/05 21:31:47
@@ -141,6 +141,7 @@
. bfd_target_aout_flavour,
. bfd_target_coff_flavour,
. bfd_target_ecoff_flavour,
+. bfd_target_xcoff_flavour,
. bfd_target_elf_flavour,
. bfd_target_ieee_flavour,
. bfd_target_nlm_flavour,
Index: bfd/xcoff-target.h
===================================================================
RCS file: /cvs/src/src/bfd/xcoff-target.h,v
retrieving revision 1.1
diff -u -r1.1 xcoff-target.h
--- bfd/xcoff-target.h 2000/04/29 14:41:30 1.1
+++ bfd/xcoff-target.h 2000/05/05 21:31:47
@@ -155,7 +155,7 @@
const bfd_target TARGET_SYM =
{
TARGET_NAME,
- bfd_target_coff_flavour,
+ bfd_target_xcoff_flavour,
BFD_ENDIAN_BIG, /* data byte order is big */
BFD_ENDIAN_BIG, /* header byte order is big */
Index: bfd/xcofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/xcofflink.c,v
retrieving revision 1.5
diff -u -r1.5 xcofflink.c
--- bfd/xcofflink.c 2000/04/26 15:09:43 1.5
+++ bfd/xcofflink.c 2000/05/05 21:31:53
@@ -29,15 +29,6 @@
#define STRING_SIZE_SIZE (4)
-/* In order to support linking different object file formats into an
- XCOFF format, we need to be able to determine whether a particular
- bfd_target is an XCOFF vector. FIXME: We need to rethink this
- whole approach. */
-#define XCOFF_XVECP(xv) \
- (strcmp ((xv)->name, "aixcoff-rs6000") == 0 \
- || strcmp ((xv)->name, "aixcoff64-rs6000") == 0 \
- || strcmp ((xv)->name, "xcoff-powermac") == 0)
-
/* Get the XCOFF hash table entries for a BFD. */
#define obj_xcoff_sym_hashes(bfd) \
((struct xcoff_link_hash_entry **) obj_coff_sym_hashes (bfd))
@@ -2916,7 +2907,7 @@
struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
struct xcoff_link_size_list *n;
- if (! XCOFF_XVECP (output_bfd->xvec))
+ if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
return true;
/* This will hardly ever be called. I don't want to burn four bytes
@@ -2952,7 +2943,7 @@
{
struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
- if (! XCOFF_XVECP (output_bfd->xvec))
+ if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
return true;
/* A symbol name which starts with a period is the code for a
@@ -3066,7 +3057,7 @@
{
struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
- if (! XCOFF_XVECP (output_bfd->xvec))
+ if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
return true;
h->flags |= XCOFF_EXPORT;
@@ -3131,7 +3122,7 @@
{
struct xcoff_link_hash_entry *h;
- if (! XCOFF_XVECP (output_bfd->xvec))
+ if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
return true;
h = ((struct xcoff_link_hash_entry *)
@@ -3165,7 +3156,7 @@
{
struct xcoff_link_hash_entry *h;
- if (! XCOFF_XVECP (output_bfd->xvec))
+ if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
return true;
h = xcoff_link_hash_lookup (xcoff_hash_table (info), name, true, true,
@@ -3250,7 +3241,7 @@
struct bfd_strtab_hash *debug_strtab;
bfd_byte *debug_contents = NULL;
- if (! XCOFF_XVECP (output_bfd->xvec))
+ if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
{
for (i = 0; i < 6; i++)
special_sections[i] = NULL;