forked from OSchip/llvm-project
[llvm-readobj] MachO -- dump LinkerOptions load command.
Example output: Linker Options { Size: 32 Count: 2 Strings [ Value: -framework Value: Cocoa ] } There were only two tests using this -- so I converted them as part of this commit rather than separately. Differential Revision: http://reviews.llvm.org/D12702 llvm-svn: 247106
This commit is contained in:
parent
ee381ffba4
commit
9a429b766f
|
@ -1,25 +1,18 @@
|
||||||
// RUN: llvm-mc -n -triple x86_64-apple-darwin10 %s -filetype=obj | macho-dump | FileCheck %s
|
// RUN: llvm-mc -n -triple x86_64-apple-darwin10 %s -filetype=obj | llvm-readobj -macho-linker-options | FileCheck %s
|
||||||
|
|
||||||
// CHECK: ('load_commands_size', 120)
|
|
||||||
// CHECK: ('load_commands', [
|
|
||||||
// CHECK: # Load Command 2
|
|
||||||
// CHECK: (('command', 45)
|
|
||||||
// CHECK: ('size', 16)
|
|
||||||
// CHECK: ('count', 1)
|
|
||||||
// CHECK: ('_strings', [
|
|
||||||
// CHECK: "a",
|
|
||||||
// CHECK: ])
|
|
||||||
// CHECK: ),
|
|
||||||
// CHECK: # Load Command 3
|
|
||||||
// CHECK: (('command', 45)
|
|
||||||
// CHECK: ('size', 16)
|
|
||||||
// CHECK: ('count', 2)
|
|
||||||
// CHECK: ('_strings', [
|
|
||||||
// CHECK: "a",
|
|
||||||
// CHECK: "b",
|
|
||||||
// CHECK: ])
|
|
||||||
// CHECK: ),
|
|
||||||
// CHECK: ])
|
|
||||||
|
|
||||||
.linker_option "a"
|
.linker_option "a"
|
||||||
.linker_option "a", "b"
|
.linker_option "a", "b"
|
||||||
|
|
||||||
|
// CHECK: Linker Options {
|
||||||
|
// CHECK: Size: 16
|
||||||
|
// CHECK: Strings [
|
||||||
|
// CHECK: Value: a
|
||||||
|
// CHECK: ]
|
||||||
|
// CHECK: }
|
||||||
|
// CHECK: Linker Options {
|
||||||
|
// CHECK: Size: 16
|
||||||
|
// CHECK: Strings [
|
||||||
|
// CHECK: Value: a
|
||||||
|
// CHECK: Value: b
|
||||||
|
// CHECK: ]
|
||||||
|
// CHECK: }
|
||||||
|
|
|
@ -4,35 +4,28 @@
|
||||||
; CHECK-ASM: .linker_option "-lz"
|
; CHECK-ASM: .linker_option "-lz"
|
||||||
; CHECK-ASM-NEXT: .linker_option "-framework", "Cocoa"
|
; CHECK-ASM-NEXT: .linker_option "-framework", "Cocoa"
|
||||||
|
|
||||||
; RUN: llc -O0 -mtriple=x86_64-apple-darwin -filetype=obj -o - %s | macho-dump > %t
|
; RUN: llc -O0 -mtriple=x86_64-apple-darwin -filetype=obj -o - %s | llvm-readobj -macho-linker-options > %t
|
||||||
; RUN: FileCheck --check-prefix=CHECK-OBJ < %t %s
|
; RUN: FileCheck --check-prefix=CHECK-OBJ < %t %s
|
||||||
|
|
||||||
; CHECK-OBJ: ('load_commands', [
|
; CHECK-OBJ: Linker Options {
|
||||||
; CHECK-OBJ: # Load Command 1
|
; CHECK-OBJ: Size: 16
|
||||||
; CHECK-OBJ: (('command', 45)
|
; CHECK-OBJ: Strings [
|
||||||
; CHECK-OBJ: ('size', 16)
|
; CHECK-OBJ: Value: -lz
|
||||||
; CHECK-OBJ: ('count', 1)
|
; CHECK-OBJ: ]
|
||||||
; CHECK-OBJ: ('_strings', [
|
; CHECK-OBJ: }
|
||||||
; CHECK-OBJ: "-lz",
|
; CHECK-OBJ: Linker Options {
|
||||||
; CHECK-OBJ: ])
|
; CHECK-OBJ: Size: 32
|
||||||
; CHECK-OBJ: ),
|
; CHECK-OBJ: Strings [
|
||||||
; CHECK-OBJ: # Load Command 2
|
; CHECK-OBJ: Value: -framework
|
||||||
; CHECK-OBJ: (('command', 45)
|
; CHECK-OBJ: Value: Cocoa
|
||||||
; CHECK-OBJ: ('size', 32)
|
; CHECK-OBJ: ]
|
||||||
; CHECK-OBJ: ('count', 2)
|
; CHECK-OBJ: }
|
||||||
; CHECK-OBJ: ('_strings', [
|
; CHECK-OBJ: Linker Options {
|
||||||
; CHECK-OBJ: "-framework",
|
; CHECK-OBJ: Size: 24
|
||||||
; CHECK-OBJ: "Cocoa",
|
; CHECK-OBJ: Strings [
|
||||||
; CHECK-OBJ: ])
|
; CHECK-OBJ: Value: -lmath
|
||||||
; CHECK-OBJ: # Load Command 3
|
; CHECK-OBJ: ]
|
||||||
; CHECK-OBJ: (('command', 45)
|
; CHECK-OBJ: }
|
||||||
; CHECK-OBJ: ('size', 24)
|
|
||||||
; CHECK-OBJ: ('count', 1)
|
|
||||||
; CHECK-OBJ: ('_strings', [
|
|
||||||
; CHECK-OBJ: "-lmath",
|
|
||||||
; CHECK-OBJ: ])
|
|
||||||
; CHECK-OBJ: ),
|
|
||||||
; CHECK-OBJ: ])
|
|
||||||
|
|
||||||
!0 = !{i32 6, !"Linker Options", !{!{!"-lz"}, !{!"-framework", !"Cocoa"}, !{!"-lmath"}}}
|
!0 = !{i32 6, !"Linker Options", !{!{!"-lz"}, !{!"-framework", !"Cocoa"}, !{!"-lmath"}}}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
void printMachODysymtab() override;
|
void printMachODysymtab() override;
|
||||||
void printMachOSegment() override;
|
void printMachOSegment() override;
|
||||||
void printMachOIndirectSymbols() override;
|
void printMachOIndirectSymbols() override;
|
||||||
|
void printMachOLinkerOptions () override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<class MachHeader>
|
template<class MachHeader>
|
||||||
|
@ -791,3 +792,22 @@ void MachODumper::printMachOIndirectSymbols() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MachODumper::printMachOLinkerOptions() {
|
||||||
|
for (const auto &Load : Obj->load_commands()) {
|
||||||
|
if (Load.C.cmd == MachO::LC_LINKER_OPTION) {
|
||||||
|
MachO::linker_option_command LOLC = Obj->getLinkerOptionLoadCommand(Load);
|
||||||
|
DictScope Group(W, "Linker Options");
|
||||||
|
W.printNumber("Size", LOLC.cmdsize);
|
||||||
|
ListScope D(W, "Strings");
|
||||||
|
uint64_t DataSize = LOLC.cmdsize - sizeof(MachO::linker_option_command);
|
||||||
|
const char *P = Load.Ptr + sizeof(MachO::linker_option_command);
|
||||||
|
StringRef Data(P, DataSize);
|
||||||
|
for (unsigned i = 0; i < LOLC.count; ++i) {
|
||||||
|
std::pair<StringRef,StringRef> Split = Data.split('\0');
|
||||||
|
W.printString("Value", Split.first);
|
||||||
|
Data = Split.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ public:
|
||||||
virtual void printMachODysymtab() { }
|
virtual void printMachODysymtab() { }
|
||||||
virtual void printMachOSegment() { }
|
virtual void printMachOSegment() { }
|
||||||
virtual void printMachOIndirectSymbols() { }
|
virtual void printMachOIndirectSymbols() { }
|
||||||
|
virtual void printMachOLinkerOptions() { }
|
||||||
|
|
||||||
virtual void printStackMap() const = 0;
|
virtual void printStackMap() const = 0;
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,11 @@ namespace opts {
|
||||||
MachOIndirectSymbols("macho-indirect-symbols",
|
MachOIndirectSymbols("macho-indirect-symbols",
|
||||||
cl::desc("Display MachO indirect symbols"));
|
cl::desc("Display MachO indirect symbols"));
|
||||||
|
|
||||||
|
// -macho-linker-options
|
||||||
|
cl::opt<bool>
|
||||||
|
MachOLinkerOptions("macho-linker-options",
|
||||||
|
cl::desc("Display MachO linker options"));
|
||||||
|
|
||||||
// -macho-segment
|
// -macho-segment
|
||||||
cl::opt<bool>
|
cl::opt<bool>
|
||||||
MachOSegment("macho-segment",
|
MachOSegment("macho-segment",
|
||||||
|
@ -343,6 +348,8 @@ static void dumpObject(const ObjectFile *Obj) {
|
||||||
Dumper->printMachODataInCode();
|
Dumper->printMachODataInCode();
|
||||||
if (opts::MachOIndirectSymbols)
|
if (opts::MachOIndirectSymbols)
|
||||||
Dumper->printMachOIndirectSymbols();
|
Dumper->printMachOIndirectSymbols();
|
||||||
|
if (opts::MachOLinkerOptions)
|
||||||
|
Dumper->printMachOLinkerOptions();
|
||||||
if (opts::MachOSegment)
|
if (opts::MachOSegment)
|
||||||
Dumper->printMachOSegment();
|
Dumper->printMachOSegment();
|
||||||
if (opts::MachOVersionMin)
|
if (opts::MachOVersionMin)
|
||||||
|
|
Loading…
Reference in New Issue