From patchwork Tue Oct 23 16:25:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Huber X-Patchwork-Id: 193522 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5BC312C0109 for ; Wed, 24 Oct 2012 03:25:58 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1351614358; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=cTOGfix X/hTaHa4aoBRVtOELThU=; b=GIYvvkoyYC/SSo3/z9bSWT73NmBSPfjYM1Pp5hP lP5Qw04Ophl33NQfRcTy/2ADtR3IPWJBmDUPBxtMmLiTs75eEFVqKqch29Qh4Psf 7RZmhMUgr0ppvWMsZdKCkJWI0molg61EKTkcSBKDyNEMXHQyBWF6bybcLgGtF2+k 5nrA= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=jRi05ViTdJIZtIS9vOcepGHyGO385E67fPI/5e7Y/FtF32N2a7wxLEIoV/N3rU +ad2yzSmWXykJ89jx8VDaR9WMK9KacZ+TfX3RwcjEg4IblqWAbrbqXKdMZvtGBHm 5p8q8ILqRj2gEedeLllRathXmbBFdbQUHrgoE/SKo4OGs=; Received: (qmail 32470 invoked by alias); 23 Oct 2012 16:25:55 -0000 Received: (qmail 32448 invoked by uid 22791); 23 Oct 2012 16:25:54 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL, BAYES_00, RDNS_DYNAMIC, T_FILL_THIS_FORM_SHORT X-Spam-Check-By: sourceware.org Received: from host-82-135-62-35.customer.m-online.net (HELO mail.embedded-brains.de) (82.135.62.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Oct 2012 16:25:48 +0000 Received: by mail.embedded-brains.de (Postfix, from userid 65534) id 60524652BFD; Tue, 23 Oct 2012 18:25:44 +0200 (CEST) Received: from [192.168.96.64] (eb0024.eb.z [192.168.96.64]) by mail.embedded-brains.de (Postfix) with ESMTP id B9B01652BFB for ; Tue, 23 Oct 2012 18:25:43 +0200 (CEST) Message-ID: <5086C507.5080905@embedded-brains.de> Date: Tue, 23 Oct 2012 18:25:43 +0200 From: Sebastian Huber User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120601 Thunderbird/13.0 MIME-Version: 1.0 To: GCC Patches Subject: [Patch] Potential fix for PR55033 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org From 7770cb04ee95666e745f96b779edec10560203e6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber 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 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