Add support for PEF, Mach-O, xSYM

This commit is contained in:
Nick Clifton 2002-11-06 13:26:29 +00:00
parent ad12c1c577
commit 3af9a47b1c
16 changed files with 7660 additions and 48 deletions

View File

@ -1,3 +1,33 @@
2002-11-06 Klee Dienes <kdienes@apple.com>
* Makefile.am (BFD32_BACKENDS): Add mach-o.lo, pef.lo, and
xsym.lo.
(BFD32_BACKENDS_CFILES): Add mach-o.c, pef.c, and xsym.c.
(SOURCE_HFILES): Add mach-o.h, pef.h, pef-traceback.h, xsym.h
* archures.c (enum bfd_architecture): Add bfd_arch_m98k.
* bfd.c (struct bfd): Add private data for mach-o, pef, and sym.
* targets.c (enum bfd_flavour): Add flavours for mach-o, pef, and
sym.
(_bfd_target_vector): Add target vectors for mach-o, pef, and sym.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* xsym.c: New file. Contains support for the Apple/Metrowerks
xSYM debugging format.
* xsym.h: New file.
* pef.c: New file. Contains support for the Apple Code Fragment
Manager Preferred Executable Format
* pef.h: New file.
* pef-traceback.h: New file. Contains support for parsing PowerPC
traceback tables as used by PEF executables (and perhaps other
systems as well).
* mach-o.c: New file. Contains support for the Mach-O object file
format.
* mach-o.h: New file.
* mach-o-target.c: New file. Declares the mach-o targets
themselves. Included three times by mach-o.c; each time with a
different set of macros set.
2002-11-06 Graeme Peterson <gp@qnx.com>
* Makefile.am: Remove entries for elf32-qnx.[ch].

View File

@ -266,6 +266,7 @@ BFD32_BACKENDS = \
m68klynx.lo \
m68knetbsd.lo \
m88kmach3.lo \
mach-o.lo \
mipsbsd.lo \
newsos3.lo \
nlm.lo \
@ -277,6 +278,7 @@ BFD32_BACKENDS = \
oasys.lo \
pc532-mach.lo \
pdp11.lo \
pef.lo \
pe-arm.lo \
pei-arm.lo \
pe-i386.lo \
@ -306,7 +308,8 @@ BFD32_BACKENDS = \
vms-hdr.lo \
vms-misc.lo \
vms-tir.lo \
xcofflink.lo
xcofflink.lo \
xsym.lo
BFD32_BACKENDS_CFILES = \
aout-adobe.c \
@ -420,6 +423,7 @@ BFD32_BACKENDS_CFILES = \
m68klynx.c \
m68knetbsd.c \
m88kmach3.c \
mach-o.c \
mipsbsd.c \
newsos3.c \
nlm.c \
@ -431,6 +435,7 @@ BFD32_BACKENDS_CFILES = \
oasys.c \
pc532-mach.c \
pdp11.c \
pef.c \
pe-arm.c \
pei-arm.c \
pe-i386.c \
@ -459,7 +464,8 @@ BFD32_BACKENDS_CFILES = \
vms-hdr.c \
vms-misc.c \
vms-tir.c \
xcofflink.c
xcofflink.c \
xsym.c
# The .o files needed by all of the 64 bit vectors that are configured into
# target_vector in targets.c if configured with --enable-targets=all
@ -563,9 +569,10 @@ SOURCE_HFILES = \
elf64-hppa.h elfcode.h elfcore.h elflink.h \
freebsd.h genlink.h go32stub.h \
libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \
libnlm.h liboasys.h libpei.h libxcoff.h \
libnlm.h liboasys.h libpei.h libxcoff.h mach-o.h \
netbsd.h nlm-target.h nlmcode.h nlmswap.h ns32k.h \
peicode.h som.h version.h vms.h xcoff-target.h
pef.h pef-traceback.h peicode.h som.h version.h \
vms.h xcoff-target.h xsym.h
## ... and all .h files which are in the build tree.
BUILD_HFILES = \
@ -1327,6 +1334,8 @@ m68knetbsd.lo: m68knetbsd.c netbsd.h $(INCDIR)/filenames.h \
m88kmach3.lo: m88kmach3.c $(INCDIR)/filenames.h libaout.h \
$(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \
$(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
mach-o.lo: mach-o.c mach-o.h $(INCDIR)/filenames.h \
$(INCDIR)/libiberty.h mach-o-target.c
mipsbsd.lo: mipsbsd.c $(INCDIR)/filenames.h libaout.h \
$(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \
$(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
@ -1358,6 +1367,8 @@ pc532-mach.lo: pc532-mach.c $(INCDIR)/filenames.h libaout.h \
pdp11.lo: pdp11.c $(INCDIR)/filenames.h libaout.h $(INCDIR)/bfdlink.h \
aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
$(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h $(INCDIR)/safe-ctype.h
pef.lo: pef.c pef.h pef-traceback.h $(INCDIR)/filenames.h \
$(INCDIR)/libiberty.h
pe-arm.lo: pe-arm.c $(INCDIR)/filenames.h coff-arm.c \
$(INCDIR)/coff/arm.h $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
$(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
@ -1450,6 +1461,7 @@ vms-tir.lo: vms-tir.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
xcofflink.lo: xcofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/coff/internal.h $(INCDIR)/coff/xcoff.h libcoff.h \
libxcoff.h
xsym.lo: xsym.c xsym.h $(INCDIR)/filenames.h
aix5ppc-core.lo: aix5ppc-core.c
aout64.lo: aout64.c aoutx.h $(INCDIR)/filenames.h $(INCDIR)/safe-ctype.h \
$(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \

View File

@ -393,6 +393,7 @@ BFD32_BACKENDS = \
m68klynx.lo \
m68knetbsd.lo \
m88kmach3.lo \
mach-o.lo \
mipsbsd.lo \
newsos3.lo \
nlm.lo \
@ -404,6 +405,7 @@ BFD32_BACKENDS = \
oasys.lo \
pc532-mach.lo \
pdp11.lo \
pef.lo \
pe-arm.lo \
pei-arm.lo \
pe-i386.lo \
@ -433,7 +435,8 @@ BFD32_BACKENDS = \
vms-hdr.lo \
vms-misc.lo \
vms-tir.lo \
xcofflink.lo
xcofflink.lo \
xsym.lo
BFD32_BACKENDS_CFILES = \
@ -548,6 +551,7 @@ BFD32_BACKENDS_CFILES = \
m68klynx.c \
m68knetbsd.c \
m88kmach3.c \
mach-o.c \
mipsbsd.c \
newsos3.c \
nlm.c \
@ -559,6 +563,7 @@ BFD32_BACKENDS_CFILES = \
oasys.c \
pc532-mach.c \
pdp11.c \
pef.c \
pe-arm.c \
pei-arm.c \
pe-i386.c \
@ -587,7 +592,8 @@ BFD32_BACKENDS_CFILES = \
vms-hdr.c \
vms-misc.c \
vms-tir.c \
xcofflink.c
xcofflink.c \
xsym.c
# The .o files needed by all of the 64 bit vectors that are configured into
@ -697,9 +703,10 @@ SOURCE_HFILES = \
elf64-hppa.h elfcode.h elfcore.h elflink.h \
freebsd.h genlink.h go32stub.h \
libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \
libnlm.h liboasys.h libpei.h libxcoff.h \
libnlm.h liboasys.h libpei.h libxcoff.h mach-o.h \
netbsd.h nlm-target.h nlmcode.h nlmswap.h ns32k.h \
peicode.h som.h version.h vms.h xcoff-target.h
pef.h pef-traceback.h peicode.h som.h version.h \
vms.h xcoff-target.h xsym.h
BUILD_HFILES = \
@ -778,7 +785,7 @@ configure.in version.h
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
SOURCES = $(libbfd_a_SOURCES) $(libbfd_la_SOURCES)
OBJECTS = $(libbfd_a_OBJECTS) $(libbfd_la_OBJECTS)
@ -1858,6 +1865,8 @@ m68knetbsd.lo: m68knetbsd.c netbsd.h $(INCDIR)/filenames.h \
m88kmach3.lo: m88kmach3.c $(INCDIR)/filenames.h libaout.h \
$(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \
$(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
mach-o.lo: mach-o.c mach-o.h $(INCDIR)/filenames.h \
$(INCDIR)/libiberty.h mach-o-target.c
mipsbsd.lo: mipsbsd.c $(INCDIR)/filenames.h libaout.h \
$(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \
$(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
@ -1889,6 +1898,8 @@ pc532-mach.lo: pc532-mach.c $(INCDIR)/filenames.h libaout.h \
pdp11.lo: pdp11.c $(INCDIR)/filenames.h libaout.h $(INCDIR)/bfdlink.h \
aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
$(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h $(INCDIR)/safe-ctype.h
pef.lo: pef.c pef.h pef-traceback.h $(INCDIR)/filenames.h \
$(INCDIR)/libiberty.h
pe-arm.lo: pe-arm.c $(INCDIR)/filenames.h coff-arm.c \
$(INCDIR)/coff/arm.h $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
$(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
@ -1981,6 +1992,7 @@ vms-tir.lo: vms-tir.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
xcofflink.lo: xcofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/coff/internal.h $(INCDIR)/coff/xcoff.h libcoff.h \
libxcoff.h
xsym.lo: xsym.c xsym.h $(INCDIR)/filenames.h
aix5ppc-core.lo: aix5ppc-core.c
aout64.lo: aout64.c aoutx.h $(INCDIR)/filenames.h $(INCDIR)/safe-ctype.h \
$(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \

View File

@ -4,21 +4,21 @@
Free Software Foundation, Inc.
Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
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 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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
@ -160,6 +160,7 @@ DESCRIPTION
. bfd_arch_alliant, {* Alliant *}
. bfd_arch_convex, {* Convex *}
. bfd_arch_m88k, {* Motorola 88xxx *}
. bfd_arch_m98k, {* Motorola 98xxx *}
. bfd_arch_pyramid, {* Pyramid Technology *}
. bfd_arch_h8300, {* Hitachi H8/300 *}
.#define bfd_mach_h8300 1

View File

@ -1551,6 +1551,7 @@ enum bfd_architecture
bfd_arch_alliant, /* Alliant */
bfd_arch_convex, /* Convex */
bfd_arch_m88k, /* Motorola 88xxx */
bfd_arch_m98k, /* Motorola 98xxx */
bfd_arch_pyramid, /* Pyramid Technology */
bfd_arch_h8300, /* Hitachi H8/300 */
#define bfd_mach_h8300 1
@ -3533,6 +3534,11 @@ struct _bfd
struct cisco_core_struct *cisco_core_data;
struct versados_data_struct *versados_data;
struct netbsd_core_struct *netbsd_core_data;
struct mach_o_data_struct *mach_o_data;
struct mach_o_fat_data_struct *mach_o_fat_data;
struct bfd_pef_data_struct *pef_data;
struct bfd_pef_xlib_data_struct *pef_xlib_data;
struct bfd_sym_data_struct *sym_data;
PTR any;
}
tdata;
@ -3795,7 +3801,11 @@ enum bfd_flavour
bfd_target_msdos_flavour,
bfd_target_ovax_flavour,
bfd_target_evax_flavour,
bfd_target_mmo_flavour
bfd_target_mmo_flavour,
bfd_target_mach_o_flavour,
bfd_target_pef_flavour,
bfd_target_pef_xlib_flavour,
bfd_target_sym_flavour
};
enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };

View File

@ -4,21 +4,21 @@
Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
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 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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*
SECTION
@ -180,6 +180,11 @@ CODE_FRAGMENT
. struct cisco_core_struct *cisco_core_data;
. struct versados_data_struct *versados_data;
. struct netbsd_core_struct *netbsd_core_data;
. struct mach_o_data_struct *mach_o_data;
. struct mach_o_fat_data_struct *mach_o_fat_data;
. struct bfd_pef_data_struct *pef_data;
. struct bfd_pef_xlib_data_struct *pef_xlib_data;
. struct bfd_sym_data_struct *sym_data;
. PTR any;
. }
. tdata;

View File

@ -245,7 +245,7 @@ DIST_COMMON = ChangeLog Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:

117
bfd/mach-o-target.c Normal file
View File

@ -0,0 +1,117 @@
/* Mach-O support for BFD.
Copyright 1999, 2000, 2001, 2002
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef TARGET_NAME
#error TARGET_NAME must be defined
#endif /* TARGET_NAME */
#ifndef TARGET_STRING
#error TARGET_STRING must be defined
#endif /* TARGET_STRING */
#ifndef TARGET_BIG_ENDIAN
#error TARGET_BIG_ENDIAN must be defined
#endif /* TARGET_BIG_ENDIAN */
#ifndef TARGET_ARCHIVE
#error TARGET_ARCHIVE must be defined
#endif /* TARGET_ARCHIVE */
#if ((TARGET_ARCHIVE) && (! TARGET_BIG_ENDIAN))
#error Mach-O fat files must always be big-endian.
#endif /* ((TARGET_ARCHIVE) && (! TARGET_BIG_ENDIAN)) */
const bfd_target TARGET_NAME =
{
TARGET_STRING, /* Name. */
bfd_target_mach_o_flavour,
#if TARGET_BIG_ENDIAN
BFD_ENDIAN_BIG, /* Target byte order. */
BFD_ENDIAN_BIG, /* Target headers byte order. */
#else
BFD_ENDIAN_LITTLE, /* Target byte order. */
BFD_ENDIAN_LITTLE, /* Target headers byte order. */
#endif
(HAS_RELOC | EXEC_P | /* Object flags. */
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
(SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
| SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* Section flags. */
'_', /* symbol_leading_char. */
' ', /* ar_pad_char. */
16, /* ar_max_namelen. */
#if TARGET_BIG_ENDIAN
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Hdrs. */
#else
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
#endif /* TARGET_BIG_ENDIAN */
{ /* bfd_check_format. */
#if TARGET_ARCHIVE
_bfd_dummy_target,
_bfd_dummy_target,
bfd_mach_o_archive_p,
_bfd_dummy_target,
#else
_bfd_dummy_target,
bfd_mach_o_object_p,
_bfd_dummy_target,
bfd_mach_o_core_p
#endif
},
{ /* bfd_set_format. */
bfd_false,
bfd_mach_o_mkobject,
bfd_false,
bfd_mach_o_mkobject,
},
{ /* bfd_write_contents. */
bfd_false,
bfd_mach_o_write_contents,
bfd_false,
bfd_mach_o_write_contents,
},
BFD_JUMP_TABLE_GENERIC (bfd_mach_o),
BFD_JUMP_TABLE_COPY (bfd_mach_o),
BFD_JUMP_TABLE_CORE (bfd_mach_o),
BFD_JUMP_TABLE_ARCHIVE (bfd_mach_o),
BFD_JUMP_TABLE_SYMBOLS (bfd_mach_o),
BFD_JUMP_TABLE_RELOCS (bfd_mach_o),
BFD_JUMP_TABLE_WRITE (bfd_mach_o),
BFD_JUMP_TABLE_LINK (bfd_mach_o),
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
NULL,
NULL
};

2163
bfd/mach-o.c Normal file

File diff suppressed because it is too large Load Diff

490
bfd/mach-o.h Normal file
View File

@ -0,0 +1,490 @@
/* Mach-O support for BFD.
Copyright 1999, 2000, 2001, 2002
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _BFD_MACH_O_H_
#define _BFD_MACH_O_H_
#include "bfd.h"
#define BFD_MACH_O_N_STAB 0xe0 /* If any of these bits set, a symbolic debugging entry. */
#define BFD_MACH_O_N_PEXT 0x10 /* Private external symbol bit. */
#define BFD_MACH_O_N_TYPE 0x0e /* Mask for the type bits. */
#define BFD_MACH_O_N_EXT 0x01 /* External symbol bit, set for external symbols. */
#define BFD_MACH_O_N_UNDF 0x00 /* Undefined, n_sect == NO_SECT. */
#define BFD_MACH_O_N_ABS 0x02 /* Absolute, n_sect == NO_SECT. */
#define BFD_MACH_O_N_SECT 0x0e /* Defined in section number n_sect. */
#define BFD_MACH_O_N_PBUD 0x0c /* Prebound undefined (defined in a dylib). */
#define BFD_MACH_O_N_INDR 0x0a /* Indirect. */
typedef enum bfd_mach_o_ppc_thread_flavour
{
BFD_MACH_O_PPC_THREAD_STATE = 1,
BFD_MACH_O_PPC_FLOAT_STATE = 2,
BFD_MACH_O_PPC_EXCEPTION_STATE = 3,
BFD_MACH_O_PPC_VECTOR_STATE = 4
}
bfd_mach_o_ppc_thread_flavour;
typedef enum bfd_mach_o_i386_thread_flavour
{
BFD_MACH_O_i386_NEW_THREAD_STATE = 1,
BFD_MACH_O_i386_FLOAT_STATE = 2,
BFD_MACH_O_i386_ISA_PORT_MAP_STATE = 3,
BFD_MACH_O_i386_V86_ASSIST_STATE = 4,
BFD_MACH_O_i386_REGS_SEGS_STATE = 5,
BFD_MACH_O_i386_THREAD_SYSCALL_STATE = 6,
BFD_MACH_O_i386_THREAD_STATE_NONE = 7,
BFD_MACH_O_i386_SAVED_STATE = 8,
BFD_MACH_O_i386_THREAD_STATE = -1,
BFD_MACH_O_i386_THREAD_FPSTATE = -2,
BFD_MACH_O_i386_THREAD_EXCEPTSTATE = -3,
BFD_MACH_O_i386_THREAD_CTHREADSTATE = -4,
}
bfd_mach_o_i386_thread_flavour;
#define BFD_MACH_O_LC_REQ_DYLD 0x80000000
typedef enum bfd_mach_o_load_command_type
{
BFD_MACH_O_LC_SEGMENT = 0x1, /* File segment to be mapped. */
BFD_MACH_O_LC_SYMTAB = 0x2, /* Link-edit stab symbol table info (obsolete). */
BFD_MACH_O_LC_SYMSEG = 0x3, /* Link-edit gdb symbol table info. */
BFD_MACH_O_LC_THREAD = 0x4, /* Thread. */
BFD_MACH_O_LC_UNIXTHREAD = 0x5, /* UNIX thread (includes a stack). */
BFD_MACH_O_LC_LOADFVMLIB = 0x6, /* Load a fixed VM shared library. */
BFD_MACH_O_LC_IDFVMLIB = 0x7, /* Fixed VM shared library id. */
BFD_MACH_O_LC_IDENT = 0x8, /* Object identification information (obsolete). */
BFD_MACH_O_LC_FVMFILE = 0x9, /* Fixed VM file inclusion. */
BFD_MACH_O_LC_PREPAGE = 0xa, /* Prepage command (internal use). */
BFD_MACH_O_LC_DYSYMTAB = 0xb, /* Dynamic link-edit symbol table info. */
BFD_MACH_O_LC_LOAD_DYLIB = 0xc, /* Load a dynamicly linked shared library. */
BFD_MACH_O_LC_ID_DYLIB = 0xd, /* Dynamicly linked shared lib identification. */
BFD_MACH_O_LC_LOAD_DYLINKER = 0xe, /* Load a dynamic linker. */
BFD_MACH_O_LC_ID_DYLINKER = 0xf, /* Dynamic linker identification. */
BFD_MACH_O_LC_PREBOUND_DYLIB = 0x10,/* Modules prebound for a dynamicly. */
BFD_MACH_O_LC_ROUTINES = 0x11, /* Image routines. */
BFD_MACH_O_LC_SUB_FRAMEWORK = 0x12, /* Sub framework. */
BFD_MACH_O_LC_SUB_UMBRELLA = 0x13, /* Sub umbrella. */
BFD_MACH_O_LC_SUB_CLIENT = 0x14, /* Sub client. */
BFD_MACH_O_LC_SUB_LIBRARY = 0x15, /* Sub library. */
BFD_MACH_O_LC_TWOLEVEL_HINTS = 0x16,/* Two-level namespace lookup hints. */
BFD_MACH_O_LC_PREBIND_CKSUM = 0x17, /* Prebind checksum. */
/* Load a dynamicly linked shared library that is allowed to be
missing (weak). */
BFD_MACH_O_LC_LOAD_WEAK_DYLIB = 0x18
}
bfd_mach_o_load_command_type;
typedef enum bfd_mach_o_cpu_type
{
BFD_MACH_O_CPU_TYPE_VAX = 1,
BFD_MACH_O_CPU_TYPE_MC680x0 = 6,
BFD_MACH_O_CPU_TYPE_I386 = 7,
BFD_MACH_O_CPU_TYPE_MIPS = 8,
BFD_MACH_O_CPU_TYPE_MC98000 = 10,
BFD_MACH_O_CPU_TYPE_HPPA = 11,
BFD_MACH_O_CPU_TYPE_ARM = 12,
BFD_MACH_O_CPU_TYPE_MC88000 = 13,
BFD_MACH_O_CPU_TYPE_SPARC = 14,
BFD_MACH_O_CPU_TYPE_I860 = 15,
BFD_MACH_O_CPU_TYPE_ALPHA = 16,
BFD_MACH_O_CPU_TYPE_POWERPC = 18
}
bfd_mach_o_cpu_type;
typedef enum bfd_mach_o_filetype
{
BFD_MACH_O_MH_OBJECT = 1,
BFD_MACH_O_MH_EXECUTE = 2,
BFD_MACH_O_MH_FVMLIB = 3,
BFD_MACH_O_MH_CORE = 4,
BFD_MACH_O_MH_PRELOAD = 5,
BFD_MACH_O_MH_DYLIB = 6,
BFD_MACH_O_MH_DYLINKER = 7,
BFD_MACH_O_MH_BUNDLE = 8
}
bfd_mach_o_filetype;
/* Constants for the type of a section. */
typedef enum bfd_mach_o_section_type
{
/* Regular section. */
BFD_MACH_O_S_REGULAR = 0x0,
/* Zero fill on demand section. */
BFD_MACH_O_S_ZEROFILL = 0x1,
/* Section with only literal C strings. */
BFD_MACH_O_S_CSTRING_LITERALS = 0x2,
/* Section with only 4 byte literals. */
BFD_MACH_O_S_4BYTE_LITERALS = 0x3,
/* Section with only 8 byte literals. */
BFD_MACH_O_S_8BYTE_LITERALS = 0x4,
/* Section with only pointers to literals. */
BFD_MACH_O_S_LITERAL_POINTERS = 0x5,
/* For the two types of symbol pointers sections and the symbol stubs
section they have indirect symbol table entries. For each of the
entries in the section the indirect symbol table entries, in
corresponding order in the indirect symbol table, start at the index
stored in the reserved1 field of the section structure. Since the
indirect symbol table entries correspond to the entries in the
section the number of indirect symbol table entries is inferred from
the size of the section divided by the size of the entries in the
section. For symbol pointers sections the size of the entries in
the section is 4 bytes and for symbol stubs sections the byte size
of the stubs is stored in the reserved2 field of the section
structure. */
/* Section with only non-lazy symbol pointers. */
BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS = 0x6,
/* Section with only lazy symbol pointers. */
BFD_MACH_O_S_LAZY_SYMBOL_POINTERS = 0x7,
/* Section with only symbol stubs, byte size of stub in the reserved2 field. */
BFD_MACH_O_S_SYMBOL_STUBS = 0x8,
/* Section with only function pointers for initialization. */
BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS = 0x9
}
bfd_mach_o_section_type;
typedef unsigned long bfd_mach_o_cpu_subtype;
typedef struct bfd_mach_o_header
{
unsigned long magic;
unsigned long cputype;
unsigned long cpusubtype;
unsigned long filetype;
unsigned long ncmds;
unsigned long sizeofcmds;
unsigned long flags;
enum bfd_endian byteorder;
}
bfd_mach_o_header;
typedef struct bfd_mach_o_section
{
asection *bfdsection;
char sectname[16 + 1];
char segname[16 + 1];
bfd_vma addr;
bfd_vma size;
bfd_vma offset;
unsigned long align;
bfd_vma reloff;
unsigned long nreloc;
unsigned long flags;
unsigned long reserved1;
unsigned long reserved2;
}
bfd_mach_o_section;
typedef struct bfd_mach_o_segment_command
{
char segname[16];
bfd_vma vmaddr;
bfd_vma vmsize;
bfd_vma fileoff;
unsigned long filesize;
unsigned long nsects;
unsigned long flags;
bfd_mach_o_section *sections;
asection *segment;
}
bfd_mach_o_segment_command;
typedef struct bfd_mach_o_symtab_command
{
unsigned long symoff;
unsigned long nsyms;
unsigned long stroff;
unsigned long strsize;
asymbol *symbols;
char *strtab;
asection *stabs_segment;
asection *stabstr_segment;
}
bfd_mach_o_symtab_command;
/* This is the second set of the symbolic information which is used to support
the data structures for the dynamicly link editor.
The original set of symbolic information in the symtab_command which contains
the symbol and string tables must also be present when this load command is
present. When this load command is present the symbol table is organized
into three groups of symbols:
local symbols (static and debugging symbols) - grouped by module
defined external symbols - grouped by module (sorted by name if not lib)
undefined external symbols (sorted by name)
In this load command there are offsets and counts to each of the three groups
of symbols.
This load command contains a the offsets and sizes of the following new
symbolic information tables:
table of contents
module table
reference symbol table
indirect symbol table
The first three tables above (the table of contents, module table and
reference symbol table) are only present if the file is a dynamicly linked
shared library. For executable and object modules, which are files
containing only one module, the information that would be in these three
tables is determined as follows:
table of contents - the defined external symbols are sorted by name
module table - the file contains only one module so everything in the
file is part of the module.
reference symbol table - is the defined and undefined external symbols
For dynamicly linked shared library files this load command also contains
offsets and sizes to the pool of relocation entries for all sections
separated into two groups:
external relocation entries
local relocation entries
For executable and object modules the relocation entries continue to hang
off the section structures. */
typedef struct bfd_mach_o_dysymtab_command
{
/* The symbols indicated by symoff and nsyms of the LC_SYMTAB load command
are grouped into the following three groups:
local symbols (further grouped by the module they are from)
defined external symbols (further grouped by the module they are from)
undefined symbols
The local symbols are used only for debugging. The dynamic binding
process may have to use them to indicate to the debugger the local
symbols for a module that is being bound.
The last two groups are used by the dynamic binding process to do the
binding (indirectly through the module table and the reference symbol
table when this is a dynamicly linked shared library file). */
unsigned long ilocalsym; /* Index to local symbols. */
unsigned long nlocalsym; /* Number of local symbols. */
unsigned long iextdefsym; /* Index to externally defined symbols. */
unsigned long nextdefsym; /* Number of externally defined symbols. */
unsigned long iundefsym; /* Index to undefined symbols. */
unsigned long nundefsym; /* Number of undefined symbols. */
/* For the for the dynamic binding process to find which module a symbol
is defined in the table of contents is used (analogous to the ranlib
structure in an archive) which maps defined external symbols to modules
they are defined in. This exists only in a dynamicly linked shared
library file. For executable and object modules the defined external
symbols are sorted by name and is use as the table of contents. */
unsigned long tocoff; /* File offset to table of contents. */
unsigned long ntoc; /* Number of entries in table of contents. */
/* To support dynamic binding of "modules" (whole object files) the symbol
table must reflect the modules that the file was created from. This is
done by having a module table that has indexes and counts into the merged
tables for each module. The module structure that these two entries
refer to is described below. This exists only in a dynamicly linked
shared library file. For executable and object modules the file only
contains one module so everything in the file belongs to the module. */
unsigned long modtaboff; /* File offset to module table. */
unsigned long nmodtab; /* Number of module table entries. */
/* To support dynamic module binding the module structure for each module
indicates the external references (defined and undefined) each module
makes. For each module there is an offset and a count into the
reference symbol table for the symbols that the module references.
This exists only in a dynamicly linked shared library file. For
executable and object modules the defined external symbols and the
undefined external symbols indicates the external references. */
unsigned long extrefsymoff; /* Offset to referenced symbol table. */
unsigned long nextrefsyms; /* Number of referenced symbol table entries. */
/* The sections that contain "symbol pointers" and "routine stubs" have
indexes and (implied counts based on the size of the section and fixed
size of the entry) into the "indirect symbol" table for each pointer
and stub. For every section of these two types the index into the
indirect symbol table is stored in the section header in the field
reserved1. An indirect symbol table entry is simply a 32bit index into
the symbol table to the symbol that the pointer or stub is referring to.
The indirect symbol table is ordered to match the entries in the section. */
unsigned long indirectsymoff; /* File offset to the indirect symbol table. */
unsigned long nindirectsyms; /* Number of indirect symbol table entries. */
/* To support relocating an individual module in a library file quickly the
external relocation entries for each module in the library need to be
accessed efficiently. Since the relocation entries can't be accessed
through the section headers for a library file they are separated into
groups of local and external entries further grouped by module. In this
case the presents of this load command who's extreloff, nextrel,
locreloff and nlocrel fields are non-zero indicates that the relocation
entries of non-merged sections are not referenced through the section
structures (and the reloff and nreloc fields in the section headers are
set to zero).
Since the relocation entries are not accessed through the section headers
this requires the r_address field to be something other than a section
offset to identify the item to be relocated. In this case r_address is
set to the offset from the vmaddr of the first LC_SEGMENT command.
The relocation entries are grouped by module and the module table
entries have indexes and counts into them for the group of external
relocation entries for that the module.
For sections that are merged across modules there must not be any
remaining external relocation entries for them (for merged sections
remaining relocation entries must be local). */
unsigned long extreloff; /* Offset to external relocation entries. */
unsigned long nextrel; /* Number of external relocation entries. */
/* All the local relocation entries are grouped together (they are not
grouped by their module since they are only used if the object is moved
from it staticly link edited address). */
unsigned long locreloff; /* Offset to local relocation entries. */
unsigned long nlocrel; /* Number of local relocation entries. */
}
bfd_mach_o_dysymtab_command;
/* An indirect symbol table entry is simply a 32bit index into the symbol table
to the symbol that the pointer or stub is refering to. Unless it is for a
non-lazy symbol pointer section for a defined symbol which strip(1) as
removed. In which case it has the value INDIRECT_SYMBOL_LOCAL. If the
symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that. */
#define INDIRECT_SYMBOL_LOCAL 0x80000000
#define INDIRECT_SYMBOL_ABS 0x40000000
typedef struct bfd_mach_o_thread_flavour
{
unsigned long flavour;
bfd_vma offset;
unsigned long size;
}
bfd_mach_o_thread_flavour;
typedef struct bfd_mach_o_thread_command
{
unsigned long nflavours;
bfd_mach_o_thread_flavour *flavours;
asection *section;
}
bfd_mach_o_thread_command;
typedef struct bfd_mach_o_dylinker_command
{
unsigned long cmd; /* LC_ID_DYLIB or LC_LOAD_DYLIB. */
unsigned long cmdsize; /* Includes pathname string. */
unsigned long name_offset; /* Offset to library's path name. */
unsigned long name_len; /* Offset to library's path name. */
asection *section;
}
bfd_mach_o_dylinker_command;
typedef struct bfd_mach_o_dylib_command
{
unsigned long cmd; /* LC_ID_DYLIB or LC_LOAD_DYLIB. */
unsigned long cmdsize; /* Includes pathname string. */
unsigned long name_offset; /* Offset to library's path name. */
unsigned long name_len; /* Offset to library's path name. */
unsigned long timestamp; /* Library's build time stamp. */
unsigned long current_version; /* Library's current version number. */
unsigned long compatibility_version; /* Library's compatibility vers number. */
asection *section;
}
bfd_mach_o_dylib_command;
typedef struct bfd_mach_o_prebound_dylib_command
{
unsigned long cmd; /* LC_PREBOUND_DYLIB. */
unsigned long cmdsize; /* Includes strings. */
unsigned long name; /* Library's path name. */
unsigned long nmodules; /* Number of modules in library. */
unsigned long linked_modules; /* Bit vector of linked modules. */
asection *section;
}
bfd_mach_o_prebound_dylib_command;
typedef struct bfd_mach_o_load_command
{
bfd_mach_o_load_command_type type;
unsigned int type_required;
bfd_vma offset;
bfd_vma len;
union
{
bfd_mach_o_segment_command segment;
bfd_mach_o_symtab_command symtab;
bfd_mach_o_dysymtab_command dysymtab;
bfd_mach_o_thread_command thread;
bfd_mach_o_dylib_command dylib;
bfd_mach_o_dylinker_command dylinker;
bfd_mach_o_prebound_dylib_command prebound_dylib;
}
command;
}
bfd_mach_o_load_command;
typedef struct mach_o_data_struct
{
bfd_mach_o_header header;
bfd_mach_o_load_command *commands;
unsigned long nsymbols;
asymbol *symbols;
unsigned long nsects;
bfd_mach_o_section **sections;
bfd *ibfd;
}
mach_o_data_struct;
typedef struct mach_o_data_struct bfd_mach_o_data_struct;
boolean bfd_mach_o_valid PARAMS ((bfd *));
int bfd_mach_o_scan_read_symtab_symbol PARAMS ((bfd *, bfd_mach_o_symtab_command *, asymbol *, unsigned long));
int bfd_mach_o_scan_read_symtab_strtab PARAMS ((bfd *, bfd_mach_o_symtab_command *));
int bfd_mach_o_scan_read_symtab_symbols PARAMS ((bfd *, bfd_mach_o_symtab_command *));
int bfd_mach_o_scan_read_dysymtab_symbol PARAMS ((bfd *, bfd_mach_o_dysymtab_command *, bfd_mach_o_symtab_command *, asymbol *, unsigned long));
int bfd_mach_o_scan_start_address PARAMS ((bfd *));
int bfd_mach_o_scan PARAMS ((bfd *, bfd_mach_o_header *));
boolean bfd_mach_o_mkobject PARAMS ((bfd *));
const bfd_target * bfd_mach_o_object_p PARAMS ((bfd *));
const bfd_target * bfd_mach_o_core_p PARAMS ((bfd *));
const bfd_target * bfd_mach_o_archive_p PARAMS ((bfd *));
bfd * bfd_mach_o_openr_next_archived_file PARAMS ((bfd *, bfd *));
int bfd_mach_o_lookup_section PARAMS ((bfd *, asection *, bfd_mach_o_load_command **, bfd_mach_o_section **));
int bfd_mach_o_lookup_command PARAMS ((bfd *, bfd_mach_o_load_command_type, bfd_mach_o_load_command **));
unsigned long bfd_mach_o_stack_addr PARAMS ((enum bfd_mach_o_cpu_type));
int bfd_mach_o_core_fetch_environment PARAMS ((bfd *, unsigned char **, unsigned int *));
char * bfd_mach_o_core_file_failing_command PARAMS ((bfd *));
int bfd_mach_o_core_file_failing_signal PARAMS ((bfd *));
boolean bfd_mach_o_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
extern const bfd_target mach_o_be_vec;
extern const bfd_target mach_o_le_vec;
extern const bfd_target mach_o_fat_vec;
#endif /* _BFD_MACH_O_H_ */

215
bfd/pef-traceback.h Normal file
View File

@ -0,0 +1,215 @@
/* PowerPC traceback table support for BFD.
Copyright 1993, 1998, 1999, 2000, 2001, 2002
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Originally written by Ira Ruben, 06/28/93 */
/* This is a compiler independent representation of the AIX Version 3 traceback table (in
sys/debug.h), which occurs, usually, one per procedure (routine). The table is marked by
a multiple of 4 32-bit word of zeroes in the instruction space. The traceback table is
also referred to as "procedure-end table".
The AIX traceback table representation on which this header is based is defined as a
series of bit field struct specifications. Bit fields are compiler dependent! Thus,
the definitions presented here follow the original header and the existing documentation
(such as it is), but define the fields as BIT MASKS and other macros. The mask names,
however, where chosen as the original field names to give some compatibility with the
original header and to agree with the documentation. */
#ifndef __TRACEBACK__
#define __TRACEBACK__
#define TB_C 0U /* C */
#define TB_FORTRAN 1U /* FORTRAN */
#define TB_PASCAL 2U /* Pascal */
#define TB_ADA 3U /* ADA */
#define TB_PL1 4U /* PL1 */
#define TB_BASIC 5U /* Basic */
#define TB_LISP 6U /* Lisp */
#define TB_COBOL 7U /* eCobol */
#define TB_MODULA2 8U /* Modula2 */
#define TB_CPLUSPLUS 9U /* C++ */
#define TB_RPG 10U /* RPG */
#define TB_PL8 11U /* PL8 */
#define TB_ASM 12U /* Asm */
/* flags 1 */
#define TB_GLOBALLINK 0x80U /* Routine is Global Linkage. */
#define TB_is_eprol 0x40U /* Out-of-line prolog or epilog routine. */
#define TB_HAS_TBOFF 0x20U /* tb_offset set (extension field). */
#define TB_INT_PROC 0x10U /* Internal leaf routine. */
#define TB_HAS_CTL 0x08U /* Has controlled automatic storage. */
#define TB_TOCLESS 0X04U /* Routine has no TOC. */
#define TB_FP_PRESENT 0x02U /* Routine has floating point ops. */
#define TB_LOG_ABORT 0x01U /* fp_present && log/abort compiler opt. */
/* flags 2 */
#define TB_INT_HNDL 0x80U /* Routine is an interrupt handler. */
#define TB_NAME_PRESENT 0x40U /* Name_len/name set (extension field). */
#define TB_USES_ALLOCA 0x20U /* Uses alloca() to allocate storage. */
#define TB_CL_DIS_inv 0x1CU /* On-condition directives (see below). */
#define TB_SAVES_CR 0x02U /* Routine saves the CR. */
#define TB_SAVES_LR 0x01U /* Routine saves the LR. */
/* cl_dis_inv "on condition" settings: */
#define TB_CL_DIS_INV(x) (((x) & cl_dis_inv) >> 2U)
#define TB_WALK_ONCOND 0U /* Walk stack without restoring state. */
#define TB_DISCARD_ONCOND 1U /* Walk stack and discard. */
#define TB_INVOKE_ONCOND 2U /* Invoke a specific system routine. */
/* flags 3 */
#define TB_STORES_BC 0x80U /* Routine saves frame ptr of caller. */
#define TB_SPARE2 0X40U /* Spare bit. */
#define TB_FPR_SAVED 0x3fU /* Number of FPRs saved (max of 32). */
/* (Last reg saved is ALWAYS fpr31). */
#define TB_NUM_FPR_SAVED(x) ((x) & fpr_saved)
/* flags 4 */
#define TB_HAS_VEC_INFO 0x80U /* Routine uses vectors. */
#define TB_SPARE3 0X40U /* Spare bit. */
#define TB_GPR_SAVED 0x3fU /* Number of GPRs saved (max of 32). */
/* (Last reg saved is ALWAYS gpr31). */
#define TB_NUM_GPR_SAVED(x) ((x) & gpr_saved)
/* flags 5 */
#define TB_FLOATPARAMS 0xfeU /* Number of floating point parameters. */
#define TB_PARAMSONSTK 0X01U /* All parameters are on the stack. */
#define TB_NUM_FLOATPARAMS(X) (((x) & floatparams) >> 1U)
/* traceback_table (fixed portion). */
struct traceback_table
{
/* Traceback table layout (fixed portion): */
unsigned char version; /* Traceback format version. */
unsigned char lang; /* Language indicators: */
unsigned char flags1; /* Flag bits #1: */
unsigned char flags2; /* Flag bits #2: */
unsigned char flags3; /* Flag bits #3: */
unsigned char flags4; /* Flag bits #4: */
unsigned char fixedparams; /* Number of fixed point parameters. */
unsigned char flags5; /* Flag bits #5: */
};
/* traceback_table (optional) extensions. */
/* Optional portions exist independently in the order presented below,
not as a structure or a union. Whether or not portions exist is
determinable from bit-fields within the fixed portion above. */
/* The following is present only if fixedparams or floatparams are non
zero and it immediately follows the fixed portion of the traceback
table... */
/* Order and type encoding of parameters: */
struct traceback_table_fixedparams
{
unsigned long paraminfo;
};
/* Left-justified bit-encoding as follows: */
#define FIXED_PARAM 0 /* '0' ==> fixed param (1 gpr or word). */
#define SPFP_PARAM 2 /* '10' ==> single-precision float param. */
#define DPFP_PARAM 3 /* '11' ==> double-precision float param. */
#define PARAM_ENCODING(x, bit) /* Yields xxx_PARAM as a function of "bit". */ \
((((x)&(1UL<<(31UL-(bit++))))==0UL) /* Values 0:31 (left-to-right). "bit" is */ \
? FIXED_PARAM /* an L-value that's left incremented to */ \
: ((((x)&(1UL<<(31UL-(bit++))))==0)/* the next bit position for the next */ \
? SPFP_PARAM /* parameter. This will be 1 or 2 bit */ \
: DPFP_PARAM)) /* positions later. */
/* The following is present only if has_tboff (in flags1) in fixed part is present... */
/* Offset from start of code to TracebackTbl. */
struct traceback_table_tboff
{
unsigned long tb_offset;
};
/* The following is present only if int_hndl (in flags2) in fixed part is present ... */
/* What interrupts are handled by the routine. */
struct traceback_table_interrupts
{
long hand_mask;
};
/* The following are present only if has_ctl (in flags1) in fixed part is present... */
/* Controlled automatic storage info: */
struct traceback_table_anchors
{
unsigned long ctl_info; /* Number of controlled automatic anchors. */
long ctl_info_disp[1]; /* Array of stack displacements where each. */
}; /* Anchor is located (array STARTS here). */
/* The following are present only if name_present (in flags2) in fixed
part is present... */
/* Routine name: */
struct traceback_table_routine
{
unsigned short name_len; /* Length of name that follows. */
char name[1]; /* Name starts here (NOT null terminated). */
};
/* The following are present only if uses_alloca (in flags2) in fixed
part is present... */
/* Register auto storage when alloca() is used. */
struct traceback_table_alloca
{
char alloca_reg;
};
/* The following are present only if has_vec_info (in flags4) in fixed
part is present... */
/* Vector info: */
struct traceback_table_vector
{
unsigned char vec_flags1; /* Vec info bits #1: */
#define TB_VR_SAVED 0xFCU /* Number of saved vector registers. */
#define TB_SAVES_VRSAVE 0x02U /* Saves VRsave. */
#define TB_HAS_VARARGS 0x01U /* Routine has a variable argument list. */
#define TB_NUM_VR_SAVED(x) (((x) & TB_VR_SAVED) >> 2U)
unsigned char vec_flags2; /* Vec info bits #2: */
#define TB_VECTORPARAMS 0xfeU /* Number of vector parameters. */
#define TB_VEC_PRESENT 0x01U /* Routine uses at least one vec instr. */
#define VECPARAMS(x) (((x) & TB_VECTORPARAMS) >> 1U)
};
#endif

1207
bfd/pef.c Normal file

File diff suppressed because it is too large Load Diff

186
bfd/pef.h Normal file
View File

@ -0,0 +1,186 @@
/* PEF support for BFD.
Copyright 1999, 2000, 2001, 2002
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include <stdio.h>
struct bfd_pef_header
{
unsigned long tag1;
unsigned long tag2;
unsigned long architecture;
unsigned long format_version;
unsigned long timestamp;
unsigned long old_definition_version;
unsigned long old_implementation_version;
unsigned long current_version;
unsigned short section_count;
unsigned short instantiated_section_count;
unsigned long reserved;
};
typedef struct bfd_pef_header bfd_pef_header;
struct bfd_pef_loader_header
{
long main_section;
unsigned long main_offset;
long init_section;
unsigned long init_offset;
long term_section;
unsigned long term_offset;
unsigned long imported_library_count;
unsigned long total_imported_symbol_count;
unsigned long reloc_section_count;
unsigned long reloc_instr_offset;
unsigned long loader_strings_offset;
unsigned long export_hash_offset;
unsigned long export_hash_table_power;
unsigned long exported_symbol_count;
};
typedef struct bfd_pef_loader_header bfd_pef_loader_header;
struct bfd_pef_imported_library
{
unsigned long name_offset;
unsigned long old_implementation_version;
unsigned long current_version;
unsigned long imported_symbol_count;
unsigned long first_imported_symbol;
unsigned char options;
unsigned char reserved_a;
unsigned short reserved_b;
};
typedef struct bfd_pef_imported_library bfd_pef_imported_library;
enum bfd_pef_imported_library_options
{
BFD_PEF_WEAK_IMPORT_LIB = 0x40,
BFD_PEF_INIT_LIB_BEFORE = 0x80
};
struct bfd_pef_imported_symbol
{
unsigned char class;
unsigned long name;
};
typedef struct bfd_pef_imported_symbol bfd_pef_imported_symbol;
enum bfd_pef_imported_symbol_class
{
BFD_PEF_CODE_SYMBOL = 0x00,
BFD_PEF_DATA_SYMBOL = 0x01,
BFD_PEF_TVECTOR_SYMBOL = 0x02,
BFD_PEF_TOC_SYMBOL = 0x03,
BFD_PEF_GLUE_SYMBOL = 0x04,
BFD_PEF_UNDEFINED_SYMBOL = 0x0F,
BFD_PEF_WEAK_IMPORT_SYMBOL_MASK = 0x80
};
#define BFD_PEF_TAG1 0x4A6F7921 /* 'Joy!' */
#define BFD_PEF_TAG2 0x70656666 /* 'peff' */
#define BFD_PEF_VERSION 0x00000001
struct bfd_pef_section
{
long name_offset;
unsigned long header_offset;
unsigned long default_address;
unsigned long total_length;
unsigned long unpacked_length;
unsigned long container_length;
unsigned long container_offset;
unsigned char section_kind;
unsigned char share_kind;
unsigned char alignment;
unsigned char reserved;
asection *bfd_section;
};
typedef struct bfd_pef_section bfd_pef_section;
#define BFD_PEF_SECTION_CODE 0
#define BFD_PEF_SECTION_UNPACKED_DATA 1
#define BFD_PEF_SECTION_PACKED_DATA 2
#define BFD_PEF_SECTION_CONSTANT 3
#define BFD_PEF_SECTION_LOADER 4
#define BFD_PEF_SECTION_DEBUG 5
#define BFD_PEF_SECTION_EXEC_DATA 6
#define BFD_PEF_SECTION_EXCEPTION 7
#define BFD_PEF_SECTION_TRACEBACK 8
#define BFD_PEF_SHARE_PROCESS 1
#define BFD_PEF_SHARE_GLOBAL 4
#define BFD_PEF_SHARE_PROTECTED 5
struct bfd_pef_data_struct
{
bfd_pef_header header;
bfd_pef_section *sections;
bfd *ibfd;
};
typedef struct bfd_pef_data_struct bfd_pef_data_struct;
#define BFD_PEF_XLIB_TAG1 0xF04D6163 /* '?Mac' */
#define BFD_PEF_VLIB_TAG2 0x564C6962 /* 'VLib' */
#define BFD_PEF_BLIB_TAG2 0x424C6962 /* 'BLib' */
#define BFD_PEF_XLIB_VERSION 0x00000001
struct bfd_pef_xlib_header
{
unsigned long tag1;
unsigned long tag2;
unsigned long current_format;
unsigned long container_strings_offset;
unsigned long export_hash_offset;
unsigned long export_key_offset;
unsigned long export_symbol_offset;
unsigned long export_names_offset;
unsigned long export_hash_table_power;
unsigned long exported_symbol_count;
unsigned long frag_name_offset;
unsigned long frag_name_length;
unsigned long dylib_path_offset;
unsigned long dylib_path_length;
unsigned long cpu_family;
unsigned long cpu_model;
unsigned long date_time_stamp;
unsigned long current_version;
unsigned long old_definition_version;
unsigned long old_implementation_version;
};
typedef struct bfd_pef_xlib_header bfd_pef_xlib_header;
struct bfd_pef_xlib_data_struct
{
bfd_pef_xlib_header header;
};
typedef struct bfd_pef_xlib_data_struct bfd_pef_xlib_data_struct;
int bfd_pef_parse_loader_header PARAMS ((bfd *, unsigned char *, size_t, bfd_pef_loader_header *));
int bfd_pef_print_loader_section PARAMS ((bfd *, FILE *));
void bfd_pef_print_loader_header PARAMS ((bfd *, bfd_pef_loader_header *, FILE *));
int bfd_pef_parse_imported_library PARAMS ((bfd *, unsigned char *, size_t, bfd_pef_imported_library *));
int bfd_pef_parse_imported_symbol PARAMS ((bfd *, unsigned char *, size_t, bfd_pef_imported_symbol *));
int bfd_pef_scan_section PARAMS ((bfd *, bfd_pef_section *));
int bfd_pef_scan_start_address PARAMS ((bfd *));
int bfd_pef_scan PARAMS ((bfd *, bfd_pef_header *));

View File

@ -4,21 +4,21 @@
Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
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 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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
@ -155,7 +155,11 @@ DESCRIPTION
. bfd_target_msdos_flavour,
. bfd_target_ovax_flavour,
. bfd_target_evax_flavour,
. bfd_target_mmo_flavour
. bfd_target_mmo_flavour,
. bfd_target_mach_o_flavour,
. bfd_target_pef_flavour,
. bfd_target_pef_xlib_flavour,
. bfd_target_sym_flavour
.};
.
.enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
@ -645,6 +649,9 @@ extern const bfd_target m68knetbsd_vec;
extern const bfd_target m68ksysvcoff_vec;
extern const bfd_target m88kbcs_vec;
extern const bfd_target m88kmach3_vec;
extern const bfd_target mach_o_be_vec;
extern const bfd_target mach_o_le_vec;
extern const bfd_target mach_o_fat_vec;
extern const bfd_target mcore_pe_big_vec;
extern const bfd_target mcore_pe_little_vec;
extern const bfd_target mcore_pei_big_vec;
@ -661,6 +668,8 @@ extern const bfd_target or32coff_big_vec;
extern const bfd_target pc532machaout_vec;
extern const bfd_target pc532netbsd_vec;
extern const bfd_target pdp11_aout_vec;
extern const bfd_target pef_vec;
extern const bfd_target pef_xlib_vec;
extern const bfd_target pmac_xcoff_vec;
extern const bfd_target ppcboot_vec;
extern const bfd_target riscix_vec;
@ -680,6 +689,7 @@ extern const bfd_target sparclynx_aout_vec;
extern const bfd_target sparclynx_coff_vec;
extern const bfd_target sparcnetbsd_vec;
extern const bfd_target sunos_big_vec;
extern const bfd_target sym_vec;
extern const bfd_target tic30_aout_vec;
extern const bfd_target tic30_coff_vec;
extern const bfd_target tic4x_coff0_beh_vec;
@ -957,6 +967,9 @@ static const bfd_target * const _bfd_target_vector[] = {
&m68ksysvcoff_vec,
&m88kbcs_vec,
&m88kmach3_vec,
&mach_o_be_vec,
&mach_o_le_vec,
&mach_o_fat_vec,
&mcore_pe_big_vec,
&mcore_pe_little_vec,
&mcore_pei_big_vec,
@ -984,6 +997,8 @@ static const bfd_target * const _bfd_target_vector[] = {
&pc532machaout_vec,
&pc532netbsd_vec,
&pdp11_aout_vec,
&pef_vec,
&pef_xlib_vec,
#if 0
/* This has the same magic number as RS/6000. */
&pmac_xcoff_vec,
@ -1013,6 +1028,7 @@ static const bfd_target * const _bfd_target_vector[] = {
&sparclynx_coff_vec,
&sparcnetbsd_vec,
&sunos_big_vec,
&sym_vec,
&tic30_aout_vec,
&tic30_coff_vec,
&tic54x_coff0_beh_vec,

2449
bfd/xsym.c Normal file

File diff suppressed because it is too large Load Diff

699
bfd/xsym.h Normal file
View File

@ -0,0 +1,699 @@
/* xSYM symbol-file support for BFD.
Copyright 1999, 2000, 2001, 2002
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include <stdio.h>
#ifndef __xSYM_H__
#define __xSYM_H__
#define BFD_SYM_VERSION_STR_3_1 "\013Version 3.1"
#define BFD_SYM_VERSION_STR_3_2 "\013Version 3.2"
#define BFD_SYM_VERSION_STR_3_3 "\013Version 3.3"
#define BFD_SYM_VERSION_STR_3_4 "\013Version 3.4"
#define BFD_SYM_VERSION_STR_3_5 "\013Version 3.5"
#define BFD_SYM_END_OF_LIST_3_2 0xffff
#define BFD_SYM_END_OF_LIST_3_4 0xffffffff
#define BFD_SYM_END_OF_LIST BFD_SYM_END_OF_LIST_3_4
#define BFD_SYM_FILE_NAME_INDEX_3_2 0xfffe
#define BFD_SYM_FILE_NAME_INDEX_3_4 0xfffffffe
#define BFD_SYM_FILE_NAME_INDEX BFD_SYM_FILE_NAME_INDEX_3_4
#define BFD_SYM_SOURCE_FILE_CHANGE_3_2 0xfffe
#define BFD_SYM_SOURCE_FILE_CHANGE_3_4 0xfffffffe
#define BFD_SYM_SOURCE_FILE_CHANGE BFD_SYM_SOURCE_FILE_CHANGE_3_4
#define BFD_SYM_MAXIMUM_LEGAL_INDEX_3_2 0xfffd
#define BFD_SYM_MAXIMUM_LEGAL_INDEX_3_4 0xfffffffd
#define BFD_SYM_MAXIMUM_LEGAL_INDEX BFD_SYM_MAXIMUM_LEGAL_INDEX_3_4
enum bfd_sym_storage_class
{
BFD_SYM_STORAGE_CLASS_REGISTER = 0,
BFD_SYM_STORAGE_CLASS_GLOBAL = 1,
BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE = 2,
BFD_SYM_STORAGE_CLASS_STACK_RELATIVE = 3,
BFD_SYM_STORAGE_CLASS_ABSOLUTE = 4,
BFD_SYM_STORAGE_CLASS_CONSTANT = 5,
BFD_SYM_STORAGE_CLASS_BIGCONSTANT = 6,
BFD_SYM_STORAGE_CLASS_RESOURCE = 99
};
typedef enum bfd_sym_storage_class bfd_sym_storage_class;
enum bfd_sym_storage_kind
{
BFD_SYM_STORAGE_KIND_LOCAL = 0,
BFD_SYM_STORAGE_KIND_VALUE = 1,
BFD_SYM_STORAGE_KIND_REFERENCE = 2,
BFD_SYM_STORAGE_KIND_WITH = 3
};
typedef enum bfd_sym_storage_kind bfd_sym_storage_kind;
enum bfd_sym_version
{
BFD_SYM_VERSION_3_1,
BFD_SYM_VERSION_3_2,
BFD_SYM_VERSION_3_3,
BFD_SYM_VERSION_3_4,
BFD_SYM_VERSION_3_5
};
typedef enum bfd_sym_version bfd_sym_version;
enum bfd_sym_module_kind
{
BFD_SYM_MODULE_KIND_NONE = 0,
BFD_SYM_MODULE_KIND_PROGRAM = 1,
BFD_SYM_MODULE_KIND_UNIT = 2,
BFD_SYM_MODULE_KIND_PROCEDURE = 3,
BFD_SYM_MODULE_KIND_FUNCTION = 4,
BFD_SYM_MODULE_KIND_DATA = 5,
BFD_SYM_MODULE_KIND_BLOCK = 6
};
typedef enum bfd_sym_module_kind bfd_sym_module_kind;
enum bfd_sym_symbol_scope
{
BFD_SYM_SYMBOL_SCOPE_LOCAL = 0, /* Object is seen only inside current scope. */
BFD_SYM_SYMBOL_SCOPE_GLOBAL = 1 /* Object has global scope. */
};
typedef enum bfd_sym_symbol_scope bfd_sym_symbol_scope;
struct bfd_sym_file_reference
{
unsigned long fref_frte_index; /* File reference table index. */
unsigned long fref_offset; /* Absolute offset into source file. */
};
typedef struct bfd_sym_file_reference bfd_sym_file_reference;
/* NAME TABLE (NTE). */
/* RESOURCES TABLE (RTE)
All code and data is *defined* to reside in a resource. Even A5
relative data is defined to reside in a dummy resource of ResType
'gbld'. Code always resides in a resource. Because a code/data
is built of many modules, when walking through a resource we must
point back to the modules in the order they were defined. This is
done by requiring the entries in the Modules Entry table to be
ordered by resource/resource-number and by the location in that
resource. Hence, the resource table entry points to the first
module making up that resource. All modules table entries following
that first one with the same restype/resnum are contiguous and offset
from that first entry. */
struct bfd_sym_resources_table_entry
{
unsigned char rte_res_type[4]; /* Resource Type. */
unsigned short rte_res_number; /* Resource Number. */
unsigned long rte_nte_index; /* Name of the resource. */
unsigned long rte_mte_first; /* Index of first module in the resource. */
unsigned long rte_mte_last; /* Index of the last module in the resource. */
unsigned long rte_res_size; /* Size of the resource. */
};
typedef struct bfd_sym_resources_table_entry bfd_sym_resources_table_entry;
/* MODULES TABLE (MTE)
Modules table entries are ordered by their appearance in a resource.
(Note that having a single module copied into two resources is not
possible). Modules map back to their resource via an index into the
resource table and an offset into the resource. Modules also point
to their source files, both the definition module and implemention
module. Because modules can be textually nested within other
modules, a link to the parent (containing) module is required. This
module can textually contain other modules. A link to the contiguous
list of child (contained) modules is required. Variables, statements,
and types defined in the module are pointed to by indexing the head of
the contiguous lists of contained variables, contained statements,
and contained types. */
struct bfd_sym_modules_table_entry
{
unsigned long mte_rte_index; /* Which resource it is in. */
unsigned long mte_res_offset; /* Offset into the resource. */
unsigned long mte_size; /* Size of module. */
char mte_kind; /* What kind of module this is. */
char mte_scope; /* How visible is it? */
unsigned long mte_parent; /* Containing module. */
bfd_sym_file_reference mte_imp_fref; /* Implementation source. */
unsigned long mte_imp_end; /* End of implementation source. */
unsigned long mte_nte_index; /* The name of the module. */
unsigned long mte_cmte_index; /* Modules contained in this. */
unsigned long mte_cvte_index; /* Variables contained in this. */
unsigned long mte_clte_index; /* Local labels defined here. */
unsigned long mte_ctte_index; /* Types contained in this. */
unsigned long mte_csnte_idx_1; /* CSNTE index of mte_snbr_first. */
unsigned long mte_csnte_idx_2; /* CSNTE index of mte_snbr_last. */
};
typedef struct bfd_sym_modules_table_entry bfd_sym_modules_table_entry;
/* FILE REFERENCES TABLE (FRTE)
The FILE REFERENCES TABLE maps from source file to module & offset.
The table is ordered by increasing file offset. Each new offset
references a module.
FRT = FILE_SOURCE_START
FILE_SOURCE_INCREMENT*
END_OF_LIST.
*** THIS MECHANISM IS VERY SLOW FOR FILE+STATEMENT_NUMBER TO
*** MODULE/CODE ADDRESS OPERATIONS. ANOTHER MECHANISM IS
*** REQUIRED!! */
union bfd_sym_file_references_table_entry
{
struct
{
/* END_OF_LIST, FILE_NAME_INDEX, or module table entry. */
unsigned long type;
}
generic;
struct
{
/* FILE_NAME_INDEX. */
unsigned long type;
unsigned long nte_index;
unsigned long mod_date;
}
filename;
struct
{
/* < FILE_NAME_INDEX. */
unsigned long mte_index;
unsigned long file_offset;
}
entry;
};
typedef union bfd_sym_file_references_table_entry bfd_sym_file_references_table_entry;
/* CONTAINED MODULES TABLE (CMTE)
Contained Modules are lists of indices into the modules table. The
lists are terminated by an END_OF_LIST index. All entries are of the
same size, hence mapping an index into a CMTE list is simple.
CMT = MTE_INDEX* END_OF_LIST. */
union bfd_sym_contained_modules_table_entry
{
struct
{
/* END_OF_LIST, index. */
unsigned long type;
}
generic;
struct
{
unsigned long mte_index; /* Index into the Modules Table. */
unsigned long nte_index; /* The name of the module. */
}
entry;
};
typedef union bfd_sym_contained_modules_table_entry bfd_sym_contained_modules_table_entry;
/* CONTAINED VARIABLES TABLE (CVTE)
Contained Variables map into the module table, file table, name table, and type
table. Contained Variables are a contiguous list of source file change record,
giving the name of and offset into the source file corresponding to all variables
following. Variable definition records contain an index into the name table (giving
the text of the variable as it appears in the source code), an index into the type
table giving the type of the variable, an increment added to the source file
offset giving the start of the implementation of the variable, and a storage
class address, giving information on variable's runtime address.
CVT = SOURCE_FILE_CHANGE SYMBOL_INFO* END_OF_LIST.
SYMBOL_INFO = SYMBOL_DEFINITION | SOURCE_FILE_CHANGE .
All entries are of the same size, making the fetching of data simple. The
variable entries in the list are in ALPHABETICAL ORDER to simplify the display of
available variables for several of the debugger's windows. */
/* 'la_size' determines the variant used below:
== BFD_SYM_CVTE_SCA
Traditional STORAGE_CLASS_ADDRESS;
<= BFD_SYM_CVTE_LA_MAX_SIZE
That many logical address bytes ("in-situ");
== BFD_SYM_CVTE_BIG_LA
Logical address bytes in constant pool, at offset 'big_la'. */
#define BFD_SYM_CVTE_SCA 0 /* Indicate SCA variant of CVTE. */
#define BFD_SYM_CVTE_LA_MAX_SIZE 13 /* Max# of logical address bytes in a CVTE. */
#define BFD_SYM_CVTE_BIG_LA 127 /* Indicates LA redirection to constant pool. */
union bfd_sym_contained_variables_table_entry
{
struct
{
/* END_OF_LIST, SOURCE_FILE_CHANGE, or type table entry. */
unsigned long type;
}
generic;
struct
{
/* SOURCE_FILE_CHANGE. */
unsigned long type;
bfd_sym_file_reference fref;
}
file;
struct
{
/* < SOURCE_FILE_CHANGE. */
unsigned long tte_index;
unsigned long nte_index;
unsigned long file_delta; /* Increment from previous source. */
unsigned char scope;
unsigned char la_size; /* #bytes of LAs below. */
union
{
/* la_size == BFD_SYM_CVTE_SCA. */
struct
{
unsigned char sca_kind; /* Distinguish local from value/var formal. */
unsigned char sca_class; /* The storage class itself. */
unsigned long sca_offset;
}
scstruct;
/* la_size <= BFD_SYM_CVTE_LA_MAX_SIZE. */
struct {
unsigned char la[BFD_SYM_CVTE_LA_MAX_SIZE]; /* Logical address bytes. */
unsigned char la_kind; /* Eqv. cvte_location.sca_kind. */
}
lastruct;
/* la_size == BFD_SYM_CVTE_BIG_LA 127. */
struct
{
unsigned long big_la; /* Logical address bytes in constant pool. */
unsigned char big_la_kind; /* Eqv. cvte_location.sca_kind. */
}
biglastruct;
}
address;
}
entry;
};
typedef union bfd_sym_contained_variables_table_entry bfd_sym_contained_variables_table_entry;
/* CONTAINED STATEMENTS TABLE (CSNTE)
Contained Statements table. This table is similar to the Contained
Variables table except that instead of VARIABLE_DEFINITION entries, this
module contains STATEMENT_NUMBER_DEFINITION entries. A statement number
definition points back to the containing module (via an index into
the module entry table) and contains the file and resource deltas
to add to the previous values to get to this statement.
All entries are of the same size, making the fetching of data simple. The
entries in the table are in order of increasing statement number within the
source file.
The Contained Statements table is indexed from two places. An MTE contains
an index to the first statement number within the module. An FRTE contains
an index to the first statement in the table (Possibly. This is slow.) Or
a table of fast statement number to CSNTE entry mappings indexes into the
table. Choice not yet made. */
union bfd_sym_contained_statements_table_entry
{
struct
{
/* END_OF_LIST, SOURCE_FILE_CHANGE, or statement table entry. */
unsigned long type;
}
generic;
struct
{
/* SOURCE_FILE_CHANGE. */
unsigned long type;
bfd_sym_file_reference fref; /* File name table. */
}
file;
struct
{
unsigned long mte_index; /* Which module contains it. */
unsigned long file_delta; /* Where it is defined. */
unsigned long mte_offset; /* Where it is in the module. */
}
entry;
};
typedef union bfd_sym_contained_statements_table_entry bfd_sym_contained_statements_table_entry;
/* CONTAINED LABELS TABLE (CLTE)
Contained Labels table names those labels local to the module. It is similar
to the Contained Statements table. */
union bfd_sym_contained_labels_table_entry
{
struct
{
/* END_OF_LIST, SOURCE_FILE_CHANGE, index. */
unsigned long type;
}
generic;
struct
{
/* SOURCE_FILE_CHANGE. */
unsigned long type;
bfd_sym_file_reference fref;
}
file;
struct
{
/* < SOURCE_FILE_CHANGE. */
unsigned long mte_index; /* Which module contains us. */
unsigned long mte_offset; /* Where it is in the module. */
unsigned long nte_index; /* The name of the label. */
unsigned long file_delta; /* Where it is defined. */
unsigned short scope; /* How visible the label is. */
}
entry;
};
typedef union bfd_sym_contained_labels_table_entry bfd_sym_contained_labels_table_entry;
/* CONTAINED TYPES TABLE (CTTE)
Contained Types define the named types that are in the module. It is used to
map name indices into type indices. The type entries in the table are in
alphabetical order by type name. */
union bfd_sym_contained_types_table_entry
{
struct
{
/* END_OF_LIST, SOURCE_FILE_CHANGE, or type table entry. */
unsigned long type;
}
generic;
struct
{
/* SOURCE_FILE_CHANGE. */
unsigned long type;
bfd_sym_file_reference fref;
}
file;
struct
{
/* < SOURCE_FILE_CHANGE. */
unsigned long tte_index;
unsigned long nte_index;
unsigned long file_delta; /* From last file definition. */
}
entry;
};
typedef union bfd_sym_contained_types_table_entry bfd_sym_contained_types_table_entry;
/* TYPE TABLE (TTE). */
typedef unsigned long bfd_sym_type_table_entry;
/* TYPE INFORMATION TABLE (TINFO). */
struct bfd_sym_type_information_table_entry
{
unsigned long nte_index;
unsigned long physical_size;
unsigned long logical_size;
unsigned long offset;
};
typedef struct bfd_sym_type_information_table_entry bfd_sym_type_information_table_entry;
/* FILE REFERENCES INDEX TABLE (FITE)
The FRTE INDEX TABLE indexes into the FILE REFERENCE TABLE above. The FRTE
at that index is the FILE_SOURCE_START for a series of files. The FRTEs are
indexed from 1. The list is terminated with an END_OF_LIST. */
union bfd_sym_file_references_index_table_entry
{
struct
{
unsigned long type;
}
generic;
struct
{
unsigned long frte_index; /* Index into the FRTE table. */
unsigned long nte_index; /* Name table index, gives filename. */
}
entry;
};
typedef union bfd_sym_file_references_index_table_entry bfd_sym_file_references_index_table_entry;
/* CONSTANT POOL (CONST)
The CONSTANT_POOL consists of entries that start on word boundaries. The entries
are referenced by byte index into the constant pool, not by record number.
Each entry takes the form:
<16-bit size>
<that many bytes of stuff>
Entries do not cross page boundaries. */
typedef short bfd_sym_constant_pool_entry;
/* The DISK_SYMBOL_HEADER_BLOCK is the first record in a .SYM file,
defining the physical characteristics of the symbolic information.
The remainder of the * .SYM file is stored in fixed block
allocations. For the purposes of paging, the * file is considered
to be an array of dshb_page_size blocks, with block 0 (and *
possibly more) devoted to the DISK_SYMBOL_HEADER_BLOCK.
The dti_object_count field means that the allowed indices for that
type of object are 0 .. dti_object_count. An index of 0, although
allowed, is never done. However, an 0th entry is created in the
table. That entry is filled with all zeroes. The reason for this
is to avoid off-by-one programming errors that would otherwise
occur: an index of k *MEANS* k, not k-1 when going to the disk
table. */
struct bfd_sym_table_info
{
unsigned long dti_first_page; /* First page for this table. */
unsigned long dti_page_count; /* Number of pages for the table. */
unsigned long dti_object_count; /* Number of objects in the table. */
};
typedef struct bfd_sym_table_info bfd_sym_table_info;
struct bfd_sym_header_block
{
unsigned char dshb_id[32]; /* Version information. */
unsigned short dshb_page_size; /* Size of the pages/blocks. */
unsigned long dshb_hash_page; /* Disk page for the hash table. */
unsigned long dshb_root_mte; /* MTE index of the program root. */
unsigned long dshb_mod_date; /* modification date of executable. */
bfd_sym_table_info dshb_frte; /* Per TABLE information. */
bfd_sym_table_info dshb_rte;
bfd_sym_table_info dshb_mte;
bfd_sym_table_info dshb_cmte;
bfd_sym_table_info dshb_cvte;
bfd_sym_table_info dshb_csnte;
bfd_sym_table_info dshb_clte;
bfd_sym_table_info dshb_ctte;
bfd_sym_table_info dshb_tte;
bfd_sym_table_info dshb_nte;
bfd_sym_table_info dshb_tinfo;
bfd_sym_table_info dshb_fite; /* File information. */
bfd_sym_table_info dshb_const; /* Constant pool. */
unsigned char dshb_file_creator[4]; /* Executable's creator. */
unsigned char dshb_file_type[4]; /* Executable's file type. */
};
typedef struct bfd_sym_header_block bfd_sym_header_block;
struct bfd_sym_data_struct
{
unsigned char *name_table;
bfd_sym_header_block header;
bfd_sym_version version;
bfd *sbfd;
};
typedef struct bfd_sym_data_struct bfd_sym_data_struct;
extern boolean bfd_sym_mkobject
PARAMS ((bfd *));
extern void bfd_sym_print_symbol
PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
extern boolean bfd_sym_valid
PARAMS ((bfd *));
extern unsigned char * bfd_sym_read_name_table
PARAMS ((bfd *, bfd_sym_header_block *));
extern void bfd_sym_parse_file_reference_v32
PARAMS ((unsigned char *, size_t, bfd_sym_file_reference *));
extern void bfd_sym_parse_disk_table_v32
PARAMS ((unsigned char *, size_t, bfd_sym_table_info *));
extern void bfd_sym_parse_header_v32
PARAMS ((unsigned char *, size_t, bfd_sym_header_block *));
extern int bfd_sym_read_header_v32
PARAMS ((bfd *, bfd_sym_header_block *));
extern int bfd_sym_read_header_v34
PARAMS ((bfd *, bfd_sym_header_block *));
extern int bfd_sym_read_header
PARAMS ((bfd *, bfd_sym_header_block *, bfd_sym_version));
extern int bfd_sym_read_version
PARAMS ((bfd *, bfd_sym_version *));
extern void bfd_sym_display_table_summary
PARAMS ((FILE *, bfd_sym_table_info *, const char *));
extern void bfd_sym_display_header
PARAMS ((FILE *, bfd_sym_header_block *));
extern void bfd_sym_parse_resources_table_entry_v32
PARAMS ((unsigned char *, size_t, bfd_sym_resources_table_entry *));
extern void bfd_sym_parse_modules_table_entry_v33
PARAMS ((unsigned char *, size_t, bfd_sym_modules_table_entry *));
extern void bfd_sym_parse_file_references_table_entry_v32
PARAMS ((unsigned char *, size_t, bfd_sym_file_references_table_entry *));
extern void bfd_sym_parse_contained_modules_table_entry_v32
PARAMS ((unsigned char *, size_t, bfd_sym_contained_modules_table_entry *));
extern void bfd_sym_parse_contained_variables_table_entry_v32
PARAMS ((unsigned char *, size_t, bfd_sym_contained_variables_table_entry *));
extern void bfd_sym_parse_contained_statements_table_entry_v32
PARAMS ((unsigned char *, size_t, bfd_sym_contained_statements_table_entry *));
extern void bfd_sym_parse_contained_labels_table_entry_v32
PARAMS ((unsigned char *, size_t, bfd_sym_contained_labels_table_entry *));
extern void bfd_sym_parse_type_table_entry_v32
PARAMS ((unsigned char *, size_t, bfd_sym_type_table_entry *));
extern int bfd_sym_fetch_resources_table_entry
PARAMS ((bfd *, bfd_sym_resources_table_entry *, unsigned long));
extern int bfd_sym_fetch_modules_table_entry
PARAMS ((bfd *, bfd_sym_modules_table_entry *, unsigned long));
extern int bfd_sym_fetch_file_references_table_entry
PARAMS ((bfd *, bfd_sym_file_references_table_entry *, unsigned long));
extern int bfd_sym_fetch_contained_modules_table_entry
PARAMS ((bfd *, bfd_sym_contained_modules_table_entry *, unsigned long));
extern int bfd_sym_fetch_contained_variables_table_entry
PARAMS ((bfd *, bfd_sym_contained_variables_table_entry *, unsigned long));
extern int bfd_sym_fetch_contained_statements_table_entry
PARAMS ((bfd *, bfd_sym_contained_statements_table_entry *, unsigned long));
extern int bfd_sym_fetch_contained_labels_table_entry
PARAMS ((bfd *, bfd_sym_contained_labels_table_entry *, unsigned long));
extern int bfd_sym_fetch_contained_types_table_entry
PARAMS ((bfd *, bfd_sym_contained_types_table_entry *, unsigned long));
extern int bfd_sym_fetch_file_references_index_table_entry
PARAMS ((bfd *, bfd_sym_file_references_index_table_entry *, unsigned long));
extern int bfd_sym_fetch_constant_pool_entry
PARAMS ((bfd *, bfd_sym_constant_pool_entry *, unsigned long));
extern int bfd_sym_fetch_type_table_entry
PARAMS ((bfd *, bfd_sym_type_table_entry *, unsigned long));
extern int bfd_sym_fetch_type_information_table_entry
PARAMS ((bfd *, bfd_sym_type_information_table_entry *, unsigned long));
extern int bfd_sym_fetch_type_table_information
PARAMS ((bfd *, bfd_sym_type_information_table_entry *, unsigned long));
extern const unsigned char * bfd_sym_symbol_name
PARAMS ((bfd *, unsigned long));
extern const unsigned char * bfd_sym_module_name
PARAMS ((bfd *, unsigned long));
extern const char * bfd_sym_unparse_storage_kind
PARAMS ((enum bfd_sym_storage_kind));
extern const char * bfd_sym_unparse_storage_class
PARAMS ((enum bfd_sym_storage_class));
extern const char * bfd_sym_unparse_module_kind
PARAMS ((enum bfd_sym_module_kind));
extern const char * bfd_sym_unparse_symbol_scope
PARAMS ((enum bfd_sym_symbol_scope));
extern void bfd_sym_print_file_reference
PARAMS ((bfd *, FILE *, bfd_sym_file_reference *));
extern void bfd_sym_print_resources_table_entry
PARAMS ((bfd *, FILE *, bfd_sym_resources_table_entry *));
extern void bfd_sym_print_modules_table_entry
PARAMS ((bfd *, FILE *, bfd_sym_modules_table_entry *));
extern void bfd_sym_print_file_references_table_entry
PARAMS ((bfd *, FILE *, bfd_sym_file_references_table_entry *));
extern void bfd_sym_print_contained_modules_table_entry
PARAMS ((bfd *, FILE *, bfd_sym_contained_modules_table_entry *));
extern void bfd_sym_print_contained_variables_table_entry
PARAMS ((bfd *, FILE *f, bfd_sym_contained_variables_table_entry *));
extern void bfd_sym_print_contained_statements_table_entry
PARAMS ((bfd *, FILE *, bfd_sym_contained_statements_table_entry *));
extern void bfd_sym_print_contained_labels_table_entry
PARAMS ((bfd *, FILE *, bfd_sym_contained_labels_table_entry *));
extern void bfd_sym_print_contained_types_table_entry
PARAMS ((bfd *, FILE *, bfd_sym_contained_types_table_entry *));
extern const char * bfd_sym_type_operator_name
PARAMS ((unsigned char));
extern const char * bfd_sym_type_basic_name
PARAMS ((unsigned char));
extern int bfd_sym_fetch_long
PARAMS ((unsigned char *, unsigned long, unsigned long, unsigned long *, long *));
extern void bfd_sym_print_type_information
PARAMS ((bfd *, FILE *, unsigned char *, unsigned long, unsigned long, unsigned long *));
extern void bfd_sym_print_type_information_table_entry
PARAMS ((bfd *, FILE *, bfd_sym_type_information_table_entry *));
extern void bfd_sym_print_file_references_index_table_entry
PARAMS ((bfd *, FILE *, bfd_sym_file_references_index_table_entry *));
extern void bfd_sym_print_constant_pool_entry
PARAMS ((bfd *, FILE *, bfd_sym_constant_pool_entry *));
extern unsigned char * bfd_sym_display_name_table_entry
PARAMS ((bfd *, FILE *, unsigned char *));
extern void bfd_sym_display_name_table
PARAMS ((bfd *, FILE *));
extern void bfd_sym_display_resources_table
PARAMS ((bfd *, FILE *));
extern void bfd_sym_display_modules_table
PARAMS ((bfd *, FILE *));
extern void bfd_sym_display_file_references_table
PARAMS ((bfd *, FILE *));
extern void bfd_sym_display_contained_modules_table
PARAMS ((bfd *, FILE *));
extern void bfd_sym_display_contained_variables_table
PARAMS ((bfd *, FILE *));
extern void bfd_sym_display_contained_statements_table
PARAMS ((bfd *, FILE *));
extern void bfd_sym_display_contained_labels_table
PARAMS ((bfd *, FILE *));
extern void bfd_sym_display_contained_types_table
PARAMS ((bfd *, FILE *));
extern void bfd_sym_display_file_references_index_table
PARAMS ((bfd *, FILE *));
extern void bfd_sym_display_constant_pool
PARAMS ((bfd *, FILE *));
extern void bfd_sym_display_type_information_table
PARAMS ((bfd *, FILE *));
extern const bfd_target * bfd_sym_object_p
PARAMS ((bfd *));
extern asymbol * bfd_sym_make_empty_symbol
PARAMS ((bfd *));
extern void bfd_sym_get_symbol_info
PARAMS ((bfd *, asymbol *, symbol_info *));
extern long bfd_sym_get_symtab_upper_bound
PARAMS ((bfd *));
extern long bfd_sym_get_symtab
PARAMS ((bfd *, asymbol **));
extern int bfd_sym_sizeof_headers
PARAMS ((bfd *, boolean));
#endif /* __xSYM_H__ */