macho/macho-go/pkg/ios/const.go

160 lines
6.0 KiB
Go
Raw Normal View History

2023-05-31 16:17:03 +07:00
package ios
// Magic values of Mach-O and Fat binaries
const (
Magic32 uint32 = 0xfeedface
Cigam32 uint32 = 0xcefaedfe
Magic64 uint32 = 0xfeedfacf
Cigam64 uint32 = 0xcffaedfe
MagicFat uint32 = 0xcafebabe
CigamFat uint32 = 0xbebafeca
)
// Flags defined in mach_header.flags
const (
FlagNoUndefs uint32 = 0x1
FlagIncrLink uint32 = 0x2
FlagDyldLink uint32 = 0x4
FlagBindAtLoad uint32 = 0x8
FlagPrebound uint32 = 0x10
FlagSplitSegs uint32 = 0x20
FlagLazyInit uint32 = 0x40
FlagTwoLevel uint32 = 0x80
FlagForceFlat uint32 = 0x100
FlagNoMultiDefs uint32 = 0x200
FlagNoFixPrebinding uint32 = 0x400
FlagPrebindable uint32 = 0x800
FlagAllModsBound uint32 = 0x1000
FlagSubsectionsViaSymbols uint32 = 0x2000
FlagCanonical uint32 = 0x4000
FlagWeakDefines uint32 = 0x8000
FlagBindsToWeak uint32 = 0x10000
FlagAllowStackExecution uint32 = 0x20000
FlagRootSafe uint32 = 0x40000
FlagSetuidSafe uint32 = 0x80000
FlagNoReexportedDylibs uint32 = 0x100000
FlagPIE uint32 = 0x200000
FlagDeadStrippableDylib uint32 = 0x400000
FlagHasTLVDescriptors uint32 = 0x800000
FlagNoHeapExecution uint32 = 0x1000000
FlagAppExtensionSafe uint32 = 0x2000000
)
// Types of Load command
const (
LC_DUMMY uint32 = 0x0
LC_SEGMENT uint32 = 0x1
LC_SYMTAB uint32 = 0x2
LC_SYMSEG uint32 = 0x3
LC_THREAD uint32 = 0x4
LC_UNIXTHREAD uint32 = 0x5
LC_LOADFVMLIB uint32 = 0x6
LC_IDFVMLIB uint32 = 0x7
LC_IDENT uint32 = 0x8
LC_FVMFILE uint32 = 0x9
LC_PREPAGE uint32 = 0xa
LC_DYSYMTAB uint32 = 0xb
LC_LOAD_DYLIB uint32 = 0xc
LC_ID_DYLIB uint32 = 0xd
LC_LOAD_DYLINKER uint32 = 0xe
LC_ID_DYLINKER uint32 = 0xf
LC_PREBOUND_DYLIB uint32 = 0x10
LC_ROUTINES uint32 = 0x11
LC_SUB_FRAMEWORK uint32 = 0x12
LC_SUB_UMBRELLA uint32 = 0x13
LC_SUB_CLIENT uint32 = 0x14
LC_SUB_LIBRARY uint32 = 0x15
LC_TWOLEVEL_HINTS uint32 = 0x16
LC_PREBIND_CKSUM uint32 = 0x17
LC_LOAD_WEAK_DYLIB uint32 = 0x18 | 0x80000000
LC_SEGMENT_64 uint32 = 0x19
LC_ROUTINES_64 uint32 = 0x1a
LC_UUID uint32 = 0x1b
LC_RPATH uint32 = 0x1c | 0x80000000
LC_CODE_SIGNATURE uint32 = 0x1d
LC_SEGMENT_SPLIT_INFO uint32 = 0x1e
LC_REEXPORT_DYLIB uint32 = 0x1f | 0x80000000
LC_LAZY_LOAD_DYLIB uint32 = 0x20
LC_ENCRYPTION_INFO uint32 = 0x21
LC_DYLD_INFO uint32 = 0x22
LC_DYLD_INFO_ONLY uint32 = 0x22 | 0x80000000
LC_VERSION_MIN_MACOSX uint32 = 0x24
LC_VERSION_MIN_IPHONEOS uint32 = 0x25
LC_FUNCTION_STARTS uint32 = 0x26
LC_DYLD_ENVIRONMENT uint32 = 0x27
LC_MAIN uint32 = 0x28 | 0x80000000
LC_DATA_IN_CODE uint32 = 0x29
LC_SOURCE_VERSION uint32 = 0x2A
LC_DYLIB_CODE_SIGN_DRS uint32 = 0x2B
LC_ENCRYPTION_INFO_64 uint32 = 0x2C
LC_LINKER_OPTION uint32 = 0x2D
LC_LINKER_OPTIMIZATION_HINT uint32 = 0x2E
LC_VERSION_MIN_TVOS uint32 = 0x2F
LC_VERSION_MIN_WATCHOS uint32 = 0x30
LC_BUILD_VERSION uint32 = 0x32
LC_DYLD_EXPORTS_TRIE uint32 = 0x33 | 0x80000000
LC_DYLD_CHAINED_FIXUPS uint32 = 0x34 | 0x80000000
)
const (
Header_size uint64 = 28
Header_size_64 uint64 = 28 + 4
)
const (
CPU_ARCH_ABI64 uint32 = 0x0100_0000
CPU_TYPE_ARM uint32 = 12
CPU_TYPE_ARM64 uint32 = CPU_TYPE_ARM | CPU_ARCH_ABI64
CPU_TYPE_POWERPC uint32 = 18
CPU_TYPE_POWERPC64 uint32 = CPU_TYPE_POWERPC | CPU_ARCH_ABI64
CPU_TYPE_I386 uint32 = 7
CPU_TYPE_X86_64 uint32 = CPU_TYPE_I386 | CPU_ARCH_ABI64
)
const (
// Section Type
S_REGULAR uint8 = 0x0
S_ZEROFILL uint8 = 0x1
S_CSTRING_LITERALS uint8 = 0x2
S_4BYTE_LITERALS uint8 = 0x3
S_8BYTE_LITERALS uint8 = 0x4
S_LITERAL_POINTERS uint8 = 0x5
S_NON_LAZY_SYMBOL_POINTERS uint8 = 0x6
S_LAZY_SYMBOL_POINTERS uint8 = 0x7
S_SYMBOL_STUBS uint8 = 0x8
S_MOD_INIT_FUNC_POINTERS uint8 = 0x9
S_MOD_TERM_FUNC_POINTERS uint8 = 0xa
S_COALESCED uint8 = 0xb
S_GB_ZEROFILL uint8 = 0xc
S_INTERPOSING uint8 = 0xd
S_16BYTE_LITERALS uint8 = 0xe
S_DTRACE_DOF uint8 = 0xf
S_LAZY_DYLIB_SYMBOL_POINTERS uint8 = 0x10
S_THREAD_LOCAL_REGULAR uint8 = 0x11
S_THREAD_LOCAL_ZEROFILL uint8 = 0x12
S_THREAD_LOCAL_VARIABLES uint8 = 0x13
S_THREAD_LOCAL_VARIABLE_POINTERS uint8 = 0x14
S_THREAD_LOCAL_INIT_FUNCTION_POINTERS uint8 = 0x15
)
const (
// Section Attribute
)
const (
BIND_OPCODE_DONE uint8 = 0x00
BIND_OPCODE_SET_DYLIB_ORDINAL_IMM uint8 = 0x10
BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB uint8 = 0x20
BIND_OPCODE_SET_DYLIB_SPECIAL_IMM uint8 = 0x30
BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM uint8 = 0x40
BIND_OPCODE_SET_TYPE_IMM uint8 = 0x50
BIND_OPCODE_SET_ADDEND_SLEB uint8 = 0x60
BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB uint8 = 0x70
BIND_OPCODE_ADD_ADDR_ULEB uint8 = 0x80
BIND_OPCODE_DO_BIND uint8 = 0x90
BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB uint8 = 0xA0
BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED uint8 = 0xB0
BIND_OPCODE_DO_BIND_ADD_ULEB_TIMES_SKIPPING_ULEB uint8 = 0xC0
)