From patchwork Fri Nov 17 12:21:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 166148 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp486003vqn; Fri, 17 Nov 2023 04:21:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHv4CTPX3G+bSEotU8MZtxQYPlDszqeOApuzA06o8Oa4IVYH1adtzewwRhSvpS4OgKlT80U X-Received: by 2002:a05:6214:20e9:b0:677:fba2:21e0 with SMTP id 9-20020a05621420e900b00677fba221e0mr295619qvk.60.1700223698838; Fri, 17 Nov 2023 04:21:38 -0800 (PST) Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u8-20020a0cc488000000b0066d046497afsi1536145qvi.357.2023.11.17.04.21.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 04:21:38 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=fail header.i=@gjlay.de header.s=strato-dkim-0002 header.b="WKJTi3/e"; dkim=neutral (no key) header.i=@gjlay.de header.s=strato-dkim-0003 header.b=r2jE9KDF; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9AF203858410 for ; Fri, 17 Nov 2023 12:21:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [85.215.255.25]) by sourceware.org (Postfix) with ESMTPS id 487313858C66 for ; Fri, 17 Nov 2023 12:21:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 487313858C66 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gjlay.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=gjlay.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 487313858C66 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=85.215.255.25 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700223676; cv=pass; b=iOGA5gk1Rtrdgokl8fJe+9iEQMRTtYwkij3v1lgegZZtfKQonNN/kUZhmipMZkX6WliRJWpDUjhgxT+IS9wXjrr8lZOGU7yzU5DmEFnZEuVzmCuPqu6esw7XBf214oMGeaIA4rGHlakKFwCCP7ou/v1Aa9FzUjpPrpYeaylRsHo= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700223676; c=relaxed/simple; bh=5BBy6dY2SwAiGLvCNYRkF3uQyUwIHR9E8c4Esk7mQSs=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version:To: From:Subject; b=k4Y0TfZdIoIOrC0nowRddAtVIbPzl1qkYVpMjh6NRPVuBkAaky/VmwceQqjSAuDjJpE6UBVEr7kfeVUgIg7kIkMg2Fd/hsTbKGvG7vK/7vGbLri4Dzf11TXrAjlV74MGEtsm7t6qztSQD81nrmt/64b1SVBm5cwPOhsNp8FHGCM= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1700223673; cv=none; d=strato.com; s=strato-dkim-0002; b=ntw40eAa/pMNcnfzzU59ESAf7hcGsesX5AZ86+vOY74/SXZj7OWNvU223Sa4P0SO0W Uyv5gJs8C7877IRyctuDykN6eRqNFKpacmI8HMiu2T0twHFd/ouavnxB6wXTsce4Y2cb +facH91R4/sKCcpY6x+2+0zZMAWkkKmaGrsZrsREgGbWumHLeguKglbUWeTpZwv+6BbE lCUAMSMEaEkfZudtVjKPQ3TZNpwcYGtOw/NeamfFXNAhe7Ie0d6dvc1WE91Ao1DHmWLC FFFAaMJh+mlDfPJdjs7xIIGNphDesYNMJX3+8QMIp4UP/ikPx49AIC9nnDAbMmbDEWkT BJfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1700223673; s=strato-dkim-0002; d=strato.com; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=FhYNkkVNn50/Oq6jEh+j93wsVcvXGU/D06/JpSNMxwQ=; b=f5FycW4CqsXAE0erH3dKHIXQlwN4NpcD5yK82rr67c4mH0eJ2dviWB6Xur/+5He5i6 Xbr+1WwdDUB+pvRDgAcspB7E80DNRnH5nkfkf5XULIuJMU6ywj4WTcyPWSfzDBPj96Pu OKltVIguWJIWQeaQHMAY8PGzTuJ83kOeXrWxgaobJINfP9tX21bC6U/op8dn+zY++ILT 2UXC0W4wPt9QSftrdUmz4YxLqCigHi36SPpeUB5o7dwubS+vph5br6KweQ6L1pUqk6xn gNpCB5TgGqJeOVa4dDgpQIlk5b86hb+EGaSM7BMKqSUhYnZwMGnBOKN2fjs7e/ptt6nz baQw== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1700223673; s=strato-dkim-0002; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=FhYNkkVNn50/Oq6jEh+j93wsVcvXGU/D06/JpSNMxwQ=; b=WKJTi3/euIfh29HQ4ZtY44BeEMBv07wC3TvckxXAz+uxindMzhADOzJ0HcpfMh67fe /eYvhyZ5rcHkUbZ41yDXD298IShIG0yDGKldpY7epClp7xY6CMbb429O2Z1DmeoST5jF jiRvmYJnXA3LaTrrYq2zoYqg1gmDJEbCXrmSUPHLh8PaUzAQY1CK5jWR4Zhn9bxD4uVa 8Hbhstlj1WCj/Twz5BjQjIfl1UkwwfSj/QE2k7nBuNT2HDHtE1xR8CItFdaYKznqwHwi 43UqdXRBHjj/aw9atsl/rIY2u44ffCnOSOLwMu+xNkdIyf5utl2rZs+SjiA/bYCRweL0 92vA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1700223673; s=strato-dkim-0003; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=FhYNkkVNn50/Oq6jEh+j93wsVcvXGU/D06/JpSNMxwQ=; b=r2jE9KDFWvp4jPwMcCboUYx6NwV5RONNyNUp91IAR3Kh1IBdr/kO60MukEVlucXjjO nBFwCTB1och6AdJMXMBQ== X-RZG-AUTH: ":LXoWVUeid/7A29J/hMvvT3koxZnKT7Qq0xotTetVnKkbjtK7q2y9LkX3hYlnPQ==" Received: from [192.168.2.102] by smtp.strato.de (RZmta 49.9.1 DYNA|AUTH) with ESMTPSA id v1b9a8zAHCLCpnA (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Fri, 17 Nov 2023 13:21:12 +0100 (CET) Message-ID: <69673087-0686-4642-adaf-70d40c08db6c@gjlay.de> Date: Fri, 17 Nov 2023 13:21:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches@gcc.gnu.org From: Georg-Johann Lay Subject: [avr, committed] PR target/53372: Don't ignore section attribute with address-space X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782813764838469319 X-GMAIL-MSGID: 1782813764838469319 The address-spaces locate data in their attaches sections like .progmem.data; but that should only be done if the user did not specify a section attribute. Johann --- PR target/53372: Don't ignore section attribute with address-space. gcc/ PR target/53372 * config/avr/avr.cc (avr_asm_named_section) [AVR_SECTION_PROGMEM]: Only return some .progmem*.data section if the user did not specify a section attribute. (avr_section_type_flags) [avr_progmem_p]: Unset SECTION_NOTYPE in returned section flags. gcc/testsuite/ PR target/53372 * gcc.target/avr/pr53372-1.c: New test. * gcc.target/avr/pr53372-2.c: New test. diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index 5e0217de36f..c3e0995dfc3 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -10873,7 +10873,12 @@ avr_asm_init_sections (void) static void avr_asm_named_section (const char *name, unsigned int flags, tree decl) { - if (flags & AVR_SECTION_PROGMEM) + if (flags & AVR_SECTION_PROGMEM + // Only use section .progmem*.data if there is no attribute section. + && ! (decl + && DECL_SECTION_NAME (decl) + && symtab_node::get (decl) + && ! symtab_node::get (decl)->implicit_section)) { addr_space_t as = (flags & AVR_SECTION_PROGMEM) / SECTION_MACH_DEP; const char *old_prefix = ".rodata"; @@ -10942,6 +10947,7 @@ avr_section_type_flags (tree decl, const char *name, int reloc) flags |= as * SECTION_MACH_DEP; flags &= ~SECTION_WRITE; flags &= ~SECTION_BSS; + flags &= ~SECTION_NOTYPE; } return flags; diff --git a/gcc/testsuite/gcc.target/avr/pr53372-1.c b/gcc/testsuite/gcc.target/avr/pr53372-1.c new file mode 100644 index 00000000000..7d3f193e79a --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr53372-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target { ! avr_tiny } } } */ +/* { dg-options "-std=gnu99" } */ + +__attribute__((__section__("fffsection"))) +const __flash char fff = 123; + +const __flash char ppp = 124; + +/* { dg-final { scan-assembler ".section fffsection,\"a\",@progbits" } } */ +/* { dg-final { scan-assembler ".section .progmem.data,\"a\",@progbits" } } */ diff --git a/gcc/testsuite/gcc.target/avr/pr53372-2.c b/gcc/testsuite/gcc.target/avr/pr53372-2.c new file mode 100644 index 00000000000..79ef2b7bbdb --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr53372-2.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target { ! avr_tiny } } } */ +/* { dg-options "-std=gnu99 -fdata-sections" } */ + +__attribute__((__section__("fffsection"))) +const __flash char fff = 123; + +const __flash char ppp = 124; + +/* { dg-final { scan-assembler ".section fffsection,\"a\",@progbits" } } */ +/* { dg-final { scan-assembler ".section .progmem.data.ppp,\"a\",@progbits" } } */