package owee

  1. Overview
  2. Docs
type magic =
  1. | MAGIC32
  2. | MAGIC64
  3. | CIGAM32
  4. | CIGAM64
val string_of_magic : magic -> string
type unknown = [
  1. | `Unknown of int
]
type cpu_type = [
  1. | `X86
  2. | `X86_64
  3. | `ARM
  4. | `POWERPC
  5. | `POWERPC64
  6. | unknown
]
type cpu_subtype = [
  1. | `Intel
  2. | `I386_ALL
  3. | `I386
  4. | `I486
  5. | `I486SX
  6. | `PENT
  7. | `PENTPRO
  8. | `PENTII_M3
  9. | `PENTII_M5
  10. | `CELERON
  11. | `CELERON_MOBILE
  12. | `PENTIUM_3
  13. | `PENTIUM_3_M
  14. | `PENTIUM_3_XEON
  15. | `PENTIUM_M
  16. | `PENTIUM_4
  17. | `PENTIUM_4_M
  18. | `ITANIUM
  19. | `ITANIUM_2
  20. | `XEON
  21. | `XEON_MP
  22. | `INTEL_FAMILY
  23. | `INTEL_FAMILY_MAX
  24. | `INTEL_MODEL
  25. | `INTEL_MODEL_ALL
  26. | `X86_ALL
  27. | `X86_64_ALL
  28. | `X86_ARCH1
  29. | `POWERPC_ALL
  30. | `POWERPC_601
  31. | `POWERPC_602
  32. | `POWERPC_603
  33. | `POWERPC_603e
  34. | `POWERPC_603ev
  35. | `POWERPC_604
  36. | `POWERPC_604e
  37. | `POWERPC_620
  38. | `POWERPC_750
  39. | `POWERPC_7400
  40. | `POWERPC_7450
  41. | `POWERPC_970
  42. | `ARM_ALL
  43. | `ARM_V4T
  44. | `ARM_V6
  45. | unknown
]
type file_type = [
  1. | `OBJECT
  2. | `EXECUTE
  3. | `CORE
  4. | `PRELOAD
  5. | `DYLIB
  6. | `DYLINKER
  7. | `BUNDLE
  8. | `DYLIB_STUB
  9. | `DSYM
  10. | unknown
]
type header_flag = [
  1. | `NOUNDEFS
  2. | `BINDATLOAD
  3. | `PREBOUND
  4. | `SPLIT_SEGS
  5. | `TWOLEVEL
  6. | `FORCE_FLAT
  7. | `NOMULTIDEFS
  8. | `NOFIXPREBINDING
  9. | `PREBINDABLE
  10. | `ALLMODSBOUND
  11. | `SUBSECTIONS_VIA_SYMBOLS
  12. | `CANONICAL
  13. | `WEAK_DEFINES
  14. | `BINDS_TO_WEAK
  15. | `ALLOW_STACK_EXECUTION
  16. | `ROOT_SAFE
  17. | `SETUID_SAFE
  18. | `NO_REEXPORTED_DYLIBS
  19. | `PIE
]
type header = {
  1. magic : magic;
  2. cpu_type : cpu_type;
  3. cpu_subtype : cpu_subtype;
  4. file_type : file_type;
  5. flags : header_flag list;
}
type reloc_type = [
  1. | `GENERIC_RELOC_VANILLA
  2. | `GENERIC_RELOC_PAIR
  3. | `GENERIC_RELOC_SECTDIFF
  4. | `GENERIC_RELOC_LOCAL_SECTDIFF
  5. | `GENERIC_RELOC_PB_LA_PTR
  6. | `X86_64_RELOC_BRANCH
  7. | `X86_64_RELOC_GOT_LOAD
  8. | `X86_64_RELOC_GOT
  9. | `X86_64_RELOC_SIGNED
  10. | `X86_64_RELOC_UNSIGNED
  11. | `X86_64_RELOC_SUBTRACTOR
  12. | `X86_64_RELOC_SIGNED_1
  13. | `X86_64_RELOC_SIGNED_2
  14. | `X86_64_RELOC_SIGNED_4
  15. | `PPC_RELOC_VANILLA
  16. | `PPC_RELOC_PAIR
  17. | `PPC_RELOC_BR14
  18. | `PPC_RELOC_BR24
  19. | `PPC_RELOC_HI16
  20. | `PPC_RELOC_LO16
  21. | `PPC_RELOC_HA16
  22. | `PPC_RELOC_LO14
  23. | `PPC_RELOC_SECTDIFF
  24. | `PPC_RELOC_LOCAL_SECTDIFF
  25. | `PPC_RELOC_PB_LA_PTR
  26. | `PPC_RELOC_HI16_SECTDIFF
  27. | `PPC_RELOC_LO16_SECTDIFF
  28. | `PPC_RELOC_HA16_SECTDIFF
  29. | `PPC_RELOC_JBSR
  30. | `PPC_RELOC_LO14_SECTDIFF
  31. | unknown
]
type relocation_info = {
  1. ri_address : int;
  2. ri_symbolnum : Owee_buf.u32;
  3. ri_pcrel : bool;
  4. ri_length : Owee_buf.u32;
  5. ri_extern : bool;
  6. ri_type : reloc_type;
}
type scattered_relocation_info = {
  1. rs_pcrel : bool;
  2. rs_length : Owee_buf.u32;
  3. rs_type : reloc_type;
  4. rs_address : Owee_buf.u32;
  5. rs_value : Owee_buf.s32;
}
type relocation = [
  1. | `Relocation_info of relocation_info
  2. | `Scattered_relocation_info of scattered_relocation_info
]
type sec_type = [
  1. | `S_REGULAR
  2. | `S_ZEROFILL
  3. | `S_CSTRING_LITERALS
  4. | `S_4BYTE_LITERALS
  5. | `S_8BYTE_LITERALS
  6. | `S_LITERAL_POINTERS
  7. | `S_NON_LAZY_SYMBOL_POINTERS
  8. | `S_LAZY_SYMBOL_POINTERS
  9. | `S_SYMBOL_STUBS
  10. | `S_MOD_INIT_FUNC_POINTERS
  11. | `S_MOD_TERM_FUNC_POINTERS
  12. | `S_COALESCED
  13. | `S_GB_ZEROFILL
  14. | `S_INTERPOSING
  15. | `S_16BYTE_LITERALS
  16. | `S_DTRACE_DOF
  17. | `S_LAZY_DYLIB_SYMBOL_POINTERS
  18. | unknown
]
type sec_user_attr = [
  1. | `PURE_INSTRUCTIONS
  2. | `NO_TOC
  3. | `STRIP_STATIC_SYMS
  4. | `NO_DEAD_STRIP
  5. | `LIVE_SUPPORT
  6. | `SELF_MODIFYING_CODE
  7. | `DEBUG
]
type sec_sys_attr = [
  1. | `SOME_INSTRUCTIONS
  2. | `EXT_RELOC
  3. | `LOC_RELOC
]
type section = {
  1. sec_sectname : string;
  2. sec_segname : string;
  3. sec_addr : Owee_buf.u64;
  4. sec_size : Owee_buf.u64;
  5. sec_align : int;
  6. sec_relocs : relocation array;
  7. sec_type : sec_type;
  8. sec_user_attrs : sec_user_attr list;
  9. sec_sys_attrs : sec_sys_attr list;
}
type vm_prot = [
  1. | `READ
  2. | `WRITE
  3. | `EXECUTE
]
type seg_flag = [
  1. | `HIGHVM
  2. | `NORELOC
]
type segment = {
  1. seg_segname : string;
  2. seg_vmaddr : Owee_buf.u64;
  3. seg_vmsize : Owee_buf.u64;
  4. seg_fileoff : Owee_buf.u64;
  5. seg_filesize : Owee_buf.u64;
  6. seg_maxprot : vm_prot list;
  7. seg_initprot : vm_prot list;
  8. seg_flags : seg_flag list;
  9. seg_sections : section array;
}
type sym_type = [
  1. | `UNDF
  2. | `ABS
  3. | `SECT
  4. | `PBUD
  5. | `INDR
  6. | `GSYM
  7. | `FNAME
  8. | `FUN
  9. | `STSYM
  10. | `LCSYM
  11. | `BNSYM
  12. | `OPT
  13. | `RSYM
  14. | `SLINE
  15. | `ENSYM
  16. | `SSYM
  17. | `SO
  18. | `OSO
  19. | `LSYM
  20. | `BINCL
  21. | `SOL
  22. | `PARAMS
  23. | `VERSION
  24. | `OLEVEL
  25. | `PSYM
  26. | `EINCL
  27. | `ENTRY
  28. | `LBRAC
  29. | `EXCL
  30. | `RBRAC
  31. | `BCOMM
  32. | `ECOMM
  33. | `ECOML
  34. | `LENG
  35. | `PC
  36. | unknown
]
type reference_flag = [
  1. | `UNDEFINED_NON_LAZY
  2. | `UNDEFINED_LAZY
  3. | `DEFINED
  4. | `PRIVATE_DEFINED
  5. | `PRIVATE_UNDEFINED_NON_LAZY
  6. | `PRIVATE_UNDEFINED_LAZY
  7. | `REFERENCED_DYNAMICALLY
  8. | `SYM_WEAK_REF
  9. | `SYM_WEAK_DEF
  10. | `LIBRARY_ORDINAL of Owee_buf.u16
  11. | unknown
]
type symbol = {
  1. sym_name : string;
  2. sym_type : sym_type;
  3. sym_pext : bool;
  4. sym_ext : bool;
  5. sym_sect : Owee_buf.u8;
  6. sym_flags : [ `Uninterpreted of Owee_buf.u16 | `Flags of reference_flag list ];
  7. sym_value : Owee_buf.u64;
}
type dylib_module = {
  1. dylib_module_name_offset : Owee_buf.u32;
  2. dylib_ext_def_sym : Owee_buf.u32 * Owee_buf.u32;
  3. dylib_ref_sym : Owee_buf.u32 * Owee_buf.u32;
  4. dylib_local_sym : Owee_buf.u32 * Owee_buf.u32;
  5. dylib_ext_rel : Owee_buf.u32 * Owee_buf.u32;
  6. dylib_init : Owee_buf.u32 * Owee_buf.u32;
  7. dylib_term : Owee_buf.u32 * Owee_buf.u32;
  8. dylib_objc_module_info_addr : Owee_buf.u32;
  9. dylib_objc_module_info_size : Owee_buf.u64;
}
type toc_entry = {
  1. symbol_index : Owee_buf.u32;
  2. module_index : Owee_buf.u32;
}
type dynamic_symbol_table = {
  1. localSyms : Owee_buf.u32 * Owee_buf.u32;
  2. extDefSyms : Owee_buf.u32 * Owee_buf.u32;
  3. undefSyms : Owee_buf.u32 * Owee_buf.u32;
  4. toc_entries : toc_entry array;
  5. modules : dylib_module array;
  6. extRefSyms : Owee_buf.u32 array;
  7. indirectSyms : Owee_buf.u32 array;
  8. extRels : relocation array;
  9. locRels : relocation array;
}
type dylib = {
  1. dylib_name : string;
  2. dylib_timestamp : Owee_buf.u32;
  3. dylib_current_version : Owee_buf.u32;
  4. dylib_compatibility_version : Owee_buf.u32;
}
type command =
  1. | LC_SEGMENT_32 of segment lazy_t
  2. | LC_SYMTAB of (symbol array * Owee_buf.t) lazy_t
  3. | LC_THREAD of (Owee_buf.u32 * Owee_buf.u32 array) list lazy_t
  4. | LC_UNIXTHREAD of (Owee_buf.u32 * Owee_buf.u32 array) list lazy_t
  5. | LC_DYSYMTAB of dynamic_symbol_table lazy_t
  6. | LC_LOAD_DYLIB of dylib lazy_t
  7. | LC_ID_DYLIB of dylib lazy_t
  8. | LC_LOAD_DYLINKER of string
  9. | LC_ID_DYLINKER of string
  10. | LC_PREBOUND_DYLIB of (string * Owee_buf.u8 array) lazy_t
  11. | LC_ROUTINES_32 of Owee_buf.u32 * Owee_buf.u32
  12. | LC_SUB_FRAMEWORK of string
  13. | LC_SUB_UMBRELLA of string
  14. | LC_SUB_CLIENT of string
  15. | LC_SUB_LIBRARY of string
  16. | LC_TWOLEVEL_HINTS of (Owee_buf.u32 * Owee_buf.u32) array lazy_t
  17. | LC_PREBIND_CKSUM of Owee_buf.u32
  18. | LC_LOAD_WEAK_DYLIB of dylib lazy_t
  19. | LC_SEGMENT_64 of segment lazy_t
  20. | LC_ROUTINES_64 of Owee_buf.u64 * Owee_buf.u64
  21. | LC_UUID of string
  22. | LC_RPATH of string
  23. | LC_CODE_SIGNATURE of Owee_buf.u32 * Owee_buf.u32
  24. | LC_SEGMENT_SPLIT_INFO of Owee_buf.u32 * Owee_buf.u32
  25. | LC_UNHANDLED of int * Owee_buf.t
val read : Owee_buf.t -> header * command list
val section_body : Owee_buf.t -> segment -> section -> Owee_buf.t