* ecoff.c: New file for generic ECOFF functions.

* ecoffswap.h: New file for ECOFF swapping functions which differ
	only slightly for different targets.
	* libecoff.h: Added prototypes for ecoff.c functions.
	(ecoff_backend_data): New structure.
	(ecoff_tdata): Added backend_data field.  Changed external data
	pointers to be PTR rather than to a particular struct.
	(ecoff_symbol_struct): Moved in from coff-mips.c.
	* coff-alpha.c, coff-mips.c: Moved common functions into ecoff.c.
	Added ECOFF backend structures.  Include ecoffswap.h.
	* coff-msym.c: Removed; superseded by ecoffswap.h.
	* bfd.c: Include coff/internal.h.
	* Makefile.in (BFD_LIBS): Removed coff-mips.o and coff-msym.o.
	Added ecoff.o.
	(BFD64_BACKENDS): Added coff-alpha.o.
	(CFILES): Removed coff-msym.c.  Added ecoff.c.
	(bfd.o): Added dependency on $(INCDIR)/coff/sym.h.
	(coff-mips.o): Added dependency on ecoffswap.h and coff/ecoff.h.
	(ecoff.o, coff-alpha.o): New targets.
	(coff-msym.o): Removed target.
This commit is contained in:
Ian Lance Taylor 1993-08-03 20:22:47 +00:00
parent 511e0322b9
commit dae31cf51b
9 changed files with 4791 additions and 8865 deletions

View File

@ -58,7 +58,6 @@ coff-i960.c
coff-m68k.c
coff-m88k.c
coff-mips.c
coff-msym.c
coff-rs6000.c
coff-sh.c
coff-u68k.c
@ -91,6 +90,8 @@ cpu-z8k.c
ctor.c
demo64.c
doc
ecoff.c
ecoffswap.h
elf.c
elf32-gen.c
elf32-hppa.c

View File

@ -1,3 +1,26 @@
Tue Aug 3 11:06:28 1993 Ian Lance Taylor (ian@cygnus.com)
* ecoff.c: New file for generic ECOFF functions.
* ecoffswap.h: New file for ECOFF swapping functions which differ
only slightly for different targets.
* libecoff.h: Added prototypes for ecoff.c functions.
(ecoff_backend_data): New structure.
(ecoff_tdata): Added backend_data field. Changed external data
pointers to be PTR rather than to a particular struct.
(ecoff_symbol_struct): Moved in from coff-mips.c.
* coff-alpha.c, coff-mips.c: Moved common functions into ecoff.c.
Added ECOFF backend structures. Include ecoffswap.h.
* coff-msym.c: Removed; superseded by ecoffswap.h.
* bfd.c: Include coff/internal.h.
* Makefile.in (BFD_LIBS): Removed coff-mips.o and coff-msym.o.
Added ecoff.o.
(BFD64_BACKENDS): Added coff-alpha.o.
(CFILES): Removed coff-msym.c. Added ecoff.c.
(bfd.o): Added dependency on $(INCDIR)/coff/sym.h.
(coff-mips.o): Added dependency on ecoffswap.h and coff/ecoff.h.
(ecoff.o, coff-alpha.o): New targets.
(coff-msym.o): Removed target.
Mon Aug 2 23:33:38 1993 John Gilmore (gnu@cygnus.com)
* elf32-hppa.h, hosts/*: Remove (one more time) all occurrances

View File

@ -69,13 +69,9 @@ TARGETLIB = libbfd.a
# bfd.h goes here, for now
BFD_H = bfd.h
# Some of these files should be in BFD*_BACKENDS below, but gdb
# won't link without them. So, in order for some of the minimal-bfd
# hacks to work, they're also included here for now.
# coff-mips.o coff-msym.o
BFD_LIBS = libbfd.o opncls.o bfd.o archive.o targets.o cache.o \
archures.o core.o section.o format.o syms.o reloc.o init.o \
ctor.o seclet.o coffgen.o reloc16.o coff-mips.o coff-msym.o
ctor.o seclet.o coffgen.o ecoff.o reloc16.o
ALL_MACHINES = cpu-h8300.o cpu-i960.o cpu-sparc.o cpu-m68k.o cpu-m88k.o \
cpu-vax.o cpu-mips.o cpu-a29k.o cpu-i386.o cpu-rs6000.o cpu-hppa.o \
@ -86,21 +82,21 @@ BFD32_BACKENDS = \
elf32.o elf32-sparc.o elf32-i386.o elf32-i860.o elf32-m68k.o \
elf32-hppa.o elf32-mips.o elf32-m88k.o elf32-gen.o \
nlm.o \
nlm32.o nlm32-gen.o \
nlm32.o nlm32-gen.o nlm32-i386.o \
aout32.o sunos.o newsos3.o mipsbsd.o aout-adobe.o \
i386aout.o i386bsd.o i386linux.o i386lynx.o \
hp300hpux.o bout.o \
coff-i960.o coff-a29k.o coff-m68k.o coff-u68k.o \
coff-i386.o coff-m88k.o \
coff-rs6000.o coff-h8300.o coff-h8500.o coff-z8k.o coff-we32k.o \
coff-mips.o coff-msym.o coff-alpha.o coff-sh.o \
coff-mips.o coff-sh.o \
hppa.o oasys.o ieee.o srec.o \
stab-syms.o
BFD64_BACKENDS = \
elf64.o elf64-gen.o \
nlm64.o nlm64-gen.o \
aout64.o demo64.o
aout64.o demo64.o coff-alpha.o
OPTIONAL_BACKENDS = trad-core.o sco-core.o aix386-core.o hpux-core.o
@ -139,8 +135,8 @@ FLAGS_TO_PASS = \
CFILES = libbfd.c opncls.c bfd.c archive.c targets.c cache.c \
archures.c coff-i386.c aout64.c aout32.c sunos.c demo64.c \
coff-i960.c srec.c tekhex.c oasys.c ieee.c \
coff-m68k.c coff-u68k.c \
coff-a29k.c coff-rs6000.c coff-msym.c coffgen.c format.c \
ecoff.c coff-m68k.c coff-u68k.c \
coff-a29k.c coff-rs6000.c coffgen.c format.c \
section.c core.c syms.c stab-syms.c reloc.c init.c ctor.c \
seclet.c coff-m88k.c coff-mips.c coff-sh.c trad-core.c newsos3.c \
i386aout.c i386linux.c bout.c aout-adobe.c coff-we32k.c \
@ -151,7 +147,7 @@ CFILES = libbfd.c opncls.c bfd.c archive.c targets.c cache.c \
elf32.c elf32-sparc.c elf32-i386.c elf32-i860.c elf32-m68k.c \
elf32-hppa.c elf32-m88k.c elf32-mips.c elf32-gen.c \
elf64.c elf64-gen.c \
nlm32.c nlm32-gen.c nlm64.c nlm64-gen.c \
nlm32.c nlm32-gen.c nlm32-i386.c nlm64.c nlm64-gen.c \
coff-alpha.c cpu-alpha.c \
hp300hpux.c i386lynx.c
@ -184,7 +180,7 @@ ofiles : Makefile
f=""; \
for i in $(OFILES) ; do \
case " $$f " in \
"* $$i *") ;; \
*" $$i "*) ;; \
*) f="$$f $$i" ;; \
esac ; \
done ; \
@ -321,8 +317,8 @@ install:
@$(MAKE) subdir_do DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
$(SHELL) ./config.status
Makefile: Makefile.in configure.in $(host_makefile_frag) $(target_makefile_frag)
$(SHELL) config.status
dep: $(CFILES)
mkdep $(CFLAGS) $?
@ -377,7 +373,7 @@ bfd.ps:
libbfd.o : libbfd.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h
opncls.o : opncls.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h
bfd.o : bfd.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h \
$(INCDIR)/coff/sym.h libecoff.h
$(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h libecoff.h
archive.o : archive.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h \
$(INCDIR)/aout/ar.h $(INCDIR)/aout/ranlib.h
targets.o : targets.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h
@ -422,9 +418,17 @@ coff-m68k.o: coff-m68k.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h \
coff-m88k.o: coff-m88k.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h \
$(INCDIR)/coff/m88k.h $(INCDIR)/coff/internal.h libcoff.h coffcode.h \
coffswap.h seclet.h
ecoff.o: ecoff.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h \
$(INCDIR)/coff/internal.h libecoff.h libcoff.h seclet.h \
$(INCDIR)/aout/ar.h $(INCDIR)/aout/ranlib.h libaout.h \
$(INCDIR)/aout/aout64.h $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/sym.h \
$(INCDIR)/coff/symconst.h
coff-mips.o: coff-mips.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h \
$(INCDIR)/coff/mips.h $(INCDIR)/coff/internal.h libcoff.h coffcode.h \
coffswap.h seclet.h libecoff.h
coffswap.h seclet.h libecoff.h ecoffswap.h $(INCDIR)/coff/ecoff.h
coff-alpha.o: coff-alpha.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h \
$(INCDIR)/coff/alpha.h $(INCDIR)/coff/internal.h libcoff.h coffcode.h \
coffswap.h seclet.h libecoff.h ecoffswap.h $(INCDIR)/coff/ecoff.h
coff-rs6000.o: coff-rs6000.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h \
$(INCDIR)/coff/rs6000.h $(INCDIR)/coff/internal.h libcoff.h coffcode.h \
coffswap.h seclet.h
@ -458,9 +462,6 @@ aix386-core.o : aix386-core.c $(BFD_H) libbfd.h libcoff.h \
$(INCDIR)/obstack.h $(INCDIR)/coff/i386.h $(INCDIR)/coff/internal.h
hpux-core.o : hpux-core.c $(BFD_H) libbfd.h libhppa.h
coff-msym.o: coff-msym.c $(BFD_H) $(INCDIR)/coff/ecoff-ext.h \
$(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h
newsos3.o : newsos3.c $(BFD_H) $(INCDIR)/obstack.h libbfd.h \
$(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
$(INCDIR)/aout/ar.h libaout.h
@ -507,11 +508,13 @@ nlm.o : nlm.c libnlm.h libbfd.h $(BFD_H) $(INCDIR)/obstack.h
nlm32.o : nlm32.c nlmcode.h libnlm.h libbfd.h $(BFD_H) \
$(INCDIR)/obstack.h
nlm32-gen.o : nlm32-gen.c libnlm.h libbfd.h \
$(BFD_H) $(INCDIR)/obstack.h
$(BFD_H) $(INCDIR)/obstack.h nlm-target.h
nlm32-i386.o : nlm32-i386.c libnlm.h libbfd.h \
$(BFD_H) $(INCDIR)/obstack.h nlm-target.h
nlm64.o : nlm64.c nlmcode.h libnlm.h libbfd.h $(BFD_H) \
$(INCDIR)/obstack.h
nlm64-gen.o : nlm64-gen.c libnlm.h libbfd.h \
$(BFD_H) $(INCDIR)/obstack.h
$(BFD_H) $(INCDIR)/obstack.h nlm-target.h
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY

View File

@ -177,6 +177,7 @@ CODE_FRAGMENT
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "coff/internal.h"
#include "coff/sym.h"
#include "libecoff.h"
@ -228,10 +229,11 @@ DEFUN(bfd_nonrepresentable_section,(abfd, name),
CONST bfd * CONST abfd AND
CONST char * CONST name)
{
printf("bfd error writing file %s, format %s can't represent section %s\n",
abfd->filename,
abfd->xvec->name,
name);
fprintf(stderr,
"bfd error writing file %s, format %s can't represent section %s\n",
abfd->filename,
abfd->xvec->name,
name);
exit(1);
}
@ -243,8 +245,8 @@ DEFUN(bfd_undefined_symbol,(relent, seclet),
CONST struct bfd_seclet *seclet)
{
asymbol *symbol = *(relent->sym_ptr_ptr);
printf("bfd error relocating, symbol %s is undefined\n",
symbol->name);
fprintf(stderr, "bfd error relocating, symbol %s is undefined\n",
symbol->name);
exit(1);
}
/*ARGSUSED*/
@ -254,7 +256,7 @@ DEFUN(bfd_reloc_value_truncated,(relent, seclet),
CONST arelent *relent AND
struct bfd_seclet *seclet)
{
printf("bfd error relocating, value truncated\n");
fprintf(stderr, "bfd error relocating, value truncated\n");
exit(1);
}
/*ARGSUSED*/
@ -264,7 +266,7 @@ DEFUN(bfd_reloc_is_dangerous,(relent, seclet),
CONST arelent *relent AND
CONST struct bfd_seclet *seclet)
{
printf("bfd error relocating, dangerous\n");
fprintf(stderr, "bfd error relocating, dangerous\n");
exit(1);
}
@ -298,7 +300,7 @@ void
DEFUN (bfd_default_error_trap, (error_tag),
bfd_ec error_tag)
{
printf("bfd assert fail (%s)\n", bfd_errmsg(error_tag));
fprintf(stderr, "bfd assert fail (%s)\n", bfd_errmsg(error_tag));
}
void (*bfd_error_trap) PARAMS ((bfd_ec)) = bfd_default_error_trap;
@ -465,7 +467,7 @@ bfd_assert(file, line)
char *file;
int line;
{
printf("bfd assertion fail %s:%d\n",file,line);
fprintf(stderr, "bfd assertion fail %s:%d\n",file,line);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,810 +0,0 @@
/* BFD support to byte-swap a symbol table in MIPS (Third-Eye, `ecoff') format.
Copyright 1992, 1993 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
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 2 of the License, or
(at your option) any later version.
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 this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* The routines in this file convert the external representation of
ECOFF symbol tables to the internal (usual struct) representation.
On a machine with the same byte-order and the same basic type
sizes and alignments as a MIPS machine, this is a no-op.
If the symbol TEST is defined when this file is compiled, a comparison
is made to ensure that, in fact, the output is bit-for-bit the same as
the input. Of course, this symbol should only be defined when
deliberately testing the code on a machine with the proper byte sex
and such. */
#include "bfd.h"
#include "coff/sym.h" /* MIPS symbols */
#include "coff/symconst.h" /* MIPS symbols */
#include "coff/ecoff-ext.h" /* ECOFF external struct defns */
/* Swap in the symbolic header. */
void
ecoff_swap_hdr_in (abfd, ext_copy, intern)
bfd *abfd;
struct hdr_ext *ext_copy;
HDRR *intern;
{
struct hdr_ext ext[1];
*ext = *ext_copy;
intern->magic = bfd_h_get_16 (abfd, (bfd_byte *)ext->h_magic);
intern->vstamp = bfd_h_get_16 (abfd, (bfd_byte *)ext->h_vstamp);
intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax);
intern->cbLine = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbLine);
intern->cbLineOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbLineOffset);
intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax);
intern->cbDnOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbDnOffset);
intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax);
intern->cbPdOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbPdOffset);
intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax);
intern->cbSymOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbSymOffset);
intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax);
intern->cbOptOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbOptOffset);
intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax);
intern->cbAuxOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbAuxOffset);
intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax);
intern->cbSsOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbSsOffset);
intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax);
intern->cbSsExtOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbSsExtOffset);
intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax);
intern->cbFdOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbFdOffset);
intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd);
intern->cbRfdOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbRfdOffset);
intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax);
intern->cbExtOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_cbExtOffset);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap out the symbolic header. */
void
ecoff_swap_hdr_out (abfd, intern_copy, ext)
bfd *abfd;
HDRR *intern_copy;
struct hdr_ext *ext;
{
HDRR intern[1];
*intern = *intern_copy;
bfd_h_put_16 (abfd, intern->magic, (bfd_byte *)ext->h_magic);
bfd_h_put_16 (abfd, intern->vstamp, (bfd_byte *)ext->h_vstamp);
bfd_h_put_32 (abfd, intern->ilineMax, (bfd_byte *)ext->h_ilineMax);
bfd_h_put_32 (abfd, intern->cbLine, (bfd_byte *)ext->h_cbLine);
bfd_h_put_32 (abfd, intern->cbLineOffset, (bfd_byte *)ext->h_cbLineOffset);
bfd_h_put_32 (abfd, intern->idnMax, (bfd_byte *)ext->h_idnMax);
bfd_h_put_32 (abfd, intern->cbDnOffset, (bfd_byte *)ext->h_cbDnOffset);
bfd_h_put_32 (abfd, intern->ipdMax, (bfd_byte *)ext->h_ipdMax);
bfd_h_put_32 (abfd, intern->cbPdOffset, (bfd_byte *)ext->h_cbPdOffset);
bfd_h_put_32 (abfd, intern->isymMax, (bfd_byte *)ext->h_isymMax);
bfd_h_put_32 (abfd, intern->cbSymOffset, (bfd_byte *)ext->h_cbSymOffset);
bfd_h_put_32 (abfd, intern->ioptMax, (bfd_byte *)ext->h_ioptMax);
bfd_h_put_32 (abfd, intern->cbOptOffset, (bfd_byte *)ext->h_cbOptOffset);
bfd_h_put_32 (abfd, intern->iauxMax, (bfd_byte *)ext->h_iauxMax);
bfd_h_put_32 (abfd, intern->cbAuxOffset, (bfd_byte *)ext->h_cbAuxOffset);
bfd_h_put_32 (abfd, intern->issMax, (bfd_byte *)ext->h_issMax);
bfd_h_put_32 (abfd, intern->cbSsOffset, (bfd_byte *)ext->h_cbSsOffset);
bfd_h_put_32 (abfd, intern->issExtMax, (bfd_byte *)ext->h_issExtMax);
bfd_h_put_32 (abfd, intern->cbSsExtOffset, (bfd_byte *)ext->h_cbSsExtOffset);
bfd_h_put_32 (abfd, intern->ifdMax, (bfd_byte *)ext->h_ifdMax);
bfd_h_put_32 (abfd, intern->cbFdOffset, (bfd_byte *)ext->h_cbFdOffset);
bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->h_crfd);
bfd_h_put_32 (abfd, intern->cbRfdOffset, (bfd_byte *)ext->h_cbRfdOffset);
bfd_h_put_32 (abfd, intern->iextMax, (bfd_byte *)ext->h_iextMax);
bfd_h_put_32 (abfd, intern->cbExtOffset, (bfd_byte *)ext->h_cbExtOffset);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap in the file descriptor record. */
void
ecoff_swap_fdr_in (abfd, ext_copy, intern)
bfd *abfd;
struct fdr_ext *ext_copy;
FDR *intern;
{
struct fdr_ext ext[1];
*ext = *ext_copy; /* Make it reasonable to do in-place. */
intern->adr = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_adr);
intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss);
intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase);
intern->cbSs = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cbSs);
intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase);
intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym);
intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase);
intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline);
intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase);
intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt);
intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst);
intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd);
intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase);
intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux);
intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase);
intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd);
/* now the fun stuff... */
if (abfd->xvec->header_byteorder_big_p != false) {
intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
>> FDR_BITS1_LANG_SH_BIG;
intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
>> FDR_BITS2_GLEVEL_SH_BIG;
} else {
intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
>> FDR_BITS1_LANG_SH_LITTLE;
intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
>> FDR_BITS2_GLEVEL_SH_LITTLE;
}
intern->reserved = 0;
intern->cbLineOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cbLineOffset);
intern->cbLine = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cbLine);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap out the file descriptor record. */
void
ecoff_swap_fdr_out (abfd, intern_copy, ext)
bfd *abfd;
FDR *intern_copy;
struct fdr_ext *ext;
{
FDR intern[1];
*intern = *intern_copy; /* Make it reasonable to do in-place. */
bfd_h_put_32 (abfd, intern->adr, (bfd_byte *)ext->f_adr);
bfd_h_put_32 (abfd, intern->rss, (bfd_byte *)ext->f_rss);
bfd_h_put_32 (abfd, intern->issBase, (bfd_byte *)ext->f_issBase);
bfd_h_put_32 (abfd, intern->cbSs, (bfd_byte *)ext->f_cbSs);
bfd_h_put_32 (abfd, intern->isymBase, (bfd_byte *)ext->f_isymBase);
bfd_h_put_32 (abfd, intern->csym, (bfd_byte *)ext->f_csym);
bfd_h_put_32 (abfd, intern->ilineBase, (bfd_byte *)ext->f_ilineBase);
bfd_h_put_32 (abfd, intern->cline, (bfd_byte *)ext->f_cline);
bfd_h_put_32 (abfd, intern->ioptBase, (bfd_byte *)ext->f_ioptBase);
bfd_h_put_32 (abfd, intern->copt, (bfd_byte *)ext->f_copt);
bfd_h_put_16 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
bfd_h_put_16 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
bfd_h_put_32 (abfd, intern->iauxBase, (bfd_byte *)ext->f_iauxBase);
bfd_h_put_32 (abfd, intern->caux, (bfd_byte *)ext->f_caux);
bfd_h_put_32 (abfd, intern->rfdBase, (bfd_byte *)ext->f_rfdBase);
bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->f_crfd);
/* now the fun stuff... */
if (abfd->xvec->header_byteorder_big_p != false) {
ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG)
& FDR_BITS1_LANG_BIG)
| (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0)
| (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0)
| (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0));
ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG)
& FDR_BITS2_GLEVEL_BIG);
ext->f_bits2[1] = 0;
ext->f_bits2[2] = 0;
} else {
ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE)
& FDR_BITS1_LANG_LITTLE)
| (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0)
| (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0)
| (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0));
ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE)
& FDR_BITS2_GLEVEL_LITTLE);
ext->f_bits2[1] = 0;
ext->f_bits2[2] = 0;
}
bfd_h_put_32 (abfd, intern->cbLineOffset, (bfd_byte *)ext->f_cbLineOffset);
bfd_h_put_32 (abfd, intern->cbLine, (bfd_byte *)ext->f_cbLine);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap in the procedure descriptor record. */
void
ecoff_swap_pdr_in (abfd, ext_copy, intern)
bfd *abfd;
struct pdr_ext *ext_copy;
PDR *intern;
{
struct pdr_ext ext[1];
*ext = *ext_copy; /* Make it reasonable to do in-place. */
intern->adr = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_adr);
intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
intern->regoffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regoffset);
intern->iopt = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iopt);
intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
intern->fregoffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregoffset);
intern->frameoffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_frameoffset);
intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
intern->cbLineOffset = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_cbLineOffset);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap out the procedure descriptor record. */
void
ecoff_swap_pdr_out (abfd, intern_copy, ext)
bfd *abfd;
PDR *intern_copy;
struct pdr_ext *ext;
{
PDR intern[1];
*intern = *intern_copy; /* Make it reasonable to do in-place. */
bfd_h_put_32 (abfd, intern->adr, (bfd_byte *)ext->p_adr);
bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
bfd_h_put_32 (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap in a symbol record. */
void
ecoff_swap_sym_in (abfd, ext_copy, intern)
bfd *abfd;
struct sym_ext *ext_copy;
SYMR *intern;
{
struct sym_ext ext[1];
*ext = *ext_copy; /* Make it reasonable to do in-place. */
intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss);
intern->value = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_value);
/* now the fun stuff... */
if (abfd->xvec->header_byteorder_big_p != false) {
intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_BIG)
>> SYM_BITS1_ST_SH_BIG;
intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG)
<< SYM_BITS1_SC_SH_LEFT_BIG)
| ((ext->s_bits2[0] & SYM_BITS2_SC_BIG)
>> SYM_BITS2_SC_SH_BIG);
intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG);
intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG)
<< SYM_BITS2_INDEX_SH_LEFT_BIG)
| (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG)
| (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG);
} else {
intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE)
>> SYM_BITS1_ST_SH_LITTLE;
intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE)
>> SYM_BITS1_SC_SH_LITTLE)
| ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE)
<< SYM_BITS2_SC_SH_LEFT_LITTLE);
intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE);
intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE)
>> SYM_BITS2_INDEX_SH_LITTLE)
| (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE)
| (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_LITTLE);
}
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap out a symbol record. */
void
ecoff_swap_sym_out (abfd, intern_copy, ext)
bfd *abfd;
SYMR *intern_copy;
struct sym_ext *ext;
{
SYMR intern[1];
*intern = *intern_copy; /* Make it reasonable to do in-place. */
bfd_h_put_32 (abfd, intern->iss, (bfd_byte *)ext->s_iss);
bfd_h_put_32 (abfd, intern->value, (bfd_byte *)ext->s_value);
/* now the fun stuff... */
if (abfd->xvec->header_byteorder_big_p != false) {
ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_BIG)
& SYM_BITS1_ST_BIG)
| ((intern->sc >> SYM_BITS1_SC_SH_LEFT_BIG)
& SYM_BITS1_SC_BIG));
ext->s_bits2[0] = (((intern->sc << SYM_BITS2_SC_SH_BIG)
& SYM_BITS2_SC_BIG)
| (intern->reserved ? SYM_BITS2_RESERVED_BIG : 0)
| ((intern->index >> SYM_BITS2_INDEX_SH_LEFT_BIG)
& SYM_BITS2_INDEX_BIG));
ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_BIG) & 0xff;
ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_BIG) & 0xff;
} else {
ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_LITTLE)
& SYM_BITS1_ST_LITTLE)
| ((intern->sc << SYM_BITS1_SC_SH_LITTLE)
& SYM_BITS1_SC_LITTLE));
ext->s_bits2[0] = (((intern->sc >> SYM_BITS2_SC_SH_LEFT_LITTLE)
& SYM_BITS2_SC_LITTLE)
| (intern->reserved ? SYM_BITS2_RESERVED_LITTLE : 0)
| ((intern->index << SYM_BITS2_INDEX_SH_LITTLE)
& SYM_BITS2_INDEX_LITTLE));
ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_LITTLE) & 0xff;
ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_LITTLE) & 0xff;
}
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap in an external symbol record. */
void
ecoff_swap_ext_in (abfd, ext_copy, intern)
bfd *abfd;
struct ext_ext *ext_copy;
EXTR *intern;
{
struct ext_ext ext[1];
*ext = *ext_copy; /* Make it reasonable to do in-place. */
/* now the fun stuff... */
if (abfd->xvec->header_byteorder_big_p != false) {
intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG);
intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG);
intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_BIG);
} else {
intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE);
intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE);
intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_LITTLE);
}
intern->reserved = 0;
intern->ifd = bfd_h_get_16 (abfd, (bfd_byte *)ext->es_ifd);
ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap out an external symbol record. */
void
ecoff_swap_ext_out (abfd, intern_copy, ext)
bfd *abfd;
EXTR *intern_copy;
struct ext_ext *ext;
{
EXTR intern[1];
*intern = *intern_copy; /* Make it reasonable to do in-place. */
/* now the fun stuff... */
if (abfd->xvec->header_byteorder_big_p != false) {
ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_BIG : 0)
| (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_BIG : 0)
| (intern->weakext ? EXT_BITS1_WEAKEXT_BIG : 0));
ext->es_bits2[0] = 0;
} else {
ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_LITTLE : 0)
| (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_LITTLE : 0)
| (intern->weakext ? EXT_BITS1_WEAKEXT_LITTLE : 0));
ext->es_bits2[0] = 0;
}
bfd_h_put_16 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap in a type information record.
BIGEND says whether AUX symbols are big-endian or little-endian; this
info comes from the file header record (fh-fBigendian). */
void
ecoff_swap_tir_in (bigend, ext_copy, intern)
int bigend;
struct tir_ext *ext_copy;
TIR *intern;
{
struct tir_ext ext[1];
*ext = *ext_copy; /* Make it reasonable to do in-place. */
/* now the fun stuff... */
if (bigend) {
intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_BIG);
intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_BIG);
intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_BIG)
>> TIR_BITS1_BT_SH_BIG;
intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_BIG)
>> TIR_BITS_TQ4_SH_BIG;
intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_BIG)
>> TIR_BITS_TQ5_SH_BIG;
intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_BIG)
>> TIR_BITS_TQ0_SH_BIG;
intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_BIG)
>> TIR_BITS_TQ1_SH_BIG;
intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_BIG)
>> TIR_BITS_TQ2_SH_BIG;
intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_BIG)
>> TIR_BITS_TQ3_SH_BIG;
} else {
intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_LITTLE);
intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_LITTLE);
intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_LITTLE)
>> TIR_BITS1_BT_SH_LITTLE;
intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_LITTLE)
>> TIR_BITS_TQ4_SH_LITTLE;
intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_LITTLE)
>> TIR_BITS_TQ5_SH_LITTLE;
intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_LITTLE)
>> TIR_BITS_TQ0_SH_LITTLE;
intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_LITTLE)
>> TIR_BITS_TQ1_SH_LITTLE;
intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_LITTLE)
>> TIR_BITS_TQ2_SH_LITTLE;
intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_LITTLE)
>> TIR_BITS_TQ3_SH_LITTLE;
}
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap out a type information record.
BIGEND says whether AUX symbols are big-endian or little-endian; this
info comes from the file header record (fh-fBigendian). */
void
ecoff_swap_tir_out (bigend, intern_copy, ext)
int bigend;
TIR *intern_copy;
struct tir_ext *ext;
{
TIR intern[1];
*intern = *intern_copy; /* Make it reasonable to do in-place. */
/* now the fun stuff... */
if (bigend) {
ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_BIG : 0)
| (intern->continued ? TIR_BITS1_CONTINUED_BIG : 0)
| ((intern->bt << TIR_BITS1_BT_SH_BIG)
& TIR_BITS1_BT_BIG));
ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_BIG)
& TIR_BITS_TQ4_BIG)
| ((intern->tq5 << TIR_BITS_TQ5_SH_BIG)
& TIR_BITS_TQ5_BIG));
ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_BIG)
& TIR_BITS_TQ0_BIG)
| ((intern->tq1 << TIR_BITS_TQ1_SH_BIG)
& TIR_BITS_TQ1_BIG));
ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_BIG)
& TIR_BITS_TQ2_BIG)
| ((intern->tq3 << TIR_BITS_TQ3_SH_BIG)
& TIR_BITS_TQ3_BIG));
} else {
ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_LITTLE : 0)
| (intern->continued ? TIR_BITS1_CONTINUED_LITTLE : 0)
| ((intern->bt << TIR_BITS1_BT_SH_LITTLE)
& TIR_BITS1_BT_LITTLE));
ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_LITTLE)
& TIR_BITS_TQ4_LITTLE)
| ((intern->tq5 << TIR_BITS_TQ5_SH_LITTLE)
& TIR_BITS_TQ5_LITTLE));
ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_LITTLE)
& TIR_BITS_TQ0_LITTLE)
| ((intern->tq1 << TIR_BITS_TQ1_SH_LITTLE)
& TIR_BITS_TQ1_LITTLE));
ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_LITTLE)
& TIR_BITS_TQ2_LITTLE)
| ((intern->tq3 << TIR_BITS_TQ3_SH_LITTLE)
& TIR_BITS_TQ3_LITTLE));
}
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap in a relative symbol record. BIGEND says whether it is in
big-endian or little-endian format.*/
void
ecoff_swap_rndx_in (bigend, ext_copy, intern)
int bigend;
struct rndx_ext *ext_copy;
RNDXR *intern;
{
struct rndx_ext ext[1];
*ext = *ext_copy; /* Make it reasonable to do in-place. */
/* now the fun stuff... */
if (bigend) {
intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_BIG)
| ((ext->r_bits[1] & RNDX_BITS1_RFD_BIG)
>> RNDX_BITS1_RFD_SH_BIG);
intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_BIG)
<< RNDX_BITS1_INDEX_SH_LEFT_BIG)
| (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_BIG)
| (ext->r_bits[3] << RNDX_BITS3_INDEX_SH_LEFT_BIG);
} else {
intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_LITTLE)
| ((ext->r_bits[1] & RNDX_BITS1_RFD_LITTLE)
<< RNDX_BITS1_RFD_SH_LEFT_LITTLE);
intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_LITTLE)
>> RNDX_BITS1_INDEX_SH_LITTLE)
| (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_LITTLE)
| (ext->r_bits[3] << RNDX_BITS3_INDEX_SH_LEFT_LITTLE);
}
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap out a relative symbol record. BIGEND says whether it is in
big-endian or little-endian format.*/
void
ecoff_swap_rndx_out (bigend, intern_copy, ext)
int bigend;
RNDXR *intern_copy;
struct rndx_ext *ext;
{
RNDXR intern[1];
*intern = *intern_copy; /* Make it reasonable to do in-place. */
/* now the fun stuff... */
if (bigend) {
ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_BIG;
ext->r_bits[1] = (((intern->rfd << RNDX_BITS1_RFD_SH_BIG)
& RNDX_BITS1_RFD_BIG)
| ((intern->index >> RNDX_BITS1_INDEX_SH_LEFT_BIG)
& RNDX_BITS1_INDEX_BIG));
ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_BIG;
ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_BIG;
} else {
ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_LITTLE;
ext->r_bits[1] = (((intern->rfd >> RNDX_BITS1_RFD_SH_LEFT_LITTLE)
& RNDX_BITS1_RFD_LITTLE)
| ((intern->index << RNDX_BITS1_INDEX_SH_LITTLE)
& RNDX_BITS1_INDEX_LITTLE));
ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_LITTLE;
ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_LITTLE;
}
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap in a relative file descriptor. */
void
ecoff_swap_rfd_in (abfd, ext, intern)
bfd *abfd;
struct rfd_ext *ext;
RFDT *intern;
{
*intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap out a relative file descriptor. */
void
ecoff_swap_rfd_out (abfd, intern, ext)
bfd *abfd;
RFDT *intern;
struct rfd_ext *ext;
{
bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap in an optimization symbol. */
void
ecoff_swap_opt_in (abfd, ext_copy, intern)
bfd *abfd;
struct opt_ext *ext_copy;
OPTR *intern;
{
struct opt_ext ext[1];
*ext = *ext_copy; /* Make it reasonable to do in-place. */
if (abfd->xvec->header_byteorder_big_p != false)
{
intern->ot = ext->o_bits1[0];
intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_BIG)
| (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_BIG)
| (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_BIG));
}
else
{
intern->ot = ext->o_bits1[0];
intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
| (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
| (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE));
}
ecoff_swap_rndx_in (abfd->xvec->header_byteorder_big_p != false,
&ext->o_rndx, &intern->rndx);
intern->offset = bfd_h_get_32 (abfd, (bfd_byte *) ext->o_offset);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap out an optimization symbol. */
void
ecoff_swap_opt_out (abfd, intern_copy, ext)
bfd *abfd;
OPTR *intern_copy;
struct opt_ext *ext;
{
OPTR intern[1];
*intern = *intern_copy; /* Make it reasonable to do in-place. */
if (abfd->xvec->header_byteorder_big_p != false)
{
ext->o_bits1[0] = intern->ot;
ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_BIG;
ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_BIG;
ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_BIG;
}
else
{
ext->o_bits1[0] = intern->ot;
ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_LITTLE;
ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_LITTLE;
ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_LITTLE;
}
ecoff_swap_rndx_out (abfd->xvec->header_byteorder_big_p != false,
&intern->rndx, &ext->o_rndx);
bfd_h_put_32 (abfd, intern->value, (bfd_byte *) ext->o_offset);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap in a dense number. */
void
ecoff_swap_dnr_in (abfd, ext_copy, intern)
bfd *abfd;
struct dnr_ext *ext_copy;
DNR *intern;
{
struct dnr_ext ext[1];
*ext = *ext_copy; /* Make it reasonable to do in-place. */
intern->rfd = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_rfd);
intern->index = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_index);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}
/* Swap out a dense number. */
void
ecoff_swap_dnr_out (abfd, intern_copy, ext)
bfd *abfd;
DNR *intern_copy;
struct dnr_ext *ext;
{
DNR intern[1];
*intern = *intern_copy; /* Make it reasonable to do in-place. */
bfd_h_put_32 (abfd, intern->rfd, (bfd_byte *) ext->d_rfd);
bfd_h_put_32 (abfd, intern->index, (bfd_byte *) ext->d_index);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
abort();
#endif
}

4248
bfd/ecoff.c Normal file

File diff suppressed because it is too large Load Diff

255
bfd/libecoff.h Normal file
View File

@ -0,0 +1,255 @@
/* BFD ECOFF object file private structure.
Copyright (C) 1993 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
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 2 of the License, or
(at your option) any later version.
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 this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* This is the backend information kept for ECOFF files. This
structure is constant for a particular backend. ECOFF already
keeps a bfd_coff_backend_data structure in the bfd_target
backend_data field, so a pointer to this backend structure is kept
in the tdata field. */
#define ecoff_backend(abfd) (ecoff_data (abfd)->backend_data)
struct ecoff_backend_data
{
/* Supported architecture. */
enum bfd_architecture arch;
/* Big endian magic number. */
int big_magic;
/* Little endian magic number. */
int little_magic;
/* Alignment of debugging information. E.g., 4. */
bfd_size_type debug_align;
/* The page boundary used to align sections in a demand-paged
executable file. E.g., 0x1000. */
bfd_vma round;
/* Bitsize of constructor entries. */
unsigned int constructor_bitsize;
/* Sizes of external symbolic information. */
bfd_size_type external_hdr_size;
bfd_size_type external_dnr_size;
bfd_size_type external_pdr_size;
bfd_size_type external_sym_size;
bfd_size_type external_opt_size;
bfd_size_type external_fdr_size;
bfd_size_type external_rfd_size;
bfd_size_type external_ext_size;
/* Functions to swap in external symbolic data. */
void (*swap_hdr_in) PARAMS ((bfd *, PTR, HDRR *));
void (*swap_dnr_in) PARAMS ((bfd *, PTR, DNR *));
void (*swap_pdr_in) PARAMS ((bfd *, PTR, PDR *));
void (*swap_sym_in) PARAMS ((bfd *, PTR, SYMR *));
void (*swap_opt_in) PARAMS ((bfd *, PTR, OPTR *));
void (*swap_fdr_in) PARAMS ((bfd *, PTR, FDR *));
void (*swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *));
void (*swap_ext_in) PARAMS ((bfd *, PTR, EXTR *));
/* Functions to swap out external symbolic data. */
void (*swap_hdr_out) PARAMS ((bfd *, const HDRR *, PTR));
void (*swap_dnr_out) PARAMS ((bfd *, const DNR *, PTR));
void (*swap_pdr_out) PARAMS ((bfd *, const PDR *, PTR));
void (*swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR));
void (*swap_opt_out) PARAMS ((bfd *, const OPTR *, PTR));
void (*swap_fdr_out) PARAMS ((bfd *, const FDR *, PTR));
void (*swap_rfd_out) PARAMS ((bfd *, const RFDT *, PTR));
void (*swap_ext_out) PARAMS ((bfd *, const EXTR *, PTR));
/* It so happens that the auxiliary type information has the same
type and format for all known ECOFF targets. I don't see any
reason that that should change, so at least for now the auxiliary
swapping information is not in this table. */
/* External reloc size. */
bfd_size_type external_reloc_size;
/* Reloc swapping functions. */
void (*swap_reloc_in) PARAMS ((bfd *, PTR, struct internal_reloc *));
void (*swap_reloc_out) PARAMS ((bfd *, const struct internal_reloc *, PTR));
};
/* This is the target specific information kept for ECOFF files. */
#define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
typedef struct ecoff_tdata
{
/* Constant backend information. */
const struct ecoff_backend_data *backend_data;
/* The reloc file position, set by
ecoff_compute_section_file_positions. */
file_ptr reloc_filepos;
/* The symbol table file position, set by ecoff_mkobject_hook. */
file_ptr sym_filepos;
/* The start and end of the text segment. Only valid for an
existing file, not for one we are creating. */
unsigned long text_start;
unsigned long text_end;
/* The cached gp value. This is used when relocating. */
bfd_vma gp;
/* The maximum size of objects to optimize using gp. This is
typically set by the -G option to the compiler, assembler or
linker. */
int gp_size;
/* The register masks. When linking, all the masks found in the
input files are combined into the masks of the output file. */
unsigned long gprmask;
unsigned long cprmask[4];
/* The size of the unswapped ECOFF symbolic information. */
bfd_size_type raw_size;
/* The unswapped ECOFF symbolic information. */
PTR raw_syments;
/* The swapped ECOFF symbolic header. */
HDRR symbolic_header;
/* Pointers to the unswapped symbolic information. */
unsigned char *line;
PTR external_dnr; /* struct dnr_ext */
PTR external_pdr; /* struct pdr_ext */
PTR external_sym; /* struct sym_ext */
PTR external_opt; /* struct opt_ext */
union aux_ext *external_aux;
char *ss;
char *ssext;
PTR external_fdr; /* struct fdr_ext */
PTR external_rfd; /* struct rfd_ext */
PTR external_ext; /* struct ext_ext */
/* The swapped FDR information. */
FDR *fdr;
/* The FDR index. This is set for an input BFD to a link so that
the external symbols can set their FDR index correctly. */
unsigned int ifdbase;
/* The canonical BFD symbols. */
struct ecoff_symbol_struct *canonical_symbols;
} ecoff_data_type;
/* Each canonical asymbol really looks like this. */
typedef struct ecoff_symbol_struct
{
/* The actual symbol which the rest of BFD works with */
asymbol symbol;
/* The fdr for this symbol. */
FDR *fdr;
/* true if this is a local symbol rather than an external one. */
boolean local;
/* A pointer to the unswapped hidden information for this symbol.
This is either a struct sym_ext or a struct ext_ext, depending on
the value of the local field above. */
PTR native;
} ecoff_symbol_type;
/* We take the address of the first element of a asymbol to ensure that the
macro is only ever applied to an asymbol. */
#define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
/* This is a hack borrowed from coffcode.h; we need to save the index
of an external symbol when we write it out so that can set the
symbol index correctly when we write out the relocs. */
#define ecoff_get_sym_index(symbol) ((unsigned long) (symbol)->udata)
#define ecoff_set_sym_index(symbol, idx) ((symbol)->udata = (PTR) (idx))
/* Make an empty ECOFF symbol. */
extern asymbol *ecoff_make_empty_symbol PARAMS ((bfd *abfd));
/* Read in the ECOFF symbolic debugging information. */
extern boolean ecoff_slurp_symbolic_info PARAMS ((bfd *));
/* Generic ECOFF BFD backend vectors. */
extern unsigned int ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd));
extern unsigned int ecoff_get_symtab PARAMS ((bfd *abfd,
asymbol **alocation));
extern void ecoff_get_symbol_info PARAMS ((bfd *abfd,
asymbol *symbol,
symbol_info *ret));
extern void ecoff_print_symbol PARAMS ((bfd *abfd, PTR filep,
asymbol *symbol,
bfd_print_symbol_type how));
extern unsigned int ecoff_canonicalize_reloc PARAMS ((bfd *abfd,
asection *section,
arelent **relptr,
asymbol **symbols));
extern CONST struct reloc_howto_struct *ecoff_bfd_reloc_type_lookup
PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
extern boolean ecoff_find_nearest_line PARAMS ((bfd *abfd,
asection *section,
asymbol **symbols,
bfd_vma offset,
CONST char **filename_ptr,
CONST char **fnname_ptr,
unsigned int *retline_ptr));
extern boolean ecoff_bfd_seclet_link PARAMS ((bfd *abfd, PTR data,
boolean relocateable));
extern boolean ecoff_set_arch_mach PARAMS ((bfd *abfd,
enum bfd_architecture arch,
unsigned long machine));
extern int ecoff_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
extern boolean ecoff_set_section_contents PARAMS ((bfd *abfd,
asection *section,
PTR location,
file_ptr offset,
bfd_size_type count));
extern boolean ecoff_write_object_contents PARAMS ((bfd *abfd));
extern boolean ecoff_slurp_armap PARAMS ((bfd *abfd));
extern boolean ecoff_write_armap PARAMS ((bfd *abfd, unsigned int elength,
struct orl *map,
unsigned int orl_count,
int stridx));
#define ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
extern bfd_target *ecoff_archive_p PARAMS ((bfd *abfd));
#define ecoff_get_lineno \
((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
#define ecoff_truncate_arname bfd_dont_truncate_arname
#define ecoff_openr_next_archived_file bfd_generic_openr_next_archived_file
#define ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
#define ecoff_get_section_contents bfd_generic_get_section_contents
#define ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
#define ecoff_close_and_cleanup bfd_generic_close_and_cleanup
#define ecoff_bfd_debug_info_start bfd_void
#define ecoff_bfd_debug_info_end bfd_void
#define ecoff_bfd_debug_info_accumulate \
((void (*) PARAMS ((bfd *, struct sec *))) bfd_void)
#define ecoff_bfd_get_relocated_section_contents \
bfd_generic_get_relocated_section_contents
#define ecoff_bfd_relax_section bfd_generic_relax_section
#define ecoff_bfd_make_debug_symbol \
((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
/* Hook functions for the generic COFF section reading code. */
extern asection *ecoff_make_section_hook PARAMS ((bfd *abfd, char *name));
extern boolean ecoff_new_section_hook PARAMS ((bfd *abfd,
asection *section));
#define ecoff_set_alignment_hook \
((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
extern boolean ecoff_set_arch_mach_hook PARAMS ((bfd *abfd, PTR filehdr));
extern long ecoff_sec_to_styp_flags PARAMS ((CONST char *name,
flagword flags));
extern flagword ecoff_styp_to_sec_flags PARAMS ((bfd *abfd, PTR hdr));
extern boolean ecoff_slurp_symbol_table PARAMS ((bfd *abfd));