[32] | 1 | /* $Id: mach-o.h 63 2013-10-30 02:00:14Z bird $ */
|
---|
[2] | 2 | /** @file
|
---|
| 3 | * Mach-0 structures, types and defines.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
[31] | 6 | /*
|
---|
[48] | 7 | * Copyright (c) 2006-2012 Knut St. Osmundsen <bird-kStuff-spamix@anduin.net>
|
---|
[31] | 8 | *
|
---|
| 9 | * Permission is hereby granted, free of charge, to any person
|
---|
| 10 | * obtaining a copy of this software and associated documentation
|
---|
| 11 | * files (the "Software"), to deal in the Software without
|
---|
| 12 | * restriction, including without limitation the rights to use,
|
---|
| 13 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
| 14 | * copies of the Software, and to permit persons to whom the
|
---|
| 15 | * Software is furnished to do so, subject to the following
|
---|
| 16 | * conditions:
|
---|
| 17 | *
|
---|
| 18 | * The above copyright notice and this permission notice shall be
|
---|
| 19 | * included in all copies or substantial portions of the Software.
|
---|
| 20 | *
|
---|
| 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
| 22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
| 23 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
| 24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
| 25 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
| 26 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
| 27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
| 28 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
| 29 | */
|
---|
| 30 |
|
---|
[2] | 31 | #ifndef ___k_kLdrFmts_mach_o_h___
|
---|
| 32 | #define ___k_kLdrFmts_mach_o_h___
|
---|
| 33 |
|
---|
| 34 | #include <k/kDefs.h>
|
---|
| 35 | #include <k/kTypes.h>
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 | /** @defgroup grp_mach_o The Mach-O Structures, Types, and Defines.
|
---|
| 39 | * @{
|
---|
| 40 | */
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 | #ifndef IMAGE_FAT_SIGNATURE
|
---|
| 44 | /** The FAT signature (universal binaries). */
|
---|
| 45 | # define IMAGE_FAT_SIGNATURE KU32_C(0xcafebabe)
|
---|
| 46 | #endif
|
---|
| 47 | #ifndef IMAGE_FAT_SIGNATURE_OE
|
---|
| 48 | /** The FAT signature (universal binaries), other endian. */
|
---|
| 49 | # define IMAGE_FAT_SIGNATURE_OE KU32_C(0xbebafeca)
|
---|
| 50 | #endif
|
---|
| 51 |
|
---|
| 52 | /**
|
---|
| 53 | * The fat header found at the start of universal binaries.
|
---|
| 54 | * It is followed by \a nfat_arch numbers of \a fat_arch structures.
|
---|
| 55 | */
|
---|
| 56 | typedef struct fat_header
|
---|
| 57 | {
|
---|
| 58 | KU32 magic;
|
---|
| 59 | KU32 nfat_arch;
|
---|
| 60 | } fat_header_t;
|
---|
| 61 |
|
---|
| 62 | /**
|
---|
| 63 | * Description of fat file item.
|
---|
| 64 | */
|
---|
| 65 | typedef struct fat_arch
|
---|
| 66 | {
|
---|
| 67 | KI32 cputype;
|
---|
| 68 | KI32 cpusubtype;
|
---|
| 69 | KU32 offset;
|
---|
| 70 | KU32 size;
|
---|
| 71 | KU32 align; /**< Power of 2. */
|
---|
| 72 | } fat_arch_t;
|
---|
| 73 |
|
---|
| 74 |
|
---|
| 75 |
|
---|
| 76 | #ifndef IMAGE_MACHO32_SIGNATURE
|
---|
| 77 | /** The 32-bit Mach-O signature. */
|
---|
| 78 | # define IMAGE_MACHO32_SIGNATURE KU32_C(0xfeedface)
|
---|
| 79 | #endif
|
---|
| 80 | #ifndef IMAGE_MACHO32_SIGNATURE_OE
|
---|
| 81 | /** The 32-bit Mach-O signature, other endian. */
|
---|
| 82 | # define IMAGE_MACHO32_SIGNATURE_OE KU32_C(0xcefaedfe)
|
---|
| 83 | #endif
|
---|
| 84 | #define MH_MAGIC IMAGE_MACHO32_SIGNATURE
|
---|
| 85 | #define MH_CIGAM IMAGE_MACHO32_SIGNATURE_OE
|
---|
| 86 |
|
---|
| 87 | /**
|
---|
| 88 | * 32-bit Mach-O header.
|
---|
| 89 | * This is followed by \a ncmds number of load commands.
|
---|
| 90 | * @see mach_header_64
|
---|
| 91 | */
|
---|
| 92 | typedef struct mach_header_32
|
---|
| 93 | {
|
---|
| 94 | KU32 magic;
|
---|
| 95 | KI32 cputype;
|
---|
| 96 | KI32 cpusubtype;
|
---|
| 97 | KU32 filetype;
|
---|
| 98 | KU32 ncmds;
|
---|
| 99 | KU32 sizeofcmds;
|
---|
| 100 | KU32 flags;
|
---|
| 101 | } mach_header_32_t;
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 |
|
---|
| 105 | #ifndef IMAGE_MACHO64_SIGNATURE
|
---|
| 106 | /** The 64-bit Mach-O signature. */
|
---|
| 107 | # define IMAGE_MACHO64_SIGNATURE KU32_C(0xfeedfacf)
|
---|
| 108 | #endif
|
---|
| 109 | #ifndef IMAGE_MACHO64_SIGNATURE_OE
|
---|
| 110 | /** The 64-bit Mach-O signature, other endian. */
|
---|
| 111 | # define IMAGE_MACHO64_SIGNATURE_OE KU32_C(0xfefaedfe)
|
---|
| 112 | #endif
|
---|
| 113 | #define MH_MAGIC_64 IMAGE_MACHO64_SIGNATURE
|
---|
| 114 | #define MH_CIGAM_64 IMAGE_MACHO64_SIGNATURE_OE
|
---|
| 115 |
|
---|
| 116 | /**
|
---|
| 117 | * 64-bit Mach-O header.
|
---|
| 118 | * This is followed by \a ncmds number of load commands.
|
---|
| 119 | * @see mach_header
|
---|
| 120 | */
|
---|
| 121 | typedef struct mach_header_64
|
---|
| 122 | {
|
---|
| 123 | KU32 magic;
|
---|
| 124 | KI32 cputype;
|
---|
| 125 | KI32 cpusubtype;
|
---|
| 126 | KU32 filetype;
|
---|
| 127 | KU32 ncmds;
|
---|
| 128 | KU32 sizeofcmds;
|
---|
| 129 | KU32 flags;
|
---|
| 130 | KU32 reserved; /**< (for proper struct and command alignment I guess) */
|
---|
| 131 | } mach_header_64_t;
|
---|
| 132 |
|
---|
| 133 |
|
---|
| 134 | /** @name File types (mach_header_64::filetype, mach_header_32::filetype)
|
---|
| 135 | * @{
|
---|
| 136 | */
|
---|
| 137 | #define MH_OBJECT KU32_C(1) /**< Object (relocatable). */
|
---|
| 138 | #define MH_EXECUTE KU32_C(2) /**< Executable (demand paged). */
|
---|
| 139 | #define MH_FVMLIB KU32_C(3) /**< Fixed VM shared library. */
|
---|
| 140 | #define MH_CORE KU32_C(4) /**< Core file. */
|
---|
| 141 | #define MH_PRELOAD KU32_C(5) /**< Preloaded executable. */
|
---|
| 142 | #define MH_DYLIB KU32_C(6) /**< Dynamically bound shared library. */
|
---|
| 143 | #define MH_DYLINKER KU32_C(7) /**< Dynamic linker. */
|
---|
| 144 | #define MH_BUNDLE KU32_C(8) /**< Dymamically bound bundle. */
|
---|
| 145 | #define MH_DYLIB_STUB KU32_C(9) /**< Shared library stub for static linking. */
|
---|
| 146 | #define MH_DSYM KU32_C(10)/**< Debug symbols. */
|
---|
[55] | 147 | #define MH_KEXT_BUNDLE KU32_C(11)/**< Kernel extension (introduced with the AMD64 kernel). */
|
---|
[2] | 148 |
|
---|
| 149 | /** @} */
|
---|
| 150 |
|
---|
| 151 |
|
---|
| 152 | /** @name Mach-O Header flags (mach_header_64::flags, mach_header_32::flags)
|
---|
| 153 | * @{
|
---|
| 154 | */
|
---|
| 155 | #define MH_NOUNDEFS KU32_C(0x00000001) /**< No undefined symbols. */
|
---|
| 156 | #define MH_INCRLINK KU32_C(0x00000002) /**< Partial increment link output. */
|
---|
| 157 | #define MH_DYLDLINK KU32_C(0x00000004) /**< Food for the dynamic linker, not for ld. */
|
---|
| 158 | #define MH_BINDATLOAD KU32_C(0x00000008) /**< Bind all undefined symbols at load time. */
|
---|
| 159 | #define MH_PREBOUND KU32_C(0x00000010) /**< Contains prebound undefined symbols. */
|
---|
| 160 | #define MH_SPLIT_SEGS KU32_C(0x00000020) /**< Read-only and read-write segments are split. */
|
---|
| 161 | #define MH_LAZY_INIT KU32_C(0x00000040) /**< Obsolete flag for doing lazy init when data is written. */
|
---|
| 162 | #define MH_TWOLEVEL KU32_C(0x00000080) /**< Uses two-level name space bindings. */
|
---|
| 163 | #define MH_FORCE_FLAT KU32_C(0x00000100) /**< Task: The executable forces all images to use flat name space bindings. */
|
---|
| 164 | #define MH_NOMULTIDEFS KU32_C(0x00000200) /**< No multiple symbol definitions, safe to use two-level namespace hints. */
|
---|
| 165 | #define MH_NOFIXPREBINDING KU32_C(0x00000400) /**< The dynamic linker should not notify the prebinding agent about this executable. */
|
---|
| 166 | #define MH_PREBINDABLE KU32_C(0x00000800) /**< Not prebound, but it can be. Invalid if MH_PREBOUND is set. */
|
---|
| 167 | #define MH_ALLMODSBOUND KU32_C(0x00001000) /**< Binds to all two-level namespace modules of preqs. Requires MH_PREBINDABLE and MH_TWOLEVEL to be set. */
|
---|
| 168 | #define MH_SUBSECTIONS_VIA_SYMBOLS KU32_C(0x00002000) /**< Safe to divide sections into sub-sections via symbols for dead code stripping. */
|
---|
| 169 | #define MH_CANONICAL KU32_C(0x00004000) /**< Canonicalized via unprebind. */
|
---|
| 170 | #define MH_WEAK_DEFINES KU32_C(0x00008000) /**< The (finally) linked image has weak symbols. */
|
---|
| 171 | #define MH_BINDS_TO_WEAK KU32_C(0x00010000) /**< The (finally) linked image uses weak symbols. */
|
---|
| 172 | #define MH_ALLOW_STACK_EXECUTION KU32_C(0x00020000) /**< Task: allow stack execution. (MH_EXECUTE only) */
|
---|
[50] | 173 | #define MH_ROOT_SAFE KU32_C(0x00040000) /**< Binary safe for root execution. */
|
---|
| 174 | #define MH_SETUID_SAFE KU32_C(0x00080000) /**< Binary safe for set-uid execution. */
|
---|
| 175 | #define MH_NO_REEXPORTED_DYLIBS KU32_C(0x00100000) /**< No reexported dylibs. */
|
---|
| 176 | #define MH_PIE KU32_C(0x00200000) /**< Address space randomization. (MH_EXECUTE only) */
|
---|
| 177 | #define MH_DEAD_STRIPPABLE_DYLIB KU32_C(0x00400000) /**< Drop dylib dependency if not used. (MH_DYLIB only) */
|
---|
| 178 | #define MH_HAS_TLV_DESCRIPTORS KU32_C(0x00800000) /**< Has a S_TRHEAD_LOCAL_VARIABLES section. TLS support. */
|
---|
| 179 | #define MH_NO_HEAP_EXECUTION KU32_C(0x01000000) /**< Task: no heap execution. (MH_EXECUTE only) */
|
---|
| 180 | #define MH_VALID_FLAGS KU32_C(0x01ffffff) /**< Mask containing the defined flags. */
|
---|
[2] | 181 | /** @} */
|
---|
| 182 |
|
---|
| 183 |
|
---|
| 184 | /** @name CPU types / bits (mach_header_64::cputype, mach_header_32::cputype, fat_arch::cputype)
|
---|
| 185 | * @{
|
---|
| 186 | */
|
---|
| 187 | #define CPU_ARCH_MASK KI32_C(0xff000000)
|
---|
| 188 | #define CPU_ARCH_ABI64 KI32_C(0x01000000)
|
---|
| 189 | #define CPU_TYPE_ANY KI32_C(-1)
|
---|
| 190 | #define CPU_TYPE_VAX KI32_C(1)
|
---|
| 191 | #define CPU_TYPE_MC680x0 KI32_C(6)
|
---|
| 192 | #define CPU_TYPE_X86 KI32_C(7)
|
---|
| 193 | #define CPU_TYPE_I386 CPU_TYPE_X86
|
---|
| 194 | #define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64)
|
---|
| 195 | #define CPU_TYPE_MC98000 KI32_C(10)
|
---|
| 196 | #define CPU_TYPE_HPPA KI32_C(11)
|
---|
| 197 | #define CPU_TYPE_MC88000 KI32_C(13)
|
---|
| 198 | #define CPU_TYPE_SPARC KI32_C(14)
|
---|
| 199 | #define CPU_TYPE_I860 KI32_C(15)
|
---|
| 200 | #define CPU_TYPE_POWERPC KI32_C(18)
|
---|
| 201 | #define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
|
---|
| 202 | /** @} */
|
---|
| 203 |
|
---|
| 204 |
|
---|
| 205 | /** @name CPU subtypes (mach_header_64::cpusubtype, mach_header_32::cpusubtype, fat_arch::cpusubtype)
|
---|
| 206 | * @{ */
|
---|
| 207 | #define CPU_SUBTYPE_MULTIPLE KI32_C(-1)
|
---|
| 208 | #define CPU_SUBTYPE_LITTLE_ENDIAN KI32_C(0) /**< figure this one out. */
|
---|
| 209 | #define CPU_SUBTYPE_BIG_ENDIAN KI32_C(1) /**< ditto */
|
---|
| 210 |
|
---|
| 211 | /* VAX */
|
---|
| 212 | #define CPU_SUBTYPE_VAX_ALL KI32_C(0)
|
---|
| 213 | #define CPU_SUBTYPE_VAX780 KI32_C(1)
|
---|
| 214 | #define CPU_SUBTYPE_VAX785 KI32_C(2)
|
---|
| 215 | #define CPU_SUBTYPE_VAX750 KI32_C(3)
|
---|
| 216 | #define CPU_SUBTYPE_VAX730 KI32_C(4)
|
---|
| 217 | #define CPU_SUBTYPE_UVAXI KI32_C(5)
|
---|
| 218 | #define CPU_SUBTYPE_UVAXII KI32_C(6)
|
---|
| 219 | #define CPU_SUBTYPE_VAX8200 KI32_C(7)
|
---|
| 220 | #define CPU_SUBTYPE_VAX8500 KI32_C(8)
|
---|
| 221 | #define CPU_SUBTYPE_VAX8600 KI32_C(9)
|
---|
| 222 | #define CPU_SUBTYPE_VAX8650 KI32_C(10)
|
---|
| 223 | #define CPU_SUBTYPE_VAX8800 KI32_C(11)
|
---|
| 224 | #define CPU_SUBTYPE_UVAXIII KI32_C(12)
|
---|
| 225 |
|
---|
| 226 | /* MC680xx */
|
---|
| 227 | #define CPU_SUBTYPE_MC680x0_ALL KI32_C(1)
|
---|
| 228 | #define CPU_SUBTYPE_MC68030 KI32_C(1)
|
---|
| 229 | #define CPU_SUBTYPE_MC68040 KI32_C(2)
|
---|
| 230 | #define CPU_SUBTYPE_MC68030_ONLY KI32_C(3)
|
---|
| 231 |
|
---|
| 232 | /* I386 */
|
---|
| 233 | #define CPU_SUBTYPE_INTEL(fam, model) ( (KI32)(((model) << 4) | (fam)) )
|
---|
| 234 | #define CPU_SUBTYPE_INTEL_FAMILY(subtype) ( (subtype) & 0xf )
|
---|
| 235 | #define CPU_SUBTYPE_INTEL_MODEL(subtype) ( (subtype) >> 4 )
|
---|
| 236 | #define CPU_SUBTYPE_INTEL_FAMILY_MAX 0xf
|
---|
| 237 | #define CPU_SUBTYPE_INTEL_MODEL_ALL 0
|
---|
| 238 |
|
---|
| 239 | #define CPU_SUBTYPE_I386_ALL CPU_SUBTYPE_INTEL(3, 0)
|
---|
| 240 | #define CPU_SUBTYPE_386 CPU_SUBTYPE_INTEL(3, 0)
|
---|
| 241 | #define CPU_SUBTYPE_486 CPU_SUBTYPE_INTEL(4, 0)
|
---|
| 242 | #define CPU_SUBTYPE_486SX CPU_SUBTYPE_INTEL(4, 8)
|
---|
| 243 | #define CPU_SUBTYPE_586 CPU_SUBTYPE_INTEL(5, 0)
|
---|
| 244 | #define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0)
|
---|
| 245 | #define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1)
|
---|
| 246 | #define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3)
|
---|
| 247 | #define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5)
|
---|
| 248 | #define CPU_SUBTYPE_CELERON CPU_SUBTYPE_INTEL(7, 6)
|
---|
| 249 | #define CPU_SUBTYPE_CELERON_MOBILE CPU_SUBTYPE_INTEL(7, 7)
|
---|
| 250 | #define CPU_SUBTYPE_PENTIUM_3 CPU_SUBTYPE_INTEL(8, 0)
|
---|
| 251 | #define CPU_SUBTYPE_PENTIUM_3_M CPU_SUBTYPE_INTEL(8, 1)
|
---|
| 252 | #define CPU_SUBTYPE_PENTIUM_3_XEON CPU_SUBTYPE_INTEL(8, 2)
|
---|
| 253 | #define CPU_SUBTYPE_PENTIUM_M CPU_SUBTYPE_INTEL(9, 0)
|
---|
| 254 | #define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0)
|
---|
| 255 | #define CPU_SUBTYPE_PENTIUM_4_M CPU_SUBTYPE_INTEL(10, 1)
|
---|
| 256 | #define CPU_SUBTYPE_ITANIUM CPU_SUBTYPE_INTEL(11, 0)
|
---|
| 257 | #define CPU_SUBTYPE_ITANIUM_2 CPU_SUBTYPE_INTEL(11, 1)
|
---|
| 258 | #define CPU_SUBTYPE_XEON CPU_SUBTYPE_INTEL(12, 0)
|
---|
| 259 | #define CPU_SUBTYPE_XEON_MP CPU_SUBTYPE_INTEL(12, 1)
|
---|
| 260 |
|
---|
| 261 | /* X86 */
|
---|
| 262 | #define CPU_SUBTYPE_X86_ALL KI32_C(3) /* CPU_SUBTYPE_I386_ALL */
|
---|
| 263 | #define CPU_SUBTYPE_X86_64_ALL KI32_C(3) /* CPU_SUBTYPE_I386_ALL */
|
---|
| 264 | #define CPU_SUBTYPE_X86_ARCH1 KI32_C(4) /* CPU_SUBTYPE_I486_ALL */
|
---|
| 265 |
|
---|
| 266 | /* MIPS */
|
---|
| 267 | #define CPU_SUBTYPE_MIPS_ALL KI32_C(0)
|
---|
| 268 | #define CPU_SUBTYPE_MIPS_R2300 KI32_C(1)
|
---|
| 269 | #define CPU_SUBTYPE_MIPS_R2600 KI32_C(2)
|
---|
| 270 | #define CPU_SUBTYPE_MIPS_R2800 KI32_C(3)
|
---|
| 271 | #define CPU_SUBTYPE_MIPS_R2000a KI32_C(4)
|
---|
| 272 | #define CPU_SUBTYPE_MIPS_R2000 KI32_C(5)
|
---|
| 273 | #define CPU_SUBTYPE_MIPS_R3000a KI32_C(6)
|
---|
| 274 | #define CPU_SUBTYPE_MIPS_R3000 KI32_C(7)
|
---|
| 275 |
|
---|
| 276 | /* MC98000 (PowerPC) */
|
---|
| 277 | #define CPU_SUBTYPE_MC98000_ALL KI32_C(0)
|
---|
| 278 | #define CPU_SUBTYPE_MC98601 KI32_C(1)
|
---|
| 279 |
|
---|
| 280 | /* HP-PA */
|
---|
| 281 | #define CPU_SUBTYPE_HPPA_ALL KI32_C(0)
|
---|
| 282 | #define CPU_SUBTYPE_HPPA_7100 KI32_C(0)
|
---|
| 283 | #define CPU_SUBTYPE_HPPA_7100LC KI32_C(1)
|
---|
| 284 |
|
---|
| 285 | /* MC88000 */
|
---|
| 286 | #define CPU_SUBTYPE_MC88000_ALL KI32_C(0)
|
---|
| 287 | #define CPU_SUBTYPE_MC88100 KI32_C(1)
|
---|
| 288 | #define CPU_SUBTYPE_MC88110 KI32_C(2)
|
---|
| 289 |
|
---|
| 290 | /* SPARC */
|
---|
| 291 | #define CPU_SUBTYPE_SPARC_ALL KI32_C(0)
|
---|
| 292 |
|
---|
| 293 | /* I860 */
|
---|
| 294 | #define CPU_SUBTYPE_I860_ALL KI32_C(0)
|
---|
| 295 | #define CPU_SUBTYPE_I860_860 KI32_C(1)
|
---|
| 296 |
|
---|
| 297 | /* PowerPC */
|
---|
| 298 | #define CPU_SUBTYPE_POWERPC_ALL KI32_C(0)
|
---|
| 299 | #define CPU_SUBTYPE_POWERPC_601 KI32_C(1)
|
---|
| 300 | #define CPU_SUBTYPE_POWERPC_602 KI32_C(2)
|
---|
| 301 | #define CPU_SUBTYPE_POWERPC_603 KI32_C(3)
|
---|
| 302 | #define CPU_SUBTYPE_POWERPC_603e KI32_C(4)
|
---|
| 303 | #define CPU_SUBTYPE_POWERPC_603ev KI32_C(5)
|
---|
| 304 | #define CPU_SUBTYPE_POWERPC_604 KI32_C(6)
|
---|
| 305 | #define CPU_SUBTYPE_POWERPC_604e KI32_C(7)
|
---|
| 306 | #define CPU_SUBTYPE_POWERPC_620 KI32_C(8)
|
---|
| 307 | #define CPU_SUBTYPE_POWERPC_750 KI32_C(9)
|
---|
| 308 | #define CPU_SUBTYPE_POWERPC_7400 KI32_C(10)
|
---|
| 309 | #define CPU_SUBTYPE_POWERPC_7450 KI32_C(11)
|
---|
| 310 | #define CPU_SUBTYPE_POWERPC_Max KI32_C(10)
|
---|
| 311 | #define CPU_SUBTYPE_POWERPC_SCVger KI32_C(11)
|
---|
| 312 | #define CPU_SUBTYPE_POWERPC_970 KI32_C(100)
|
---|
| 313 |
|
---|
[20] | 314 | /* Subtype capability / feature bits, added in 10.5. X86 only? */
|
---|
| 315 | #define CPU_SUBTYPE_MASK KU32_C(0xff000000)
|
---|
| 316 | #define CPU_SUBTYPE_LIB64 KU32_C(0x8000000)
|
---|
| 317 |
|
---|
[2] | 318 | /** @} */
|
---|
| 319 |
|
---|
| 320 |
|
---|
| 321 |
|
---|
| 322 | /** @defgroup grp_macho_o_lc Load Commands
|
---|
| 323 | * @{ */
|
---|
| 324 |
|
---|
| 325 | /**
|
---|
| 326 | * The load command common core structure.
|
---|
| 327 | *
|
---|
| 328 | * After the Mach-O header follows an array of variable sized
|
---|
| 329 | * load command which all has this header in common.
|
---|
| 330 | */
|
---|
| 331 | typedef struct load_command
|
---|
| 332 | {
|
---|
| 333 | KU32 cmd; /**< The load command id. */
|
---|
| 334 | KU32 cmdsize; /**< The size of the command (including this header). */
|
---|
| 335 | } load_command_t;
|
---|
| 336 |
|
---|
| 337 | /** @name Load Command IDs (load_command::cmd)
|
---|
| 338 | * @{
|
---|
| 339 | */
|
---|
| 340 | /** Flag that when set requires the dynamic linker to fail if it doesn't
|
---|
| 341 | * grok the command. The dynamic linker will otherwise ignore commands it
|
---|
| 342 | * doesn't understand. Introduced with Mac OS X 10.1. */
|
---|
| 343 | #define LC_REQ_DYLD KU32_C(0x80000000)
|
---|
| 344 |
|
---|
| 345 | #define LC_SEGMENT_32 KU32_C(0x01) /**< Segment to be mapped (32-bit). See segment_command_32. */
|
---|
| 346 | #define LC_SYMTAB KU32_C(0x02) /**< 'stab' symbol table. See symtab_command. */
|
---|
| 347 | #define LC_SYMSEG KU32_C(0x03) /**< Obsoleted gdb symbol table. */
|
---|
| 348 | #define LC_THREAD KU32_C(0x04) /**< Thread. See thread_command. */
|
---|
| 349 | #define LC_UNIXTHREAD KU32_C(0x05) /**< Unix thread (includes stack and stuff). See thread_command. */
|
---|
| 350 | #define LC_LOADFVMLIB KU32_C(0x06) /**< Load a specified fixed VM shared library (obsolete?). See fvmlib_command. */
|
---|
| 351 | #define LC_IDFVMLIB KU32_C(0x07) /**< Fixed VM shared library id (obsolete?). See fvmlib_command. */
|
---|
| 352 | #define LC_IDENT KU32_C(0x08) /**< Identification info (obsolete). See ident_command. */
|
---|
| 353 | #define LC_FVMFILE KU32_C(0x09) /**< Fixed VM file inclusion (internal). See fvmfile_command. */
|
---|
| 354 | #define LC_PREPAGE KU32_C(0x0a) /**< Prepage command (internal). See ?? */
|
---|
| 355 | #define LC_DYSYMTAB KU32_C(0x0b) /**< Symbol table for dynamic linking. See dysymtab_command. */
|
---|
| 356 | #define LC_LOAD_DYLIB KU32_C(0x0c) /**< Load a dynamically linked shared library. See dylib_command. */
|
---|
| 357 | #define LC_ID_DYLIB KU32_C(0x0d) /**< Dynamically linked share library ident. See dylib_command. */
|
---|
| 358 | #define LC_LOAD_DYLINKER KU32_C(0x0e) /**< Load a dynamical link editor. See dylinker_command. */
|
---|
| 359 | #define LC_ID_DYLINKER KU32_C(0x0f) /**< Dynamic link editor ident. See dylinker_command. */
|
---|
| 360 | #define LC_PREBOUND_DYLIB KU32_C(0x10) /**< Prebound modules for dynamically linking of a shared lib. See prebound_dylib_command. */
|
---|
| 361 | #define LC_ROUTINES KU32_C(0x11) /**< Image routines. See routines_command_32. */
|
---|
| 362 | #define LC_SUB_FRAMEWORK KU32_C(0x12) /**< Sub framework. See sub_framework_command. */
|
---|
| 363 | #define LC_SUB_UMBRELLA KU32_C(0x13) /**< Sub umbrella. See sub_umbrella_command. */
|
---|
| 364 | #define LC_SUB_CLIENT KU32_C(0x14) /**< Sub client. See sub_client_command. */
|
---|
| 365 | #define LC_SUB_LIBRARY KU32_C(0x15) /**< Sub library. See sub_library_command. */
|
---|
| 366 | #define LC_TWOLEVEL_HINTS KU32_C(0x16) /**< Two-level namespace lookup hints. See twolevel_hints_command. */
|
---|
| 367 | #define LC_PREBIND_CKSUM KU32_C(0x17) /**< Prebind checksum. See prebind_cksum_command. */
|
---|
| 368 | #define LC_LOAD_WEAK_DYLIB (KU32_C(0x18) | LC_REQ_DYLD) /**< Dylib that can be missing, all symbols weak. See dylib_command. */
|
---|
| 369 | #define LC_SEGMENT_64 KU32_C(0x19) /**< segment to be mapped (64-bit). See segment_command_32. */
|
---|
| 370 | #define LC_ROUTINES_64 KU32_C(0x1a) /**< Image routines (64-bit). See routines_command_32. */
|
---|
| 371 | #define LC_UUID KU32_C(0x1b) /**< The UUID of the object module. See uuid_command. */
|
---|
[56] | 372 | #define LC_RPATH (KU32_C(0x1c) | LC_REQ_DYLD) /**< Runpth additions. See rpath_command. */
|
---|
[48] | 373 | #define LC_CODE_SIGNATURE KU32_C(0x1d) /**< Code signature location. See linkedit_data_command. */
|
---|
| 374 | #define LC_SEGMENT_SPLIT_INFO KU32_C(0x1e)/**< Segment split info location. See linkedit_data_command. */
|
---|
[56] | 375 | #define LC_REEXPORT_DYLIB (KU32_C(0x1f) | LC_REQ_DYLD)/**< Load and re-export the given dylib - DLL forwarding. See dylib_command. */
|
---|
[48] | 376 | #define LC_LAZY_LOAD_DYLIB KU32_C(0x20) /**< Delays loading of the given dylib until used. See dylib_command? */
|
---|
| 377 | #define LC_ENCRYPTION_INFO KU32_C(0x21) /**< Segment encryption information. See encryption_info_command. */
|
---|
| 378 | #define LC_DYLD_INFO KU32_C(0x22) /**< Compressed dylib relocation information, alternative present. See dyld_info_command. */
|
---|
[56] | 379 | #define LC_DYLD_INFO_ONLY (KU32_C(0x22) | LC_REQ_DYLD) /**< Compressed dylib relocation information, no alternative. See dyld_info_command. */
|
---|
[48] | 380 | #define LC_LOAD_UPWARD_DYLIB KU32_C(0x23) /**< ???? */
|
---|
| 381 | #define LC_VERSION_MIN_MACOSX KU32_C(0x24) /**< The image requires the given Mac OS X version. See version_min_command. */
|
---|
| 382 | #define LC_VERSION_MIN_IPHONEOS KU32_C(0x25) /**< The image requires the given iOS version. See version_min_command. */
|
---|
| 383 | #define LC_FUNCTION_STARTS KU32_C(0x26) /**< Where to find the compress function start addresses. See linkedit_data_command. */
|
---|
[56] | 384 | #define LC_DYLD_ENVIRONMENT KU32_C(0x27) /**< Environment variable for the dynamic linker. See dylinker_command. */
|
---|
| 385 | #define LC_MAIN (KU32_C(0x28) | LC_REQ_DYLD) /**< Simpler alternative to LC_UNIXTHREAD. */
|
---|
| 386 | #define LC_DATA_IN_CODE KU32_C(0x29) /**< Table of data in the the text section. */
|
---|
| 387 | #define LC_SOURCE_VERSION KU32_C(0x2a) /**< Source code revision / version hint. */
|
---|
| 388 | #define LC_DYLIB_CODE_SIGN_DRS KU32_C(0x2b) /**< Code signing designated requirements copied from dylibs prequisites. */
|
---|
[2] | 389 | /** @} */
|
---|
| 390 |
|
---|
| 391 |
|
---|
| 392 | /**
|
---|
| 393 | * Load Command String.
|
---|
| 394 | */
|
---|
| 395 | typedef struct lc_str
|
---|
| 396 | {
|
---|
| 397 | /** Offset of the string relative to the load_command structure.
|
---|
| 398 | * The string is zero-terminated. the size of the load command
|
---|
| 399 | * is zero padded up to a multiple of 4 bytes. */
|
---|
| 400 | KU32 offset;
|
---|
| 401 | } lc_str_t;
|
---|
| 402 |
|
---|
| 403 |
|
---|
| 404 | /**
|
---|
| 405 | * Segment load command (32-bit).
|
---|
| 406 | */
|
---|
| 407 | typedef struct segment_command_32
|
---|
| 408 | {
|
---|
| 409 | KU32 cmd; /**< LC_SEGMENT */
|
---|
| 410 | KU32 cmdsize; /**< sizeof(self) + sections. */
|
---|
| 411 | char segname[16]; /**< The segment name. */
|
---|
| 412 | KU32 vmaddr; /**< Memory address of this segment. */
|
---|
| 413 | KU32 vmsize; /**< Size of this segment. */
|
---|
| 414 | KU32 fileoff; /**< The file location of the segment. */
|
---|
| 415 | KU32 filesize; /**< The file size of the segment. */
|
---|
| 416 | KU32 maxprot; /**< Maximum VM protection. */
|
---|
| 417 | KU32 initprot; /**< Initial VM protection. */
|
---|
| 418 | KU32 nsects; /**< Number of section desciptors following this structure. */
|
---|
| 419 | KU32 flags; /**< Flags (SG_*). */
|
---|
| 420 | } segment_command_32_t;
|
---|
| 421 |
|
---|
| 422 |
|
---|
| 423 | /**
|
---|
| 424 | * Segment load command (64-bit).
|
---|
| 425 | * Same as segment_command_32 except 4 members has been blown up to 64-bit.
|
---|
| 426 | */
|
---|
| 427 | typedef struct segment_command_64
|
---|
| 428 | {
|
---|
| 429 | KU32 cmd; /**< LC_SEGMENT */
|
---|
| 430 | KU32 cmdsize; /**< sizeof(self) + sections. */
|
---|
| 431 | char segname[16]; /**< The segment name. */
|
---|
| 432 | KU64 vmaddr; /**< Memory address of this segment. */
|
---|
| 433 | KU64 vmsize; /**< Size of this segment. */
|
---|
| 434 | KU64 fileoff; /**< The file location of the segment. */
|
---|
| 435 | KU64 filesize; /**< The file size of the segment. */
|
---|
| 436 | KU32 maxprot; /**< Maximum VM protection. */
|
---|
| 437 | KU32 initprot; /**< Initial VM protection. */
|
---|
| 438 | KU32 nsects; /**< Number of section desciptors following this structure. */
|
---|
| 439 | KU32 flags; /**< Flags (SG_*). */
|
---|
| 440 | } segment_command_64_t;
|
---|
| 441 |
|
---|
| 442 | /** @name Segment flags (segment_command_64::flags, segment_command_32::flags)
|
---|
| 443 | * @{ */
|
---|
| 444 | /** Map the file bits in the top end of the memory area for the segment
|
---|
| 445 | * instead of the low end. Intended for stacks in core dumps.
|
---|
| 446 | * The part of the segment memory not covered by file bits will be zeroed. */
|
---|
| 447 | #define SG_HIGHVM KU32_C(0x00000001)
|
---|
| 448 | /** This segment is the virtual memory allocated by a fixed VM library.
|
---|
| 449 | * (Used for overlap checking in the linker.) */
|
---|
| 450 | #define SG_FVMLIB KU32_C(0x00000002)
|
---|
| 451 | /** No relocations for or symbols that's relocated to in this segment.
|
---|
| 452 | * The segment can therefore safely be replaced. */
|
---|
| 453 | #define SG_NORELOC KU32_C(0x00000004)
|
---|
| 454 | /** The segment is protected.
|
---|
| 455 | * The first page isn't protected if it starts at file offset 0
|
---|
| 456 | * (so that the mach header and this load command can be easily mapped). */
|
---|
| 457 | #define SG_PROTECTED_VERSION_1 KU32_C(0x00000008)
|
---|
| 458 | /** @} */
|
---|
| 459 |
|
---|
| 460 |
|
---|
| 461 | /**
|
---|
| 462 | * 32-bit section (part of a segment load command).
|
---|
| 463 | */
|
---|
| 464 | typedef struct section_32
|
---|
| 465 | {
|
---|
| 466 | char sectname[16]; /**< The section name. */
|
---|
| 467 | char segname[16]; /**< The name of the segment this section goes into. */
|
---|
| 468 | KU32 addr; /**< The memory address of this section. */
|
---|
| 469 | KU32 size; /**< The size of this section. */
|
---|
| 470 | KU32 offset; /**< The file offset of this section. */
|
---|
| 471 | KU32 align; /**< The section alignment (**2). */
|
---|
| 472 | KU32 reloff; /**< The file offset of the relocations. */
|
---|
| 473 | KU32 nreloc; /**< The number of relocations. */
|
---|
| 474 | KU32 flags; /**< The section flags; section type and attribs */
|
---|
| 475 | KU32 reserved1; /**< Reserved / offset / index. */
|
---|
| 476 | KU32 reserved2; /**< Reserved / count / sizeof. */
|
---|
| 477 | } section_32_t;
|
---|
| 478 |
|
---|
| 479 | /**
|
---|
| 480 | * 64-bit section (part of a segment load command).
|
---|
| 481 | */
|
---|
| 482 | typedef struct section_64
|
---|
| 483 | {
|
---|
| 484 | char sectname[16]; /**< The section name. */
|
---|
| 485 | char segname[16]; /**< The name of the segment this section goes into. */
|
---|
| 486 | KU64 addr; /**< The memory address of this section. */
|
---|
| 487 | KU64 size; /**< The size of this section. */
|
---|
| 488 | KU32 offset; /**< The file offset of this section. */
|
---|
| 489 | KU32 align; /**< The section alignment (**2). */
|
---|
| 490 | KU32 reloff; /**< The file offset of the relocations. */
|
---|
| 491 | KU32 nreloc; /**< The number of relocations. */
|
---|
| 492 | KU32 flags; /**< The section flags; section type and attribs */
|
---|
| 493 | KU32 reserved1; /**< Reserved / offset / index. */
|
---|
| 494 | KU32 reserved2; /**< Reserved / count / sizeof. */
|
---|
| 495 | KU32 reserved3; /**< (Just) Reserved. */
|
---|
| 496 | } section_64_t;
|
---|
| 497 |
|
---|
| 498 | /** @name Section flags (section_64::flags, section_32::flags)
|
---|
| 499 | * @{
|
---|
| 500 | */
|
---|
| 501 | /** Section type mask. */
|
---|
[63] | 502 | #define SECTION_TYPE KU32_C(0x000000ff)
|
---|
[2] | 503 | /** Regular section. */
|
---|
[63] | 504 | #define S_REGULAR 0x00
|
---|
[2] | 505 | /** Zero filled section. */
|
---|
[63] | 506 | #define S_ZEROFILL 0x01
|
---|
[2] | 507 | /** C literals. */
|
---|
[63] | 508 | #define S_CSTRING_LITERALS 0x02
|
---|
[2] | 509 | /** 4 byte literals. */
|
---|
[63] | 510 | #define S_4BYTE_LITERALS 0x03
|
---|
[2] | 511 | /** 8 byte literals. */
|
---|
[63] | 512 | #define S_8BYTE_LITERALS 0x04
|
---|
[2] | 513 | /** Pointer to literals. */
|
---|
[63] | 514 | #define S_LITERAL_POINTERS 0x05
|
---|
[2] | 515 | /** Section containing non-lazy symbol pointers.
|
---|
| 516 | * Reserved1 == start index in the indirect symbol table. */
|
---|
[63] | 517 | #define S_NON_LAZY_SYMBOL_POINTERS 0x06
|
---|
[2] | 518 | /** Section containing lazy symbol pointers.
|
---|
| 519 | * Reserved1 == start index in the indirect symbol table. */
|
---|
[63] | 520 | #define S_LAZY_SYMBOL_POINTERS 0x07
|
---|
[2] | 521 | /** Section containing symbol stubs.
|
---|
| 522 | * Reserved2 == stub size. */
|
---|
[63] | 523 | #define S_SYMBOL_STUBS 0x08
|
---|
[2] | 524 | /** Section containing function pointers for module initialization. . */
|
---|
[63] | 525 | #define S_MOD_INIT_FUNC_POINTERS 0x09
|
---|
[2] | 526 | /** Section containing function pointers for module termination. . */
|
---|
[63] | 527 | #define S_MOD_TERM_FUNC_POINTERS 0x0a
|
---|
[2] | 528 | /** Section containing symbols that are to be coalesced. */
|
---|
[63] | 529 | #define S_COALESCED 0x0b
|
---|
[2] | 530 | /** Zero filled section that be larger than 4GB. */
|
---|
[63] | 531 | #define S_GB_ZEROFILL 0x0c
|
---|
[2] | 532 | /** Section containing pairs of function pointers for interposing. */
|
---|
[63] | 533 | #define S_INTERPOSING 0x0d
|
---|
[2] | 534 | /** 16 byte literals. */
|
---|
[63] | 535 | #define S_16BYTE_LITERALS 0x0e
|
---|
| 536 | /** DTrace byte code / definitions (DOF = DTrace object format). */
|
---|
| 537 | #define S_DTRACE_DOF 0x0f
|
---|
| 538 | /** Section containing pointers to symbols in lazily loaded dylibs. */
|
---|
| 539 | #define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10
|
---|
[2] | 540 |
|
---|
| 541 | /** Section attribute mask. */
|
---|
| 542 | #define SECTION_ATTRIBUTES KU32_C(0xffffff00)
|
---|
| 543 |
|
---|
| 544 | /** User settable attribute mask. */
|
---|
| 545 | #define SECTION_ATTRIBUTES_USR KU32_C(0xff000000)
|
---|
| 546 | /** Pure instruction (code). */
|
---|
| 547 | #define S_ATTR_PURE_INSTRUCTIONS KU32_C(0x80000000)
|
---|
| 548 | /** ranlib, ignore my symbols... */
|
---|
| 549 | #define S_ATTR_NO_TOC KU32_C(0x40000000)
|
---|
| 550 | /** May strip static symbols when linking int a MH_DYLDLINK file. */
|
---|
| 551 | #define S_ATTR_STRIP_STATIC_SYMS KU32_C(0x20000000)
|
---|
| 552 | /** No dead stripping. */
|
---|
| 553 | #define S_ATTR_NO_DEAD_STRIP KU32_C(0x10000000)
|
---|
| 554 | /** Live support. */
|
---|
| 555 | #define S_ATTR_LIVE_SUPPORT KU32_C(0x08000000)
|
---|
| 556 | /** Contains self modifying code (generally i386 code stub for dyld). */
|
---|
| 557 | #define S_ATTR_SELF_MODIFYING_CODE KU32_C(0x04000000)
|
---|
| 558 | /** Debug info (DWARF usually). */
|
---|
| 559 | #define S_ATTR_DEBUG KU32_C(0x02000000)
|
---|
| 560 |
|
---|
| 561 | /** System settable attribute mask. */
|
---|
| 562 | #define SECTION_ATTRIBUTES_SYS KU32_C(0x00ffff00)
|
---|
| 563 | /** Contains some instructions (code). */
|
---|
| 564 | #define S_ATTR_SOME_INSTRUCTIONS KU32_C(0x00000400)
|
---|
| 565 | /** Has external relocations. */
|
---|
| 566 | #define S_ATTR_EXT_RELOC KU32_C(0x00000200)
|
---|
| 567 | /** Has internal (local) relocations. */
|
---|
| 568 | #define S_ATTR_LOC_RELOC KU32_C(0x00000100)
|
---|
| 569 | /** @} */
|
---|
| 570 |
|
---|
| 571 | /** @name Known Segment and Section Names.
|
---|
| 572 | * Some of these implies special linker behaviour.
|
---|
| 573 | * @{
|
---|
| 574 | */
|
---|
| 575 | /** Page zero - not-present page for catching invalid access. (MH_EXECUTE typically) */
|
---|
| 576 | #define SEG_PAGEZERO "__PAGEZERO"
|
---|
| 577 | /** Traditional UNIX text segment.
|
---|
| 578 | * Defaults to R-X. */
|
---|
| 579 | #define SEG_TEXT "__TEXT"
|
---|
| 580 | /** The text part of SEG_TEXT. */
|
---|
| 581 | #define SECT_TEXT "__text"
|
---|
| 582 | /** The fvmlib initialization. */
|
---|
| 583 | #define SECT_FVMLIB_INIT0 "__fvmlib_init0"
|
---|
| 584 | /** The section following the fvmlib initialization. */
|
---|
| 585 | #define SECT_FVMLIB_INIT1 "__fvmlib_init1"
|
---|
| 586 | /** The traditional UNIX data segment. (DGROUP to DOS and OS/2 people.) */
|
---|
| 587 | #define SEG_DATA "__DATA"
|
---|
| 588 | /** The initialized data section. */
|
---|
| 589 | #define SECT_DATA "__data"
|
---|
| 590 | /** The uninitialized data section. */
|
---|
| 591 | #define SECT_BSS "__bss"
|
---|
| 592 | /** The common symbol section. */
|
---|
| 593 | #define SECT_COMMON "__common"
|
---|
| 594 | /** Objective-C runtime segment. */
|
---|
| 595 | #define SEG_OBJC "__OBJC"
|
---|
| 596 | /** Objective-C symbol table section. */
|
---|
| 597 | #define SECT_OBJC_SYMBOLS "__symbol_table"
|
---|
| 598 | /** Objective-C module information section. */
|
---|
| 599 | #define SECT_OBJC_MODULES "__module_info"
|
---|
| 600 | /** Objective-C string table section. */
|
---|
| 601 | #define SECT_OBJC_STRINGS "__selector_strs"
|
---|
| 602 | /** Objective-C string table section. */
|
---|
| 603 | #define SECT_OBJC_REFS "__selector_refs"
|
---|
| 604 | /** Icon segment. */
|
---|
| 605 | #define SEG_ICON "__ICON"
|
---|
| 606 | /** The icon headers. */
|
---|
| 607 | #define SECT_ICON_HEADER "__header"
|
---|
| 608 | /** The icons in the TIFF format. */
|
---|
| 609 | #define SECT_ICON_TIFF "__tiff"
|
---|
| 610 | /** ld -seglinkedit segment containing all the structs create and maintained
|
---|
| 611 | * by the linker. MH_EXECUTE and MH_FVMLIB only. */
|
---|
| 612 | #define SEG_LINKEDIT "__LINKEDIT"
|
---|
| 613 | /** The unix stack segment. */
|
---|
| 614 | #define SEG_UNIXSTACK "__UNIXSTACK"
|
---|
| 615 | /** The segment for the self modifying code for dynamic linking.
|
---|
| 616 | * Implies RWX permissions. */
|
---|
| 617 | #define SEG_IMPORT "__IMPORT"
|
---|
| 618 | /** @} */
|
---|
| 619 |
|
---|
| 620 |
|
---|
| 621 | /** @todo fvmlib */
|
---|
| 622 | /** @todo fvmlib_command (LC_IDFVMLIB or LC_LOADFVMLIB) */
|
---|
| 623 | /** @todo dylib */
|
---|
[48] | 624 | /** @todo dylib_command (LC_ID_DYLIB, LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB,
|
---|
| 625 | * LC_REEXPORT_DYLIB, LC_LAZY_LOAD_DYLIB) */
|
---|
[2] | 626 | /** @todo sub_framework_command (LC_SUB_FRAMEWORK) */
|
---|
| 627 | /** @todo sub_client_command (LC_SUB_CLIENT) */
|
---|
| 628 | /** @todo sub_umbrella_command (LC_SUB_UMBRELLA) */
|
---|
| 629 | /** @todo sub_library_command (LC_SUB_LIBRARY) */
|
---|
| 630 | /** @todo prebound_dylib_command (LC_PREBOUND_DYLIB) */
|
---|
[48] | 631 | /** @todo dylinker_command (LC_ID_DYLINKER or LC_LOAD_DYLINKER,
|
---|
| 632 | * LC_DYLD_ENVIRONMENT) */
|
---|
[2] | 633 |
|
---|
| 634 | /**
|
---|
| 635 | * Thread command.
|
---|
| 636 | *
|
---|
| 637 | * State description of a thread that is to be created. The description
|
---|
| 638 | * is made up of a number of state structures preceded by a 32-bit flavor
|
---|
| 639 | * and 32-bit count field stating the kind of stat structure and it's size
|
---|
| 640 | * in KU32 items respecitvly.
|
---|
| 641 | *
|
---|
| 642 | * LC_UNIXTHREAD differs from LC_THREAD in that it implies stack creation
|
---|
| 643 | * and that it's started with the typical main(int, char **, char **) frame
|
---|
| 644 | * on the stack.
|
---|
| 645 | */
|
---|
| 646 | typedef struct thread_command
|
---|
| 647 | {
|
---|
| 648 | KU32 cmd; /**< LC_UNIXTHREAD or LC_THREAD. */
|
---|
| 649 | KU32 cmdsize; /**< The size of the command (including this header). */
|
---|
| 650 | } thread_command_t;
|
---|
| 651 |
|
---|
| 652 |
|
---|
| 653 | /** @todo routines_command (LC_ROUTINES) */
|
---|
| 654 | /** @todo routines_command_64 (LC_ROUTINES_64) */
|
---|
| 655 |
|
---|
| 656 |
|
---|
| 657 | /**
|
---|
| 658 | * Symbol table command.
|
---|
| 659 | * Contains a.out style symbol table with some tricks.
|
---|
| 660 | */
|
---|
| 661 | typedef struct symtab_command
|
---|
| 662 | {
|
---|
| 663 | KU32 cmd; /**< LC_SYMTAB */
|
---|
| 664 | KU32 cmdsize; /** sizeof(symtab_command_t) */
|
---|
| 665 | KU32 symoff; /** The file offset of the symbol table. */
|
---|
| 666 | KU32 nsyms; /** The number of symbols in the symbol table. */
|
---|
| 667 | KU32 stroff; /** The file offset of the string table. */
|
---|
| 668 | KU32 strsize; /** The size of the string table. */
|
---|
| 669 | } symtab_command_t;
|
---|
| 670 |
|
---|
| 671 |
|
---|
| 672 | /** @todo dysymtab_command (LC_DYSYMTAB) */
|
---|
| 673 | /** @todo dylib_table_of_contents */
|
---|
| 674 | /** @todo dylib_module_32 */
|
---|
| 675 | /** @todo dylib_module_64 */
|
---|
| 676 | /** @todo dylib_reference */
|
---|
| 677 | /** @todo twolevel_hints_command (LC_TWOLEVEL_HINTS) */
|
---|
| 678 | /** @todo twolevel_hint */
|
---|
| 679 | /** @todo prebind_cksum_command (LC_PREBIND_CKSUM) */
|
---|
| 680 |
|
---|
| 681 |
|
---|
| 682 | /**
|
---|
| 683 | * UUID generated by ld.
|
---|
| 684 | */
|
---|
| 685 | typedef struct uuid_command
|
---|
| 686 | {
|
---|
| 687 | KU32 cmd; /**< LC_UUID */
|
---|
| 688 | KU32 cmdsize; /**< sizeof(uuid_command_t) */
|
---|
| 689 | KU8 uuid[16]; /** The UUID bytes. */
|
---|
| 690 | } uuid_command_t;
|
---|
| 691 |
|
---|
| 692 |
|
---|
| 693 | /** @todo symseg_command (LC_SYMSEG) */
|
---|
| 694 | /** @todo ident_command (LC_IDENT) */
|
---|
| 695 | /** @todo fvmfile_command (LC_FVMFILE) */
|
---|
[48] | 696 | /** @todo rpath_command (LC_RPATH) */
|
---|
[2] | 697 |
|
---|
[48] | 698 | typedef struct linkedit_data_command
|
---|
| 699 | {
|
---|
| 700 | KU32 cmd; /**< LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS */
|
---|
| 701 | KU32 cmdsize; /**< size of this structure. */
|
---|
| 702 | KU32 dataoff; /**< Offset into the file of the data. */
|
---|
| 703 | KU32 datasize; /**< The size of the data. */
|
---|
| 704 | } linkedit_data_command_t;
|
---|
| 705 |
|
---|
| 706 | /** @todo encryption_info_command (LC_ENCRYPTION_INFO) */
|
---|
| 707 | /** @todo dyld_info_command (LC_DYLD_INFO, LC_DYLD_INFO_ONLY) */
|
---|
| 708 |
|
---|
| 709 | typedef struct version_min_command
|
---|
| 710 | {
|
---|
| 711 | KU32 cmd; /**< LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_IPHONEOS */
|
---|
| 712 | KU32 cmdsize; /**< size of this structure. */
|
---|
| 713 | KU32 version; /**< 31..16=major, 15..8=minor, 7..0=patch. */
|
---|
| 714 | KU32 reserved; /**< MBZ. */
|
---|
| 715 | } version_min_command_t;
|
---|
| 716 |
|
---|
[2] | 717 | /** @} */
|
---|
| 718 |
|
---|
| 719 |
|
---|
| 720 |
|
---|
| 721 | /** @defgroup grp_macho_o_syms Symbol Table
|
---|
| 722 | * @{ */
|
---|
| 723 |
|
---|
| 724 | /**
|
---|
| 725 | * The 32-bit Mach-O version of the nlist structure.
|
---|
| 726 | *
|
---|
| 727 | * This differs from the a.out nlist struct in that the unused n_other field
|
---|
| 728 | * was renamed to n_sect and used for keeping the relevant section number.
|
---|
| 729 | * @remark This structure is not name mach_nlist_32 in the Apple headers, but nlist.
|
---|
| 730 | */
|
---|
| 731 | typedef struct macho_nlist_32
|
---|
| 732 | {
|
---|
| 733 | union
|
---|
| 734 | {
|
---|
| 735 | KI32 n_strx; /**< Offset (index) into the string table. 0 means "". */
|
---|
| 736 | } n_un;
|
---|
| 737 | KU8 n_type; /**< Symbol type. */
|
---|
| 738 | KU8 n_sect; /**< Section number of NO_SECT. */
|
---|
| 739 | KI16 n_desc; /**< Type specific, debug info details mostly.*/
|
---|
| 740 | KU32 n_value; /**< The symbol value or stab offset. */
|
---|
| 741 | } macho_nlist_32_t;
|
---|
| 742 |
|
---|
| 743 |
|
---|
| 744 | /**
|
---|
| 745 | * The 64-bit Mach-O version of the nlist structure.
|
---|
| 746 | * @see macho_nlist_32
|
---|
| 747 | */
|
---|
| 748 | typedef struct macho_nlist_64
|
---|
| 749 | {
|
---|
| 750 | union
|
---|
| 751 | {
|
---|
| 752 | KU32 n_strx; /**< Offset (index) into the string table. 0 means "". */
|
---|
| 753 | } n_un;
|
---|
| 754 | KU8 n_type; /**< Symbol type. */
|
---|
| 755 | KU8 n_sect; /**< Section number of NO_SECT. */
|
---|
| 756 | KI16 n_desc; /**< Type specific, debug info details mostly.*/
|
---|
| 757 | KU64 n_value; /**< The symbol value or stab offset. */
|
---|
| 758 | } macho_nlist_64_t;
|
---|
| 759 |
|
---|
| 760 |
|
---|
| 761 | /** @name Symbol Type Constants (macho_nlist_32_t::n_type, macho_nlist_64_t::n_type)
|
---|
| 762 | *
|
---|
| 763 | * In the Mach-O world n_type is somewhat similar to a.out, meaning N_EXT, N_UNDF, N_ABS
|
---|
| 764 | * and the debug symbols are essentially the same, but the remaining stuff is different.
|
---|
| 765 | * The main reason for this is that the encoding of section has been moved to n_sect
|
---|
| 766 | * to permit up to 255 sections instead of the fixed 3 a.out sections (not counting
|
---|
| 767 | * the abs symbols and set vectors).
|
---|
| 768 | *
|
---|
| 769 | * To avoid confusion with a.out the Mach-O constants has been fitted with a MACHO_
|
---|
| 770 | * prefix here.
|
---|
| 771 | *
|
---|
| 772 | * Common symbols (aka communal symbols and comdefs) are represented by
|
---|
| 773 | * n_type = MACHO_N_EXT | MACHO_N_UNDF, n_sect = NO_SECT and n_value giving
|
---|
| 774 | * the size.
|
---|
| 775 | *
|
---|
| 776 | *
|
---|
| 777 | * Symbol table entries can be inserted directly in the assembly code using
|
---|
| 778 | * this notation:
|
---|
| 779 | * @code
|
---|
| 780 | * .stabs "n_name", n_type, n_sect, n_desc, n_value
|
---|
| 781 | * @endcode
|
---|
| 782 | *
|
---|
| 783 | * (1) The line number is optional, GCC doesn't set it.
|
---|
| 784 | * (2) The type is optional, GCC doesn't set it.
|
---|
| 785 | * (3) The binutil header is "skeptical" about the line. I'm skeptical about the whole thing... :-)
|
---|
| 786 | * (M) Mach-O specific?
|
---|
| 787 | * (S) Sun specific?
|
---|
| 788 | * @{
|
---|
| 789 | */
|
---|
| 790 |
|
---|
| 791 | /* Base masks. */
|
---|
| 792 | #define MACHO_N_EXT KU8_C(0x01) /**< External symbol (when set) (N_EXT). */
|
---|
| 793 | #define MACHO_N_TYPE KU8_C(0x0e) /**< Symbol type (N_TYPE without the 8th bit). */
|
---|
| 794 | #define MACHO_N_PEXT KU8_C(0x10) /**< Private extern symbol (when set). (M) */
|
---|
| 795 | #define MACHO_N_STAB KU8_C(0xe0) /**< Debug symbol mask (N_STAB). */
|
---|
| 796 |
|
---|
| 797 | /* MACHO_N_TYPE values. */
|
---|
| 798 | #define MACHO_N_UNDF KU8_C(0x00) /**< MACHO_N_TYPE: Undefined symbol (N_UNDF). n_sect = NO_SECT. */
|
---|
| 799 | #define MACHO_N_ABS KU8_C(0x02) /**< MACHO_N_TYPE: Absolute symbol (N_UNDF). n_sect = NO_SECT. */
|
---|
| 800 | #define MACHO_N_INDR KU8_C(0x0a) /**< MACHO_N_TYPE: Indirect symbol, n_value is the index of the symbol. (M) */
|
---|
| 801 | #define MACHO_N_PBUD KU8_C(0x0c) /**< MACHO_N_TYPE: Prebound undefined symbo (defined in a dylib). (M) */
|
---|
| 802 | #define MACHO_N_SECT KU8_C(0x0e) /**< MACHO_N_TYPE: Defined in the section given by n_sects. (M) */
|
---|
| 803 |
|
---|
| 804 | /* Debug symbols. */
|
---|
| 805 | #define MACHO_N_GSYM KU8_C(0x20) /**< Global variable. "name",, NO_SECT, type, 0 (2) */
|
---|
| 806 | #define MACHO_N_FNAME KU8_C(0x22) /**< Function name (F77). "name",, NO_SECT, 0, 0 */
|
---|
| 807 | #define MACHO_N_FUN KU8_C(0x24) /**< Function / text var. "name",, section, line, address (1) */
|
---|
| 808 | #define MACHO_N_STSYM KU8_C(0x26) /**< Static data symbol. "name",, section, type, address (2) */
|
---|
| 809 | #define MACHO_N_LCSYM KU8_C(0x28) /**< static bss symbol. "name",, section, type, address (2) */
|
---|
| 810 | /* omits N_MAIN and N_ROSYM. */
|
---|
| 811 | #define MACHO_N_BNSYM KU8_C(0x2e) /**< Begin nsect symbol. 0,, section, 0, address (M) */
|
---|
| 812 | #define MACHO_N_PC KU8_C(0x30) /**< Global pascal symbol. "name",, NO_SECT, subtype?, line (3) */
|
---|
| 813 | /* omits N_NSYMS, N_NOMAP and N_OBJ. */
|
---|
| 814 | #define MACHO_N_OPT KU8_C(0x3c) /**< Options for the debugger related to the language of the
|
---|
| 815 | source file. "options?",,,, */
|
---|
| 816 | #define MACHO_N_RSYM KU8_C(0x40) /**< Register variable. "name",, NO_SECT, type, register */
|
---|
| 817 | /* omits N_M2C */
|
---|
| 818 | #define MACHO_N_SLINE KU8_C(0x44) /**< Source line. 0,, section, line, address */
|
---|
| 819 | /* omits N_DSLINE, N_BSLINE / N_BROWS, N_DEFD and N_FLINE. */
|
---|
| 820 | #define MACHO_N_ENSYM KU8_C(0x4e) /**< End nsect symbol. 0,, section, 0, address (M) */
|
---|
| 821 | /* omits N_EHDECL / N_MOD2 and N_CATCH. */
|
---|
| 822 | #define MACHO_N_SSYM KU8_C(0x60) /**< Struct/union element. "name",, NO_SECT, type, offset */
|
---|
| 823 | /* omits N_ENDM */
|
---|
| 824 | #define MACHO_N_SO KU8_C(0x64) /**< Source file name. "fname",, section, 0, address */
|
---|
| 825 | #define MACHO_N_OSO KU8_C(0x66) /**< Object file name. "fname",, 0, 0, st_mtime (M?) */
|
---|
| 826 | /* omits N_ALIAS */
|
---|
| 827 | #define MACHO_N_LSYM KU8_C(0x80) /**< Stack variable. "name",, NO_SECT, type, frame_offset */
|
---|
| 828 | #define MACHO_N_BINCL KU8_C(0x82) /**< Begin #include. "fname",, NO_SECT, 0, sum? */
|
---|
| 829 | #define MACHO_N_SOL KU8_C(0x84) /**< #included file. "fname",, section, 0, start_address (S) */
|
---|
| 830 | #define MACHO_N_PARAMS KU8_C(0x86) /**< Compiler params. "params",, NO_SECT, 0, 0 */
|
---|
| 831 | #define MACHO_N_VERSION KU8_C(0x88) /**< Compiler version. "version",, NO_SECT, 0, 0 */
|
---|
| 832 | #define MACHO_N_OLEVEL KU8_C(0x8A) /**< Compiler -O level. "level",, NO_SECT, 0, 0 */
|
---|
| 833 | #define MACHO_N_PSYM KU8_C(0xa0) /**< Parameter variable. "name",, NO_SECT, type, frame_offset */
|
---|
| 834 | #define MACHO_N_EINCL KU8_C(0xa2) /**< End #include. "fname",, NO_SECT, 0, 0 (S) */
|
---|
| 835 | #define MACHO_N_ENTRY KU8_C(0xa4) /**< Alternate entry point. "name",, section, line, address */
|
---|
| 836 | #define MACHO_N_LBRAC KU8_C(0xc0) /**< Left bracket. 0,, NO_SECT, nesting_level, address */
|
---|
| 837 | #define MACHO_N_EXCL KU8_C(0xc2) /**< Deleted include file. "fname",, NO_SECT, 0, sum? (S) */
|
---|
| 838 | /* omits N_SCOPE */
|
---|
| 839 | #define MACHO_N_RBRAC KU8_C(0xe0) /**< Right bracket. 0,, NO_SECT, nesting_level, address */
|
---|
| 840 | #define MACHO_N_BCOMM KU8_C(0xe2) /**< Begin common. "name",, NO_SECT?, 0, 0 */
|
---|
| 841 | #define MACHO_N_ECOMM KU8_C(0xe4) /**< End common. "name",, section, 0, 0 */
|
---|
| 842 | #define MACHO_N_ECOML KU8_C(0xe8) /**< End local common. 0,, section, 0, address */
|
---|
| 843 | #define MACHO_N_LENG KU8_C(0xfe) /**< Length-value of the preceding entry.
|
---|
| 844 | "name",, NO_SECT, 0, length */
|
---|
| 845 |
|
---|
| 846 | /** @} */
|
---|
| 847 |
|
---|
| 848 | /** @name Symbol Description Bits (macho_nlist_32_t::n_desc, macho_nlist_64_t::n_desc)
|
---|
| 849 | *
|
---|
| 850 | * Mach-O puts the n_desc field to a number of uses, like lazy binding , library
|
---|
| 851 | * ordinal numbers for -twolevel_namespace, stripping and weak symbol handling.
|
---|
| 852 | *
|
---|
| 853 | * @remark The REFERENCE_FLAGS_* are really not flags in the normal sense (bit),
|
---|
| 854 | * they are more like enum values.
|
---|
| 855 | * @{
|
---|
| 856 | */
|
---|
| 857 |
|
---|
| 858 | #define REFERENCE_TYPE KU16_C(0x000f) /**< The reference type mask. */
|
---|
| 859 | #define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0 /**< Normal undefined symbol. */
|
---|
| 860 | #define REFERENCE_FLAG_UNDEFINED_LAZY 1 /**< Lazy undefined symbol. */
|
---|
| 861 | #define REFERENCE_FLAG_DEFINED 2 /**< Defined symbol (dynamic linking). */
|
---|
| 862 | #define REFERENCE_FLAG_PRIVATE_DEFINED 3 /**< Defined private symbol (dynamic linking). */
|
---|
| 863 | #define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4 /**< Normal undefined private symbol. */
|
---|
| 864 | #define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5 /**< Lazy undefined private symbol. */
|
---|
| 865 |
|
---|
| 866 | #define REFERENCED_DYNAMICALLY KU16_C(0x0010) /**< Don't strip. */
|
---|
| 867 |
|
---|
| 868 |
|
---|
| 869 | /** Get the dynamic library ordinal. */
|
---|
| 870 | #define GET_LIBRARY_ORDINAL(n_desc) \
|
---|
| 871 | (((n_desc) >> 8) & 0xff)
|
---|
| 872 | /** Set the dynamic library ordinal. */
|
---|
| 873 | #define SET_LIBRARY_ORDINAL(n_desc, ordinal) \
|
---|
| 874 | (n_desc) = (((n_desc) & 0xff) | (((ordinal) & 0xff) << 8))
|
---|
| 875 | #define SELF_LIBRARY_ORDINAL 0x00 /**< Special ordinal for refering to onself. */
|
---|
| 876 | #define MAX_LIBRARY_ORDINAL 0xfd /**< Maximum ordinal number. */
|
---|
| 877 | #define DYNAMIC_LOOKUP_ORDINAL 0xfe /**< Special ordinal number for dynamic lookup. (Mac OS X 10.3 and later) */
|
---|
| 878 | #define EXECUTABLE_ORDINAL 0xff /**< Special ordinal number for the executable. */
|
---|
| 879 |
|
---|
| 880 |
|
---|
| 881 | /** Only MH_OBJECT: Never dead strip me! */
|
---|
| 882 | #define N_NO_DEAD_STRIP KU16_C(0x0020)
|
---|
| 883 | /** Not MH_OBJECT: Discarded symbol. */
|
---|
| 884 | #define N_DESC_DISCARDED KU16_C(0x0020)
|
---|
| 885 | /** Weak external symbol. Symbol can be missing, in which case it's will have the value 0. */
|
---|
| 886 | #define N_WEAK_REF KU16_C(0x0040)
|
---|
| 887 | /** Weak symbol definition. The symbol can be overridden by another weak
|
---|
| 888 | * symbol already present or by a non-weak (strong) symbol definition.
|
---|
| 889 | * Currently only supported for coalesed symbols.
|
---|
| 890 | * @remark This bit means something differently for undefined symbols, see N_REF_TO_WEAK.
|
---|
| 891 | */
|
---|
| 892 | #define N_WEAK_DEF KU16_C(0x0080)
|
---|
| 893 | /** Reference to a weak symbol, resolve using flat namespace searching.
|
---|
| 894 | * @remark This bit means something differently for defined symbols, see N_WEAK_DEF. */
|
---|
| 895 | #define N_REF_TO_WEAK KU16_C(0x0080)
|
---|
| 896 |
|
---|
| 897 | /** @} */
|
---|
| 898 |
|
---|
| 899 | /** @} */
|
---|
| 900 |
|
---|
| 901 |
|
---|
| 902 | /** @defgroup grp_macho_o_relocs Relocations
|
---|
| 903 | * @{ */
|
---|
| 904 |
|
---|
| 905 | /**
|
---|
| 906 | * Relocation entry.
|
---|
| 907 | *
|
---|
| 908 | * Differs from a.out in the meaning of r_symbolnum when r_extern=0 and
|
---|
| 909 | * that r_pad is made into r_type.
|
---|
| 910 | *
|
---|
| 911 | * @remark This structure and type has been prefixed with macho_ to avoid
|
---|
| 912 | * confusion with the original a.out type.
|
---|
| 913 | */
|
---|
| 914 | typedef struct macho_relocation_info
|
---|
| 915 | {
|
---|
| 916 | KI32 r_address; /**< Section relative address of the fixup.
|
---|
| 917 | The top bit (signed) indicates that this is a scattered
|
---|
| 918 | relocation if set, see scattered_relocation_info_t. */
|
---|
| 919 | KU32 r_symbolnum : 24, /**< r_extern=1: Symbol table index, relocate with the address of this symbol.
|
---|
| 920 | r_extern=0: Section ordinal, relocate with the address of this section. */
|
---|
| 921 | r_pcrel : 1, /**< PC (program counter) relative fixup; subtract the fixup address. */
|
---|
| 922 | r_length : 2, /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. */
|
---|
| 923 | r_extern : 1, /**< External or internal fixup, decides the r_symbolnum interpretation.. */
|
---|
| 924 | r_type : 4; /**< Relocation type; 0 is standard, non-zero are machine specific. */
|
---|
| 925 | } macho_relocation_info_t;
|
---|
| 926 |
|
---|
| 927 | /** Special section ordinal value for absolute relocations. */
|
---|
| 928 | #define R_ABS 0
|
---|
| 929 |
|
---|
| 930 | /** Flag in r_address indicating that the relocation is of the
|
---|
| 931 | * scattered_relocation_info_t kind and not macho_relocation_info_t. */
|
---|
| 932 | #define R_SCATTERED KU32_C(0x80000000)
|
---|
| 933 |
|
---|
| 934 | /**
|
---|
| 935 | * Scattered relocation.
|
---|
| 936 | *
|
---|
| 937 | * This is a hack mainly for RISC machines which restricts section size
|
---|
| 938 | * to 16MB among other things.
|
---|
| 939 | *
|
---|
| 940 | * The reason for the big/little endian differences here is of course because
|
---|
| 941 | * of the R_SCATTERED mask and the way bitfields are implemented by the
|
---|
| 942 | * C/C++ compilers.
|
---|
| 943 | */
|
---|
| 944 | typedef struct scattered_relocation_info
|
---|
| 945 | {
|
---|
| 946 | #if K_ENDIAN == K_ENDIAN_LITTLE
|
---|
| 947 | KU32 r_address : 24, /**< Section relative address of the fixup. (macho_relocation_info_t::r_address) */
|
---|
| 948 | r_type : 4, /**< Relocation type; 0 is standard, non-zero are machine specific. (macho_relocation_info_t::r_type) */
|
---|
| 949 | r_length : 2, /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. (macho_relocation_info_t::r_length) */
|
---|
| 950 | r_pcrel : 1, /**< PC (program counter) relative fixup; subtract the fixup address. (macho_relocation_info_t::r_pcrel) */
|
---|
| 951 | r_scattered : 1; /**< Set if scattered relocation, clear if normal relocation. */
|
---|
| 952 | #elif K_ENDIAN == K_ENDIAN_BIG
|
---|
| 953 | KU32 r_scattered : 1, /**< Set if scattered relocation, clear if normal relocation. */
|
---|
| 954 | r_pcrel : 1, /**< PC (program counter) relative fixup; subtract the fixup address. (macho_relocation_info_t::r_pcrel) */
|
---|
| 955 | r_length : 2, /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. (macho_relocation_info_t::r_length) */
|
---|
| 956 | r_type : 4, /**< Relocation type; 0 is standard, non-zero are machine specific. (macho_relocation_info_t::r_type) */
|
---|
| 957 | r_address : 24; /**< Section relative address of the fixup. (macho_relocation_info_t::r_address) */
|
---|
| 958 | #else
|
---|
| 959 | # error "Neither K_ENDIAN isn't LITTLE or BIG!"
|
---|
| 960 | #endif
|
---|
| 961 | KI32 r_value; /**< The value the fixup is refering to (without offset added). */
|
---|
| 962 | } scattered_relocation_info_t;
|
---|
| 963 |
|
---|
| 964 | /**
|
---|
| 965 | * Relocation type values for a generic implementation (for r_type).
|
---|
| 966 | */
|
---|
| 967 | typedef enum reloc_type_generic
|
---|
| 968 | {
|
---|
| 969 | GENERIC_RELOC_VANILLA = 0, /**< Standard relocation. */
|
---|
| 970 | GENERIC_RELOC_PAIR, /**< Follows GENERIC_RELOC_SECTDIFF. */
|
---|
| 971 | GENERIC_RELOC_SECTDIFF, /**< ??? */
|
---|
| 972 | GENERIC_RELOC_PB_LA_PTR, /**< Prebound lazy pointer whatever that. */
|
---|
| 973 | GENERIC_RELOC_LOCAL_SECTDIFF /**< ??? */
|
---|
| 974 | } reloc_type_generic_t;
|
---|
| 975 |
|
---|
[20] | 976 | /**
|
---|
| 977 | * Relocation type values for AMD64 (for r_type).
|
---|
| 978 | */
|
---|
| 979 | typedef enum reloc_type_x86_64
|
---|
| 980 | {
|
---|
| 981 | X86_64_RELOC_UNSIGNED = 0, /**< Absolute address. */
|
---|
| 982 | X86_64_RELOC_SIGNED, /**< Signed displacement. */
|
---|
| 983 | X86_64_RELOC_BRANCH, /**< Branch displacement (jmp/call, adj by size). */
|
---|
| 984 | X86_64_RELOC_GOT_LOAD, /**< GOT entry load. */
|
---|
[27] | 985 | X86_64_RELOC_GOT, /**< GOT reference. */
|
---|
[20] | 986 | X86_64_RELOC_SUBTRACTOR, /**< ??. */
|
---|
| 987 | X86_64_RELOC_SIGNED_1, /**< Signed displacement with a -1 added. */
|
---|
| 988 | X86_64_RELOC_SIGNED_2, /**< Signed displacement with a -2 added. */
|
---|
| 989 | X86_64_RELOC_SIGNED_4 /**< Signed displacement with a -4 added. */
|
---|
| 990 | } reloc_type_x86_64_t;
|
---|
| 991 |
|
---|
[2] | 992 | /** @} */
|
---|
| 993 |
|
---|
| 994 |
|
---|
| 995 | /** @} */
|
---|
| 996 | #endif
|
---|
| 997 |
|
---|