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: Alan Modra <amodra at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 21 May 2013 11:27:19 +0200
- Subject: Re: GNU LD: Linker script generating incorrect address
- References: <20130521062602780057 dot 62ec95fc at gpio dot dk> <20130521053016 dot GE9651 at bubble dot grove dot modra dot org> <20130521100851904201 dot d72777f3 at gpio dot dk> <20130521084720 dot GG9651 at bubble dot grove dot modra dot org>
Hi Alan.
I begin to understand where the problem is introduced (technically).
In my thinking, (relative - relative) = absolute. (relative + relative) = illegal. (relative + absolute) = relative.
Just like relocatable - relocatable = position independent [it won't make sense adding two relocatable values either, unless subtracting a third relocatable address].
-But if ld needs to be compatible with an older version, the older version might not handle these as I expect them to be handled.
...So if I didn't use SIZEOF (which I do now), it seems the problem could be solved by using LD_FEATURE("SANE_EXPR"), am I right ?
Regarding 'info'... My distro is "Mac OS X", the CPU is PowerPC, which means my 'host gcc 4.2' is compiled slightly different from the 'host gcc 4.2' on intel based Macs.
This results in toolchains such as Yagarto will not compile on my system.
It also means that there are many tools I have been unable to build; some were successfully built, but required weeks or months of work to get them installed.
I came across a show-stopper, while trying to build the docs for my toolchain, which is why I currently can't just use a command-line tool like 'info'.
Ofcourse I've not given up, I just need to keep my focus on the main task, rather than creating tools to fix the fixes for fixing other tools. ;)
(I used to be advocating Macintosh, due to their ease-of-use, but the last PPC based Mac OS X changed that; support is gone, errors start to show up more and more, system getting sluggish, even on fresh installs, hmm).
Love
Jens
On Tue, 21 May 2013 18:17:20 +0930, Alan Modra wrote:
> On Tue, May 21, 2013 at 10:08:51AM +0200, Jens Bauer wrote:
>> I've read these (online):
>> <http://sourceware.org/binutils/docs/ld/index.html#Top>
>> (<http://sourceware.org/binutils/docs-2.23.1/ld/index.html>)
>>
>> <http://info2html.sourceforge.net/cgi-bin/info2html-demo/info2html?(ld.info.gz)Expressions>
>> -Are those the ones the same as the "ld info doc" ?
>
> Yes.
>
>> ($info ld does not give anything useful at my end)
>
> Some distros don't install documentation unless you install
> "development" packages. It would of course be a good idea to read the
> docs for your particular binutils.
>
>> If they are, I've read the section about linker scripts 4 times now
>> and still haven't come across any place explaining what not to do,
>> regarding symbols.
>
> It's not so much what not to do, but knowing that symbols can be
> absolute or section relative.
> http://sourceware.org/binutils/docs/ld/Expression-Section.html#Expression-Section
> has some examples and goes into some detail on how ld evaluates
> expressions. Unfortunately the rules are not simple, mainly due to
> wanting some level of backwards compatibility with older versions of
> ld.
>
> --
> Alan Modra
> Australia Development Lab, IBM