This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Allow copy relocations with pie links
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Sriraman Tallam <tmsriram at google dot com>
- Cc: Cary Coutant <ccoutant at google dot com>, binutils <binutils at sourceware dot org>, Ian Lance Taylor <iant at google dot com>, David Li <davidxl at google dot com>
- Date: Thu, 8 May 2014 12:27:31 -0700
- Subject: Re: Allow copy relocations with pie links
- Authentication-results: sourceware.org; auth=none
- References: <CAAs8HmxwPuH7_s1yLxeW_6qkMCB+_kYSzB6yYG85QZS6yVHpZg at mail dot gmail dot com> <CAHACq4q9qP_h=PuwhJkE6KMt_xf6_Ne3unGRdQpvFqaXL=OxPw at mail dot gmail dot com> <CAAs8HmxkGVYAyq4wf1FChqowmQRTO9POve8Ve5f4kb3DXPfywQ at mail dot gmail dot com>
On Thu, May 8, 2014 at 11:48 AM, Sriraman Tallam <tmsriram@google.com> wrote:
> On Wed, May 7, 2014 at 4:46 PM, Cary Coutant <ccoutant@google.com> wrote:
>>> * symtab.h (may_need_copy_reloc): Extra default parameter to
>>> indicate if this is a PC relative relocation.
>>
>> In the PC-rel case, you need to check for output_is_executable. With
>> your patch, we will now allow copy relocs for pc-relative relocations
>> even in shared libraries.
>>
>> I'd prefer to move the check for output format to the points of call;
>> there are two calls in each target, one for pc-relative relocs, and
>> one for absolute relocs. For the absolute reloc, use:
>>
>> if (!parameters->options().output_is_position_independent()
>> && gsym->may_need_copy_reloc())
>>
>> For the pc-relative reloc, use:
>>
>> if (parameters->options().output_is_executable()
>> && gsym->may_need_copy_reloc())
>>
>>> * x86_64.cc (Target_x86_64<size>::Scan::global): Call
>>> may_need_copy_reloc with parameter set to true.
>>
>> Please update the other targets, too.
>
> All changes done and new patch attached. Tested *only* for x86_64.
> Appreciate help in testing other targets.
>
>
> * symtab.h (may_need_copy_reloc): Remove check for position independent
> code.
> * x86_64.cc (Target_x86_64<size>::Scan::global): Add check for no
> position independence before pc absolute may_need_copy_reloc call.
> Add check for executable output befor pc relative may_need_copy_reloc
> call.
> * i386.cc: Ditto.
> * arm.cc: Ditto.
> * sparc.cc: Ditto.
> * powerpc.cc: Ditto.
> * tilegx.cc: Ditto.
> * testsuite/pie_copyrelocs_test.cc: New file.
> * testsuite/pie_copyrelocs_shared_test.cc: New file.
> * Makefile.am (pie_copyrelocs_test): New test.
> * Makefile.in: Regenerate.
>
x86 doesn't have PC-relative data access. x86 needs
to use GOT for all data access in PIE unless run-time
text relocation is allowed. Normally x86 shouldn't have
copy relocation in PIE.
--
H.J.