public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PowerPC section type conflict
@ 2011-12-16 11:36 Chung-Lin Tang
  2011-12-16 22:22 ` Richard Henderson
  0 siblings, 1 reply; 9+ messages in thread
From: Chung-Lin Tang @ 2011-12-16 11:36 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]


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  <cltang@codesourcery.com>

	gcc/
	* varasm.c (default_section_type_flags): Set SECTION_CODE in
	flags when decl is NULL_TREE, and section name matches ".text*".


[-- Attachment #2: varasm.diff --]
[-- Type: text/plain, Size: 415 bytes --]

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)
     {

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-12-29 21:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-16 11:36 [PATCH] PowerPC section type conflict Chung-Lin Tang
2011-12-16 22:22 ` Richard Henderson
2011-12-18  6:37   ` Chung-Lin Tang
2011-12-18 21:26     ` Richard Henderson
2011-12-19 16:15       ` [PATCH] PowerPC section type conflict (created PR 51623) Chung-Lin Tang
2011-12-28 18:32         ` Michael Meissner
2011-12-28 20:43           ` Richard Henderson
2011-12-28 20:50             ` Michael Meissner
2011-12-29 21:33             ` Michael Meissner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).