[gold][PATCH] PR gold/17619: Check PC-relative offset overflow in PLT entry
Cary Coutant
ccoutant@google.com
Fri Nov 21 19:12:00 GMT 2014
+ bool gotplt_after_plt = got_address > plt_address;
+ int32_t plt_got_pcrel_offset = (got_address + got_offset
+ - (plt_address + plt_offset + 6));
+ if ((gotplt_after_plt && plt_got_pcrel_offset < 0)
+ || (!gotplt_after_plt && plt_got_pcrel_offset > 0))
Please use a uint64_t for the offset, and check for overflow with
Bits<32>::has_overflow() from reloc.h.
This is OK with that change. Thanks!
-cary
On Thu, Nov 20, 2014 at 8:07 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Nov 19, 2014 at 5:08 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Wed, Nov 19, 2014 at 4:37 PM, Cary Coutant <ccoutant@google.com> wrote:
>>>> + // Check PC-relative offset overflow in PLT entry.
>>>> + bool gotplt_after_plt = got_address > plt_address;
>>>> + int32_t plt_got_pcrel_offset = (got_address + got_offset
>>>> + - (plt_address + plt_offset + 6));
>>>> + if ((gotplt_after_plt && plt_got_pcrel_offset < 0)
>>>> + || (!gotplt_after_plt && plt_got_pcrel_offset > 0))
>>>> + gold_error(_("PC-relative offset overflow in PLT entry"));
>>>
>>> It would be nice to print more information here. I think it's
>>> next-to-impossible at this point to translate the PLT index into a
>>
>> I will update it.
>>
>
> Does this patch look OK? I got
>
> ./ld -shared -o libfoo.so gap.o foo.o
> ./ld: warning: overflow in PLT unwind data; unwinding through PLT may fail
> ./ld: error: PC-relative offset overflow in PLT entry 1
> ./ld: error: PC-relative offset overflow in PLT entry 2
> make: *** [libfoo.so] Error 1
>
> Thanks.
>
>
> --
> H.J.
More information about the Binutils
mailing list