This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to get 16-byte stack alignment in leaf functions


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]