Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AArch64][Windows] Add llvm-readobj support for ec_context unwind opcode #69515

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

bylaws
Copy link
Contributor

@bylaws bylaws commented Oct 18, 2023

ARM64EC uses the same CONTEXT structure as x86_64 as opposed to the regular ARM64 context, a new unwind opcode (MSFT_OP_EC_CONTEXT) is added to handle this.

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 18, 2023

@llvm/pr-subscribers-llvm-binary-utilities

Author: Billy Laws (bylaws)

Changes

ARM64EC uses the same CONTEXT structure as x86_64 as opposed to the regular ARM64 context, a new unwind opcode (MSFT_OP_EC_CONTEXT) is added to handle this.


Full diff: https://github.com/llvm/llvm-project/pull/69515.diff

2 Files Affected:

  • (modified) llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp (+8)
  • (modified) llvm/tools/llvm-readobj/ARMWinEHPrinter.h (+2)
diff --git a/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp b/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
index ef77d4b2fd224bd..cf5c77cf107c36f 100644
--- a/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
+++ b/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
@@ -171,6 +171,7 @@ const Decoder::RingEntry Decoder::Ring64[] = {
     {0xff, 0xe8, 1, &Decoder::opcode_trap_frame},
     {0xff, 0xe9, 1, &Decoder::opcode_machine_frame},
     {0xff, 0xea, 1, &Decoder::opcode_context},
+    {0xff, 0xeb, 1, &Decoder::opcode_ec_context},
     {0xff, 0xec, 1, &Decoder::opcode_clear_unwound_to_call},
     {0xff, 0xfc, 1, &Decoder::opcode_pac_sign_lr},
 };
@@ -969,6 +970,13 @@ bool Decoder::opcode_context(const uint8_t *OC, unsigned &Offset,
   return false;
 }
 
+bool Decoder::opcode_ec_context(const uint8_t *OC, unsigned &Offset,
+                                unsigned Length, bool Prologue) {
+  SW.startLine() << format("0x%02x                ; EC context\n", OC[Offset]);
+  ++Offset;
+  return false;
+}
+
 bool Decoder::opcode_clear_unwound_to_call(const uint8_t *OC, unsigned &Offset,
                                            unsigned Length, bool Prologue) {
   SW.startLine() << format("0x%02x                ; clear unwound to call\n",
diff --git a/llvm/tools/llvm-readobj/ARMWinEHPrinter.h b/llvm/tools/llvm-readobj/ARMWinEHPrinter.h
index 0ffebe5834c480b..92b3a78e4330098 100644
--- a/llvm/tools/llvm-readobj/ARMWinEHPrinter.h
+++ b/llvm/tools/llvm-readobj/ARMWinEHPrinter.h
@@ -129,6 +129,8 @@ class Decoder {
                             unsigned Length, bool Prologue);
   bool opcode_context(const uint8_t *Opcodes, unsigned &Offset, unsigned Length,
                       bool Prologue);
+  bool opcode_ec_context(const uint8_t *Opcodes, unsigned &Offset, unsigned Length,
+                         bool Prologue);
   bool opcode_clear_unwound_to_call(const uint8_t *Opcodes, unsigned &Offset,
                                     unsigned Length, bool Prologue);
   bool opcode_pac_sign_lr(const uint8_t *Opcodes, unsigned &Offset,

@github-actions
Copy link

github-actions bot commented Oct 18, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

@bylaws
Copy link
Contributor Author

bylaws commented Nov 13, 2023

cc: @mstorsjo @cjacek

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself looks good, thanks!

This is lacking a test, but OTOH I don't see a standalone test for disassembling all the other corresponding opcodes either.

Many of them were added in llvm-readobj in the same commit as the MC layer code for assembling them, in f5e2ea9, so the readobj changes are covered by those MC tests at least.

So as long as this is merged close together with #69520 which does provide some test coverage for this, I think it's fine.

@cjacek cjacek merged commit 5edf586 into llvm:main Nov 16, 2023
3 checks passed
sr-tream pushed a commit to sr-tream/llvm-project that referenced this pull request Nov 20, 2023
…ode (llvm#69515)

ARM64EC uses the same CONTEXT structure as x86_64 as opposed to the
regular ARM64 context, a new unwind opcode MSFT_OP_EC_CONTEXT is
added to handle this.
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
…ode (llvm#69515)

ARM64EC uses the same CONTEXT structure as x86_64 as opposed to the
regular ARM64 context, a new unwind opcode MSFT_OP_EC_CONTEXT is
added to handle this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants