This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Define constants in CODE (ROM) area.
- From: Gary Thomas <gthomas at redhat dot com>
- To: felixwong at i-technologies dot cc
- Cc: eCos Discussion <ecos-discuss at sources dot redhat dot com>
- Date: 29 Nov 2001 07:07:28 -0700
- Subject: Re: [ECOS] Define constants in CODE (ROM) area.
- References: <NFBBLLEDKLLJHLKGHKACKEKNCAAA.felixwong@i-technologies.cc>
On Thu, 2001-11-29 at 01:59, felixwong@i-technologies.cc wrote:
> Has anyone tried to define constants within the program CODE area?
> So that no more RAM memory will be wasted as in normal compilers.
>
> Any directives in GCC used for this purpose? Or any samples already
> used in eCos?
>
> For I checked the hardware initialization part for EB40 eCos port.
> It uses ARM ASSEMBLY language for defining memory layout constant values.
> Any means of using C/C++? Since that my code may involve many
> structures of constants.
>
> Note: some other compilers use "code" before variable declaration
> for including in code area.
If these are truly constant, the "const" qualifier should make this
happen. For example,
const int abc = 345;
will put that data into the ".rodata" section. You can adjust the
linker script to put this into the TEXT section. Note: we normally
put read-only data into the DATA section, so you would have to make
some changes for this to work completely.
On the other hand, you can try using "attribute"
const int abc __attribute__((section(".text"))) = 345;
which will put the data item into the TEXT section manually.