This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR gold/16945: Executable with -fpie and -mcmodel=large gives segfault on start
- From: Alexander Ivchenko <aivchenk at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils <binutils at sourceware dot org>, Cary Coutant <ccoutant at google dot com>
- Date: Thu, 15 May 2014 22:13:47 +0400
- Subject: Re: PATCH: PR gold/16945: Executable with -fpie and -mcmodel=large gives segfault on start
- Authentication-results: sourceware.org; auth=none
- References: <20140515173129 dot GA19564 at intel dot com> <CACysShjg4vz0VB=3TtuPPW_RNCBQrD67puA9=KEauuOURy66vA at mail dot gmail dot com> <CAMe9rOoyqZUWo0Sgkfe6ec4dnKMyLFHmSQjbQ4FCOgrhkvf59A at mail dot gmail dot com>
I just don't get why got_offset sometimes "unsigned int", sometimes
"section_offset_type" and now "int". I guess it's just a little mess.
I believe that the right way is having it as "ptrdiff", which is the
same "section_offset_type".
2014-05-15 22:09 GMT+04:00 H.J. Lu <hjl.tools@gmail.com>:
> On Thu, May 15, 2014 at 11:02 AM, Alexander Ivchenko <aivchenk@gmail.com> wrote:
>> Shouldn't got_offset be the type of section_offset_type ?
>
> That also works.
>
>> 2014-05-15 21:31 GMT+04:00 H.J. Lu <hongjiu.lu@intel.com>:
>>> There are 2 issues:
>>>
>>> 1. Since the GOT offset is always negative, we need to use signed int
>>> to support 64-bit GOT relocations.
>>> 2. R_X86_64_PLTOFF64 uses the address of GLOBAL_OFFSET_TABLE, which is
>>> the address of the .got.plt section, not the .got section.
>>>
>>> This patch fixes both. OK for master and 2.24 branch?
>>>
>>> Thanks.
>>>
>>> H.J.
>>> ---
>>> 2014-05-15 H.J. Lu <hongjiu.lu@intel.com>
>>>
>>> PR gold/16945
>>> * x86_64.cc (Target_x86_64::Relocate::relocate): Use signed int
>>> for got_offset. Properly get GOT address for R_X86_64_PLTOFF64.
>>>
>>> diff --git a/gold/x86_64.cc b/gold/x86_64.cc
>>> index 479fb42..f58c843 100644
>>> --- a/gold/x86_64.cc
>>> +++ b/gold/x86_64.cc
>>> @@ -3327,7 +3327,9 @@ Target_x86_64<size>::Relocate::relocate(
>>> // We need to subtract the size of the GOT section to get
>>> // the actual offset to use in the relocation.
>>> bool have_got_offset = false;
>>> - unsigned int got_offset = 0;
>>> + // Since the actual offset is always negative, we use signed int to
>>> + // support 64-bit GOT relocations.
>>
>
> --
> H.J.