public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5552] PR target/53372: Don't ignore section attribute with address-space.
@ 2023-11-17 11:54 Georg-Johann Lay
0 siblings, 0 replies; only message in thread
From: Georg-Johann Lay @ 2023-11-17 11:54 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:68221c54a9752dbf131c231413edfd21046f8dad
commit r14-5552-g68221c54a9752dbf131c231413edfd21046f8dad
Author: Georg-Johann Lay <avr@gjlay.de>
Date: Fri Nov 17 12:51:16 2023 +0100
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:
---
gcc/config/avr/avr.cc | 8 +++++++-
gcc/testsuite/gcc.target/avr/pr53372-1.c | 10 ++++++++++
gcc/testsuite/gcc.target/avr/pr53372-2.c | 10 ++++++++++
3 files changed, 27 insertions(+), 1 deletion(-)
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" } } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-17 11:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-17 11:54 [gcc r14-5552] PR target/53372: Don't ignore section attribute with address-space Georg-Johann Lay
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).