+Tue Nov 26 09:10:55 1991 Steve Chamberlain (sac at cygnus.com)
+
+ * Makefile.in: added coff-h8300
+ * configure.in: now h8 is a coff target
+ * cpu-h8300.c: fix various disassembly problems
+ * libcoff.h: took out some code which has been #0ed for a long
+ time.
+ * targets.c: added h8 coff
+ * coff-a29k.c, coff-i386.c, coff-i960.c, coff-m68k.c, coff-m88k.c
+ added new macro RTYPE2HOWTO to take a load of #ifdefs out of
+ coffcode.h
+ * coffcode.h: Started to change the way machine dependencies are
+ handled, from the nest of #ifdefs to macros defined in the
+ including coff-<foo>.c
+
+
+
+
Fri Nov 22 08:11:42 1991 John Gilmore (gnu at cygnus.com)
* aoutx.h (some_aout_object_p): Set the `executable' bit
BFD_BACKENDS = oasys.o ieee.o srec.o elf.o stab-syms.o\
aout64.o aout32.o demo64.o sunos.o newsos3.o i386aout.o bout.o \
coff-i960.o coff-a29k.o coff-m68k.o coff-i386.o coff-m88k.o \
- coff-mips.o coff-rs6000.o
+ coff-mips.o coff-rs6000.o coff-h8300.o
OPTIONAL_BACKENDS = trad-core.o
format.c section.c core.c syms.c stabs-syms.c reloc.c init.c ctor.c \
coff-m88k.c coff-mips.c trad-core.c newsos3.c i386aout.c bout.c elf.c \
cpu-h8300.c cpu-i960.c cpu-sparc.c cpu-m68k.c cpu-m88k.c \
- cpu-vax.c cpu-mips.c cpu-a29k.c cpu-i386.c cpu-rs6000.c
+ cpu-vax.c cpu-mips.c cpu-a29k.c cpu-i386.c cpu-rs6000.c coff-h8300.c
STAGESTUFF = $(TARGETLIB) $(OFILES)
targets.o : targets.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h
cache.o : cache.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h
archures.o : archures.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h
-coff-i386.o : coff-i386.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \
- $(INCDIR)/coff-i386.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h
aout64.o : aout64.c
aout32.o : aout32.c aoutx.h $(INCDIR)/bfd.h $(INCDIR)/ansidecl.h \
$(INCDIR)/obstack.h libaout.h libbfd.h $(INCDIR)/aout64.h \
libaout.h libbfd.h $(INCDIR)/aout64.h $(INCDIR)/stab.gnu.h \
$(INCDIR)/stab.def $(INCDIR)/ar.h
demo64.o : demo64.c
-coff-i960.o : coff-i960.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \
- $(INCDIR)/coff-i960.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h
+
srec.o : srec.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h
oasys.o : oasys.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \
$(INCDIR)/oasys.h liboasys.h
ieee.o : ieee.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \
$(INCDIR)/ieee.h libieee.h
-coff-m68k.o : coff-m68k.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \
- $(INCDIR)/coff-m68k.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h
-coff-a29k.o : coff-a29k.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \
- $(INCDIR)/coff-a29k.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h
-coff-rs6000.o: coff-rs6000.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \
- $(INCDIR)/coff-rs6000.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h
+coff-h8300.o: coff-h8300.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \
+ $(INCDIR)/coff-h8300.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h
format.o : format.c $(INCDIR)/bfd.h \
$(INCDIR)/obstack.h libbfd.h
section.o : section.c $(INCDIR)/bfd.h \
syms.o : stab-syms.c
reloc.o : reloc.c $(INCDIR)/bfd.h \
$(INCDIR)/obstack.h libbfd.h
-coff-m88k.o : coff-m88k.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \
- $(INCDIR)/coff-m88k.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h
-coff-mips.o : coff-mips.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \
- $(INCDIR)/coff-mips.h $(INCDIR)/internalcoff.h libcoff.h trad-core.h \
- coffcode.h
+
trad-core.o : trad-core.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h \
libbfd.h libaout.h
newsos3.o : newsos3.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \
#define BADMAG(x) A29KBADMAG(x)
+/* This macro translates an external r_type field into a pointer to an
+ entry in the above table */
+
+
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ if (dst.r_type == R_IHCONST) { \
+ /* Add in the value which was stored in the symbol index */\
+ cache_ptr->addend += dst.r_symndx; \
+ /* Throw away the bogus symbol pointer */ \
+ cache_ptr->sym_ptr_ptr = 0; \
+ } \
+ cache_ptr->howto = howto_table + dst.r_type; \
+
#include "coffcode.h"
bfd_target a29kcoff_big_vec =
/* $Id$ */
-#define I386 1
-#include <ansidecl.h>
-#include <sysdep.h>
#include "bfd.h"
+#include "sysdep.h"
#include "libbfd.h"
#include "obstack.h"
-#include "i386coff.h"
+#include "coff-i386.h"
#include "internalcoff.h"
#include "libcoff.h"
#define SELECT_RELOC(x,howto) { x = howto->type; }
#define BADMAG(x) I386BADMAG(x)
+#define I386 1 /* Customize coffcode.h */
+
+#define RTYPETOHOWTO(cache_ptr, dst) \
+ cache_ptr->howto = howto_table + dst.r_type;
+
#include "coffcode.h"
#define coff_write_armap bsd_write_armap
bfd_target i386coff_vec =
{
- "i386coff", /* name */
+ "coff-i386", /* name */
bfd_target_coff_flavour,
false, /* data byte order is little */
false, /* header byte order is little */
-/* Intel 960 COFF support for BFD. */
+/* Intel 960 COFF support for BFD.
+ Copyright (C) 1990-1991 Free Software Foundation, Inc.
+ Written by Cygnus Support.
-/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+This file is part of BFD, the Binary File Descriptor library.
-This file is part of BFD, the Binary File Diddler.
-
-BFD is free software; you can redistribute it and/or modify
+This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
-BFD is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with BFD; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* $Id$ */
#define I960 1
#define BADMAG(x) I960BADMAG(x)
-#include <ansidecl.h>
-#include <sysdep.h>
#include "bfd.h"
+#include "sysdep.h"
#include "libbfd.h"
#include "obstack.h"
-#include "intel-coff.h"
+#include "coff-i960.h"
+#include "internalcoff.h"
#include "libcoff.h" /* to allow easier abstraction-breaking */
#define BAL 0x0b000000 /* Template for 'bal' instruction */
#define BAL_MASK 0x00ffffff
-static bfd_reloc_status_enum_type
+static bfd_reloc_status_type
optcall_callback(abfd, reloc_entry, symbol_in, data, ignore_input_section)
bfd *abfd;
arelent *reloc_entry;
/* This item has already been relocated correctly, but we may be
* able to patch in yet better code - done by digging out the
* correct info on this symbol */
- bfd_reloc_status_enum_type result;
+ bfd_reloc_status_type result;
coff_symbol_type *cs = coffsymbol(symbol_in);
/* So the target symbol has to be of coff type, and the symbol
has to have the correct native information within it */
- if ((cs->symbol.the_bfd->xvec->flavour != bfd_target_coff_flavour_enum)
- || (cs->native == (struct internal_syment *)NULL)) {
+ if ((cs->symbol.the_bfd->xvec->flavour != bfd_target_coff_flavour)
+ || (cs->native == (combined_entry_type *)NULL)) {
/* This is interesting, consider the case where we're outputting */
/* coff from a mix n match input, linking from coff to a symbol */
/* defined in a bout file will cause this match to be true. Should */
result = bfd_reloc_dangerous;
}
else {
- switch (cs->native->n_sclass)
+ switch (cs->native->u.syment.n_sclass)
{
case C_LEAFSTAT:
case C_LEAFEXT:
/* This is a call to a leaf procedure, replace instruction with a bal
to the correct location */
{
- union internal_auxent *aux = (union internal_auxent *)(cs->native+2);
+ union internal_auxent *aux = &((cs->native+2)->u.auxent);
int word = bfd_get_32(abfd, data + reloc_entry->address);
- int olf = (aux->x_bal.x_balntry - cs->native->n_value);
- BFD_ASSERT(cs->native->n_numaux==2);
+ int olf = (aux->x_bal.x_balntry - cs->native->u.syment.n_value);
+ BFD_ASSERT(cs->native->u.syment.n_numaux==2);
/* We replace the original call instruction with a bal to */
/* the bal entry point - the offset of which is described in the */
/* 2nd auxent of the original symbol. We keep the native sym and */
result = bfd_reloc_ok;
break;
case C_SCALL:
- {
- /* This is a call to a system call, replace with a calls to # */
- BFD_ASSERT(0);
- }
+ /* This is a call to a system call, replace with a calls to # */
+ BFD_ASSERT(0);
+ result = bfd_reloc_ok;
break;
default:
result = bfd_reloc_ok;
/* The real code is in coffcode.h */
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ cache_ptr->howto = howto_table + dst.r_type;
+
#include "coffcode.h"
bfd_target icoff_little_vec =
{
"coff-Intel-little", /* name */
- bfd_target_coff_flavour_enum,
+ bfd_target_coff_flavour,
false, /* data byte order is little */
false, /* header byte order is little */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
+ 3, /* minimum alignment power */
_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */
_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */
bfd_target icoff_big_vec =
{
"coff-Intel-big", /* name */
- bfd_target_coff_flavour_enum,
+ bfd_target_coff_flavour,
false, /* data byte order is little */
true, /* header byte order is big */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
+ 3, /* minimum alignment power */
_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */
_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
-/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+/* Motorola 68000 COFF back-end for BFD.
+ Copyright (C) 1990-1991 Free Software Foundation, Inc.
+ Written by Cygnus Support.
-This file is part of BFD, the Binary File Diddler.
+This file is part of BFD, the Binary File Descriptor library.
-BFD is free software; you can redistribute it and/or modify
+This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
-BFD is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with BFD; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* $Id$ */
-#define M68 1
-#include <ansidecl.h>
-#include <sysdep.h>
#include "bfd.h"
+#include "sysdep.h"
#include "libbfd.h"
#include "obstack.h"
-#include "m68kcoff.h"
+#include "coff-m68k.h"
+#include "internalcoff.h"
#include "libcoff.h"
-
static reloc_howto_type howto_table[] =
{
HOWTO(R_RELBYTE, 0, 0, 8, false, 0, true, true,0,"8", true, 0x000000ff,0x000000ff, false),
};
-/* Turn a howto into a reloc nunmber */
+/* Turn a howto into a reloc number */
#define SELECT_RELOC(x,howto) { x = howto_table[howto->size +(int)howto->pc_relative*3].type; }
#define BADMAG(x) M68KBADMAG(x)
-#include "coff-code.h"
+#define M68 1 /* Customize coffcode.h */
+#define RTYPE2HOWTO(internal, relocentry) \
+ (internal)->howto = ( howto_table + (relocentry).r_type - R_RELBYTE);
-#define coff_write_armap bsd_write_armap
+#include "coffcode.h"
+#define coff_write_armap bsd_write_armap
+
bfd_target m68kcoff_vec =
{
- "m68kcoff", /* name */
- bfd_target_coff_flavour_enum,
+ "coff-m68k", /* name */
+ bfd_target_coff_flavour,
true, /* data byte order is big */
true, /* header byte order is big */
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
-
+ 3, /* minimum section alignment */
_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
_bfd_write_archive_contents, bfd_false},
JUMP_TABLE(coff)
-
- };
-
-
-
+};
};
+/* Code to swap in the reloc offset */
+#define SWAP_IN_RELOC_OFFSET bfd_h_get_16
+#define SWAP_OUT_RELOC_OFFSET bfd_h_put_16
+
+
+/* Code to turn an external r_type into a pointer to an entry in the
+ above howto table */
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ if (dst.r_type >= R_PCR16L && dst.r_type <= R_VRT32) { \
+ cache_ptr->howto = howto_table + dst.r_type - R_PCR16L; \
+ cache_ptr->addend += dst.r_offset << 16; \
+ } \
+ else { \
+ BFD_ASSERT(0); \
+ }
+
+
#define BADMAG(x) MC88BADMAG(x)
#include "coffcode.h"
bfd_target m88kbcs_vec =
{
- "m88kbcs", /* name */
+ "coff-m88kbcs", /* name */
bfd_target_coff_flavour,
true, /* data byte order is big */
true, /* header byte order is big */
Coff in all its varieties is implimented with a few common files and a
number of implementation specific files. For example, The 88k bcs coff
-format is implemented in the file @code{m88k-bcs.c}. This file
-@code{#include}s @code{m88k-bcs.h} which defines the external
+format is implemented in the file @code{coff-m88k.c}. This file
+@code{#include}s @code{coff-m88k.h} which defines the external
structure of the coff format for the 88k, and @code{internalcoff.h}
-which defines the internal structure. @code{m88k-bcs.c} also defines
+which defines the internal structure. @code{coff-m88k.c} also defines
the relocations used by the 88k format @xref{Relocations}. Then the
major portion of coff code is included (@code{coffcode.h}) which
defines the methods used to act upon the types defined in
-@code{m88k-bcs.h} and @code{internalcoff.h}.
+@code{coff-m88k.h} and @code{internalcoff.h}.
The Intel i960 processor version of coff is implemented in
-@code{icoff.c}. This file has the same structure as
-@code{m88k-bcs.c}, except that it includes @code{intel-coff.h} rather
-than @code{m88k-bcs.h}.
+@code{coff-i960.c}. This file has the same structure as
+@code{coff-m88k.c}, except that it includes @code{coff-i960.h} rather
+than @code{coff-m88k.h}.
@subsection Porting To A New Version of Coff
reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
#endif
-#if M88
- reloc_dst->r_offset = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_offset);
+#ifdef SWAP_IN_RELOC_OFFSET
+ reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd, reloc_src->r_offset);
#endif
}
struct external_reloc *reloc_dst = (struct external_reloc *)dst;
bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
- bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *) reloc_dst->r_type);
-#if M88
- bfd_h_put_16(abfd, reloc_src->r_offset, (bfd_byte *) reloc_dst->r_offset);
+ bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
+ reloc_dst->r_type);
+
+#ifdef SWAP_OUT_RELOC_OFFSET
+ SWAP_OUT_RELOC_OFFSET(abfd,
+ reloc_src->r_offset,
+ (bfd_byte *) reloc_dst->r_offset);
+#endif
+#ifdef SWAP_OUT_RELOC_EXTRA
+ SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
#endif
+
return sizeof(struct external_reloc);
}
break;
#endif
+#ifdef H8300MAGIC
+ case H8300MAGIC:
+ arch = bfd_arch_h8300;
+ machine = 0;
+ break;
+#endif
default: /* Unreadable input file type */
arch = bfd_arch_obscure;
{
FILE *file = (FILE *)filep;
switch (how) {
- case bfd_print_symbol_name:
- fprintf(file, "%s", symbol->name);
- break;
- case bfd_print_symbol_more:
- fprintf(file, "coff %lx %lx", (unsigned long) coffsymbol(symbol)->native,
- (unsigned long) coffsymbol(symbol)->lineno);
- break;
- case bfd_print_symbol_nm:
- case bfd_print_symbol_all:
+ case bfd_print_symbol_name:
+ fprintf(file, "%s", symbol->name);
+ break;
+ case bfd_print_symbol_more:
+ fprintf(file, "coff %lx %lx", (unsigned long) coffsymbol(symbol)->native,
+ (unsigned long) coffsymbol(symbol)->lineno);
+ break;
+ case bfd_print_symbol_nm:
+
+ {
+ CONST char *section_name = symbol->section == (asection *) NULL ?
+ "*abs" : symbol->section->name;
+ bfd_print_symbol_vandf((PTR) file, symbol);
+
+
+ fprintf(file, " %-5s %s %s %s",
+ section_name,
+ coffsymbol(symbol)->native ? "n" : "g",
+ coffsymbol(symbol)->lineno ? "l" : " ",
+ symbol->name);
+ }
+
+
+ break;
+ case bfd_print_symbol_all:
+ /* Print out the symbols in a reasonable way */
+ {
+ CONST char *section_name = symbol->section == (asection *) NULL ?
+ "*abs" : symbol->section->name;
+
+
+ if (coffsymbol(symbol)->native)
{
- CONST char *section_name = symbol->section == (asection *) NULL ?
- (CONST char *)"*abs" : symbol->section->name;
- bfd_print_symbol_vandf((PTR) file, symbol);
-
- fprintf(file, " %-5s %s %s %s",
- section_name,
- coffsymbol(symbol)->native ? "n" : "g",
- coffsymbol(symbol)->lineno ? "l" : " ",
- symbol->name);
- }
+ unsigned int aux;
+ combined_entry_type *combined = coffsymbol(symbol)->native;
+ combined_entry_type *root = obj_raw_syments(ignore_abfd);
+
+fprintf(file,"[%3d]",
+ combined - root);
+
+ fprintf(file, "(sc %2d)(fl%4x)(ty%3x)(sc%3d) nx(%d) %08x %s",
+ combined->u.syment.n_scnum,
+ combined->u.syment.n_flags,
+ combined->u.syment.n_type,
+ combined->u.syment.n_sclass,
+ combined->u.syment.n_numaux,
+ combined->u.syment.n_value,
+ symbol->name
+ );
+ for (aux = 0; aux < combined->u.syment.n_numaux; aux++)
+ {
+ fprintf(file,"\n");
+ switch (combined->u.syment.n_sclass) {
+ case C_FILE:
+ fprintf(file, "File ");
+ break;
+ default:
+ fprintf(file, "AUX tv %x lnno %x size %x",
+ combined[aux+1].u.auxent.x_sym.x_misc.x_lnsz.x_lnno,
+ combined[aux+1].u.auxent.x_sym.x_misc.x_lnsz.x_size);
+ break;
+
+ }
- break;
- }
+ }
+
+
+
+
+ }
+
+ else {
+ bfd_print_symbol_vandf((PTR) file, symbol);
+ fprintf(file, " %-5s %s %s %s",
+ section_name,
+ coffsymbol(symbol)->native ? "n" : "g",
+ coffsymbol(symbol)->lineno ? "l" : " ",
+ symbol->name);
+ }
+
+ }
+
+ }
}
#endif /* NO_COFF_SYMBOLS */
#ifdef I960ROMAGIC
- case bfd_arch_i960:
+ case bfd_arch_i960:
{
unsigned flags;
#endif
#ifdef MC88MAGIC
- case bfd_arch_m88k:
- *magicp = MC88OMAGIC;
- return true;
- break;
+ case bfd_arch_m88k:
+ *magicp = MC88OMAGIC;
+ return true;
+ break;
+#endif
+#ifdef H8300MAGIC
+ case bfd_arch_h8300:
+ *magicp = H8300MAGIC;
+ return true;
+ break;
#endif
-
#ifdef A29K_MAGIC_BIG
- case bfd_arch_a29k:
- if (abfd->xvec->byteorder_big_p)
- *magicp = A29K_MAGIC_BIG;
- else
- *magicp = A29K_MAGIC_LITTLE;
- return true;
- break;
+ case bfd_arch_a29k:
+ if (abfd->xvec->byteorder_big_p)
+ *magicp = A29K_MAGIC_BIG;
+ else
+ *magicp = A29K_MAGIC_LITTLE;
+ return true;
+ break;
#endif
#ifdef U802TOCMAGIC
if (cache_ptr->line_number == 0) {
coff_symbol_type *sym =
(coff_symbol_type *) (dst.l_addr.l_symndx
- + obj_symbol_slew(abfd)
+ obj_raw_syments(abfd))->u.syment._n._n_n._n_zeroes;
cache_ptr->u.sym = (asymbol *) sym;
sym->lineno = cache_ptr;
/* This nasty code looks at the symbol to decide whether or
not it is descibes a constructor/destructor entry point. It
is structured this way to (hopefully) speed non matches */
-
- if (symbase->symbol.name[9] == '$')
+#if 0
+ if (0 && symbase->symbol.name[9] == '$')
{
bfd_constructor_entry(abfd,
(asymbol **)location,
symbase->symbol.name[10] == 'I' ?
"CTOR" : "DTOR");
}
-
+#endif
*(location++) = symbase++;
counter++;
}
@end itemize
*/
+#ifndef CALC_ADDEND
+#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
+ if (ptr && ptr->the_bfd == abfd \
+ && ptr->section != (asection *) NULL \
+ && ((ptr->flags & BSF_OLD_COMMON)== 0)) \
+ { \
+ cache_ptr->addend = -(ptr->section->vma + ptr->value); \
+ } \
+ else { \
+ cache_ptr->addend = 0; \
+ }
+#endif
+
static boolean
DEFUN(coff_slurp_reloc_table,(abfd, asect, symbols),
bfd *abfd AND
sec_ptr asect AND
asymbol **symbols)
{
- RELOC *native_relocs;
- arelent *reloc_cache;
- if (asect->relocation)
- return true;
- if (asect->reloc_count == 0)
- return true;
- if (asect->flags & SEC_CONSTRUCTOR)
- return true;
+ RELOC *native_relocs;
+ arelent *reloc_cache;
+ arelent *cache_ptr;
+
+ unsigned int idx;
+
+ if (asect->relocation)
+ return true;
+ if (asect->reloc_count == 0)
+ return true;
+ if (asect->flags & SEC_CONSTRUCTOR)
+ return true;
#ifndef NO_COFF_SYMBOLS
- if (!coff_slurp_symbol_table(abfd))
- return false;
-#endif
- native_relocs =
- (RELOC *) buy_and_read(abfd,
- asect->rel_filepos,
- SEEK_SET,
- (size_t) (RELSZ *
- asect->reloc_count));
- reloc_cache = (arelent *)
- bfd_alloc(abfd, (size_t) (asect->reloc_count * sizeof(arelent)));
-
- if (reloc_cache == NULL) {
- bfd_error = no_memory;
- return false;
- } { /* on error */
- arelent *cache_ptr;
- RELOC *src;
- for (cache_ptr = reloc_cache,
- src = native_relocs;
- cache_ptr < reloc_cache + asect->reloc_count;
- cache_ptr++,
- src++) {
- struct internal_reloc dst;
- asymbol *ptr;
- bfd_swap_reloc_in(abfd, src, &dst);
-
- dst.r_symndx += obj_symbol_slew(abfd);
- cache_ptr->sym_ptr_ptr = symbols + obj_convert(abfd)[dst.r_symndx];
+ if (!coff_slurp_symbol_table(abfd))
+ return false;
+#endif
+ native_relocs =
+ (RELOC *) buy_and_read(abfd,
+ asect->rel_filepos,
+ SEEK_SET,
+ (size_t) (RELSZ *
+ asect->reloc_count));
+ reloc_cache = (arelent *)
+ bfd_alloc(abfd, (size_t) (asect->reloc_count * sizeof(arelent)));
+
+ if (reloc_cache == NULL) {
+ bfd_error = no_memory;
+ return false;
+ }
+
+
+ for (idx = 0; idx < asect->reloc_count; idx ++)
+ {
+ struct internal_reloc dst;
+ asymbol *ptr;
+ struct external_reloc *src;
+
+ cache_ptr = reloc_cache + idx;
+ src = native_relocs + idx;
+
+ bfd_swap_reloc_in(abfd, src, &dst);
+
+
+ if (dst.r_symndx != -1)
+ {
+ cache_ptr->sym_ptr_ptr = symbols + obj_convert(abfd)[dst.r_symndx];
+ }
+ else
+ {
+ cache_ptr->sym_ptr_ptr = 0;
+ ptr = 0;
+ goto puke_logic;
+
+ }
+
#ifdef A29K
- /* AMD has two relocation entries for the 'consth' instruction.
- * The first is R_IHIHALF (part 1), the second is R_IHCONST
- * (part 2). The second entry's r_symndx does not contain
- * an index to a symbol but rather a value (apparently).
- * Also, see the ifdef below for saving the r_symndx value in addend.
- */
- if (dst.r_type == R_IHCONST) {
- ptr = NULL;
- } else
+ /* AMD has two relocation entries for the 'consth' instruction.
+ * The first is R_IHIHALF (part 1), the second is R_IHCONST
+ * (part 2). The second entry's r_symndx does not contain
+ * an index to a symbol but rather a value (apparently).
+ * Also, see the ifdef below for saving the r_symndx value in addend.
+ */
+ if (dst.r_type == R_IHCONST) {
+ ptr = NULL;
+ }
+ else
#endif
ptr = *(cache_ptr->sym_ptr_ptr);
cache_ptr->address = dst.r_vaddr;
Note that symbols which used to be common must be left alone */
- if (ptr && ptr->the_bfd == abfd
- && ptr->section != (asection *) NULL
- && ((ptr->flags & BSF_OLD_COMMON)== 0))
- {
-#ifndef M88
- cache_ptr->addend = -(ptr->section->vma + ptr->value);
-#else
- cache_ptr->addend = 0;
-#endif
-
- }
- else {
- cache_ptr->addend = 0;
- }
+ puke_logic:
+ cache_ptr->address = dst.r_vaddr;
+ /*
+ The symbols definitions that we have read in have been
+ relocated as if their sections started at 0. But the offsets
+ refering to the symbols in the raw data have not been
+ modified, so we have to have a negative addend to compensate.
+
+ Note that symbols which used to be common must be left alone */
- cache_ptr->address -= asect->vma;
+ /* Calculate any reloc addend by looking at the symbol */
+ CALC_ADDEND(abfd, ptr, dst, cache_ptr);
- cache_ptr->section = (asection *) NULL;
+ cache_ptr->address -= asect->vma;
+ cache_ptr->section = (asection *) NULL;
-#ifdef A29K
- if (dst.r_type == R_IHCONST) {
- /* Add in the value which was stored in the symbol index */
- /* See above comment */
- cache_ptr->addend += dst.r_symndx;
- /* Throw away the bogus symbol pointer */
- cache_ptr->sym_ptr_ptr = 0;
- }
- cache_ptr->howto = howto_table + dst.r_type;
-#endif
-#if I386
- cache_ptr->howto = howto_table + dst.r_type;
-#endif
-#if I960
- cache_ptr->howto = howto_table + dst.r_type;
-#endif
-#if M68
- cache_ptr->howto = howto_table + dst.r_type - R_RELBYTE;
-#endif
-#if M88
- if (dst.r_type >= R_PCR16L && dst.r_type <= R_VRT32) {
- cache_ptr->howto = howto_table + dst.r_type - R_PCR16L;
- cache_ptr->addend += dst.r_offset << 16;
- }
- else {
- BFD_ASSERT(0);
- }
-#endif
- }
+ /* Fill in the cache_ptr->howto field from dst.r_type */
+ RTYPE2HOWTO(cache_ptr, dst);
}
- asect->relocation = reloc_cache;
- return true;
+ asect->relocation = reloc_cache;
+ return true;
}
# appropriate for this directory. For more information, check any
# existing configure script.
+configdirs="doc"
srctrigger=libbfd.c
srcname="BFD"
hitachi)
case "${target_cpu}" in
- h8300) bfd_target=h8300-ieee ;;
+ h8300) bfd_target=h8300-coff ;;
*) echo "bad hitachi cpu" ;;
esac
;;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include <sysdep.h>
#include "bfd.h"
+#include "sysdep.h"
#include "libbfd.h"
#define DEFINE_TABLE
/* Find the exact opcode/arg combo */
while (*p) {
- op_enum_type *nib;
+ op_type *nib;
unsigned int len = 0;
q = *p++;
nib =q->data.nib;
while (*nib != E) {
- op_enum_type looking_for = *nib;
+ op_type looking_for = *nib;
int thisnib = data[len>>1] ;
thisnib = (len & 1) ? (thisnib & 0xf) : ((thisnib >> 4) & 0xf);
if ((int)looking_for & (int)B31) {
if (((int)thisnib & 0x8) ==0) goto fail;
- looking_for = (op_enum_type)((int)looking_for & ~(int)B31);
+ looking_for = (op_type)((int)looking_for & ~(int)B31);
}
if ((int)looking_for & (int)B30) {
if (((int)thisnib & 0x8) !=0) goto fail;
- looking_for = (op_enum_type)((int)looking_for & ~(int)B30);
+ looking_for = (op_type)((int)looking_for & ~(int)B30);
}
switch (looking_for) {
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
rdisp = thisnib;
break;
case KBIT:
- abs = thisnib == 0x80 ? 2:1;
+ abs = thisnib == 0x8 ? 2:1;
break;
case IMM8:
case ABS8SRC:
;
}
- fprintf(stream, "%02x %02x .word\tH'%x,H'%x\n",
+ fprintf(stream, "%02x %02x .word\tH'%x,H'%x",
data[0], data[1],
data[0], data[1]);
return 2;
fprintf(stream, "%s\t",q->name);
/* Now print out the args */
{
- op_enum_type *args = q->args.nib;
+ op_type *args = q->args.nib;
int hadone = 0;
while (*args != E) {
if (hadone)
case IMM16:
case IMM8:
case IMM3:
- fprintf(stream, "#H'%x", (unsigned)abs); break;
+ fprintf(stream, "#0x%x", (unsigned)abs); break;
case RD8:
fprintf(stream, "%s", regnames[rd]); break;
case RS8:
case ABS16SRC:
case ABS16DST:
case ABS8DST:
- fprintf(stream, "@H'%x", (unsigned)abs); break;
+ fprintf(stream, "@0x%x", (unsigned)abs); break;
case DISP8:
fprintf(stream, ".%s%d (%x)",(char)abs>0 ? "+" :"", (char)abs,
addr + (char)abs);
break;
case DISPSRC:
case DISPDST:
- fprintf(stream, "@(%d,r%d)", abs, rdisp & 0x7); break;
+ fprintf(stream, "@(0x%x,r%d)", abs, rdisp & 0x7); break;
case CCR:
fprintf(stream, "ccr"); break;
case KBIT:
-unsigned int DEFUN( print_insn_h8300,(addr, data, file),
+unsigned int DEFUN(print_insn_h8300,(addr, data, file),
bfd_vma addr AND
-CONST bfd_byte *data AND
+CONST char *data AND
PTR file)
{
static boolean init;
if (!init) {
bfd_h8_disassemble_init();
init= 1;
-
}
- return bfd_h8_disassemble(addr, data, file);
+
+ return bfd_h8_disassemble(addr, (bfd_byte *)data, file);
}
/*
Relocations for the H8
*/
-static bfd_reloc_status_enum_type
+static bfd_reloc_status_type
DEFUN(howto16_callback,(abfd, reloc_entry, symbol_in, data, ignore_input_section),
bfd *abfd AND
arelent *reloc_entry AND
}
-static bfd_reloc_status_enum_type
+static bfd_reloc_status_type
DEFUN(howto8_callback,(abfd, reloc_entry, symbol_in, data, ignore_input_section),
bfd *abfd AND
arelent *reloc_entry AND
}
-static bfd_reloc_status_enum_type
+static bfd_reloc_status_type
DEFUN(howto8_FFnn_callback,(abfd, reloc_entry, symbol_in, data, ignore_input_section),
bfd *abfd AND
arelent *reloc_entry AND
return bfd_reloc_ok;
}
-static bfd_reloc_status_enum_type
+static bfd_reloc_status_type
DEFUN(howto8_pcrel_callback,(abfd, reloc_entry, symbol_in, data, ignore_input_section),
bfd *abfd AND
arelent *reloc_entry AND
static CONST struct reloc_howto_struct *
DEFUN(local_bfd_reloc_type_lookup,(arch, code),
- bfd_arch_info_struct_type *arch AND
- bfd_reloc_code_enum_type code)
+ CONST struct bfd_arch_info *arch AND
+ bfd_reloc_code_type code)
{
switch (code) {
case BFD_RELOC_16:
static boolean
DEFUN(h8300_scan,(info, string),
-CONST struct bfd_arch_info_struct *info AND
+CONST struct bfd_arch_info *info AND
CONST char *string)
{
if (strcmp(string,"h8300") == 0) return true;
if (strcmp(string,"H8/300") == 0) return true;
return false;
}
-static bfd_arch_info_struct_type arch_info_struct =
+
+static bfd_arch_info_type arch_info_struct =
{
16, /* 16 bits in a word */
16, /* 16 bits in an address */
0,
};
-
-
-
-void DEFUN_VOID(bfd_h8300_arch)
+void
+DEFUN_VOID(bfd_h8300_arch)
{
bfd_arch_linkin(&arch_info_struct);
}
-
-
-
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* $Id$ */
/* Object file tdata; access macros */
-#define obj_icof(bfd) ((struct icofdata *) ((bfd)->tdata))
-#define coff_data(bfd) ((struct icofdata *) ((bfd)->tdata))
-#define exec_hdr(bfd) (obj_icof(bfd)->hdr)
-#define obj_symbols(bfd) (obj_icof(bfd)->symbols)
-#define obj_sym_filepos(bfd) (obj_icof(bfd)->sym_filepos)
-
-#define obj_relocbase(bfd) (obj_icof(bfd)->relocbase)
-#define obj_raw_syments(bfd) (obj_icof(bfd)->raw_syments)
-#define obj_convert(bfd) (obj_icof(bfd)->conversion_table)
-#if CFILE_STUFF
-#define obj_symbol_slew(bfd) (obj_icof(bfd)->symbol_index_slew)
-#else
-#define obj_symbol_slew(bfd) 0
-#endif
-#define obj_string_table(bfd) (obj_icof(bfd)->string_table)
-
-#if 0
-typedef struct coff_ptr_struct
-{
- unsigned int offset;
- char fix_tag;
- char fix_end;
- union {
- union internal_auxent auxent;
- struct internal_syment syment;
- } u;
-} combined_entry_type;
+#define coff_data(bfd) ((coff_data_type *) ((bfd)->tdata))
+#define exec_hdr(bfd) (coff_data(bfd)->hdr)
+#define obj_symbols(bfd) (coff_data(bfd)->symbols)
+#define obj_sym_filepos(bfd) (coff_data(bfd)->sym_filepos)
+#define obj_relocbase(bfd) (coff_data(bfd)->relocbase)
+#define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments)
+#define obj_convert(bfd) (coff_data(bfd)->conversion_table)
-typedef struct
-{
- asymbol symbol;
- combined_entry_type *native;
- struct lineno_cache_entry *lineno;
-} coff_symbol_type;
-#endif
-typedef struct icofdata
-{
+/* `Tdata' information kept for COFF files. */
-struct coff_symbol_struct *symbols; /* symtab for input bfd */
+typedef struct coff_tdata
+{
+ struct coff_symbol_struct *symbols; /* symtab for input bfd */
unsigned int *conversion_table;
file_ptr sym_filepos;
long symbol_index_slew; /* used during read to mark whether a
C_FILE symbol as been added. */
-struct coff_ptr_struct *raw_syments;
+ struct coff_ptr_struct *raw_syments;
struct lineno *raw_linenos;
unsigned int raw_syment_count;
- char *string_table;
unsigned short flags;
+
/* These are only valid once writing has begun */
long int relocbase;
+
+ /* These members communicate important constants about the symbol table
+ to GDB's symbol-reading code. These `constants' unfortunately vary
+ from coff implementation to implementation... */
+ unsigned local_n_btmask;
+ unsigned local_n_btshft;
+ unsigned local_n_tmask;
+ unsigned local_n_tshift;
+ unsigned local_symesz;
+ unsigned local_auxesz;
+ unsigned local_linesz;
} coff_data_type;
/* We take the address of the first element of a asymbol to ensure that the
/*THE FOLLOWING IS EXTRACTED FROM THE SOURCE*/
-/* FROM coffcode.h*/
-/* ------------------------------START FROM coffcode.h
+/*:coffcode.h*/
+/*
The hidden information for an asymbol is:
*/
} coff_symbol_type;
/*
-
- --------------------------------END FROM coffcode.h*/
-
+*/
extern bfd_target a29kcoff_big_vec;
extern bfd_target trad_core_vec;
extern bfd_target rs6000coff_vec;
+extern bfd_target h8300coff_vec;
#ifdef DEFAULT_VECTOR
extern bfd_target DEFAULT_VECTOR;
#define I386AOUT_VEC i386aout_vec
#define A29KCOFF_BIG_VEC a29kcoff_big_vec
#define RS6000COFF_VEC rs6000coff_vec
+#define H8300COFF_VEC h8300coff_vec
#endif
bfd_target *target_vector[] = {
#endif
#endif
+#ifdef H300COFF_VEC
+ &h8300coff_vec,
+#endif
#ifdef M88KBCS_VEC
&M88KBCS_VEC,
#endif