Missaligment during stack construction and destruction

Asked by Steve

Hi,

Iam using gcc for ARM version 5.4.1-2016-q3 and I have trouble when compiling with -Ofast and -mfpu=neon-vfpv4.

When entering a certain function in my software, gcc generates on function entry
FSTMDBD R13!, {D8-D9} to save some stack data into neon registers,
and on function exit when restoring, it generates
VST1.8 {D8, D9}, [R13@64]

However on certain calls of this function at the time of the restoring the stack pointer is not 8-byte aligned. This gives an exception of type 18 and the cpu crashes.

Compiler flags Iam using are
-fno-common -mcpu=cortex-a15 -mfpu=neon-vfpv4 -mtune=cortex-a15 -marm -mfloat-abi=hard -fno-exceptions -specs=rdimon.specs -ffast-math -pedantic-errors -g -gdwarf-3 -Ofast

Do you have any advice for me on this issue?

If you need more info let me know.

Thanks for your help in advance.

Steve

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Andre Vieira (andre-simoesdiasvieira) said :
#3

Hi Steve,

It sounds like there is some stack leakage going on there. The stack should be the same size after entering and before leaving a function AFAIK. Do you have a reduced testcase such that we can reproduce this?

Cheers,
Andre

Revision history for this message
Steve (skreyer) said :
#4

Hi Andre,

thanks a lot for the hint. Yes you're right stack size didn't change, its already missaligned on function entry.

I debugged a bit further and found that it looks like an ABI-compatibility problem. The function containing the mentioned assemblies is located in my application compiled with the mentioned gcc-version, but the caller is a library function of a framework which is compiled either with a somewhat older version of gcc (gcc-4.7-2012-q4) or even with a different compiler for ARM. However the caller seems to be responsible for the miss-alignment, it seems that it generates a stack pointer which is only 4-byte aligned on function entry.

Do you know if there was a change in the stack-alignment requirement of the ABI between both gcc-versions?

Thanks,
Steve

Can you help with this problem?

Provide an answer of your own, or ask Steve for more information if necessary.

To post a message you must log in.