-fmerge-all-constants and –fmerge-constants don’t work at AVR target.
const char text1 PROGMEM=”Test”;
const char text2 PROGMEM=”Test”;
will still produce duplicated “Test” string in generated code.
I think this is essentially a duplicate of bug #21018.
Yes, it seems that you are right. I mark it as duplicate of bug #21018
*** This bug has been marked as a duplicate of 21018 ***
Reopening this enhancement request. Bug #21018, which this was marked a duplicate of, is now marked as WONTFIX.
Date: Thu Jul 14 07:49:14 2011
New Revision: 176262
* config/avr/elf.h (TARGET_ASM_SELECT_SECTION): Remove,
i.e. use default_elf_select_section.
(TARGET_ASM_NAMED_SECTION): Move from here...
* config/avr/avr.c: ...to here.
(avr_asm_init_sections): Set unnamed callback of
(avr_asm_named_section): Make static.
* gcc.dg/array-quals-1.c: Don't xfail on AVR.
Set the status to NEW.
The above patch fixes constant merging for constants in .rodata which is mapped into RAM for AVR.
To make it work for .progmem (data in Flash) requires a seperate patch.
*** Bug 21018 has been marked as a duplicate of this bug. ***
Date: Mon Sep 12 10:06:46 2011
New Revision: 178779
* config/avr/avr.c (AVR_SECTION_PROGMEM): New Define.
(progmem_section): New Variable.
(avr_asm_init_sections): Initialize it.
(TARGET_ASM_SELECT_SECTION): Define to...
(avr_asm_select_section): ... this new Function.
(avr_replace_prefix): New Function.
(avr_asm_function_rodata_section): Use it.
(avr_insert_attributes): Don't add section attribute for PROGMEM.
(avr_section_type_flags): Use avr_progmem_p instead of section
name to detect if object is in PROGMEM.
(avr_asm_named_section): Set section name prefix for objects in
(AVR_TORTURE_OPTIONS): Add test cases "-O2 -fdata-sections" and
Closed as fixed for 4.7 Milestone.
Initially I intended to add a -fprogmem-sections command line option that works similar but independent to -fdata-section. That way data sections could be used and strings in progmem merged. However, I did not find a straight forward way without cluttering avr BE with lots of code from varasm.c. Thus, for now, there is no -fprogmem-sections, i.e. progmem-sections are in sync with data-sections and you have to decide wether you prefer string merging or fine grained sections.