diff options
author | Michael Trent <mtrent@apple.com> | 2019-01-15 20:41:30 +0000 |
---|---|---|
committer | Michael Trent <mtrent@apple.com> | 2019-01-15 20:41:30 +0000 |
commit | 7e6602110b89c066aabeb47445f17f557974eaef (patch) | |
tree | 795d5e5e1185b0dcb8f5ec410951b7d29f743bdb /llvm/tools | |
parent | d6a9bbf68e2c795d0d2d7f831235ed14af978f87 (diff) | |
download | bcm5719-llvm-7e6602110b89c066aabeb47445f17f557974eaef.tar.gz bcm5719-llvm-7e6602110b89c066aabeb47445f17f557974eaef.zip |
llvm-objdump -m -D should disassemble all text segments
Summary:
When running llvm-objdump with the -macho option objdump will by default
disassemble only the __TEXT,__text section (or __TEXT_EXEC,__text when
disassembling MH_KEXT_BUNDLE files). The -disassemble-all option is
treated no diferently than -disassemble.
This change upates llvm-objdump's MachO parsing code to disassemble all
__text sections found in a file when -disassemble-all is specified. This
is useful for disassembling files with more than one __text section, or
when disassembling files whose __text section is not present in __TEXT.
I added a lit test case that verifies "llvm-objdump -m -d" and
"llvm-objdump -m -D" produce the expected results on a reference binary.
I also updated the CommandGuide documentation for llvm-objdump.rst and
verified it renders correctly as man and html.
rdar://42899338
Reviewers: ab, pete, lhames
Reviewed By: lhames
Subscribers: rupprecht, llvm-commits
Differential Revision: https://reviews.llvm.org/D56649
llvm-svn: 351238
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/llvm-objdump/MachODump.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index c8707ac1183..5ef7058ec9d 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -1610,8 +1610,19 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF, if (Disassemble || IndirectSymbols || !FilterSections.empty() || UnwindInfo) if (Error Err = MachOOF->checkSymbolTable()) report_error(ArchiveName, FileName, std::move(Err), ArchitectureName); - - if (Disassemble) { + + if (DisassembleAll) { + for (const SectionRef &Section : MachOOF->sections()) { + StringRef SectName; + Section.getName(SectName); + if (SectName.equals("__text")) { + DataRefImpl Ref = Section.getRawDataRefImpl(); + StringRef SegName = MachOOF->getSectionFinalSegmentName(Ref); + DisassembleMachO(FileName, MachOOF, SegName, SectName); + } + } + } + else if (Disassemble) { if (MachOOF->getHeader().filetype == MachO::MH_KEXT_BUNDLE && MachOOF->getHeader().cputype == MachO::CPU_TYPE_ARM64) DisassembleMachO(FileName, MachOOF, "__TEXT_EXEC", "__text"); |