This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Locate thunks with thunkee
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 29 Dec 2005 16:42:41 +0000
- Subject: [C++ PATCH] Locate thunks with thunkee
I've installed this patch to make thunks non-weak when the target function is
non-weak. Making them always weak can place them far away from the target
function, and can cause problems on systems with limited branch ranges.
tested on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2005-12-29 Nathan Sidwell <nathan@codesourcery.com>
* varasm.c (get_section): Use gcc_assert.
* method.c (make_thunk): Don't set comdat_linkage here.
(use_thunk): Make thunk one only here, if thunk target is
DECL_ONE_ONLY.
* g++.dg/abi/thunk3.C: New.
* g++.dg/abi/thunk4.C: New.
Index: testsuite/g++.dg/abi/thunk3.C
===================================================================
--- testsuite/g++.dg/abi/thunk3.C (revision 0)
+++ testsuite/g++.dg/abi/thunk3.C (revision 0)
@@ -0,0 +1,20 @@
+// { dg-final { scan-assembler-not ".weak\t_ZThn4_N7Derived3FooEv" } }
+
+struct Base
+{
+ virtual void Foo ();
+};
+
+struct Filler
+{
+ virtual void Baz ();
+};
+
+struct Derived : Filler, Base
+{
+ virtual void Foo ();
+};
+
+void Derived::Foo ()
+{
+}
Index: testsuite/g++.dg/abi/thunk4.C
===================================================================
--- testsuite/g++.dg/abi/thunk4.C (revision 0)
+++ testsuite/g++.dg/abi/thunk4.C (revision 0)
@@ -0,0 +1,22 @@
+// { dg-final { scan-assembler ".weak\t_ZThn4_N7Derived3FooEv" } }
+
+struct Base
+{
+ virtual void Foo ();
+};
+
+struct Filler
+{
+ virtual void Baz ();
+};
+
+struct Derived : Filler, Base
+{
+ virtual void Foo ();
+};
+
+inline void Derived::Foo ()
+{
+}
+
+Derived f;
Index: cp/method.c
===================================================================
--- cp/method.c (revision 109139)
+++ cp/method.c (working copy)
@@ -137,8 +137,6 @@ make_thunk (tree function, bool this_adj
TREE_READONLY (thunk) = TREE_READONLY (function);
TREE_THIS_VOLATILE (thunk) = TREE_THIS_VOLATILE (function);
TREE_PUBLIC (thunk) = TREE_PUBLIC (function);
- if (flag_weak)
- comdat_linkage (thunk);
SET_DECL_THUNK_P (thunk, this_adjusting);
THUNK_TARGET (thunk) = function;
THUNK_FIXED_OFFSET (thunk) = d;
@@ -381,8 +379,8 @@ use_thunk (tree thunk_fndecl, bool emit_
DECL_VISIBILITY (thunk_fndecl) = DECL_VISIBILITY (function);
DECL_VISIBILITY_SPECIFIED (thunk_fndecl)
= DECL_VISIBILITY_SPECIFIED (function);
- if (flag_weak && TREE_PUBLIC (thunk_fndecl))
- comdat_linkage (thunk_fndecl);
+ if (DECL_ONE_ONLY (function))
+ make_decl_one_only (thunk_fndecl);
if (flag_syntax_only)
{
Index: varasm.c
===================================================================
--- varasm.c (revision 109139)
+++ varasm.c (working copy)
@@ -249,10 +249,8 @@ get_section (const char *name, unsigned
/* Sanity check user variables for flag changes. */
if (decl == 0)
decl = sect->named.decl;
- if (decl)
- error ("%+D causes a section type conflict", decl);
- else
- gcc_unreachable ();
+ gcc_assert (decl);
+ error ("%+D causes a section type conflict", decl);
}
}
return sect;