mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Add printing the LC_ENCRYPTION_INFO_64 load command with llvm-objdump’s -private-headers
and add tests for the two AArch64 binaries. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224400 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7c3af9120c
commit
e479df2161
@ -366,6 +366,8 @@ public:
|
||||
getEntryPointCommand(const LoadCommandInfo &L) const;
|
||||
MachO::encryption_info_command
|
||||
getEncryptionInfoCommand(const LoadCommandInfo &L) const;
|
||||
MachO::encryption_info_command_64
|
||||
getEncryptionInfoCommand64(const LoadCommandInfo &L) const;
|
||||
|
||||
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const;
|
||||
MachO::data_in_code_entry getDice(DataRefImpl Rel) const;
|
||||
|
@ -130,7 +130,7 @@ namespace llvm {
|
||||
LC_DATA_IN_CODE = 0x00000029u,
|
||||
LC_SOURCE_VERSION = 0x0000002Au,
|
||||
LC_DYLIB_CODE_SIGN_DRS = 0x0000002Bu,
|
||||
// 0x0000002Cu,
|
||||
LC_ENCRYPTION_INFO_64 = 0x0000002Cu,
|
||||
LC_LINKER_OPTIONS = 0x0000002Du,
|
||||
LC_LINKER_OPTIMIZATION_HINT = 0x0000002Eu
|
||||
};
|
||||
@ -842,6 +842,15 @@ namespace llvm {
|
||||
uint32_t cryptid;
|
||||
};
|
||||
|
||||
struct encryption_info_command_64 {
|
||||
uint32_t cmd;
|
||||
uint32_t cmdsize;
|
||||
uint32_t cryptoff;
|
||||
uint32_t cryptsize;
|
||||
uint32_t cryptid;
|
||||
uint32_t pad;
|
||||
};
|
||||
|
||||
struct version_min_command {
|
||||
uint32_t cmd; // LC_VERSION_MIN_MACOSX or
|
||||
// LC_VERSION_MIN_IPHONEOS
|
||||
@ -1136,6 +1145,15 @@ namespace llvm {
|
||||
sys::swapByteOrder(e.cryptid);
|
||||
}
|
||||
|
||||
inline void swapStruct(encryption_info_command_64 &e) {
|
||||
sys::swapByteOrder(e.cmd);
|
||||
sys::swapByteOrder(e.cmdsize);
|
||||
sys::swapByteOrder(e.cryptoff);
|
||||
sys::swapByteOrder(e.cryptsize);
|
||||
sys::swapByteOrder(e.cryptid);
|
||||
sys::swapByteOrder(e.pad);
|
||||
}
|
||||
|
||||
inline void swapStruct(dysymtab_command &dst) {
|
||||
sys::swapByteOrder(dst.cmd);
|
||||
sys::swapByteOrder(dst.cmdsize);
|
||||
|
@ -2304,6 +2304,11 @@ MachOObjectFile::getEncryptionInfoCommand(const LoadCommandInfo &L) const {
|
||||
return getStruct<MachO::encryption_info_command>(this, L.Ptr);
|
||||
}
|
||||
|
||||
MachO::encryption_info_command_64
|
||||
MachOObjectFile::getEncryptionInfoCommand64(const LoadCommandInfo &L) const {
|
||||
return getStruct<MachO::encryption_info_command_64>(this, L.Ptr);
|
||||
}
|
||||
|
||||
|
||||
MachO::any_relocation_info
|
||||
MachOObjectFile::getRelocation(DataRefImpl Rel) const {
|
||||
|
312
test/tools/llvm-objdump/AArch64/macho-private-headers.test
Normal file
312
test/tools/llvm-objdump/AArch64/macho-private-headers.test
Normal file
@ -0,0 +1,312 @@
|
||||
// RUN: llvm-objdump -p %p/Inputs/hello.obj.macho-aarch64 | FileCheck %s
|
||||
// RUN: llvm-objdump -p %p/Inputs/hello.exe.macho-aarch64 \
|
||||
// RUN: | FileCheck %s -check-prefix=EXE
|
||||
|
||||
CHECK: Mach header
|
||||
CHECK: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
|
||||
CHECK: MH_MAGIC_64 ARM64 ALL 0x00 OBJECT 4 352 SUBSECTIONS_VIA_SYMBOLS
|
||||
CHECK: Load command 0
|
||||
CHECK: cmd LC_SEGMENT_64
|
||||
CHECK: cmdsize 232
|
||||
CHECK: segname
|
||||
CHECK: vmaddr 0x0000000000000000
|
||||
CHECK: vmsize 0x000000000000004d
|
||||
CHECK: fileoff 384
|
||||
CHECK: filesize 77
|
||||
CHECK: maxprot rwx
|
||||
CHECK: initprot rwx
|
||||
CHECK: nsects 2
|
||||
CHECK: flags (none)
|
||||
CHECK: Section
|
||||
CHECK: sectname __text
|
||||
CHECK: segname __TEXT
|
||||
CHECK: addr 0x0000000000000000
|
||||
CHECK: size 0x0000000000000040
|
||||
CHECK: offset 384
|
||||
CHECK: align 2^2 (4)
|
||||
CHECK: reloff 464
|
||||
CHECK: nreloc 3
|
||||
CHECK: type S_REGULAR
|
||||
CHECK: attributes PURE_INSTRUCTIONS SOME_INSTRUCTIONS
|
||||
CHECK: reserved1 0
|
||||
CHECK: reserved2 0
|
||||
CHECK: Section
|
||||
CHECK: sectname __cstring
|
||||
CHECK: segname __TEXT
|
||||
CHECK: addr 0x0000000000000040
|
||||
CHECK: size 0x000000000000000d
|
||||
CHECK: offset 448
|
||||
CHECK: align 2^0 (1)
|
||||
CHECK: reloff 0
|
||||
CHECK: nreloc 0
|
||||
CHECK: type S_CSTRING_LITERALS
|
||||
CHECK: attributes (none)
|
||||
CHECK: reserved1 0
|
||||
CHECK: reserved2 0
|
||||
CHECK: Load command 1
|
||||
CHECK: cmd LC_VERSION_MIN_IPHONEOS
|
||||
CHECK: cmdsize 16
|
||||
CHECK: version 9.0
|
||||
CHECK: sdk n/a
|
||||
CHECK: Load command 2
|
||||
CHECK: cmd LC_SYMTAB
|
||||
CHECK: cmdsize 24
|
||||
CHECK: symoff 488
|
||||
CHECK: nsyms 5
|
||||
CHECK: stroff 568
|
||||
CHECK: strsize 36
|
||||
CHECK: Load command 3
|
||||
CHECK: cmd LC_DYSYMTAB
|
||||
CHECK: cmdsize 80
|
||||
CHECK: ilocalsym 0
|
||||
CHECK: nlocalsym 3
|
||||
CHECK: iextdefsym 3
|
||||
CHECK: nextdefsym 1
|
||||
CHECK: iundefsym 4
|
||||
CHECK: nundefsym 1
|
||||
CHECK: tocoff 0
|
||||
CHECK: ntoc 0
|
||||
CHECK: modtaboff 0
|
||||
CHECK: nmodtab 0
|
||||
CHECK: extrefsymoff 0
|
||||
CHECK: nextrefsyms 0
|
||||
CHECK: indirectsymoff 0
|
||||
CHECK: nindirectsyms 0
|
||||
CHECK: extreloff 0
|
||||
CHECK: nextrel 0
|
||||
CHECK: locreloff 0
|
||||
CHECK: nlocrel 0
|
||||
|
||||
EXE: Mach header
|
||||
EXE: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
|
||||
EXE: MH_MAGIC_64 ARM64 ALL 0x00 EXECUTE 17 1240 NOUNDEFS DYLDLINK TWOLEVEL PIE
|
||||
EXE: Load command 0
|
||||
EXE: cmd LC_SEGMENT_64
|
||||
EXE: cmdsize 72
|
||||
EXE: segname __PAGEZERO
|
||||
EXE: vmaddr 0x0000000000000000
|
||||
EXE: vmsize 0x0000000100000000
|
||||
EXE: fileoff 0
|
||||
EXE: filesize 0
|
||||
EXE: maxprot ---
|
||||
EXE: initprot ---
|
||||
EXE: nsects 0
|
||||
EXE: flags (none)
|
||||
EXE: Load command 1
|
||||
EXE: cmd LC_SEGMENT_64
|
||||
EXE: cmdsize 472
|
||||
EXE: segname __TEXT
|
||||
EXE: vmaddr 0x0000000100000000
|
||||
EXE: vmsize 0x0000000000008000
|
||||
EXE: fileoff 0
|
||||
EXE: filesize 32768
|
||||
EXE: maxprot r-x
|
||||
EXE: initprot r-x
|
||||
EXE: nsects 5
|
||||
EXE: flags (none)
|
||||
EXE: Section
|
||||
EXE: sectname __text
|
||||
EXE: segname __TEXT
|
||||
EXE: addr 0x0000000100007f38
|
||||
EXE: size 0x0000000000000040
|
||||
EXE: offset 32568
|
||||
EXE: align 2^2 (4)
|
||||
EXE: reloff 0
|
||||
EXE: nreloc 0
|
||||
EXE: type S_REGULAR
|
||||
EXE: attributes PURE_INSTRUCTIONS SOME_INSTRUCTIONS
|
||||
EXE: reserved1 0
|
||||
EXE: reserved2 0
|
||||
EXE: Section
|
||||
EXE: sectname __stubs
|
||||
EXE: segname __TEXT
|
||||
EXE: addr 0x0000000100007f78
|
||||
EXE: size 0x000000000000000c
|
||||
EXE: offset 32632
|
||||
EXE: align 2^1 (2)
|
||||
EXE: reloff 0
|
||||
EXE: nreloc 0
|
||||
EXE: type S_SYMBOL_STUBS
|
||||
EXE: attributes PURE_INSTRUCTIONS SOME_INSTRUCTIONS
|
||||
EXE: reserved1 0 (index into indirect symbol table)
|
||||
EXE: reserved2 12 (size of stubs)
|
||||
EXE: Section
|
||||
EXE: sectname __stub_helper
|
||||
EXE: segname __TEXT
|
||||
EXE: addr 0x0000000100007f84
|
||||
EXE: size 0x0000000000000024
|
||||
EXE: offset 32644
|
||||
EXE: align 2^2 (4)
|
||||
EXE: reloff 0
|
||||
EXE: nreloc 0
|
||||
EXE: type S_REGULAR
|
||||
EXE: attributes PURE_INSTRUCTIONS SOME_INSTRUCTIONS
|
||||
EXE: reserved1 0
|
||||
EXE: reserved2 0
|
||||
EXE: Section
|
||||
EXE: sectname __cstring
|
||||
EXE: segname __TEXT
|
||||
EXE: addr 0x0000000100007fa8
|
||||
EXE: size 0x000000000000000d
|
||||
EXE: offset 32680
|
||||
EXE: align 2^0 (1)
|
||||
EXE: reloff 0
|
||||
EXE: nreloc 0
|
||||
EXE: type S_CSTRING_LITERALS
|
||||
EXE: attributes (none)
|
||||
EXE: reserved1 0
|
||||
EXE: reserved2 0
|
||||
EXE: Section
|
||||
EXE: sectname __unwind_info
|
||||
EXE: segname __TEXT
|
||||
EXE: addr 0x0000000100007fb8
|
||||
EXE: size 0x0000000000000048
|
||||
EXE: offset 32696
|
||||
EXE: align 2^2 (4)
|
||||
EXE: reloff 0
|
||||
EXE: nreloc 0
|
||||
EXE: type S_REGULAR
|
||||
EXE: attributes (none)
|
||||
EXE: reserved1 0
|
||||
EXE: reserved2 0
|
||||
EXE: Load command 2
|
||||
EXE: cmd LC_SEGMENT_64
|
||||
EXE: cmdsize 232
|
||||
EXE: segname __DATA
|
||||
EXE: vmaddr 0x0000000100008000
|
||||
EXE: vmsize 0x0000000000004000
|
||||
EXE: fileoff 32768
|
||||
EXE: filesize 16384
|
||||
EXE: maxprot rw-
|
||||
EXE: initprot rw-
|
||||
EXE: nsects 2
|
||||
EXE: flags (none)
|
||||
EXE: Section
|
||||
EXE: sectname __got
|
||||
EXE: segname __DATA
|
||||
EXE: addr 0x0000000100008000
|
||||
EXE: size 0x0000000000000010
|
||||
EXE: offset 32768
|
||||
EXE: align 2^3 (8)
|
||||
EXE: reloff 0
|
||||
EXE: nreloc 0
|
||||
EXE: type S_NON_LAZY_SYMBOL_POINTERS
|
||||
EXE: attributes (none)
|
||||
EXE: reserved1 1 (index into indirect symbol table)
|
||||
EXE: reserved2 0
|
||||
EXE: Section
|
||||
EXE: sectname __la_symbol_ptr
|
||||
EXE: segname __DATA
|
||||
EXE: addr 0x0000000100008010
|
||||
EXE: size 0x0000000000000008
|
||||
EXE: offset 32784
|
||||
EXE: align 2^3 (8)
|
||||
EXE: reloff 0
|
||||
EXE: nreloc 0
|
||||
EXE: type S_LAZY_SYMBOL_POINTERS
|
||||
EXE: attributes (none)
|
||||
EXE: reserved1 3 (index into indirect symbol table)
|
||||
EXE: reserved2 0
|
||||
EXE: Load command 3
|
||||
EXE: cmd LC_SEGMENT_64
|
||||
EXE: cmdsize 72
|
||||
EXE: segname __LINKEDIT
|
||||
EXE: vmaddr 0x000000010000c000
|
||||
EXE: vmsize 0x0000000000004000
|
||||
EXE: fileoff 49152
|
||||
EXE: filesize 264
|
||||
EXE: maxprot r--
|
||||
EXE: initprot r--
|
||||
EXE: nsects 0
|
||||
EXE: flags (none)
|
||||
EXE: Load command 4
|
||||
EXE: cmd LC_DYLD_INFO_ONLY
|
||||
EXE: cmdsize 48
|
||||
EXE: rebase_off 49152
|
||||
EXE: rebase_size 8
|
||||
EXE: bind_off 49160
|
||||
EXE: bind_size 24
|
||||
EXE: weak_bind_off 0
|
||||
EXE: weak_bind_size 0
|
||||
EXE: lazy_bind_off 49184
|
||||
EXE: lazy_bind_size 16
|
||||
EXE: export_off 49200
|
||||
EXE: export_size 48
|
||||
EXE: Load command 5
|
||||
EXE: cmd LC_SYMTAB
|
||||
EXE: cmdsize 24
|
||||
EXE: symoff 49280
|
||||
EXE: nsyms 4
|
||||
EXE: stroff 49360
|
||||
EXE: strsize 56
|
||||
EXE: Load command 6
|
||||
EXE: cmd LC_DYSYMTAB
|
||||
EXE: cmdsize 80
|
||||
EXE: ilocalsym 0
|
||||
EXE: nlocalsym 0
|
||||
EXE: iextdefsym 0
|
||||
EXE: nextdefsym 2
|
||||
EXE: iundefsym 2
|
||||
EXE: nundefsym 2
|
||||
EXE: tocoff 0
|
||||
EXE: ntoc 0
|
||||
EXE: modtaboff 0
|
||||
EXE: nmodtab 0
|
||||
EXE: extrefsymoff 0
|
||||
EXE: nextrefsyms 0
|
||||
EXE: indirectsymoff 49344
|
||||
EXE: nindirectsyms 4
|
||||
EXE: extreloff 0
|
||||
EXE: nextrel 0
|
||||
EXE: locreloff 0
|
||||
EXE: nlocrel 0
|
||||
EXE: Load command 7
|
||||
EXE: cmd LC_LOAD_DYLINKER
|
||||
EXE: cmdsize 32
|
||||
EXE: name /usr/lib/dyld (offset 12)
|
||||
EXE: Load command 8
|
||||
EXE: cmd LC_UUID
|
||||
EXE: cmdsize 24
|
||||
EXE: uuid D687F888-CD3F-3276-8C94-BA3CCA21D820
|
||||
EXE: Load command 9
|
||||
EXE: cmd LC_VERSION_MIN_IPHONEOS
|
||||
EXE: cmdsize 16
|
||||
EXE: version 9.0
|
||||
EXE: sdk 9.0
|
||||
EXE: Load command 10
|
||||
EXE: cmd LC_SOURCE_VERSION
|
||||
EXE: cmdsize 16
|
||||
EXE: version 0.0
|
||||
EXE: Load command 11
|
||||
EXE: cmd LC_MAIN
|
||||
EXE: cmdsize 24
|
||||
EXE: entryoff 32568
|
||||
EXE: stacksize 0
|
||||
EXE: Load command 12
|
||||
EXE: cmd LC_ENCRYPTION_INFO_64
|
||||
EXE: cmdsize 24
|
||||
EXE: cryptoff 16384
|
||||
EXE: cryptsize 16384
|
||||
EXE: cryptid 0
|
||||
EXE: pad 0
|
||||
EXE: Load command 13
|
||||
EXE: cmd LC_LOAD_DYLIB
|
||||
EXE: cmdsize 56
|
||||
EXE: name /usr/lib/libSystem.B.dylib (offset 24)
|
||||
EXE: current version 1215.0.0
|
||||
EXE: compatibility version 1.0.0
|
||||
EXE: Load command 14
|
||||
EXE: cmd LC_FUNCTION_STARTS
|
||||
EXE: cmdsize 16
|
||||
EXE: dataoff 49248
|
||||
EXE: datasize 8
|
||||
EXE: Load command 15
|
||||
EXE: cmd LC_DATA_IN_CODE
|
||||
EXE: cmdsize 16
|
||||
EXE: dataoff 49256
|
||||
EXE: datasize 0
|
||||
EXE: Load command 16
|
||||
EXE: cmd LC_DYLIB_CODE_SIGN_DRS
|
||||
EXE: cmdsize 16
|
||||
EXE: dataoff 49256
|
||||
EXE: datasize 24
|
@ -3558,7 +3558,7 @@ static void PrintVersionMinLoadCommand(MachO::version_min_command vd) {
|
||||
outs() << "." << (vd.version & 0xff);
|
||||
outs() << "\n";
|
||||
if (vd.sdk == 0)
|
||||
outs() << " sdk n/a\n";
|
||||
outs() << " sdk n/a";
|
||||
else {
|
||||
outs() << " sdk " << ((vd.sdk >> 16) & 0xffff) << "."
|
||||
<< ((vd.sdk >> 8) & 0xff);
|
||||
@ -3622,6 +3622,28 @@ static void PrintEncryptionInfoCommand(MachO::encryption_info_command ec,
|
||||
outs() << " cryptid " << ec.cryptid << "\n";
|
||||
}
|
||||
|
||||
static void PrintEncryptionInfoCommand64(MachO::encryption_info_command_64 ec,
|
||||
uint32_t object_size) {
|
||||
outs() << " cmd LC_ENCRYPTION_INFO_64\n";
|
||||
outs() << " cmdsize " << ec.cmdsize;
|
||||
if (ec.cmdsize != sizeof(struct MachO::encryption_info_command_64))
|
||||
outs() << " Incorrect size\n";
|
||||
else
|
||||
outs() << "\n";
|
||||
outs() << " cryptoff " << ec.cryptoff;
|
||||
if (ec.cryptoff > object_size)
|
||||
outs() << " (past end of file)\n";
|
||||
else
|
||||
outs() << "\n";
|
||||
outs() << " cryptsize " << ec.cryptsize;
|
||||
if (ec.cryptsize > object_size)
|
||||
outs() << " (past end of file)\n";
|
||||
else
|
||||
outs() << "\n";
|
||||
outs() << " cryptid " << ec.cryptid << "\n";
|
||||
outs() << " pad " << ec.pad << "\n";
|
||||
}
|
||||
|
||||
static void PrintDylibCommand(MachO::dylib_command dl, const char *Ptr) {
|
||||
if (dl.cmd == MachO::LC_ID_DYLIB)
|
||||
outs() << " cmd LC_ID_DYLIB\n";
|
||||
@ -3772,6 +3794,9 @@ static void PrintLoadCommands(const MachOObjectFile *Obj, uint32_t ncmds,
|
||||
} else if (Command.C.cmd == MachO::LC_ENCRYPTION_INFO) {
|
||||
MachO::encryption_info_command Ei = Obj->getEncryptionInfoCommand(Command);
|
||||
PrintEncryptionInfoCommand(Ei, Buf.size());
|
||||
} else if (Command.C.cmd == MachO::LC_ENCRYPTION_INFO_64) {
|
||||
MachO::encryption_info_command_64 Ei = Obj->getEncryptionInfoCommand64(Command);
|
||||
PrintEncryptionInfoCommand64(Ei, Buf.size());
|
||||
} else if (Command.C.cmd == MachO::LC_LOAD_DYLIB ||
|
||||
Command.C.cmd == MachO::LC_ID_DYLIB ||
|
||||
Command.C.cmd == MachO::LC_LOAD_WEAK_DYLIB ||
|
||||
|
Loading…
Reference in New Issue
Block a user