armstack-sizearmclang

Armclang armlink stack size information of function giving unknown bytes in --callgraph information


In Armclang armlink, stack size information of function giving unknown bytes when executing armling with --callgraph information. In addition, --info=stack is not giving those functions in its output.

So, questions is: In which cases do we get unknown bytes for armling --callgraph? Please note that none of the code is protected by any compile time macro. I am getting for some of the functions and not getting for a few and I am very confused.


Solution

  • The armlink documentation about --callgraph options states:

    If there is a cycle, or if the linker detects a function with no stack size information in the call chain, + Unknown is added to the stack usage.

    Cyclic / recursive calls is quite obvious barrier for stack usage estimation as linker cannot determine the level of nesting.
    The missing stack size is more complex case, if you have problem with assembler functions, you need to add special directives to produce debug info about stack frames:

    .cfi_sections .debug_frame
    .cfi_startproc
    <HERE YOUR ASSEMBLER FUNCTION>
    .cfi_endproc
    

    You can check --callgraph details in armlink docs: link

    Here is also great ARM article "How to get a backtrace through assembler functions": link