I start liking the GNU linker (ld) more and more. Yes, that linker command file syntax needs some time to learn, but it is very powerful. I stumbled over an interesting way how to define linker symbols:
/* Linker file for GNU C Compiler */ /* Entry Point */ ENTRY(Reset_Handler) HEAP_SIZEÂ = DEFINED(__heap_size__)Â ? __heap_size__Â : 0x00000400; STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x00000400;
The interesting part is how the HEAP_SIZE and STACK_SIZE symbols are defined.
It checks if e.g. __heap_size__ is DEFINED, and if so, it uses that symbol, otherwise it is using 0x400. Very similar to the C/C++ ‘?’ operator. So I can overwrite the default of 0x400 with my value or symbol. The questions is: from where does the symbol come from?








