mono: fix build on ppc64-musl and ppc32

This commit is contained in:
q66 2019-12-13 23:01:29 +01:00
parent 5500a894c6
commit b70beb081e
2 changed files with 63 additions and 0 deletions

View file

@ -0,0 +1,33 @@
Musl does not include kernel headers.
Also, fix context handling for ppc32/musl.
--- mono/utils/mono-sigcontext.h
+++ mono/utils/mono-sigcontext.h
@@ -321,6 +321,8 @@ typedef struct ucontext {
#elif defined(__mono_ppc__)
+#include <asm/ptrace.h>
+
#if HAVE_UCONTEXT_H
#include <ucontext.h>
#endif
@@ -334,10 +336,17 @@ typedef struct ucontext {
#define UCONTEXT_REG_NIP(ctx) (((os_ucontext*)(ctx))->uc_mcontext.gp_regs [PT_NIP])
#define UCONTEXT_REG_LNK(ctx) (((os_ucontext*)(ctx))->uc_mcontext.gp_regs [PT_LNK])
#else
+#ifdef __GLIBC__
#define UCONTEXT_REG_Rn(ctx, n) (((os_ucontext*)(ctx))->uc_mcontext.uc_regs->gregs [(n)])
#define UCONTEXT_REG_FPRn(ctx, n) (((os_ucontext*)(ctx))->uc_mcontext.uc_regs->fpregs.fpregs [(n)])
#define UCONTEXT_REG_NIP(ctx) (((os_ucontext*)(ctx))->uc_mcontext.uc_regs->gregs [PT_NIP])
#define UCONTEXT_REG_LNK(ctx) (((os_ucontext*)(ctx))->uc_mcontext.uc_regs->gregs [PT_LNK])
+#else
+ #define UCONTEXT_REG_Rn(ctx, n) (((os_ucontext*)(ctx))->uc_mcontext.gregs [(n)])
+ #define UCONTEXT_REG_FPRn(ctx, n) (((os_ucontext*)(ctx))->uc_mcontext.fpregs.fpregs [(n)])
+ #define UCONTEXT_REG_NIP(ctx) (((os_ucontext*)(ctx))->uc_mcontext.gregs [PT_NIP])
+ #define UCONTEXT_REG_LNK(ctx) (((os_ucontext*)(ctx))->uc_mcontext.gregs [PT_LNK])
+#endif
#endif
#elif defined (__APPLE__) && defined (_STRUCT_MCONTEXT)
typedef struct __darwin_ucontext os_ucontext;

View file

@ -0,0 +1,30 @@
From 121928d29ac1e0aebb80531b3ebcca1a9ffcd618 Mon Sep 17 00:00:00 2001
From: Bernhard Urban-Forster <lewurm@gmail.com>
Date: Fri, 6 Dec 2019 11:35:11 +0100
Subject: [PATCH] [ppc32] delete leftover code from pre-monoctx area (#18072)
Also update assert which doesn't make sense since we have moved over to MonoContext
Some context: e7011c780f676914f559f14f25e76c192bb2b0b2
Fixes: https://github.com/mono/mono/issues/18064
---
mono/mini/exceptions-ppc.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/mono/mini/exceptions-ppc.c b/mono/mini/exceptions-ppc.c
index 44d09bcaba1d..d14f8383eba9 100644
--- mono/mini/exceptions-ppc.c
+++ mono/mini/exceptions-ppc.c
@@ -692,10 +692,7 @@ mono_arch_handle_altstack_exception (void *sigctx, MONO_SIG_HANDLER_INFO_TYPE *s
/* may need to adjust pointers in the new struct copy, depending on the OS */
uc_copy = (MonoContext*)(sp + 16);
mono_sigctx_to_monoctx (uc, uc_copy);
-#if defined(__linux__) && !defined(__mono_ppc64__)
- uc_copy->uc_mcontext.uc_regs = (gpointer)((char*)uc_copy + ((char*)uc->uc_mcontext.uc_regs - (char*)uc));
-#endif
- g_assert (mono_arch_ip_from_context (uc) == mono_arch_ip_from_context (uc_copy));
+ g_assert (mono_arch_ip_from_context (uc) == MONO_CONTEXT_GET_IP (uc_copy));
/* at the return form the signal handler execution starts in altstack_handle_and_restore() */
UCONTEXT_REG_LNK(uc) = UCONTEXT_REG_NIP(uc);
#ifdef PPC_USES_FUNCTION_DESCRIPTOR