This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR gold/18609
- From: Andrew Senkevich <andrew dot n dot senkevich at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Cary Coutant <ccoutant at gmail dot com>, Binutils <binutils at sourceware dot org>
- Date: Mon, 20 Jul 2015 19:22:58 +0300
- 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> <CAMXFM3vmaJNcg_Kz5tMUoR7jsJABiF2qVYRrXqg1p=qok_g5aQ at mail dot gmail dot com> <CAMe9rOrKALc8Q363j28vz3BjyBHXXN2vRwFUy2LEj-k6vrtuzQ at mail dot gmail dot com>
2015-07-20 18:30 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
> On Mon, Jul 20, 2015 at 8:24 AM, Andrew Senkevich
> <andrew.n.senkevich@gmail.com> wrote:
>>>> diff --git a/gold/x86_64.cc b/gold/x86_64.cc
>>>> index 007af1d..8f53bfc 100644
>>>> --- a/gold/x86_64.cc
>>>> +++ b/gold/x86_64.cc
>>>> @@ -2480,23 +2480,6 @@ Target_x86_64<size>::Scan::local(Symbol_table* symtab,
>>>> // The symbol requires a GOT section.
>>>> Output_data_got<64, false>* got = target->got_section(symtab, layout);
>>>>
>>>> - // If the relocation symbol isn't IFUNC,
>>>> - // and is local, then we will convert
>>>> - // mov foo@GOTPCREL(%rip), %reg
>>>> - // to lea foo(%rip), %reg.
>>>> - // in Relocate::relocate.
>>>> - if (r_type == elfcpp::R_X86_64_GOTPCREL
>>>> - && reloc.get_r_offset() >= 2
>>>> - && !is_ifunc)
>>>> - {
>>>> - section_size_type stype;
>>>> - const unsigned char* view = object->section_contents(data_shndx,
>>>> - &stype, true);
>>>> - if (view[reloc.get_r_offset() - 2] == 0x8b)
>>>> - break;
>>>> - }
>>>> -
>>>> -
>>>> // The symbol requires a GOT entry.
>>>> unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
>>>>
>>>> @@ -2906,21 +2889,6 @@ Target_x86_64<size>::Scan::global(Symbol_table* symtab,
>>>> // The symbol requires a GOT entry.
>>>> Output_data_got<64, false>* got = target->got_section(symtab, layout);
>>>>
>>>> - // If we convert this from
>>>> - // mov foo@GOTPCREL(%rip), %reg
>>>> - // to lea foo(%rip), %reg.
>>>> - // in Relocate::relocate, then there is nothing to do here.
>>>> - if (r_type == elfcpp::R_X86_64_GOTPCREL
>>>> - && reloc.get_r_offset() >= 2
>>>> - && Target_x86_64<size>::can_convert_mov_to_lea(gsym))
>>>> - {
>>>> - section_size_type stype;
>>>> - const unsigned char* view = object->section_contents(data_shndx,
>>>> - &stype, true);
>>>> - if (view[reloc.get_r_offset() - 2] == 0x8b)
>>>> - break;
>>>> - }
>>>> -
>>>
>>> If you remove those changes, won't it generate an unused GOT slot
>>> when GOTPCREL relocation is converted to PC-relative relocation?
>>
>> Yes, it can generate unused GOT slots.
>>
>
> I think we should add a testcase to check for the unused GOT slot.
> Please check if you can implement similar heuristic in gold:
>
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=59cab532835904f368b0aa99267afba5fda5ded2
No addresses available at the time of Target_x86_64<size>::Scan::local
and *::global work, so not clear how to use some heuristics here...
--
WBR,
Andrew