diff options
-rwxr-xr-x | include/a.out.sun4.h | 19 | ||||
-rwxr-xr-x | include/a.out.vax.h | 20 | ||||
-rwxr-xr-x | include/ar.h | 24 | ||||
-rwxr-xr-x | include/bcs88kcoff.h | 296 | ||||
-rw-r--r-- | include/bfd.h | 855 | ||||
-rw-r--r-- | include/bout.h | 168 | ||||
-rwxr-xr-x | include/coff-i960.h | 414 | ||||
-rwxr-xr-x | include/coff-m88k.h | 298 | ||||
-rw-r--r-- | include/ieee.h | 128 | ||||
-rw-r--r-- | include/oasys.h | 117 | ||||
-rw-r--r-- | include/obstack.h | 416 | ||||
-rwxr-xr-x | include/reloc.h | 38 | ||||
-rwxr-xr-x | include/sysdep.h | 110 |
13 files changed, 2903 insertions, 0 deletions
diff --git a/include/a.out.sun4.h b/include/a.out.sun4.h new file mode 100755 index 0000000..0c89c2a --- /dev/null +++ b/include/a.out.sun4.h @@ -0,0 +1,19 @@ +/* SPARC-specific values for a.out files */ + +#define PAGE_SIZE 0x02000 /* 8K. aka NBPG in <sys/param.h> */ +/* Note that some SPARCs have 4K pages, some 8K, some others. */ +#define SEGMENT_SIZE PAGE_SIZE +#define TEXT_START_ADDR PAGE_SIZE /* Location 0 is not accessible */ + +#define N_BADMAG(x) \ + (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ + && N_MAGIC(x) != ZMAGIC) + + +#define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? 0 : sizeof(struct exec) ) +#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text ) +#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data ) +#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize ) +#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize ) +#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms ) + diff --git a/include/a.out.vax.h b/include/a.out.vax.h new file mode 100755 index 0000000..4ece018 --- /dev/null +++ b/include/a.out.vax.h @@ -0,0 +1,20 @@ +/* VAX-specific definitions for a.out file header fields. */ + +#define PAGE_SIZE 512 /* aka NBPG in <sys/param.h> */ +#define SEGMENT_SIZE PAGE_SIZE /* rounding between text/data ??! */ +#define TEXT_START_ADDR 0 /* Text start address: see + <machine/vmparam.h> USRTEXT. */ +#define STACK_END_ADDR 0x80000000-(14+14)*PAGE_SIZE /* see + <machine/vmparam.h> USRSTACK. */ + +#define N_BADMAG(x) \ + (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ + && N_MAGIC(x) != ZMAGIC) + + +#define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? 1024 : EXEC_BYTES_SIZE ) +#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text ) +#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data ) +#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize ) +#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize ) +#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms ) diff --git a/include/ar.h b/include/ar.h new file mode 100755 index 0000000..2bca46d --- /dev/null +++ b/include/ar.h @@ -0,0 +1,24 @@ +/* archive file definition for GNU software */ + +/* So far this is correct for BSDish archives. Don't forget that + files must begin on an even byte boundary. */ + +#ifndef __GNU_AR_H__ +#define __GNU_AR_H__ + +#define ARMAG "!<arch>\n" /* For COFF and a.out archives */ +#define ARMAGB "!<bout>\n" /* For b.out archives */ +#define SARMAG 8 +#define ARFMAG "`\n" + +struct ar_hdr { + char ar_name[16]; /* name of this member */ + char ar_date[12]; /* file mtime */ + char ar_uid[6]; /* owner uid; printed as decimal */ + char ar_gid[6]; /* owner gid; printed as decimal */ + char ar_mode[8]; /* file mode, printed as octal */ + char ar_size[10]; /* file size, printed as decimal */ + char ar_fmag[2]; /* should contain ARFMAG */ +}; + +#endif /* __GNU_AR_H__ */ diff --git a/include/bcs88kcoff.h b/include/bcs88kcoff.h new file mode 100755 index 0000000..ca7ef83 --- /dev/null +++ b/include/bcs88kcoff.h @@ -0,0 +1,296 @@ +/*** coff information for 88k bcs */ + +/********************** FILE HEADER **********************/ + +struct filehdr { + unsigned short f_magic; /* magic number */ + unsigned short f_nscns; /* number of sections */ + long f_timdat; /* time & date stamp */ + long f_symptr; /* file pointer to symtab */ + long f_nsyms; /* number of symtab entries */ + unsigned short f_opthdr; /* sizeof(optional hdr) */ + unsigned short f_flags; /* flags */ +}; + +/* Bits for f_flags: + * F_RELFLG relocation info stripped from file + * F_EXEC file is executable (no unresolved externel references) + * F_LNNO line nunbers stripped from file + * F_LSYMS local symbols stripped from file + * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) + */ +#define F_RELFLG 0000001 +#define F_EXEC 0000002 +#define F_LNNO 0000004 +#define F_LSYMS 0000010 +#define F_AR32WR 0000400 + + +#define MC88MAGIC 0555 /* 88k BCS executable */ +#define MC88DMAGIC 0541 /* DG/UX executable */ + + +#define MC88BADMAG(x) (((x).f_magic!=MC88MAGIC) && ((x).f_magic!=MC88DMAGIC)) + +#define FILHDR struct filehdr +#define FILHSZ sizeof(FILHDR) + + +/********************** AOUT "OPTIONAL HEADER" **********************/ + + +#define PAGEMAGIC3 0414 /* Split i&d, zero mapped */ +typedef struct aouthdr { + short magic; /* type of file */ + short vstamp; /* version stamp */ + unsigned long tsize; /* text size in bytes, padded to FW bdry*/ + unsigned long dsize; /* initialized data " " */ + unsigned long bsize; /* uninitialized data " " */ + + unsigned long entry; /* entry pt. */ + unsigned long text_start; /* base of text used for this file */ + unsigned long data_start; /* base of data used for this file */ + +} AOUTHDR; + + +/* compute size of a header */ + +#define AOUTSZ (sizeof(AOUTHDR)) + +/********************** STORAGE CLASSES **********************/ + +#define C_EFCN -1 /* physical end of function */ +#define C_NULL 0 +#define C_AUTO 1 /* automatic variable */ +#define C_EXT 2 /* external symbol */ +#define C_STAT 3 /* static */ +#define C_REG 4 /* register variable */ +#define C_EXTDEF 5 /* external definition */ +#define C_LABEL 6 /* label */ +#define C_ULABEL 7 /* undefined label */ +#define C_MOS 8 /* member of structure */ +#define C_ARG 9 /* function argument */ +#define C_STRTAG 10 /* structure tag */ +#define C_MOU 11 /* member of union */ +#define C_UNTAG 12 /* union tag */ +#define C_TPDEF 13 /* type definition */ +#define C_USTATIC 14 /* undefined static */ +#define C_ENTAG 15 /* enumeration tag */ +#define C_MOE 16 /* member of enumeration */ +#define C_REGPARM 17 /* register parameter */ +#define C_FIELD 18 /* bit field */ +#define C_BLOCK 100 /* ".bb" or ".eb" */ +#define C_FCN 101 /* ".bf" or ".ef" */ +#define C_EOS 102 /* end of structure */ +#define C_FILE 103 /* file name */ +#define C_LINE 104 /* line # reformatted as symbol table entry */ +#define C_ALIAS 105 /* duplicate tag */ +#define C_HIDDEN 106 /* ext symbol in dmert public lib */ +#define C_SHADOW 107 /* shadow symbol */ +#define C_VERSION 108 /* coff version symbol */ + + +/********************** SECTION HEADER **********************/ + +struct scnhdr { + char s_name[8]; /* section name */ + long s_paddr; /* physical address, aliased s_nlib */ + long s_vaddr; /* virtual address */ + long s_size; /* section size */ + long s_scnptr; /* file ptr to raw data for section */ + long s_relptr; /* file ptr to relocation */ + long s_lnnoptr; /* file ptr to line numbers */ + long s_nreloc; /* number of relocation entries */ + long s_nlnno; /* number of line number entries*/ + long s_flags; /* flags */ +}; + +/* + * names of "special" sections + */ +#define _TEXT ".text" +#define _DATA ".data" +#define _BSS ".bss" + +/* + * s_flags "type" + */ +#define STYP_TEXT 0x20 /* section contains text only */ +#define STYP_DATA 0x40 /* section contains data only */ +#define STYP_BSS 0x80 /* section contains bss only */ + +#define SCNHDR struct scnhdr +#define SCNHSZ sizeof(SCNHDR) + + +/********************** LINE NUMBERS **********************/ + +/* 1 line number entry for every "breakpointable" source line in a section. + * Line numbers are grouped on a per function basis; first entry in a function + * grouping will have l_lnno = 0 and in place of physical address will be the + * symbol table index of the function name. + */ +struct lineno{ + union { + long l_symndx; /* function name symbol index, iff l_lnno == 0*/ + long l_paddr; /* (physical) address of line number */ + } l_addr; + + long l_lnno; + +}; + +#define LINENO struct lineno +#define LINESZ sizeof(LINENO) + + +/********************** SYMBOLS **********************/ + +#define SYMNMLEN 8 /* # characters in a symbol name */ +#define FILNMLEN 14 /* # characters in a file name */ +#define DIMNUM 4 /* # array dimensions in auxiliary entry */ + + +struct syment { + union { + char _n_name[SYMNMLEN]; /* old COFF version */ + struct { + long _n_zeroes; /* new == 0 */ + long _n_offset; /* offset into string table */ + } _n_n; + char *_n_nptr[2]; /* allows for overlaying */ + } _n; + long n_value; /* value of symbol */ + short n_scnum; /* section number */ + unsigned short n_type; /* type and derived type */ + char n_sclass; /* storage class */ + char n_numaux; /* number of aux. entries */ + char pad2[2]; /* force alignment */ +}; + +#define n_name _n._n_name +#define n_zeroes _n._n_n._n_zeroes +#define n_offset _n._n_n._n_offset + +/* + * Relocatable symbols have number of the section in which they are defined, + * or one of the following: + */ +#define N_UNDEF 0 /* undefined symbol */ +#define N_ABS -1 /* value of symbol is absolute */ +#define N_DEBUG -2 /* debugging symbol -- symbol value is meaningless */ + +/* + * Type of a symbol, in low 4 bits of the word + */ +#define T_NULL 0 +#define T_VOID 1 /* function argument (only used by compiler) */ +#define T_CHAR 2 /* character */ +#define T_SHORT 3 /* short integer */ +#define T_INT 4 /* integer */ +#define T_LONG 5 /* long integer */ +#define T_FLOAT 6 /* floating point */ +#define T_DOUBLE 7 /* double word */ +#define T_STRUCT 8 /* structure */ +#define T_UNION 9 /* union */ +#define T_ENUM 10 /* enumeration */ +#define T_MOE 11 /* member of enumeration*/ +#define T_UCHAR 12 /* unsigned character */ +#define T_USHORT 13 /* unsigned short */ +#define T_UINT 14 /* unsigned integer */ +#define T_ULONG 15 /* unsigned long */ + + + +/* + * derived types + */ +#define DT_NON 0 +#define DT_PTR 1 /* pointer */ +#define DT_FCN 2 /* function */ +#define DT_ARY 3 /* array */ + +#define N_BTMASK 017 +#define N_TMASK 060 +#define N_BTSHFT 4 +#define N_TSHIFT 2 + +#define BTYPE(x) ((x) & N_BTMASK) + + +#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) +#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) +#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) + +#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) + +union auxent { + struct { + long x_tagndx; /* str, un, or enum tag indx */ + union { + struct { + unsigned long x_lnno; /* declaration line number */ + unsigned long x_size; /* str/union/array size */ + } x_lnsz; + long x_fsize; /* size of function */ + } x_misc; + union { + struct { /* if ISFCN, tag, or .bb */ + long x_lnnoptr; /* ptr to fcn line # */ + long x_endndx; /* entry ndx past block end */ + } x_fcn; + struct { /* if ISARY, up to 4 dimen. */ + unsigned short x_dimen[DIMNUM]; + } x_ary; + } x_fcnary; + unsigned short x_tvndx; /* tv index */ + } x_sym; + + union { + char x_fname[FILNMLEN]; + struct { + long x_zeroes; + long x_offset; + } x_n; + } x_file; + + struct { + long x_scnlen; /* section length */ + unsigned long x_nreloc; /* # relocation entries */ + unsigned long x_nlinno; /* # line numbers */ + } x_scn; + + +}; + +#define SYMENT struct syment +#define SYMESZ sizeof(SYMENT) +#define AUXENT union auxent +#define AUXESZ sizeof(AUXENT) + + +/********************** RELOCATION DIRECTIVES **********************/ + +struct reloc { + long r_vaddr; /* Virtual address of reference */ + long r_symndx; /* Index into symbol table */ + unsigned short r_type; /* Relocation type */ + unsigned short r_offset;/* Hi 16 bits of constant */ +}; + +/* Only values of r_type GNU/88k cares about */ +#define R_PCR16L 128 +#define R_PCR26L 129 +#define R_VRT16 130 +#define R_HVRT16 131 +#define R_LVRT16 132 +#define R_VRT32 133 + + + + +#define RELOC struct reloc +#define RELSZ sizeof(RELOC) + +#define DEFAULT_SECTION_ALIGNMENT 8 /* double word */ diff --git a/include/bfd.h b/include/bfd.h new file mode 100644 index 0000000..5161a54 --- /dev/null +++ b/include/bfd.h @@ -0,0 +1,855 @@ + /* A -*- C -*- header file for the bfd library */ + +/*** bfd.h -- The only header file required by users of the bfd library */ + +/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. + +This file is part of BFD, the Binary File Diddler. + +BFD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +BFD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with BFD; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* $Id$ */ + +/* executable_object_p is gone -- you can check the bfd flags and call + access() yourself */ + +#ifndef __BFD_H_SEEN__ +#define __BFD_H_SEEN__ + +#include "ansidecl.h" +#include "obstack.h" + +/* Make it easier to declare prototypes (puts conditional here) */ +#ifndef PROTO +# if __STDC__ +# define PROTO(type, name, arglist) type name arglist +# else +# define PROTO(type, name, arglist) type name () +# endif +#endif + +#define BFD_VERSION "1.9" +/* forward declaration */ +typedef struct _bfd_struct bfd; + +/* I'm sure this is going to break something and someone is going to + force me to change it. */ +typedef enum boolean {false, true} boolean; +/* FIXME-SOON: I hate it when types are invented for things that + already have types. In this case, zero and non-zero are so common + that true vs false makes me stop and read code each time I want to + know if they mean true there was an error or true the function did + something. I can't fix this particularly quickly, so I'll just + skirt the issue for now. This WILL change soon. */ +#define BFD_SUCCESS (true) +#define BFD_FAILURE (false) + +/* Try to avoid breaking stuff */ +typedef long int file_ptr; + +/* This is used to refer to locations inside a section's rawdata */ +typedef unsigned long int rawdata_offset; + +typedef unsigned long bfd_vma; +typedef unsigned long bfd_offset; + +typedef unsigned int flagword; /* 32 bits of flags */ + +/** File formats */ + +typedef enum bfd_format { + bfd_unknown = 0, /* file format is unknown */ + bfd_object, /* linker/assember/compiler output */ + bfd_archive, /* object archive file */ + bfd_core, /* core dump */ + bfd_type_end} /* marks the end; don't use it! */ + bfd_format; + +/* Object file flag values */ +#define NO_FLAGS 0 +#define HAS_RELOC 001 +#define EXEC_P 002 +#define HAS_LINENO 004 +#define HAS_DEBUG 010 +#define HAS_SYMS 020 +#define HAS_LOCALS 040 +#define DYNAMIC 0100 +#define WP_TEXT 0200 +#define D_PAGED 0400 + +/* This enum gives the object file's CPU architecture, in a global sense. + E.g. what processor family does it belong to? There is another field, + which indicates what processor within the family is in use. */ +enum bfd_architecture { + bfd_arch_unknown, /* File arch not known */ + bfd_arch_obscure, /* File arch known, not one of these */ + bfd_arch_m68k, /* Motorola 68xxx */ + bfd_arch_vax, /* DEC Vax */ + bfd_arch_i960, /* Intel 960 */ +#define bfd_mach_i960_core 0 +#define bfd_mach_i960_kb_sb 1 +#define bfd_mach_i960_mc 2 +#define bfd_mach_i960_xa 3 +#define bfd_mach_i960_ca 4 +#define bfd_mach_i960_ka_sa 5 + + bfd_arch_a29k, /* AMD 29000 */ + bfd_arch_sparc, /* Sun (SPARC International) SPARC */ + bfd_arch_mips, /* MIPS Rxxxx */ + bfd_arch_i386, /* Intel 386 */ + bfd_arch_ns32k, /* National Semiconductor 32xxx */ + bfd_arch_tahoe, /* CCI/Harris Tahoe */ + bfd_arch_i860, /* Intel 860 */ + bfd_arch_romp, /* IBM ROMP RS/6000 */ + bfd_arch_alliant, /* Alliant */ + bfd_arch_convex, /* Convex */ + bfd_arch_m88k, /* Motorola 88xxx */ + bfd_arch_pyramid, /* Pyramid Technology */ + bfd_arch_h8_300, /* Hitachi H8/300 */ + bfd_arch_last, +}; + +/* symbols and relocation */ + +typedef unsigned long symindex; + +#define BFD_NO_MORE_SYMBOLS ((symindex) ~0) + +typedef enum {bfd_symclass_unknown = 0, + bfd_symclass_fcommon, /* fortran common symbols */ + bfd_symclass_global, /* global symbol, what a surprise */ + bfd_symclass_debugger, /* some debugger symbol */ + bfd_symclass_undefined /* none known */ + } symclass; + +typedef unsigned long symvalue; /* someday they may be 64-bit qtys */ +typedef int symtype; /* Who knows, yet? */ +typedef int bfd_size_type; +/* Symbol cache classifications: (Bfd-Symbol-Flag_FOOBAR) */ +#define BSF_NO_FLAGS 0x00 +#define BSF_LOCAL 0x01 /* bfd_symclass_unknown */ +#define BSF_GLOBAL 0x02 /* bfd_symclass_global */ +#define BSF_IMPORT 0x04 +#define BSF_EXPORT 0x08 +#define BSF_UNDEFINED 0x10 /* bfd_symclass_undefined */ +#define BSF_FORT_COMM 0x20 /* bfd_symclass_fcommon */ +#define BSF_DEBUGGING 0x40 /* bfd_symclass_debugger */ +#define BSF_ABSOLUTE 0x80 +#define BSF_KEEP 0x10000 +#define BSF_WARNING 0x20000 +#define BSF_KEEP_G 0x80000 +#define BSF_WEAK 0x100000 +#define BSF_CTOR 0x200000 /* Symbol is a con/destructor */ +#define BSF_FAKE 0x400000 /* SYmbol doesn't really exist */ +#define BSF_OLD_COMMON 0x800000 /* Symbol used to be common, + but now is allocated */ +/* If symbol is fort_comm, then value is size, and this is the */ +/* contents */ +#define BFD_FORT_COMM_DEFAULT_VALUE 0 + +/* in some files the type of a symbol sometimes alters its location + * in an output file - ie in coff a ISFCN symbol which is also C_EXT + * symbol appears where it was declared and not at the end of a section. + * This bit is set by the target bfd part to convey this information. + */ +#define BSF_NOT_AT_END 0x40000 + + +/* general purpose part of a symbol + * target specific parts will be found in libcoff.h, liba.out.h etc + */ +typedef struct symbol_cache_entry +{ + struct _bfd_struct *the_bfd; /* Just a way to find out host type */ + CONST char *name; + symvalue value; + flagword flags; + struct sec_struct *section; + PTR udata; /* Target-specific stuff */ +} asymbol; + +#define bfd_get_section(x) ((x)->section) +#define bfd_get_output_section(x) ((x)->section->output_section) +#define bfd_set_section(x,y) ((x)->section) = (y) +#define bfd_asymbol_base(x) ((x)->section?((x)->section->vma):0) +#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + x->value) +#define bfd_asymbol_name(x) ((x)->name) + + +/* This is a type pun with struct ranlib on purpose! */ +typedef struct { + char *name; + file_ptr file_offset; /* look here to find the file */ +} carsym; /* to make these you call a carsymogen */ + +/* Relocation stuff */ + +/* Either: sym will point to a symbol and isextern will be 0, *OR* + sym will be NULL and isextern will be a symbol type (eg N_TEXT) + which means the location should be relocated relative to the + segment origin. This is because we won't necessarily have a symbol + which is guaranteed to point to the segment origin. */ + +typedef enum { + bfd_reloc_ok, + bfd_reloc_overflow, + bfd_reloc_outofrange, + bfd_reloc_continue, + bfd_reloc_notsupported, + bfd_reloc_other, + bfd_reloc_undefined, + bfd_reloc_dangerous} + bfd_reloc_status_enum_type; + +typedef CONST struct rint_struct { + unsigned int type; + unsigned int rightshift; + unsigned int size; + unsigned int bitsize; + boolean pc_relative; + unsigned int bitpos; + + boolean absolute; + boolean complain_on_overflow; + bfd_reloc_status_enum_type (*special_function)(); + char *name; + boolean partial_inplace; +/* Two mask fields, + the src_mask is used to select what parts of the read in data are to + be used in the relocation sum. Eg, if this was an 8 bit bit of data + which we read and relocated, this would be 0x000000ff. When we have + relocs which have an addend, such as sun4 extended relocs, the value + in the offset part of a relocating field is garbage so we never use + it. In this case the mask would be 0x00000000. + + The dst_mask is what parts of the instruction are replaced into the + instruction. In most cases src_mask == dst_mask, except in the above + special case, where dst_mask would be 0x000000ff, and src_mask would + be 0x00000000. +*/ + unsigned int src_mask; /* What things to take from the source */ + unsigned int dst_mask; /* What things to put into the dest */ + + /* Does a pc rel offset already have the offset of the jump from the + beginnining of the module in place - eg on the sun3, a pcrel + instruction always has a negative number in place, containing the + displacement from the beginning of the module. 88k bcs has a zero + in there, so you have to work out the offset yourself. */ + boolean pcrel_offset; +} reloc_howto_type; + +#define HOWTO(CODE, RT,SIZE,BITSIZE, PCREL, BITPOS, ABS, OVERFLOW, SF, NAME, INPLACE, MASKSRC, MASKDST, PCRELDONE) \ +{(unsigned)CODE,RT,SIZE,BITSIZE, PCREL, BITPOS,ABS,OVERFLOW,SF,NAME,INPLACE,MASKSRC,MASKDST,PCRELDONE} + +typedef unsigned char bfd_byte; + +typedef struct reloc_cache_entry +{ + /* A pointer into the canonicalized table for the symbol */ + asymbol **sym_ptr_ptr; + + rawdata_offset address; /* offset in section */ + bfd_vma addend; /* addend for relocation value */ + struct sec_struct *section; /* if sym is null this is the section */ + reloc_howto_type *howto; + +} arelent; + +typedef struct relent_chain_struct { + arelent relent; + struct relent_chain_struct *next; +} arelent_chain; + +/* Used in generating armaps. Perhaps just a forward definition would do? */ +struct orl { /* output ranlib */ + char **name; /* symbol name */ + file_ptr pos; /* element number or file position */ + int namidx; /* index into string table */ +}; + + + +/* Linenumber stuff */ +typedef struct lineno_cache_entry { + unsigned int line_number; /* Linenumber from start of function*/ + union { + asymbol *sym; /* Function name */ + unsigned long offset; /* Offset into section */ + } u; +} alent; + +/* object and core file sections */ + +/* Section flag definitions */ +#define SEC_NO_FLAGS 000 +#define SEC_ALLOC 001 +#define SEC_LOAD 002 +#define SEC_RELOC 004 +#define SEC_BALIGN 010 +#define SEC_READONLY 020 +#define SEC_CODE 040 +#define SEC_DATA 0100 +#define SEC_ROM 0200 +#define SEC_CONSTRUCTOR 0400 +#define SEC_HAS_CONTENTS (0x200) + +typedef struct sec_struct +{ + CONST char *name; + struct sec_struct *next; + flagword flags; + + bfd_vma vma; + bfd_size_type size; + + /* The output_offset is the indent into the output section of + this section. If this is the first section to go into + an output section, this value will be 0... + */ + bfd_vma output_offset; + struct sec_struct *output_section; + unsigned int alignment_power; /* eg 4 aligns to 2^4*/ + + arelent *relocation; /* for input files */ + arelent **orelocation; /* for output files */ + + unsigned reloc_count; + file_ptr filepos; /* File position of section data */ + file_ptr rel_filepos; /* File position of relocation info */ + file_ptr line_filepos; + struct user_section_struct *userdata; + struct lang_output_section_struct *otheruserdata; + int index; /* Which section is it 0..nth */ + alent *lineno; + unsigned int lineno_count; + + /* When a section is being output, this value changes as more + * linenumbers are written out */ + file_ptr moving_line_filepos; + + /* what the section number is in the target world */ + unsigned int target_index; + + PTR used_by_bfd; + + /* If this is a constructor section then here is a list of relents + */ + arelent_chain *constructor_chain; +} asection; + +#define align_power(addr, align) \ + ( ((addr) + ((1<<(align))-1)) & (-1 << (align))) + + + +typedef struct sec_struct *sec_ptr; + +#define bfd_section_name(bfd, ptr) ((ptr)->name) +#define bfd_section_size(bfd, ptr) ((ptr)->size) +#define bfd_section_vma(bfd, ptr) ((ptr)->vma) +#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power) +#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags) +#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata) + +#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (val)), true) +#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true) +#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true) +struct stat; + +/** Error handling */ + +typedef enum {no_error = 0, system_call_error, invalid_target, + wrong_format, invalid_operation, no_memory, + no_symbols, no_relocation_info, + no_more_archived_files, malformed_archive, + symbol_not_found, file_not_recognized, + file_ambiguously_recognized, no_contents, + bfd_error_nonrepresentable_section, + invalid_error_code} bfd_ec; + +extern bfd_ec bfd_error; + +typedef struct { + PROTO(void,(* nonrepresentable_section ),(CONST bfd *CONST abfd, + CONST char *CONST name)); +} bfd_error_vector_type; + +PROTO (char *, bfd_errmsg, ()); +PROTO (void, bfd_perror, (CONST char *message)); + + +typedef enum +{ + bfd_print_symbol_name_enum, + bfd_print_symbol_type_enum, + bfd_print_symbol_all_enum, +} bfd_print_symbol_enum_type; + + +/* The BFD target structure. + + This structure is how to find out everything BFD knows about a target. + It includes things like its byte order, name, what routines to call + to do various operations, etc. + + Every BFD points to a target structure with its "xvec" member. */ + +/* Shortcut for declaring fields which are prototyped function pointers, + while avoiding anguish on compilers that don't support protos. */ + +#define SDEF(ret, name, arglist) PROTO(ret,(*name),arglist) +#define SDEF_FMT(ret, name, arglist) PROTO(ret,(*name[bfd_type_end]),arglist) + +/* These macros are used to dispatch to functions through the bfd_target + vector. They are used in a number of macros further down in bfd.h, + and are also used when calling various routines by hand inside the + bfd implementation. The "arglist" argument must be parenthesized; + it contains all the arguments to the called function. */ + +#define BFD_SEND(bfd, message, arglist) ((*((bfd)->xvec->message)) arglist) +/* For operations which index on the bfd format */ +#define BFD_SEND_FMT(bfd, message, arglist) \ + (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) + +/* FIXME, these names should be rationalised with the names of the entry points + which call them. Too bad we can't have one macro to define them both! */ +typedef struct bfd_target +{ + /* identifies the kind of target, eg SunOS4, Ultrix, etc */ + char *name; + + /* This is bogus. Anything that can be told from the "flavour" + by some user program should be an independent attribute that can + be queried instead. FIXME. -- gnu@cygnus.com */ + enum target_flavour_enum { + bfd_target_aout_flavour_enum, + bfd_target_coff_flavour_enum, + bfd_target_ieee_flavour_enum, + bfd_target_oasys_flavour_enum, + bfd_target_srec_flavour_enum} flavour; + + boolean byteorder_big_p; /* Order of bytes in data sections */ + boolean header_byteorder_big_p; /* Order of bytes in header */ + + flagword object_flags; /* these are the ones that may be set */ + flagword section_flags; /* ditto */ + + char ar_pad_char; /* filenames in archives padded w/this char */ + unsigned short ar_max_namelen; /* this could be a char too! */ + + /* Byte swapping for data */ + /* Note that these don't take bfd as first arg. Certain other handlers + could do the same. */ + SDEF (long, bfd_getxlong, (bfd_byte *)); + SDEF (void, bfd_putxlong, (unsigned long, bfd_byte *)); + SDEF (short, bfd_getxshort, (bfd_byte *)); + SDEF (void, bfd_putxshort, (int, bfd_byte *)); + + /* Byte swapping for headers */ + SDEF (long, bfd_h_getxlong, (bfd_byte *)); + SDEF (void, bfd_h_putxlong, (unsigned long, bfd_byte *)); + SDEF (short, bfd_h_getxshort, (bfd_byte *)); + SDEF (void, bfd_h_putxshort, (int, bfd_byte *)); + + /* Format-dependent */ + SDEF_FMT (struct bfd_target *, _bfd_check_format, (bfd *));/* file fmt or 0 */ + SDEF_FMT (boolean, _bfd_set_format, (bfd *)); /* make it an object file. */ + + /* All these are defined in JUMP_TABLE */ + /* Core files */ + SDEF (char *, _core_file_failing_command, (bfd *)); + SDEF (int, _core_file_failing_signal, (bfd *)); + SDEF (boolean, _core_file_matches_executable_p, (bfd *, bfd *)); + + /* Archives */ + SDEF (boolean, _bfd_slurp_armap, (bfd *)); + SDEF (boolean, _bfd_slurp_extended_name_table, (bfd *)); + SDEF (void, _bfd_truncate_arname, (bfd *, CONST char *, char *)); + SDEF (boolean, write_armap, (bfd *arch, unsigned int elength, + struct orl *map, int orl_count, int + stridx)); + + /* All the standard stuff */ + SDEF (boolean, _close_and_cleanup, (bfd *)); /* free any allocated data */ + SDEF (boolean, _bfd_set_section_contents, (bfd *, sec_ptr, PTR, + file_ptr, int)); + SDEF (boolean, _bfd_get_section_contents, (bfd *, sec_ptr, PTR, + file_ptr, int)); + SDEF (boolean, _new_section_hook, (bfd *, sec_ptr)); + + /* Symbols and relocation */ + SDEF (unsigned int, _get_symtab_upper_bound, (bfd *)); + SDEF (unsigned int, _bfd_canonicalize_symtab, (bfd *, asymbol **)); + SDEF (unsigned int, _get_reloc_upper_bound, (bfd *, sec_ptr)); + SDEF (unsigned int, _bfd_canonicalize_reloc, (bfd *, sec_ptr, arelent **, + asymbol**)); + + /* FIXME: For steve -- clean up later */ + SDEF (asymbol *, _bfd_make_empty_symbol, (bfd *)); + SDEF (void, _bfd_print_symbol, (bfd *, PTR, asymbol *, + bfd_print_symbol_enum_type)); + SDEF(alent *, _get_lineno, (bfd *, asymbol *)); + + /* This should perhaps be format-dependent, I don't know yet. -gnu */ + SDEF (boolean, _bfd_set_arch_mach, (bfd *, enum bfd_architecture, + unsigned long)); + + SDEF (bfd *, openr_next_archived_file, (bfd *arch, bfd *prev)); + SDEF (boolean, _bfd_find_nearest_line, + (bfd *abfd, asection *section, asymbol **symbols,bfd_vma offset, + CONST char **file, CONST char **func, unsigned int *line)); + SDEF (int, _bfd_stat_arch_elt, (bfd *, struct stat *)); + SDEF (int, _bfd_sizeof_headers, (bfd *, boolean)); +} bfd_target; + +/* The code that implements targets can initialize a jump table with this + macro. It must name all its routines the same way (a prefix plus + the standard routine suffix), or it must #define the routines that + are not so named, before calling JUMP_TABLE in the initializer. */ + +/* Semi-portable string concatenation in cpp */ +#ifndef CAT +#ifdef __STDC__ +#define CAT(a,b) a##b +#else +#define CAT(a,b) a/**/b +#endif +#endif + +#define JUMP_TABLE(NAME)\ +CAT(NAME,_core_file_failing_command),\ +CAT(NAME,_core_file_failing_signal),\ +CAT(NAME,_core_file_matches_executable_p),\ +CAT(NAME,_slurp_armap),\ +CAT(NAME,_slurp_extended_name_table),\ +CAT(NAME,_truncate_arname),\ +CAT(NAME,_write_armap),\ +CAT(NAME,_close_and_cleanup), \ +CAT(NAME,_set_section_contents),\ +CAT(NAME,_get_section_contents),\ +CAT(NAME,_new_section_hook),\ +CAT(NAME,_get_symtab_upper_bound),\ +CAT(NAME,_get_symtab),\ +CAT(NAME,_get_reloc_upper_bound),\ +CAT(NAME,_canonicalize_reloc),\ +CAT(NAME,_make_empty_symbol),\ +CAT(NAME,_print_symbol),\ +CAT(NAME,_get_lineno),\ +CAT(NAME,_set_arch_mach),\ +CAT(NAME,_openr_next_archived_file),\ +CAT(NAME,_find_nearest_line),\ +CAT(NAME,_generic_stat_arch_elt),\ +CAT(NAME,_sizeof_headers) + +/* User program access to BFD facilities */ + +extern CONST short _bfd_host_big_endian; +#define HOST_BYTE_ORDER_BIG_P (*(char *)&_bfd_host_big_endian) + +/* The bfd itself */ + +#define bfd_get_filename(abfd) ((abfd)->filename) +#define bfd_get_format(abfd) ((abfd)->format) +#define bfd_get_target(abfd) ((abfd)->xvec->name) +#define bfd_get_file_flags(abfd) ((abfd)->flags) +#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags) +#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags) +#define bfd_my_archive(abfd) ((abfd)->my_archive); +#define bfd_has_map(abfd) ((abfd)->has_armap) +#define bfd_header_twiddle_required(abfd) \ + ((((abfd)->xvec->header_byteorder_big_p) \ + != (boolean)HOST_BYTE_ORDER_BIG_P) ? true:false) + +#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types) +#define bfd_usrdata(abfd) ((abfd)->usrdata) + +#define bfd_get_start_address(abfd) ((abfd)->start_address) +#define bfd_get_symcount(abfd) ((abfd)->symcount) +#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols) +#define bfd_count_sections(abfd) ((abfd)->section_count) +#define bfd_get_architecture(abfd) ((abfd)->obj_arch) +#define bfd_get_machine(abfd) ((abfd)->obj_machine) + +/* Finally! The BFD struct itself. This contains the major data about + the file, and contains pointers to the rest of the data. + + To avoid dragging too many header files into every file that + includes bfd.h, IOSTREAM has been declared as a "char *", and MTIME + as a "long". Their correct types, to which they are cast when used, + are "FILE *" and "time_t". If these had been declared as structs + rather than typedefs, we wouldn't have this problem. */ + +struct _bfd_struct +{ + + CONST char *filename; /* could be null; filename user opened with */ + bfd_target *xvec; /* operation jump table */ + char *iostream; /* stdio FILE *, unless an archive element */ + + boolean cacheable; /* iostream can be closed if desired */ + struct _bfd_struct *lru_prev; /* Used for file caching */ + struct _bfd_struct *lru_next; /* Used for file caching */ + file_ptr where; /* Where the file was when closed */ + boolean opened_once; + boolean mtime_set; /* Flag indicating mtime is available */ + long mtime; /* File modified time */ + int ifd; /* for output files, channel we locked. */ + bfd_format format; + enum bfd_direction {no_direction = 0, + read_direction = 1, + write_direction = 2, + both_direction = 3} direction; + + flagword flags; /* format_specific */ +/* +Currently my_archive is tested before adding origin to anything. I +believe that this can become always an add of origin, with origin set +to 0 for non archive files +*/ + + file_ptr origin; /* for archive contents */ + boolean output_has_begun; /* cf bfd_set_section_size */ + asection *sections; /* Pointer to linked list of sections */ + unsigned int section_count; /* The number of sections */ + + /* Some object file stuff */ + bfd_vma start_address; /* for object files only, of course */ + unsigned int symcount; /* used for input and output */ + asymbol **outsymbols; /* symtab for output bfd */ + enum bfd_architecture obj_arch; /* Architecture of object machine, eg m68k */ + unsigned long obj_machine; /* Particular machine within arch, e.g. 68010 */ + + /* Archive stuff. strictly speaking we don't need all three bfd* vars, + but doing so would allow recursive archives! */ + PTR arelt_data; /* needed if this came from an archive */ + struct _bfd_struct *my_archive; /* if this is an archive element */ + struct _bfd_struct *next; /* output chain pointer */ + struct _bfd_struct *archive_head; /* for output archive */ + boolean has_armap; /* if an arch; has it an armap? */ + + PTR tdata; /* target-specific storage */ + PTR usrdata; /* application-specific storage */ + + /* Should probably be enabled here always, so that library may be changed + to switch this on and off, while user code may remain unchanged */ +#ifdef BFD_LOCKS + struct flock *lock; + char *actual_name; /* for output files, name given to open() */ +#endif + + /* Where all the allocated stuff under this BFD goes */ + struct obstack memory; +}; + +PROTO(PTR, bfd_alloc, (bfd *abfd, size_t size)); +PROTO(PTR, bfd_zalloc,(bfd *abfd, size_t size)); +PROTO(PTR, bfd_realloc,(bfd *abfd, PTR orig, size_t new)); +PROTO(size_t, bfd_alloc_size,(bfd *abfd)); +/* FIXME, these are broken! bfd_free references "Y" which is not a parameter. + bfd_release frees the mentioned object AND EVERYTHING AFTER IT IN THE + OBSTACK! -- gnu@cygnus.com */ +#define bfd_free(x) (obstack_free(&(x->memory),y)) +#define bfd_release(x,y) (obstack_free(&(x->memory),y)) +PROTO (char *, bfd_printable_arch_mach,(enum bfd_architecture, unsigned long)); +PROTO (char *, bfd_format_string, (bfd_format format)); + +PROTO (char**, bfd_target_list, ()); +PROTO (bfd *, bfd_openr, (CONST char *filename, CONST char *target)); +PROTO (bfd *, bfd_fdopenr, (CONST char *filename, CONST char *target, int fd)); +PROTO (bfd *, bfd_openw, (CONST char *filename, CONST char *target)); +PROTO (bfd *, bfd_create, (CONST char *filename, CONST bfd *abfd)); +PROTO (boolean, bfd_close, (bfd *abfd)); +PROTO (long, bfd_get_mtime, (bfd *abfd)); +PROTO (bfd *, bfd_openr_next_archived_file, (bfd *obfd, bfd *last_file)); +PROTO (boolean, bfd_set_archive_head, (bfd *output_archive, bfd *new_head)); +PROTO (boolean, bfd_check_format, (bfd *abfd, bfd_format format)); +PROTO (boolean, bfd_set_format, (bfd *abfd, bfd_format format)); +PROTO (char *, bfd_core_file_failing_command, (bfd *abfd)); +PROTO (int, bfd_core_file_failing_signal, (bfd *abfd)); +PROTO (boolean, core_file_matches_executable_p, (bfd *core_bfd, bfd *exec_bfd)); +PROTO (sec_ptr, bfd_get_section_by_name, (bfd *abfd, CONST char *name)); +PROTO (void, bfd_map_over_sections, (bfd *abfd, void (*operation)(), + PTR user_storage)); +PROTO (sec_ptr, bfd_make_section, (bfd *abfd, CONST char *CONST name)); +PROTO (boolean, bfd_set_section_flags, (bfd *abfd, sec_ptr section, + flagword flags)); +PROTO (boolean, bfd_set_file_flags, (bfd *abfd, flagword flags)); +PROTO (boolean, bfd_arch_compatible, (bfd *abfd, bfd *bbfd, + enum bfd_architecture *res_arch, + unsigned long *res_machine)); + +PROTO (boolean, bfd_set_section_size, (bfd *abfd, sec_ptr ptr, + unsigned long val)); +PROTO (boolean, bfd_get_section_contents, (bfd *abfd, sec_ptr section, + PTR location, + file_ptr offset, int count)); +PROTO (boolean, bfd_set_section_contents, (bfd *abfd, sec_ptr section, + PTR location, + file_ptr offset, int count)); + +PROTO (unsigned long, bfd_get_next_mapent, (bfd *abfd, symindex prev, carsym **entry)); +PROTO (bfd *, bfd_get_elt_at_index, (bfd *abfd, int index)); +PROTO (boolean, bfd_set_symtab, (bfd *abfd, asymbol **location, + unsigned int symcount)); +PROTO (unsigned int, get_reloc_upper_bound, (bfd *abfd, sec_ptr asect)); +PROTO (unsigned int, bfd_canonicalize_reloc, (bfd *abfd, sec_ptr asect, + arelent **location, + asymbol **canon)); +PROTO (void, bfd_set_reloc, (bfd *abfd, sec_ptr asect, arelent **location, + unsigned int count)); +PROTO (boolean, bfd_set_start_address, (bfd *,bfd_vma)); + +PROTO (void, bfd_print_symbol_vandf, (PTR, asymbol *)); +PROTO (bfd_reloc_status_enum_type, bfd_perform_relocation, + (bfd *, arelent*, PTR, asection *, bfd*)); + +PROTO (bfd_vma, bfd_log2, (bfd_vma)); +#define bfd_symbol_same_target(abfd, symbol) \ +( ( ((symbol)->the_bfd->xvec) == (abfd)->xvec) ? true:false) + +PROTO(boolean, bfd_scan_arch_mach,(CONST char *, enum bfd_architecture *, + unsigned long *)); + +/* For speed we turn calls to these interface routines directly into + jumps through the transfer vector. This makes error-checking somewhat + confusing; the user basically has to read the documentation since there + are no longer prototypes, only declarations in the xfer vector (which + should be enough for some compilers). + + To bad the preprocessor is too dumb to allow us to clean this up with + a macro. */ + +#define bfd_set_arch_mach(abfd, arch, mach) \ + BFD_SEND (abfd, _bfd_set_arch_mach, (abfd, arch, mach)) + +#define bfd_sizeof_headers(abfd, reloc) \ + BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc)) + +#define bfd_symbol_value(abfd, idx) \ + BFD_SEND (abfd, _bfd_symbol_value, (abfd, idx)) + +#define bfd_symbol_name(abfd, idx) \ + BFD_SEND (abfd, _bfd_symbol_name, (abfd, idx)) + + +#define bfd_get_first_symbol(abfd) \ + BFD_SEND (abfd, _bfd_get_first_symbol, (abfd)) + +#define bfd_get_next_symbol(abfd, oidx) \ + BFD_SEND (abfd, _bfd_get_next_symbol, (abfd, oidx)) + +#define bfd_classify_symbol(abfd, idx) \ + BFD_SEND (abfd, _bfd_classify_symbol, (abfd, idx)) + +#define bfd_symbol_hasclass(abfd, idx, class) \ + BFD_SEND (abfd, _bfd_symbol_hasclass, (abfd, idx, class)) + +#define get_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _get_symtab_upper_bound, (abfd)) + +#define bfd_canonicalize_symtab(abfd, location) \ + BFD_SEND (abfd, _bfd_canonicalize_symtab, (abfd, location)) + + +#define bfd_make_empty_symbol(abfd) \ + BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) + +#define bfd_print_symbol(abfd, file, symbol, how) \ + BFD_SEND (abfd, _bfd_print_symbol, (abfd, file, symbol, how)) + +#define bfd_get_lineno(abfd, symbol) \ + BFD_SEND (abfd, _get_lineno, (abfd, symbol)) + +#define bfd_stat_arch_elt(abfd, buf) \ + BFD_SEND(abfd, _bfd_stat_arch_elt, (abfd, buf)) + +#define bfd_find_nearest_line(abfd, section, symbols, offset,filename_ptr, func, line_ptr) \ +BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, section,symbols, offset, filename_ptr, func, line_ptr)) + + +/* Some byte-swapping i/o operations */ +#define LONG_SIZE 4 +#define SHORT_SIZE 2 +#define BYTE_SIZE 1 +#define bfd_putchar(abfd, val, ptr) (*((char *)ptr) = (char)val) +#define bfd_getchar(abfd, ptr) (*((char *)ptr)) + +#define bfd_putlong(abfd, val, ptr) BFD_SEND(abfd, bfd_putxlong, (val,ptr)) +#define bfd_getlong(abfd, ptr) BFD_SEND(abfd, bfd_getxlong, (ptr)) + +#define bfd_putshort(abfd, val, ptr) BFD_SEND(abfd, bfd_putxshort, (val,ptr)) +#define bfd_getshort(abfd, ptr) BFD_SEND(abfd, bfd_getxshort, (ptr)) + +#define bfd_h_putchar(abfd, val, ptr) bfd_putchar (abfd, val, ptr) +#define bfd_h_getchar(abfd, ptr) bfd_getchar (abfd, ptr) + +#define bfd_h_putlong(abfd, val, ptr) BFD_SEND(abfd, bfd_h_putxlong, (val, (bfd_byte *) ptr)) +#define bfd_h_getlong(abfd, ptr) BFD_SEND(abfd, bfd_h_getxlong, ((bfd_byte *) ptr)) + +#define bfd_h_putshort(abfd, val, ptr) BFD_SEND(abfd, bfd_h_putxshort,(val,ptr)) +#define bfd_h_getshort(abfd, ptr) BFD_SEND(abfd, bfd_h_getxshort,(ptr)) + +/* General purpose one fits all. The do { } while (0) makes a single + statement out of it, for use in things like nested if-statements. + + USE OF THESE MACROS IS DISCOURAGED. THEY ASSUME THAT THE HOST AND + TARGET FIELD ALIGNMENT AND SIZES ARE THE SAME. TARGET STRUCTS SHOULD + BE MODELED AS BYTE ARRAYS INSTEAD, TO AVOID THESE ASSUMPTIONS. */ + +#define bfd_h_put_x(abfd, val, ptr) \ + do { \ + if (sizeof(*(ptr)) == LONG_SIZE) \ + bfd_h_putlong (abfd, val, (bfd_byte*)(ptr));\ + else if (sizeof(*(ptr)) == SHORT_SIZE) \ + bfd_h_putshort (abfd, val, (bfd_byte *)(ptr));\ + else if (sizeof(*(ptr)) == BYTE_SIZE) \ + bfd_h_putchar (abfd, val, (bfd_byte *)(ptr));\ + else abort(); } while (0) + +#define bfd_h_get_x(abfd, ptr) \ + ((sizeof(*(ptr))==LONG_SIZE) ? bfd_h_getlong (abfd, (bfd_byte *)(ptr)):\ + (sizeof(*(ptr))==SHORT_SIZE) ? bfd_h_getshort(abfd, (bfd_byte *)(ptr)):\ + (sizeof(*(ptr))==BYTE_SIZE) ? bfd_h_getchar (abfd, (bfd_byte *)(ptr)):\ + (abort(),1) ) + +#ifdef GNU960 + +#define BFD_COFF_FORMAT bfd_target_coff_flavour_enum +#define BFD_BOUT_FORMAT bfd_target_aout_flavour_enum + +/* + * Return nonzero iff specified bfd is for big-endian target + */ +#define BFD_BIG_ENDIAN_FILE_P(abfd) \ + ((abfd)->xvec->header_byteorder_big_p == true) + +/* + * Return nonzero iff specified bfd is for coff target + */ +#define BFD_COFF_FILE_P(abfd) ((abfd)->xvec->flavour == BFD_COFF_FORMAT) + +/* + * The names of the only targets the GNU/960 release cares about + */ +#define BFD_BIG_COFF_TARG "coff-Intel-big" +#define BFD_LITTLE_COFF_TARG "coff-Intel-little" +#define BFD_BIG_BOUT_TARG "b.out.big" +#define BFD_LITTLE_BOUT_TARG "b.out.little" + +extern PROTO (char *, bfd_make_targ_name,( enum target_flavour_enum format, int bigendian)); + +#endif /* GNU960 */ + +#endif /* __BFD_H_SEEN__ */ diff --git a/include/bout.h b/include/bout.h new file mode 100644 index 0000000..b0d4fb2 --- /dev/null +++ b/include/bout.h @@ -0,0 +1,168 @@ +/* $Id$ + * + * This file is a modified version of 'a.out.h'. It is to be used in all + * GNU tools modified to support the i80960 (or tools that operate on + * object files created by such tools). + * + * All i80960 development is done in a CROSS-DEVELOPMENT environment. I.e., + * object code is generated on, and executed under the direction of a symbolic + * debugger running on, a host system. We do not want to be subject to the + * vagaries of which host it is or whether it supports COFF or a.out format, + * or anything else. We DO want to: + * + * o always generate the same format object files, regardless of host. + * + * o have an 'a.out' header that we can modify for our own purposes + * (the 80960 is typically an embedded processor and may require + * enhanced linker support that the normal a.out.h header can't + * accommodate). + * + * As for byte-ordering, the following rules apply: + * + * o Text and data that is actually downloaded to the target is always + * in i80960 (little-endian) order. + * + * o All other numbers (in the header, symbols, relocation directives) + * are in host byte-order: object files CANNOT be lifted from a + * little-end host and used on a big-endian (or vice versa) without + * modification. + * ==> THIS IS NO LONGER TRUE USING BFD. WE CAN GENERATE ANY BYTE ORDER + * FOR THE HEADER, AND READ ANY BYTE ORDER. PREFERENCE WOULD BE TO + * USE LITTLE-ENDIAN BYTE ORDER THROUGHOUT, REGARDLESS OF HOST. <== + * + * o The downloader ('comm960') takes care to generate a pseudo-header + * with correct (i80960) byte-ordering before shipping text and data + * off to the NINDY monitor in the target systems. Symbols and + * relocation info are never sent to the target. + */ + + +#define BMAGIC 0415 +/* We don't accept the following (see N_BADMAG macro). + * They're just here so GNU code will compile. + */ +#define OMAGIC 0407 /* old impure format */ +#define NMAGIC 0410 /* read-only text */ +#define ZMAGIC 0413 /* demand load format */ + +/* FILE HEADER + * All 'lengths' are given as a number of bytes. + * All 'alignments' are for relinkable files only; an alignment of + * 'n' indicates the corresponding segment must begin at an + * address that is a multiple of (2**n). + */ +struct exec { + /* Standard stuff */ + unsigned long a_magic; /* Identifies this as a b.out file */ + unsigned long a_text; /* Length of text */ + unsigned long a_data; /* Length of data */ + unsigned long a_bss; /* Length of runtime uninitialized data area */ + unsigned long a_syms; /* Length of symbol table */ + unsigned long a_entry; /* Runtime start address */ + unsigned long a_trsize; /* Length of text relocation info */ + unsigned long a_drsize; /* Length of data relocation info */ + + /* Added for i960 */ + unsigned long a_tload; /* Text runtime load address */ + unsigned long a_dload; /* Data runtime load address */ + unsigned char a_talign; /* Alignment of text segment */ + unsigned char a_dalign; /* Alignment of data segment */ + unsigned char a_balign; /* Alignment of bss segment */ + unsigned char unused; /* (Just to make struct size a multiple of 4) */ +}; + +#define N_BADMAG(x) (((x).a_magic)!=BMAGIC) +#define N_TXTOFF(x) ( sizeof(struct exec) ) +#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text ) +#define N_TROFF(x) ( N_DATOFF(x) + (x).a_data ) +#define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize ) +#define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize ) +#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms ) + +/* A single entry in the symbol table + */ +struct nlist { + union { + char *n_name; + struct nlist *n_next; + long n_strx; /* Index into string table */ + } n_un; + unsigned char n_type; /* See below */ + char n_other; /* Used in i80960 support -- see below */ + short n_desc; + unsigned long n_value; +}; + + +/* Legal values of n_type + */ +#define N_UNDF 0 /* Undefined symbol */ +#define N_ABS 2 /* Absolute symbol */ +#define N_TEXT 4 /* Text symbol */ +#define N_DATA 6 /* Data symbol */ +#define N_BSS 8 /* BSS symbol */ +#define N_FN 31 /* Filename symbol */ + +#define N_EXT 1 /* External symbol (OR'd in with one of above) */ +#define N_TYPE 036 /* Mask for all the type bits */ +#define N_STAB 0340 /* Mask for all bits used for SDB entries */ + +/* MEANING OF 'n_other' + * + * If non-zero, the 'n_other' fields indicates either a leaf procedure or + * a system procedure, as follows: + * + * 1 <= n_other <= 32 : + * The symbol is the entry point to a system procedure. + * 'n_value' is the address of the entry, as for any other + * procedure. The system procedure number (which can be used in + * a 'calls' instruction) is (n_other-1). These entries come from + * '.sysproc' directives. + * + * n_other == N_CALLNAME + * the symbol is the 'call' entry point to a leaf procedure. + * The *next* symbol in the symbol table must be the corresponding + * 'bal' entry point to the procedure (see following). These + * entries come from '.leafproc' directives in which two different + * symbols are specified (the first one is represented here). + * + * + * n_other == N_BALNAME + * the symbol is the 'bal' entry point to a leaf procedure. + * These entries result from '.leafproc' directives in which only + * one symbol is specified, or in which the same symbol is + * specified twice. + * + * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry, + * but not every N_BALNAME entry must have an N_CALLNAME entry. + */ +#define N_CALLNAME (-1) +#define N_BALNAME (-2) +#define IS_CALLNAME(x) (N_CALLNAME == (int)(x)) +#define IS_BALNAME(x) (N_BALNAME == (int)(x)) +#define IS_OTHER(x) ((x)>0 && (x) <=32) + +struct relocation_info { + int r_address; /* File address of item to be relocated */ + unsigned + r_symbolnum:24,/* Index of symbol on which relocation is based, + * if r_extern is set. Otherwise set to + * either N_TEXT, N_DATA, or N_BSS to + * indicate section on which relocation is + * based. + */ + r_pcrel:1, /* 1 => relocate PC-relative; else absolute + * On i960, pc-relative implies 24-bit + * address, absolute implies 32-bit. + */ + r_length:2, /* Number of bytes to relocate: + * 0 => 1 byte + * 1 => 2 bytes + * 2 => 4 bytes -- only value used for i960 + */ + r_extern:1, + r_bsr:1, /* Something for the GNU NS32K assembler */ + r_disp:1, /* Something for the GNU NS32K assembler */ + r_callj:1, /* 1 if relocation target is an i960 'callj' */ + nuthin:1; /* Unused */ +}; diff --git a/include/coff-i960.h b/include/coff-i960.h new file mode 100755 index 0000000..cac9d11 --- /dev/null +++ b/include/coff-i960.h @@ -0,0 +1,414 @@ +/*** coff information for 80960. Origins: Intel corp, natch. */ + +/* NOTE: Tagentries (cf TAGBITS) are not used by the 960 */ + +/********************** FILE HEADER **********************/ + +struct filehdr { + unsigned short f_magic; /* magic number */ + unsigned short f_nscns; /* number of sections */ + long f_timdat; /* time & date stamp */ + long f_symptr; /* file pointer to symtab */ + long f_nsyms; /* number of symtab entries */ + unsigned short f_opthdr; /* sizeof(optional hdr) */ + unsigned short f_flags; /* flags */ +}; + +/* Bits for f_flags: + * F_RELFLG relocation info stripped from file + * F_EXEC file is executable (no unresolved external references) + * F_LNNO line numbers stripped from file + * F_LSYMS local symbols stripped from file + * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) + */ + +#define F_RELFLG (0x0001) +#define F_EXEC (0x0002) +#define F_LNNO (0x0004) +#define F_LSYMS (0x0008) +#define F_AR32WR (0x0010) + +/* + * Intel 80960 (I960) processor flags. + * F_I960TYPE == mask for processor type field. + */ + +#define F_I960TYPE (0xf000) +#define F_I960CORE (0x1000) +#define F_I960KB (0x2000) +#define F_I960SB (0x2000) +#define F_I960MC (0x3000) +#define F_I960XA (0x4000) +#define F_I960CA (0x5000) +#define F_I960KA (0x6000) +#define F_I960SA (0x6000) + + /* + * i80960 Magic Numbers + */ + +#define I960ROMAGIC (0x160) /* read-only text segments */ +#define I960RWMAGIC (0x161) /* read-write text segments */ + +#define I960BADMAG(x) (((x).f_magic!=I960ROMAGIC) && ((x).f_magic!=I960RWMAGIC)) + +#define FILHDR struct filehdr +#define FILHSZ sizeof(FILHDR) + + +/********************** AOUT "OPTIONAL HEADER" **********************/ + +typedef struct { + unsigned long phys_addr; + unsigned long bitarray; +} TAGBITS; + + +/* These appear to be used only by exec(2). I don't know who cares + about them in a cross development environment. In any case, this + is my collection after researching the issue for a few hours. + Apparently, most have these have remained essentially unchanged + since v7 days, although a few new ones have been added. xoxorich. + Could we have a little more teleology please? -- Gumby */ + +#define BAD0MAGIC (0401) /* (?) "lpd (UNIX/RT)" */ +#define BAD1MAGIC (0405) /* (?) overlay */ +#define OMAGIC (0407) /* old impure format. data immediately + follows text. both sections are rw. */ +#define NMAGIC (0410) /* split i&d, read-only text */ +#define A_MAGIC3 (0411) /* (?) "separated I&D" */ +#define ZMAGIC (0413) /* like NMAGIC, but demand loaded */ +#define PAGEMAGIC2 (0414) /* (?) like ZMAGIC, but address zero + explicitly unmapped. */ /* */ +#define REGMAGIC (0414) /* (?) a PAGEMAGIC2 alias? */ +#define PAGEMAGIC3 (0415) /* (?) like ZMAGIC, but address zero mapped. */ +#define A_MAGIC5 (0437) /* (?) "system overlay, separated I&D" */ +#define SASMAGIC (010000) /* (?) "Single Address Space" */ +#define MASMAGIC (020000) /* (?) "Multiple (separate I/D) Addr. Spaces" */ +typedef struct aouthdr { + short magic; /* type of file */ + short vstamp; /* version stamp */ + unsigned long tsize; /* text size in bytes, padded to FW bdry*/ + unsigned long dsize; /* initialized data " " */ + unsigned long bsize; /* uninitialized data " " */ +#if U3B + unsigned long dum1; + unsigned long dum2; /* pad to entry point */ +#endif + unsigned long entry; /* entry pt. */ + unsigned long text_start; /* base of text used for this file */ + unsigned long data_start; /* base of data used for this file */ + unsigned long tagentries; /* number of tag entries to follow */ +} AOUTHDR; + +/* return a pointer to the tag bits array */ + +#define TAGPTR(aout) ((TAGBITS *) (&(aout.tagentries)+1)) + +/* compute size of a header */ + +/*#define AOUTSZ(aout) (sizeof(AOUTHDR)+(aout.tagentries*sizeof(TAGBITS)))*/ +#define AOUTSZ (sizeof(AOUTHDR)) + + +/********************** STORAGE CLASSES **********************/ + +#define C_EFCN -1 /* physical end of function */ +#define C_NULL 0 +#define C_AUTO 1 /* automatic variable */ +#define C_EXT 2 /* external symbol */ +#define C_STAT 3 /* static */ +#define C_REG 4 /* register variable */ +#define C_EXTDEF 5 /* external definition */ +#define C_LABEL 6 /* label */ +#define C_ULABEL 7 /* undefined label */ +#define C_MOS 8 /* member of structure */ +#define C_ARG 9 /* function argument */ +#define C_STRTAG 10 /* structure tag */ +#define C_MOU 11 /* member of union */ +#define C_UNTAG 12 /* union tag */ +#define C_TPDEF 13 /* type definition */ +#define C_USTATIC 14 /* undefined static */ +#define C_ENTAG 15 /* enumeration tag */ +#define C_MOE 16 /* member of enumeration */ +#define C_REGPARM 17 /* register parameter */ +#define C_FIELD 18 /* bit field */ +/* #define C_REGARG 19 */ /* My guess - but Intel specific*/ +#define C_AUTOARG 19 /* auto argument */ +#define C_LASTENT 20 /* dummy entry (end of block) */ +#define C_BLOCK 100 /* ".bb" or ".eb" */ +#define C_FCN 101 /* ".bf" or ".ef" */ +#define C_EOS 102 /* end of structure */ +#define C_FILE 103 /* file name */ +#define C_LINE 104 /* line # reformatted as symbol table entry */ +#define C_ALIAS 105 /* duplicate tag */ +#define C_HIDDEN 106 /* ext symbol in dmert public lib */ + + /* New storage classes for 80960 */ + +/* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */ +#define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */ + +#define C_SCALL 107 /* Procedure reachable via system call */ +#define C_LEAFEXT 108 /* External leaf */ +#define C_LEAFSTAT 113 /* Static leaf */ +#define C_OPTVAR 109 /* Optimized variable */ +#define C_DEFINE 110 /* Preprocessor #define */ +#define C_PRAGMA 111 /* Advice to compiler or linker */ +#define C_SEGMENT 112 /* 80960 segment name */ + +/********************** SECTION HEADER **********************/ + +struct scnhdr { + char s_name[8]; /* section name */ + long s_paddr; /* physical address, aliased s_nlib */ + long s_vaddr; /* virtual address */ + long s_size; /* section size */ + long s_scnptr; /* file ptr to raw data for section */ + long s_relptr; /* file ptr to relocation */ + long s_lnnoptr; /* file ptr to line numbers */ + unsigned short s_nreloc; /* number of relocation entries */ + unsigned short s_nlnno; /* number of line number entries*/ + long s_flags; /* flags */ + unsigned long s_align; /* section alignment */ +}; + +/* + * names of "special" sections + */ +#define _TEXT ".text" +#define _DATA ".data" +#define _BSS ".bss" + +/* + * s_flags "type" + */ +#define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */ +#define STYP_DSECT (0x0001) /* "dummy": relocated only*/ +#define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, not loaded */ +#define STYP_GROUP (0x0004) /* "grouped": formed of input sections */ +#define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, loaded */ +#define STYP_COPY (0x0010) /* "copy": for decision function used by field update; not allocated, not relocated, + loaded; reloc & lineno entries processed normally */ +#define STYP_TEXT (0x0020) /* section contains text only */ +#define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile + will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will + update all process invocations. */ +#define STYP_DATA (0x0040) /* section contains data only */ +#define STYP_BSS (0x0080) /* section contains bss only */ +#define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */ +#define STYP_INFO (0x0200) /* comment: not allocated not relocated, not loaded */ +#define STYP_OVER (0x0400) /* overlay: relocated not allocated or loaded */ +#define STYP_LIB (0x0800) /* for .lib: same as INFO */ +#define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */ +#define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a + word of contiguous bytes beginning on a word boundary. */ + +#define SCNHDR struct scnhdr +#define SCNHSZ sizeof(SCNHDR) + + +/********************** LINE NUMBERS **********************/ + +/* 1 line number entry for every "breakpointable" source line in a section. + * Line numbers are grouped on a per function basis; first entry in a function + * grouping will have l_lnno = 0 and in place of physical address will be the + * symbol table index of the function name. + */ +struct lineno { + union { + long l_symndx; /* function name symbol index, iff l_lnno == 0*/ + long l_paddr; /* (physical) address of line number */ + } l_addr; + unsigned short l_lnno; /* line number */ + char padding[2]; /* force alignment */ +}; + +#define LINENO struct lineno +#define LINESZ sizeof(LINENO) + + +/********************** SYMBOLS **********************/ + +#define SYMNMLEN 8 /* # characters in a symbol name */ +#define FILNMLEN 14 /* # characters in a file name */ +#define DIMNUM 4 /* # array dimensions in auxiliary entry */ + +struct syment { + union { + char _n_name[SYMNMLEN]; /* old COFF version */ + struct { + long _n_zeroes; /* new == 0 */ + long _n_offset; /* offset into string table */ + } _n_n; + char *_n_nptr[2]; /* allows for overlaying */ + } _n; + long n_value; /* value of symbol */ + short n_scnum; /* section number */ + unsigned short n_flags; /* copy of flags from filhdr */ + unsigned long n_type; /* type and derived type */ + char n_sclass; /* storage class */ + char n_numaux; /* number of aux. entries */ + char pad2[2]; /* force alignment */ +}; + +#define n_name _n._n_name +#define n_ptr _n._n_nptr[1] +#define n_zeroes _n._n_n._n_zeroes +#define n_offset _n._n_n._n_offset + +/* + * Relocatable symbols have number of the section in which they are defined, + * or one of the following: + */ +#define N_UNDEF ((short)0) /* undefined symbol */ +#define N_ABS ((short)-1) /* value of symbol is absolute */ +#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */ +#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */ +#define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/ + +/* + * Type of a symbol, in low 4 bits of the word + */ +#define T_NULL 0 +#define T_VOID 1 /* function argument (only used by compiler) */ +#define T_CHAR 2 /* character */ +#define T_SHORT 3 /* short integer */ +#define T_INT 4 /* integer */ +#define T_LONG 5 /* long integer */ +#define T_FLOAT 6 /* floating point */ +#define T_DOUBLE 7 /* double word */ +#define T_STRUCT 8 /* structure */ +#define T_UNION 9 /* union */ +#define T_ENUM 10 /* enumeration */ +#define T_MOE 11 /* member of enumeration*/ +#define T_UCHAR 12 /* unsigned character */ +#define T_USHORT 13 /* unsigned short */ +#define T_UINT 14 /* unsigned integer */ +#define T_ULONG 15 /* unsigned long */ +#define T_LNGDBL 16 /* long double */ + +/* + * derived types, in n_type +*/ +#define DT_NON (0) /* no derived type */ +#define DT_PTR (1) /* pointer */ +#define DT_FCN (2) /* function */ +#define DT_ARY (3) /* array */ + +#define N_BTMASK (0x1f) +#define N_TMASK (0x60) +#define N_BTSHFT (5) +#define N_TSHIFT (2) + +#define BTYPE(x) ((x) & N_BTMASK) + +#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) +#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) +#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) + +#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) + +union auxent { + struct { + long x_tagndx; /* str, un, or enum tag indx */ + union { + struct { + unsigned short x_lnno; /* declaration line number */ + unsigned short x_size; /* str/union/array size */ + } x_lnsz; + long x_fsize; /* size of function */ + } x_misc; + union { + struct { /* if ISFCN, tag, or .bb */ + long x_lnnoptr; /* ptr to fcn line # */ + long x_endndx; /* entry ndx past block end */ + } x_fcn; + struct { /* if ISARY, up to 4 dimen. */ + unsigned short x_dimen[DIMNUM]; + } x_ary; + } x_fcnary; + unsigned short x_tvndx; /* tv index */ + } x_sym; + + union { + char x_fname[FILNMLEN]; + struct { + long x_zeroes; + long x_offset; + } x_n; + } x_file; + + struct { + long x_scnlen; /* section length */ + unsigned short x_nreloc; /* # relocation entries */ + unsigned short x_nlinno; /* # line numbers */ + } x_scn; + + struct { + long x_tvfill; /* tv fill value */ + unsigned short x_tvlen; /* length of .tv */ + unsigned short x_tvran[2]; /* tv range */ + } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ + + /****************************************** + * I960-specific *2nd* aux. entry formats + ******************************************/ + struct { +/* This is a very old typo that keeps getting propagated. */ +#define x_stdindx x_stindx + long x_stindx; /* sys. table entry */ + } x_sc; /* system call entry */ + + struct { + unsigned long x_balntry; /* BAL entry point */ + } x_bal; /* BAL-callable function */ + + struct { + unsigned long x_timestamp; /* time stamp */ + char x_idstring[20]; /* producer identity string */ + } x_ident; /* Producer ident info */ + + char a[sizeof(struct syment)]; /* force auxent/syment sizes to match */ +}; + +#define SYMENT struct syment +#define SYMESZ sizeof(SYMENT) +#define AUXENT union auxent +#define AUXESZ sizeof(AUXENT) + +#if VAX || I960 +# define _ETEXT "_etext" +#else +# define _ETEXT "etext" +#endif + +/********************** RELOCATION DIRECTIVES **********************/ + +struct reloc { + long r_vaddr; /* Virtual address of reference */ + long r_symndx; /* Index into symbol table */ + unsigned short r_type; /* Relocation type */ + char pad[2]; /* Unused */ +}; + +/* Relevent values for r_type and i960. Would someone please document them */ + +#define R_RELLONG (0x11) /* Direct 32-bit relocation */ +#define R_IPRSHORT (0x18) +#define R_IPRMED (0x19) /* 24-bit ip-relative relocation */ +#define R_IPRLONG (0x1a) +#define R_OPTCALL (0x1b) /* 32-bit optimizable call (leafproc/sysproc) */ +#define R_OPTCALLX (0x1c) /* 64-bit optimizable call (leafproc/sysproc) */ +#define R_GETSEG (0x1d) +#define R_GETPA (0x1e) +#define R_TAGWORD (0x1f) + +#define RELOC struct reloc +#define RELSZ sizeof(RELOC) + +#define DEFAULT_DATA_SECTION_ALIGNMENT 4 +#define DEFAULT_BSS_SECTION_ALIGNMENT 4 +#define DEFAULT_TEXT_SECTION_ALIGNMENT 16 +/* For new sections we havn't heard of before */ +#define DEFAULT_SECTION_ALIGNMENT 4 diff --git a/include/coff-m88k.h b/include/coff-m88k.h new file mode 100755 index 0000000..1a1d5d8 --- /dev/null +++ b/include/coff-m88k.h @@ -0,0 +1,298 @@ +/*** coff information for 88k bcs */ + +/********************** FILE HEADER **********************/ + +struct filehdr { + unsigned short f_magic; /* magic number */ + unsigned short f_nscns; /* number of sections */ + long f_timdat; /* time & date stamp */ + long f_symptr; /* file pointer to symtab */ + long f_nsyms; /* number of symtab entries */ + unsigned short f_opthdr; /* sizeof(optional hdr) */ + unsigned short f_flags; /* flags */ +}; + +/* Bits for f_flags: + * F_RELFLG relocation info stripped from file + * F_EXEC file is executable (no unresolved externel references) + * F_LNNO line nunbers stripped from file + * F_LSYMS local symbols stripped from file + * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) + */ +#define F_RELFLG 0000001 +#define F_EXEC 0000002 +#define F_LNNO 0000004 +#define F_LSYMS 0000010 +#define F_AR32WR 0x100 +#define F_AR32W 0x200 + +#define MC88MAGIC 0540 /* 88k BCS executable */ +#define MC88DMAGIC 0541 /* DG/UX executable */ +#define MC88OMAGIC 0555 /* Object file */ + +#define MC88BADMAG(x) (((x).f_magic!=MC88MAGIC) &&((x).f_magic!=MC88DMAGIC) && ((x).f_magic != MC88OMAGIC)) + +#define FILHDR struct filehdr +#define FILHSZ sizeof(FILHDR) + + +/********************** AOUT "OPTIONAL HEADER" **********************/ + + +#define PAGEMAGIC3 0414 /* Split i&d, zero mapped */ +#define PAGEMAGICBCS 0413 + +typedef struct aouthdr { + short magic; /* type of file */ + short vstamp; /* version stamp */ + unsigned long tsize; /* text size in bytes, padded to FW bdry*/ + unsigned long dsize; /* initialized data " " */ + unsigned long bsize; /* uninitialized data " " */ + + unsigned long entry; /* entry pt. */ + unsigned long text_start; /* base of text used for this file */ + unsigned long data_start; /* base of data used for this file */ + +} AOUTHDR; + + +/* compute size of a header */ + +#define AOUTSZ (sizeof(AOUTHDR)) + +/********************** STORAGE CLASSES **********************/ + +#define C_EFCN -1 /* physical end of function */ +#define C_NULL 0 +#define C_AUTO 1 /* automatic variable */ +#define C_EXT 2 /* external symbol */ +#define C_STAT 3 /* static */ +#define C_REG 4 /* register variable */ +#define C_EXTDEF 5 /* external definition */ +#define C_LABEL 6 /* label */ +#define C_ULABEL 7 /* undefined label */ +#define C_MOS 8 /* member of structure */ +#define C_ARG 9 /* function argument */ +#define C_STRTAG 10 /* structure tag */ +#define C_MOU 11 /* member of union */ +#define C_UNTAG 12 /* union tag */ +#define C_TPDEF 13 /* type definition */ +#define C_USTATIC 14 /* undefined static */ +#define C_ENTAG 15 /* enumeration tag */ +#define C_MOE 16 /* member of enumeration */ +#define C_REGPARM 17 /* register parameter */ +#define C_FIELD 18 /* bit field */ +#define C_BLOCK 100 /* ".bb" or ".eb" */ +#define C_FCN 101 /* ".bf" or ".ef" */ +#define C_EOS 102 /* end of structure */ +#define C_FILE 103 /* file name */ +#define C_LINE 104 /* line # reformatted as symbol table entry */ +#define C_ALIAS 105 /* duplicate tag */ +#define C_HIDDEN 106 /* ext symbol in dmert public lib */ +#define C_SHADOW 107 /* shadow symbol */ +#define C_VERSION 108 /* coff version symbol */ + + +/********************** SECTION HEADER **********************/ + +struct scnhdr { + char s_name[8]; /* section name */ + long s_paddr; /* physical address, aliased s_nlib */ + long s_vaddr; /* virtual address */ + long s_size; /* section size */ + long s_scnptr; /* file ptr to raw data for section */ + long s_relptr; /* file ptr to relocation */ + long s_lnnoptr; /* file ptr to line numbers */ + long s_nreloc; /* number of relocation entries */ + long s_nlnno; /* number of line number entries*/ + long s_flags; /* flags */ +}; + +/* + * names of "special" sections + */ +#define _TEXT ".text" +#define _DATA ".data" +#define _BSS ".bss" + +/* + * s_flags "type" + */ +#define STYP_TEXT 0x20 /* section contains text only */ +#define STYP_DATA 0x40 /* section contains data only */ +#define STYP_BSS 0x80 /* section contains bss only */ + +#define SCNHDR struct scnhdr +#define SCNHSZ sizeof(SCNHDR) + + +/********************** LINE NUMBERS **********************/ + +/* 1 line number entry for every "breakpointable" source line in a section. + * Line numbers are grouped on a per function basis; first entry in a function + * grouping will have l_lnno = 0 and in place of physical address will be the + * symbol table index of the function name. + */ +struct lineno{ + union { + long l_symndx; /* function name symbol index, iff l_lnno == 0*/ + long l_paddr; /* (physical) address of line number */ + } l_addr; + + long l_lnno; + +}; + +#define LINENO struct lineno +#define LINESZ sizeof(LINENO) + + +/********************** SYMBOLS **********************/ + +#define SYMNMLEN 8 /* # characters in a symbol name */ +#define FILNMLEN 14 /* # characters in a file name */ +#define DIMNUM 4 /* # array dimensions in auxiliary entry */ + + +struct syment { + union { + char _n_name[SYMNMLEN]; /* old COFF version */ + struct { + long _n_zeroes; /* new == 0 */ + long _n_offset; /* offset into string table */ + } _n_n; + char *_n_nptr[2]; /* allows for overlaying */ + } _n; + long n_value; /* value of symbol */ + short n_scnum; /* section number */ + unsigned short n_type; /* type and derived type */ + char n_sclass; /* storage class */ + char n_numaux; /* number of aux. entries */ + char pad2[2]; /* force alignment */ +}; + +#define n_name _n._n_name +#define n_zeroes _n._n_n._n_zeroes +#define n_offset _n._n_n._n_offset + +/* + * Relocatable symbols have number of the section in which they are defined, + * or one of the following: + */ +#define N_UNDEF 0 /* undefined symbol */ +#define N_ABS -1 /* value of symbol is absolute */ +#define N_DEBUG -2 /* debugging symbol -- symbol value is meaningless */ + +/* + * Type of a symbol, in low 4 bits of the word + */ +#define T_NULL 0 +#define T_VOID 1 /* function argument (only used by compiler) */ +#define T_CHAR 2 /* character */ +#define T_SHORT 3 /* short integer */ +#define T_INT 4 /* integer */ +#define T_LONG 5 /* long integer */ +#define T_FLOAT 6 /* floating point */ +#define T_DOUBLE 7 /* double word */ +#define T_STRUCT 8 /* structure */ +#define T_UNION 9 /* union */ +#define T_ENUM 10 /* enumeration */ +#define T_MOE 11 /* member of enumeration*/ +#define T_UCHAR 12 /* unsigned character */ +#define T_USHORT 13 /* unsigned short */ +#define T_UINT 14 /* unsigned integer */ +#define T_ULONG 15 /* unsigned long */ + + + +/* + * derived types + */ +#define DT_NON 0 +#define DT_PTR 1 /* pointer */ +#define DT_FCN 2 /* function */ +#define DT_ARY 3 /* array */ + +#define N_BTMASK 017 +#define N_TMASK 060 +#define N_BTSHFT 4 +#define N_TSHIFT 2 + +#define BTYPE(x) ((x) & N_BTMASK) + + +#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) +#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) +#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) + +#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) + +union auxent { + struct { + long x_tagndx; /* str, un, or enum tag indx */ + union { + struct { + unsigned long x_lnno; /* declaration line number */ + unsigned long x_size; /* str/union/array size */ + } x_lnsz; + long x_fsize; /* size of function */ + } x_misc; + union { + struct { /* if ISFCN, tag, or .bb */ + long x_lnnoptr; /* ptr to fcn line # */ + long x_endndx; /* entry ndx past block end */ + } x_fcn; + struct { /* if ISARY, up to 4 dimen. */ + unsigned short x_dimen[DIMNUM]; + } x_ary; + } x_fcnary; + unsigned short x_tvndx; /* tv index */ + } x_sym; + + union { + char x_fname[FILNMLEN]; + struct { + long x_zeroes; + long x_offset; + } x_n; + } x_file; + + struct { + long x_scnlen; /* section length */ + unsigned long x_nreloc; /* # relocation entries */ + unsigned long x_nlinno; /* # line numbers */ + } x_scn; + + +}; + +#define SYMENT struct syment +#define SYMESZ 20 +#define AUXENT union auxent +#define AUXESZ 20 + + +/********************** RELOCATION DIRECTIVES **********************/ + +struct reloc { + long r_vaddr; /* Virtual address of reference */ + long r_symndx; /* Index into symbol table */ + unsigned short r_type; /* Relocation type */ + unsigned short r_offset;/* Hi 16 bits of constant */ +}; + +/* Only values of r_type GNU/88k cares about */ +#define R_PCR16L 128 +#define R_PCR26L 129 +#define R_VRT16 130 +#define R_HVRT16 131 +#define R_LVRT16 132 +#define R_VRT32 133 + + + + +#define RELOC struct reloc +#define RELSZ sizeof(RELOC) + +#define DEFAULT_SECTION_ALIGNMENT 8 /* double word */ diff --git a/include/ieee.h b/include/ieee.h new file mode 100644 index 0000000..08ebd01 --- /dev/null +++ b/include/ieee.h @@ -0,0 +1,128 @@ +#define N_W_VARIABLES 8 +#define Module_Beginning 0xe0 + +typedef struct { + char *processor; + char *module_name; +} ieee_module_begin_type; + +#define Address_Descriptor 0xec +typedef struct { +bfd_vma number_of_bits_mau; + bfd_vma number_of_maus_in_address; + + unsigned char byte_order; +#define IEEE_LITTLE 0xcc +#define IEEE_BIG 0xcd +} ieee_address_descriptor_type; + +typedef union { + file_ptr offset[N_W_VARIABLES]; + struct { + file_ptr extension_record; + file_ptr environmental_record; + file_ptr section_part; + file_ptr external_part; + file_ptr debug_information_part; + file_ptr data_part; + file_ptr trailer_part; + file_ptr me_record; + } r; +} ieee_w_variable_type; + + + + + +typedef enum +{ + ieee_number_start_enum = 0x00, + ieee_number_end_enum=0x7f, + ieee_number_repeat_start_enum = 0x80, + ieee_number_repeat_end_enum = 0x88, + ieee_number_repeat_4_enum = 0x84, + ieee_number_repeat_3_enum = 0x83, + ieee_number_repeat_2_enum = 0x82, + ieee_number_repeat_1_enum = 0x81, + ieee_module_beginning_enum = 0xe0, + ieee_module_end_enum = 0xe1, + ieee_extension_length_1_enum = 0xde, + ieee_extension_length_2_enum = 0xdf, + ieee_section_type_enum = 0xe6, + ieee_section_alignment_enum = 0xe7, + ieee_external_symbol_enum = 0xe8, + ieee_attribute_record_enum = 0xf1c9, + ieee_comma = 0x90, + ieee_external_reference_enum = 0xe9, + ieee_set_current_section_enum = 0xe5, + ieee_address_descriptor_enum = 0xec, + ieee_load_constant_bytes_enum = 0xed, + ieee_load_with_relocation_enum = 0xe4, + + ieee_variable_A_enum = 0xc1, + ieee_variable_B_enum = 0xc2, + ieee_variable_C_enum = 0xc3, + ieee_variable_D_enum = 0xc4, + ieee_variable_E_enum = 0xc5, + ieee_variable_F_enum = 0xc6, + ieee_variable_G_enum = 0xc7, + ieee_variable_H_enum = 0xc8, + ieee_variable_I_enum = 0xc9, + ieee_variable_J_enum = 0xca, + ieee_variable_K_enum = 0xcb, + ieee_variable_L_enum = 0xcc, + ieee_variable_M_enum = 0xcd, + ieee_variable_N_enum = 0xce, + ieee_variable_O_enum = 0xcf, + ieee_variable_P_enum = 0xd0, + ieee_variable_Q_enum = 0xd1, + ieee_variable_R_enum = 0xd2, + ieee_variable_S_enum = 0xd3, + ieee_variable_T_enum = 0xd4, + ieee_variable_U_enum = 0xd5, + ieee_variable_V_enum = 0xd6, + ieee_variable_W_enum = 0xd7, + ieee_variable_X_enum = 0xd8, + ieee_variable_Y_enum = 0xd9, + ieee_variable_Z_enum = 0xda, + ieee_function_plus_enum = 0xa5, + ieee_function_minus_enum = 0xa6, + ieee_function_signed_open_b_enum = 0xba, + ieee_function_signed_close_b_enum = 0xbb, + + ieee_function_unsigned_open_b_enum = 0xbc, + ieee_function_unsigned_close_b_enum = 0xbd, + + ieee_function_either_open_b_enum = 0xbe, + ieee_function_either_close_b_enum = 0xbf, + ieee_record_seperator_enum = 0xdb, + + ieee_e2_first_byte_enum = 0xe2, + ieee_section_size_enum = 0xe2d3, + ieee_physical_region_size_enum = 0xe2c1, + ieee_region_base_address_enum = 0xe2c2, + ieee_mau_size_enum = 0xe2c6, + ieee_m_value_enum = 0xe2cd, + ieee_section_base_address_enum = 0xe2cc, + ieee_section_offset_enum = 0xe2d2, + ieee_value_starting_address_enum = 0xe2c7, + ieee_assign_value_to_variable_enum = 0xe2d7, + ieee_set_current_pc_enum = 0xe2d0, + ieee_value_record_enum = 0xe2c9, + ieee_weak_external_reference_enum= 0xf4, + +} ieee_record_enum_type; + + +typedef struct { + unsigned int section_index; + unsigned int section_type; + char *section_name; + unsigned int parent_section_index; + unsigned int sibling_section_index; + unsigned int context_index; +} ieee_section_type; +#define IEEE_REFERENCE_BASE 11 +#define IEEE_PUBLIC_BASE 32 +#define IEEE_SECTION_NUMBER_BASE 1 + diff --git a/include/oasys.h b/include/oasys.h new file mode 100644 index 0000000..642f752 --- /dev/null +++ b/include/oasys.h @@ -0,0 +1,117 @@ + +/* **** */ + + +typedef struct { + int32_type version; + char create_date[12]; + char revision_date[12]; + uint32_type mod_count; + uint32_type mod_tbl_offset; + uint32_type sym_tbl_size; + uint32_type sym_count; + uint32_type sym_tbl_offset; + uint32_type xref_count; + uint32_type xref_lst_offset; +} oasys_archive_header_type; + +typedef struct { + int32_type mod_number; + char mod_date[12]; + int32_type mod_size; + int32_type dep_count; + int32_type depee_count; + int32_type sect_count; + int32_type file_offset; + int32_type mod_name_length; +} oasys_module_table_type; + + +typedef enum { + oasys_record_is_end_enum = 0, + oasys_record_is_data_enum = 1, + oasys_record_is_symbol_enum = 2, + oasys_record_is_header_enum = 3, + oasys_record_is_named_section_enum = 4, + oasys_record_is_com_enum = 5, + oasys_record_is_debug_enum = 6, + oasys_record_is_section_enum = 7, + oasys_record_is_debug_file_enum = 8, + oasys_record_is_module_enum = 9, + oasys_record_is_local_enum = 10 +} oasys_record_enum_type; + + + +typedef struct { + uint8_type length; + int8_type check_sum; + int8_type type; + int8_type fill; +} oasys_record_header_type; + +typedef struct { + oasys_record_header_type header; + uint8e_type relb; + uint8e_type addr[4]; + uint8e_type data[256]; +} oasys_data_record_type; + +typedef struct { + oasys_record_header_type header; + int8_type version_number; + int8_type rev_number; + char module_name[26-6]; + char description[64-26]; +} oasys_header_record_type; + +#define OASYS_VERSION_NUMBER 0 +#define OASYS_REV_NUMBER 0 +typedef struct { + oasys_record_header_type header; + int8e_type relb; + int8e_type value[4]; + int8e_type refno[2]; + char name[64]; +} oasys_symbol_record_type; + +typedef int8e_type relocation_byte; + +#define RELOCATION_PCREL_BIT 0x80 +#define RELOCATION_32BIT_BIT 0x40 +#define RELOCATION_TYPE_BITS 0x30 +#define RELOCATION_TYPE_ABS 0x00 +#define RELOCATION_TYPE_REL 0x10 +#define RELOCATION_TYPE_UND 0x20 +#define RELOCATION_TYPE_COM 0x30 +#define RELOCATION_SECT_BITS 0x0f + +typedef struct +{ + oasys_record_header_type header; + uint8e_type relb; + int8_type value[4]; + int8_type vma[4]; + int8_type fill[3]; +} oasys_section_record_type; + +typedef struct { + oasys_record_header_type header; + uint8e_type relb; + int8e_type entry[4]; + int8e_type fill[2]; + int8e_type zero; +} oasys_end_record_type; + + +#define OASYS_MAX_SEC_COUNT 16 +typedef union +{ + oasys_record_header_type header; + oasys_data_record_type data; + oasys_section_record_type section; + oasys_symbol_record_type symbol; + oasys_header_record_type first; + oasys_end_record_type end; + uint8e_type pad[256]; +} oasys_record_union_type; diff --git a/include/obstack.h b/include/obstack.h new file mode 100644 index 0000000..2e80c9c --- /dev/null +++ b/include/obstack.h @@ -0,0 +1,416 @@ +/* obstack.h - object stack macros + Copyright (C) 1988 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 1, or (at your option) any +later version. + +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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Summary: + +All the apparent functions defined here are macros. The idea +is that you would use these pre-tested macros to solve a +very specific set of problems, and they would run fast. +Caution: no side-effects in arguments please!! They may be +evaluated MANY times!! + +These macros operate a stack of objects. Each object starts life +small, and may grow to maturity. (Consider building a word syllable +by syllable.) An object can move while it is growing. Once it has +been "finished" it never changes address again. So the "top of the +stack" is typically an immature growing object, while the rest of the +stack is of mature, fixed size and fixed address objects. + +These routines grab large chunks of memory, using a function you +supply, called `obstack_chunk_alloc'. On occasion, they free chunks, +by calling `obstack_chunk_free'. You must define them and declare +them before using any obstack macros. + +Each independent stack is represented by a `struct obstack'. +Each of the obstack macros expects a pointer to such a structure +as the first argument. + +One motivation for this package is the problem of growing char strings +in symbol tables. Unless you are "fascist pig with a read-only mind" +[Gosper's immortal quote from HAKMEM item 154, out of context] you +would not like to put any arbitrary upper limit on the length of your +symbols. + +In practice this often means you will build many short symbols and a +few long symbols. At the time you are reading a symbol you don't know +how long it is. One traditional method is to read a symbol into a +buffer, realloc()ating the buffer every time you try to read a symbol +that is longer than the buffer. This is beaut, but you still will +want to copy the symbol from the buffer to a more permanent +symbol-table entry say about half the time. + +With obstacks, you can work differently. Use one obstack for all symbol +names. As you read a symbol, grow the name in the obstack gradually. +When the name is complete, finalize it. Then, if the symbol exists already, +free the newly read name. + +The way we do this is to take a large chunk, allocating memory from +low addresses. When you want to build a symbol in the chunk you just +add chars above the current "high water mark" in the chunk. When you +have finished adding chars, because you got to the end of the symbol, +you know how long the chars are, and you can create a new object. +Mostly the chars will not burst over the highest address of the chunk, +because you would typically expect a chunk to be (say) 100 times as +long as an average object. + +In case that isn't clear, when we have enough chars to make up +the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) +so we just point to it where it lies. No moving of chars is +needed and this is the second win: potentially long strings need +never be explicitly shuffled. Once an object is formed, it does not +change its address during its lifetime. + +When the chars burst over a chunk boundary, we allocate a larger +chunk, and then copy the partly formed object from the end of the old +chunk to the beginning of the new larger chunk. We then carry on +accreting characters to the end of the object as we normally would. + +A special macro is provided to add a single char at a time to a +growing object. This allows the use of register variables, which +break the ordinary 'growth' macro. + +Summary: + We allocate large chunks. + We carve out one object at a time from the current chunk. + Once carved, an object never moves. + We are free to append data of any size to the currently + growing object. + Exactly one object is growing in an obstack at any one time. + You can run one obstack per control block. + You may have as many control blocks as you dare. + Because of the way we do it, you can `unwind' a obstack + back to a previous state. (You may remove objects much + as you would with a stack.) +*/ + + +/* Don't do the contents of this file more than once. */ + +#ifndef __OBSTACKS__ +#define __OBSTACKS__ + +/* We use subtraction of (char *)0 instead of casting to int + because on word-addressable machines a simple cast to int + may ignore the byte-within-word field of the pointer. */ + +#ifndef __PTR_TO_INT +#define __PTR_TO_INT(P) ((P) - (char *)0) +#endif + +#ifndef __INT_TO_PTR +#define __INT_TO_PTR(P) ((P) + (char *)0) +#endif + +struct _obstack_chunk /* Lives at front of each chunk. */ +{ + char *limit; /* 1 past end of this chunk */ + struct _obstack_chunk *prev; /* address of prior chunk or NULL */ + char contents[4]; /* objects begin here */ +}; + +struct obstack /* control current object in current chunk */ +{ + long chunk_size; /* preferred size to allocate chunks in */ + struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */ + char *object_base; /* address of object we are building */ + char *next_free; /* where to add next char to current object */ + char *chunk_limit; /* address of char after current chunk */ + int temp; /* Temporary for some macros. */ + int alignment_mask; /* Mask of alignment for each object. */ +#ifdef __STDC__ + void *(*chunkfun) (); /* User's fcn to allocate a chunk. */ +#else + char *(*chunkfun) (); /* User's fcn to allocate a chunk. */ +#endif + void (*freefun) (); /* User's function to free a chunk. */ +}; + +#ifdef __STDC__ + +/* Do the function-declarations after the structs + but before defining the macros. */ + +void obstack_init (struct obstack *obstack); + +void * obstack_alloc (struct obstack *obstack, int size); + +void * obstack_copy (struct obstack *obstack, void *address, int size); +void * obstack_copy0 (struct obstack *obstack, void *address, int size); + +void obstack_free (struct obstack *obstack, void *block); + +void obstack_blank (struct obstack *obstack, int size); + +void obstack_grow (struct obstack *obstack, void *data, int size); +void obstack_grow0 (struct obstack *obstack, void *data, int size); + +void obstack_1grow (struct obstack *obstack, int data_char); +void obstack_ptr_grow (struct obstack *obstack, void *data); +void obstack_int_grow (struct obstack *obstack, int data); + +void * obstack_finish (struct obstack *obstack); + +int obstack_object_size (struct obstack *obstack); + +int obstack_room (struct obstack *obstack); +void obstack_1grow_fast (struct obstack *obstack, int data_char); +void obstack_ptr_grow_fast (struct obstack *obstack, void *data); +void obstack_int_grow_fast (struct obstack *obstack, int data); +void obstack_blank_fast (struct obstack *obstack, int size); + +void * obstack_base (struct obstack *obstack); +void * obstack_next_free (struct obstack *obstack); +int obstack_alignment_mask (struct obstack *obstack); +int obstack_chunk_size (struct obstack *obstack); + +#endif /* __STDC__ */ + +/* Non-ANSI C cannot really support alternative functions for these macros, + so we do not declare them. */ + +/* Pointer to beginning of object being allocated or to be allocated next. + Note that this might not be the final address of the object + because a new chunk might be needed to hold the final size. */ + +#define obstack_base(h) ((h)->object_base) + +/* Size for allocating ordinary chunks. */ + +#define obstack_chunk_size(h) ((h)->chunk_size) + +/* Pointer to next byte not yet allocated in current chunk. */ + +#define obstack_next_free(h) ((h)->next_free) + +/* Mask specifying low bits that should be clear in address of an object. */ + +#define obstack_alignment_mask(h) ((h)->alignment_mask) + +#define obstack_init(h) \ + _obstack_begin ((h), 0, 0, obstack_chunk_alloc, obstack_chunk_free) + +#define obstack_begin(h, size) \ + _obstack_begin ((h), (size), 0, obstack_chunk_alloc, obstack_chunk_free) + +#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) + +#define obstack_blank_fast(h,n) ((h)->next_free += (n)) + +#if defined (__GNUC__) && defined (__STDC__) + +/* For GNU C, if not -traditional, + we can define these macros to compute all args only once + without using a global variable. + Also, we can avoid using the `temp' slot, to make faster code. */ + +#define obstack_object_size(OBSTACK) \ + ({ struct obstack *__o = (OBSTACK); \ + (unsigned) (__o->next_free - __o->object_base); }) + +#define obstack_room(OBSTACK) \ + ({ struct obstack *__o = (OBSTACK); \ + (unsigned) (__o->chunk_limit - __o->next_free); }) + +#define obstack_grow(OBSTACK,where,length) \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + ((__o->next_free + __len > __o->chunk_limit) \ + ? _obstack_newchunk (__o, __len) : 0); \ + bcopy (where, __o->next_free, __len); \ + __o->next_free += __len; \ + (void) 0; }) + +#define obstack_grow0(OBSTACK,where,length) \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + ((__o->next_free + __len + 1 > __o->chunk_limit) \ + ? _obstack_newchunk (__o, __len + 1) : 0), \ + bcopy (where, __o->next_free, __len), \ + __o->next_free += __len, \ + *(__o->next_free)++ = 0; \ + (void) 0; }) + +#define obstack_1grow(OBSTACK,datum) \ +({ struct obstack *__o = (OBSTACK); \ + ((__o->next_free + 1 > __o->chunk_limit) \ + ? _obstack_newchunk (__o, 1) : 0), \ + *(__o->next_free)++ = (datum); \ + (void) 0; }) + +/* These assume that the obstack alignment is good enough for pointers or ints, + and that the data added so far to the current object + shares that much alignment. */ + +#define obstack_ptr_grow(OBSTACK,datum) \ +({ struct obstack *__o = (OBSTACK); \ + ((__o->next_free + sizeof (void *) > __o->chunk_limit) \ + ? _obstack_newchunk (__o, sizeof (void *)) : 0), \ + *(*(void ***)&__o->next_free)++ = ((void *)datum); \ + (void) 0; }) + +#define obstack_int_grow(OBSTACK,datum) \ +({ struct obstack *__o = (OBSTACK); \ + ((__o->next_free + sizeof (int) > __o->chunk_limit) \ + ? _obstack_newchunk (__o, sizeof (int)) : 0), \ + *(*(int **)&__o->next_free)++ = ((int)datum); \ + (void) 0; }) + +#define obstack_ptr_grow_fast(h,aptr) (*(*(void ***)&(h)->next_free)++ = (void *)aptr) +#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint) + +#define obstack_blank(OBSTACK,length) \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + ((__o->chunk_limit - __o->next_free < __len) \ + ? _obstack_newchunk (__o, __len) : 0); \ + __o->next_free += __len; \ + (void) 0; }) + +#define obstack_alloc(OBSTACK,length) \ +({ struct obstack *__h = (OBSTACK); \ + obstack_blank (__h, (length)); \ + obstack_finish (__h); }) + +#define obstack_copy(OBSTACK,where,length) \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow (__h, (where), (length)); \ + obstack_finish (__h); }) + +#define obstack_copy0(OBSTACK,where,length) \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow0 (__h, (where), (length)); \ + obstack_finish (__h); }) + +#define obstack_finish(OBSTACK) \ +({ struct obstack *__o = (OBSTACK); \ + void *value = (void *) __o->object_base; \ + __o->next_free \ + = __INT_TO_PTR ((__PTR_TO_INT (__o->next_free)+__o->alignment_mask)\ + & ~ (__o->alignment_mask)); \ + ((__o->next_free - (char *)__o->chunk \ + > __o->chunk_limit - (char *)__o->chunk) \ + ? (__o->next_free = __o->chunk_limit) : 0); \ + __o->object_base = __o->next_free; \ + value; }) + +#define obstack_free(OBSTACK, OBJ) \ +({ struct obstack *__o = (OBSTACK); \ + void *__obj = (OBJ); \ + if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ + __o->next_free = __o->object_base = __obj; \ + else (obstack_free) (__o, __obj); }) + +#else /* not __GNUC__ or not __STDC__ */ + +#define obstack_object_size(h) \ + (unsigned) ((h)->next_free - (h)->object_base) + +#define obstack_room(h) \ + (unsigned) ((h)->chunk_limit - (h)->next_free) + +#define obstack_grow(h,where,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp > (h)->chunk_limit) \ + ? _obstack_newchunk ((h), (h)->temp) : 0), \ + bcopy (where, (h)->next_free, (h)->temp), \ + (h)->next_free += (h)->temp) + +#define obstack_grow0(h,where,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ + ? _obstack_newchunk ((h), (h)->temp + 1) : 0), \ + bcopy (where, (h)->next_free, (h)->temp), \ + (h)->next_free += (h)->temp, \ + *((h)->next_free)++ = 0) + +#define obstack_1grow(h,datum) \ +( (((h)->next_free + 1 > (h)->chunk_limit) \ + ? _obstack_newchunk ((h), 1) : 0), \ + *((h)->next_free)++ = (datum)) + +#define obstack_ptr_grow(h,datum) \ +( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ + ? _obstack_newchunk ((h), sizeof (char *)) : 0), \ + *(*(char ***)&(h)->next_free)++ = ((char *)datum)) + +#define obstack_int_grow(h,datum) \ +( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ + ? _obstack_newchunk ((h), sizeof (int)) : 0), \ + *(*(int **)&(h)->next_free)++ = ((int)datum)) + +#define obstack_ptr_grow_fast(h,aptr) (*(*(char ***)&(h)->next_free)++ = (char *)aptr) +#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint) + +#define obstack_blank(h,length) \ +( (h)->temp = (length), \ + (((h)->chunk_limit - (h)->next_free < (h)->temp) \ + ? _obstack_newchunk ((h), (h)->temp) : 0), \ + (h)->next_free += (h)->temp) + +#define obstack_alloc(h,length) \ + (obstack_blank ((h), (length)), obstack_finish ((h))) + +#define obstack_copy(h,where,length) \ + (obstack_grow ((h), (where), (length)), obstack_finish ((h))) + +#define obstack_copy0(h,where,length) \ + (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) + +#define obstack_finish(h) \ +( (h)->temp = __PTR_TO_INT ((h)->object_base), \ + (h)->next_free \ + = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ + & ~ ((h)->alignment_mask)), \ + (((h)->next_free - (char *)(h)->chunk \ + > (h)->chunk_limit - (char *)(h)->chunk) \ + ? ((h)->next_free = (h)->chunk_limit) : 0), \ + (h)->object_base = (h)->next_free, \ + __INT_TO_PTR ((h)->temp)) + +#ifdef __STDC__ +#define obstack_free(h,obj) \ +( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ + (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ + ? (int) ((h)->next_free = (h)->object_base \ + = (h)->temp + (char *) (h)->chunk) \ + : ((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0))) +#else +#define obstack_free(h,obj) \ +( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ + (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ + ? (int) ((h)->next_free = (h)->object_base \ + = (h)->temp + (char *) (h)->chunk) \ + : (int) _obstack_free ((h), (h)->temp + (char *) (h)->chunk))) +#endif + +#endif /* not __GNUC__ or not __STDC__ */ + +/* Declare the external functions we use; they are in obstack.c. */ + +#ifdef __STDC__ + extern int _obstack_newchunk (struct obstack *h, int length); + extern int _obstack_free (struct obstack *h, void *obj); + extern void _obstack_begin (struct obstack *h, int size, int alignment, + void *(*chunkfun) (), void (*freefun) ()); +#else + extern int _obstack_newchunk (); + extern int _obstack_free (); + extern void _obstack_begin (); +#endif + +#endif /* not __OBSTACKS__ */ + diff --git a/include/reloc.h b/include/reloc.h new file mode 100755 index 0000000..b8e46a5 --- /dev/null +++ b/include/reloc.h @@ -0,0 +1,38 @@ +/* Relocation types for a.out files using reloc_info_extended + (SPARC and AMD 29000). */ + +#ifndef _RELOC_H_READ_ +#define _RELOC_H_READ_ 1 + +enum reloc_type +{ + RELOC_8, RELOC_16, RELOC_32, /* simple relocations */ + RELOC_DISP8, RELOC_DISP16, RELOC_DISP32, /* pc-rel displacement */ + RELOC_WDISP30, RELOC_WDISP22, + RELOC_HI22, RELOC_22, + RELOC_13, RELOC_LO10, + RELOC_SFA_BASE, RELOC_SFA_OFF13, + RELOC_BASE10, RELOC_BASE13, RELOC_BASE22, /* P.I.C. (base-relative) */ + RELOC_PC10, RELOC_PC22, /* for some sort of pc-rel P.I.C. (?) */ + RELOC_JMP_TBL, /* P.I.C. jump table */ + RELOC_SEGOFF16, /* reputedly for shared libraries somehow */ + RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE, + +/* 29K relocation types */ + RELOC_JUMPTARG, RELOC_CONST, RELOC_CONSTH, + + NO_RELOC +}; + +#define RELOC_TYPE_NAMES \ +"8", "16", "32", "DISP8", \ +"DISP16", "DISP32", "WDISP30", "WDISP22", \ +"HI22", "22", "13", "LO10", \ +"SFA_BASE", "SFAOFF13", "BASE10", "BASE13", \ +"BASE22", "PC10", "PC22", "JMP_TBL", \ +"SEGOFF16", "GLOB_DAT", "JMP_SLOT", "RELATIVE", \ +"JUMPTARG", "CONST", "CONSTH", \ +"NO_RELOC", \ +"XXX_28", "XXX_29", "XXX_30", "XXX_31" + +#endif /* _RELOC_H_READ_ */ diff --git a/include/sysdep.h b/include/sysdep.h new file mode 100755 index 0000000..25996d81 --- /dev/null +++ b/include/sysdep.h @@ -0,0 +1,110 @@ +/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. + +This file is part of BFD, the Binary File Diddler. + +BFD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +BFD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with BFD; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* $Id$ */ + +/* All the system include files boiled into one place. + + One day, everyone will have the same set of include files.. + + This is ugly, but if you can think of a better way of doing this, + tell me. steve@cygnus.com + +*/ + + + +#ifndef _SYSDEP_H +#define _SYSDEP_H + +/* + The including makefile must define HOST_SYS to be one of these. + Each combination of Machine and OS (and maybe OS Version) must + have a different number. + */ + +#define SUN4_SYS 2 +#define POSIX_SYS 3 +#define AIX_SYS 4 +#define VAX_ULTRIX_SYS 5 +#define i386_SYSV_SYS 6 +#define SUN3_SYS 7 +#define UNKNOWN_SYS 8 +#define DGUX_SYS 9 +#define DEC3100_SYS 10 +#define HP9000_SYS 11 + +#include <ansidecl.h> + +#if __STDC__ +#define PROTO(type, name, arglist) type name arglist +#else +#define PROTO(type, name, arglist) type name () +#define NO_STDARG +#endif + +#ifndef HOST_SYS +#define HOST_SYS = Hey_you_HOST_SYS_has_not_been_defined. +#endif + +#if HOST_SYS==SUN4_SYS +#define HOST_IS_SUN4 1 +#include <sys/h-sun4.h> +#endif + +#if HOST_SYS==DGUX_SYS +#include <sys/h-dgux.h> +#endif + +#if HOST_SYS==POSIX_SYS +#define HOST_IS_POSIX 1 +#endif + +#if HOST_SYS==AIX_SYS +#define HOST_IS_AIX 1 +#include <sys/h-rs6000.h> +#endif + +#if HOST_SYS==VAX_ULTRIX_SYS +#define HOST_IS_VAX_ULTRIX 1 +#include <sys/h-vaxult.h> +#endif + +#if HOST_SYS==i386_SYSV_SYS +#define HOST_IS_i386_SYSV 1 +#define USG +#include <sys/h-i386v.h> +#endif + +#if HOST_SYS==SUN3_SYS +#define HOST_IS_SUN3 1 +#include <sys/h-sun3.h> +#endif + +#if HOST_SYS==DEC3100_SYS +#define HOST_IS_DEC3100 1 +#include <sys/h-dec3100.h> +#endif + +#if HOST_SYS==HP9000_SYS +#define HOST_IS_HP9000 1 +#define USG +#include <sys/h-hp9000.h> +#endif + +#endif |