public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [google gcc-4_8][x86_64]Optimize access to globals in "-fpie -pie" builds with copy relocations
@ 2014-05-22 23:36 Sriraman Tallam
  2014-05-23  0:01 ` Paul Pluzhnikov
  0 siblings, 1 reply; 4+ messages in thread
From: Sriraman Tallam @ 2014-05-22 23:36 UTC (permalink / raw)
  To: GCC Patches, David Li, Paul Pluzhnikov

[-- Attachment #1: Type: text/plain, Size: 222 bytes --]

This patch is pending review for trunk. Please see if this is ok to
commit to google/gcc-4_8 branch. Please see this for more details:

https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01215.html

Patch attached.

Thanks
Sri

[-- Attachment #2: gcc_google_4_8_pie_copyrelocs_patch.txt --]
[-- Type: text/plain, Size: 2461 bytes --]

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 210728)
+++ config/i386/i386.c	(working copy)
@@ -12540,7 +12540,10 @@ legitimate_pic_address_disp_p (rtx disp)
 	  /* TLS references should always be enclosed in UNSPEC.  */
 	  if (SYMBOL_REF_TLS_MODEL (op0))
 	    return false;
-	  if (!SYMBOL_REF_FAR_ADDR_P (op0) && SYMBOL_REF_LOCAL_P (op0)
+	  if (!SYMBOL_REF_FAR_ADDR_P (op0)
+	      && (SYMBOL_REF_LOCAL_P (op0)
+	          || (TARGET_64BIT && ix86_ld_pie_copyrelocs && flag_pie
+	    	      && !SYMBOL_REF_FUNCTION_P (op0)))
 	      && ix86_cmodel != CM_LARGE_PIC)
 	    return true;
 	  break;
Index: config/i386/i386.opt
===================================================================
--- config/i386/i386.opt	(revision 210728)
+++ config/i386/i386.opt	(working copy)
@@ -198,6 +198,10 @@ mfancy-math-387
 Target RejectNegative Report InverseMask(NO_FANCY_MATH_387, USE_FANCY_MATH_387) Save
 Generate sin, cos, sqrt for FPU
 
+mld-pie-copyrelocs
+Target Report Var(ix86_ld_pie_copyrelocs) Init(0)
+Use linker copy relocs for pie
+
 mforce-drap
 Target Report Var(ix86_force_drap)
 Always use Dynamic Realigned Argument Pointer (DRAP) to realign stack
Index: testsuite/gcc.target/i386/ld-pie-copyrelocs-1.c
===================================================================
--- testsuite/gcc.target/i386/ld-pie-copyrelocs-1.c	(revision 0)
+++ testsuite/gcc.target/i386/ld-pie-copyrelocs-1.c	(revision 0)
@@ -0,0 +1,13 @@
+/* Test if -mld-pie-copyrelocs does the right thing. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fpie -mld-pie-copyrelocs" } */
+
+extern int glob_a;
+
+int foo ()
+{
+  return glob_a;
+}
+
+/* glob_a should never be accessed with a GOTPCREL  */ 
+/* { dg-final { scan-assembler-not "glob_a\\@GOTPCREL" { target { x86_64-*-* } } } } */
Index: testsuite/gcc.target/i386/ld-pie-copyrelocs-2.c
===================================================================
--- testsuite/gcc.target/i386/ld-pie-copyrelocs-2.c	(revision 0)
+++ testsuite/gcc.target/i386/ld-pie-copyrelocs-2.c	(revision 0)
@@ -0,0 +1,13 @@
+/* Test if -mno-ld-pie-copyrelocs does the right thing. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fpie -mno-ld-pie-copyrelocs" } */
+
+extern int glob_a;
+
+int foo ()
+{
+  return glob_a;
+}
+
+/* glob_a should always be accessed via GOT  */ 
+/* { dg-final { scan-assembler "glob_a\\@GOT" { target { x86_64-*-* } } } } */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [google gcc-4_8][x86_64]Optimize access to globals in "-fpie -pie" builds with copy relocations
  2014-05-22 23:36 [google gcc-4_8][x86_64]Optimize access to globals in "-fpie -pie" builds with copy relocations Sriraman Tallam
@ 2014-05-23  0:01 ` Paul Pluzhnikov
  2014-05-23  0:04   ` Xinliang David Li
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Pluzhnikov @ 2014-05-23  0:01 UTC (permalink / raw)
  To: Sriraman Tallam; +Cc: GCC Patches, David Li

On Thu, May 22, 2014 at 4:36 PM, Sriraman Tallam <tmsriram@google.com> wrote:
> This patch is pending review for trunk. Please see if this is ok to
> commit to google/gcc-4_8 branch. Please see this for more details:
>
> https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01215.html

+mld-pie-copyrelocs
+Target Report Var(ix86_ld_pie_copyrelocs) Init(0)
+Use linker copy relocs for pie

They are not "linker copy relocs", they are simply "copy relocations".

So I would call the option "-mcopy-relocs" and be done with that. But this
is just bike-shedding :-)

LGTM.
-- 
Paul Pluzhnikov

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [google gcc-4_8][x86_64]Optimize access to globals in "-fpie -pie" builds with copy relocations
  2014-05-23  0:01 ` Paul Pluzhnikov
@ 2014-05-23  0:04   ` Xinliang David Li
  2014-05-23 20:43     ` Sriraman Tallam
  0 siblings, 1 reply; 4+ messages in thread
From: Xinliang David Li @ 2014-05-23  0:04 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: Sriraman Tallam, GCC Patches

Also missing documentation in invoke.texi? Other than that, ok.

David

On Thu, May 22, 2014 at 5:00 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
> On Thu, May 22, 2014 at 4:36 PM, Sriraman Tallam <tmsriram@google.com> wrote:
>> This patch is pending review for trunk. Please see if this is ok to
>> commit to google/gcc-4_8 branch. Please see this for more details:
>>
>> https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01215.html
>
> +mld-pie-copyrelocs
> +Target Report Var(ix86_ld_pie_copyrelocs) Init(0)
> +Use linker copy relocs for pie
>
> They are not "linker copy relocs", they are simply "copy relocations".
>
> So I would call the option "-mcopy-relocs" and be done with that. But this
> is just bike-shedding :-)
>
> LGTM.
> --
> Paul Pluzhnikov

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [google gcc-4_8][x86_64]Optimize access to globals in "-fpie -pie" builds with copy relocations
  2014-05-23  0:04   ` Xinliang David Li
@ 2014-05-23 20:43     ` Sriraman Tallam
  0 siblings, 0 replies; 4+ messages in thread
From: Sriraman Tallam @ 2014-05-23 20:43 UTC (permalink / raw)
  To: Xinliang David Li; +Cc: Paul Pluzhnikov, GCC Patches

On Thu, May 22, 2014 at 5:04 PM, Xinliang David Li <davidxl@google.com> wrote:
> Also missing documentation in invoke.texi? Other than that, ok.

I have made the changes and committed my patch.

Sri

>
> David
>
> On Thu, May 22, 2014 at 5:00 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
>> On Thu, May 22, 2014 at 4:36 PM, Sriraman Tallam <tmsriram@google.com> wrote:
>>> This patch is pending review for trunk. Please see if this is ok to
>>> commit to google/gcc-4_8 branch. Please see this for more details:
>>>
>>> https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01215.html
>>
>> +mld-pie-copyrelocs
>> +Target Report Var(ix86_ld_pie_copyrelocs) Init(0)
>> +Use linker copy relocs for pie
>>
>> They are not "linker copy relocs", they are simply "copy relocations".
>>
>> So I would call the option "-mcopy-relocs" and be done with that. But this
>> is just bike-shedding :-)
>>
>> LGTM.
>> --
>> Paul Pluzhnikov

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-23 20:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-22 23:36 [google gcc-4_8][x86_64]Optimize access to globals in "-fpie -pie" builds with copy relocations Sriraman Tallam
2014-05-23  0:01 ` Paul Pluzhnikov
2014-05-23  0:04   ` Xinliang David Li
2014-05-23 20:43     ` Sriraman Tallam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).