diff mbox

[google,gcc-4_8] Thunk section names

Message ID CAAs8Hmyk-AVVQGw-snzdbgArJ1E=NgOETv4xiJt=EJesEr+wBA@mail.gmail.com
State New
Headers show

Commit Message

Sriraman Tallam Feb. 6, 2014, 10:19 p.m. UTC
Patch attached.





On Thu, Feb 6, 2014 at 2:18 PM, Sriraman Tallam <tmsriram@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?

Comments

Teresa Johnson Feb. 10, 2014, 9:59 p.m. UTC | #1
Looks good. Thanks, Teresa

On Thu, Feb 6, 2014 at 2:19 PM, Sriraman Tallam <tmsriram@google.com> wrote:
> Patch attached.
>
>
>
>
>
> On Thu, Feb 6, 2014 at 2:18 PM, Sriraman Tallam <tmsriram@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
diff mbox

Patch

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" } } */