This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH x86_64] Optimize access to globals in "-fpie -pie" builds with copy relocations
- From: Sriraman Tallam <tmsriram at google dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Richard Henderson <rth at redhat dot com>, Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>, Jakub Jelinek <jakub at redhat dot com>, Uros Bizjak <ubizjak at gmail dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, David Li <davidxl at google dot com>, Cary Coutant <ccoutant at google dot com>
- Date: Thu, 5 Feb 2015 14:31:32 -0800
- Subject: Re: [PATCH x86_64] Optimize access to globals in "-fpie -pie" builds with copy relocations
- Authentication-results: sourceware.org; auth=none
- References: <20150203193615 dot GZ1746 at tucnak dot redhat dot com> <20150203221935 dot GA1746 at tucnak dot redhat dot com> <CAMe9rOq-A3YebgJ_xRnQDekYuvRw6C9GD9DYbhUizvr3OPad_Q at mail dot gmail dot com> <CAAs8Hmxdx1n+hgJ0oTAufPauz=S67oM2F_NAmyTzzUSh-ic=4Q at mail dot gmail dot com> <20150204183127 dot GU1746 at tucnak dot redhat dot com> <CAMe9rOpWUnex45v3hM9=tDNfnC6ipJ-hMEkiY1714Km15bL=bg at mail dot gmail dot com> <20150204184205 dot GW1746 at tucnak dot redhat dot com> <CAMe9rOoWkw==PQZt1hR1xjKaVxwkFh39vNbFb1WFbaxgxofJMA at mail dot gmail dot com> <CAAs8HmzByYULg8y0F2DnVo0YBnh__Jx2xSrvAoMYuWPJJb2q6A at mail dot gmail dot com> <CAMe9rOpFiaRuauCqFwUxYPEo46jPiQf8=W9+7Cf8q=1QCm0sEA at mail dot gmail dot com> <CAAs8HmwHY-vNEBdULByHYU__xKcKOarMqr-+69VRxo_kBkzwxw at mail dot gmail dot com> <CAMe9rOoGdDBpn12LFyTqdbfhdOxXgw4i9Xmk34fj=K+KzhSoAw at mail dot gmail dot com> <50365BC5-5D7C-423A-803B-F8F6F040C865 at gmail dot com> <CAMe9rOpAnkfsJMXMM=MGNfqsCsLeBdNwmyCqLk6FbbrULbKigQ at mail dot gmail dot com> <54D3BC5B dot 3080300 at redhat dot com> <CAMe9rOqxn1r6vDMqMhNWATNtrbmX6JviPSJx0hJ=bAu2tPqkkA at mail dot gmail dot com> <54D3CB8E dot 3050004 at redhat dot com> <CAAs8HmyO5hFsKTYoOxgBv9B4-Qo0rh+7VrBjuT03Qc0BCOhmPQ at mail dot gmail dot com> <CAMe9rOo8+ou8mkRJ950vQO-rZ=PrqX1JWCHAjgp2pAfOO96hXg at mail dot gmail dot com>
On Thu, Feb 5, 2015 at 2:23 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Feb 5, 2015 at 2:05 PM, Sriraman Tallam <tmsriram@google.com> wrote:
>> On Thu, Feb 5, 2015 at 11:59 AM, Richard Henderson <rth@redhat.com> wrote:
>>> On 02/05/2015 11:01 AM, H.J. Lu wrote:
>>>> Can you elaborate why it depends on COPY relocation? There
>>>> is no COPY relocation on x86-64.
>>>
>>> Ho hum, we appear to have switched topics mid-thread.
>>>
>>> I agree that we cannot override a weak symbol in the executable with even a
>>> non-weak symbol in a shared library.
>>
>> Hi HJ,
>>
>> Is your patch supposed to fix weak symbols too? Will
>> SYMBOL_REF_LOCAL_P evaluate to true for weak defined symbols with this
>> patch? I tested this in gcc-4_9 and it didnt seem to do that.
>
> I am working on a comprehensive patch. I will post it
> after testing is finished.
Thanks!
Sri
>
> --
> H.J.
> --
> [hjl@gnu-6 copyreloc-3]$ cat initweak.i
> __attribute__((weak))
> int xxxxxxxxxxxx = -1;
>
> int
> foo ()
> {
> return xxxxxxxxxxxx;
> }
> [hjl@gnu-6 copyreloc-3]$ cat commonweak.i
> __attribute__((weak))
> int xxxxxxxxxxxx;
>
> int
> foo ()
> {
> return xxxxxxxxxxxx;
> }
> [hjl@gnu-6 copyreloc-3]$ make initweak.s commonweak.s
> /export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc
> -B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -pie -fpie -O3
> -fuse-ld=gold -S initweak.i
> /export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc
> -B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -pie -fpie -O3
> -fuse-ld=gold -S commonweak.i
> [hjl@gnu-6 copyreloc-3]$ cat commonweak.s initweak.s
> .file "commonweak.i"
> .section .text.unlikely,"ax",@progbits
> .LCOLDB0:
> .text
> .LHOTB0:
> .p2align 4,,15
> .globl foo
> .type foo, @function
> foo:
> .LFB0:
> .cfi_startproc
> movl xxxxxxxxxxxx(%rip), %eax
> ret
> .cfi_endproc
> .LFE0:
> .size foo, .-foo
> .section .text.unlikely
> .LCOLDE0:
> .text
> .LHOTE0:
> .weak xxxxxxxxxxxx
> .bss
> .align 4
> .type xxxxxxxxxxxx, @object
> .size xxxxxxxxxxxx, 4
> xxxxxxxxxxxx:
> .zero 4
> .ident "GCC: (GNU) 5.0.0 20150205 (experimental)"
> .section .note.GNU-stack,"",@progbits
> .file "initweak.i"
> .section .text.unlikely,"ax",@progbits
> .LCOLDB0:
> .text
> .LHOTB0:
> .p2align 4,,15
> .globl foo
> .type foo, @function
> foo:
> .LFB0:
> .cfi_startproc
> movl xxxxxxxxxxxx(%rip), %eax
> ret
> .cfi_endproc
> .LFE0:
> .size foo, .-foo
> .section .text.unlikely
> .LCOLDE0:
> .text
> .LHOTE0:
> .weak xxxxxxxxxxxx
> .data
> .align 4
> .type xxxxxxxxxxxx, @object
> .size xxxxxxxxxxxx, 4
> xxxxxxxxxxxx:
> .long -1
> .ident "GCC: (GNU) 5.0.0 20150205 (experimental)"
> .section .note.GNU-stack,"",@progbits
> [hjl@gnu-6 copyreloc-3]$