Code Warrior 'C' Compiler Sections

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

Code Warrior 'C' Compiler Sections

3,874 Views
phmoore
Contributor I
What are the various sections that the C compiler generates and how is the code distributed into these sections?
The closest thing I've found is in the "CodeWarrior Development Studio ColdFire™Architectures Edition Build Tools Reference" in table 32.1.  This only lists the generated sections.  It doesn't explain what gets put in each of these sections.  I assume all "code" goes in section ".text" and all "const" data goes in ".rodata".  Is there some other manual that clearly explains the other sections?  The table doesn't show ".bss" or ".sbss" sections but I know the compiler generates these.
 
Thanks
Labels (1)
0 Kudos
Reply
4 Replies

480 Views
CompilerGuru
NXP Employee
NXP Employee
Check this entry in another thread  from Simon Marsden,  he explained the sections

http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&message.id=1844&query.id=14202#M...

Daniel

0 Kudos
Reply

480 Views
phmoore
Contributor I
Hi Daniel,
 
Thanks for the link.  That was helpful in confirming what I had already suspected about the .text, .bss, .sbss, and .rodata sections.
I still have other sections that I have no clue about.  I see them used in the template *.lcf file and I see them in the disassembled main() file.  Here's a list of these sections -->
 
COMMON
SCOMMON
.exceptlist
.exception
 
Are there more than these?
What code/data is placed in these sections?  How do you control it?
 
Thanks for your help.
-Paul


Message Edited by phmoore on 2007-06-23 01:39 PM
0 Kudos
Reply

480 Views
twoerner
Contributor I
My understanding is that the CW compilers generate ELF output (or something that appears to be very strongly based on the ELF format). So if you understand ELF, it makes it easier to understand the CW output and the *.lcf files.

http://en.wikipedia.org/wiki/Executable_and_Linkable_Format

The ELF format was originally defined as part of the SysV ABI, which is a UNIXy thing. The SysV ABI can be found here: http://www.sco.com/developers/devspecs/

Note that the ELF format is flexible (i.e. you can add to the sections it outputs, as long as your link file defines what to do with any added sections). It would appear that the .exceptlist section is something that is not part of the base ELF specification.
0 Kudos
Reply

480 Views
CompilerGuru
NXP Employee
NXP Employee
As far as I know, the
.exceptlist
.exception
sections are used for the C++ exception handling. Note that in order to cross C function calls from C++ throws to C++ caches, the compiler has to emit that data even for plain C functions if the C++ exceptions (or RTTI, I would guess) is enabled. For C applications I would not expect those sections to be linked/contain anything (not verified).

The COMMON and SCOMMON, well never saw that. I did grep over all example *.lcf's in CW 6.3 and did not find a single instance, but I saw a single place in a pdf just using it.
The S may be the small prefix just as the s in .sbss, but that's only a guess.
Hmm. ELF does have some special sections, one with a defined section number with the alias name SHN_COMMON. Could be that this special section is referred. Could very well also be just a user specified section.

The most likely case is that this is just for compatibility, either with an old compiler or with another compiler (gcc?). If the other compiler would ever emit things into SHN_COMMON, then those would have to be linked too.

Daniel

0 Kudos
Reply