pub const DYLD_MACOSX_VERSION_10_4: u32 = 0x000A_0400;
pub const DYLD_MACOSX_VERSION_10_5: u32 = 0x000A_0500;
pub const DYLD_MACOSX_VERSION_10_6: u32 = 0x000A_0600;
pub const DYLD_MACOSX_VERSION_10_7: u32 = 0x000A_0700;
pub const DYLD_MACOSX_VERSION_10_8: u32 = 0x000A_0800;
pub const DYLD_MACOSX_VERSION_10_9: u32 = 0x000A_0900;
pub const DYLD_MACOSX_VERSION_10_10: u32 = 0x000A_0A00;
pub const DYLD_MACOSX_VERSION_10_11: u32 = 0x000A_0B00;
pub const DYLD_MACOSX_VERSION_10_12: u32 = 0x000A_0C00;
pub const DYLD_MACOSX_VERSION_10_13: u32 = 0x000A_0D00;
pub const DYLD_IOS_VERSION_2_0: u32 = 0x0002_0000;
pub const DYLD_IOS_VERSION_2_1: u32 = 0x0002_0100;
pub const DYLD_IOS_VERSION_2_2: u32 = 0x0002_0200;
pub const DYLD_IOS_VERSION_3_0: u32 = 0x0003_0000;
pub const DYLD_IOS_VERSION_3_1: u32 = 0x0003_0100;
pub const DYLD_IOS_VERSION_3_2: u32 = 0x0003_0200;
pub const DYLD_IOS_VERSION_4_0: u32 = 0x0004_0000;
pub const DYLD_IOS_VERSION_4_1: u32 = 0x0004_0100;
pub const DYLD_IOS_VERSION_4_2: u32 = 0x0004_0200;
pub const DYLD_IOS_VERSION_4_3: u32 = 0x0004_0300;
pub const DYLD_IOS_VERSION_5_0: u32 = 0x0005_0000;
pub const DYLD_IOS_VERSION_5_1: u32 = 0x0005_0100;
pub const DYLD_IOS_VERSION_6_0: u32 = 0x0006_0000;
pub const DYLD_IOS_VERSION_6_1: u32 = 0x0006_0100;
pub const DYLD_IOS_VERSION_7_0: u32 = 0x0007_0000;
pub const DYLD_IOS_VERSION_7_1: u32 = 0x0007_0100;
pub const DYLD_IOS_VERSION_8_0: u32 = 0x0008_0000;
pub const DYLD_IOS_VERSION_9_0: u32 = 0x0009_0000;
pub const DYLD_IOS_VERSION_10_0: u32 = 0x000A_0000;
pub const DYLD_IOS_VERSION_11_0: u32 = 0x000B_0000;
pub const SECTION_TYPE: u32 = 0x0000_00ff;
pub const SECTION_ATTRIBUTES: u32 = 0xffff_ff00;
pub const S_REGULAR: u32 = 0x0;
pub const S_ZEROFILL: u32 = 0x1;
pub const S_CSTRING_LITERALS: u32 = 0x2;
pub const S_4BYTE_LITERALS: u32 = 0x3;
pub const S_8BYTE_LITERALS: u32 = 0x4;
pub const S_LITERAL_POINTERS: u32 = 0x5;
pub const S_NON_LAZY_SYMBOL_POINTERS: u32 = 0x6;
pub const S_LAZY_SYMBOL_POINTERS: u32 = 0x7;
pub const S_SYMBOL_STUBS: u32 = 0x8;
pub const S_MOD_INIT_FUNC_POINTERS: u32 = 0x9;
pub const S_MOD_TERM_FUNC_POINTERS: u32 = 0xa;
pub const S_COALESCED: u32 = 0xb;
pub const S_GB_ZEROFILL: u32 = 0xc;
pub const S_INTERPOSING: u32 = 0xd;
pub const S_16BYTE_LITERALS: u32 = 0xe;
pub const S_DTRACE_DOF: u32 = 0xf;
pub const S_LAZY_DYLIB_SYMBOL_POINTERS: u32 = 0x10;
pub const S_THREAD_LOCAL_REGULAR: u32 = 0x11;
pub const S_THREAD_LOCAL_ZEROFILL: u32 = 0x12;
pub const S_THREAD_LOCAL_VARIABLES: u32 = 0x13;
pub const S_THREAD_LOCAL_VARIABLE_POINTERS: u32 = 0x14;
pub const S_THREAD_LOCAL_INIT_FUNCTION_POINTERS: u32 = 0x15;
pub const SECTION_ATTRIBUTES_USR: u32 = 0xff00_0000;
pub const S_ATTR_PURE_INSTRUCTIONS: u32 = 0x8000_0000;
pub const S_ATTR_NO_TOC: u32 = 0x4000_0000;
pub const S_ATTR_STRIP_STATIC_SYMS: u32 = 0x2000_0000;
pub const S_ATTR_NO_DEAD_STRIP: u32 = 0x1000_0000;
pub const S_ATTR_LIVE_SUPPORT: u32 = 0x0800_0000;
pub const S_ATTR_SELF_MODIFYING_CODE: u32 = 0x0400_0000;
pub const S_ATTR_DEBUG: u32 = 0x0200_0000;
pub const SECTION_ATTRIBUTES_SYS: u32 = 0x00ff_ff00;
pub const S_ATTR_SOME_INSTRUCTIONS: u32 = 0x0000_0400;
pub const S_ATTR_EXT_RELOC: u32 = 0x0000_0200;
pub const S_ATTR_LOC_RELOC: u32 = 0x0000_0100;
pub const SEG_PAGEZERO: &str = "__PAGEZERO";
pub const SEG_TEXT: &str = "__TEXT";
pub const SECT_TEXT: &str = "__text";
pub const SECT_FVMLIB_INIT0: &str = "__fvmlib_init0";
pub const SECT_FVMLIB_INIT1: &str = "__fvmlib_init1";
pub const SEG_DATA: &str = "__DATA";
pub const SECT_DATA: &str = "__data";
pub const SECT_BSS: &str = "__bss";
pub const SECT_COMMON: &str = "__common";
pub const SEG_OBJC: &str = "__OBJC";
pub const SECT_OBJC_SYMBOLS: &str = "__symbol_table";
pub const SECT_OBJC_MODULES: &str = "__module_info";
pub const SECT_OBJC_STRINGS: &str = "__selector_strs";
pub const SECT_OBJC_REFS: &str = "__selector_refs";
pub const SEG_ICON: &str = "__ICON";
pub const SECT_ICON_HEADER: &str = "__header";
pub const SECT_ICON_TIFF: &str = "__tiff";
pub const SEG_LINKEDIT: &str = "__LINKEDIT";
pub const SEG_UNIXSTACK: &str = "__UNIXSTACK";
pub const SEG_IMPORT: &str = "__IMPORT";
pub const VM_PROT_READ: u32 = 0x1;
pub const VM_PROT_WRITE: u32 = 0x2;
pub const VM_PROT_EXECUTE: u32 = 0x4;
pub mod cputype {
pub type CpuType = u32;
pub type CpuSubType = u32;
pub const CPU_SUBTYPE_MASK: u32 = 0xff00_0000;
pub const CPU_ARCH_MASK: CpuType = 0xff00_0000;
pub const CPU_ARCH_ABI64: CpuType = 0x0100_0000;
pub const CPU_ARCH_ABI64_32: CpuType = 0x0200_0000;
pub const CPU_TYPE_ANY: CpuType = !0;
pub const CPU_TYPE_VAX: CpuType = 1;
pub const CPU_TYPE_MC680X0: CpuType = 6;
pub const CPU_TYPE_X86: CpuType = 7;
pub const CPU_TYPE_I386: CpuType = CPU_TYPE_X86;
pub const CPU_TYPE_X86_64: CpuType = CPU_TYPE_X86 | CPU_ARCH_ABI64;
pub const CPU_TYPE_MIPS: CpuType = 8;
pub const CPU_TYPE_MC98000: CpuType = 10;
pub const CPU_TYPE_HPPA: CpuType = 11;
pub const CPU_TYPE_ARM: CpuType = 12;
pub const CPU_TYPE_ARM64: CpuType = CPU_TYPE_ARM | CPU_ARCH_ABI64;
pub const CPU_TYPE_ARM64_32: CpuType = CPU_TYPE_ARM | CPU_ARCH_ABI64_32;
pub const CPU_TYPE_MC88000: CpuType = 13;
pub const CPU_TYPE_SPARC: CpuType = 14;
pub const CPU_TYPE_I860: CpuType = 15;
pub const CPU_TYPE_ALPHA: CpuType = 16;
pub const CPU_TYPE_POWERPC: CpuType = 18;
pub const CPU_TYPE_POWERPC64: CpuType = CPU_TYPE_POWERPC | CPU_ARCH_ABI64;
pub const CPU_SUBTYPE_MULTIPLE: CpuSubType = !0;
pub const CPU_SUBTYPE_LITTLE_ENDIAN: CpuSubType = 0;
pub const CPU_SUBTYPE_BIG_ENDIAN: CpuSubType = 1;
pub const CPU_SUBTYPE_VAX_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_VAX780: CpuSubType = 1;
pub const CPU_SUBTYPE_VAX785: CpuSubType = 2;
pub const CPU_SUBTYPE_VAX750: CpuSubType = 3;
pub const CPU_SUBTYPE_VAX730: CpuSubType = 4;
pub const CPU_SUBTYPE_UVAXI: CpuSubType = 5;
pub const CPU_SUBTYPE_UVAXII: CpuSubType = 6;
pub const CPU_SUBTYPE_VAX8200: CpuSubType = 7;
pub const CPU_SUBTYPE_VAX8500: CpuSubType = 8;
pub const CPU_SUBTYPE_VAX8600: CpuSubType = 9;
pub const CPU_SUBTYPE_VAX8650: CpuSubType = 10;
pub const CPU_SUBTYPE_VAX8800: CpuSubType = 11;
pub const CPU_SUBTYPE_UVAXIII: CpuSubType = 12;
pub const CPU_SUBTYPE_MC680X0_ALL: CpuSubType = 1;
pub const CPU_SUBTYPE_MC68030: CpuSubType = 1;
pub const CPU_SUBTYPE_MC68040: CpuSubType = 2;
pub const CPU_SUBTYPE_MC68030_ONLY: CpuSubType = 3;
macro_rules! CPU_SUBTYPE_INTEL {
($f:expr, $m:expr) => {{
($f) + (($m) << 4)
}};
}
pub const CPU_SUBTYPE_I386_ALL: CpuSubType = CPU_SUBTYPE_INTEL!(3, 0);
pub const CPU_SUBTYPE_386: CpuSubType = CPU_SUBTYPE_INTEL!(3, 0);
pub const CPU_SUBTYPE_486: CpuSubType = CPU_SUBTYPE_INTEL!(4, 0);
pub const CPU_SUBTYPE_486SX: CpuSubType = CPU_SUBTYPE_INTEL!(4, 8);
pub const CPU_SUBTYPE_586: CpuSubType = CPU_SUBTYPE_INTEL!(5, 0);
pub const CPU_SUBTYPE_PENT: CpuSubType = CPU_SUBTYPE_INTEL!(5, 0);
pub const CPU_SUBTYPE_PENTPRO: CpuSubType = CPU_SUBTYPE_INTEL!(6, 1);
pub const CPU_SUBTYPE_PENTII_M3: CpuSubType = CPU_SUBTYPE_INTEL!(6, 3);
pub const CPU_SUBTYPE_PENTII_M5: CpuSubType = CPU_SUBTYPE_INTEL!(6, 5);
pub const CPU_SUBTYPE_CELERON: CpuSubType = CPU_SUBTYPE_INTEL!(7, 6);
pub const CPU_SUBTYPE_CELERON_MOBILE: CpuSubType = CPU_SUBTYPE_INTEL!(7, 7);
pub const CPU_SUBTYPE_PENTIUM_3: CpuSubType = CPU_SUBTYPE_INTEL!(8, 0);
pub const CPU_SUBTYPE_PENTIUM_3_M: CpuSubType = CPU_SUBTYPE_INTEL!(8, 1);
pub const CPU_SUBTYPE_PENTIUM_3_XEON: CpuSubType = CPU_SUBTYPE_INTEL!(8, 2);
pub const CPU_SUBTYPE_PENTIUM_M: CpuSubType = CPU_SUBTYPE_INTEL!(9, 0);
pub const CPU_SUBTYPE_PENTIUM_4: CpuSubType = CPU_SUBTYPE_INTEL!(10, 0);
pub const CPU_SUBTYPE_PENTIUM_4_M: CpuSubType = CPU_SUBTYPE_INTEL!(10, 1);
pub const CPU_SUBTYPE_ITANIUM: CpuSubType = CPU_SUBTYPE_INTEL!(11, 0);
pub const CPU_SUBTYPE_ITANIUM_2: CpuSubType = CPU_SUBTYPE_INTEL!(11, 1);
pub const CPU_SUBTYPE_XEON: CpuSubType = CPU_SUBTYPE_INTEL!(12, 0);
pub const CPU_SUBTYPE_XEON_MP: CpuSubType = CPU_SUBTYPE_INTEL!(12, 1);
pub const CPU_SUBTYPE_INTEL_FAMILY_MAX: CpuSubType = 15;
pub const CPU_SUBTYPE_INTEL_MODEL_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_X86_ALL: CpuSubType = 3;
pub const CPU_SUBTYPE_X86_64_ALL: CpuSubType = 3;
pub const CPU_SUBTYPE_X86_ARCH1: CpuSubType = 4;
pub const CPU_SUBTYPE_X86_64_H: CpuSubType = 8;
pub const CPU_SUBTYPE_MIPS_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_MIPS_R2300: CpuSubType = 1;
pub const CPU_SUBTYPE_MIPS_R2600: CpuSubType = 2;
pub const CPU_SUBTYPE_MIPS_R2800: CpuSubType = 3;
pub const CPU_SUBTYPE_MIPS_R2000A: CpuSubType = 4;
pub const CPU_SUBTYPE_MIPS_R2000: CpuSubType = 5;
pub const CPU_SUBTYPE_MIPS_R3000A: CpuSubType = 6;
pub const CPU_SUBTYPE_MIPS_R3000: CpuSubType = 7;
pub const CPU_SUBTYPE_MC98000_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_MC98601: CpuSubType = 1;
pub const CPU_SUBTYPE_HPPA_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_HPPA_7100: CpuSubType = 0;
pub const CPU_SUBTYPE_HPPA_7100LC: CpuSubType = 1;
pub const CPU_SUBTYPE_MC88000_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_MC88100: CpuSubType = 1;
pub const CPU_SUBTYPE_MC88110: CpuSubType = 2;
pub const CPU_SUBTYPE_SPARC_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_I860_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_I860_860: CpuSubType = 1;
pub const CPU_SUBTYPE_POWERPC_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_POWERPC_601: CpuSubType = 1;
pub const CPU_SUBTYPE_POWERPC_602: CpuSubType = 2;
pub const CPU_SUBTYPE_POWERPC_603: CpuSubType = 3;
pub const CPU_SUBTYPE_POWERPC_603E: CpuSubType = 4;
pub const CPU_SUBTYPE_POWERPC_603EV: CpuSubType = 5;
pub const CPU_SUBTYPE_POWERPC_604: CpuSubType = 6;
pub const CPU_SUBTYPE_POWERPC_604E: CpuSubType = 7;
pub const CPU_SUBTYPE_POWERPC_620: CpuSubType = 8;
pub const CPU_SUBTYPE_POWERPC_750: CpuSubType = 9;
pub const CPU_SUBTYPE_POWERPC_7400: CpuSubType = 10;
pub const CPU_SUBTYPE_POWERPC_7450: CpuSubType = 11;
pub const CPU_SUBTYPE_POWERPC_970: CpuSubType = 100;
pub const CPU_SUBTYPE_ARM_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_ARM_V4T: CpuSubType = 5;
pub const CPU_SUBTYPE_ARM_V6: CpuSubType = 6;
pub const CPU_SUBTYPE_ARM_V5TEJ: CpuSubType = 7;
pub const CPU_SUBTYPE_ARM_XSCALE: CpuSubType = 8;
pub const CPU_SUBTYPE_ARM_V7: CpuSubType = 9;
pub const CPU_SUBTYPE_ARM_V7F: CpuSubType = 10;
pub const CPU_SUBTYPE_ARM_V7S: CpuSubType = 11;
pub const CPU_SUBTYPE_ARM_V7K: CpuSubType = 12;
pub const CPU_SUBTYPE_ARM_V6M: CpuSubType = 14;
pub const CPU_SUBTYPE_ARM_V7M: CpuSubType = 15;
pub const CPU_SUBTYPE_ARM_V7EM: CpuSubType = 16;
pub const CPU_SUBTYPE_ARM_V8: CpuSubType = 13;
pub const CPU_SUBTYPE_ARM64_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_ARM64_V8: CpuSubType = 1;
pub const CPU_SUBTYPE_ARM64_E: CpuSubType = 2;
pub const CPU_SUBTYPE_ARM64_32_ALL: CpuSubType = 0;
pub const CPU_SUBTYPE_ARM64_32_V8: CpuSubType = 1;
macro_rules! cpu_flag_mapping {
(
$(($name:expr, $cputype:ident, $cpusubtype:ident),)*
) => {
fn get_arch_from_flag_no_alias(name: &str) -> Option<(CpuType, CpuSubType)> {
match name {
$($name => Some(($cputype, $cpusubtype)),)*
_ => None
}
}
pub fn get_arch_name_from_types(cputype: CpuType, cpusubtype: CpuSubType)
-> Option<&'static str> {
match (cputype, cpusubtype) {
$(($cputype, $cpusubtype) => Some($name),)*
(_, _) => None
}
}
}
}
pub fn get_arch_from_flag(name: &str) -> Option<(CpuType, CpuSubType)> {
get_arch_from_flag_no_alias(name).or_else(|| {
match name {
"pentium" => Some((CPU_TYPE_I386, CPU_SUBTYPE_PENT)),
"pentpro" => Some((CPU_TYPE_I386, CPU_SUBTYPE_PENTPRO)),
"x86" => Some((CPU_TYPE_I386, CPU_SUBTYPE_I386_ALL)),
_ => None,
}
})
}
cpu_flag_mapping! {
("any", CPU_TYPE_ANY, CPU_SUBTYPE_MULTIPLE),
("little", CPU_TYPE_ANY, CPU_SUBTYPE_LITTLE_ENDIAN),
("big", CPU_TYPE_ANY, CPU_SUBTYPE_BIG_ENDIAN),
("ppc64", CPU_TYPE_POWERPC64, CPU_SUBTYPE_POWERPC_ALL),
("x86_64", CPU_TYPE_X86_64, CPU_SUBTYPE_X86_64_ALL),
("x86_64h", CPU_TYPE_X86_64, CPU_SUBTYPE_X86_64_H),
("arm64", CPU_TYPE_ARM64, CPU_SUBTYPE_ARM64_ALL),
("arm64_32", CPU_TYPE_ARM64_32, CPU_SUBTYPE_ARM64_32_ALL),
("ppc970-64", CPU_TYPE_POWERPC64, CPU_SUBTYPE_POWERPC_970),
("ppc", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_ALL),
("i386", CPU_TYPE_I386, CPU_SUBTYPE_I386_ALL),
("m68k", CPU_TYPE_MC680X0, CPU_SUBTYPE_MC680X0_ALL),
("hppa", CPU_TYPE_HPPA, CPU_SUBTYPE_HPPA_ALL),
("sparc", CPU_TYPE_SPARC, CPU_SUBTYPE_SPARC_ALL),
("m88k", CPU_TYPE_MC88000, CPU_SUBTYPE_MC88000_ALL),
("i860", CPU_TYPE_I860, CPU_SUBTYPE_I860_ALL),
("arm", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_ALL),
("ppc601", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_601),
("ppc603", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_603),
("ppc603e", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_603E),
("ppc603ev", CPU_TYPE_POWERPC,CPU_SUBTYPE_POWERPC_603EV),
("ppc604", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_604),
("ppc604e",CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_604E),
("ppc750", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_750),
("ppc7400", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_7400),
("ppc7450", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_7450),
("ppc970", CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_970),
("i486", CPU_TYPE_I386, CPU_SUBTYPE_486),
("i486SX", CPU_TYPE_I386, CPU_SUBTYPE_486SX),
("i586", CPU_TYPE_I386, CPU_SUBTYPE_586),
("i686", CPU_TYPE_I386, CPU_SUBTYPE_PENTPRO),
("pentIIm3", CPU_TYPE_I386, CPU_SUBTYPE_PENTII_M3),
("pentIIm5", CPU_TYPE_I386, CPU_SUBTYPE_PENTII_M5),
("pentium4", CPU_TYPE_I386, CPU_SUBTYPE_PENTIUM_4),
("m68030", CPU_TYPE_MC680X0, CPU_SUBTYPE_MC68030_ONLY),
("m68040", CPU_TYPE_MC680X0, CPU_SUBTYPE_MC68040),
("hppa7100LC", CPU_TYPE_HPPA, CPU_SUBTYPE_HPPA_7100LC),
("armv4t", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V4T),
("armv5", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V5TEJ),
("xscale", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_XSCALE),
("armv6", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V6),
("armv6m", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V6M),
("armv7", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7),
("armv7f", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7F),
("armv7s", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7S),
("armv7k", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7K),
("armv7m", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7M),
("armv7em", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7EM),
("arm64v8", CPU_TYPE_ARM64, CPU_SUBTYPE_ARM64_V8),
("arm64e", CPU_TYPE_ARM64, CPU_SUBTYPE_ARM64_E),
("arm64_32_v8", CPU_TYPE_ARM64_32, CPU_SUBTYPE_ARM64_32_V8),
}
}
#[cfg(test)]
mod tests {
#[test]
fn test_basic_mapping() {
use super::cputype::*;
assert_eq!(
get_arch_from_flag("armv7"),
Some((CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7))
);
assert_eq!(
get_arch_name_from_types(CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7),
Some("armv7")
);
assert_eq!(
get_arch_from_flag("i386"),
Some((CPU_TYPE_I386, CPU_SUBTYPE_I386_ALL))
);
assert_eq!(
get_arch_from_flag("x86"),
Some((CPU_TYPE_I386, CPU_SUBTYPE_I386_ALL))
);
}
}