/* Mach-O support for BFD.
- Copyright 2011
- Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
}
bfd_mach_o_mach_header_magic;
-#define BFD_MACH_O_CPU_IS64BIT 0x1000000
+/* Capability bits in cpu type. */
+#define BFD_MACH_O_CPU_ARCH_MASK 0xff000000
+#define BFD_MACH_O_CPU_ARCH_ABI64 0x01000000
+#define BFD_MACH_O_CPU_IS64BIT 0x01000000
typedef enum bfd_mach_o_cpu_type
{
BFD_MACH_O_CPU_TYPE_I860 = 15,
BFD_MACH_O_CPU_TYPE_ALPHA = 16,
BFD_MACH_O_CPU_TYPE_POWERPC = 18,
- BFD_MACH_O_CPU_TYPE_POWERPC_64 = (BFD_MACH_O_CPU_TYPE_POWERPC | BFD_MACH_O_CPU_IS64BIT),
- BFD_MACH_O_CPU_TYPE_X86_64 = (BFD_MACH_O_CPU_TYPE_I386 | BFD_MACH_O_CPU_IS64BIT)
+ BFD_MACH_O_CPU_TYPE_POWERPC_64 =
+ (BFD_MACH_O_CPU_TYPE_POWERPC | BFD_MACH_O_CPU_IS64BIT),
+ BFD_MACH_O_CPU_TYPE_X86_64 =
+ (BFD_MACH_O_CPU_TYPE_I386 | BFD_MACH_O_CPU_IS64BIT),
+ BFD_MACH_O_CPU_TYPE_ARM64 =
+ (BFD_MACH_O_CPU_TYPE_ARM | BFD_MACH_O_CPU_IS64BIT)
}
bfd_mach_o_cpu_type;
+/* Capability bits in cpu subtype. */
+#define BFD_MACH_O_CPU_SUBTYPE_MASK 0xff000000
+#define BFD_MACH_O_CPU_SUBTYPE_LIB64 0x80000000
+
typedef enum bfd_mach_o_cpu_subtype
{
- BFD_MACH_O_CPU_SUBTYPE_X86_ALL = 3
+ /* i386. */
+ BFD_MACH_O_CPU_SUBTYPE_X86_ALL = 3,
+
+ /* arm. */
+ BFD_MACH_O_CPU_SUBTYPE_ARM_ALL = 0,
+ BFD_MACH_O_CPU_SUBTYPE_ARM_V4T = 5,
+ BFD_MACH_O_CPU_SUBTYPE_ARM_V6 = 6,
+ BFD_MACH_O_CPU_SUBTYPE_ARM_V5TEJ = 7,
+ BFD_MACH_O_CPU_SUBTYPE_ARM_XSCALE = 8,
+ BFD_MACH_O_CPU_SUBTYPE_ARM_V7 = 9,
+
+ /* arm64. */
+ BFD_MACH_O_CPU_SUBTYPE_ARM64_ALL = 0,
+ BFD_MACH_O_CPU_SUBTYPE_ARM64_V8 = 1
}
bfd_mach_o_cpu_subtype;
BFD_MACH_O_MH_PIE = 0x0200000,
BFD_MACH_O_MH_DEAD_STRIPPABLE_DYLIB = 0x0400000,
BFD_MACH_O_MH_HAS_TLV_DESCRIPTORS = 0x0800000,
- BFD_MACH_O_MH_NO_HEAP_EXECUTION = 0x1000000
+ BFD_MACH_O_MH_NO_HEAP_EXECUTION = 0x1000000,
+ BFD_MACH_O_MH_APP_EXTENSION_SAFE = 0x2000000
}
bfd_mach_o_header_flags;
\f
/* Load a dynamically linked shared library that is allowed to be
missing (weak). */
BFD_MACH_O_LC_LOAD_WEAK_DYLIB = 0x18,
- BFD_MACH_O_LC_SEGMENT_64 = 0x19, /* 64-bit segment of this file to be
+ BFD_MACH_O_LC_SEGMENT_64 = 0x19, /* 64-bit segment of this file to be
mapped. */
- BFD_MACH_O_LC_ROUTINES_64 = 0x1a, /* Address of the dyld init routine
+ BFD_MACH_O_LC_ROUTINES_64 = 0x1a, /* Address of the dyld init routine
in a dylib. */
BFD_MACH_O_LC_UUID = 0x1b, /* 128-bit UUID of the executable. */
BFD_MACH_O_LC_RPATH = 0x1c, /* Run path addiions. */
BFD_MACH_O_LC_VERSION_MIN_MACOSX = 0x24, /* Minimal MacOSX version. */
BFD_MACH_O_LC_VERSION_MIN_IPHONEOS = 0x25, /* Minimal IOS version. */
BFD_MACH_O_LC_FUNCTION_STARTS = 0x26, /* Compressed table of func start. */
- BFD_MACH_O_LC_DYLD_ENVIRONMENT = 0x27 /* Env variable string for dyld. */
+ BFD_MACH_O_LC_DYLD_ENVIRONMENT = 0x27, /* Env variable string for dyld. */
+ BFD_MACH_O_LC_MAIN = 0x28, /* Entry point. */
+ BFD_MACH_O_LC_DATA_IN_CODE = 0x29, /* Table of non-instructions. */
+ BFD_MACH_O_LC_SOURCE_VERSION = 0x2a, /* Source version. */
+ BFD_MACH_O_LC_DYLIB_CODE_SIGN_DRS = 0x2b, /* DRs from dylibs. */
+ BFD_MACH_O_LC_ENCRYPTION_INFO_64 = 0x2c, /* Encrypted 64 bit seg info. */
+ BFD_MACH_O_LC_LINKER_OPTIONS = 0x2d, /* Linker options. */
+ BFD_MACH_O_LC_LINKER_OPTIMIZATION_HINT = 0x2e, /* Optimization hints. */
+ BFD_MACH_O_LC_VERSION_MIN_WATCHOS = 0x30 /* Minimal WatchOS version. */
}
bfd_mach_o_load_command_type;
\f
#define BFD_MACH_O_SECTION_ATTRIBUTES_MASK 0xffffff00
/* System setable attributes. */
#define BFD_MACH_O_SECTION_ATTRIBUTES_SYS 0x00ffff00
-/* User attributes. */
+/* User attributes. */
#define BFD_MACH_O_SECTION_ATTRIBUTES_USR 0xff000000
typedef enum bfd_mach_o_section_attribute
{
+ /* Section has no specified attibutes. */
+ BFD_MACH_O_S_ATTR_NONE = 0,
+
/* Section has local relocation entries. */
BFD_MACH_O_S_ATTR_LOC_RELOC = 0x00000100,
- /* Section has external relocation entries. */
+ /* Section has external relocation entries. */
BFD_MACH_O_S_ATTR_EXT_RELOC = 0x00000200,
/* Section contains some machine instructions. */
/* Used with i386 stubs. */
BFD_MACH_O_S_SELF_MODIFYING_CODE = 0x04000000,
-
+
/* Blocks are live if they reference live blocks. */
BFD_MACH_O_S_ATTR_LIVE_SUPPORT = 0x08000000,
#define BFD_MACH_O_NO_SECT 0 /* Symbol not in any section of the image. */
/* Symbol n_desc reference flags. */
-#define BFD_MACH_O_REFERENCE_MASK 0x0f
+#define BFD_MACH_O_REFERENCE_MASK 0x07
#define BFD_MACH_O_REFERENCE_FLAG_UNDEFINED_NON_LAZY 0x00
#define BFD_MACH_O_REFERENCE_FLAG_UNDEFINED_LAZY 0x01
#define BFD_MACH_O_REFERENCE_FLAG_DEFINED 0x02
#define BFD_MACH_O_N_NO_DEAD_STRIP 0x20
#define BFD_MACH_O_N_WEAK_REF 0x40
#define BFD_MACH_O_N_WEAK_DEF 0x80
+#define BFD_MACH_O_N_REF_TO_WEAK 0x80
+
+#define BFD_MACH_O_N_ARM_THUMB_DEF 0x08
+#define BFD_MACH_O_N_SYMBOL_RESOLVER 0x100
+
+#define BFD_MACH_O_INDIRECT_SYM_LOCAL 0x80000000
+#define BFD_MACH_O_INDIRECT_SYM_ABS 0x40000000
\f
+/* Constants for dyld info rebase. */
+#define BFD_MACH_O_REBASE_OPCODE_MASK 0xf0
+#define BFD_MACH_O_REBASE_IMMEDIATE_MASK 0x0f
+
+/* The rebase opcodes. */
+#define BFD_MACH_O_REBASE_OPCODE_DONE 0x00
+#define BFD_MACH_O_REBASE_OPCODE_SET_TYPE_IMM 0x10
+#define BFD_MACH_O_REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x20
+#define BFD_MACH_O_REBASE_OPCODE_ADD_ADDR_ULEB 0x30
+#define BFD_MACH_O_REBASE_OPCODE_ADD_ADDR_IMM_SCALED 0x40
+#define BFD_MACH_O_REBASE_OPCODE_DO_REBASE_IMM_TIMES 0x50
+#define BFD_MACH_O_REBASE_OPCODE_DO_REBASE_ULEB_TIMES 0x60
+#define BFD_MACH_O_REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB 0x70
+#define BFD_MACH_O_REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB 0x80
+
+/* The rebase type. */
+#define BFD_MACH_O_REBASE_TYPE_POINTER 1
+#define BFD_MACH_O_REBASE_TYPE_TEXT_ABSOLUTE32 2
+#define BFD_MACH_O_REBASE_TYPE_TEXT_PCREL32 3
+
+/* Constants for dyld info bind. */
+#define BFD_MACH_O_BIND_OPCODE_MASK 0xf0
+#define BFD_MACH_O_BIND_IMMEDIATE_MASK 0x0f
+
+/* The bind opcodes. */
+#define BFD_MACH_O_BIND_OPCODE_DONE 0x00
+#define BFD_MACH_O_BIND_OPCODE_SET_DYLIB_ORDINAL_IMM 0x10
+#define BFD_MACH_O_BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB 0x20
+#define BFD_MACH_O_BIND_OPCODE_SET_DYLIB_SPECIAL_IMM 0x30
+#define BFD_MACH_O_BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM 0x40
+#define BFD_MACH_O_BIND_OPCODE_SET_TYPE_IMM 0x50
+#define BFD_MACH_O_BIND_OPCODE_SET_ADDEND_SLEB 0x60
+#define BFD_MACH_O_BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x70
+#define BFD_MACH_O_BIND_OPCODE_ADD_ADDR_ULEB 0x80
+#define BFD_MACH_O_BIND_OPCODE_DO_BIND 0x90
+#define BFD_MACH_O_BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB 0xa0
+#define BFD_MACH_O_BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED 0xb0
+#define BFD_MACH_O_BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0xc0
+
+/* The bind types. */
+#define BFD_MACH_O_BIND_TYPE_POINTER 1
+#define BFD_MACH_O_BIND_TYPE_TEXT_ABSOLUTE32 2
+#define BFD_MACH_O_BIND_TYPE_TEXT_PCREL32 3
+
+/* The special dylib. */
+#define BFD_MACH_O_BIND_SPECIAL_DYLIB_SELF 0
+#define BFD_MACH_O_BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE -1
+#define BFD_MACH_O_BIND_SPECIAL_DYLIB_FLAT_LOOKUP -2
+
+/* Constants for dyld info export. */
+#define BFD_MACH_O_EXPORT_SYMBOL_FLAGS_KIND_MASK 0x03
+#define BFD_MACH_O_EXPORT_SYMBOL_FLAGS_KIND_REGULAR 0x00
+#define BFD_MACH_O_EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL 0x01
+#define BFD_MACH_O_EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION 0x04
+#define BFD_MACH_O_EXPORT_SYMBOL_FLAGS_REEXPORT 0x08
+#define BFD_MACH_O_EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER 0x10
+
+/* Constants for DATA_IN_CODE entries. */
+typedef enum bfd_mach_o_data_in_code_entry_kind
+{
+ BFD_MACH_O_DICE_KIND_DATA = 0x0001, /* Data */
+ BFD_MACH_O_DICE_JUMP_TABLES8 = 0x0002, /* 1 byte jump tables. */
+ BFD_MACH_O_DICE_JUMP_TABLES16 = 0x0003, /* 2 bytes. */
+ BFD_MACH_O_DICE_JUMP_TABLES32 = 0x0004, /* 4 bytes. */
+ BFD_MACH_O_DICE_ABS_JUMP_TABLES32 = 0x0005 /* Absolute jump table. */
+} bfd_mach_o_data_in_code_entry_kind;
+
/* Thread constants. */
typedef enum bfd_mach_o_ppc_thread_flavour