scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit bd570a1ef1dbec67feecf715db543f08a3cd9f29
parent 6781c8de92991e861efec7bae7f96d64b2c9bb4b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue,  6 Mar 2018 12:19:15 +0100

Add COFF 32 bit version includes

These includes are derivated from the clasical coff headers
of UNIX System V.

Diffstat:
Ainc/coff32/aouthdr.h | 15+++++++++++++++
Ainc/coff32/filehdr.h | 22++++++++++++++++++++++
Ainc/coff32/linenum.h | 11+++++++++++
Ainc/coff32/reloc.h | 8++++++++
Ainc/coff32/scnhdr.h | 38++++++++++++++++++++++++++++++++++++++
Ainc/coff32/syms.h | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 179 insertions(+), 0 deletions(-)

diff --git a/inc/coff32/aouthdr.h b/inc/coff32/aouthdr.h @@ -0,0 +1,15 @@ + +/* This file is inspired in the book "Understanding and using COFF" */ + +struct aouthdr { + short magic; /* magic number */ + short vstamp; /* version stamp */ + long tsize; /* text size in bytes */ + long dsize; /* initialized data size */ + long bsize; /* uinitialized data size */ + long entry; /* entry point */ + long text_start; /* base of text segment */ + long data_start; /* base of data segment */ +}; + +typedef struct aouthdr AOUTHDR; diff --git a/inc/coff32/filehdr.h b/inc/coff32/filehdr.h @@ -0,0 +1,22 @@ + +/* This file is inspired in the book "Understanding and using COFF" */ + +struct filehdr { + unsigned short f_magic; /* magic number */ + unsigned short f_nscns; /* number of sections */ + long f_timdat; /* time stamp */ + long f_symptr; /* file pointer to symbols */ + long f_nsyms; /* number of symbols */ + unsigned short f_opthdr; /* size of optional header */ + unsigned short f_flags; /* file flags */ +}; + +#define FILHDR struct filehdr +#define FILHSZ 20 + +#define F_RELFLG (1 << 0) +#define F_EXEC (1 << 1) +#define F_LMNO (1 << 2) +#define F_SYMS (1 << 3) + +#define COFF_Z80MAGIC 0x805a diff --git a/inc/coff32/linenum.h b/inc/coff32/linenum.h @@ -0,0 +1,11 @@ + +/* This file is inspired in the book "Understanding and using COFF" */ + +struct lineno { + long l_symndx; /* index in table symbol if l_lnno == 0 */ + long l_paddr; /* Break pointable address if l_lnno > 0 */ + unsigned short l_lnno; /* Line number */ +}; + +#define LINENO struct lineno +#define LINESZ 6 diff --git a/inc/coff32/reloc.h b/inc/coff32/reloc.h @@ -0,0 +1,8 @@ + +/* This file is inspired in the book "Understanding and using COFF" */ + +struct reloc { + long r_vaddr; /* address of reference */ + long r_symndx; /* index into symbol table */ + unsignedd short r_type; /* relocation type */ +}; diff --git a/inc/coff32/scnhdr.h b/inc/coff32/scnhdr.h @@ -0,0 +1,38 @@ + +/* This file is inspired in the book "Understanding and using COFF" */ + +#define SCNNMLEN 8 + +struct scnhdr { + char s_name[SCNNMLEN]; /* section name */ + long s_paddr; /* physical address */ + long s_vaddr; /* virtual address */ + long s_size; /* section size */ + long s_scnptr; /* file ptr to raw data */ + long s_relptr; /* file ptr to relo info */ + long s_lnnoptr; /* file ptr to line number */ + unsigned short s_nrelloc; /* number of relocation entries */ + unsigned short s_nlnno; /* number of lines entries */ + long s_flags; /* type and content flags */ +}; + +#define SCNHDR struct scnhdr +#define SCNHSZ 40 + +#define STYP_REG 0 +#define STYP_DSECT (1 << 0) +#define STYP_NOLOAD (1 << 1) +#define STYP_GROUP (1 << 2) +#define STYP_PAD (1 << 3) +#define STYP_COPY (1 << 4) +#define STYP_TEXT (1 << 5) +#define S_SHRSEG (1 << 6) +#define STYP_DATA (1 << 7) +#define STYP_BSS (1 << 8) +#define S_NEWFCN (1 << 9) +#define STYP_INFO (1 << 10) +#define STYP_OVER (1 << 11) +#define STYP_LIB (1 << 12) +#define STYP_MERGE (1 << 13) +#define STYP_REVERSE_PAD (1 << 14) +#define STYP_LIT 0x8020 diff --git a/inc/coff32/syms.h b/inc/coff32/syms.h @@ -0,0 +1,85 @@ + +/* This file is inspired in the book "Understanding and using COFF" */ + +struct syment { + union { + char _n_name[8]; /* symbol name */ + struct { + long _n_zeroes; /* if _n_name[0-3] == 0 */ + long _n_offset; /* offset into string table */ + } _n_n; + char _n_ptr[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 */ +}; + +#define n_name _n._n_name +#define n_nptr _n._n_nptr[1] +#define n_zeroes _n._n_n._n_zeroes +#define n_offset _n._n_n._n_offset + +/* Special n_scnum values */ +#define N_DEBUG -2 +#define N_ABS -1 +#define N_UNDEF 0 + +/* basic types */ +#define T_NULL 0 +#define T_VOID 1 +#define T_CHAR 2 +#define T_SHORT 3 +#define T_INT 4 +#define T_LONG 5 +#define T_FLOAT 6 +#define T_DOUBLE 7 +#define T_STRUCT 8 +#define T_UNION 9 +#define T_ENUM 10 +#define T_MOE 11 +#define T_UCHAR 12 +#define T_USHORT 13 +#define T_UINT 14 +#define T_ULONG 15 +#define T_LNGDBL 16 + +/* derivated types */ +#define DT_NON 0 +#define DT_PTR 1 +#define DT_FCN 2 +#define DT_ARY 3 + +/* storage class */ +#define C_NULL 0 +#define C_AUTO 1 +#define C_EXT 2 +#define C_STAT 3 +#define C_REG 4 +#define C_EXTDEF 5 +#define C_LABEL 6 +#define C_ULABEL 7 +#define C_MOS 8 +#define C_ARG 9 +#define C_STRTAG 10 +#define C_MOU 11 +#define C_UNTAG 12 +#define C_TPDEF 13 +#define C_USTATIC 14 +#define C_ENTAG 15 +#define C_MOE 16 +#define C_REGPARM 17 +#define C_FIELD 18 +#define C_AUTOARG 19 +#define C_LASTENT 20 +#define C_BLOCK 100 +#define C_FCN 101 +#define C_EOS 102 +#define C_FILE 103 +#define C_LINE 104 +#define C_ALIAS 105 +#define C_HIDDEN 106 +#define C_WEAKEXT 127 +#define C_EFCN 255