This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Place function in specific section - ARM compiler

Hi,

I am using ARM compiler 5.1.9 and I'm trying to place a function in a section of the linker called "flashAPI", but I am getting an unrecognized #pragma warning

#pragma arm section code = "flashAPI"
static void handleFlashPrepare(CmdFmt_Obj *pCmd, RspFmt_Obj *pRsp)
{

I can place it in the section successfully using __attribute__, but  I don't want to have to enable gcc extensions

__attribute__ ((section ("flashAPI"))) static void handleFlashPrepare(CmdFmt_Obj *pCmd, RspFmt_Obj *pRsp)

Is my syntax for the #pragma incorrect?

 

Thanks,

David

  • See section 5.9.3. The CODE_SECTION Pragma in the TI ARM Optimizing C/C++ Compiler User's Guide:

    The CODE_SECTION pragma allocates space for the symbol in C, or the next symbol declared in C++, in a section named section name.

    The syntax of the pragma in C is:

    #pragma CODE_SECTION (symbol , "section name ")

    The syntax of the pragma in C++ is:

    #pragma CODE_SECTION (" section name ")

    The CODE_SECTION pragma is useful if you have code objects that you want to link into an area separate from the .text section.

    The following examples demonstrate the use of the CODE_SECTION pragma.

    Example 5.2. Using the CODE_SECTION Pragma C Source File

    #pragma CODE_SECTION(fn, "my_sect")
    
    int fn(int x)
    {
        return x;
    }