Content originally posted in LPCWare by starblue on Mon Nov 23 05:55:44 MST 2015
Yes, it is a bit hackish, but it is simple and easy to understand, and guaranteed to work. The places where these variables are used stick out in the code, which is good.
I don't use it for all global variables, only a few variables that need to be shared among cores. And there are substructures for the different modules, so each variable is local to a module.
Convincing the linker to do the same is somewhat harder and more dangerous IMHO. Write a .c file with the definitions for the shared variables and put it in a separate section that is linked at a fixed address. Best would be to compile it only once, and link the .o file twice, but that might not be so easy to set up.