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";
flags |= as * SECTION_MACH_DEP;
flags &= ~SECTION_WRITE;
flags &= ~SECTION_BSS;
+ flags &= ~SECTION_NOTYPE;
}
return flags;
--- /dev/null
+/* { 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" } } */
--- /dev/null
+/* { 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" } } */