===================================================================
@@ -205,6 +205,10 @@ bool avr_have_dimode = true;
bool avr_need_clear_bss_p = false;
bool avr_need_copy_data_p = false;
+/* Track need for the non-generic address spaces, similar to
+ avr_need_copy_data_p. */
+static bool avr_need_addrspace_p[ADDR_SPACE_COUNT];
+
/* Custom function to count number of set bits. */
@@ -8148,6 +8152,9 @@ avr_asm_function_rodata_section (tree de
flags = frodata->common.flags;
}
+ /* Just for the record... */
+ avr_need_addrspace_p[ADDR_SPACE_FLASH] = true;
+
if (frodata != readonly_data_section
&& flags & SECTION_NAMED)
{
@@ -8195,6 +8202,8 @@ avr_asm_named_section (const char *name,
const char *old_prefix = ".rodata";
const char *new_prefix = avr_addrspace[as].section_name;
+ avr_need_addrspace_p[as] = true;
+
if (STR_PREFIX_P (name, old_prefix))
{
const char *sname = ACONCAT ((new_prefix,
@@ -8313,6 +8322,8 @@ avr_asm_select_section (tree decl, int r
if (ADDR_SPACE_GENERIC_P (as))
as = ADDR_SPACE_FLASH;
+ avr_need_addrspace_p[as] = true;
+
if (sect->common.flags & SECTION_NAMED)
{
const char * name = sect->named.name;
@@ -8393,6 +8404,27 @@ avr_file_end (void)
if (avr_need_clear_bss_p)
fputs (".global __do_clear_bss\n", asm_out_file);
+
+ for (size_t n = 0; n < ADDR_SPACE_COUNT; n++)
+ {
+ addr_space_t as = (addr_space_t) n;
+
+ if (avr_need_addrspace_p[as]
+ /* We only need the __need_ symbols in the linker script for
+ the paged sections that move the location counter forward.
+ For example, bumping the location counter to 0x10000 for
+ __flash1 / .progmem1.data is only needed if that input section
+ is non-empty. The linker script language is not generic enough
+ to express this. Thus, we trigger the definition of a symbol
+ that can be used as predicate via DEFINED(symbol). */
+ && !ADDR_SPACE_GENERIC_P (as)
+ && ADDR_SPACE_FLASH != as
+ && ADDR_SPACE_MEMX != as)
+ {
+ fprintf (asm_out_file, ".global __need_%s\n",
+ avr_addrspace[as].section_name);
+ }
+ }
}
/* Choose the order in which to allocate hard registers for
===================================================================
@@ -2935,4 +2935,37 @@ ENDF __fmul
#undef C0
#undef C1
+;; Marker Symbols to be used in the Linker Script.
+;; GCC will acquire them if any data is put into .progmem<N>.data
+
+#if defined L_progmem1
+.section .progmem1.data, "a", @progbits
+.global __need_.progmem1.data
+__need_.progmem1.data:
+#endif /* L_progmem1 */
+
+#if defined L_progmem2
+.section .progmem2.data, "a", @progbits
+.global __need_.progmem2.data
+__need_.progmem2.data:
+#endif /* L_progmem2 */
+
+#if defined L_progmem3
+.section .progmem3.data, "a", @progbits
+.global __need_.progmem3.data
+__need_.progmem3.data:
+#endif /* L_progmem3 */
+
+#if defined L_progmem4
+.section .progmem4.data, "a", @progbits
+.global __need_.progmem4.data
+__need_.progmem4.data:
+#endif /* L_progmem4 */
+
+#if defined L_progmem5
+.section .progmem5.data, "a", @progbits
+.global __need_.progmem5.data
+__need_.progmem5.data:
+#endif /* L_progmem5 */
+
#include "lib1funcs-fixed.S"
===================================================================
@@ -77,7 +77,9 @@ LIB1ASMFUNCS += \
_ssneg_2 _ssneg_4 _ssneg_8 \
_ssabs_2 _ssabs_4 _ssabs_8 \
_ssadd_8 _sssub_8 \
- _usadd_8 _ussub_8
+ _usadd_8 _ussub_8 \
+ \
+ _progmem1 _progmem2 _progmem3 _progmem4 _progmem5
LIB2FUNCS_EXCLUDE = \
_moddi3 _umoddi3 \