This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Defining a section
- To: "Rodney Bryant" <Rodney dot Bryant at spikebroadband dot net>
- Subject: Re: Defining a section
- From: andy at softbook dot com
- Date: Mon, 15 Oct 2001 10:59:33 -0700
- Cc: gcc-help at gcc dot gnu dot org
If you're gonna be using gcc why not define the section in a linker script?
Placing anything but C code in a .c file seems morally repugnant to me :-))
Andy
>Hi,
> I am currently working on an embedded project that is being ported
>from using a
>Dib compiler to the GNU-GCC compiler. My question stems from a pragma that
>is
>supported by the Diab compiler that I have been unable to locate a similar
>method in
>the GCC compiler. The Diab compiler pragma defines a section as a part of a
>C source
>code file. There is a subsequent pragma from the Diab compiler that forces
>the data
>following the pragma to be placed into this newly defined section. I have
>located the
>attribute to use during variable definition to force the data to be located
>into the section
>that is defined in the variable definition. My question is how do I define
>a section in a
>C code source file? The following source code snippet is giving me
>difficulty.
>
>
>#ifdef GNU
>Persistent_t gPersistentWork __attribute__ ((section (".persistentWData")));
>#else
>// place the working persistent data in a reserved memory area that
>// is equal in size as the persistent sector in flash
>#pragma section persistWork "" ".persistentWData" far-data RW
>
>// Declare working copy of persistent data
>#pragma use_section persistWork gPersistentWork
>Persistent_t gPersistentWork;
>#endif
>
>
>The section .persistentWData is handled in my linker script file.
>
>Respectfully,
>Rodney Bryant