-- 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.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>From 7770cb04ee95666e745f96b779edec10560203e6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber <sebastian.hu...@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.hu...@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