[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 57bfe47451/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
This commit is contained in:
Arpad Borsos 2022-09-01 14:05:13 -07:00 committed by Fangrui Song
parent 0b509f2d1a
commit de3633e746

View File

@ -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;