We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 33133

11 EDK - How do I use symbols to pass variables to use in C source code?


How can I use the linker variables such as stack and heap in my source code?


Use the extern keyword which declares a variable and specifies that it has external linkage; this means that the variable is visible in files other than the one in which it has been defined, in our case the linker script.

For example, the code below declares linker script variables using the external keyword so that they can be accessed globally.

In this simple code the stack and heap are defined and a print function is used to display stack and heap information.

extern int _stack_end;

extern int _STACK_SIZE;

extern int _stack;

extern int __stack;

extern int _heap;

extern int _heap_start;

extern int _heap_end;

int main(){

xil_printf("_stack_end: 0x%X", &_stack_end);

xil_printf("_STACK_SIZE: 0x%X", &_STACK_SIZE);

xil_printf("_stack: 0x%X", &_stack);

xil_printf("__stack: 0x%X", &__stack);

xil_printf("_heap: 0x%X", &_heap);

xil_printf("_heap_start: 0x%X", &_heap_start);

xil_printf("_heap_end: 0x%X", &_heap_end);

return 0;


AR# 33133
Date Created 07/15/2009
Last Updated 12/15/2012
Status Active
Type General Article