This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to get 16-byte stack alignment in leaf functions
- From: Andrew Haley <aph at redhat dot com>
- To: Dave Allured - NOAA Affiliate <dave dot allured at noaa dot gov>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 11 Sep 2013 09:53:31 +0100
- Subject: Re: How to get 16-byte stack alignment in leaf functions
- Authentication-results: sourceware.org; auth=none
- References: <CALqwTFMA9B5FLOF_3CcDwAyyO8LYBoD=f9ErnD11qKdxbCqs0Q at mail dot gmail dot com> <522EE995 dot 5030901 at redhat dot com> <CALqwTFMvRAB4WyQPY6-R8JeGizjfS2j2kZ8uA=zUfa7za36DpA at mail dot gmail dot com>
On 09/10/2013 05:35 PM, Dave Allured - NOAA Affiliate wrote:
>> On 09/10/2013 01:21 AM, Dave Allured - NOAA Affiliate wrote:
>>> Hello, I am trying to create a dynamic library for
>>> x86_64-apple-darwin12 (Mac OS) with gcc 4.8.1. My source code
>>> includes some simple functions that I think are being identified as
>>> leaf functions. This works fine when compiling to a static library.
>>>
>>> However, when compiling to dynamic library (-dynamiclib etc.), seg
>>> fault results immediately on call from one of these leaf-like
>>> functions to another. GDB tells me that the stack becomes misaligned
>>> in the calling function, and the actual seg fault happens within a
>>> dynamic loader stub function. The simplified message from GDB is:
>>>
>>> misaligned_stack_error_entering_dyld_stub_binder
>>>
> On Tue, Sep 10, 2013 at 3:42 AM, Andrew Haley <aph@redhat.com> wrote:
>> What is the faulting instruction?
>>
>> x/i $pc
>
> movdqa, an SSE instruction that requires 16-byte alignment. This is
> about a dozen instructions within the dynamic loader.
OK, that makes sense. Now, a leaf function cannot call a function: so,
what is the assembly code of the "leaf-like" function makinf th ecall?
Andrew.