This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Tracking Heap and Stack (ARM Cortex M4)

Hello, I want to track boundaries for Heap and Stack in my RAM, I tried reading .axf file using 'readelf' but unable to find.

Please find screenshot of readelf output and memory map of MCU arm cortex m4 in below links.

https://ibb.co/ctmtvcS
https://ibb.co/98fh6z5

Thanks

Parents
  • You're going to need to look at the exported symbols, not the sections in the .ELF/AXF file
    Perhaps review the .MAP file, where the linker tells you where it put stuff.
    You define the stack/heap size in the startup_stm32xxx.s file

                    EXPORT  Stack_Size
                    EXPORT  Stack_Mem
    
    Stack_Size              EQU     0x1000
    
                    AREA    STACK, NOINIT, READWRITE, ALIGN=3
    Stack_Mem       SPACE   Stack_Size
    __initial_sp
    
    ...
    
    Heap_Size       EQU     0x200
    
                    AREA    HEAP, NOINIT, READWRITE, ALIGN=3
    __heap_base
    Heap_Mem        SPACE   Heap_Size
    __heap_limit
    

    You could export the heap base/size. You could walk the allocation structures.
    You can dynamically check the maximal stack depth

Reply
  • You're going to need to look at the exported symbols, not the sections in the .ELF/AXF file
    Perhaps review the .MAP file, where the linker tells you where it put stuff.
    You define the stack/heap size in the startup_stm32xxx.s file

                    EXPORT  Stack_Size
                    EXPORT  Stack_Mem
    
    Stack_Size              EQU     0x1000
    
                    AREA    STACK, NOINIT, READWRITE, ALIGN=3
    Stack_Mem       SPACE   Stack_Size
    __initial_sp
    
    ...
    
    Heap_Size       EQU     0x200
    
                    AREA    HEAP, NOINIT, READWRITE, ALIGN=3
    __heap_base
    Heap_Mem        SPACE   Heap_Size
    __heap_limit
    

    You could export the heap base/size. You could walk the allocation structures.
    You can dynamically check the maximal stack depth

Children