From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116852 invoked by alias); 30 Aug 2019 10:14:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 116823 invoked by uid 89); 30 Aug 2019 10:14:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-wm1-f44.google.com Received: from mail-wm1-f44.google.com (HELO mail-wm1-f44.google.com) (209.85.128.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Aug 2019 10:14:16 +0000 Received: by mail-wm1-f44.google.com with SMTP id y135so4046262wmc.1 for ; Fri, 30 Aug 2019 03:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mittosystems.com; s=google; h=date:from:to:subject:message-id:in-reply-to:references:mime-version; bh=2R1ubWN0y4G8W+p7KaomhH5De5oBGPAdgvnK4eUjBtk=; b=E5GwiddeI0Cy6tpDNbC7Lw0844GNz7TeohC70Ku1k1gWU6159u8bjd5d0CeI3EPoFb CyGYbaSwYPnX7qbfGjAVpVAUahIh4D25Vyc30UUBvMpPdTYOeF/cUxJuc6QLsDmJ9ShF YVOBUCJ8VvbepOa1Ofi815JUK1Zt9zjLeYJv1milkkS0kgDycXm5/q+esOnTqFzQTCel Hsl2hfM1RSx8j7c3FyH8TkXoad9V6TLgdNNbaCOSR0cRyn1uh/8W+a6K+haDBxhAZ/uL TGfw4ipmzy53pShh9o1u9+KjsUnT/UvliuznUzpvzQBR+vLKdThUlI3nzRuB88Uqyj3l wn3w== Return-Path: Received: from jozef-kubuntu ([2a01:4b00:87fd:900:a5be:302d:c094:b13e]) by smtp.gmail.com with ESMTPSA id l2sm1850855wme.36.2019.08.30.03.14.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Aug 2019 03:14:13 -0700 (PDT) Date: Fri, 30 Aug 2019 10:58:00 -0000 From: Jozef Lawrynowicz To: "gcc-patches@gcc.gnu.org" Subject: [PATCH 3/3][MSP430] Use default_elf_select_section to select sections for data where possible Message-ID: <20190830111411.2b258770@jozef-kubuntu> In-Reply-To: <20190830110740.731a0ae0@jozef-kubuntu> References: <20190830110740.731a0ae0@jozef-kubuntu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/yC1.y7DDG0asu80FtOMpJjo" X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg02062.txt.bz2 --MP_/yC1.y7DDG0asu80FtOMpJjo Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 353 With the "noinit" attribute now handled generically, direct assignment of data with the "noinit" attribute to the ".noinit" attribute can be removed from the msp430 back end, and default_elf_select_section can be used instead. default_elf_select_section can also be used for SECCAT_RODATA_MERGE_* sections, to enable the linker to merge constant data. --MP_/yC1.y7DDG0asu80FtOMpJjo Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0003-MSP430-Use-default_elf_select_section-to-determine-s.patch Content-length: 5519 >From 2d2bc7f11b7d5bfc918351a5963b041f69aac673 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Wed, 28 Aug 2019 17:54:22 +0100 Subject: [PATCH 3/3] MSP430: Use default_elf_select_section to determine sections for data where possible gcc/ChangeLog: 2019-08-29 Jozef Lawrynowicz * config/msp430/msp430.c (msp430_init_sections): Remove handling of the noinit section. (msp430_select_section): Handle decls with the "noinit" attribute with default_elf_select_section. Handle SECCAT_RODATA_MERGE_* section types with default_elf_select_section. Add comments about handling of unsupported section types. (msp430_section_type_flags): Remove handling of the noinit section. --- gcc/config/msp430/msp430.c | 81 +++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index 1b2e9683a94..d409ea15df2 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -1785,7 +1785,6 @@ gen_prefix (tree decl) return NULL; } -static section * noinit_section; static section * persist_section; #undef TARGET_ASM_INIT_SECTIONS @@ -1794,8 +1793,6 @@ static section * persist_section; static void msp430_init_sections (void) { - noinit_section = get_unnamed_section (0, output_section_asm_op, - ".section .noinit,\"aw\""); persist_section = get_unnamed_section (0, output_section_asm_op, ".section .persistent,\"aw\""); } @@ -1806,6 +1803,10 @@ msp430_init_sections (void) static section * msp430_select_section (tree decl, int reloc, unsigned HOST_WIDE_INT align) { + const char * prefix; + const char * sec_name; + const char * base_sec_name; + gcc_assert (decl != NULL_TREE); if (TREE_CODE (decl) == STRING_CST @@ -1821,51 +1822,71 @@ msp430_select_section (tree decl, int reloc, unsigned HOST_WIDE_INT align) && is_interrupt_func (decl)) return get_section (".lowtext", SECTION_CODE | SECTION_WRITE , decl); - const char * prefix = gen_prefix (decl); - if (prefix == NULL) - { - if (TREE_CODE (decl) == FUNCTION_DECL) - return text_section; - /* FIXME: ATTR_NOINIT is handled generically in - default_elf_select_section. */ - else if (has_attr (ATTR_NOINIT, decl)) - return noinit_section; - else if (has_attr (ATTR_PERSIST, decl)) - return persist_section; - else - return default_select_section (decl, reloc, align); - } + if (has_attr (ATTR_PERSIST, decl)) + return persist_section; + + /* ATTR_NOINIT is handled generically. */ + if (has_attr (ATTR_NOINIT, decl)) + return default_elf_select_section (decl, reloc, align); + + prefix = gen_prefix (decl); - const char * sec; switch (categorize_decl_for_section (decl, reloc)) { - case SECCAT_TEXT: sec = ".text"; break; - case SECCAT_DATA: sec = ".data"; break; - case SECCAT_BSS: sec = ".bss"; break; - case SECCAT_RODATA: sec = ".rodata"; break; + case SECCAT_TEXT: + if (!prefix) + return text_section; + base_sec_name = ".text"; + break; + case SECCAT_DATA: + if (!prefix) + return data_section; + base_sec_name = ".data"; + break; + case SECCAT_BSS: + if (!prefix) + return bss_section; + base_sec_name = ".bss"; + break; + case SECCAT_RODATA: + if (!prefix) + return readonly_data_section; + base_sec_name = ".rodata"; + break; + /* Enable merging of constant data by the GNU linker using + default_elf_select_section and therefore enabling creation of + sections with the SHF_MERGE flag. */ case SECCAT_RODATA_MERGE_STR: case SECCAT_RODATA_MERGE_STR_INIT: case SECCAT_RODATA_MERGE_CONST: + return default_elf_select_section (decl, reloc, align); + + /* The sections listed below are are not supported for MSP430. + They should not be generated, but in case they are, we use + default_select_section so they get placed in sections + the msp430 assembler and linker understand. */ + /* "small data" sections are not supported. */ case SECCAT_SRODATA: - case SECCAT_DATA_REL: - case SECCAT_DATA_REL_LOCAL: - case SECCAT_DATA_REL_RO: - case SECCAT_DATA_REL_RO_LOCAL: case SECCAT_SDATA: case SECCAT_SBSS: + /* Thread-local storage (TLS) is not supported. */ case SECCAT_TDATA: case SECCAT_TBSS: + /* Sections used by a dynamic linker are not supported. */ + case SECCAT_DATA_REL: + case SECCAT_DATA_REL_LOCAL: + case SECCAT_DATA_REL_RO: + case SECCAT_DATA_REL_RO_LOCAL: return default_select_section (decl, reloc, align); default: gcc_unreachable (); } - const char * dec_name = DECL_SECTION_NAME (decl); - char * name = ACONCAT ((prefix, sec, dec_name, NULL)); + sec_name = ACONCAT ((prefix, base_sec_name, DECL_SECTION_NAME (decl), NULL)); - return get_named_section (decl, name, 0); + return get_named_section (decl, sec_name, 0); } #undef TARGET_ASM_FUNCTION_SECTION @@ -1901,8 +1922,6 @@ msp430_section_type_flags (tree decl, const char * name, int reloc) name += strlen (upper_prefix); else if (strncmp (name, either_prefix, strlen (either_prefix)) == 0) name += strlen (either_prefix); - else if (strcmp (name, ".noinit") == 0) - return SECTION_WRITE | SECTION_BSS | SECTION_NOTYPE; else if (strcmp (name, ".persistent") == 0) return SECTION_WRITE | SECTION_NOTYPE; -- 2.17.1 --MP_/yC1.y7DDG0asu80FtOMpJjo--