This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: PATCH: PR target/39013: [4.3/4.4 regression] Missing @PLT when -fpie is used


On Thu, Jan 29, 2009 at 10:38:13AM +0100, Richard Guenther wrote:
> On Thu, Jan 29, 2009 at 5:03 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> > Functions marked inline without body won't bind locally.  This patch
> > fixes it.  OK for trunk after regression test on Linux/ia32,
> > Linux/ia64 and Linux/x86-64.
> 
> I am not sure we should test DECL_DECLARED_INLINE_P here.
> Why does the fndecl not have DECL_EXTERNAL set?  Thus, this
> IMHO looks more like a frontend issue.
> 

This patch removes DECL_DECLARED_INLINE_P.  If we don't think
it should ever happen, we should replace my change with an assert,
something like

  /* Functions without body are not local.  */
  assert (TREE_CODE (exp) != FUNCTION_DECL
	  || DECL_INITIAL (exp) != NULL
	  || local_p == false);


H.J.
-----
gcc/

2009-01-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/39013
	* varasm.c (default_binds_local_p_1): Return false for functions
	without body.

gcc/testsuite/

2009-01-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/39013
	* gcc.target/i386/pie-1.c: New.

--- gcc/testsuite/gcc.target/i386/pie-1.c.pie	2009-01-29 07:50:12.000000000 -0800
+++ gcc/testsuite/gcc.target/i386/pie-1.c	2009-01-29 07:50:12.000000000 -0800
@@ -0,0 +1,12 @@
+/* PR target/39013 */
+/* { dg-do compile { target { *-*-linux* } } } */
+/* { dg-options "-fpie" } */
+/* { dg-final { scan-assembler "call\[\\t \]*foo@PLT" } } */
+
+inline int foo (void);
+
+int
+main ()
+{
+  return foo ();
+}
--- gcc/varasm.c.pie	2008-11-30 08:49:54.000000000 -0800
+++ gcc/varasm.c	2009-01-29 07:50:46.000000000 -0800
@@ -6321,6 +6321,10 @@ default_binds_local_p_1 (const_tree exp,
 	   && (DECL_INITIAL (exp) == NULL
 	       || DECL_INITIAL (exp) == error_mark_node))
     local_p = false;
+  /* Functions without body are not local.  */
+  else if (TREE_CODE (exp) == FUNCTION_DECL
+	   && DECL_INITIAL (exp) == NULL)
+    local_p = false;
   /* Otherwise we're left with initialized (or non-common) global data
      which is of necessity defined locally.  */
   else


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