Converting #pragma section definition from WindRiver Diab compiler to CodeWarrior

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

Converting #pragma section definition from WindRiver Diab compiler to CodeWarrior

Jump to solution
6,382 Views
pierreschmidt
Contributor III

Hello,

 

I am working on an MPC5668G project which I need to convert from Diab compiler to CodeWarrior. I am facing problems related to section définitions.

 

In one of the include file is the following definition:

 

#  pragma section APPLVECT "APPLVECT"

#  pragma use_section APPLVECT ApplIntJmpTable

 

In .lcf file, APPLVECT is defined like that:

 

APPLVECT   (DATA) : {}

 

This generates a compilation error.under CodeWarrior because the use_section directive is not recognized.

 

So I left the .lcf defnition unchanged but modified the include code like that:

 

#  pragma section APPLVECT "ApplIntJmpTable"

 

But this generates following error: "pragma section expected an object type or access permission and/or quoted name."

 

How should I convert the section definition to compile under CodeWarrior?

 

I've seen somewhere sections could be defined as:

 

#pragma section RX "ApplIntJmpTable"

 

But if written like that, the linker cannot know the section has to be of APPLVECT type...

 

Thanks a lot.

 

Best regard,

 

P.SCHMIDT

Labels (1)
0 Kudos
1 Solution
2,719 Views
CrasyCat
Specialist III

Hello

The pragma section defines 2 sections in fact. One for initialized variables and one for uninitialized variables.

You can use the same declspec and depending if the variable is define with or without initializer, it will be placed in the corresponding section.

Regarding the issue with sdata2 the linker puts variable which size is smaller than 8 bytes in dedicated sections.

I do not think you need that...

To prevent usage of such small data sections:

  • Open Target Settings dialog
  • Go to Target > EPPC Target page
  • Set Small Data and Small Data2 edit box to 0
  • Rebuild.

CrasyCat

View solution in original post

0 Kudos
10 Replies
2,719 Views
CrasyCat
Specialist III

Hello

In order to place a variable called MyVar in a section called .myUData, I would write it as follows:

#pragma section data_type ".myIData" ".myUData" data_mode=far_abs code_mode=pc_rel

__declspec(section ".myIData")int MyVar[100];

then make sure to place the section .myUData inside of a valid section in the .lcf file.

The {Install}\Help\PDF\Power Architecture Build Tools Reference.pdf manual describes the syntax of the section pragma.

See chapter Pragmas for Power Architecture Compiler, section Library and Linking Pragmas for more information.

CrasyCat

2,719 Views
pierreschmidt
Contributor III

Thanks a lot CrasyCat,

this really helped.

But now I am facing another problem related to section definition which generates following error:

"Linker command file output section 'EEPDATA' has a type or input which is incompatible with section 'EEPDATA' in file ....
Change the type or add an input for this section

In .lcf EEPDATA is defined as:

EEPDATA  (BSS) : {}

and in .h it is

# pragma section  "EEPDATA" "EEPDATA" data_mode=far_abs code_mode=pc_rel

__declspec(section "EEPDATA")extern V_MEMRAM0 V_MEMRAM1_NEAR IO_U8 V_MEMRAM2_NEAR eepData[EEP_BUFFER_SIZE];

I know bss is for uninitialized RW data section, so maybe data_type is not appropriate, but which type to use instead of data_type?

P.SCHMIDT

0 Kudos
2,719 Views
CrasyCat
Specialist III

Hello

Did you try

    EEPDATA  (DATA) : {}

in the linker file?

Apparently you are using EEPDATA section for both initialized and uninitialized data.

So in this case the section type is DATA rather than BSS.

Otherwise use different section name in the C source file for initialized and uninitialized data.

# pragma section  "EEPDATA" "uEEPDATA" data_mode=far_abs code_mode=pc_rel

Then uEEPDATA can be considered as a BSS section whereas EEPDATA is considered as a DATA section.

CrasyCat

2,719 Views
pierreschmidt
Contributor III

I am sorry but I forgot the data_type identifier. So the exact definition is:

# pragma section data_type "EEPDATA" "EEPDATA" data_mode=far_abs code_mode=pc_rel

__declspec(section "EEPDATA")extern V_MEMRAM0 V_MEMRAM1_NEAR IO_U8 V_MEMRAM2_NEAR eepData[EEP_BUFFER_SIZE];

Why do you think I am using EEPDATA for both initialized and uninitialized data?

Because is an array but with no default values...

0 Kudos
2,719 Views
CrasyCat
Specialist III

hello

The syntax of the section pragma looks as follows:

#pragma section [ objecttype | permission ][iname][uname][data_mode=datamode][code_mode=codemode]

where uname is described as follows:

uname: specifies the name of the section where the compiler stores uninitialized objects.

This parameter is required for sections that have data objects. The uname parameter value may be a unique name or it may be the name of any previous

iname or uname section. If the uname section is also an iname section then uninitialized data is stored in the same section as initialized objects.

So with the syntax you are using section EEPDATA is used for both initialized and uninitialized variables.

CrasyCat

0 Kudos
2,719 Views
pierreschmidt
Contributor III

Thanks,

Everything is more clear now. Using different names for iname and uname solves the confusion I had previously.

But I still have a problem because, if EEPDATA is an uninitialized section name, the __declspec don't let me put a variable into this section. (explained at page 238 of build Reference Manual).

But I didn't find through the build Reference Manual how to put a variable in an uninitialized section name (EEPDATA)

Is the there an alternative to te __declspec directive?

0 Kudos
2,719 Views
CrasyCat
Specialist III

Hello

The declspec is the only way that worked for me.

Attached you find a very simple project, which defines a variable in an uninitialized section EEPDATA.

Look at the .map file. The variable array is in fact allocated in EEPDATA.

The project has been created with CodeWarrior for MPC55xx V2.7.

CrasyCat

0 Kudos
2,719 Views
pierreschmidt
Contributor III

Hello,

Thanks. I had a look at your project, your solution is OK because as you said the array goes in EEPDATA which is uninitialized section. But it still seems very strange to give to __declcpec the initialized section name. I understand that the linker then put the variable at the right place which is EEPDATA.

I still have a linker error regarding sections:

"Linker command file output section '.sdata2' has a type or input which is incompatible with section '.sdata2' in file ...flb_flio.o".

The problem is that in my project there aren't any variables that are instructed to go in .sdata2 section. The linker put some variables automatically in .sdata2 if I understand well.

So how can I know which variable I have to look for to fix this error?


0 Kudos
2,720 Views
CrasyCat
Specialist III

Hello

The pragma section defines 2 sections in fact. One for initialized variables and one for uninitialized variables.

You can use the same declspec and depending if the variable is define with or without initializer, it will be placed in the corresponding section.

Regarding the issue with sdata2 the linker puts variable which size is smaller than 8 bytes in dedicated sections.

I do not think you need that...

To prevent usage of such small data sections:

  • Open Target Settings dialog
  • Go to Target > EPPC Target page
  • Set Small Data and Small Data2 edit box to 0
  • Rebuild.

CrasyCat

0 Kudos
2,719 Views
pierreschmidt
Contributor III

Hello,

Thank you, your solution helps as it suppress .sdata2 section generation.

I also found another way to fix this error:

I had:

.sdata2    (TEXT)

in my .lcf which I changed for:

.sdata2       : {}

(simply suppressed (TEXT)).

0 Kudos