[llvm] de3633e - [llvm-objdump][COFF] Correctly decode `UOP_Epilog` opcodes
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 1 14:05:23 PDT 2022
Author: Arpad Borsos
Date: 2022-09-01T14:05:14-07:00
New Revision: de3633e746dba4774ba7f638f04e9c8f2541fd54
URL: https://github.com/llvm/llvm-project/commit/de3633e746dba4774ba7f638f04e9c8f2541fd54
DIFF: https://github.com/llvm/llvm-project/commit/de3633e746dba4774ba7f638f04e9c8f2541fd54.diff
LOG: [llvm-objdump][COFF] Correctly decode `UOP_Epilog` opcodes
At least `ntdll` is using the undocumented version 2 unwind info, and opcode 6, which is already defined as `UOP_Epilog`.
Using `llvm-objdump --unwind` with `ntdll` would previously result in unreachable assertions because this code was missing from `getNumUsedSlots` and `getUnwindCodeTypeName`.
The slots of these codes comes from https://github.com/dotnet/runtime/blob/57bfe474518ab5b7cfe6bf7424a79ce3af9d6657/src/coreclr/inc/win64unwind.h#L51-L52 which I would assume is a good authoritative source.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D107655
Added:
Modified:
llvm/tools/llvm-objdump/COFFDump.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-objdump/COFFDump.cpp b/llvm/tools/llvm-objdump/COFFDump.cpp
index e65762e020220..1fcbeade35cb8 100644
--- a/llvm/tools/llvm-objdump/COFFDump.cpp
+++ b/llvm/tools/llvm-objdump/COFFDump.cpp
@@ -10,7 +10,7 @@
/// This file implements the COFF-specific dumper for llvm-objdump.
/// It outputs the Win64 EH data structures as plain text.
/// The encoding of the unwind codes is described in MSDN:
-/// http://msdn.microsoft.com/en-us/library/ck9asaa9.aspx
+/// https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64
///
//===----------------------------------------------------------------------===//
@@ -194,6 +194,8 @@ static StringRef getUnwindCodeTypeName(uint8_t Code) {
case UOP_SetFPReg: return "UOP_SetFPReg";
case UOP_SaveNonVol: return "UOP_SaveNonVol";
case UOP_SaveNonVolBig: return "UOP_SaveNonVolBig";
+ case UOP_Epilog: return "UOP_Epilog";
+ case UOP_SpareCode: return "UOP_SpareCode";
case UOP_SaveXMM128: return "UOP_SaveXMM128";
case UOP_SaveXMM128Big: return "UOP_SaveXMM128Big";
case UOP_PushMachFrame: return "UOP_PushMachFrame";
@@ -234,9 +236,11 @@ static unsigned getNumUsedSlots(const UnwindCode &UnwindCode) {
return 1;
case UOP_SaveNonVol:
case UOP_SaveXMM128:
+ case UOP_Epilog:
return 2;
case UOP_SaveNonVolBig:
case UOP_SaveXMM128Big:
+ case UOP_SpareCode:
return 3;
case UOP_AllocLarge:
return (UnwindCode.getOpInfo() == 0) ? 2 : 3;
More information about the llvm-commits
mailing list