[PATCH] D67328: [llvm-readobj] Warn user when dumping not supported version of stack map (PR38278).
Xing via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 8 08:29:45 PDT 2019
Higuoxing created this revision.
Higuoxing added reviewers: jhenderson, grimar.
Herald added subscribers: llvm-commits, seiya, rupprecht.
Herald added a project: LLVM.
Currently, StackMapParser only supports dumping stack map of version 3.
We should warn user when dumping stack map of other versions.
This partly fixes https://bugs.llvm.org/show_bug.cgi?id=38278
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D67328
Files:
llvm/include/llvm/Object/StackMapParser.h
llvm/test/tools/llvm-readobj/elf-stackmap-version2.test
llvm/tools/llvm-readobj/StackMapPrinter.h
Index: llvm/tools/llvm-readobj/StackMapPrinter.h
===================================================================
--- llvm/tools/llvm-readobj/StackMapPrinter.h
+++ llvm/tools/llvm-readobj/StackMapPrinter.h
@@ -18,6 +18,12 @@
template <typename StackMapParserT>
void prettyPrintStackMap(ScopedPrinter &W, const StackMapParserT &SMP) {
+ unsigned version = SMP.getVersion();
+ if (version != 3) {
+ errs() << "Currently, only supports dumping stack map version 3.\n";
+ return;
+ }
+
W.printNumber("LLVM StackMap Version", SMP.getVersion());
W.printNumber("Num Functions", SMP.getNumFunctions());
Index: llvm/test/tools/llvm-readobj/elf-stackmap-version2.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-readobj/elf-stackmap-version2.test
@@ -0,0 +1,18 @@
+# RUN: yaml2obj %s -o %t.o
+# RUN: llvm-readobj -stackmap %t.o 2>&1 | FileCheck %s
+
+# CHECK: Currently, only supports dumping stack map version 3.
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .llvm_stackmaps
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 0x0000000000000008
+ Content: 020000000100000003000000010000000000000000000000080000000000000001000000000000000000008000000000FFFFFFFF00000000000000000100000001000000000000000400000000000C000400080000000000FFFFFFFF0400080000000000FFFFFFFF0400080000000000000001000400080000000000009435770400080000000000FFFFFF7F0400080000000000FFFFFFFF0400080000000000FFFFFFFF0400080000000000000000000500080000000000000000000500080000000000010000000500080000000000020000000400080000000000FFFFFFFF0000010007000008
+...
Index: llvm/include/llvm/Object/StackMapParser.h
===================================================================
--- llvm/include/llvm/Object/StackMapParser.h
+++ llvm/include/llvm/Object/StackMapParser.h
@@ -322,8 +322,10 @@
using constant_iterator = AccessorIterator<ConstantAccessor>;
using record_iterator = AccessorIterator<RecordAccessor>;
- /// Get the version number of this stackmap. (Always returns 3).
- unsigned getVersion() const { return 3; }
+ /// Get the version number of this stackmap.
+ unsigned getVersion() const {
+ return read<uint8_t>(&StackMapSection[0]);
+ }
/// Get the number of functions in the stack map.
uint32_t getNumFunctions() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67328.219269.patch
Type: text/x-patch
Size: 2488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190908/a9eeb76b/attachment.bin>
More information about the llvm-commits
mailing list