How to run code from RAM on ARM architecture

前端 未结 3 1218
星月不相逢
星月不相逢 2020-12-01 11:38

I am programming an ARM Cortex-R4 and I have a few binary files that I\'d like to execute them from TCRAM, just to see if the increase in performance is good enough.

<
3条回答
  •  醉话见心
    2020-12-01 11:57

    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
    

提交回复
热议问题