diff mbox

PR46667, fix section type conflicts

Message ID 4CF76168.6060806@codesourcery.com
State New
Headers show

Commit Message

Chung-Lin Tang Dec. 2, 2010, 9:05 a.m. UTC
Hi,
this patch tries to fix the section type conflicts seen on ARM-Linux 
(which currently prevents libstdc++ from building on trunk) and the 
reported x86-64 fails when -freorder-blocks-and-partition is involved.

The ARM fails seem to be due to DECL_ONE_ONLY symbols being treated as 
added to the .text.unlikely section; I've added a call to 
resolve_unique_section() to fill in the DECL_SECTION_NAME and 
DECL_HAS_IMPLICIT_SECTION_NAME_P values as I see are needed.

The x86-64 failure seems to be calling get_named_section() during 
dwarf2out_init(), when current_function_decl is still NULL, with the 
resulting section flags containing SECTION_WRITE. I've added an 
additional condition testing the ".text." section name prefix when decl 
is NULL.

This patch has been tested on the respective platforms with no 
regressions, and does now revive the ARM-Linux C++ build; however, I'm 
not sure whether this is a robust enough fix; it may just well be 
band-aid :P

Thanks,
Chung-Lin

2010-12-02  Chung-Lin Tang  <cltang@codesourcery.com>

         PR middle-end/46667
         * varasm.c (get_named_section): Add call to
	resolve_unique_section().
         (default_function_section): Call get_named_section() for
         DECL_ONE_ONLY decls.
         (default_section_type_flags): Start off with SECTION_CODE as
	flags value when decl is NULL and section name starts with
	".text.".

Comments

Ramana Radhakrishnan Dec. 3, 2010, 9:52 a.m. UTC | #1
On Thu, 2010-12-02 at 17:05 +0800, Chung-Lin Tang wrote:
> Hi,
> this patch tries to fix the section type conflicts seen on ARM-Linux 
> (which currently prevents libstdc++ from building on trunk) and the 
> reported x86-64 fails when -freorder-blocks-and-partition is involved.
> 
> The ARM fails seem to be due to DECL_ONE_ONLY symbols being treated as 
> added to the .text.unlikely section; I've added a call to 
> resolve_unique_section() to fill in the DECL_SECTION_NAME and 
> DECL_HAS_IMPLICIT_SECTION_NAME_P values as I see are needed.

I can't approve or reject your patch but ..

I don't see how that is wrong. Looking at a backtrace it does appear as
though a decl that needs a unique section gets a .text.unlikely. I've
tested your patch and it restores the testing to something sane.

Can someone approve this part of the patch to unbreak ARM builds of
libstdc++ ? 

Thanks,
Ramana
diff mbox

Patch

Index: varasm.c
===================================================================
--- varasm.c	(revision 167365)
+++ varasm.c	(working copy)
@@ -380,6 +380,10 @@ 
   unsigned int flags;
 
   gcc_assert (!decl || DECL_P (decl));
+
+  if (decl)
+    resolve_unique_section (decl, reloc, 0);
+
   if (name == NULL)
     name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
 
@@ -533,6 +537,9 @@ 
 default_function_section (tree decl, enum node_frequency freq,
 			  bool startup, bool exit)
 {
+  if (decl && DECL_ONE_ONLY (decl))
+    return get_named_section (decl, NULL, 0);
+
   /* Startup code should go to startup subsection unless it is
      unlikely executed (this happens especially with function splitting
      where we can split away unnecesary parts of static constructors.  */
@@ -5934,7 +5941,8 @@ 
 {
   unsigned int flags;
 
-  if (decl && TREE_CODE (decl) == FUNCTION_DECL)
+  if ((decl && TREE_CODE (decl) == FUNCTION_DECL)
+      || (!decl && strncmp (name, ".text.", 6) == 0))
     flags = SECTION_CODE;
   else if (decl && decl_readonly_section (decl, reloc))
     flags = 0;