#ifndef TCC_OBJECT_COFF_H # define TCC_OBJECT_COFF_H 1 # include /** * @defgroup object_coff COFF Object * @ingroup object * @{ */ # define COFF_MAGIC 0x14c typedef struct COFFFileHeader { uint16_t magic; uint16_t nscns; int32_t timdat; int32_t nsyms; uint16_t opthdr; uint16_t flags; } COFFFileHeader; # define COFF_FILHSZ sizeof(COFFFileHeader) # define COFF_F_RELFLG 0x0001 # define COFF_F_EXEC 0x0002 # define COFF_F_LNNO 0x0004 # define COFF_F_LSYMS 0x0008 # define COFF_F_LITTLE 0x0100 # define COFF_F_BIG 0x0200 # define COFF_F_SYMMERGE 0x1000 typedef struct AOutHeader { int16_t magic; int16_t vstamp; int32_t tsize; int32_t dsize; int32_t bsize; int32_t entry; int32_t text_start; int32_t data_start; } AOutHeader; # define AOUT_HSZ sizeof(AOutHeader) # define AOUT_OMAGIC 0404 # define AOUT_NMAGIC 0410 # define AOUT_ZMAGIC 0413 # define AOUT_STMAGIC 0401 # define AOUT_SHMAGIC 0443 typedef struct COFFSectionHeader { int8_t name[8]; int32_t paddr; int32_t vaddr; int32_t size; int32_t scnptr; int32_t relptr; int32_t lnnoptr; uint16_t nreloc; uint16_t nlnno; int32_t flags; } COFFSectionHeader; # define COFF_STYP_REG 0x000 # define COFF_STYP_DSECT 0x001 # define COFF_STYP_NOLOAD 0x002 # define COFF_STYP_GROUP 0x004 # define COFF_STYP_PAD 0x008 # define COFF_STYP_COPY 0x010 # define COFF_STYP_TEXT 0x020 # define COFF_STYP_DATA 0x040 # define COFF_STYP_BSS 0x080 # define COFF_STYP_RODATA 0x100 /** stupidos extension */ # define COFF_STYP_INFO 0x200 # define COFF_STYP_OVER 0x400 # define COFF_STYP_LIB 0x800 typedef struct COFFReloc { uint32_t vaddr; uint32_t symndx; uint16_t type; } COFFReloc; # define COFF_R_ABS 0 # define COFF_R_DIR32 06 # define COFF_R_SEG12 011 # define COFF_R_PCRLONG 024 # define COFF_SYMNMLEN 8 typedef struct COFFSym { union { char name[COFF_SYMNMLEN]; struct { int32_t zeroes; int32_t offset; } n; } n; uint32_t value; int16_t scnum; uint16_t type; int8_t sclass; int8_t numaux; } COFFSym; # define COFF_N_UNDEF 0 # define COFF_N_ABS -1 # define COFF_C_EFCN -1 /* physical end of a function */ # define COFF_C_NULL 0 # define COFF_C_AUTO 1 # define COFF_C_EXT 2 /* external symbol */ # define COFF_C_STAT 3 /* static */ # define COFF_C_REG 4 /* register var */ # define COFF_C_EXTDEF 5 /* external definition */ # define COFF_C_LABEL 6 # define COFF_C_ULABEL 7 /* undefined label */ # define COFF_C_MOS 8 /* member of struct */ # define COFF_C_ARG 9 # define COFF_C_STRTAG 10 /* struct tag */ # define COFF_C_MOU 11 /* member of union */ # define COFF_C_UNTAG 12 /* union tag */ # define COFF_C_TPDEF 13 /* typedef */ # define COFF_C_USTATIC 14 # define COFF_C_ENTAG 15 # define COFF_C_MOE 16 # define COFF_C_REGPARM 17 # define COFF_C_FIELD 18 # define COFF_C_BLOCK 100 # define COFF_C_FCN 101 # define COFF_C_EOS 102 # define COFF_C_FILE 103 # define COFF_C_LINE 104 # define COFF_C_ALIAS 105 # define COFF_C_HIDDEN 106 # define COFF_DT_FUNC (2 << 2) # define COFF_DT_NON (0 << 2) # define COFF_DT_PTR (1 << 2) # define COFF_DT_FCN (2 << 2) # define COFF_DT_ARY (3 << 2) /** * @} */ #endif /* !TCC_COFF_H */