This is the mail archive of the binutils@sourceware.org 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] PR gold/18609


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.


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