This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR gold/18609
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Andrew Senkevich <andrew dot n dot senkevich at gmail dot com>
- Cc: Cary Coutant <ccoutant at gmail dot com>, Binutils <binutils at sourceware dot org>
- Date: Mon, 20 Jul 2015 07:57:44 -0700
- Subject: Re: [PATCH] PR gold/18609
- Authentication-results: sourceware.org; auth=none
- References: <CAMXFM3ufsJmH8trBQ6GJ5ZWBRxEpXbTTr-cDY_X=hxrkEsK=pQ at mail dot gmail dot com> <CAJimCsGgpjpAZdmwZF+kviPANMWnS_Fi6+hPtKftN82nJOLT7A at mail dot gmail dot com> <CAMXFM3tDV0tELGu6iiLop6gBO2c0S48GYTDaMet-wHXbQxGF6g at mail dot gmail dot com> <CAMe9rOrGp-KGrRyqH6TNsMJfsAOS3ze=e=O1SAOgd0GQhQqBMA at mail dot gmail dot com>
On Mon, Jul 20, 2015 at 5:38 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> if (gsym->final_value_is_known())
>> {
>> // For a STT_GNU_IFUNC symbol we want the PLT address.
>> @@ -3543,7 +3511,8 @@ Target_x86_64<size>::Relocate::relocate(
>> // mov foo@GOTPCREL(%rip), %reg
>> // to lea foo(%rip), %reg.
>> // if possible.
>> - if (rela.get_r_offset() >= 2
>> + if (!Bits<32>::has_overflow(psymval->value(object, addend) - address)
>> + && rela.get_r_offset() >= 2
>> && view[-2] == 0x8b
>> && ((gsym == NULL && !psymval->is_ifunc_symbol())
>> || (gsym != NULL
>>
>
> There are
>
> // Return true if VAL (stored in a uint32_t) has overflowed a signed
> // value with BITS bits.
> static inline bool
> has_overflow32(uint32_t val)
> {
> gold_assert(bits > 0 && bits <= 32);
> if (bits == 32)
> return false;
> int32_t max = (1 << (bits - 1)) - 1;
> int32_t min = -(1 << (bits - 1));
> int32_t as_signed = static_cast<int32_t>(val);
> return as_signed > max || as_signed < min;
> }
>
> Bits<32>::has_overflow will always return false for x32. I think we
> need has_overflow_xxx similar to power.cc and use them to check
> relocation overflow instead of the ones in reloc.h.
>
I opened:
https://sourceware.org/bugzilla/show_bug.cgi?id=18695
--
H.J.