R_SPARC_RELATIVE vs R_SPARC_UA32 & unaligned unwind tables - again

Ian Lance Taylor ian@airs.com
Tue Dec 18 18:57:00 GMT 2001


DJ Delorie <dj@delorie.com> writes:

> > R_SPARC_RELATIVE is an optimization which skips the symbol lookup.  It
> > seems to me that you can always use an R_SPARC_UA32 reloc against an
> > offset from a section, or at the very least you could do that against
> > a symbol.
> 
> That would be nice, but it doesn't work.  The R_SPARC_UA32 relocs are
> there, interspersed with the R_SPARC_RELATIVEs, but when the program
> runs the pointer is wrong.  If you read the Sparc PS-ABI, the only
> reloc that uses the image load base in its calculation is
> R_SPARC_RELATIVE.

I think you are misreading the ABI.  When there is a dynamic
relocation against a symbol defined in a dynamic object, the
relocation is done using the runtime value of the symbol, which
naturally incorporates the image load base.

R_SPARC_RELATIVE mentions the image load base explicitly only because
R_SPARC_RELATIVE does not use any symbol value.  You could replace all
R_SPARC_RELATIVE relocations with a R_SPARC_32 relocation against a
symbol with the appropriate value, and the program would run
correctly, although it would load slightly more slowly.

I don't know why the program isn't working, but I don't think you have
analyzed the problem correctly.

Ian



More information about the Binutils mailing list