How to make extern variable of a file stored into a section

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to make extern variable of a file stored into a section

1,696 Views
yuehedeng
Contributor III

Hello,

 

   I know there is a way to store extern variables in a section defined in ld file as below:

__attribute__ ((section(".ccp_database1"))) struct  stDataCache stDataRamCacheA;

__attribute__ ((section(".ccp_database1"))) struct  stDataCache stDataRamCacheB;

....

 

But it is quite inconvenient if there are many extern variables in source files. Some compiler can do it by writing it in link file, for example TI CCS. Could S32 IDE  also have this feature?

 

My platform is: S32 IDE V1.1 + MPC574x

Labels (2)
Tags (3)
0 Kudos
Reply
2 Replies

1,323 Views
stanish
NXP Employee
NXP Employee

Hi,

You can e.g. replace an attribute with  shorter alias:

#define CCP_DATA1 __attribute__ ((section(".ccp_database1")))
CCP_DATA1  struct  stDataCache stDataRamCacheA;

You can also explicitly assign the object files into a custom section in the linker script command file (.ld).

First I'd suggest to turn off  function and data sections compiler flags since they might interfere with it.

pastedImage_1.png

SECTION
{
   .my_custom_section_consts : 
    {
    * source1.o (.rodata) 
   * source2.o (.rodata) 
   * source3.o (.rodata) 
    } > m_text

   .my_custom_text : 
   { INPUT_SECTION_FLAGS (SHF_PPC_VLE) 
   * source1.o (.text) 
   * source2.o (.text) 
   } > m_text
...‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Hope it helps.

Stan

0 Kudos
Reply

1,323 Views
yuehedeng
Contributor III

Thanks very much. I will have a try as you provide.

0 Kudos
Reply