[PATCH] D62275: [llvm-objdump] Add warning if --disassemble-functions specifies an unknown symbol
Mike Pozulp via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 6 22:12:17 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG50f61af3f304: [llvm-objdump] Add warning if --disassemble-functions specifies an unknown… (authored by mmpozulp).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62275/new/
https://reviews.llvm.org/D62275
Files:
llvm/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test
llvm/tools/llvm-objdump/llvm-objdump.cpp
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -18,6 +18,7 @@
#include "llvm-objdump.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Triple.h"
@@ -375,6 +376,10 @@
errs().flush();
}
+void warn(Twine Message) {
+ WithColor::warning(errs(), ToolName) << Message << "\n";
+}
+
LLVM_ATTRIBUTE_NORETURN void report_error(StringRef File, Twine Message) {
WithColor::error(errs(), ToolName)
<< "'" << File << "': " << Message << ".\n";
@@ -1090,6 +1095,7 @@
// Sort all the symbols, this allows us to use a simple binary search to find
// a symbol near an address.
+ StringSet<> FoundDisasmFuncsSet;
for (std::pair<const SectionRef, SectionSymbolsTy> &SecSyms : AllSymbols)
array_pod_sort(SecSyms.second.begin(), SecSyms.second.end());
array_pod_sort(AbsoluteSymbols.begin(), AbsoluteSymbols.end());
@@ -1181,6 +1187,8 @@
uint64_t Start = std::get<0>(Symbols[SI]);
if (Start < SectionAddr || StopAddress <= Start)
continue;
+ else
+ FoundDisasmFuncsSet.insert(std::get<1>(Symbols[SI]));
// The end is the section end, the beginning of the next symbol, or
// --stop-address.
@@ -1401,6 +1409,10 @@
}
}
}
+ StringSet<> MissingDisasmFuncsSet =
+ set_difference(DisasmFuncsSet, FoundDisasmFuncsSet);
+ for (StringRef MissingDisasmFunc : MissingDisasmFuncsSet.keys())
+ warn("failed to disassemble missing function " + MissingDisasmFunc);
}
static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
Index: llvm/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test
@@ -0,0 +1,11 @@
+## Warn if --disassemble-functions specifies an unknown symbol.
+# RUN: yaml2obj %s | llvm-objdump - --disassemble-functions=foo 2>&1 | FileCheck %s
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+
+# CHECK: warning: failed to disassemble missing function foo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62275.203493.patch
Type: text/x-patch
Size: 2393 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190607/2cecfa65/attachment.bin>
More information about the llvm-commits
mailing list