SPRU513Z August 2001 – October 2023 SM320F28335-EP
To access linker-defined symbols that represent addresses, use the _symval built-in operator to get the symbol's value as a pointer value.
For example, the linker symbol __TI_STACK_END evaluates to an address. To get the symbol's value as a pointer value in C/C++ code, use the following syntax:
extern void __TI_STACK_END;
void *get_stack_end() { return (void*)_symval(&__TI_STACK_END); }
Although the linker symbol __TI_STACK_END is an address, and thus looks a lot like a C/C++ pointer value, you cannot simply define the C/C++ variable __TI_STACK_END as a pointer variable and omit taking the symbol's address. See Section 8.6.4 for details. The following example is incorrect.
extern void * __TI_STACK_END;
void *get_stack_end() { return __TI_STACK_END; } // wrong, missing &