This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TM4C129XNCZAD: how to reference section name is C code?

Part Number: TM4C129XNCZAD

Tool/software: TI C/C++ Compiler

Is there a way to programmatically obtain the addresses of the different sections? For example, in my code I want to assign a pointer to the start of the heap, which is in the .sysmem section. Is there some global symbol that I can reference? In the .map file I saw a symbol called _sys_memory, but the compiler generates an error when I try to use it.

Also, the compiler manual says that the linker generates a global symbol called __SYSMEM_SIZE, which is supposed to be the size of the section. It's in the .map file, but I also get a compiler error when I try to use it.

Regards,

Dave

  • I suspect you are using the linker created symbols incorrectly.  Please see the section titled Using Linker Symbols in C/C++ Applications  in the ARM assembly tools manual.  

    There is a general method by which you can create a symbol for the start of a section.  In the linker command file, use the operator RUN_START(name_of_symbol).  Read more about it in the section titled Address and Dimension Operators in the same manual.

    Thanks and regards,

    -George

  • Thanks, George. I was able to get things working after reading the Using LInker Symbols section. In case anyone else is interested, here is what I ended up with:

    #ifdef INIT_HEAP
        extern void * _sys_memory;
        extern void * __SYSMEM_SIZE;
        void *heapAddr = &_sys_memory;
        void *heapSize = &__SYSMEM_SIZE;
    
        memset(heapAddr, '*', (size_t)(heapSize));
    #endif
    

    Regards,

    Dave