From a8f3d651171c0296179c9b29367151c7d62f24fd Mon Sep 17 00:00:00 2001 From: Steve Chamberlain Date: Sat, 11 May 1991 02:23:48 +0000 Subject: [PATCH] Fixed the shapes of external things some more.  --- include/bfd.h | 18 +++---- include/coff-i960.h | 132 +++++++++++++++++++++++++++++++++++++++------------- include/coff-m68k.h | 69 +++++++++++++++++++++------ include/coff-m88k.h | 106 ++++++++++++++++++++++++++++------------- include/oasys.h | 25 ++++++++++ 5 files changed, 260 insertions(+), 90 deletions(-) diff --git a/include/bfd.h b/include/bfd.h index b398c44..0a3d710 100644 --- a/include/bfd.h +++ b/include/bfd.h @@ -808,18 +808,18 @@ BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, section,symbols, offset, filename #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));\ + if (sizeof((ptr)) == LONG_SIZE) \ + bfd_h_putlong (abfd, val, (ptr));\ + else if (sizeof((ptr)) == SHORT_SIZE) \ + bfd_h_putshort (abfd, val, (ptr));\ + else if (sizeof((ptr)) == BYTE_SIZE) \ + bfd_h_putchar (abfd, val, (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)):\ + ((sizeof((ptr))==LONG_SIZE) ? bfd_h_getlong (abfd, &(ptr[0])):\ + (sizeof((ptr))==SHORT_SIZE) ? bfd_h_getshort(abfd, &(ptr[0])):\ + (sizeof((ptr))==BYTE_SIZE) ? bfd_h_getchar (abfd, &(ptr[0])):\ (abort(),1) ) #ifdef GNU960 diff --git a/include/coff-i960.h b/include/coff-i960.h index db21c4b..bf33d5a 100755 --- a/include/coff-i960.h +++ b/include/coff-i960.h @@ -7,23 +7,34 @@ /********************** 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 */ +struct external_filehdr { + char f_magic[2]; /* magic number */ + char f_nscns[2]; /* number of sections */ + char f_timdat[4]; /* time & date stamp */ + char f_symptr[4]; /* file pointer to symtab */ + char f_nsyms[4]; /* number of symtab entries */ + char f_opthdr[2]; /* sizeof(optional hdr) */ + char f_flags[2]; /* flags */ +}; + +struct internal_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) - */ +* 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) @@ -32,9 +43,9 @@ struct filehdr { #define F_AR32WR (0x0010) /* - * Intel 80960 (I960) processor flags. - * F_I960TYPE == mask for processor type field. - */ +* Intel 80960 (I960) processor flags. +* F_I960TYPE == mask for processor type field. +*/ #define F_I960TYPE (0xf000) #define F_I960CORE (0x1000) @@ -45,19 +56,35 @@ struct filehdr { #define F_I960CA (0x5000) #define F_I960KA (0x6000) #define F_I960SA (0x6000) - - /* - * i80960 Magic Numbers - */ + + +/* Mips magics */ +#define MIPSEBMAGIC 0x160 +#define MIPSELMAGIC 0x161 +#define SMIPSEBMAGIC 0x6001 +#define SMIPSELMAGIC 0x162 /*0x6201*/ +#define MIPSEBUMAGIC 0x0180 +#define MIPSELUMAGIC 0x0182 + + + +#define ECOFFBADMAG(x) (((x).f_magic!=MIPSEBMAGIC) &&\ + ((x).f_magic!=MIPSELMAGIC) &&\ + ((x).f_magic!=SMIPSEBMAGIC) &&\ + ((x).f_magic!=SMIPSELMAGIC) &&\ + ((x).f_magic!=MIPSEBUMAGIC) &&\ + ((x).f_magic!=MIPSELUMAGIC)) + +/** 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) - +#define FILHDR struct external_filehdr +#define FILHSZ 20 /********************** AOUT "OPTIONAL HEADER" **********************/ @@ -89,7 +116,7 @@ typedef struct { #define SASMAGIC (010000) /* (?) "Single Address Space" */ #define MASMAGIC (020000) /* (?) "Multiple (separate I/D) Addr. Spaces" */ -typedef struct aouthdr { +struct internal_aouthdr { short magic; /* type of file */ short vstamp; /* version stamp */ unsigned long tsize; /* text size in bytes, padded to FW bdry*/ @@ -101,9 +128,31 @@ typedef struct aouthdr { #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; + unsigned long data_start; /* base of data used for this + file */ +#ifndef MIPS + unsigned long tagentries; /* number of tag entries to + follow */ +#endif + +} ; + + +typedef struct +{ + char magic[2]; /* type of file */ + char vstamp[2]; /* version stamp */ + char tsize[4]; /* text size in bytes, padded to FW bdry*/ + char dsize[4]; /* initialized data " " */ + char bsize[4]; /* uninitialized data " " */ + char entry[4]; /* entry pt. */ + char text_start[4]; /* base of text used for this file */ + char data_start[4]; /* base of data used for this file */ +#ifndef MIPS + char tagentries[4]; /* number of tag entries to follow */ +#endif +} +AOUTHDR; /* return a pointer to the tag bits array */ @@ -163,7 +212,7 @@ typedef struct aouthdr { /********************** SECTION HEADER **********************/ -struct scnhdr { +struct internal_scnhdr { char s_name[8]; /* section name */ long s_paddr; /* physical address, aliased s_nlib */ long s_vaddr; /* virtual address */ @@ -180,6 +229,23 @@ struct scnhdr { #endif }; +struct external_scnhdr { + char s_name[8]; /* section name */ + char s_paddr[4]; /* physical address, aliased s_nlib */ + char s_vaddr[4]; /* virtual address */ + char s_size[4]; /* section size */ + char s_scnptr[4]; /* file ptr to raw data for section */ + char s_relptr[4]; /* file ptr to relocation */ + char s_lnnoptr[4]; /* file ptr to line numbers */ + char s_nreloc[2]; /* number of relocation entries */ + char s_nlnno[2]; /* number of line number entries*/ + char s_flags[4]; /* flags */ +#ifndef MIPS + /* This field exists in Intel COFF, not in Mips ECOFF. */ + char s_align[4]; /* section alignment */ +#endif +}; + /* * names of "special" sections */ @@ -211,7 +277,7 @@ struct scnhdr { #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 SCNHDR struct external_scnhdr #define SCNHSZ sizeof(SCNHDR) @@ -227,7 +293,7 @@ struct external_lineno { char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ char l_paddr[4]; /* (physical) address of line number */ } l_addr; - unsigned short l_lnno; /* line number */ + char l_lnno[2]; /* line number */ char padding[2]; /* force alignment */ }; @@ -462,9 +528,9 @@ union internal_auxent { }; #define SYMENT struct external_syment -#define SYMESZ sizeof(SYMENT) +#define SYMESZ sizeof(SYMENT) /* FIXME - calc by hand */ #define AUXENT union external_auxent -#define AUXESZ sizeof(AUXENT) +#define AUXESZ sizeof(AUXENT) /* FIXME - calc by hand */ # define _ETEXT "_etext" diff --git a/include/coff-m68k.h b/include/coff-m68k.h index 10672a1..06c6912 100755 --- a/include/coff-m68k.h +++ b/include/coff-m68k.h @@ -3,14 +3,25 @@ /********************** 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 */ +struct external_filehdr { + char f_magic[2]; /* magic number */ + char f_nscns[2]; /* number of sections */ + char f_timdat[4]; /* time & date stamp */ + char f_symptr[4]; /* file pointer to symtab */ + char f_nsyms[4]; /* number of symtab entries */ + char f_opthdr[2]; /* sizeof(optional hdr) */ + char f_flags[2]; /* flags */ +}; + +struct internal_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: @@ -41,25 +52,41 @@ struct filehdr { -#define FILHDR struct filehdr +#define FILHDR struct external_filehdr #define FILHSZ sizeof(FILHDR) /********************** AOUT "OPTIONAL HEADER" **********************/ - -typedef struct aouthdr { +struct internal_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 */ -} AOUTHDR; + unsigned long tagentries; /* number of tag entries to follow */ +} ; +typedef struct +{ + char magic[2]; /* type of file */ + char vstamp[2]; /* version stamp */ + char tsize[4]; /* text size in bytes, padded to FW bdry*/ + char dsize[4]; /* initialized data " " */ + char bsize[4]; /* uninitialized data " " */ + char entry[4]; /* entry pt. */ + char text_start[4]; /* base of text used for this file */ + char data_start[4]; /* base of data used for this file */ + char tagentries[4]; /* number of tag entries to follow */ +} +AOUTHDR; #define AOUTSZ (sizeof(AOUTHDR)) @@ -98,7 +125,7 @@ typedef struct aouthdr { /********************** SECTION HEADER **********************/ -struct scnhdr { +struct internal_scnhdr { char s_name[8]; /* section name */ long s_paddr; /* physical address, aliased s_nlib */ long s_vaddr; /* virtual address */ @@ -109,7 +136,19 @@ struct scnhdr { unsigned short s_nreloc; /* number of relocation entries */ unsigned short s_nlnno; /* number of line number entries*/ long s_flags; /* flags */ +}; +struct external_scnhdr { + char s_name[8]; /* section name */ + char s_paddr[4]; /* physical address, aliased s_nlib */ + char s_vaddr[4]; /* virtual address */ + char s_size[4]; /* section size */ + char s_scnptr[4]; /* file ptr to raw data for section */ + char s_relptr[4]; /* file ptr to relocation */ + char s_lnnoptr[4]; /* file ptr to line numbers */ + char s_nreloc[2]; /* number of relocation entries */ + char s_nlnno[2]; /* number of line number entries*/ + char s_flags[4]; /* flags */ }; /* @@ -143,7 +182,7 @@ struct scnhdr { #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 SCNHDR struct external_scnhdr #define SCNHSZ sizeof(SCNHDR) diff --git a/include/coff-m88k.h b/include/coff-m88k.h index 64a7a01..e5a2de8 100755 --- a/include/coff-m88k.h +++ b/include/coff-m88k.h @@ -1,15 +1,25 @@ /*** coff information for 88k bcs */ /********************** FILE HEADER **********************/ +struct external_filehdr { + char f_magic[2]; /* magic number */ + char f_nscns[2]; /* number of sections */ + char f_timdat[4]; /* time & date stamp */ + char f_symptr[4]; /* file pointer to symtab */ + char f_nsyms[4]; /* number of symtab entries */ + char f_opthdr[2]; /* sizeof(optional hdr) */ + char f_flags[2]; /* flags */ +}; -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 */ +struct internal_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: @@ -32,7 +42,7 @@ struct filehdr { #define MC88BADMAG(x) (((x).f_magic!=MC88MAGIC) &&((x).f_magic!=MC88DMAGIC) && ((x).f_magic != MC88OMAGIC)) -#define FILHDR struct filehdr +#define FILHDR struct external_filehdr #define FILHSZ sizeof(FILHDR) @@ -42,18 +52,33 @@ struct filehdr { #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; +struct internal_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 */ + unsigned long tagentries; /* number of tag entries to follow */ +} ; + + +typedef struct +{ + char magic[2]; /* type of file */ + char vstamp[2]; /* version stamp */ + char tsize[4]; /* text size in bytes, padded to FW bdry*/ + char dsize[4]; /* initialized data " " */ + char bsize[4]; /* uninitialized data " " */ + char entry[4]; /* entry pt. */ + char text_start[4]; /* base of text used for this file */ + char data_start[4]; /* base of data used for this file */ + char tagentries[4]; /* number of tag entries to follow */ +} +AOUTHDR; /* compute size of a header */ @@ -95,17 +120,32 @@ typedef struct aouthdr { /********************** 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 */ +struct internal_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 long s_nreloc; /* number of relocation entries */ + unsigned long s_nlnno; /* number of line number entries*/ + long s_flags; /* flags */ +}; + +struct external_scnhdr +{ + char s_name[8]; /* section name */ + char s_paddr[4]; /* physical address, aliased s_nlib */ + char s_vaddr[4]; /* virtual address */ + char s_size[4]; /* section size */ + char s_scnptr[4]; /* file ptr to raw data for section */ + char s_relptr[4]; /* file ptr to relocation */ + char s_lnnoptr[4]; /* file ptr to line numbers */ + char s_nreloc[4]; /* number of relocation entries */ + char s_nlnno[4]; /* number of line number entries*/ + char s_flags[4]; /* flags */ }; /* @@ -122,7 +162,7 @@ struct scnhdr { #define STYP_DATA 0x40 /* section contains data only */ #define STYP_BSS 0x80 /* section contains bss only */ -#define SCNHDR struct scnhdr +#define SCNHDR struct external_scnhdr #define SCNHSZ sizeof(SCNHDR) diff --git a/include/oasys.h b/include/oasys.h index 642f752..b54a3fe 100644 --- a/include/oasys.h +++ b/include/oasys.h @@ -16,6 +16,19 @@ typedef struct { } oasys_archive_header_type; typedef struct { + char version[4]; + char create_date[12]; + char revision_date[12]; + char mod_count[4]; + char mod_tbl_offset[4]; + char sym_tbl_size[4]; + char sym_count[4]; + char sym_tbl_offset[4]; + char xref_count[4]; + char xref_lst_offset[4]; +} oasys_external_archive_header_type; + +typedef struct { int32_type mod_number; char mod_date[12]; int32_type mod_size; @@ -27,6 +40,18 @@ typedef struct { } oasys_module_table_type; +typedef struct { + char mod_number[4]; + char mod_date[12]; + char mod_size[4]; + char dep_count[4]; + char depee_count[4]; + char sect_count[4]; + char file_offset[4]; + char mod_name_length[4]; +} oasys_external_module_table_type; + + typedef enum { oasys_record_is_end_enum = 0, oasys_record_is_data_enum = 1, -- 2.7.4