public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch] Potential fix for PR55033
@ 2012-10-23 16:38 Sebastian Huber
  2012-10-24 15:17 ` Alan Modra
  2012-10-26 12:35 ` Sebastian Huber
  0 siblings, 2 replies; 10+ messages in thread
From: Sebastian Huber @ 2012-10-23 16:38 UTC (permalink / raw)
  To: GCC Patches

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


-- 
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


[-- Attachment #2: 0001-Potential-fix-for-PR55033.patch --]
[-- Type: text/x-patch, Size: 2622 bytes --]

From 7770cb04ee95666e745f96b779edec10560203e6 Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Tue, 23 Oct 2012 18:06:25 +0200
Subject: [PATCH] Potential fix for PR55033

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55033

This patch fixes my problem, but I am absolutely not sure if this is the
right way.

We have in gcc/varasm.c:

[...]
static bool
decl_readonly_section_1 (enum section_category category)
{
  switch (category)
    {
    case SECCAT_RODATA:
    case SECCAT_RODATA_MERGE_STR:
    case SECCAT_RODATA_MERGE_STR_INIT:
    case SECCAT_RODATA_MERGE_CONST:
    case SECCAT_SRODATA:
      return true;
    default:
      return false;
    }
}
[...]
section *
default_elf_select_section (tree decl, int reloc,
			    unsigned HOST_WIDE_INT align)
{
  const char *sname;
  switch (categorize_decl_for_section (decl, reloc))
    {
    case SECCAT_TEXT:
      /* We're not supposed to be called on FUNCTION_DECLs.  */
      gcc_unreachable ();
    case SECCAT_RODATA:
      return readonly_data_section;
    case SECCAT_RODATA_MERGE_STR:
      return mergeable_string_section (decl, align, 0);
    case SECCAT_RODATA_MERGE_STR_INIT:
      return mergeable_string_section (DECL_INITIAL (decl), align, 0);
    case SECCAT_RODATA_MERGE_CONST:
      return mergeable_constant_section (DECL_MODE (decl), align, 0);
    case SECCAT_SRODATA:
      sname = ".sdata2";
      break;
[...]

All read-only sections have a special object except SECCAT_SRODATA.
Thus it is created with get_named_section() and potentially decl ==
NULL.  The patch adds another special case to
default_section_type_flags().

2012-10-23  Sebastian Huber <sebastian.huber@embedded-brains.de>

	PR middle-end/55033
	* varasm.c (default_section_type_flags): If decl is NULL and
	name is .sdata2, set flags to 0.
---
 gcc/varasm.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/gcc/varasm.c b/gcc/varasm.c
index a587c80..d0941f3 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -5937,10 +5937,15 @@ default_section_type_flags (tree decl, const char *name, int reloc)
     }
   else
     {
-      flags = SECTION_WRITE;
-      if (strcmp (name, ".data.rel.ro") == 0
-	  || strcmp (name, ".data.rel.ro.local") == 0)
-	flags |= SECTION_RELRO;
+      if (strcmp (name, ".sdata2") != 0)
+        {
+          flags = SECTION_WRITE;
+          if (strcmp (name, ".data.rel.ro") == 0
+              || strcmp (name, ".data.rel.ro.local") == 0)
+            flags |= SECTION_RELRO;
+        }
+      else
+        flags = 0;
     }
 
   if (decl && DECL_ONE_ONLY (decl))
-- 
1.7.7


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

end of thread, other threads:[~2013-01-29 17:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-23 16:38 [Patch] Potential fix for PR55033 Sebastian Huber
2012-10-24 15:17 ` Alan Modra
2012-10-25  9:10   ` Sebastian Huber
2012-10-30 14:18   ` Sebastian Huber
2013-01-29 14:40   ` Sebastian Huber
2013-01-29 17:05     ` Sebastian Huber
2012-10-26 12:35 ` Sebastian Huber
2012-10-30 14:12   ` Sebastian Huber
2012-10-31  0:36     ` Alan Modra
2012-10-31 14:02       ` Sebastian Huber

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