Hi, under powerpc targets, using -mrelocatable under some cases triggers an error during final assembly generation: rs6000_assemble_integer() calls varasm.c:unlikely_text_section_p(), and the call chain eventually gets to where the section htab is queried for ".text.unlikely", and fails because of mismatched section flags: "error: foo causes a section type conflict"
This seems to happen after rev.167085, 4.6 branch is also affected. The flag mismatch seems quite straightforward: current_function_decl is passed in as the decl here, and as it's final assembly now, it is NULL_TREE. varasm.c:default_section_type_flags() adds SECTION_WRITE to its return value, and things get borked. This patch simply adds a condition to the SECTION_CODE case, to include when decl == NULL_TREE, and the queried section has a .text* name. I think this should be the intuitive way, and it does allow the testcase to compile. Tested on a powerpc target, is this okay for trunk? (and maybe 4.6 too?) Thanks, Chung-Lin 2011-12-16 Chung-Lin Tang <clt...@codesourcery.com> gcc/ * varasm.c (default_section_type_flags): Set SECTION_CODE in flags when decl is NULL_TREE, and section name matches ".text*".
Index: trunk/gcc/varasm.c =================================================================== --- trunk/gcc/varasm.c (revision 182398) +++ trunk/gcc/varasm.c (working copy) @@ -6218,7 +6218,8 @@ { unsigned int flags; - if (decl && TREE_CODE (decl) == FUNCTION_DECL) + if (decl ? TREE_CODE (decl) == FUNCTION_DECL + : strncmp (name, ".text", 5) == 0) flags = SECTION_CODE; else if (decl) {