[Gold] how to do relax in Gold ?

Ian Lance Taylor iant@google.com
Wed Jan 16 06:10:00 GMT 2013
On Tue, Jan 15, 2013 at 10:02 PM, Shawn <shaolin.xie@ia.ac.cn> wrote:
> Hi All:
>     I'am porting Gold to our processor right now ,everything is fine except
> the label whose value is big.  For Example, the following instruction assign
> a LABEL value to register R0:
>    ===========
>     R0 = LABEL_0;
>    ===========
>
> 1. Our Objects
>   Our instruction is encoded in 32bit,   if the value of "LABLE_0" is too
> big, for example 0x40000, there is not enough space to encode the
> instruction into a 32bit instruction, we have to expand "R0 = LABEL_0" into
> a 64bit instruction automatically.
>   Because the value of "LABEL_0" is not known until link-time, we hope
> "Gold" can handle this .
>
> 2. My plan  & Question:
>   I found the function related to our object is  the "Target::do_relax"
> function, but only arm.cc & powerpc.cc has overwritten it. The "do_relax" in
> arm.cc & powerpc.cc is too complicate to analyze. I hope to get a clean
> implementation of Our Objects.
>    a)  Scan  relocation info in all input objects, find the relocations that
> may  need relaxation ( read & compare the symbol value )
>          How can I read the relocation info ?
>          How can I reany advice ad the symbol  value ? Is the value read
> from the Symbol_table represent the value after layout ?
>    b)  for each relocation that  need relaxation, insert a 32bit stub in the
> VIEW, and update the value of the symbol which is located after the
> relocation site.
>
>     And is there any other example related to relaxation except arm.cc &
> powerpc.cc ? or any document ?

No, sorry.

I think one approach would be to record the possible relaxation points
in your scan_relocs routine.  You will have all the relocation
information available there.  That will let you detect out of range
relocations where you can insert stubs.

Ian



More information about the Binutils mailing list