[PATCH] PR gold/18609
H.J. Lu
hjl.tools@gmail.com
Mon Jul 20 16:28:00 GMT 2015
On Mon, Jul 20, 2015 at 9:22 AM, Andrew Senkevich
<andrew.n.senkevich@gmail.com> wrote:
> 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...
>
There are no addresses available in ld.bfd neither. An estimate was
used in ld.bfd.
--
H.J.
More information about the Binutils
mailing list