[PATCH] D107655: Correctly decode `UOP_Epilog` opcodes in `llvm-objdump`

Arpad Borsos via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 6 08:57:05 PDT 2021


Swatinem created this revision.
Swatinem added a reviewer: Bigcheese.
Herald added a subscriber: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Swatinem requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107655

Files:
  llvm/tools/llvm-objdump/COFFDump.cpp


Index: llvm/tools/llvm-objdump/COFFDump.cpp
===================================================================
--- llvm/tools/llvm-objdump/COFFDump.cpp
+++ 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
 ///
 //===----------------------------------------------------------------------===//
 
@@ -41,6 +41,8 @@
   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";
@@ -81,9 +83,11 @@
     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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107655.364812.patch
Type: text/x-patch
Size: 1317 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210806/d9fc850e/attachment.bin>


More information about the llvm-commits mailing list