Patch attached.




On Thu, Feb 6, 2014 at 2:18 PM, Sriraman Tallam <tmsri...@google.com> wrote:
> I sent the following patch for review for trunk commit here. Details here:
> http://gcc.gnu.org/ml/gcc-patches/2014-02/msg00328.html
>
> This is important for function layout for the following reason.
> Without this patch, the thunk's section name is the same as the original
> function's section name for which the thunk is created.  This affects function
> layout as it is not possible to figure out the thunk section from the name
> alone.  With this patch, the thunk's section name is suffixed with the mangled
> name of the thunk and this solves the problem.
>
> Is this patch ok for google/gcc-4_8?
>
> Sri
I sent the following patch for review for trunk commit here. Details here:
http://gcc.gnu.org/ml/gcc-patches/2014-02/msg00328.html

This is important for function layout for the following reason.
Without this patch, the thunk's section name is the same as the original
function's section name for which the thunk is created.  This affects function
layout as it is not possible to figure out the thunk section from the name
alone.  With this patch, the thunk's section name is suffixed with the mangled
name of the thunk and this solves the problem.  

Is this patch ok for google/gcc-4_8?

Index: cp/method.c
===================================================================
--- cp/method.c (revision 207581)
+++ cp/method.c (working copy)
@@ -360,8 +360,10 @@ use_thunk (tree thunk_fndecl, bool emit_p)
        {
          resolve_unique_section (thunk_fndecl, 0, flag_function_sections);
 
-         /* Output the thunk into the same section as function.  */
-         DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function);
+         /* Output the thunk into the same section as function if function 
reordering
+            is not switched on.  */
+         if (!flag_reorder_functions)
+           DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function);
        }
     }
 
Index: testsuite/g++.dg/thunk_section_name.C
===================================================================
--- testsuite/g++.dg/thunk_section_name.C       (revision 0)
+++ testsuite/g++.dg/thunk_section_name.C       (revision 0)
@@ -0,0 +1,30 @@
+/* { dg-require-named-sections "" } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-reorder-blocks-and-partition -ffunction-sections" } 
*/
+
+class base_class_1
+{
+public:
+  virtual void vfn () {}
+};
+
+class base_class_2
+{
+public:
+  virtual void vfn () {}
+};
+
+class need_thunk_class : public base_class_1, public base_class_2
+{
+public:
+  virtual void vfn () {} 
+};
+
+int main (int argc, char *argv[])
+{
+  base_class_1 *c = new need_thunk_class ();
+  c->vfn();
+  return 0;
+}
+
+/* { dg-final { scan-assembler "\.text\._ZThn8_N16need_thunk_class3vfnEv" } } 
*/

Reply via email to