On Wed, Oct 24, 2012 at 10:17:48AM +0100, Richard Sandiford wrote: > > Sparc accepts addresses of the form: > > > > (plus:DI (lo_sum:DI (reg/f:DI 282) > > (symbol_ref:DI ("__mf_opts") <var_decl 0xf78d74a0 __mf_opts>)) > > (const_int 40 [0x28])) > > > > These make use of Sparc's offsetable %lo() relocations. > > Hmm, this looks a bit risky. In terms of RTL semantics, this > (plus:DI ...) is a full 64-bit addition of the result of the > (lo_sum:DI ...), whatever that (lo_sum:DI ...) result happens to be. > I assume the offset is really folded into the %lo() constant itself, > in which case the usual form would be: > > (lo_sum:DI (reg/f:DI 282) > (const:DI (plus:DI (symbol_ref:DI ...) (const_int 40))))
R_SPARC_OLO10 relocation has two addends though, please see http://sourceware.org/ml/binutils/1999-q3/msg00099.html so the plus there is right. The constant in second operand of PLUS where first operand is LO_SUM needs to be RTX_OK_FOR_OLO10_P, so that there is no overflow on the lo_sum operand & 0x3ff plus the RTX_OK_FOR_OLO10_P offset (it needs to fit into signed 13 bit field). Jakub