chromium/third_party/nasm/output/pecoff.h

/* ----------------------------------------------------------------------- *
 *
 *   Copyright 1996-2020 The NASM Authors - All Rights Reserved
 *   See the file AUTHORS included with the NASM distribution for
 *   the specific copyright holders.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following
 *   conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *
 *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 *     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 *     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 *     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 *     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ----------------------------------------------------------------------- */

#ifndef PECOFF_H
#define PECOFF_H

/*
 * Microsoft Portable Executable and Common Object
 * File Format Specification
 *
 * Revision 8.1 – February 15, 2008
 */

/*
 * Machine types
 */
#define IMAGE_FILE_MACHINE_UNKNOWN
#define IMAGE_FILE_MACHINE_AM33
#define IMAGE_FILE_MACHINE_AMD64
#define IMAGE_FILE_MACHINE_EBC
#define IMAGE_FILE_MACHINE_M32R
#define IMAGE_FILE_MACHINE_ALPHA
#define IMAGE_FILE_MACHINE_ARM
#define IMAGE_FILE_MACHINE_ALPHA64
#define IMAGE_FILE_MACHINE_I386
#define IMAGE_FILE_MACHINE_IA64
#define IMAGE_FILE_MACHINE_M68K
#define IMAGE_FILE_MACHINE_MIPS16
#define IMAGE_FILE_MACHINE_MIPSFPU
#define IMAGE_FILE_MACHINE_MIPSFPU16
#define IMAGE_FILE_MACHINE_POWERPC
#define IMAGE_FILE_MACHINE_POWERPCFP
#define IMAGE_FILE_MACHINE_R3000
#define IMAGE_FILE_MACHINE_R4000
#define IMAGE_FILE_MACHINE_R10000
#define IMAGE_FILE_MACHINE_SH3
#define IMAGE_FILE_MACHINE_SH3DSP
#define IMAGE_FILE_MACHINE_SH4
#define IMAGE_FILE_MACHINE_SH5
#define IMAGE_FILE_MACHINE_THUMB
#define IMAGE_FILE_MACHINE_WCEMIPSV2
#define IMAGE_FILE_MACHINE_MASK

/*
 * Characteristics
 */
#define IMAGE_FILE_RELOCS_STRIPPED
#define IMAGE_FILE_EXECUTABLE_IMAGE
#define IMAGE_FILE_LINE_NUMS_STRIPPED
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED
#define IMAGE_FILE_AGGRESSIVE_WS_TRIM
#define IMAGE_FILE_LARGE_ADDRESS_AWARE
#define IMAGE_FILE_BYTES_REVERSED_LO
#define IMAGE_FILE_32BIT_MACHINE
#define IMAGE_FILE_DEBUG_STRIPPED
#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP
#define IMAGE_FILE_NET_RUN_FROM_SWAP
#define IMAGE_FILE_SYSTEM
#define IMAGE_FILE_DLL
#define IMAGE_FILE_UP_SYSTEM_ONLY
#define IMAGE_FILE_BYTES_REVERSED_HI

/*
 * Windows subsystem
 */
#define IMAGE_SUBSYSTEM_UNKNOWN
#define IMAGE_SUBSYSTEM_NATIVE
#define IMAGE_SUBSYSTEM_WINDOWS_GUI
#define IMAGE_SUBSYSTEM_WINDOWS_CUI
#define IMAGE_SUBSYSTEM_POSIX_CUI
#define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI
#define IMAGE_SUBSYSTEM_EFI_APPLICATION
#define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
#define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
#define IMAGE_SUBSYSTEM_EFI_ROM
#define IMAGE_SUBSYSTEM_XBOX

/*
 * DLL characteristics
 */
#define IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE
#define IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY
#define IMAGE_DLL_CHARACTERISTICS_NX_COMPAT
#define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION
#define IMAGE_DLLCHARACTERISTICS_NO_SEH
#define IMAGE_DLLCHARACTERISTICS_NO_BIND
#define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER
#define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE

/*
 * Section flags
 */
#define IMAGE_SCN_TYPE_REG
#define IMAGE_SCN_TYPE_DSECT
#define IMAGE_SCN_TYPE_NOLOAD
#define IMAGE_SCN_TYPE_GROUP
#define IMAGE_SCN_TYPE_NO_PAD
#define IMAGE_SCN_TYPE_COPY

#define IMAGE_SCN_CNT_CODE
#define IMAGE_SCN_CNT_INITIALIZED_DATA
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA

#define IMAGE_SCN_LNK_OTHER
#define IMAGE_SCN_LNK_INFO
#define IMAGE_SCN_TYPE_OVER
#define IMAGE_SCN_LNK_REMOVE
#define IMAGE_SCN_LNK_COMDAT

#define IMAGE_SCN_MAX_RELOC

#define IMAGE_SCN_MEM_FARDATA
#define IMAGE_SCN_MEM_PURGEABLE
#define IMAGE_SCN_MEM_16BIT
#define IMAGE_SCN_MEM_LOCKED
#define IMAGE_SCN_MEM_PRELOAD

#define IMAGE_SCN_ALIGN_1BYTES
#define IMAGE_SCN_ALIGN_2BYTES
#define IMAGE_SCN_ALIGN_4BYTES
#define IMAGE_SCN_ALIGN_8BYTES
#define IMAGE_SCN_ALIGN_16BYTES
#define IMAGE_SCN_ALIGN_32BYTES
#define IMAGE_SCN_ALIGN_64BYTES
#define IMAGE_SCN_ALIGN_128BYTES
#define IMAGE_SCN_ALIGN_256BYTES
#define IMAGE_SCN_ALIGN_512BYTES
#define IMAGE_SCN_ALIGN_1024BYTES
#define IMAGE_SCN_ALIGN_2048BYTES
#define IMAGE_SCN_ALIGN_4096BYTES
#define IMAGE_SCN_ALIGN_8192BYTES
#define IMAGE_SCN_ALIGN_MASK

#define IMAGE_SCN_LNK_NRELOC_OVFL
#define IMAGE_SCN_MEM_DISCARDABLE
#define IMAGE_SCN_MEM_NOT_CACHED
#define IMAGE_SCN_MEM_NOT_PAGED
#define IMAGE_SCN_MEM_SHARED
#define IMAGE_SCN_MEM_EXECUTE
#define IMAGE_SCN_MEM_READ
#define IMAGE_SCN_MEM_WRITE

/*
 * Relocation type x86-64
 */
#define IMAGE_REL_AMD64_ABSOLUTE
#define IMAGE_REL_AMD64_ADDR64
#define IMAGE_REL_AMD64_ADDR32
#define IMAGE_REL_AMD64_ADDR32NB
#define IMAGE_REL_AMD64_REL32
#define IMAGE_REL_AMD64_REL32_1
#define IMAGE_REL_AMD64_REL32_2
#define IMAGE_REL_AMD64_REL32_3
#define IMAGE_REL_AMD64_REL32_4
#define IMAGE_REL_AMD64_REL32_5
#define IMAGE_REL_AMD64_SECTION
#define IMAGE_REL_AMD64_SECREL
#define IMAGE_REL_AMD64_SECREL7
#define IMAGE_REL_AMD64_TOKEN
#define IMAGE_REL_AMD64_SREL32
#define IMAGE_REL_AMD64_PAIR
#define IMAGE_REL_AMD64_SSPAN32

/*
 * Relocation types i386
 */
#define IMAGE_REL_I386_ABSOLUTE
#define IMAGE_REL_I386_DIR16
#define IMAGE_REL_I386_REL16
#define IMAGE_REL_I386_DIR32
#define IMAGE_REL_I386_DIR32NB
#define IMAGE_REL_I386_SEG12
#define IMAGE_REL_I386_SECTION
#define IMAGE_REL_I386_SECREL
#define IMAGE_REL_I386_TOKEN
#define IMAGE_REL_I386_SECREL7
#define IMAGE_REL_I386_REL32

/*
 * Relocation types ARM
 */
#define IMAGE_REL_ARM_ABSOLUTE
#define IMAGE_REL_ARM_ADDR32
#define IMAGE_REL_ARM_ADDR32NB
#define IMAGE_REL_ARM_BRANCH24
#define IMAGE_REL_ARM_BRANCH11
#define IMAGE_REL_ARM_SECTION
#define IMAGE_REL_ARM_SECREL

/*
 * Relocation types Hitachi SuperH
 */
#define IMAGE_REL_SH3_ABSOLUTE
#define IMAGE_REL_SH3_DIRECT16
#define IMAGE_REL_SH3_DIRECT32
#define IMAGE_REL_SH3_DIRECT8
#define IMAGE_REL_SH3_DIRECT8_WORD
#define IMAGE_REL_SH3_DIRECT8_LONG
#define IMAGE_REL_SH3_DIRECT4
#define IMAGE_REL_SH3_DIRECT4_WORD
#define IMAGE_REL_SH3_DIRECT4_LONG
#define IMAGE_REL_SH3_PCREL8_WORD
#define IMAGE_REL_SH3_PCREL8_LONG
#define IMAGE_REL_SH3_PCREL12_WORD
#define IMAGE_REL_SH3_STARTOF_SECTION
#define IMAGE_REL_SH3_SIZEOF_SECTION
#define IMAGE_REL_SH3_SECTION
#define IMAGE_REL_SH3_SECREL
#define IMAGE_REL_SH3_DIRECT32_NB
#define IMAGE_REL_SH3_GPREL4_LONG
#define IMAGE_REL_SH3_TOKEN
#define IMAGE_REL_SHM_PCRELPT
#define IMAGE_REL_SHM_REFLO
#define IMAGE_REL_SHM_REFHALF
#define IMAGE_REL_SHM_RELLO
#define IMAGE_REL_SHM_RELHALF
#define IMAGE_REL_SHM_PAIR
#define IMAGE_REL_SHM_NOMODE

/*
 * Relocation types IBM PowerPC processors
 */
#define IMAGE_REL_PPC_ABSOLUTE
#define IMAGE_REL_PPC_ADDR64
#define IMAGE_REL_PPC_ADDR32
#define IMAGE_REL_PPC_ADDR24
#define IMAGE_REL_PPC_ADDR16
#define IMAGE_REL_PPC_ADDR14
#define IMAGE_REL_PPC_REL24
#define IMAGE_REL_PPC_REL14
#define IMAGE_REL_PPC_ADDR32NB
#define IMAGE_REL_PPC_SECREL
#define IMAGE_REL_PPC_SECTION
#define IMAGE_REL_PPC_SECREL16
#define IMAGE_REL_PPC_REFHI
#define IMAGE_REL_PPC_REFLO
#define IMAGE_REL_PPC_PAIR
#define IMAGE_REL_PPC_SECRELLO
#define IMAGE_REL_PPC_GPREL
#define IMAGE_REL_PPC_TOKEN

/*
 * Relocation types Intel Itanium processor family (IPF)
 */
#define IMAGE_REL_IA64_ABSOLUTE
#define IMAGE_REL_IA64_IMM14
#define IMAGE_REL_IA64_IMM22
#define IMAGE_REL_IA64_IMM64
#define IMAGE_REL_IA64_DIR32
#define IMAGE_REL_IA64_DIR64
#define IMAGE_REL_IA64_PCREL21B
#define IMAGE_REL_IA64_PCREL21M
#define IMAGE_REL_IA64_PCREL21F
#define IMAGE_REL_IA64_GPREL22
#define IMAGE_REL_IA64_LTOFF22
#define IMAGE_REL_IA64_SECTION
#define IMAGE_REL_IA64_SECREL22
#define IMAGE_REL_IA64_SECREL64I
#define IMAGE_REL_IA64_SECREL32
#define IMAGE_REL_IA64_DIR32NB
#define IMAGE_REL_IA64_SREL14
#define IMAGE_REL_IA64_SREL22
#define IMAGE_REL_IA64_SREL32
#define IMAGE_REL_IA64_UREL32
#define IMAGE_REL_IA64_PCREL60X
#define IMAGE_REL_IA64_PCREL
#define IMAGE_REL_IA64_PCREL60F
#define IMAGE_REL_IA64_PCREL60I
#define IMAGE_REL_IA64_PCREL60M
#define IMAGE_REL_IA64_IMMGPREL64
#define IMAGE_REL_IA64_TOKEN
#define IMAGE_REL_IA64_GPREL32
#define IMAGE_REL_IA64_ADDEND

/*
 * Relocation types MIPS Processors
 */
#define IMAGE_REL_MIPS_ABSOLUTE
#define IMAGE_REL_MIPS_REFHALF
#define IMAGE_REL_MIPS_REFWORD
#define IMAGE_REL_MIPS_JMPADDR
#define IMAGE_REL_MIPS_REFHI
#define IMAGE_REL_MIPS_REFLO
#define IMAGE_REL_MIPS_GPREL
#define IMAGE_REL_MIPS_LITERAL
#define IMAGE_REL_MIPS_SECTION
#define IMAGE_REL_MIPS_SECREL
#define IMAGE_REL_MIPS_SECRELLO
#define IMAGE_REL_MIPS_SECRELHI
#define IMAGE_REL_MIPS_JMPADDR16
#define IMAGE_REL_MIPS_REFWORDNB
#define IMAGE_REL_MIPS_PAIR

/*
 * Relocation types Mitsubishi M32R
 */
#define IMAGE_REL_M32R_ABSOLUTE
#define IMAGE_REL_M32R_ADDR32
#define IMAGE_REL_M32R_ADDR32NB
#define IMAGE_REL_M32R_ADDR24
#define IMAGE_REL_M32R_GPREL16
#define IMAGE_REL_M32R_PCREL24
#define IMAGE_REL_M32R_PCREL16
#define IMAGE_REL_M32R_PCREL8
#define IMAGE_REL_M32R_REFHALF
#define IMAGE_REL_M32R_REFHI
#define IMAGE_REL_M32R_REFLO
#define IMAGE_REL_M32R_PAIR
#define IMAGE_REL_M32R_SECTION
#define IMAGE_REL_M32R_SECREL
#define IMAGE_REL_M32R_TOKEN

/*
 * Section number values
 */
#define IMAGE_SYM_UNDEFINED
#define IMAGE_SYM_ABSOLUTE
#define IMAGE_SYM_DEBUG

/*
 * Type representation
 */
#define IMAGE_SYM_TYPE_NULL
#define IMAGE_SYM_TYPE_VOID
#define IMAGE_SYM_TYPE_CHAR
#define IMAGE_SYM_TYPE_SHORT
#define IMAGE_SYM_TYPE_INT
#define IMAGE_SYM_TYPE_LONG
#define IMAGE_SYM_TYPE_FLOAT
#define IMAGE_SYM_TYPE_DOUBLE
#define IMAGE_SYM_TYPE_STRUCT
#define IMAGE_SYM_TYPE_UNION
#define IMAGE_SYM_TYPE_ENUM
#define IMAGE_SYM_TYPE_MOE
#define IMAGE_SYM_TYPE_BYTE
#define IMAGE_SYM_TYPE_WORD
#define IMAGE_SYM_TYPE_UINT
#define IMAGE_SYM_TYPE_DWORD

#define IMAGE_SYM_DTYPE_NULL
#define IMAGE_SYM_DTYPE_POINTER
#define IMAGE_SYM_DTYPE_FUNCTION
#define IMAGE_SYM_DTYPE_ARRAY

/*
 * Storage class
 */
#define IMAGE_SYM_CLASS_END_OF_FUNCTION
#define IMAGE_SYM_CLASS_NULL
#define IMAGE_SYM_CLASS_AUTOMATIC
#define IMAGE_SYM_CLASS_EXTERNAL
#define IMAGE_SYM_CLASS_STATIC
#define IMAGE_SYM_CLAS
#define IMAGE_SYM_CLASS_EXTERNAL_DEF
#define IMAGE_SYM_CLASS_LABEL
#define IMAGE_SYM_CLASS_UNDEFINED_LABEL
#define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT
#define IMAGE_SYM_CLASS_ARGUMENT
#define IMAGE_SYM_CLASS_STRUCT_TAG
#define IMAGE_SYM_CLASS_MEMBER_OF_UNION
#define IMAGE_SYM_CLASS_UNION_TAG
#define IMAGE_SYM_CLASS_TYPE_DEFINITION
#define IMAGE_SYM_CLASS_UNDEFINED_STATIC
#define IMAGE_SYM_CLASS_ENUM_TAG
#define IMAGE_SYM_CLASS_MEMBER_OF_ENUM
#define IMAGE_SYM_CLASS_REGISTER_PARAM
#define IMAGE_SYM_CLASS_BIT_FIELD
#define IMAGE_SYM_CLASS_BLOCK
#define IMAGE_SYM_CLASS_FUNCTION
#define IMAGE_SYM_CLASS_END_OF_STRUCT
#define IMAGE_SYM_CLASS_FILE
#define IMAGE_SYM_CLASS_SECTION
#define IMAGE_SYM_CLASS_WEAK_EXTERNAL
#define IMAGE_SYM_CLASS_CLR_TOKEN

/*
 * COMDAT sections
 */
#define IMAGE_COMDAT_SELECT_NODUPLICATES
#define IMAGE_COMDAT_SELECT_ANY
#define IMAGE_COMDAT_SELECT_SAME_SIZE
#define IMAGE_COMDAT_SELECT_EXACT_MATCH
#define IMAGE_COMDAT_SELECT_ASSOCIATIVE
#define IMAGE_COMDAT_SELECT_LARGEST

/*
 * Attribute certificate table
 */
#define WIN_CERT_REVISION_1_0
#define WIN_CERT_REVISION_2_0
#define WIN_CERT_TYPE_X509
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA
#define WIN_CERT_TYPE_RESERVED_1
#define WIN_CERT_TYPE_TS_STACK_SIGNED

/*
 * Debug type
 */
#define IMAGE_DEBUG_TYPE_UNKNOWN
#define IMAGE_DEBUG_TYPE_COFF
#define IMAGE_DEBUG_TYPE_CODEVIEW
#define IMAGE_DEBUG_TYPE_FPO
#define IMAGE_DEBUG_TYPE_MISC
#define IMAGE_DEBUG_TYPE_EXCEPTION
#define IMAGE_DEBUG_TYPE_FIXUP
#define IMAGE_DEBUG_TYPE_OMAP_TO_SRC
#define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC
#define IMAGE_DEBUG_TYP
#define IMAGE_DEBUG_TYPE_RESERVED10
#define IMAGE_DEBUG_TYPE_CLSID

/*
 * Base relocation types
 */
#define IMAGE_REL_BASED_ABSOLUTE
#define IMAGE_REL_BASED_HIGH
#define IMAGE_REL_BASED_LOW
#define IMAGE_REL_BASED_HIGHLOW
#define IMAGE_REL_BASED_HIGHADJ
#define IMAGE_REL_BASED_MIPS_JMPADDR
#define IMAGE_REL_BASED_MIPS_JMPADDR16
#define IMAGE_REL_BASED_DIR64

/*
 * TLS callback functions
 */
#define DLL_PROCESS_ATTACH
#define DLL_THREAD_ATTACH
#define DLL_THREAD_DETACH
#define DLL_PROCESS_DETACH

/*
 * Import Type
 */
#define IMPORT_CODE
#define IMPORT_DATA
#define IMPORT_CONST

/*
 * Import name type
 */
#define IMPORT_ORDINAL
#define IMPORT_NAME
#define IMPORT_NAME_NOPREFIX
#define IMPORT_NAME_UNDECORATE

struct coff_Section {};

struct coff_Reloc {};

struct coff_Symbol {};

struct coff_DebugInfo {};

extern struct coff_Section **coff_sects;
extern int coff_nsects;
extern struct SAA *coff_syms;
extern uint32_t coff_nsyms;
extern struct SAA *coff_strs;
extern bool win32, win64;

extern char coff_infile[FILENAME_MAX];
extern char coff_outfile[FILENAME_MAX];

extern int coff_make_section(char *name, uint32_t flags);


#endif /* PECOFF_H */