qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PULL 02/26] linux-user: Support stack-grows-up in elfl


From: Peter Maydell
Subject: Re: [Qemu-devel] [PULL 02/26] linux-user: Support stack-grows-up in elfload.c
Date: Tue, 27 Jun 2017 17:32:57 +0100

On 23 January 2017 at 02:17, Richard Henderson <address@hidden> wrote:
> HPPA is a (the) stack-grows-up target, and supporting that requires
> rearranging how we compute addresses while laying out the initial
> program stack.  In addition, hppa32 requires 64-byte stack alignment
> so parameterize that as well.

>  #define NEW_AUX_ENT(id, val) do {               \
> -        sp -= n; put_user_ual(val, sp);         \
> -        sp -= n; put_user_ual(id, sp);          \
> +        put_user_ual(id, u_auxv);  u_auxv += n; \
> +        put_user_ual(val, u_auxv); u_auxv += n; \
>      } while(0)

I've just noticed that this change breaks powerpc32, because now
we fill in the auxv starting at the lowest address and working
up, rather than starting at the highest address and working down.
powerpc32 needs some magic values at the lowest address, which
we deal with in ARCH_DLINFO. So now we need to invoke ARCH_DLINFO
first, rather than last (the kernel also fills auxv in from
low to high and invokes ARCH_DLINFO first). The PPC ARCH_DLINFO
also needs to have its entries reversed so the AT_IGNOREPPC
entries come first (lowest address).

The effect of this bug is that my ppc test program
(which is one of the ones in the ancient collection on the
wiki: http://wiki.qemu.org/download/linux-user-test-0.3.tar.gz )
segfaults on startup if the environment is the wrong size:

e104462:xenial:linux-user-test-0.3$ X=1
/home/petmay01/linaro/qemu-for-merges/build/all-linux-static/ppc-linux-user/qemu-ppc
-L ./gnemul/qemu-ppc ppc/ls -l dummyfile
-rw-r--r--    1 petmay01 petmay01        0 Nov 12  2007 dummyfile
e104462:xenial:linux-user-test-0.3$ X=1 Y=1
/home/petmay01/linaro/qemu-for-merges/build/all-linux-static/ppc-linux-user/qemu-ppc
-L ./gnemul/qemu-ppc ppc/ls -l dummyfile
-rw-r--r--    1 petmay01 petmay01        0 Nov 12  2007 dummyfile
e104462:xenial:linux-user-test-0.3$ X=1 Y=1 Z=1
/home/petmay01/linaro/qemu-for-merges/build/all-linux-static/ppc-linux-user/qemu-ppc
-L ./gnemul/qemu-ppc ppc/ls -l dummyfile
-rw-r--r--    1 petmay01 petmay01        0 Nov 12  2007 dummyfile
e104462:xenial:linux-user-test-0.3$ X=1 Y=1 Z=1 A=1
/home/petmay01/linaro/qemu-for-merges/build/all-linux-static/ppc-linux-user/qemu-ppc
-L ./gnemul/qemu-ppc ppc/ls -l dummyfile
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault (core dumped)
e104462:xenial:linux-user-test-0.3$ X=1 Y=1 Z=1 A=1 B=1
/home/petmay01/linaro/qemu-for-merges/build/all-linux-static/ppc-linux-user/qemu-ppc
-L ./gnemul/qemu-ppc ppc/ls -l dummyfile
-rw-r--r--    1 petmay01 petmay01        0 Nov 12  2007 dummyfile

(exactly which 1 out of 4 will fail for you will depend
on the size of your environment, etc, obviously.)

Newer ppc binaries which have glibc versions that dropped
that attempt to handle alignment won't trip over this,
only older ones.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]