On 2018-01-21 00:47, Ben Hutchings wrote: > On Wed, 17 Jan 2018 12:31:06 +0100 Aurelien Jarno <aure...@debian.org> wrote: > [...] > > busybox is compiled with -mpreferred-stack-boundary=2 on i386 which has > > the same effect of reducing the default stack alignment from 16 bytes to > > 2 bytes. This comes from arch/i386/Makefile: > > The argument is the log2 of the alignment, so this sets alignment to 4 > bytes - which is compliant with the System V psABI for i386.
This is correct, but it is not compliant with the i386 GCC ABI which assumes the stack is 16-byte aligned (not just 4-byte aligned) when the call instruction in the caller was executed. > Any assumption of 16-byte stack alignment in glibc on i386 will break > not only busybox but most binaries built with old versions of gcc > (before 4.2, if the comment in busybox is correct). So this really > ought to be fixed there. The 16-byte stack alignment in glibc on i386 comes from a GCC 7 regression, reported as bug #887327. It has been fixed in the upstream gcc-7 branch in the mean time. > I think that any libraries that need to maintain backward binary > compatibility will need to be compiled with the option > -mincoming-stack-boundary=2. gcc will then fix up the stack alignment > in functions that need greater alignment for local variables. If we allow any binary to be built with -mpreferred-stack-boundary=2, we need to build *all* libraries with -mincoming-stack-boundary=2, not only the ones that need to maintain backward binary compatibility. In that case we should make it the default in GCC. Aurelien -- Aurelien Jarno GPG: 4096R/1DDD8C9B aurel...@aurel32.net http://www.aurel32.net
signature.asc
Description: PGP signature