Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Wed, 21 Feb 2018 21:19:39 +0100
From: Matthias Schiffer <>
Subject: [PATCH] powerpc: make ucontext_t API match glibc

In glibc, ucontext_t's uc_mcontext contains the uc_regs field, pointing at
the actual mcontext_t at the end of the structure. Bring our definition in
line with what glibc does to allow builing libunwind.

Note that this fixes only one of the two problems arising when building
libunwind on PPC with musl. The other is that libunwind needs register
definitions from Linux's asm/ptrace.h, which is pulled in through
sys/user.h in glibc. As asm/ptrace.h contains a conflicting pt_regs
definition, I've patched this into libunwind itself now in my OpenWrt tree:;a=blob;f=package/libs/libunwind/patches/004-ppc-registers-musl.patch

 arch/powerpc/bits/signal.h  | 7 ++++---
 arch/powerpc/pthread_arch.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/bits/signal.h b/arch/powerpc/bits/signal.h
index 06efb11cf271..f842f5b82985 100644
--- a/arch/powerpc/bits/signal.h
+++ b/arch/powerpc/bits/signal.h
@@ -64,10 +64,11 @@ typedef struct __ucontext {
 	struct __ucontext *uc_link;
 	stack_t uc_stack;
 	int uc_pad[7];
-	mcontext_t *uc_regs;
+	struct {
+		mcontext_t *uc_regs;
+	} uc_mcontext;
 	sigset_t uc_sigmask;
-        int             uc_pad2[3];
-	mcontext_t uc_mcontext;
+	char uc_pad2[12 + sizeof(mcontext_t)];
 } ucontext_t;
 #define SA_NOCLDSTOP  1U
diff --git a/arch/powerpc/pthread_arch.h b/arch/powerpc/pthread_arch.h
index 7c5c4fadb211..8791ec5deb56 100644
--- a/arch/powerpc/pthread_arch.h
+++ b/arch/powerpc/pthread_arch.h
@@ -17,6 +17,6 @@ static inline struct pthread *__pthread_self()
 // the kernel calls the ip "nip", it's the first saved value after the 32
 // GPRs.
-#define MC_PC gregs[32]
+#define MC_PC uc_regs->gregs[32]
 #define CANARY canary_at_end

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.