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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

1,798件の閲覧回数
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

ラベル(2)
タグ(3)
0 件の賞賛
返信
2 返答(返信)

1,425件の閲覧回数
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 件の賞賛
返信

1,425件の閲覧回数
yuehedeng
Contributor III

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

0 件の賞賛
返信