public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dlltool: Make x86_64 delay-load trampoline SEH-compatible.
@ 2020-12-09  1:22 Zebediah Figura
  2020-12-09  1:22 ` [PATCH 2/2] dlltool: Add SEH annotations to the x86_64 delay-load trampoline Zebediah Figura
  2021-01-11 22:46 ` (ping) [PATCH 1/2] dlltool: Make x86_64 delay-load trampoline SEH-compatible Zebediah Figura
  0 siblings, 2 replies; 5+ messages in thread
From: Zebediah Figura @ 2020-12-09  1:22 UTC (permalink / raw)
  To: binutils

	binutils/
		* dlltool.c: Adjust %rsp immediately on entry and
		before exit.
---
 binutils/dlltool.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index ed016b97dc..ccba665262 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -570,19 +570,19 @@ static const char i386_trampoline[] =
   "\tjmp *%%eax\n";
 
 static const char i386_x64_trampoline[] =
-  "\tpushq %%rcx\n"
-  "\tpushq %%rdx\n"
-  "\tpushq %%r8\n"
-  "\tpushq %%r9\n"
-  "\tsubq  $40, %%rsp\n"
+  "\tsubq $72, %%rsp\n"
+  "\tmovq %%rcx, 64(%%rsp)\n"
+  "\tmovq %%rdx, 56(%%rsp)\n"
+  "\tmovq %%r8, 48(%%rsp)\n"
+  "\tmovq %%r9, 40(%%rsp)\n"
   "\tmovq  %%rax, %%rdx\n"
   "\tleaq  __DELAY_IMPORT_DESCRIPTOR_%s(%%rip), %%rcx\n"
   "\tcall __delayLoadHelper2\n"
-  "\taddq  $40, %%rsp\n"
-  "\tpopq %%r9\n"
-  "\tpopq %%r8\n"
-  "\tpopq %%rdx\n"
-  "\tpopq %%rcx\n"
+  "\tmovq 40(%%rsp), %%r9\n"
+  "\tmovq 48(%%rsp), %%r8\n"
+  "\tmovq 56(%%rsp), %%rdx\n"
+  "\tmovq 64(%%rsp), %%rcx\n"
+  "\taddq $72, %%rsp\n"
   "\tjmp *%%rax\n";
 
 struct mac
-- 
2.29.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] dlltool: Add SEH annotations to the x86_64 delay-load trampoline.
  2020-12-09  1:22 [PATCH 1/2] dlltool: Make x86_64 delay-load trampoline SEH-compatible Zebediah Figura
@ 2020-12-09  1:22 ` Zebediah Figura
  2021-01-11 22:46 ` (ping) [PATCH 1/2] dlltool: Make x86_64 delay-load trampoline SEH-compatible Zebediah Figura
  1 sibling, 0 replies; 5+ messages in thread
From: Zebediah Figura @ 2020-12-09  1:22 UTC (permalink / raw)
  To: binutils

	binutils/
		PR 27037
		* dlltool.c: Add SEH annotations to i386_x64_trampoline.
---
 binutils/dlltool.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index ccba665262..112b826227 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -571,6 +571,8 @@ static const char i386_trampoline[] =
 
 static const char i386_x64_trampoline[] =
   "\tsubq $72, %%rsp\n"
+  "\t.seh_stackalloc 72\n"
+  "\t.seh_endprologue\n"
   "\tmovq %%rcx, 64(%%rsp)\n"
   "\tmovq %%rdx, 56(%%rsp)\n"
   "\tmovq %%r8, 48(%%rsp)\n"
@@ -609,6 +611,7 @@ struct mac
   int how_dljtab_roff1; /* Offset for the ind 32 reloc into idata 5.  */
   int how_dljtab_roff2; /* Offset for the ind 32 reloc into idata 5.  */
   int how_dljtab_roff3; /* Offset for the ind 32 reloc into idata 5.  */
+  bfd_boolean how_seh;
   const char *trampoline;
 };
 
@@ -622,7 +625,7 @@ mtable[] =
     ".global", ".space", ".align\t2",".align\t4", "-mapcs-32",
     "pe-arm-little", bfd_arch_arm,
     arm_jtab, sizeof (arm_jtab), 8,
-    0, 0, 0, 0, 0, 0
+    0, 0, 0, 0, 0, FALSE, 0
   }
   ,
   {
@@ -631,7 +634,7 @@ mtable[] =
     "jmp *", ".global", ".space", ".align\t2",".align\t4", "",
     "pe-i386",bfd_arch_i386,
     i386_jtab, sizeof (i386_jtab), 2,
-    i386_dljtab, sizeof (i386_dljtab), 2, 7, 12, i386_trampoline
+    i386_dljtab, sizeof (i386_dljtab), 2, 7, 12, FALSE, i386_trampoline
   }
   ,
   {
@@ -641,7 +644,7 @@ mtable[] =
     ".global", ".space", ".align\t2",".align\t4", "-mthumb-interwork",
     "pe-arm-little", bfd_arch_arm,
     thumb_jtab, sizeof (thumb_jtab), 12,
-    0, 0, 0, 0, 0, 0
+    0, 0, 0, 0, 0, FALSE, 0
   }
   ,
 #define MARM_INTERWORK 3
@@ -651,7 +654,7 @@ mtable[] =
     ".global", ".space", ".align\t2",".align\t4", "-mthumb-interwork",
     "pe-arm-little", bfd_arch_arm,
     arm_interwork_jtab, sizeof (arm_interwork_jtab), 12,
-    0, 0, 0, 0, 0, 0
+    0, 0, 0, 0, 0, FALSE, 0
   }
   ,
   {
@@ -661,7 +664,7 @@ mtable[] =
     ".global", ".space", ".align\t2",".align\t4", "",
     "pe-mcore-big", bfd_arch_mcore,
     mcore_be_jtab, sizeof (mcore_be_jtab), 8,
-    0, 0, 0, 0, 0, 0
+    0, 0, 0, 0, 0, FALSE, 0
   }
   ,
   {
@@ -671,7 +674,7 @@ mtable[] =
     ".global", ".space", ".align\t2",".align\t4", "-EL",
     "pe-mcore-little", bfd_arch_mcore,
     mcore_le_jtab, sizeof (mcore_le_jtab), 8,
-    0, 0, 0, 0, 0, 0
+    0, 0, 0, 0, 0, FALSE, 0
   }
   ,
   {
@@ -681,7 +684,7 @@ mtable[] =
     ".global", ".space", ".align\t2",".align\t4", "",
     "elf32-mcore-big", bfd_arch_mcore,
     mcore_be_jtab, sizeof (mcore_be_jtab), 8,
-    0, 0, 0, 0, 0, 0
+    0, 0, 0, 0, 0, FALSE, 0
   }
   ,
   {
@@ -691,7 +694,7 @@ mtable[] =
     ".global", ".space", ".align\t2",".align\t4", "-EL",
     "elf32-mcore-little", bfd_arch_mcore,
     mcore_le_jtab, sizeof (mcore_le_jtab), 8,
-    0, 0, 0, 0, 0, 0
+    0, 0, 0, 0, 0, FALSE, 0
   }
   ,
   {
@@ -701,7 +704,7 @@ mtable[] =
     ".global", ".space", ".align\t2",".align\t4", "-mapcs-32",
     "pe-arm-wince-little", bfd_arch_arm,
     arm_jtab, sizeof (arm_jtab), 8,
-    0, 0, 0, 0, 0, 0
+    0, 0, 0, 0, 0, FALSE, 0
   }
   ,
   {
@@ -710,10 +713,10 @@ mtable[] =
     "jmp *", ".global", ".space", ".align\t2",".align\t4", "",
     "pe-x86-64",bfd_arch_i386,
     i386_jtab, sizeof (i386_jtab), 2,
-    i386_x64_dljtab, sizeof (i386_x64_dljtab), 2, 9, 14, i386_x64_trampoline
+    i386_x64_dljtab, sizeof (i386_x64_dljtab), 2, 9, 14, TRUE, i386_x64_trampoline
   }
   ,
-  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
 };
 
 typedef struct dlist
@@ -947,6 +950,7 @@ asm_prefix (int mach, const char *name)
 #define HOW_JTAB_ROFF2		(delay ? mtable[machine].how_dljtab_roff2 : 0)
 #define HOW_JTAB_ROFF3		(delay ? mtable[machine].how_dljtab_roff3 : 0)
 #define ASM_SWITCHES		mtable[machine].how_default_as_switches
+#define HOW_SEH			mtable[machine].how_seh
 
 static char **oav;
 
@@ -2789,8 +2793,12 @@ make_delay_head (void)
   fprintf (f, "%s Import trampoline\n", ASM_C);
   fprintf (f, "\t.section\t.text\n");
   fprintf(f,"\t%s\t%s\n", ASM_GLOBAL, head_label);
+  if (HOW_SEH)
+    fprintf (f, "\t.seh_proc\t%s\n", head_label);
   fprintf (f, "%s:\n", head_label);
   fprintf (f, mtable[machine].trampoline, imp_name_lab);
+  if (HOW_SEH)
+    fprintf (f, "\t.seh_endproc\n");
 
   /* Output the delay import descriptor */
   fprintf (f, "\n%s DELAY_IMPORT_DESCRIPTOR\n", ASM_C);
-- 
2.29.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* (ping) [PATCH 1/2] dlltool: Make x86_64 delay-load trampoline SEH-compatible.
  2020-12-09  1:22 [PATCH 1/2] dlltool: Make x86_64 delay-load trampoline SEH-compatible Zebediah Figura
  2020-12-09  1:22 ` [PATCH 2/2] dlltool: Add SEH annotations to the x86_64 delay-load trampoline Zebediah Figura
@ 2021-01-11 22:46 ` Zebediah Figura
  2021-01-13 10:57   ` Nick Clifton
  1 sibling, 1 reply; 5+ messages in thread
From: Zebediah Figura @ 2021-01-11 22:46 UTC (permalink / raw)
  To: binutils

Pinging this patch set again due to lack of review.

On 12/8/20 7:22 PM, Zebediah Figura wrote:
> 	binutils/
> 		* dlltool.c: Adjust %rsp immediately on entry and
> 		before exit.
> ---
>  binutils/dlltool.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/binutils/dlltool.c b/binutils/dlltool.c
> index ed016b97dc..ccba665262 100644
> --- a/binutils/dlltool.c
> +++ b/binutils/dlltool.c
> @@ -570,19 +570,19 @@ static const char i386_trampoline[] =
>    "\tjmp *%%eax\n";
>  
>  static const char i386_x64_trampoline[] =
> -  "\tpushq %%rcx\n"
> -  "\tpushq %%rdx\n"
> -  "\tpushq %%r8\n"
> -  "\tpushq %%r9\n"
> -  "\tsubq  $40, %%rsp\n"
> +  "\tsubq $72, %%rsp\n"
> +  "\tmovq %%rcx, 64(%%rsp)\n"
> +  "\tmovq %%rdx, 56(%%rsp)\n"
> +  "\tmovq %%r8, 48(%%rsp)\n"
> +  "\tmovq %%r9, 40(%%rsp)\n"
>    "\tmovq  %%rax, %%rdx\n"
>    "\tleaq  __DELAY_IMPORT_DESCRIPTOR_%s(%%rip), %%rcx\n"
>    "\tcall __delayLoadHelper2\n"
> -  "\taddq  $40, %%rsp\n"
> -  "\tpopq %%r9\n"
> -  "\tpopq %%r8\n"
> -  "\tpopq %%rdx\n"
> -  "\tpopq %%rcx\n"
> +  "\tmovq 40(%%rsp), %%r9\n"
> +  "\tmovq 48(%%rsp), %%r8\n"
> +  "\tmovq 56(%%rsp), %%rdx\n"
> +  "\tmovq 64(%%rsp), %%rcx\n"
> +  "\taddq $72, %%rsp\n"
>    "\tjmp *%%rax\n";
>  
>  struct mac
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: (ping) [PATCH 1/2] dlltool: Make x86_64 delay-load trampoline SEH-compatible.
  2021-01-11 22:46 ` (ping) [PATCH 1/2] dlltool: Make x86_64 delay-load trampoline SEH-compatible Zebediah Figura
@ 2021-01-13 10:57   ` Nick Clifton
  2021-01-13 15:17     ` Zebediah Figura
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Clifton @ 2021-01-13 10:57 UTC (permalink / raw)
  To: Zebediah Figura, binutils

Hi Zebediah,

> Pinging this patch set again due to lack of review.

Sorry - mega busy right now.  Anyway...

>> 	binutils/
>> 		* dlltool.c: Adjust %rsp immediately on entry and
>> 		before exit.

> binutils/
> 		PR 27037
> 		* dlltool.c: Add SEH annotations to i386_x64_trampoline.

Both of these are approved and have been applied.

Cheers
   Nick

  


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: (ping) [PATCH 1/2] dlltool: Make x86_64 delay-load trampoline SEH-compatible.
  2021-01-13 10:57   ` Nick Clifton
@ 2021-01-13 15:17     ` Zebediah Figura
  0 siblings, 0 replies; 5+ messages in thread
From: Zebediah Figura @ 2021-01-13 15:17 UTC (permalink / raw)
  To: Nick Clifton, binutils

On 1/13/21 4:57 AM, Nick Clifton wrote:
> Hi Zebediah,
> 
>> Pinging this patch set again due to lack of review.
> 
> Sorry - mega busy right now.  Anyway...

No worries; thanks for reviewing it!

> 
>>> 	binutils/
>>> 		* dlltool.c: Adjust %rsp immediately on entry and
>>> 		before exit.
> 
>> binutils/
>> 		PR 27037
>> 		* dlltool.c: Add SEH annotations to i386_x64_trampoline.
> 
> Both of these are approved and have been applied.
> 
> Cheers
>    Nick
> 
>   
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-13 15:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09  1:22 [PATCH 1/2] dlltool: Make x86_64 delay-load trampoline SEH-compatible Zebediah Figura
2020-12-09  1:22 ` [PATCH 2/2] dlltool: Add SEH annotations to the x86_64 delay-load trampoline Zebediah Figura
2021-01-11 22:46 ` (ping) [PATCH 1/2] dlltool: Make x86_64 delay-load trampoline SEH-compatible Zebediah Figura
2021-01-13 10:57   ` Nick Clifton
2021-01-13 15:17     ` Zebediah Figura

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).