Re: [Mingw-w64-public] [PATCH] headers: Define IMAGE_FILE_MACHINE_ARM64

2018-04-12 Thread Martin Storsjö

On Wed, 11 Apr 2018, JonY via Mingw-w64-public wrote:


On 04/11/2018 09:30 PM, Martin Storsjö wrote:

Signed-off-by: Martin Storsjö 
---
 mingw-w64-headers/include/winnt.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mingw-w64-headers/include/winnt.h 
b/mingw-w64-headers/include/winnt.h
index 878cdc3..45718c3 100644
--- a/mingw-w64-headers/include/winnt.h
+++ b/mingw-w64-headers/include/winnt.h
@@ -6037,6 +6037,7 @@ __buildmemorybarrier()
 #define IMAGE_FILE_MACHINE_ARM 0x01c0
 #define IMAGE_FILE_MACHINE_ARMV7 0x01c4
 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
+#define IMAGE_FILE_MACHINE_ARM64 0xaa64
 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
 #define IMAGE_FILE_MACHINE_AM33 0x01d3
 #define IMAGE_FILE_MACHINE_POWERPC 0x01F0



Patch looks good to me.


Thanks, pushed!

// Martin
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] setjmp: Provide a manual implementation for arm and arm64 (fwd)

2018-04-12 Thread André Hentschel
Am 11.04.2018 um 22:38 schrieb Martin Storsjö:
> Hi André,
> 
> Can you review this patch I sent to mingw-w64 yesterday? (I don't think many 
> others are going to give it much comments.)
> 
> The arm32 implementation is based on your code from wine (I hope that's ok 
> with you license-wise), while the arm64 one, also from wine, is one that I 
> wrote.
> 
> // Martin
> 
> -- Forwarded message --
> Date: Tue, 10 Apr 2018 22:52:03 +0300
> From: Martin Storsjö 
> To: mingw-w64-public@lists.sourceforge.net
> Cc: Martin Storsjö 
> Subject: [PATCH] setjmp: Provide a manual implementation for arm and arm64
> 
> On arm and arm64, the setjmp/longjmp implementations (in both msvcrt.dll
> and ucrtbase.dll) require binaries to have proper SEH information. On
> arm, we can get around this by passing NULL as the frame/ctx parameter
> to _setjmp, but that doesn't work on arm64.
> 
> Work around it by providing a custom implementation of the functions
> in libmingwex instead.
> 
> Signed-off-by: Martin Storsjö 
> ---
>  mingw-w64-crt/misc/mingw_getsp.S | 99 
> 
>  mingw-w64-headers/crt/setjmp.h   |  4 ++
>  2 files changed, 103 insertions(+)
> 
> diff --git a/mingw-w64-crt/misc/mingw_getsp.S 
> b/mingw-w64-crt/misc/mingw_getsp.S
> index 97510c8..5d224d1 100644
> --- a/mingw-w64-crt/misc/mingw_getsp.S
> +++ b/mingw-w64-crt/misc/mingw_getsp.S
> @@ -51,3 +51,102 @@ __MINGW_USYMBOL(longjmp):
>    jmp *__imp__longjmp
>  #endif
>  #endif /* !(defined(_ARM_) || defined(__arm__)) */
> +
> +#if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || 
> defined(__aarch64__)
> +    .globl __MINGW_USYMBOL(__mingw_setjmp)
> +    .def    __MINGW_USYMBOL(__mingw_setjmp);    .scl    2;    .type    32;   
>  .endef
> +__MINGW_USYMBOL(__mingw_setjmp):
> +#if defined(_ARM_) || defined(__arm__)
> +    mov r1,  #0
> +    str r1,  [r0]    /* jmp_buf->Frame */
> +    str r4,  [r0, #0x4]  /* jmp_buf->R4 */
> +    str r5,  [r0, #0x8]  /* jmp_buf->R5 */
> +    str r6,  [r0, #0xc]  /* jmp_buf->R6 */
> +    str r7,  [r0, #0x10] /* jmp_buf->R7 */
> +    str r8,  [r0, #0x14] /* jmp_buf->R8 */
> +    str r9,  [r0, #0x18] /* jmp_buf->R9 */
> +    str r10, [r0, #0x1c] /* jmp_buf->R10 */
> +    str r11, [r0, #0x20] /* jmp_buf->R11 */
> +    str sp,  [r0, #0x24] /* jmp_buf->Sp */
> +    str lr,  [r0, #0x28] /* jmp_buf->Pc */
> +    vmrs    r2,  fpscr
> +    str r2,  [r0, #0x2c] /* jmp_buf->Fpscr */
> +    vstr    d8,  [r0, #0x30] /* jmp_buf->D[0] */
> +    vstr    d9,  [r0, #0x38] /* jmp_buf->D[1] */
> +    vstr    d10, [r0, #0x40] /* jmp_buf->D[2] */
> +    vstr    d11, [r0, #0x48] /* jmp_buf->D[3] */
> +    vstr    d12, [r0, #0x50] /* jmp_buf->D[4] */
> +    vstr    d13, [r0, #0x58] /* jmp_buf->D[5] */
> +    vstr    d14, [r0, #0x60] /* jmp_buf->D[6] */
> +    vstr    d15, [r0, #0x68] /* jmp_buf->D[7] */
> +    mov r0,  #0
> +    bx  lr
> +#elif defined(_ARM64_) || defined(__aarch64__)
> +    str xzr, [x0] /* jmp_buf->Frame */
> +    stp x19, x20, [x0, #0x10] /* jmp_buf->X19, X20 */
> +    stp x21, x22, [x0, #0x20] /* jmp_buf->X21, X22 */
> +    stp x23, x24, [x0, #0x30] /* jmp_buf->X23, X24 */
> +    stp x25, x26, [x0, #0x40] /* jmp_buf->X25, X26 */
> +    stp x27, x28, [x0, #0x50] /* jmp_buf->X27, X28 */
> +    stp x29, x30, [x0, #0x60] /* jmp_buf->Fp,  Lr  */
> +    mov x2,  sp
> +    str x2,   [x0, #0x70] /* jmp_buf->Sp */
> +    mrs x2,  fpcr
> +    str w2,   [x0, #0x78] /* jmp_buf->Fpcr */
> +    mrs x2,  fpsr
> +    str w2,   [x0, #0x7c] /* jmp_buf->Fpsr */
> +    stp d8,  d9,  [x0, #0x80] /* jmp_buf->D[0-1] */
> +    stp d10, d11, [x0, #0x90] /* jmp_buf->D[2-3] */
> +    stp d12, d13, [x0, #0xa0] /* jmp_buf->D[4-5] */
> +    stp d14, d15, [x0, #0xb0] /* jmp_buf->D[6-7] */
> +    mov x0,  #0
> +    ret
> +#endif
> +
> +    .globl __MINGW_USYMBOL(__mingw_longjmp)
> +    .def    __MINGW_USYMBOL(__mingw_longjmp);    .scl    2;    .type    32;  
>   .endef
> +__MINGW_USYMBOL(__mingw_longjmp):
> +#if defined(_ARM_) || defined(__arm__)
> +    ldr r4,  [r0, #0x4]  /* jmp_buf->R4 */
> +    ldr r5,  [r0, #0x8]  /* jmp_buf->R5 */
> +    ldr r6,  [r0, #0xc]  /* jmp_buf->R6 */
> +    ldr r7,  [r0, #0x10] /* jmp_buf->R7 */
> +    ldr r8,  [r0, #0x14] /* jmp_buf->R8 */
> +    ldr r9,  [r0, #0x18] /* jmp_buf->R9 */
> +    ldr r10, [r0, #0x1c] /* jmp_buf->R10 */
> +    ldr r11, [r0, #0x20] /* jmp_buf->R11 */
> +    ldr sp,  [r0, #0x24] /* jmp_buf->Sp */
> +    ldr r2,  [r0, #0x28] /* jmp_buf->Pc */
> +    ldr r3,  [r0, #0x2c] /* jmp_buf->Fpscr */
> +    vmsr    fpscr, r3
> +    vldr    d8,  [r0, #0x30] /* jmp_buf->D[0] */
> + 

Re: [Mingw-w64-public] [PATCH] setjmp: Provide a manual implementation for arm and arm64 (fwd)

2018-04-12 Thread Martin Storsjö

On Thu, 12 Apr 2018, André Hentschel wrote:


Am 11.04.2018 um 22:38 schrieb Martin Storsjö:

Hi André,

Can you review this patch I sent to mingw-w64 yesterday? (I don't think many 
others are going to give it much comments.)

The arm32 implementation is based on your code from wine (I hope that's ok with 
you license-wise), while the arm64 one, also from wine, is one that I wrote.

// Martin

-- Forwarded message --
Date: Tue, 10 Apr 2018 22:52:03 +0300
From: Martin Storsjö 
To: mingw-w64-public@lists.sourceforge.net
Cc: Martin Storsjö 
Subject: [PATCH] setjmp: Provide a manual implementation for arm and arm64

On arm and arm64, the setjmp/longjmp implementations (in both msvcrt.dll
and ucrtbase.dll) require binaries to have proper SEH information. On
arm, we can get around this by passing NULL as the frame/ctx parameter
to _setjmp, but that doesn't work on arm64.

Work around it by providing a custom implementation of the functions
in libmingwex instead.

Signed-off-by: Martin Storsjö 
---
 mingw-w64-crt/misc/mingw_getsp.S | 99 
 mingw-w64-headers/crt/setjmp.h   |  4 ++
 2 files changed, 103 insertions(+)

diff --git a/mingw-w64-crt/misc/mingw_getsp.S b/mingw-w64-crt/misc/mingw_getsp.S
index 97510c8..5d224d1 100644
--- a/mingw-w64-crt/misc/mingw_getsp.S
+++ b/mingw-w64-crt/misc/mingw_getsp.S
@@ -51,3 +51,102 @@ __MINGW_USYMBOL(longjmp):
   jmp *__imp__longjmp
 #endif
 #endif /* !(defined(_ARM_) || defined(__arm__)) */
+
+#if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || 
defined(__aarch64__)
+    .globl __MINGW_USYMBOL(__mingw_setjmp)
+    .def    __MINGW_USYMBOL(__mingw_setjmp);    .scl    2;    .type    32;    
.endef
+__MINGW_USYMBOL(__mingw_setjmp):
+#if defined(_ARM_) || defined(__arm__)
+    mov r1,  #0
+    str r1,  [r0]    /* jmp_buf->Frame */
+    str r4,  [r0, #0x4]  /* jmp_buf->R4 */
+    str r5,  [r0, #0x8]  /* jmp_buf->R5 */
+    str r6,  [r0, #0xc]  /* jmp_buf->R6 */
+    str r7,  [r0, #0x10] /* jmp_buf->R7 */
+    str r8,  [r0, #0x14] /* jmp_buf->R8 */
+    str r9,  [r0, #0x18] /* jmp_buf->R9 */
+    str r10, [r0, #0x1c] /* jmp_buf->R10 */
+    str r11, [r0, #0x20] /* jmp_buf->R11 */
+    str sp,  [r0, #0x24] /* jmp_buf->Sp */
+    str lr,  [r0, #0x28] /* jmp_buf->Pc */
+    vmrs    r2,  fpscr
+    str r2,  [r0, #0x2c] /* jmp_buf->Fpscr */
+    vstr    d8,  [r0, #0x30] /* jmp_buf->D[0] */
+    vstr    d9,  [r0, #0x38] /* jmp_buf->D[1] */
+    vstr    d10, [r0, #0x40] /* jmp_buf->D[2] */
+    vstr    d11, [r0, #0x48] /* jmp_buf->D[3] */
+    vstr    d12, [r0, #0x50] /* jmp_buf->D[4] */
+    vstr    d13, [r0, #0x58] /* jmp_buf->D[5] */
+    vstr    d14, [r0, #0x60] /* jmp_buf->D[6] */
+    vstr    d15, [r0, #0x68] /* jmp_buf->D[7] */
+    mov r0,  #0
+    bx  lr
+#elif defined(_ARM64_) || defined(__aarch64__)
+    str xzr, [x0] /* jmp_buf->Frame */
+    stp x19, x20, [x0, #0x10] /* jmp_buf->X19, X20 */
+    stp x21, x22, [x0, #0x20] /* jmp_buf->X21, X22 */
+    stp x23, x24, [x0, #0x30] /* jmp_buf->X23, X24 */
+    stp x25, x26, [x0, #0x40] /* jmp_buf->X25, X26 */
+    stp x27, x28, [x0, #0x50] /* jmp_buf->X27, X28 */
+    stp x29, x30, [x0, #0x60] /* jmp_buf->Fp,  Lr  */
+    mov x2,  sp
+    str x2,   [x0, #0x70] /* jmp_buf->Sp */
+    mrs x2,  fpcr
+    str w2,   [x0, #0x78] /* jmp_buf->Fpcr */
+    mrs x2,  fpsr
+    str w2,   [x0, #0x7c] /* jmp_buf->Fpsr */
+    stp d8,  d9,  [x0, #0x80] /* jmp_buf->D[0-1] */
+    stp d10, d11, [x0, #0x90] /* jmp_buf->D[2-3] */
+    stp d12, d13, [x0, #0xa0] /* jmp_buf->D[4-5] */
+    stp d14, d15, [x0, #0xb0] /* jmp_buf->D[6-7] */
+    mov x0,  #0
+    ret
+#endif
+
+    .globl __MINGW_USYMBOL(__mingw_longjmp)
+    .def    __MINGW_USYMBOL(__mingw_longjmp);    .scl    2;    .type    32;    
.endef
+__MINGW_USYMBOL(__mingw_longjmp):
+#if defined(_ARM_) || defined(__arm__)
+    ldr r4,  [r0, #0x4]  /* jmp_buf->R4 */
+    ldr r5,  [r0, #0x8]  /* jmp_buf->R5 */
+    ldr r6,  [r0, #0xc]  /* jmp_buf->R6 */
+    ldr r7,  [r0, #0x10] /* jmp_buf->R7 */
+    ldr r8,  [r0, #0x14] /* jmp_buf->R8 */
+    ldr r9,  [r0, #0x18] /* jmp_buf->R9 */
+    ldr r10, [r0, #0x1c] /* jmp_buf->R10 */
+    ldr r11, [r0, #0x20] /* jmp_buf->R11 */
+    ldr sp,  [r0, #0x24] /* jmp_buf->Sp */
+    ldr r2,  [r0, #0x28] /* jmp_buf->Pc */
+    ldr r3,  [r0, #0x2c] /* jmp_buf->Fpscr */
+    vmsr    fpscr, r3
+    vldr    d8,  [r0, #0x30] /* jmp_buf->D[0] */
+    vldr    d9,  [r0, #0x38] /* jmp_buf->D[1] */
+    vldr    d10, [r0, #0x40] /* jmp_buf->D[2] */
+    vldr    d11, [r0, #0x48] /* jmp_buf->D[3] */
+    vldr    d12, [r0, 

Re: [Mingw-w64-public] Bad DWARF info?

2018-04-12 Thread Tom Ritter
Okay, I've been digging into this and have more information.  I have a
few things I'm going to try, but any insight into what might be
happening or why or other things to try would be greatly appreciated.

The DWARF data is definitely bad.  Specifically the offset into the
.debug_abbrev section is wrong.
https://ritter.vg/misc/stuff/dwarf-error.html shows the details.

I did more more analysis into the bad sections here:
https://ritter.vg/misc/stuff/dwarf-error-2.html

The bad sections fall into two categories:
1) Stuff in Firefox we produce with yasm.  I don't know why this is,
but I think it's coming from
https://dxr.mozilla.org/mozilla-central/source/python/mozbuild/mozbuild/frontend/context.py#375
so I'm going to try and just remove debug information for this stuff

2) Stuff from mingw-w64, specifically mingw-w64-crt and winpthreads.
I have no idea why these files are producing DWARF version 2 debugging
information or why the offsets are corrupted.

-tom

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public