Invalid work with floating point if stack is not aligned to 8 bytes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I check it for RM46L852 chip, with software floating point support.
#include <stdio.h>
int main()
{
float f = 0.000187F;
char buf[100];
snprintf(buf, 100, "%f %f", f, (int)(f * 1e6f));
return 0;
}
If top of stack (at least before calling __libc_init() from my startup code) is not aligned to 8 bytes then buf will be invalid for both numbers.
If top of stack is aligned to 8 bytes then buf will be correct.
Bug is detected for v5.2 2015q4, v4.9 2015q1.
Compilation flags:
arm-none-eabi-gcc -Og -mcpu=cortex-r4f -marm -g -mfloat-abi=soft -fmessage-length=0 -fno-builtin -c -std=c99 main.cpp -o main.o
Linking flags:
arm-none-eabi-g++ -Og -mcpu=cortex-r4f -marm -g -mfloat-abi=soft -fmessage-length=0 -fno-builtin -Wl,-T,rom.lds -Wl,--gc-sections --specs=nosys.specs main.o sys_startup.o -o fw.elf
Changed in gcc-arm-embedded: | |
status: | New → Invalid |
Additional information. infocenter. arm.com/ help/topic/ com.arm. doc.ihi0046b/ IHI0046B_ ABI_Advisory_ 1.pdf
According to ARM documentation, SP must be aligned to 8 bytes for AAPCS and ABI. See http://
As I suppose code in newlib rely for 8-bytes alignment.
Is all calls in newlib done according to ARM ABI, AAPCS and 8-bytes alignment on stack? It seems that no.
Should I close this "bug"?