This is the mail archive of the binutils@sources.redhat.com 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: [patch] MIPS: Incorrect calculation for R_MIPS_LO16 relocs


"Maciej W. Rozycki" <macro@linux-mips.org> writes:
> 2. Warning messages for many cases (unfortunately not all, but information
> is lost already) when a previously built object is malformed and may
> produce a broken binary.  I think this is the case you refer to above,
> writing: "[...] it would silently mishandle existing references to
> mergeable section symbols + offsets."  It's neither a worse mishandling
> than the current one -- the offset will be left intact as for an ordinary
> section -- nor actually a silent one.

Well, the current linker correctly handles any LO16 relocations in which
the high part of a mergeable section offset is zero.  Even if the LO16
relocation isn't paired to a HI16 or GOT16.

With your patch, orphaned LO16 relocations will take the high bits of
the offset from the previous HI16 relocation, whatever that happens to be.
That runs a high risk of introducing silent breakage when used with
old binaries.

> 3. Warning messages for sources that use %hi and %lo operators in a
> dangerous way.  I was quite surprised having discovered GCC is an offender
> here.

Can't respond to this unless you give examples.  Note that gcc does
deliberately create orphaned LO16 relocations in cases like:

        lui     $2,%hi(.LC1)
        lwc1    $f0,%lo(.LC1)
        lwc1    $f1,%lo(.LC1 + 4)

where LC1 is known to be double-word aligned.  Is this the kind
of case you're talking about?

Richard


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