[PATCH] D93265: [llvm-objdump-macho] print per-second-level-page encodings for option --unwind-info
Greg McGary via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 14 18:45:31 PST 2020
gkm created this revision.
gkm added a reviewer: lld-macho.
Herald added a subscriber: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
gkm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Compact unwind entries have 8 bits for the encoding-table offset:
- offsets 0..126 reference the global commmon-encodings table, while
- offsets 127..255 reference a per-second-level-page table.
This diff teaches `llvm-objdump` to print this per-page encodings table.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93265
Files:
llvm/tools/llvm-objdump/MachODump.cpp
Index: llvm/tools/llvm-objdump/MachODump.cpp
===================================================================
--- llvm/tools/llvm-objdump/MachODump.cpp
+++ llvm/tools/llvm-objdump/MachODump.cpp
@@ -8014,12 +8014,23 @@
(void)Kind;
assert(Kind == 3 && "kind for a compressed 2nd level index should be 3");
+ uint32_t NumCommonEncodings = CommonEncodings.size();
uint16_t EntriesStart = readNext<uint16_t>(PageData, Pos);
uint16_t NumEntries = readNext<uint16_t>(PageData, Pos);
- uint16_t EncodingsStart = readNext<uint16_t>(PageData, Pos);
- readNext<uint16_t>(PageData, Pos);
- StringRef PageEncodings = PageData.substr(EncodingsStart, StringRef::npos);
+ uint16_t PageEncodingsStart = readNext<uint16_t>(PageData, Pos);
+ uint16_t NumPageEncodings = readNext<uint16_t>(PageData, Pos);
+ SmallVector<uint32_t, 64> PageEncodings;
+ if (NumPageEncodings) {
+ outs() << " Page encodings: (count = " << NumPageEncodings << ")\n";
+ Pos = PageEncodingsStart;
+ for (unsigned i = 0; i < NumPageEncodings; ++i) {
+ uint32_t Encoding = readNext<uint32_t>(PageData, Pos);
+ PageEncodings.push_back(Encoding);
+ outs() << " encoding[" << (i + NumCommonEncodings)
+ << "]: " << format("0x%08" PRIx32, Encoding) << '\n';
+ }
+ }
Pos = EntriesStart;
for (unsigned i = 0; i < NumEntries; ++i) {
@@ -8028,12 +8039,10 @@
uint32_t EncodingIdx = Entry >> 24;
uint32_t Encoding;
- if (EncodingIdx < CommonEncodings.size())
+ if (EncodingIdx < NumCommonEncodings)
Encoding = CommonEncodings[EncodingIdx];
else
- Encoding = read<uint32_t>(PageEncodings,
- sizeof(uint32_t) *
- (EncodingIdx - CommonEncodings.size()));
+ Encoding = PageEncodings[EncodingIdx - NumCommonEncodings];
outs() << " [" << i << "]: "
<< "function offset=" << format("0x%08" PRIx32, FunctionOffset)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93265.311766.patch
Type: text/x-patch
Size: 1969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201215/52b2852f/attachment.bin>
More information about the llvm-commits
mailing list