On GCC: Just put the function in the .data section:
__attribute__( ( section(".data") ) )
It will be copied over with the rest of your initialzed variables by the startup code (no need to mess with the linker scipt). You may also need a "long_call" option as well if the function ends up "far away" from the rest of the code after being placed into RAM.
__attribute__( ( long_call, section(".data") ) )
Example:
__attribute__( ( long_call, section(".data") ) ) void ram_foobar (void) { ... }
You may get an compiler warning that can be safely ignored:
Warning: ignoring changed section attributes for .data
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…