PATCH: Replace @PLT with @GOTPCREL(%rip) in call
H.J. Lu
hjl.tools@gmail.com
Fri Mar 4 23:40:00 GMT 2016
On Thu, Mar 3, 2016 at 4:03 PM, Roland McGrath <roland@hack.frob.com> wrote:
>> --- a/sysdeps/x86_64/crti.S
>> +++ b/sysdeps/x86_64/crti.S
>> @@ -66,7 +66,7 @@ _init:
>> movq PREINIT_FUNCTION@GOTPCREL(%rip), %rax
>> testq %rax, %rax
>> je .Lno_weak_fn
>> - call PREINIT_FUNCTION@PLT
>> + call *PREINIT_FUNCTION@GOTPCREL(%rip)
>
> Can't this just be "call *%rax"?
Good idea.
>> --- a/sysdeps/x86_64/start.S
>> +++ b/sysdeps/x86_64/start.S
>> @@ -105,7 +105,7 @@ ENTRY (_start)
>>
>> /* Call the user's main function, and exit with its value.
>> But let the libc call main. */
>> - call __libc_start_main@PLT
>> + call *__libc_start_main@GOTPCREL(%rip)
>> #else
>> /* Pass address of our own entry points to .fini and .init. */
>> mov $__libc_csu_fini, %R8_LP
>
> In the general case, foo@PLT is preferable to foo@GOTPCREL(%rip) because it
> allows for lazy resolution. That's not worthwhile here because _start is
> presumably always run and run very early. But it merits a comment saying
> why it's not following the normal pattern for PIC calls.
>
Here are updated patches.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Replace-PLT-with-GOTPCREL-rip-in-call.patch
Type: text/x-patch
Size: 1714 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160304/ad0a35a1/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Replace-PREINIT_FUNCTION-PLT-with-rax-in-call.patch
Type: text/x-patch
Size: 1324 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160304/ad0a35a1/attachment-0001.bin>
More information about the Libc-alpha
mailing list