I chuckled at the use of gcc to ‘edit’ the .ld file, replacing, via a -D directive, FLASH__ with either the bootloader or application string.
I too have used the idea of a .ld.in file, i.e. a template linker script with ‘holes’ to fill in, but have always used good old sed as the edit tool.
Surely this is at least as suitable as gcc? Doing this task with gcc just seems wrong to me, something about ‘if you’ve only got a hammer, everything looks like a nail’ ???
You caught me! sed is usually a better option for this kind of work; in this case I was trying to keep the set of tools used in the examples as low as possible (eg, windows may not have sed installed : ).