This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
[PATCH] bfd_target_xcoff_flavour (again)
- To: binutils at sourceware dot cygnus dot com
- Subject: [PATCH] bfd_target_xcoff_flavour (again)
- From: Nick Duffek <nsd at redhat dot com>
- Date: Thu, 8 Jun 2000 21:43:19 -0400
I submitted this patch last month for approval, but I didn't get a
response, probably because I mixed up the subject line with another patch.
Here it is again.
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.
Okay to apply?
Nick Duffek
nsd@redhat.com
2000-06-08 Nicholas Duffek <nsd@redhat.com>
* bfd-in.h (bfd_family_coff): Define.
* bfd-in2.h: Regenerate.
* coffgen.c (coff_count_linenumbers, coff_symbol_from,
coff_find_nearest_line): Check COFFness using bfd_family_coff()
instead of bfd_target_coff_flavour.
* cofflink.c (_bfd_coff_final_link): Likewise.
* cpu-ns32k.c (do_ns32k_reloc): Don't strcmp() target name to
exclude XCOFF files.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Likewise.
* targets.c (enum bfd_flavour): Add bfd_target_xcoff_flavour.
* xcoff-target.h (TARGET_SYM): Use bfd_target_xcoff_flavour.
* xcofflink.c (XCOFF_XVECP): Delete.
(bfd_xcoff_link_record_set, bfd_xcoff_import_symbol,
bfd_xcoff_export_symbol, bfd_xcoff_link_count_reloc,
bfd_xcoff_record_link_assignment,
bfd_xcoff_size_dynamic_sections): Replace XCOFF_XVECP() with
check for bfd_target_xcoff_flavour.
Index: bfd/bfd-in.h
===================================================================
diff -u bfd/bfd-in.h bfd/bfd-in.h
--- bfd/bfd-in.h Mon Jun 5 12:37:33 2000
+++ bfd/bfd-in.h Mon Jun 5 12:37:25 2000
@@ -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
===================================================================
diff -u bfd/bfd-in2.h bfd/bfd-in2.h
--- bfd/bfd-in2.h Mon Jun 5 12:37:53 2000
+++ bfd/bfd-in2.h Mon Jun 5 12:37:25 2000
@@ -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) \
@@ -3057,6 +3060,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
===================================================================
diff -u bfd/coffgen.c bfd/coffgen.c
--- bfd/coffgen.c Mon Jun 5 12:38:06 2000
+++ bfd/coffgen.c Mon Jun 5 12:37:25 2000
@@ -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
===================================================================
diff -u bfd/cofflink.c bfd/cofflink.c
--- bfd/cofflink.c Mon Jun 5 12:38:24 2000
+++ bfd/cofflink.c Mon Jun 5 12:37:25 2000
@@ -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
===================================================================
diff -u bfd/cpu-ns32k.c bfd/cpu-ns32k.c
--- bfd/cpu-ns32k.c Mon Jun 5 12:38:32 2000
+++ bfd/cpu-ns32k.c Mon Jun 5 12:37:25 2000
@@ -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
===================================================================
diff -u bfd/reloc.c bfd/reloc.c
--- bfd/reloc.c Mon Jun 5 12:38:52 2000
+++ bfd/reloc.c Mon Jun 5 12:37:25 2000
@@ -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
===================================================================
diff -u bfd/targets.c bfd/targets.c
--- bfd/targets.c Mon Jun 5 12:39:02 2000
+++ bfd/targets.c Mon Jun 5 12:37:25 2000
@@ -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
===================================================================
diff -u bfd/xcoff-target.h bfd/xcoff-target.h
--- bfd/xcoff-target.h Mon Jun 5 12:39:07 2000
+++ bfd/xcoff-target.h Mon Jun 5 12:37:25 2000
@@ -151,7 +151,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
===================================================================
diff -u bfd/xcofflink.c bfd/xcofflink.c
--- bfd/xcofflink.c Mon Jun 5 12:39:39 2000
+++ bfd/xcofflink.c Mon Jun 5 12:37:25 2000
@@ -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;