Loading...
 
Skip to main content

System Workbench for STM32


Conditional Linker script

Hi, i need to make some conditional assignments in the linker script, example: #ifdef DEBUG -> assign more memory for stack, #elif -> assign less memory for stack

something similar to pre-processor statements in c.

is there a way to do so in the linker of the openstm32?
if yes, is it possible to read defines made in a header file? or should i made a separate defines inside the linker itself?

thank you

Tunisia

as far as I know gcc linker cannot read defines made in header, but you can add symbol definition to you linker using defsym

example :

in you project properties > C/C++ Build > Settings > Tools Sttings (tab) > MCU GCC Linker > Miscellaneous > Linker flags add

Copy to clipboard
-Wl,--defsym,stack_size=0x2000


and in my linker I add this

Copy to clipboard
stack_size = DEFINED(stack_size) ? stack_size : 0x400 ;