With the Green Hill compiler it is possible to create variables in the linker that is visible at runtime. In the linker:
__ghs_ramstart = MEMADDR(dram_memory);
In the code:
if (__ghs_ramstart == 0) {do something}
Is it possible to do the same type of thing when using gcc?
With the Green Hill compiler it is possible to create variables in the linker
Share
Yes, you can do that using GNU ld linker scripting. http://sourceware.org/binutils/docs-2.21/ld/Scripts.html#Scripts You can defined symbols in scripts that are accessible from gcc. I’ve also used scripts to create data tables (an array of addresses, for example).
In the linker script, you can say something like
and access it from C, e.g.
You may need to add or remove a leading underscore, depending on your target. Some targets add them to symbols, some do not.