Code: Select all
void foo(void) __attribute__((section(".data")));
void foo(void) {
// Some useful code here...
}
So this approach works if I want to place a function on RAM, but on the flash handling module I have a lot of functions I'd like to place on RAM. I could use the attribute definition above on each function, but I suppose there must be other way of putting all the code generated by the module on RAM. Also I'm not sure about how the section attribute will behave with inline functions.
So, is there any magic to place all the code of a module in RAM without having to "attribute" each function?
Also, on the test I did, I used ".data" section. I suppose there must be a better approach, like creating a new section and modifying the linker script to locate the section in RAM. But I'm not 100% this would work without modifying SGDK startup code to make sure the code is copied from the ROM to the appropiate RAM location before main() is executed.
And one last question... Is there any restriction I should be aware of while doing this trick? E.g. should I manually add an attribute to guarantee the code is aligned to a specific boundary?