This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] powerpc: add crt files
On Wed, Feb 8, 2012 at 12:50 PM, Ryan S. Arnold <ryan.arnold@gmail.com> wrote:
> On Wed, Feb 8, 2012 at 12:18 PM, Ryan S. Arnold <ryan.arnold@gmail.com> wrote:
>> On Wed, Feb 8, 2012 at 12:12 PM, Roland McGrath <roland@hack.frob.com> wrote:
>>>> + Â Â .section .init,"ax",@progbits
>>>> + Â Â .align Â2
>>>
>>> Let's stick to .p2align or .balign to make things clearer.
>>>
>>>> +_init:
>>>> + Â Â stwu r1, -16(r1)
>>>> + Â Â mflr r0
>>>> + Â Â stw r0, 20(r1)
>>>> + Â Â stw r30, 8(r1)
>>>
>>> I don't really know ppc code, but this looks like it's setting up a frame
>>> pointer. ÂIs that really necessary?
>>>
>>>
>>> Thanks,
>>> Roland
>>
>> We're taking a look at this exact thing right now.
>
> The stwu r1, -16(r1) does indeed stack a frame. ÂStacking a frame is
> required for non-leaf functions in the 32-bit PPC ABI.
>
> The stw r0, 20(r1) is saving the LR to the previous frame's LR Save slot.
>
> The stw r30,8(r1) is saving the general-purpose register r30, which is
> marked as a non-volatile (and therefore must be saved prior to
> branch), to the register save area.
>
> So yes this sequence is necessary.
>
> We're looking at a difference in the version generated for Power7
> where the frame size is 32 bytes before I ack this.
Adhemerval noticed that when the old initfini.c code was built for
power6 and power7 the stacked frame was 32-bytes instead of 16-bytes.
We were wondering if this was a concern (the difference) since all
POWER machines will use these (32-bit/64-bit) unified crti.S files.
In the presence of -maltivec (as implied by -mcpu=power6 and
-mcpu=power7), ".gnu_attribute 8,2" is emitted (indicating conformance
to the Power Vector ABI) and a 32-byte frame is the default, since a
non-leaf function _might_ spill a vector register to the stack (which
would require 16-byte alignment).
As far as we can tell this is just precautionary behavior on the part
of the compiler and it doesn't actually check to see if VRs are used
in the function prior to the branch.
So Andreas's patch should work just fine.
Ryan S. Arnold