# Copyright (C) 2014-2024 Free Software Foundation, Inc. # # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright # notice and this notice are preserved. # RODATA_PM_OFFSET # If empty and not HAVE_FLMAP, .rodata sections will be part of .data. # This is for devices where it is not possible to use LD* instructions # to read from flash. # # If non-empty, .rodata is not part of .data and the .rodata # objects are assigned addresses at an offest of RODATA_PM_OFFSET. # This is for devices that feature reading from flash by means of # LD* instructions, provided the addresses are offset by # __RODATA_PM_OFFSET__ (which defaults to RODATA_PM_OFFSET). # HAVE_FLMAP # The .rodata section is located in program memory. Devices from # the AVR64* and AVR128* families (from avrxmega2 and avrxmega4) # see a 32k segment of their program memory in their RAM address # space. Which 32k segment is visible is determined by the # bit-field NVMCTRL_CTRLB.FLMAP. # Output section .rodata is placed in MEMORY region rodata. # The LMA of the .rodata section can be set by means of: # * __RODATA_FLASH_START__ specifies the byte address of the # rodata LMA. # * __flmap specifies which 32k block is visible in RAM provided # __RODATA_FLASH_START__ is undefined # * When __flmap and __RODATA_FLASH_START__ are undefined, then an # emulation-specific default is used (the last 32k block). # MAYBE_FLMAP # For devices from avrxmega2 and avrxmega4: The user can chose whether # or not .rodata is located in flash (if HAVE_FLMAP) or located in # in RAM (if not HAVE_FLMAP by means of -mrodata-in-ram). This is # achieved by new emulations avrxmega2_flmap and avrxmega4_flmap that # are selected by compiler option -mno-rodata-in-ram. # # In order to facilitate initialization of NVMCTRL_CTRLB.FLMAP and # NVMCTRL_CTRLB.FLMAPLOCK in the startup code irrespective of # HAVE_FLMAP, the following symbols are used / defined in order to # communicate with the startup code. # Notice that the hardware default for FLMAP is the last 32k block, # so that explicit initialization of FLMAP is only required when the # user wants to deviate from the defaults. # # __flmap = HAVE_FLMAP # ? given by __flmap resp. __RODATA_FLASH_START__ >> 15 # : 0; # # __flmap_value = __flmap << __flmap_bpos; # # __flmap_value_with_lock = __flmap__value | __flmap_lock_mask; # # __flmap_init_label = HAVE_FLMAP # ? __flmap_init_start # : __flmap_noinit_start; # Supposed to be used as a jump target for RJMP so that the code # can initialize FLMAP / skip initialization of FLMAP depending # on the chosen emulation, and without the need to support two code # versions of crt.o for the two possible emulations. # # __flmap_lock is a bool provided by the user when FLMAP should be # protected from any further changes. # # __flmap_lock_mask is an 8-bit mask like NVMCTRL_FLMAPLOCK_bm # provided by the user which is set in __flmap_value_with_lock # when __flmap_lock is on. # # __do_init_flmap = HAVE_FLMAP ? 1 : 0; # Whether or not FLMAP is supposed to be initialized according # to, and for the purpose of, .rodata in flash. # # Apart from that, the compiler (device-specs actually) defines the # following macros: # # __AVR_HAVE_FLMAP__ # Defined if a device has the NVMCTRL_CTRLB.FLMAP bitfield # *AND* if it's unknown at compile-time / assembler-time whether # emulation avrxmega* is used or avrxmega*_flmap. cat < text} EOF # Devices like ATtiny816 allow to read from flash memory by means of LD* # instructions provided we add an offset of __RODATA_PM_OFFSET__ to the # flash addresses. if test -n "$RODATA_PM_OFFSET"; then cat < text} EOF fi cat < data ${RELOCATING+AT> text}} .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))} { ${RELOCATING+ PROVIDE (__bss_start = .) ; } *(.bss) ${RELOCATING+ *(.bss*)} ${RELOCATING+ *(COMMON)} ${RELOCATING+ PROVIDE (__bss_end = .) ; } } ${RELOCATING+ > data} ${RELOCATING+ __data_load_start = LOADADDR(.data); } ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); } /* Global data not cleared after reset. */ .noinit ${RELOCATING+ ADDR(.bss) + SIZEOF (.bss)} ${RELOCATING-0}: ${RELOCATING+ AT (ADDR (.noinit))} { ${RELOCATING+ PROVIDE (__noinit_start = .) ; } *(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*}) ${RELOCATING+ PROVIDE (__noinit_end = .) ; } ${RELOCATING+ _end = . ; } ${RELOCATING+ PROVIDE (__heap_start = .) ; } } ${RELOCATING+ > data} EOF # Devices like AVR128DA32 and AVR64DA32 see a 32 KiB block of their program # memory at 0x8000 (RODATA_LDS_OFFSET). Which portion will be determined by # bitfield NVMCTRL_CTRLB.FLMAP. if test -z "${HAVE_FLMAP}" && test -n "${RELOCATING}"; then cat <> 15); __RODATA_FLASH_START__ = __flmap << 15; __rodata_load_start = MAX (__data_load_end, __RODATA_FLASH_START__); __rodata_start = __RODATA_ORIGIN__ + __rodata_load_start - __RODATA_FLASH_START__;} .rodata ${RELOCATING+ __rodata_start} ${RELOCATING-0} : ${RELOCATING+ AT (__rodata_load_start)} { *(.rodata) ${RELOCATING+ *(.rodata*)} ${RELOCATING+ *(.gnu.linkonce.r*)} ${RELOCATING+ __rodata_end = ABSOLUTE(.) ;} } ${RELOCATING+ > rodata} ${RELOCATING+ __rodata_load_end = __rodata_load_start + __rodata_end - __rodata_start;} EOF fi if test -n "${MAYBE_FLMAP}" && test -n "${RELOCATING}"; then cat < eeprom} EOF fi if test "$FUSE_NAME" = "fuse" ; then cat < fuse} EOF fi cat < lock} .signature ${RELOCATING-0}: { KEEP(*(.signature*)) } ${RELOCATING+ > signature} EOF if test "$FUSE_NAME" = "config" ; then cat < config} EOF fi source_sh $srcdir/scripttempl/misc-sections.sc cat <