From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] powerpc64: use a type for mcontext_t regs field
Date: Tue, 12 Feb 2019 12:23:38 -0500 [thread overview]
Message-ID: <20190212172338.GL23599@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAGWvnymxae_PEdG7OfG2Usv=SwrjNRdOaW46in+SsA8Tz-nWCg@mail.gmail.com>
On Tue, Feb 12, 2019 at 12:05:17PM -0500, David Edelsohn wrote:
> On Tue, Feb 12, 2019 at 11:18 AM Rich Felker <dalias@libc.org> wrote:
> >
> > On Tue, Feb 12, 2019 at 09:35:22AM -0600, A. Wilcox wrote:
> > > GCC Go dereferences `regs` for `nip`. Without this change, compilation
> > > fails with the following message:
> > >
> > > .../../../libgo/runtime/go-signal.c: In function ‘getSiginfo’:
> > > .../../../libgo/runtime/go-signal.c:225:56: warning: dereferencing ‘void *’ pointer
> > > ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip;
> > > ^~
> > > .../../../libgo/runtime/go-signal.c:225:56: error: request for member ‘nip’ in something not a structure or union
> > > ---
> > > arch/powerpc64/bits/signal.h | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/arch/powerpc64/bits/signal.h b/arch/powerpc64/bits/signal.h
> > > index 34693a68..6736c69a 100644
> > > --- a/arch/powerpc64/bits/signal.h
> > > +++ b/arch/powerpc64/bits/signal.h
> > > @@ -8,6 +8,8 @@
> > >
> > > #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
> > >
> > > +#include <bits/user.h>
> > > +
> >
> > This is almost surely not right. You can never use a bits/* header
> > except from the corresponding public header that includes it. They do
> > not have multiple-inclusion guards and are not designed to be usable
> > independently. And including sys/user.h is also almost surely wrong
> > since it's a problematic header you don't want getting included
> > (conflicts with linux/*.h stuff).
> >
> > > typedef unsigned long greg_t, gregset_t[48];
> > >
> > > typedef struct {
> > > @@ -29,7 +31,7 @@ typedef struct sigcontext {
> > > int _pad0;
> > > unsigned long handler;
> > > unsigned long oldmask;
> > > - void *regs;
> > > + struct pt_regs *regs;
> > > gregset_t gp_regs;
> > > fpregset_t fp_regs;
> > > vrregset_t *v_regs;
> > > --
> > > 2.19.2
> >
> > Do you know if there's a reason Go is trying to use this regs member
> > rather than gp_regs? I think that's the real issue here.
>
> Apparently GCCGo runtime has dependencies on GLibc and has not been
> ported to Musl Libc. The GCCGo runtime is trying to obtain the PC for
> a signal.
>
> #ifdef __PPC__
> #ifdef __linux__
> ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip;
> #endif
> #ifdef _AIX
> ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.jmp_context.iar;
> #endif
> #endif
>
> The program counter is not part of gp_regs.
Yes it is, as musl already depends on having access to the program
counter for thread cancellation. See arch/powerpc64/pthread_arch.h:
// the kernel calls the ip "nip", it's the first saved value after the 32
// GPRs.
#define MC_PC gp_regs[32]
Rich
next prev parent reply other threads:[~2019-02-12 17:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 15:35 A. Wilcox
2019-02-12 16:18 ` Rich Felker
2019-02-12 17:05 ` David Edelsohn
2019-02-12 17:23 ` Rich Felker [this message]
2019-02-12 18:17 ` David Edelsohn
2019-02-12 18:21 ` Rich Felker
2019-02-12 18:24 ` David Edelsohn
2019-02-12 18:32 ` Rich Felker
2019-02-12 18:36 ` A. Wilcox
2019-02-12 18:42 ` James Larrowe
2019-02-12 18:53 ` A. Wilcox
2019-02-12 18:48 ` David Edelsohn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190212172338.GL23599@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).