GCC - How to realign stack?

前端 未结 5 781
广开言路
广开言路 2021-02-09 05:45

I try to build an application which uses pthreads and __m128 SSE type. According to GCC manual, default stack alignment is 16 bytes. In order to use __m128, the requirement is t

5条回答
  •  忘了有多久
    2021-02-09 06:26

    Sorry to resurrect an old thread...

    For those with a newer compiler than OP, OP mentions a -mstackrealign option, which lead me to __attribute__((force_align_arg_pointer)). If your function is being optimized to use SSE, but %ebp is misaligned, this will do the runtime fixes if required for you, transparently. I also found out that this is only an issue on i386. The x86_64 ABI guarantees the arguments are aligned to 16 bytes.

    __attribute__((force_align_arg_pointer)) void i_crash_when_not_aligned_to_16_bytes() { ... }

    Cool article for those who might want to learn more: http://wiki.osdev.org/System_V_ABI

提交回复
热议问题