Allow .seh_pushframe to take an optional [code] parameter

Message ID 4507728.LvFx2qVVIh@fixe-jerome.gardouchoux
State New
Headers show
Series
  • Allow .seh_pushframe to take an optional [code] parameter
Related show

Commit Message

Alan Modra via Binutils April 22, 2021, 2:25 p.m.
This helps with developing an OS when using PE/COFF 
objects on x86_64.

See here for details. https://docs.microsoft.com/fr-fr/cpp/
assembler/masm/dot-pushframe?view=msvc-160[1] 

--------
[1] https://docs.microsoft.com/fr-fr/cpp/assembler/masm/
dot-pushframe?view=msvc-160

Comments

Alan Modra via Binutils April 23, 2021, 3:34 p.m. | #1
Hi Jérôme,

> This helps with developing an OS when using PE/COFF

> objects on x86_64.


Patch approved and applied.

Cheers
   Nick

Patch

From 56da029d5c7dfb67ffd71e8b6a538b3c8198feff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= <jerome.gardou@reactos.org>
Date: Thu, 22 Apr 2021 15:42:55 +0200
Subject: [PATCH] gas: Allow optional "code" parameter to .seh_pushframe
 pseudo-op

gas/Changelog
 * config/obj-coff-seh.c (seh_pushframe): Accept "code" parameter
---
 gas/config/obj-coff-seh.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/gas/config/obj-coff-seh.c b/gas/config/obj-coff-seh.c
index 964fe87e..aac82430 100644
--- a/gas/config/obj-coff-seh.c
+++ b/gas/config/obj-coff-seh.c
@@ -582,12 +582,29 @@  obj_coff_seh_pushreg (int what ATTRIBUTE_UNUSED)
 static void
 obj_coff_seh_pushframe (int what ATTRIBUTE_UNUSED)
 {
+  int code = 0;
+  
   if (!verify_context_and_target (".seh_pushframe", seh_kind_x64)
       || !seh_validate_seg (".seh_pushframe"))
     return;
+  
+  SKIP_WHITESPACE();
+  
+  if (is_name_beginner(*input_line_pointer))
+  {
+    char* identifier;
+    get_symbol_name(&identifier);
+    if (strcmp(identifier, "code") != 0)
+    {
+      as_bad(_("invalid argument \"%s\" for .seh_pushframe. Expected \"code\" or nothing"), identifier);
+      return;
+    }
+    code = 1;
+  }
+  
   demand_empty_rest_of_line ();
 
-  seh_x64_make_prologue_element (UWOP_PUSH_MACHFRAME, 0, 0);
+  seh_x64_make_prologue_element (UWOP_PUSH_MACHFRAME, code, 0);
 }
 
 /* Add a register save-unwind token to current context.  */
-- 
2.30.2