This is the mail archive of the 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]
Other format: [Raw text]

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.

"Horse guts never lie."  -- Cherek Bear-Shoulders

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