Skip to content

Commit 6313f55

Browse files
committed
[llvm-readobj] [ARMWinEH] Fix printing of exception handlers with packed epilogues
If there's a packed epilogue (indicated by the flag E), the EpilogueCount() field actually should be interpreted as EpilogueOffset. Differential Revision: https://reviews.llvm.org/D87365
1 parent 8060283 commit 6313f55

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

llvm/include/llvm/Support/ARMWinEH.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,13 @@ struct ExceptionDataRecord {
416416

417417
uint32_t ExceptionHandlerRVA() const {
418418
assert(X() && "Exception Handler RVA is only valid if the X bit is set");
419-
return Data[HeaderWords(*this) + EpilogueCount() + CodeWords()];
419+
return Data[HeaderWords(*this) + (E() ? 0 : EpilogueCount()) + CodeWords()];
420420
}
421421

422422
uint32_t ExceptionHandlerParameter() const {
423423
assert(X() && "Exception Handler RVA is only valid if the X bit is set");
424-
return Data[HeaderWords(*this) + EpilogueCount() + CodeWords() + 1];
424+
return Data[HeaderWords(*this) + (E() ? 0 : EpilogueCount()) + CodeWords() +
425+
1];
425426
}
426427
};
427428

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// REQUIRES: aarch64-registered-target
2+
// RUN: llvm-mc -filetype=obj -triple aarch64-windows %s -o %t.o
3+
// RUN: llvm-readobj --unwind %t.o | FileCheck %s
4+
5+
// CHECK: ExceptionData {
6+
// CHECK-NEXT: FunctionLength: 4
7+
// CHECK-NEXT: Version: 0
8+
// CHECK-NEXT: ExceptionData: Yes
9+
// CHECK-NEXT: EpiloguePacked: Yes
10+
// CHECK-NEXT: EpilogueOffset: 0
11+
// CHECK-NEXT: ByteCodeLength: 4
12+
// CHECK-NEXT: Prologue [
13+
// CHECK-NEXT: 0xe4 ; end
14+
// CHECK-NEXT: ]
15+
// CHECK-NEXT: ExceptionHandler [
16+
// CHECK-NEXT: Routine: 0x11223344
17+
// CHECK-NEXT: Parameter: 0x55667788
18+
// CHECK-NEXT: ]
19+
20+
.section .pdata,"dr"
21+
.long func@IMGREL
22+
.long "$unwind$func"@IMGREL
23+
24+
.text
25+
.globl func
26+
func:
27+
ret
28+
29+
.section .xdata,"dr"
30+
"$unwind$func":
31+
.byte 0x01, 0x00, 0x30, 0x08
32+
.byte 0xe4, 0xe3, 0xe3, 0xe3
33+
.byte 0x44, 0x33, 0x22, 0x11
34+
.byte 0x88, 0x77, 0x66, 0x55

0 commit comments

Comments
 (0)