i386.h revision 33965
133965Sjdp/*** coff information for Intel 386/486. */ 233965Sjdp 333965Sjdp 433965Sjdp/********************** FILE HEADER **********************/ 533965Sjdp 633965Sjdpstruct external_filehdr { 733965Sjdp char f_magic[2]; /* magic number */ 833965Sjdp char f_nscns[2]; /* number of sections */ 933965Sjdp char f_timdat[4]; /* time & date stamp */ 1033965Sjdp char f_symptr[4]; /* file pointer to symtab */ 1133965Sjdp char f_nsyms[4]; /* number of symtab entries */ 1233965Sjdp char f_opthdr[2]; /* sizeof(optional hdr) */ 1333965Sjdp char f_flags[2]; /* flags */ 1433965Sjdp}; 1533965Sjdp 1633965Sjdp/* Bits for f_flags: 1733965Sjdp * F_RELFLG relocation info stripped from file 1833965Sjdp * F_EXEC file is executable (no unresolved external references) 1933965Sjdp * F_LNNO line numbers stripped from file 2033965Sjdp * F_LSYMS local symbols stripped from file 2133965Sjdp * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) 2233965Sjdp */ 2333965Sjdp 2433965Sjdp#define F_RELFLG (0x0001) 2533965Sjdp#define F_EXEC (0x0002) 2633965Sjdp#define F_LNNO (0x0004) 2733965Sjdp#define F_LSYMS (0x0008) 2833965Sjdp 2933965Sjdp 3033965Sjdp 3133965Sjdp#define I386MAGIC 0x14c 3233965Sjdp#define I386PTXMAGIC 0x154 3333965Sjdp#define I386AIXMAGIC 0x175 3433965Sjdp 3533965Sjdp/* This is Lynx's all-platform magic number for executables. */ 3633965Sjdp 3733965Sjdp#define LYNXCOFFMAGIC 0415 3833965Sjdp 3933965Sjdp#define I386BADMAG(x) (((x).f_magic != I386MAGIC) \ 4033965Sjdp && (x).f_magic != I386AIXMAGIC \ 4133965Sjdp && (x).f_magic != I386PTXMAGIC \ 4233965Sjdp && (x).f_magic != LYNXCOFFMAGIC) 4333965Sjdp 4433965Sjdp#define FILHDR struct external_filehdr 4533965Sjdp#define FILHSZ 20 4633965Sjdp 4733965Sjdp 4833965Sjdp/********************** AOUT "OPTIONAL HEADER" **********************/ 4933965Sjdp 5033965Sjdp 5133965Sjdptypedef struct 5233965Sjdp{ 5333965Sjdp char magic[2]; /* type of file */ 5433965Sjdp char vstamp[2]; /* version stamp */ 5533965Sjdp char tsize[4]; /* text size in bytes, padded to FW bdry*/ 5633965Sjdp char dsize[4]; /* initialized data " " */ 5733965Sjdp char bsize[4]; /* uninitialized data " " */ 5833965Sjdp char entry[4]; /* entry pt. */ 5933965Sjdp char text_start[4]; /* base of text used for this file */ 6033965Sjdp char data_start[4]; /* base of data used for this file */ 6133965Sjdp 6233965Sjdp 6333965Sjdp} 6433965SjdpAOUTHDR; 6533965Sjdp 6633965Sjdp 6733965Sjdp#define AOUTSZ 28 6833965Sjdp#define AOUTHDRSZ 28 6933965Sjdp 7033965Sjdp#define OMAGIC 0404 /* object files, eg as output */ 7133965Sjdp#define ZMAGIC 0413 /* demand load format, eg normal ld output */ 7233965Sjdp#define STMAGIC 0401 /* target shlib */ 7333965Sjdp#define SHMAGIC 0443 /* host shlib */ 7433965Sjdp 7533965Sjdp 7633965Sjdp/* define some NT default values */ 7733965Sjdp/* #define NT_IMAGE_BASE 0x400000 moved to internal.h */ 7833965Sjdp#define NT_SECTION_ALIGNMENT 0x1000 7933965Sjdp#define NT_FILE_ALIGNMENT 0x200 8033965Sjdp#define NT_DEF_RESERVE 0x100000 8133965Sjdp#define NT_DEF_COMMIT 0x1000 8233965Sjdp 8333965Sjdp/********************** SECTION HEADER **********************/ 8433965Sjdp 8533965Sjdp 8633965Sjdpstruct external_scnhdr { 8733965Sjdp char s_name[8]; /* section name */ 8833965Sjdp char s_paddr[4]; /* physical address, aliased s_nlib */ 8933965Sjdp char s_vaddr[4]; /* virtual address */ 9033965Sjdp char s_size[4]; /* section size */ 9133965Sjdp char s_scnptr[4]; /* file ptr to raw data for section */ 9233965Sjdp char s_relptr[4]; /* file ptr to relocation */ 9333965Sjdp char s_lnnoptr[4]; /* file ptr to line numbers */ 9433965Sjdp char s_nreloc[2]; /* number of relocation entries */ 9533965Sjdp char s_nlnno[2]; /* number of line number entries*/ 9633965Sjdp char s_flags[4]; /* flags */ 9733965Sjdp}; 9833965Sjdp 9933965Sjdp#define SCNHDR struct external_scnhdr 10033965Sjdp#define SCNHSZ 40 10133965Sjdp 10233965Sjdp/* 10333965Sjdp * names of "special" sections 10433965Sjdp */ 10533965Sjdp#define _TEXT ".text" 10633965Sjdp#define _DATA ".data" 10733965Sjdp#define _BSS ".bss" 10833965Sjdp#define _COMMENT ".comment" 10933965Sjdp#define _LIB ".lib" 11033965Sjdp 11133965Sjdp/********************** LINE NUMBERS **********************/ 11233965Sjdp 11333965Sjdp/* 1 line number entry for every "breakpointable" source line in a section. 11433965Sjdp * Line numbers are grouped on a per function basis; first entry in a function 11533965Sjdp * grouping will have l_lnno = 0 and in place of physical address will be the 11633965Sjdp * symbol table index of the function name. 11733965Sjdp */ 11833965Sjdpstruct external_lineno { 11933965Sjdp union { 12033965Sjdp char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ 12133965Sjdp char l_paddr[4]; /* (physical) address of line number */ 12233965Sjdp } l_addr; 12333965Sjdp char l_lnno[2]; /* line number */ 12433965Sjdp}; 12533965Sjdp 12633965Sjdp 12733965Sjdp#define LINENO struct external_lineno 12833965Sjdp#define LINESZ 6 12933965Sjdp 13033965Sjdp 13133965Sjdp/********************** SYMBOLS **********************/ 13233965Sjdp 13333965Sjdp#define E_SYMNMLEN 8 /* # characters in a symbol name */ 13433965Sjdp#define E_FILNMLEN 14 /* # characters in a file name */ 13533965Sjdp#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ 13633965Sjdp 13733965Sjdpstruct external_syment 13833965Sjdp{ 13933965Sjdp union { 14033965Sjdp char e_name[E_SYMNMLEN]; 14133965Sjdp struct { 14233965Sjdp char e_zeroes[4]; 14333965Sjdp char e_offset[4]; 14433965Sjdp } e; 14533965Sjdp } e; 14633965Sjdp char e_value[4]; 14733965Sjdp char e_scnum[2]; 14833965Sjdp char e_type[2]; 14933965Sjdp char e_sclass[1]; 15033965Sjdp char e_numaux[1]; 15133965Sjdp}; 15233965Sjdp 15333965Sjdp#define N_BTMASK (0xf) 15433965Sjdp#define N_TMASK (0x30) 15533965Sjdp#define N_BTSHFT (4) 15633965Sjdp#define N_TSHIFT (2) 15733965Sjdp 15833965Sjdpunion external_auxent { 15933965Sjdp struct { 16033965Sjdp char x_tagndx[4]; /* str, un, or enum tag indx */ 16133965Sjdp union { 16233965Sjdp struct { 16333965Sjdp char x_lnno[2]; /* declaration line number */ 16433965Sjdp char x_size[2]; /* str/union/array size */ 16533965Sjdp } x_lnsz; 16633965Sjdp char x_fsize[4]; /* size of function */ 16733965Sjdp } x_misc; 16833965Sjdp union { 16933965Sjdp struct { /* if ISFCN, tag, or .bb */ 17033965Sjdp char x_lnnoptr[4]; /* ptr to fcn line # */ 17133965Sjdp char x_endndx[4]; /* entry ndx past block end */ 17233965Sjdp } x_fcn; 17333965Sjdp struct { /* if ISARY, up to 4 dimen. */ 17433965Sjdp char x_dimen[E_DIMNUM][2]; 17533965Sjdp } x_ary; 17633965Sjdp } x_fcnary; 17733965Sjdp char x_tvndx[2]; /* tv index */ 17833965Sjdp } x_sym; 17933965Sjdp 18033965Sjdp union { 18133965Sjdp char x_fname[E_FILNMLEN]; 18233965Sjdp struct { 18333965Sjdp char x_zeroes[4]; 18433965Sjdp char x_offset[4]; 18533965Sjdp } x_n; 18633965Sjdp } x_file; 18733965Sjdp 18833965Sjdp struct { 18933965Sjdp char x_scnlen[4]; /* section length */ 19033965Sjdp char x_nreloc[2]; /* # relocation entries */ 19133965Sjdp char x_nlinno[2]; /* # line numbers */ 19233965Sjdp char x_checksum[4]; /* section COMDAT checksum */ 19333965Sjdp char x_associated[2]; /* COMDAT associated section index */ 19433965Sjdp char x_comdat[1]; /* COMDAT selection number */ 19533965Sjdp } x_scn; 19633965Sjdp 19733965Sjdp struct { 19833965Sjdp char x_tvfill[4]; /* tv fill value */ 19933965Sjdp char x_tvlen[2]; /* length of .tv */ 20033965Sjdp char x_tvran[2][2]; /* tv range */ 20133965Sjdp } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ 20233965Sjdp 20333965Sjdp 20433965Sjdp}; 20533965Sjdp 20633965Sjdp#define SYMENT struct external_syment 20733965Sjdp#define SYMESZ 18 20833965Sjdp#define AUXENT union external_auxent 20933965Sjdp#define AUXESZ 18 21033965Sjdp 21133965Sjdp 21233965Sjdp# define _ETEXT "etext" 21333965Sjdp 21433965Sjdp 21533965Sjdp/********************** RELOCATION DIRECTIVES **********************/ 21633965Sjdp 21733965Sjdp 21833965Sjdp 21933965Sjdpstruct external_reloc { 22033965Sjdp char r_vaddr[4]; 22133965Sjdp char r_symndx[4]; 22233965Sjdp char r_type[2]; 22333965Sjdp}; 22433965Sjdp 22533965Sjdp 22633965Sjdp#define RELOC struct external_reloc 22733965Sjdp#define RELSZ 10 22833965Sjdp 229