mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Issues building gdbserver with musl
Date: Sat, 10 Jun 2017 22:46:16 -0400	[thread overview]
Message-ID: <20170611024616.GW1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <20170605113127.270f0473@free-electrons.com>

On Mon, Jun 05, 2017 at 11:31:27AM +0200, Thomas Petazzoni wrote:
> Hello,
> 
> On Sat, 3 Jun 2017 18:50:59 -0400, mzpqnxow wrote:
> > FWIW, the following is the patch I came up with for PPC- it was very, very
> > short:
> > 
> > diff -Naur gdb-7.12/gdb/gdbserver/linux-ppc-low.c
> > gdb-7.12-ppc-patched/gdb/gdbserver/linux-ppc-low.c
> > --- gdb-7.12/gdb/gdbserver/linux-ppc-low.c 2016-08-01 11:50:20.000000000
> > -0400
> > +++ gdb-7.12-ppc-patched/gdb/gdbserver/linux-ppc-low.c 2017-05-15
> > 13:40:22.073884258 -0400
> > @@ -21,7 +21,9 @@
> >  #include "linux-low.h"
> > 
> >  #include <elf.h>
> > +#define __ASSEMBLY__
> >  #include <asm/ptrace.h>
> > +#undef __ASSEMBLY__
> 
> Can we upstream something like this? What is the explanation why musl
> needs such a patch and not glibc/uclibc?

Sorry for the delayed response. The reason is a historical mess. The
original intent of glibc was not to use kernel headers to define
things the libc headers need to provide, but to do their own
definitions for everything (like musl always does). But some poorly
maintained archs (that were originally maintained out-of-tree) ignored
this rule/intent and did things the old (libc5) way, using the kernel
headers.

In order to provide an API matching what glibc exposes, musl defines
pt_regs etc. in the powerpc sys/user.h. (Compare this to something
like the arm version, which has non-overlapping names.) But this
breaks if you also include the kernel header that defines pt_regs.

I'm not sure what the right solution is; there really is no good one.
Ideally musl and glibc would agree the problem needs to be fixed and
change user.h to provide definitions with new names that don't clash
with the kernel, and fix glibc's use of kernel headers. But then
applications (basically just gdb) would need to be fixed to use the
new names.

Another possible solution would be removing sys/user.h and other "just
for gdb cruft" from musl and providing it in a separate package that
depends (for some archs) on kernel headers. Or we could do something
really nasty and just say "on broken archs X, Y, and Z, sys/user.h and
other cruft headers depend on kernel headers, just like on glibc".

I'm not really sure what's best to do; that's why there's been no
progress on this issue, despite it being known and longstanding.

Rich


  reply	other threads:[~2017-06-11  2:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-03 14:14 Thomas Petazzoni
2017-06-03 14:34 ` Khem Raj
2017-06-03 17:19   ` mzpqnxow
2017-06-03 20:14     ` Thomas Petazzoni
2017-06-03 20:13   ` Thomas Petazzoni
2017-06-03 22:50   ` mzpqnxow
2017-06-05  9:31     ` Thomas Petazzoni
2017-06-11  2:46       ` Rich Felker [this message]
2017-06-11 22:37         ` A. Wilcox

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=20170611024616.GW1627@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).