[PATCH] D75631: [llvm-objdump] Fix reliability of call target disassembling
Thomas Preud'homme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 25 09:10:16 PDT 2020
thopre updated this revision to Diff 252590.
thopre marked an inline comment as done.
thopre added a comment.
Remove assert
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75631/new/
https://reviews.llvm.org/D75631
Files:
lld/test/ELF/pre_init_fini_array.s
llvm/test/tools/llvm-objdump/X86/disassemble-functions.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
@@ -1208,6 +1208,12 @@
SectionAddresses.emplace_back(Sec.getAddress(), Sec);
array_pod_sort(SectionAddresses.begin(), SectionAddresses.end());
+ std::vector<std::pair<uint64_t, SectionRef>> CodeSectionAddresses;
+ for (std::pair<uint64_t, SectionRef> SectionAddress : SectionAddresses) {
+ if (SectionAddress.second.isText())
+ CodeSectionAddresses.emplace_back(SectionAddress);
+ }
+
// Linked executables (.exe and .dll files) typically don't include a real
// symbol table but they might contain an export table.
if (const auto *COFFObj = dyn_cast<COFFObjectFile>(Obj)) {
@@ -1483,11 +1489,11 @@
auto *TargetSectionSymbols = &Symbols;
if (!Obj->isRelocatableObject()) {
auto It = partition_point(
- SectionAddresses,
+ CodeSectionAddresses,
[=](const std::pair<uint64_t, SectionRef> &O) {
return O.first <= Target;
});
- if (It != SectionAddresses.begin()) {
+ if (It != CodeSectionAddresses.begin()) {
--It;
TargetSectionSymbols = &AllSymbols[It->second];
} else {
Index: llvm/test/tools/llvm-objdump/X86/disassemble-functions.test
===================================================================
--- llvm/test/tools/llvm-objdump/X86/disassemble-functions.test
+++ llvm/test/tools/llvm-objdump/X86/disassemble-functions.test
@@ -3,9 +3,9 @@
# RUN: yaml2obj -o %t.out %p/Inputs/simple-executable-x86_64.yaml
# RUN: llvm-objdump -d %t.out --disassemble-functions=main \
-# RUN: | FileCheck %s --check-prefix=MAIN --implicit-check-not=foo --implicit-check-not=somedata
+# RUN: | FileCheck %s --check-prefix=MAIN --implicit-check-not="<foo>:" --implicit-check-not="<somedata>:"
# RUN: llvm-objdump -d %t.out --disassemble-functions=main,foo \
-# RUN: | FileCheck %s --check-prefixes=MAIN,FOO --implicit-check-not=somedata
+# RUN: | FileCheck %s --check-prefixes=MAIN,FOO --implicit-check-not="<somedata>:"
# FOO: <foo>:
# MAIN: <main>:
Index: lld/test/ELF/pre_init_fini_array.s
===================================================================
--- lld/test/ELF/pre_init_fini_array.s
+++ lld/test/ELF/pre_init_fini_array.s
@@ -137,9 +137,9 @@
// CHECK-NEXT: }
// DISASM: <_start>:
-// DISASM-NEXT: callq {{.*}} <__preinit_array_start>
-// DISASM-NEXT: callq {{.*}} <__fini_array_start>
-// DISASM-NEXT: callq {{.*}} <__init_array_start>
-// DISASM-NEXT: callq {{.*}} <__preinit_array_start>
-// DISASM-NEXT: callq {{.*}} <__fini_array_start>
-// DISASM-NEXT: callq {{.*}} <__fini_array_end>
+// DISASM-NEXT: callq {{.*}} <_start+{{.*}}>
+// DISASM-NEXT: callq {{.*}} <_start+{{.*}}>
+// DISASM-NEXT: callq {{.*}} <_start+{{.*}}>
+// DISASM-NEXT: callq {{.*}} <_start+{{.*}}>
+// DISASM-NEXT: callq {{.*}} <_start+{{.*}}>
+// DISASM-NEXT: callq {{.*}} <_start+{{.*}}>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75631.252590.patch
Type: text/x-patch
Size: 3190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200325/3c141554/attachment.bin>
More information about the llvm-commits
mailing list