summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objdump
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2017-06-22 17:41:22 +0000
committerKevin Enderby <enderby@apple.com>2017-06-22 17:41:22 +0000
commitabf10f2d2e3c18dc5825ad0dcd5b70de0bc00ba1 (patch)
tree81c3c043dd53ac387623b44a3d0d860eeb868c2d /llvm/tools/llvm-objdump
parent4402a39981063992cd8f4ca81e240a6fe7cdf4fd (diff)
downloadbcm5719-llvm-abf10f2d2e3c18dc5825ad0dcd5b70de0bc00ba1.tar.gz
bcm5719-llvm-abf10f2d2e3c18dc5825ad0dcd5b70de0bc00ba1.zip
Updated llvm-objdump symbolic disassembly with x86_64 Mach-O MH_KEXT_BUNDLE
file types so it symbolically disassembles operands using the external relocation entries. rdar://31521343 llvm-svn: 306037
Diffstat (limited to 'llvm/tools/llvm-objdump')
-rw-r--r--llvm/tools/llvm-objdump/MachODump.cpp42
1 files changed, 38 insertions, 4 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 960ef6be414..ec4c44a2665 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -1921,11 +1921,45 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
if (Arch == Triple::x86_64) {
if (Size != 1 && Size != 2 && Size != 4 && Size != 0)
return 0;
+ // For non MH_OBJECT types, like MH_KEXT_BUNDLE, Search the external
+ // relocation entries of a linked image (if any) for an entry that matches
+ // this segment offset.
if (info->O->getHeader().filetype != MachO::MH_OBJECT) {
- // TODO:
- // Search the external relocation entries of a fully linked image
- // (if any) for an entry that matches this segment offset.
- // uint64_t seg_offset = (Pc + Offset);
+ uint64_t seg_offset = Pc + Offset;
+ bool reloc_found = false;
+ DataRefImpl Rel;
+ MachO::any_relocation_info RE;
+ bool isExtern = false;
+ SymbolRef Symbol;
+ for (const RelocationRef &Reloc : info->O->external_relocations()) {
+ uint64_t RelocOffset = Reloc.getOffset();
+ if (RelocOffset == seg_offset) {
+ Rel = Reloc.getRawDataRefImpl();
+ RE = info->O->getRelocation(Rel);
+ // external relocation entries should always be external.
+ isExtern = info->O->getPlainRelocationExternal(RE);
+ if (isExtern) {
+ symbol_iterator RelocSym = Reloc.getSymbol();
+ Symbol = *RelocSym;
+ }
+ reloc_found = true;
+ break;
+ }
+ }
+ if (reloc_found && isExtern) {
+ // The Value passed in will be adjusted by the Pc if the instruction
+ // adds the Pc. But for x86_64 external relocation entries the Value
+ // is the offset from the external symbol.
+ if (info->O->getAnyRelocationPCRel(RE))
+ op_info->Value -= Pc + Offset + Size;
+ Expected<StringRef> SymName = Symbol.getName();
+ if (!SymName)
+ report_error(info->O->getFileName(), SymName.takeError());
+ const char *name = SymName->data();
+ op_info->AddSymbol.Present = 1;
+ op_info->AddSymbol.Name = name;
+ return 1;
+ }
return 0;
}
// In MH_OBJECT filetypes search the section's relocation entries (if any)
OpenPOWER on IntegriCloud