mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: debugging problem with musl ld and qemu-ppc
Date: Thu, 16 Oct 2014 11:34:48 -0400	[thread overview]
Message-ID: <20141016153448.GY32028@brightrain.aerifal.cx> (raw)
In-Reply-To: <20141016060741.GA3707@euler>

On Thu, Oct 16, 2014 at 08:09:01AM +0200, Felix Janda wrote:
> Hello list,
> 
> can you maybe help me debugging the following problem with qemu-ppc?
> It gives an invalid instruction error after doing:
> 
> tar -xf crossx86-powerpc-linux-musl-0.9.9.tar.xz
> # (I get something similar for other versions of musl or gcc)
> cat > a.s <<EOF
> b	_GLOBAL_OFFSET_TABLE_@local
> EOF
> cat > b.c <<EOF
> int main(void) { return 0; }
> EOF
> ../powerpc-linux-musl/bin/powerpc-linux-musl-gcc -o good b.c
> ../powerpc-linux-musl/bin/powerpc-linux-musl-gcc -o bad a.s b.c
> # set up symlinks to make 'qemu-ppc good' work
> qemu-ppc bad
> 
> After musl ld has done its work it jumps to libgcc's _init and
> very soon tries to execute some data.
> 
> When executing in some chroot the 'qemu-ppc -d in_asm' for
> good and bad is exactly the same up to two instructions in
> libgcc until it diverges (and bad crashes).
> 
> Do you have any ideas what could be the problem?

Using the cross compiler I had lying around, I get a warning while
linking "bad":

/opt/powerpc-linux-musl/bin/../lib/gcc/powerpc-linux-musl/4.7.2/../../../../powerpc-linux-musl/bin/ld: bss-plt forced due to /tmp/ccfPiE1t.o

I suspect this is happening for you too (possibly without a warning
being printed?) and that this is the cause of the problem: something
about your asm file is forcing the linker to use the old "bss-plt"
dynamic linking model, which musl does not support, rather than the
"secure-plt" model.

The "bss-plt" model requires the dynamic linker to generate direct
call instructions inline in a writable (mode rwx!) page rather than
having the PLT thunks load their actual function addresses from
pointers filled into the GOT by the dynamic linker, so it's a major
risk from a security standpoint, and also a lot more work to implement
in the dynamic linker. As such, when powerpc support was added we
opted to omit this model and push for use of the more secure model
that works like every other arch.

What I'm not clear about is the cause for why the linker is forcing
you back to the bss-plt model. It might be a matter of the strange
relocation type you put in a.s:

00000000 <.text>:
   0:   48 00 00 00     b       0x0
                           0: R_PPC_LOCAL24PC      _GLOBAL_OFFSET_TABLE_

Let's see if anyone else has ideas.

Rich


  reply	other threads:[~2014-10-16 15:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-16  6:09 Felix Janda
2014-10-16 15:34 ` Rich Felker [this message]
2014-10-16 16:58   ` Felix Janda
2014-10-19 20:29     ` Felix Janda
2014-10-19 21:13       ` Rich Felker
2014-11-01 21:41         ` Felix Janda
2014-11-01 21:47           ` Rich Felker
2014-11-01 22:01             ` Felix Janda
2014-11-03 23:11               ` stephen Turner
2014-11-04 18:34                 ` Felix Janda
2014-10-17 19:30   ` Felix Janda
2014-10-17 20:17     ` Rich Felker
2014-10-17 21:15       ` Felix Janda

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=20141016153448.GY32028@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).