public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Julian Waters <tanksherman27@gmail.com>
To: binutils@sourceware.org
Subject: Re: [PATCH] Reimplement the .seh_scope directive
Date: Mon, 3 Jul 2023 11:22:40 +0800	[thread overview]
Message-ID: <CAP2b4GMVuEsPJdGpW1nY8BSZ-DL4F37rL7J89Ox5gWY7Jehong@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2663 bytes --]

A second revision of the patch, with a small bugfix

From 89463e94572a022b55c793d299857f85afadd2ff Mon Sep 17 00:00:00 2001
From: TheShermanTanker <tanksherman27@gmail.com>
Date: Mon, 3 Jul 2023 10:42:18 +0800
Subject: [PATCH] Reimplement the .seh_scope directive

---
 gas/config/obj-coff-seh.c | 20 ++++++++++++++++++++
 gas/config/obj-coff-seh.h |  8 +++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/gas/config/obj-coff-seh.c b/gas/config/obj-coff-seh.c
index 7b4486a..87eed0f 100644
--- a/gas/config/obj-coff-seh.c
+++ b/gas/config/obj-coff-seh.c
@@ -388,6 +388,20 @@ obj_coff_seh_handlerdata (int what ATTRIBUTE_UNUSED)
   switch_xdata (seh_ctx_cur->subsection + 1, seh_ctx_cur->code_seg);
 }

+static void obj_coff_seh_scope (int what)
+{
+  if (!verify_context_and_target (".seh_scope", seh_kind_x64))
+    return;
+
+  segT seg = now_seg;
+  int subseg = now_subseg;
+
+  seh_ctx_cur->scopes++;
+  switch_xdata (seh_ctx_cur->subsection + 1, seh_ctx_cur->code_seg);
+  s_rva (4);
+  subseg_set(seg, subseg);
+}
+
 /* Mark end of current context.  */

 static void
@@ -436,6 +450,8 @@ obj_coff_seh_proc (int what ATTRIBUTE_UNUSED)

   seh_ctx_cur = XCNEW (seh_context);

+  seh_ctx_cur->scopes = 0;
+
   seh_ctx_cur->code_seg = now_seg;

   if (seh_get_target_kind () == seh_kind_x64)
@@ -899,6 +915,10 @@ seh_x64_write_function_xdata (seh_context *c)
       emit_expr (&c->handler, 4);
     }

+  if (c->scopes > 0) {
+    out_four (c->scopes);
+  }
+
   /* Handler data will be tacked in here by subsections.  */
 }

diff --git a/gas/config/obj-coff-seh.h b/gas/config/obj-coff-seh.h
index 8d77bac..7c92921 100644
--- a/gas/config/obj-coff-seh.h
+++ b/gas/config/obj-coff-seh.h
@@ -57,6 +57,7 @@
   .seh_savexmm
   .seh_pushframe
   .seh_code
+  .seh_scope
 */

 /* architecture specific pdata/xdata handling.  */
@@ -75,7 +76,8 @@
  {"seh_no32", obj_coff_seh_32, 0}, \
  {"seh_handler", obj_coff_seh_handler, 0}, \
  {"seh_code", obj_coff_seh_code, 0}, \
- {"seh_handlerdata", obj_coff_seh_handlerdata, 0},
+ {"seh_handlerdata", obj_coff_seh_handlerdata, 0}, \
+ {"seh_scope", obj_coff_seh_scope, 0},

 /* Type definitions.  */

@@ -128,6 +130,9 @@ typedef struct seh_context
   int elems_count;
   int elems_max;
   seh_prologue_element *elems;
+
+  /* Scope count for x64 .xdata */
+  unsigned int scopes;
 } seh_context;

 typedef enum seh_kind {
@@ -151,6 +156,7 @@ static void obj_coff_seh_proc  (int);
 static void obj_coff_seh_handler (int);
 static void obj_coff_seh_handlerdata (int);
 static void obj_coff_seh_code (int);
+static void obj_coff_seh_scope (int);

 #define UNDSEC bfd_und_section_ptr

-- 
2.35.1.windows.2

             reply	other threads:[~2023-07-03  3:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03  3:22 Julian Waters [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-07-03  6:12 Julian Waters
2023-07-02 10:18 Julian Waters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP2b4GMVuEsPJdGpW1nY8BSZ-DL4F37rL7J89Ox5gWY7Jehong@mail.gmail.com \
    --to=tanksherman27@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).