When the option '--info stack' is added to the Linker, the generated linker map file contains stack usage for each function.One function written in C is not calculated correctly:The function repeatedly calls another function that returns a struct. For each call the stack usage in the map file increases when compiled with compiler version 6 (tested with 6.12, 6.15 and 6.20.1).Debugging through the function shows that R13(SP) is not increased after each call.This behavior is not if the compiler version 5 is used, or the file is in C++ (filename ending changed .cpp)Is there an error in the Linker? We need this value to check automatically if the stack size declared too small.
Examplecode:
#define NUM 300 struct a { union { float f; unsigned short us; } f2u; }; struct b { float sF; int i; }; static struct a arr[NUM]; static struct b foo(int x) { struct b ret; ret.sF = 1.F; ret.i = x; return ret; } void my_init(void) { int i = 0; arr[i].f2u.f = foo(1).sF; i++; arr[i].f2u.f = foo(12).sF; i++; arr[i].f2u.f = foo(71).sF; i++; arr[i].f2u.f = foo(42).sF; i++; arr[i].f2u.f = foo(13).sF; i++; arr[i].f2u.f = foo(1).sF; i++; arr[i].f2u.f = foo(12).sF; i++; arr[i].f2u.f = foo(2).sF; i++; arr[i].f2u.f = foo(2).sF; i++; } int main() { my_init(); }