This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [gold][PATCH] PR gold/17619: Check PC-relative offset overflow in PLT entry
- From: Cary Coutant <ccoutant at google dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Fri, 21 Nov 2014 11:12:42 -0800
- Subject: Re: [gold][PATCH] PR gold/17619: Check PC-relative offset overflow in PLT entry
- Authentication-results: sourceware.org; auth=none
- References: <20141118193634 dot GA16737 at intel dot com> <CAHACq4pASeVcQQa=iMw+WywpTEmWbnEvqp9DgcxQ1saAtYoo7Q at mail dot gmail dot com> <CAMe9rOrF2ZYJUdewPyHyK_x8uh59b9kMJi=25okGB4JFqnkMVA at mail dot gmail dot com> <CAMe9rOpKJi3sKV-BeLycbkJHD9oaVQ0ABuV6mPDYKbiLzJKJdg at mail dot gmail dot com>
+ 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.