This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: linker script question



> 	.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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]