]> git.ipfire.org Git - thirdparty/qemu.git/commit - linux-user/elfload.c
linux-user: Put PPC AT_IGNOREPPC auxv entries in the right place
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 27 Jun 2017 16:49:58 +0000 (17:49 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 29 Jun 2017 09:25:26 +0000 (10:25 +0100)
commit82991bed738783d68c9950840b2e98d84b9f0621
treed0d23e454fa4705eef7a89f032401ef821621f63
parent577caa2672ccde7352fda3ef17e44993de862f0e
linux-user: Put PPC AT_IGNOREPPC auxv entries in the right place

The 32-bit PPC auxv is a bit complicated because in the
mists of time it used to be 16-aligned rather than directly
after the environment. Older glibc versions had code to
try to probe for whether it needed alignment or not:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c;hb=e84eabb3871c9b39e59323bf3f6b98c2ca9d1cd0
and the kernel has code which puts some magic entries at
the bottom to ensure that the alignment probe fails:
http://elixir.free-electrons.com/linux/latest/source/arch/powerpc/include/asm/elf.h#L158

QEMU has similar code too, but it was broken by commit
7c4ee5bcc82e64, which changed elfload.c from filling in
the auxv starting at the highest address and working down
to starting at the lowest address and working up. This
means that the ARCH_DLINFO hook must now be invoked first
rather than last, and the entries in it for PPC must
be reversed so that the magic AT_IGNOREPPC entries come
at the lowest address in the auxv as they should.

The effect of this was that if running a guest binary that
used an old glibc with the alignment probing the guest ld.so
code would segfault if the size of the guest environment and
argv happened to put the auxv at an address that triggered
the alignment code in the guest glibc.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Tested-by: Richard Henderson <rth@twiddle.net>
Message-id: 1498582198-6649-1-git-send-email-peter.maydell@linaro.org
linux-user/elfload.c