📄 coff.h
字号:
/* @(#)coff.h 1.8 91/12/16 16:48:10, AMD *//********************************************************************* 29K COFF Declarations **** **** **** This file contains the declarations required to define **** the COFF format as proposed for use by AMD for the 29K **** family of RISC microprocessors. **** **** No attempt is made here to describe in detail those portions **** of COFF which have not been modified or extended. Pertinent **** #define's and struct's are included for completeness. Those **** declarations are distributed in several System V headers. **** **** For a better and more complete description of COFF with **** general and 29K Family specific clarifications, see the **** AMD's "Programmer's Guide to the Common Object File Format **** (COFF) for the Am29000" Application Note, order number 11963.**** **** For non-29K-Family specific COFF information, consult AT&T **** UNIX System V Release 3, Programmer's Guide, Chapter 11 **** (Manual 307-225, Issue 1). **** **** **** Revision history: **** **** 0.01 JG - first published **** 0.02 JG - added relocation type R_IFAR and renumbered **** 0.03 RC - COFF spec now compiles without error **** 0.04 RC - removed R_IPAIR and R_IFAR and renumbered **** 0.05 RC - added R_HWORD relocation type **** 0.06 RC - section types **** changed value of STYP_BSSREG **** replaced STYP_RDATA and STYP_IDATA **** with STYP_LIT, STYP_ABS, and STYP_ENVIR **** - relocation types **** added R_IABS **** replaced R_IBYTE with R_BYTE and renumbered **** - changed comments and removed comments **** 0.07 RC - relocation types **** Added R_IHCONST to support relocation offsets **** for CONSTH instruction. Added commentary, **** and renumbered to make room for R_IHCONST, **** putting the (as yet unused) global reloc **** types at the end. **** - bug fix (typo) **** Added slash to terminate comment field on **** C_EXT so now C_STAT is defined. **** 0.08 RC - official magic numbers assigned by AT&T. **** 0.09 RC - support multiple address spaces by adding magic **** a.out header numbers SASMAGIC and MASMAGIC. **** 0.10 RC - No changes. Just added the comments below and **** corrected comments on tsize, dsize, and bsize. **** - All portions of the COFF file described as C **** structs must use Host Endian byte ordering. **** Files created on a machine with a byte **** ordering different from the host may be **** converted using the UNIX conv(1) command. **** - Assemblers and compilers must create section **** headers for .text, .data, and .bss (in that **** order) even if they are 0 length. **** - tsize, dsize, and bsize are the size of .text, **** .data, and .bss respectively. Other sections **** of type STYP_TEXT, STYP_DATA, and STYP_BSS **** are not included in the byte count. **** - Assemblers and compilers must create output **** sections to the exact byte length (and not **** round them up). The linker will take care **** of rounding. **** 2.1.01 - Added C_STARTOF storage class for support of **** assembler $startof(sect_name) and **** $sizeof(sect_name) operators. **** 2.1.02 - Added a few more defines for completeness. **** 2.1.03 - Added more magic numbers for completeness. *********************************************************************//*** Overall structure of a COFF file*//* *--------------------------------* | File Header | ---------------------------------- | Optional Information | ---------------------------------- | Section 1 Header | ---------------------------------- | ... | ---------------------------------- | Section n Header | ---------------------------------- | Raw Data for Section 1 | ---------------------------------- | ... | ---------------------------------- | Raw Data for Section n | ---------------------------------- | Relocation Info for Section 1 | ---------------------------------- | ... | ---------------------------------- | Relocation Info for Section n | ---------------------------------- | Line Numbers for Section 1 | ---------------------------------- | ... | ---------------------------------- | Line Numbers for Section n | ---------------------------------- | Symbol Table | ---------------------------------- | String Table | *--------------------------------**/ /****************************************************************//*** File Header and related definitions*/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 */};#define FILHDR struct filehdr#define FILHSZ sizeof (FILHDR)/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*//*** Magic numbers currently known to us,** Plus 29K magic numbers assigned by AT&T.*/#define M68MAGIC 0210#define M68TVMAGIC 0211#define B16MAGIC 0502#define BTVMAGIC 0503#define IAPX16 0504#define IAPX16TV 0505#define IAPX20 0506#define IAPX20TV 0507#define X86MAGIC 0510#define XTVMAGIC 0511#define I286SMAGIC 0512#define I386MAGIC 0514#define MC68MAGIC 0520#define MC68KWRMAGIC 0520 /* 68K writeable text sections */#define MC68TVMAGIC 0521#define MC68KPGMAGIC 0522 /* 68K demand paged text (shared with i286) */#define I286LMAGIC 0522 /* i286 (shared with 68K) *//* 0524 * reserved for NSC *//* 0525 * reserved for NSC *//* 0544 * reserved for Zilog *//* 0545 * reserved for Zilog */#define N3BMAGIC 0550 /* 3B20S executable, no TV */ #define NTVMAGIC 0551 /* 3B20 executable with TV */#define FBOMAGIC 0560 /* WE*-32 (Forward Byte Ordering) */#define WE32MAGIC 0560 /* WE 32000, no TV */#define MTVMAGIC 0561 /* WE 32000 with TV */#define RBOMAGIC 0562 /* WE-32 (Reverse Byte Ordering) */#define VAXWRMAGIC 0570 /* VAX-11/750 and VAX-11/780 */ /* (writable text sections) */#define VAXROMAGIC 0575 /* VAX-11/750 and VAX-11780 */ /* (read-only text sections) */#define U370WRMAGIC 0530 /* IBM 370 (writable text sections) */#define AMDWRMAGIC 0531 /* Amdahl 470/580 writable text sections */#define AMDROMAGIC 0534 /* Amdahl 470/580 read only sharable text */#define U370ROMAGIC 0535 /* IBM 370 (read-only sharable text sections) */#define SIPFBOMAGIC 0572 /* 29K Family (Byte 0 is MSB - Big Endian) */#define SIPRBOMAGIC 0573 /* 29K Family (Byte 0 is LSB - Little Endian) *//* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*//*** File header flags currently known to us.**** Am29000 will use the F_AR32WR and F_AR32W flags to indicate** the byte ordering in the file.*/#define F_RELFLG 00001 /* Relocation information stripped */ /* from the file. */#define F_EXEC 00002 /* File is executable (i.e. no */ /* unresolved external references). */#define F_LNNO 00004 /* Line numbers stripped from */ /* the file. */#define F_LSYMS 00010 /* Local symbols stripped from */ /* the file. */#define F_MINMAL 00020 /* Not used by UNIX. */#define F_UPDATE 00040 /* Not used by UNIX. */#define F_SWABD 00100 /* Not used by UNIX. */#define F_AR16WR 00200 /* File has the byte ordering used */ /* by the PDP*-11/70 processor. */#define F_AR32WR 00400 /* File has 32 bits per word, */ /* least significant byte first. */#define F_AR32W 01000 /* File has 32 bits per word, */ /* most significant byte first. */#define F_PATCH 02000 /* Not used by UNIX. */#define F_BM32BRST 0010000 /* 32100 required; has RESTORE work-around. */#define F_BM32B 0020000 /* 32100 required. */#define F_BM32MAU 0040000 /* MAU required. */#define F_BM32ID 0160000 /* WE 32000 processor ID field. *//*--------------------------------------------------------------*//*** Optional (a.out) header */typedef struct aouthdr { short magic; /* magic number */ short vstamp; /* version stamp */ long tsize; /* size of .text in bytes */ long dsize; /* size of .data (initialized data) */ long bsize; /* size of .bss (uninitialized data) */ long entry; /* entry point */ long text_start; /* base of text used for this file */ long data_start; /* base of data used for this file */} AOUTHDR;/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*//*** Magic a.out header numbers for cross development (non-UNIX),** support of separate I and D address spaces.*/#define SASMAGIC 010000 /* Single Address Space */ #define MASMAGIC 020000 /* Multiple (separate I & D) Address Spaces *//*--------------------------------------------------------------*//*** Section header and related definitions*/struct scnhdr { char s_name[8]; /* 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 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 */};#define SCNHDR struct scnhdr#define SCNHSZ sizeof (SCNHDR)/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*//*** Section types - with additional section type for global ** registers which will be relocatable for the Am29000.**** In instances where it is necessary for a linker to produce an** output file which contains text or data not based at virtual** address 0, e.g. for a ROM, then the linker should accept** address base information as command input and use PAD sections** to skip over unused addresses.*/#define STYP_REG 0x00 /* Regular section (allocated, */ /* relocated, loaded) */#define STYP_DSECT 0x01 /* Dummy section (not allocated, */ /* relocated, not loaded) */#define STYP_NOLOAD 0x02 /* Noload section (allocated, */ /* relocated, not loaded) */#define STYP_GROUP 0x04 /* Grouped section (formed from */ /* input sections) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -