This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: GNU LD: Linker script generating incorrect address
- From: Jens Bauer <jens-lists at gpio dot dk>
- To: dvalin at internode dot on dot net
- Cc: binutils at sourceware dot org
- Date: Wed, 22 May 2013 03:00:16 +0200
- Subject: Re: GNU LD: Linker script generating incorrect address
- References: <20130521062602780057 dot 62ec95fc at gpio dot dk> <20130521111909 dot GA1926 at ratatosk>
Hi Erik.
I think you understood my mail completely.
Thank you for sending me the "info ld" text-file.
I've already used info_gas *a lot*; it makes life *much* easier for me. :)
It turns out that I could use...
.ustack (NOLOAD) : /* a user stack pseudo-section that only defines the user stack length */
{
. = ALIGN(4);
_sustack = ABSOLUTE(.);
*(.ustack .ustack.*)
. = ALIGN(4);
_eustack = ABSOLUTE(.);
}
_lustack = (_eustack - _sustack);
...That works too. But in this particular case, I'd rather use SIZEOF; it makes more sense.
Love
Jens
On Tue, 21 May 2013 21:19:09 +1000, Erik Christiansen wrote:
> Hi Jens,
>
> The relevant "info ld" section is "3.10.5 The Location Counter", which
> makes the point that a '.' assignment inside an output section is
> relative to the start of that section, _not_ absolute.
>
> An expression like your "_lustack = _eustack - _sustack;" will provide
> a size, because the difference is the same, whether the addresses are
> absolute, or relative _and_ set in the current section.
>
> One simple way to gain absolute addresses, is e.g.:
>
> » ABSOLUTE: For an absolute symbol giving the address of the end of the
> output section .data:
>
> .data : { *(.data) _edata = ABSOLUTE(.); }
>
> By default, _edata would be relative to the .data section.
> «
>
> Another way to make it absolute is the form appearing in many scripts:
>
> _edata = ADDR(.data) + SIZOF(.data) ;
>
> The line should be placed outside (after) the .data section.
>
> A third way which should work is:
>
> _edata = ADDR(.data) + _data_size ;
>
> where _data_size is from an "__data_size = . ;" assignment within the
> .data section. (i.e. assignments like yours, lacking the ABSOLUTE
> operator. This last expression mixes absolute and relative values in a
> workable way. (AIUI, (relative + absolute) = absolute, if the right
> absolute is used, else it's an error, because you're missing a third
> value.)
>
> I haven't read your post in ultimate detail, so hope I have the nub of the
> problem.
>
> møjn,
>
> Erik
>
> --
> Leibowitz's Rule:
> When hammering a nail, you will never hit your finger if you hold the
> hammer with both hands.
>