This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Allow pie links to create PLT entries


Hi Cary,

   Like we discussed off-line, I have made this patch x86_64 specific
to allow R_X86_64_PC32 relocations to function symbols to create PLT
entries.

Thanks
Sri

On Fri, Jan 30, 2015 at 1:04 PM, Magnus Granberg <zorry@gentoo.org> wrote:
> fredag 30 januari 2015 12.15.29 skrev  H.J. Lu:
>> >>>>>
>> >>>>> movslq   0x1655(%rip),%rax  # 401b80 <i>
>> >>>>> mov    0x401b30(,%rax,4),%esi # a[i]
>> >>
>> >> If you link it with -pie, you will have TEXTREL in executable.
>> >> Do you want relocations in text sections in PIE?
>> >
>> > I have been told TEXTRELs are not preferred though I never understood why.
>> >
>> > Just to make sure I understand, are you saying that the absolute
>> > address in the case of -pie will be a text relocation?   I think that
>>
>> It is not about absolute address.  It is about symbol address.  Since
>> the address of symbol, a,  in
>>
>> movl a(,%rdi,4), %eax
>>
>> is unknown at link-time, linker has to generate relocation in text
>> section to resolve it at run-time.
>
> The sections need to be writeble and you can do change in that section and
> that is not good from a security piont of view.  You may even get performance
> penalties. I see no point to use no -fPIE objects in executable when you can
> get gcc to handel it with some patches. Gentoo Hardened have been building
> executable with -fPIE and linke with -pie for ages and it even a tread on gcc-
> patches ml to get support to Gcc 5.0
>
> /Magnus G.
>
>>
>> > is not true because this mov instruction
>> >
>> > mov    0x401b30(,%rax,4),%esi
>> >
>> > does not allow a 64-bit absolute value which is needed for -pie.  What
>> > I was instead suggesting is to  make that PC-relative like:
>> >
>> > mov    0xabcd(%rip,%rax,4),%esi
>> >
>> > which would not need a text relocation.  However, I do not think such
>> > an insn is supported yet, thought it would be useful.
>>
>> That will be useful.
>

Attachment: allow_plt_for_pie_x86_64.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]