[PATCH] MIPS gas: Fix broken relocation sorting

Richard Sandiford richard@codesourcery.com
Wed Nov 8 06:38:00 GMT 2006


David Daney <ddaney@avtrex.com> writes:
> Richard Sandiford wrote:
>> David Daney <ddaney@avtrex.com> writes:
>>>I chose the second option, as it looked like the exclusion of global 
>>>relocations from the sorting was probably just an optimization.  The 
>>>first option would result in many %got() relocations that have no 
>>>corresponding %lo() not being converted to be against the section.
>> 
>> 
>> It isn't just an optimisation. 
>
> The optimization I was referring to is that for R_MIPS_GOT16 against a 
> global symbol, the relocation was never considered for moving.  If there 
> is no corresponding R_MIPS_LO16 it will not be moved anyway.  So the 
> optimization was the elimination of the search for the corresponding 
> R_MIPS_LO16.  That is all my patch changes.  It changes nothing to do 
> with whether it is a global or local symbol.

I was thinking that if you move a GOT16 reloc in front of a LO16
that didn't need it, you might orphan a HI16 reloc that does need it.
However, I suppose with the way the linker searches for relocations,
that isn't really a problem; it will just skip over the GOT16.
I'd still argue that the binary was wrong though. ;)

To be honest, I'm slightly nervous about your patch.  It's the first
use of section_symbol_p in the gas sources, and given that we already
handle most section symbols correctly, it seems like a broad stroke.
The clinching factor in your testcase appears to be that the section
is comdat.

Richard



More information about the Binutils mailing list