MPC5554: sbss,sdata and others; basic question regarding sections

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

MPC5554: sbss,sdata and others; basic question regarding sections

3,030 Views
MPC5554_Newbee
Contributor I
Hi everybody,

I have some general questions regarding code,data and const sections and their naming conventions in codewarrior and how they relate to power pc in general.  Where can I find a document/book that really goes into detail what default sections there are and to what type of C language data definitions they belong:
e.g.:   int MyVariable;      // will be put into sbss section by default if this xxx switch is set to .... in the linker...

I have read some basic info in "PowerPC Build Tool Reference.PDF" regarding predefined sections and default sections, but that only scratches the surface.

Any hints as to where I can find detailed info will be greatly appreciated!!

Alwin
0 Kudos
2 Replies

1,143 Views
CrasyCat
Specialist III
Hello
 
Take a look at {Install}\Help\PDF\PowerPC Build Tools Reference.pdf.
Chapter "PowerPC Linker" contains a section named "Predefined sections", which shows
predefined section names and their usage.
 
I hope this helps.
 
CrasyCat
0 Kudos

1,143 Views
MPC5554_Newbee
Contributor I
Hi CrasyCat,

As indicated in my initial post, I found the document and also looked at the section you are mentioning.  The "Predefined sections" are doesn't give the whole picture.  Once I dug through it and put the puzzle together it made more sense, since I could fill in the blanks then. I went through the exercise to build a test software set and played around with pragma section statements to find our what C variable definitions ends up where.

Here are my findings (which I did for MPC5554 compiler version 2.1) in the form of a truth table:


Metroworks Codewarrior Compiler Version 2.x definition for memory mapping in C-Source code: =====================================================================

 #pragma section <type> "initialized_Object_Name" "uninitialized_Object_Name"

possible options for <type>:
====================
code_type     executable object code
data_type   
  non-constant data of a size greater than the size specified in the
                        small data threshold setting in the CodeWarrior IDE’s PowerPC EABI Project
 
                       panel
sdata_type  —   non-constant data of a size less than or equal to the size
                        specified in the small data threshold setting in the CodeWarrior IDE’s
                        PowerPC EABI Project panel
const_type —   constant data of a size greater than the size specified in the
                        small const data threshold setting in the CodeWarrior IDE’s PowerPC EABI
                        Project panel
sconst_type —   constant data of a size less than or equal to the size specified
                        in the small const data threshold setting in the CodeWarrior IDE’s PowerPC
                        EABI Project panel
all_types   —   all data


Default sections and default access:
==========================    
code_type           ".text"                       data_mode=far_abs   code_mode=pc_rel
data_type           ".data”                       data_mode=far_abs   code_mode=pc_rel
const_type          ".rodata”                   data_mode=far_abs   code_mode=pc_rel
sdata_type          ".sdata”                    data_mode=sda_rel   code_mode=pc_rel
sconst_type        ".sdata2” ".sbss2"    data_mode=sda_rel   code_mode=pc_rel
all_types          

Here are some examples (truth table format):
================================
                                             
                                              // *1           *2             *3             *4            *5
const char   t1[5]  = {1,2,3,4,5};              // sdata2    sconst_type         const,         initialized,        small
const char   t2[9]  = {1,2,3,4,5,7,8,9};     // rodata      const_type         const,         initialized,  not small
const char   t3;                                       // sbss2       sconst_type         const,    not initialized,        small
const char   t4[9];                                    // rodata     const_type          const,   not initialized,  not small
          char   t5[5]    = {1,2,3,4,5};            // sdata       sdata_type    not const,        initialized,        small
          char   t6[9]    = {1,2,3,4,5,7,8,9};   // data          data_type    not const,        initialized, not small
          char   t7;                                       // sbss         sdata_type    not const,   not initialized,       small
          char   t8[9];                                   // bss            data_type    not const,   not initialized, not small

Notes:  *1    default name of region used by the compiler
            *2     <type> to use in #pragma statement (see above)
            *3     Truth table entry 1 (const / not const)
            *4     Truth table entry 2 (initialized / not initialized)
            *5     Truth table entry 3 (small / not small)

NOTE:   "small" is determined by Codewarrior "EPPC Target panel" settings "Small Data" and
"Small Data2" and has a value of 8 bytes by default.


Now, if I want to place a variable in a section that I like to define, you can do that like this:
#pragma section sdata_type "dum_sec" "unini_Vars_less_9_Bytes"
uint8_t    my_8_Bit_Variable;
uint32_t   my_32_Bit_Variable;
#pragma section sdata_type  // set back to default section names...


Hope this helps some folks out there....

Alwin
0 Kudos