From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12530 Path: news.gmane.org!.POSTED!not-for-mail From: Matthias Schiffer Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] powerpc: make ucontext_t API match glibc Date: Wed, 21 Feb 2018 21:19:39 +0100 Message-ID: <0cba4a364a78622a9334e1768ceea73066d6ce4b.1519243731.git.mschiffer@universe-factory.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1519244283 12923 195.159.176.226 (21 Feb 2018 20:18:03 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 21 Feb 2018 20:18:03 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-12546-gllmg-musl=m.gmane.org@lists.openwall.com Wed Feb 21 21:17:59 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eoapw-0002lj-92 for gllmg-musl@m.gmane.org; Wed, 21 Feb 2018 21:17:56 +0100 Original-Received: (qmail 5510 invoked by uid 550); 21 Feb 2018 20:19:58 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 5475 invoked from network); 21 Feb 2018 20:19:57 -0000 X-Mailer: git-send-email 2.16.2 Xref: news.gmane.org gmane.linux.lib.musl.general:12530 Archived-At: 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: https://git.openwrt.org/?p=openwrt/staging/neoraider.git;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 -- 2.16.2