[Patch, AVR]: FIX PR43746 (merge progmem strings)

Georg-Johann Lay avr@gjlay.de
Wed Jun 22 17:03:00 GMT 2011


This patch will put progmem strings into a mergeable strings section.

progmem_section is globally renamed to progmem_sw_table_section as
it's only used for switch_case jumptables.

The code that attached the explicit section name ".progmem" in
avr_insert_attributes is removed.

Instead, avr_init_sections sets up two new sections progmem_section
and progmem_string_section which are selected in new hook
avr_asm_select_section if appropriate, i.e. if progmem attribute is
specified.

The classic implementation of progmem always chose .progmem section
regardless of -fdata-sections.  The new code behaves similar: If
attribute "progmem" is on, avr_asm_named_section will put data in
.progmem resp. .progmem.string.

Note that .progmem.string coincides with .progmem if -fmerge-constants
if off, e.g. if optimization is off.

As Eric recently reopened PR43746, there is obviously need for such
tweak to save flash.

Tested without regressions and lightly tested with own code.

Johann


	PR target/43746
	* config/avr/avr.h (progmem_section): Rename progmem_section to
	progmem_sw_table_section.
	(ASM_OUTPUT_CASE_LABEL): Ditto.
	* config/avr/avr.c (avr_output_addr_vec_elt): Ditto.
	(avr_output_bld): Ditto.
	(progmem_string_section): New variable.
	(progmem_sw_table_section): New variable.
	(TARGET_ASM_SELECT_SECTION): Define to...
	(avr_asm_select_section): ...this new function.
	(avr_progmem_string_p): New function.
	(avr_insert_attributes): Don't attach explicit section names to
	'progmem' variables.
	(avr_output_progmem_section_asm_op): Remove.
	(avr_asm_init_sections): Setup progmem_section,
	progmem_string_section, progmem_sw_table_section.
	(avr_asm_named_section): Put 'progmem' data into .progmem resp.
	.progmem.string section.
	(avr_section_type_flags): Setup flags for these sections.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr43746-mergestring.diff
Type: text/x-patch
Size: 7666 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110622/786622d0/attachment.bin>


More information about the Gcc-patches mailing list