This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Initialized variables location question
- From: geneSmith <gene dot smith at sea dot siemens dot com>
- To: binutils at sources dot redhat dot com
- Date: Fri, 07 May 2004 17:01:26 -0400
- Subject: Initialized variables location question
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"