2025-02-11 12:07:04 +00:00
|
|
|
#ifndef TCC_OBJECT_COFF_H
|
|
|
|
# define TCC_OBJECT_COFF_H 1
|
2025-02-07 16:17:17 +00:00
|
|
|
|
|
|
|
# include <stdint.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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;
|
|
|
|
|
2025-02-11 19:16:44 +00:00
|
|
|
# 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
|
2025-02-14 16:47:45 +00:00
|
|
|
# define COFF_STYP_RODATA 0x100 /** stupidos extension */
|
2025-02-11 19:16:44 +00:00
|
|
|
# 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;
|
|
|
|
|
2025-02-14 16:47:45 +00:00
|
|
|
# define COFF_N_UNDEF 0
|
|
|
|
# define COFF_N_ABS -1
|
|
|
|
|
2025-02-07 16:17:17 +00:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2025-02-11 12:07:04 +00:00
|
|
|
#endif /* !TCC_COFF_H */
|