This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: linker script question
- To: npapadon at yahoo dot com
- Subject: Re: linker script question
- From: DJ Delorie <dj at delorie dot com>
- Date: Wed, 28 Mar 2001 02:51:32 -0500
- CC: binutils at sourceware dot cygnus dot com
- References: <m34rweuyiz.fsf@h0050bad6338d.ne.mediaone.net>
> .data :
> {
> _sdata = . ;
> *(.data)
> } > ram
>
>
> Can I assume, _sdata becomes a symbol and is initialized with an
> unsigned integer value of the memory location at .data?
>
> Should _sdata be a symbol located at
> .data and assigned nothing?
>
> 'ld' is apparently doing the later. I don't think this is correct.
That's correct. _sdata's "value" is assigned the current value of
".", or the address at which the next datum would be added. In the
linker, the "value" of a symbol has nothing to do with the data that
happens to be stored there - the value of a symbol is an *address*
(for the most part). The linker doesn't know about ints, structs,
arrays, or whatnot. It only knows about addresses. So, _sdata is a
symbol whose address is the start of the .data section. If you did
something like this:
extern int _sdata;
Then the *address* of _sdata would be useful. Actually, it would be
more appropriate to do this:
extern char _sdata[];
Then you could say that _sdata is an array of char, and the "chars"
are the contents of the .data section.