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.

#pragma DATA_SECTION

I am trying to add a simple section header to my app code. This is how the code looks like.

#pragma DATA_SECTION(SYS_cstAppSectionHeader, "AppSectionHeaderSection")
EXPORTED  const SYS_ST_SECTION_HEADER_T SYS_cstAppSectionHeader =
{
   LNK_pvAppStartAddress,
   LNK_pvAppEndAddress,
   (struct SYS_ST_SECTION_HEADER_T_TAG const  *)LNK_pvCalSectionHeaderAddress,
   SOFT_VERSION,
   EEP_U16_CAL_COMPATABILITY_VER,
   {0, 0, 0, 0, 0},
   SYS_U8_MEMORY_REGION_TEST_REQ
};

 

 

Linker script looks like this:

 

SECTIONS             
{

    /*.intvecs : {} > VECTORS    */
    .data : {              
                section_header.obj(AppSectionHeaderSection)
            } > FLASH1
    .entry:{AppMain.obj(.txt)}

    .text    : {} > FLASH1 | FLASH2 | FLASH3
    .const   : {} > FLASH1 | FLASH2 | FLASH3
    .cinit   : {} > FLASH1 | FLASH2 | FLASH3
    .pinit   : {} > FLASH1 | FLASH2 | FLASH3
    .bss     : {} > RAM
    .data    : {} > RAM                                              
    .stack   : {} > STACKS


}

 

During the build I get the error,  "no matching section" in the linker script line  " section_header.obj(AppSectionHeaderSection)"

 

 

What could be the issue ?

  • Ecoder, we're looking into this.

  • In your linker script you may want to try,

    .AppSectionHeaderSection : {} > FLASH1

    instead of

    .data : {

       section_header.obj(AppSectionHeaderSection)

    } > FLASH1

     

  • that did not help me  :-(

    My code looks like this.

    #pragma DATA_SECTION (SYS_cu32AppExpectedCrc, "AppCRCSection")
    EXPORTED  const U32_T SYS_cu32AppExpectedCrc = SYS_U32_DEFAULT_CRC;

    and my linker script looks like this...

    MEMORY
    {
        FLASH1  (RX) : origin=0x00080000 length=0x00080000
    }

    SECTIONS             
    {
        .AppCRCSection    :
                   {
                   } > FLASH1   
        .text    : {} > FLASH1
    }

    When I build my project I get a warning "creating output section "AppCRCSection" without a SECTIONS.

     

    Any idea...?

  • Hi

    I am trying to duplicate the issue at my end, could you pls give some information on keyword EXPORTED?

    Also let me know the compiler version you are using.

    Note: Pragma can be applied only to the file level symbols.

     

     

  • Sorry I did not  mention what is EXPORTED. Its empty. you can remove that.

    BTW, is there something like #PRAGMA END ? How do I show the end of  a section ?

  • Hi

    I tried to simulate a similar #pragma DATA_SECTION .. Pls see the below code snippet i tired, this is working code.

    -------------------------------------------------------------------------------------------
    ------------------
    crc_pattern.c
    ------------------

    #pragma DATA_SECTION(CRC_Pattern, ".crc_pattern");

    const unsigned int CRC_Pattern[0x40] =
    {
    0xC67E816B,
    0x4BFBE2FB,
    0x54F6BDDF,
    -----
    -----
    0x7C1CE187,
    0x01BF31DE,
    0x56720F47

    }
    -------------------------------------------------------------------------------------------
    -------------------------------------------
    linker Command FIle( lnk.cmd)
    -------------------------------------------

    MEMORY
    {
    VECTORS : origin = 0x00000000 length = 0x00000028 fill =0
    crc_pattern : origin = 0x00000030 length = 0x00000100 fill =0
    ----------
    }
    SECTIONS
    {
    .intvecs : {} > VECTORS /* INTERRUPT VECTORS */
    .crc_pattern: {} > crc_pattern
    ----------
    }

    ----------------------------------------------------------------------------------------------------

    This pragma defines a separate .section for that particular buffer(CRC_Pattern in the above example). I think there is no seperate syntax for the section end. It is taken care already knowing the buffer size.

    Cheers!!!

  • Got it. The issue with my code was

    When I defined the pragma there was no "." [no dot], I thought the linker will automatically add a dot.

     

    Thanks!