|
| 1 | +@enum METALLIB_TARGET::UInt16 begin |
| 2 | + METALLIB_TARGET_MACOS = 0x8001 |
| 3 | + METALLIB_TARGET_IOS = 0x0001 |
| 4 | +end |
| 5 | + |
| 6 | +@enum METALLIB_FILETYPE::UInt8 begin |
| 7 | + METALLIB_FILETYPE_EXECUTABLE = 0x00 |
| 8 | + METALLIB_FILETYPE_COREIMAGE = 0x01 |
| 9 | + METALLIB_FILETYPE_DYNAMIC = 0x02 |
| 10 | + METALLIB_FILETYPE_SYMBOLCOMPANION = 0x03 |
| 11 | +end |
| 12 | + |
| 13 | +@enum METALLIB_TARGET_OS::UInt8 begin |
| 14 | + METALLIB_TARGET_OS_UNKNOWN = 0x00 |
| 15 | + METALLIB_TARGET_OS_MACOS = 0x81 |
| 16 | + METALLIB_TARGET_OS_IOS = 0x82 |
| 17 | + METALLIB_TARGET_OS_TVOS = 0x83 |
| 18 | + METALLIB_TARGET_OS_WATCHOS = 0x84 |
| 19 | + METALLIB_TARGET_OS_BRIDGEOS = 0x85 |
| 20 | + METALLIB_TARGET_OS_MACCATALYST = 0x86 |
| 21 | + METALLIB_TARGET_OS_IOS_SIMULATOR = 0x87 |
| 22 | + METALLIB_TARGET_OS_TVOS_SIMULATOR = 0x88 |
| 23 | + METALLIB_TARGET_OS_WATCHOS_SIMULATOR = 0x89 |
| 24 | +end |
| 25 | + |
| 26 | +@io struct MetallibHeader{H <: ObjectHandle} <: MachOHeader{H} |
| 27 | + magic::UInt32 |
| 28 | + target::METALLIB_TARGET |
| 29 | + ver_major::UInt16 |
| 30 | + ver_minor::UInt16 |
| 31 | + filetype::METALLIB_FILETYPE |
| 32 | + target_os::METALLIB_TARGET_OS |
| 33 | + os_major::UInt16 |
| 34 | + os_minor::UInt16 |
| 35 | + size::UInt64 |
| 36 | + funclist_offset::UInt64 |
| 37 | + funclist_size::UInt64 |
| 38 | + public_md_offset::UInt64 |
| 39 | + public_md_size::UInt64 |
| 40 | + private_md_offset::UInt64 |
| 41 | + private_md_size::UInt64 |
| 42 | + bitcode_offset::UInt64 |
| 43 | + bitcode_size::UInt64 |
| 44 | +end |
| 45 | + |
| 46 | +function show(io::IO, header::MetallibHeader) |
| 47 | + println(io, "Metallib Header") |
| 48 | + println(io, " Target ", header.target) |
| 49 | + println(io, " Version ", header.ver_major, ".", header.ver_minor) |
| 50 | + println(io, " File Type ", header.filetype) |
| 51 | + println(io, " Target OS ", header.target_os) |
| 52 | + println(io, " OS Version ", header.os_major, ".", header.os_minor) |
| 53 | + println(io, " Size ", Base.format_bytes(header.size)) |
| 54 | + println(io, " Function List ", Base.format_bytes(header.funclist_size), " at 0x", string(header.funclist_offset; base=16)) |
| 55 | + println(io, " Public Metadata ", Base.format_bytes(header.public_md_size), " at 0x", string(header.public_md_offset; base=16)) |
| 56 | + println(io, " Private Metadata ", Base.format_bytes(header.private_md_size), " at 0x", string(header.private_md_offset; base=16)) |
| 57 | + println(io, " Bitcode ", Base.format_bytes(header.bitcode_size), " at 0x", string(header.bitcode_offset; base=16)) |
| 58 | +end |
0 commit comments