[PATCH] D86527: [3/5] [MC] [Win64EH] Produce well-formed xdata records when info is missing
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 25 04:34:54 PDT 2020
mstorsjo created this revision.
mstorsjo added reviewers: efriedma, ssijaric, TomTan.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
mstorsjo requested review of this revision.
Previously, this generated truncated xdata records, and llvm-readobj would error out when trying to print them.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86527
Files:
llvm/lib/MC/MCWin64EH.cpp
llvm/test/MC/AArch64/seh.s
Index: llvm/test/MC/AArch64/seh.s
===================================================================
--- llvm/test/MC/AArch64/seh.s
+++ llvm/test/MC/AArch64/seh.s
@@ -1,6 +1,8 @@
// This test checks that the SEH directives don't cause the assembler to fail.
+// Checking that llvm-readobj doesn't bail out on the unwind data, but not
+// really checking the contents yet.
-// RUN: llvm-mc -triple aarch64-pc-win32 -filetype=obj %s | llvm-readobj -S -r - | FileCheck %s
+// RUN: llvm-mc -triple aarch64-pc-win32 -filetype=obj %s | llvm-readobj -S -r -u - | FileCheck %s
// CHECK: Sections [
// CHECK: Section {
@@ -15,7 +17,7 @@
// CHECK-NEXT: }
// CHECK: Section {
// CHECK: Name: .xdata
-// CHECK: RawDataSize: 20
+// CHECK: RawDataSize: 24
// CHECK: RelocationCount: 1
// CHECK: Characteristics [
// CHECK-NEXT: ALIGN_4BYTES
Index: llvm/lib/MC/MCWin64EH.cpp
===================================================================
--- llvm/lib/MC/MCWin64EH.cpp
+++ llvm/lib/MC/MCWin64EH.cpp
@@ -576,7 +576,13 @@
if (CodeWordsMod)
CodeWords++;
uint32_t EpilogCount = info->EpilogMap.size();
- bool ExtensionWord = EpilogCount > 31 || TotalCodeBytes > 124;
+ // If we need to signal a larger EpilogCount or TotalCodeBytes, we need to
+ // use the extension word, and leave those fields as zero in row1.
+ // If both EpilogCount and CodeWords actually are zero though (e.g. due to
+ // missing/incomplete .seh directives in assembly), we still need to include
+ // the extension word, as that is how the reader will interpret it.
+ bool ExtensionWord = EpilogCount > 31 || TotalCodeBytes > 124 ||
+ (EpilogCount == 0 && CodeWords == 0);
if (!ExtensionWord) {
row1 |= (EpilogCount & 0x1F) << 22;
row1 |= (CodeWords & 0x1F) << 27;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86527.287629.patch
Type: text/x-patch
Size: 1862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200825/7ed59801/attachment.bin>
More information about the llvm-commits
mailing list