<div dir="ltr">This commit was reverted as it depended on the previously reverted commit r362766.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 7, 2019 at 1:53 AM Michael Pozulp via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: pozulp<br>
Date: Thu Jun 6 22:11:13 2019<br>
New Revision: 362768<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=362768&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=362768&view=rev</a><br>
Log:<br>
[llvm-objdump] Add warning if --disassemble-functions specifies an unknown symbol<br>
<br>
Summary: Fixes Bug 41904 <a href="https://bugs.llvm.org/show_bug.cgi?id=41904" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=41904</a><br>
<br>
Reviewers: jhenderson, rupprecht, grimar, MaskRay<br>
<br>
Reviewed By: jhenderson, rupprecht, MaskRay<br>
<br>
Subscribers: dexonsmith, rupprecht, kristina, llvm-commits<br>
<br>
Tags: #llvm<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D62275" rel="noreferrer" target="_blank">https://reviews.llvm.org/D62275</a><br>
<br>
Added:<br>
llvm/trunk/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test<br>
Modified:<br>
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp<br>
<br>
Added: llvm/trunk/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test?rev=362768&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test?rev=362768&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test (added)<br>
+++ llvm/trunk/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test Thu Jun 6 22:11:13 2019<br>
@@ -0,0 +1,11 @@<br>
+## Warn if --disassemble-functions specifies an unknown symbol.<br>
+# RUN: yaml2obj %s | llvm-objdump - --disassemble-functions=foo 2>&1 | FileCheck %s<br>
+<br>
+--- !ELF<br>
+FileHeader:<br>
+ Class: ELFCLASS64<br>
+ Data: ELFDATA2LSB<br>
+ Type: ET_REL<br>
+ Machine: EM_X86_64<br>
+<br>
+# CHECK: warning: failed to disassemble missing function foo<br>
<br>
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=362768&r1=362767&r2=362768&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=362768&r1=362767&r2=362768&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)<br>
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Thu Jun 6 22:11:13 2019<br>
@@ -18,6 +18,7 @@<br>
#include "llvm-objdump.h"<br>
#include "llvm/ADT/Optional.h"<br>
#include "llvm/ADT/STLExtras.h"<br>
+#include "llvm/ADT/SetOperations.h"<br>
#include "llvm/ADT/StringExtras.h"<br>
#include "llvm/ADT/StringSet.h"<br>
#include "llvm/ADT/Triple.h"<br>
@@ -375,6 +376,10 @@ void warn(StringRef Message) {<br>
errs().flush();<br>
}<br>
<br>
+void warn(Twine Message) {<br>
+ WithColor::warning(errs(), ToolName) << Message << "\n";<br>
+}<br>
+<br>
LLVM_ATTRIBUTE_NORETURN void report_error(StringRef File, Twine Message) {<br>
WithColor::error(errs(), ToolName)<br>
<< "'" << File << "': " << Message << ".\n";<br>
@@ -1090,6 +1095,7 @@ static void disassembleObject(const Targ<br>
<br>
// Sort all the symbols, this allows us to use a simple binary search to find<br>
// a symbol near an address.<br>
+ StringSet<> FoundDisasmFuncsSet;<br>
for (std::pair<const SectionRef, SectionSymbolsTy> &SecSyms : AllSymbols)<br>
array_pod_sort(SecSyms.second.begin(), SecSyms.second.end());<br>
array_pod_sort(AbsoluteSymbols.begin(), AbsoluteSymbols.end());<br>
@@ -1181,6 +1187,8 @@ static void disassembleObject(const Targ<br>
uint64_t Start = std::get<0>(Symbols[SI]);<br>
if (Start < SectionAddr || StopAddress <= Start)<br>
continue;<br>
+ else<br>
+ FoundDisasmFuncsSet.insert(std::get<1>(Symbols[SI]));<br>
<br>
// The end is the section end, the beginning of the next symbol, or<br>
// --stop-address.<br>
@@ -1401,6 +1409,10 @@ static void disassembleObject(const Targ<br>
}<br>
}<br>
}<br>
+ StringSet<> MissingDisasmFuncsSet =<br>
+ set_difference(DisasmFuncsSet, FoundDisasmFuncsSet);<br>
+ for (StringRef MissingDisasmFunc : MissingDisasmFuncsSet.keys())<br>
+ warn("failed to disassemble missing function " + MissingDisasmFunc);<br>
}<br>
<br>
static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>