This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Question on LD Linker providing low 2 bytes of address as a constant
- From: Michael Hennebry <hennebry at web dot cs dot ndsu dot NoDak dot edu>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: "Miller, Doreen" <domiller at tycoint dot com>, <binutils at sourceware dot org>
- Date: Thu, 18 Oct 2007 09:53:15 -0500 (CDT)
- Subject: Re: Question on LD Linker providing low 2 bytes of address as a constant
On Thu, 18 Oct 2007, Nick Clifton wrote:
> Hi Doreen,
>
> > If I put the address of the table I wanted stored in HdlrTbl in my
> > pre-initializer, the compiler reports "error: initializer element is not
> > constant". If I change HdlrTbl from 2 bytes to 4 bytes and leave the
> > pre-initilizer the way it was, it compiles fine. So it looks like I
> > need a way to tell the compiler and linker that I only want the lowest 2
> > bytes of the address (which is identical to the address since the 2 high
> > bytes are 0).
>
> Tricky. There are several possibilities, none of them easy:
> 4. Hard code the addresses of your HdlrTbl structures.
> You would have to make sure that you use a low memory area that is not
> going to be used by anything else and use two versions of the address,
> one 16-bit and the other 32-bit.
Another way is similar.
Compile and link using any value in the pre-initializer source.
Use nm, grep and sed to place the correct
value in the pre-initilizer source.
Compile and link again.
Use nm, grep and diff to make sure that the correct value didn't change.
If it does, I don't kow why it would, I suppose you could iterate like tex.
There is, I suppose, the possibility of editing the binary.
That would only work if everything that
uses the 2-byte address fetches it first.
--
Mike hennebry@web.cs.ndsu.NoDak.edu
"Horse guts never lie." -- Cherek Bear-Shoulders