* Initialized variables location question
@ 2004-05-07 21:10 geneSmith
2004-05-09 14:19 ` Richard Sandiford
0 siblings, 1 reply; 3+ messages in thread
From: geneSmith @ 2004-05-07 21:10 UTC (permalink / raw)
To: binutils
The linker manual section 3.4.4,
http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_mono/ld.html#SEC21
describes how to use the AT directives so you can copy your initialized
variables (.data) from their "rom" load location to "ram" and zero out
your bss. It gives this example:
SECTIONS
{
.text 0x1000 : { *(.text) _etext = . ; }
.mdata 0x2000 :
AT ( ADDR(.text) + SIZEOF ( .text ) )
{ _data = . ; *(.data); _edata = . ; }
.bss 0x3000 :
{ _bstart = . ; *(.bss) *(COMMON) ; _bend = . ;}
}
This allows the initialized variable to be placed (loaded) right after
.text so they can be copied to ram at 0x2000 on start-up. (Not concerned
with the .bss right now.)
My question would be is how would you cause .mdata to always be located
right after the point where .data is loaded rather than at a fixed
address? In otherwords, the above SECTIONS defines things like this:
.text section at 0x1000
:
:
end of .text
.data values (loaded here)
:
:
end of .data values
:
(memory gap)
:
.mdata section at 0x2000 (.data values copied here at startup)
:
:
.end if .data
I want there to be no gap. I want .mdata section to begin right after
the point marked "end of .data values" above. If I add more initialized
data, I want .mdata section to move down dynamically and not be at a
fixed address. Is this possible? (I keep getting "forward reference"
errors when I try to use "SIZEOF (.data)" before the .mdata section.)
Tks,
-gene
--
"Lit up like Levy's"
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Initialized variables location question
2004-05-07 21:10 Initialized variables location question geneSmith
@ 2004-05-09 14:19 ` Richard Sandiford
2004-05-12 20:29 ` geneSmith
0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2004-05-09 14:19 UTC (permalink / raw)
To: geneSmith; +Cc: binutils
geneSmith <gene.smith@sea.siemens.com> writes:
> My question would be is how would you cause .mdata to always be located
> right after the point where .data is loaded rather than at a fixed
> address? In otherwords, the above SECTIONS defines things like this:
Probably the easiest way is with memory regions. The script might
look something like this (not checked for syntax, etc):
MEMORY
{
REGION1 (r) : ORIGIN = 0x1000, LENGTH = 0x....
}
SECTIONS
{
.text : { *(.text) _etext = . ; } > REGION1
.mdata : { ... } > REGION1
.bss : { ... } > REGION1
}
See the MEMORY section of the ld manual for more details.
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Initialized variables location question
2004-05-09 14:19 ` Richard Sandiford
@ 2004-05-12 20:29 ` geneSmith
0 siblings, 0 replies; 3+ messages in thread
From: geneSmith @ 2004-05-12 20:29 UTC (permalink / raw)
To: binutils
Richard Sandiford wrote, On 5/9/2004 5:16 AM:
> geneSmith <gene.smith@sea.siemens.com> writes:
>
>>My question would be is how would you cause .mdata to always be located
>>right after the point where .data is loaded rather than at a fixed
>>address? In otherwords, the above SECTIONS defines things like this:
>
>
> Probably the easiest way is with memory regions. The script might
> look something like this (not checked for syntax, etc):
>
> MEMORY
> {
> REGION1 (r) : ORIGIN = 0x1000, LENGTH = 0x....
> }
>
> SECTIONS
> {
> .text : { *(.text) _etext = . ; } > REGION1
> .mdata : { ... } > REGION1
> .bss : { ... } > REGION1
> }
>
> See the MEMORY section of the ld manual for more details.
>
> Richard
>
Thanks for the suggestion. However, it didn't seem to help. I ended up
just using the original order ok by working around the problem. However,
it turned out I need "position independent" code to do a completely
general solution. So I am now looking at things regarding -fpic gcc flag
on crossgcc list.
-gene
--
Lit up like Levy's
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-05-12 20:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-07 21:10 Initialized variables location question geneSmith
2004-05-09 14:19 ` Richard Sandiford
2004-05-12 20:29 ` geneSmith
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).