coff.h
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C头文件 代码 · 共 606 行 · 第 1/2 页
H
606 行
IMAGE_SYM_CLASS_REGISTER = 0x0004,
IMAGE_SYM_CLASS_EXTERNAL_DEF = 0x0005,
IMAGE_SYM_CLASS_LABEL = 0x0006,
IMAGE_SYM_CLASS_UNDEFINED_LABEL = 0x0007,
IMAGE_SYM_CLASS_MEMBER_OF_STRUCT = 0x0008,
IMAGE_SYM_CLASS_ARGUMENT = 0x0009,
IMAGE_SYM_CLASS_STRUCT_TAG = 0x000A,
IMAGE_SYM_CLASS_MEMBER_OF_UNION = 0x000B,
IMAGE_SYM_CLASS_UNION_TAG = 0x000C,
IMAGE_SYM_CLASS_TYPE_DEFINITION = 0x000D,
IMAGE_SYM_CLASS_UNDEFINED_STATIC = 0x000E,
IMAGE_SYM_CLASS_ENUM_TAG = 0x000F,
IMAGE_SYM_CLASS_MEMBER_OF_ENUM = 0x0010,
IMAGE_SYM_CLASS_REGISTER_PARAM = 0x0011,
IMAGE_SYM_CLASS_BIT_FIELD = 0x0012,
IMAGE_SYM_CLASS_FAR_EXTERNAL = 0x0044, //
IMAGE_SYM_CLASS_BLOCK = 0x0064,
IMAGE_SYM_CLASS_FUNCTION = 0x0065,
IMAGE_SYM_CLASS_END_OF_STRUCT = 0x0066,
IMAGE_SYM_CLASS_FILE = 0x0067,
// new
IMAGE_SYM_CLASS_SECTION = 0x0068,
IMAGE_SYM_CLASS_WEAK_EXTERNAL = 0x0069
}image_sym_class;
//
// Communal selection types.
//
typedef enum {
IMAGE_COMDAT_SELECT_UNKNOWN = 0,
IMAGE_COMDAT_SELECT_NODUPLICATES = 1,
IMAGE_COMDAT_SELECT_ANY = 2,
IMAGE_COMDAT_SELECT_SAME_SIZE = 3,
IMAGE_COMDAT_SELECT_EXACT_MATCH = 4,
IMAGE_COMDAT_SELECT_ASSOCIATIVE = 5,
IMAGE_COMDAT_SELECT_LARGEST = 6,
IMAGE_COMDAT_SELECT_NEWEST = 7
}image_comdat_select;
// weak extern types
enum {
IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY = 1,
IMAGE_WEAK_EXTERN_SEARCH_LIBRARY = 2,
IMAGE_WEAK_EXTERN_SEARCH_ALIAS = 3
};
// Following comes from winnt.h
//
// I386 relocation types.
//
#define IMAGE_REL_I386_ABSOLUTE 0 // Reference is absolute, no relocation is necessary
#define IMAGE_REL_I386_DIR16 1 // Direct 16-bit reference to the symbols virtual address
#define IMAGE_REL_I386_REL16 2 // PC-relative 16-bit reference to the symbols virtual address
#define IMAGE_REL_I386_DIR32 6 // Direct 32-bit reference to the symbols virtual address
#define IMAGE_REL_I386_DIR32NB 7 // Direct 32-bit reference to the symbols virtual address, base not included
#define IMAGE_REL_I386_SEG12 9 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
#define IMAGE_REL_I386_SECTION 10
#define IMAGE_REL_I386_SECREL 11
#define IMAGE_REL_I386_REL32 20 // PC-relative 32-bit reference to the symbols virtual address
//
// MIPS relocation types.
//
#define IMAGE_REL_MIPS_ABSOLUTE 0x0000 // Reference is absolute, no relocation is necessary
#define IMAGE_REL_MIPS_REFHALF 0x0001
#define IMAGE_REL_MIPS_REFWORD 0x0002
#define IMAGE_REL_MIPS_JMPADDR 0x0003
#define IMAGE_REL_MIPS_REFHI 0x0004
#define IMAGE_REL_MIPS_REFLO 0x0005
#define IMAGE_REL_MIPS_GPREL 0x0006
#define IMAGE_REL_MIPS_LITERAL 0x0007
#define IMAGE_REL_MIPS_SECTION 0x000A
#define IMAGE_REL_MIPS_SECREL 0x000B
#define IMAGE_REL_MIPS_SECRELLO 0x000C // Low 16-bit section relative referemce (used for >32k TLS)
#define IMAGE_REL_MIPS_SECRELHI 0x000D // High 16-bit section relative reference (used for >32k TLS)
#define IMAGE_REL_MIPS_JMPADDR16 0x0010
#define IMAGE_REL_MIPS_REFWORDNB 0x0022
#define IMAGE_REL_MIPS_PAIR 0x0025
//
// Alpha Relocation types.
//
#define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
#define IMAGE_REL_ALPHA_REFLONG 0x0001
#define IMAGE_REL_ALPHA_REFQUAD 0x0002
#define IMAGE_REL_ALPHA_GPREL32 0x0003
#define IMAGE_REL_ALPHA_LITERAL 0x0004
#define IMAGE_REL_ALPHA_LITUSE 0x0005
#define IMAGE_REL_ALPHA_GPDISP 0x0006
#define IMAGE_REL_ALPHA_BRADDR 0x0007
#define IMAGE_REL_ALPHA_HINT 0x0008
#define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
#define IMAGE_REL_ALPHA_REFHI 0x000A
#define IMAGE_REL_ALPHA_REFLO 0x000B
#define IMAGE_REL_ALPHA_PAIR 0x000C
#define IMAGE_REL_ALPHA_MATCH 0x000D
#define IMAGE_REL_ALPHA_SECTION 0x000E
#define IMAGE_REL_ALPHA_SECREL 0x000F
#define IMAGE_REL_ALPHA_REFLONGNB 0x0010
#define IMAGE_REL_ALPHA_SECRELLO 0x0011 // Low 16-bit section relative reference
#define IMAGE_REL_ALPHA_SECRELHI 0x0012 // High 16-bit section relative reference
#define IMAGE_REL_ALPHA_REFQ3 0x0013 // High 16 bits of 48 bit reference
#define IMAGE_REL_ALPHA_REFQ2 0x0014 // Middle 16 bits of 48 bit reference
#define IMAGE_REL_ALPHA_REFQ1 0x0015 // Low 16 bits of 48 bit reference
#define IMAGE_REL_ALPHA_GPRELLO 0x0016 // Low 16-bit GP relative reference
#define IMAGE_REL_ALPHA_GPRELHI 0x0017 // High 16-bit GP relative reference
//
// PowerPC relocation types.
//
#define IMAGE_REL_PPC_ABSOLUTE 0x0000 // NOP
#define IMAGE_REL_PPC_ADDR64 0x0001 // 64-bit address
#define IMAGE_REL_PPC_ADDR32 0x0002 // 32-bit address
#define IMAGE_REL_PPC_ADDR24 0x0003 // 26-bit address, shifted left 2 (branch absolute)
#define IMAGE_REL_PPC_ADDR16 0x0004 // 16-bit address
#define IMAGE_REL_PPC_ADDR14 0x0005 // 16-bit address, shifted left 2 (load doubleword)
#define IMAGE_REL_PPC_REL24 0x0006 // 26-bit PC-relative offset, shifted left 2 (branch relative)
#define IMAGE_REL_PPC_REL14 0x0007 // 16-bit PC-relative offset, shifted left 2 (br cond relative)
#define IMAGE_REL_PPC_TOCREL16 0x0008 // 16-bit offset from TOC base
#define IMAGE_REL_PPC_TOCREL14 0x0009 // 16-bit offset from TOC base, shifted left 2 (load doubleword)
#define IMAGE_REL_PPC_ADDR32NB 0x000A // 32-bit addr w/o image base
#define IMAGE_REL_PPC_SECREL 0x000B // va of containing section (as in an image sectionhdr)
#define IMAGE_REL_PPC_SECTION 0x000C // sectionheader number
#define IMAGE_REL_PPC_IFGLUE 0x000D // substitute TOC restore instruction iff symbol is glue code
#define IMAGE_REL_PPC_IMGLUE 0x000E // symbol is glue code; virtual address is TOC restore instruction
#define IMAGE_REL_PPC_SECREL16 0x000F // va of containing section (limited to 16 bits)
#define IMAGE_REL_PPC_REFHI 0x0010
#define IMAGE_REL_PPC_REFLO 0x0011
#define IMAGE_REL_PPC_PAIR 0x0012
#define IMAGE_REL_PPC_SECRELLO 0x0013 // Low 16-bit section relative reference (used for >32k TLS)
#define IMAGE_REL_PPC_SECRELHI 0x0014 // High 16-bit section relative reference (used for >32k TLS)
#define IMAGE_REL_PPC_GPREL 0x0015
#define IMAGE_REL_PPC_TYPEMASK 0x00FF // mask to isolate above values in IMAGE_RELOCATION.Type
// Flag bits in IMAGE_RELOCATION.TYPE
#define IMAGE_REL_PPC_NEG 0x0100 // subtract reloc value rather than adding it
#define IMAGE_REL_PPC_BRTAKEN 0x0200 // fix branch prediction bit to predict branch taken
#define IMAGE_REL_PPC_BRNTAKEN 0x0400 // fix branch prediction bit to predict branch not taken
#define IMAGE_REL_PPC_TOCDEFN 0x0800 // toc slot defined in file (or, data in toc)
//
// AMD64 (X86-64) relocations
//
#define IMAGE_REL_AMD64_ABSOLUTE 0x0000 // Reference is absolute, no relocation is necessary
#define IMAGE_REL_AMD64_ADDR64 0x0001 // 64-bit address
#define IMAGE_REL_AMD64_ADDR32 0x0002 // 32-bit address
#define IMAGE_REL_AMD64_ADDR32NB 0x0003 // 32-bit address reference to the virtual address, base not included
#define IMAGE_REL_AMD64_REL32 0x0004 // PC-relative 32-bit reference to the symbols virtual address (0 byte distance to target)
#define IMAGE_REL_AMD64_REL32_1 0x0005 // PC-relative 32-bit reference to the symbols virtual address (1 byte distance to target)
#define IMAGE_REL_AMD64_REL32_2 0x0006 // PC-relative 32-bit reference to the symbols virtual address (2 byte distance to target)
#define IMAGE_REL_AMD64_REL32_3 0x0007 // PC-relative 32-bit reference to the symbols virtual address (3 byte distance to target)
#define IMAGE_REL_AMD64_REL32_4 0x0008 // PC-relative 32-bit reference to the symbols virtual address (4 byte distance to target)
#define IMAGE_REL_AMD64_REL32_5 0x0009 // PC-relative 32-bit reference to the symbols virtual address (5 byte distance to target)
#define IMAGE_REL_AMD64_SECTION 0x000A // va of containing section (size unknown yet; I think its 32-bit)
#define IMAGE_REL_AMD64_SECREL 0x000B // 32-bit section relative reference
#define IMAGE_REL_AMD64_SECREL7 0x000C // 7-bit section relative reference
//
// I think that I've figured out for what these REL32_x relocations are.
// following is a simple asm program to demonstate the behavoir:
//
// asdf:
// ; ex for IMAGE_REL_AMD64_REL32
// ; vvvvvvvvvvv <- distance: 0 (to the end)
// ; 44 12 05 00 00 00 00
// adc r8b, byte ptr [asdf]
//
// ; ex for IMAGE_REL_AMD64_REL32_1
// ; vvvvvvvvvvv <- distance: 1 (to the end)
// ; 83 15 00 00 00 00 12
// adc dword ptr asdf, 12h
//
// ; ex for IMAGE_REL_AMD64_REL32_4
// ; vvvvvvvvvvv <- distance: 4 (to the end)
// ; 48 81 15 00 00 00 00 78 56 34 12
// adc qword ptr [asdf], 12345678h
//
typedef struct {
uint_32 rva;
uint_32 size;
} coff_image_data_directory;
typedef struct {
uint_16 magic; //standard fields
uint_8 l_major;
uint_8 l_minor;
uint_32 code_size;
uint_32 init_data;
uint_32 uninit_data;
uint_32 entry_point;
uint_32 base_code;
uint_32 base_data;
uint_32 image_base; //nt specific fields
uint_32 section_align;
uint_32 file_align;
uint_16 os_major;
uint_16 os_minor;
uint_16 user_major;
uint_16 user_minor;
uint_16 subsys_major;
uint_16 subsys_minor;
uint_32 reserved1;
uint_32 image_size;
uint_32 header_size;
uint_32 file_checksum;
uint_16 sub_system;
uint_16 dll_flags;
uint_32 stack_reserve;
uint_32 stack_commit;
uint_32 heap_reserve;
uint_32 heap_commit;
uint_32 loader_flags;
uint_32 data_directories;
coff_image_data_directory export_table;
coff_image_data_directory import_table;
coff_image_data_directory resource_table;
coff_image_data_directory exception_table;
coff_image_data_directory security_table;
coff_image_data_directory base_reloc_table;
coff_image_data_directory debug;
coff_image_data_directory copyright;
coff_image_data_directory machine_value;
coff_image_data_directory tls_table;
coff_image_data_directory load_config_table;
uint_8 reserved2[40];
} coff_opt_hdr;
#define COFF_OPT_HDR_SIZE sizeof( coff_opt_hdr )
// The following structure defines the new import object. Note the
// values of the first two fields, which must be set as stated in
// order to differentiate old and new import members. Following this
// structure, the linker emits two null-terminated strings used to
// recreate the import at the time of use. The first string is the
// import's name, the second is the dll's name.
#define IMPORT_OBJECT_HDR_SIG2 0xffff
typedef struct {
uint_16 sig1; // Must be IMAGE_FILE_MACHINE_UNKNOWN
uint_16 sig2; // Must be IMPORT_OBJECT_HDR_SIG2.
uint_16 version;
uint_16 machine;
uint_32 time_date_stamp; // Time/date stamp
uint_32 size_of_data; // particularly useful for incremental links
union {
uint_16 ordinal; // if grf & IMPORT_OBJECT_ORDINAL
uint_16 hint;
};
uint_16 object_type : 2; // import_object_type
uint_16 name_type : 3; // import_name_type
uint_16 reserved : 11; // Reserved. Must be zero.
} coff_import_object_header;
// Note that coff_import_object_header is the same size as coff_file_header
typedef enum
{
IMPORT_OBJECT_CODE = 0,
IMPORT_OBJECT_DATA = 1,
IMPORT_OBJECT_CONST = 2,
} coff_import_object_type;
typedef enum
{
IMPORT_OBJECT_ORDINAL = 0, // Import by ordinal
IMPORT_OBJECT_NAME = 1, // Import name == public symbol name.
IMPORT_OBJECT_NAME_NO_PREFIX = 2, // Import name == public symbol name skipping leading ?, @, or optionally _.
IMPORT_OBJECT_NAME_UNDECORATE = 3, // Import name == public symbol name skipping leading ?, @, or optionally _
// and truncating at first @
} coff_import_object_name_type;
#if 0
// old identifiers - I hate these
typedef coff_file_head CoffFHdr;
typedef coff_section_header CoffSHdr;
typedef coff_reloc CoffReloc;
typedef coff_symbol CoffSymEnt;
typedef coff_sym_func CoffAuxSymFuncDef;
typedef coff_sym_bfef CoffAuxSymBFEF;
typedef coff_sym_weak CoffAuxSymWeakExtern;
typedef coff_sym_file CoffAuxSymFile;
typedef coff_sym_section CoffAuxSymSecDef;
typedef coff_line_num CoffLineNum;
#endif
#pragma pack()
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?