Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Jan 2016 18:32:38 -0800
From:      Mark Millard <markmi@dsl-only.net>
To:        Justin Hibbits <chmeeedalf@gmail.com>
Cc:        Roman Divacky <rdivacky@vlakno.cz>, Nathan Whitehorn <nwhitehorn@freebsd.org>, FreeBSD Toolchain <freebsd-toolchain@freebsd.org>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>
Subject:   Re: 3 quick questions about stack alignment for powerpc (32-bit) signal handlers
Message-ID:  <70A66DFD-557A-4D82-813C-05EED6EAB089@dsl-only.net>
In-Reply-To: <E591AEFA-8BB0-4CD2-BD29-5B7D6C8F6D91@gmail.com>
References:  <517B7923-5166-42D0-8FA8-52C05F956F06@dsl-only.net> <20160131140807.GA83147@vlakno.cz> <0716BE3E-B7D1-4A10-B011-C1F0245296E7@dsl-only.net> <E591AEFA-8BB0-4CD2-BD29-5B7D6C8F6D91@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
[I've never noticed gcc 4.2.1 generating code that was based on =
presuming the alignment was present. For example: it always seems to use =
addition to deal with address offsets, never masking. So I'd not expect =
to see segmentation faults for that context even when the stack is =
aligned modulo only 4. Separately checking the alignment is appropriate =
for me to do.]

A) The reported context:

The kernel context here is a gcc 4.2.1 based buildkernel then =
installkernel.
The world context here is a clang 3.8.0 based buildworld then =
installworld.
The program context here is a clang 3.8.0 based:

> # clang -std=3Dc11 -Wall -Wpedantic sig_snprintf_use_test.c
> # /usr/local/bin/gdb a.out


Using "break handler" in gdb (7.10_5) and using "info frame" when it =
stops for the "raise" shows the misalignment of the frame that the =
handler was given ny the signal delivery.

By contrast the earlier direct call of the handler gets a "info frame" =
result that shows the expected sort of alignment.

I find no evidence of frame/stack misalignment via gdb except for the =
one that is created by the signal delivery.


B) I'll look at trying one or more of gcc 4.2.1, gcc49, gcc5 for the =
program context, still based on a clang 3.8.0 buildworld and gcc 4.2.1 =
buildkernel based on projects/clang380-import (-r294962).

C) I will look at trying the same program builds on a pure gcc 4.2.1 =
buildworld/buildkernel context. (Likely 11.0-CURRENT -r294960.)


I'll send more results when I have them.






=3D=3D=3D
Mark Millard
markmi at dsl-only.net

On 2016-Jan-31, at 5:50 PM, Justin Hibbits <chmeeedalf at gmail.com> =
wrote:

Does this occur with gcc-built world and/or kernel?  You could put some =
printf()s in sendsig(), and there are KTR tracepoints already present.  =
The code assumes a fully aligned user stack, which should be correct, =
but may not be.

- Justin
On Jan 31, 2016, at 6:41 PM, Mark Millard wrote:

> I have submitted Bug 206810 for this 11.0-CURRENT/clang380-import =
stack alignment problem for TARGET_ARCH=3Dpowerpc signal delivery.
>=20
> =3D=3D=3D
> Mark Millard
> markmi at dsl-only.net
>=20
> On 2016-Jan-31, at 6:08 AM, Roman Divacky <rdivacky at vlakno.cz> =
wrote:
>=20
> Fwiw, LLVM expect 16B aligned stack on PowerPC.
>=20
> On Sun, Jan 31, 2016 at 05:55:20AM -0800, Mark Millard wrote:
>> 3 quick FreeBSD for powerpc (32-bit) questions:
>>=20
>>=20
>> A) For PowerPC (32-bit) what is the stack alignment requirement by =
the ABI(s) that FreeBSD targets?
>>=20
>> B) Are signal handlers supposed to be given that alignment?
>>=20
>>=20
>> I ask because signal handlers are at times begin given just 4-byte =
alignment but clang 3.8.0 powerpc's code generation can depend on the =
alignment being more than 4.
>>=20
>> clang 3.8.0 can calculate addresses by, for example, masking in a 0x4 =
relative to what would need to be an aligned address with alignment 8 or =
more instead of adding 0x4 to a more arbitrary address.
>>=20
>> So far I've only seen less than 8 byte stack alignment via signal =
handler activity.
>>=20
>>=20
>> C) Which should be blamed for problems here: clang's code generation, =
FreeBSD's stack alignment handling for signals, or both?
>>=20
>> =3D=3D=3D
>> Mark Millard
>> markmi at dsl-only.net
>>=20
>> _______________________________________________
>> freebsd-toolchain@freebsd.org mailing list
>> https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
>> To unsubscribe, send any mail to =
"freebsd-toolchain-unsubscribe@freebsd.org"
>=20





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?70A66DFD-557A-4D82-813C-05EED6EAB089>