Update avrxmega3 linker emulation to support avrxmega2 devices with flash memory...
authoreorg-Johann Lay <avr@gjlay.de>
Fri, 19 May 2017 14:06:33 +0000 (15:06 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 19 May 2017 14:06:33 +0000 (15:06 +0100)
    PR ld/21472
ld  * emulparams/avrxmega3.sh (RODATA_PM_OFFSET): Set to 0x8000.
    * scripttempl/avr.sc
    (__RODATA_PM_OFFSET__) [RODATA_PM_OFFSET]: Use RODATA_PM_OFFSET
    as default if not already defined.
    (.data) [!RODATA_PM_OFFSET]: Don't include .rodata and friends.
    (.rodata) [RODATA_PM_OFFSET]: Put at an offset of
    __RODATA_PM_OFFSET__.

gas * config/tc-avr.c (mcu_types): Add entries for: attiny416,
     attiny417, attiny816, attiny817.

gas/ChangeLog
gas/config/tc-avr.c
ld/ChangeLog
ld/emulparams/avrxmega3.sh
ld/scripttempl/avr.sc

index 8605e59d53f649cef685f667973c43d847fea7cb..e96a59c3df2eb0e000466a8e1791a8ec0d7609d2 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-19  Georg-Johann Lay  <avr@gjlay.de>
+
+       PR ld/21472
+       * config/tc-avr.c (mcu_types): Add entries for: attiny416,
+       attiny417, attiny816, attiny817.
+
 2017-05-18  Alan Modra  <amodra@gmail.com>
 
        * config/tc-aarch64.c: Don't compare booleans against TRUE or FALSE.
index 7214c070d6a744ec646b6ee7aaaba1ef4bcedc02..79837c84fa1876e8acbef4dcb77db593bae58845 100644 (file)
@@ -300,6 +300,10 @@ static struct mcu_type_s mcu_types[] =
   {"atxmega16e5", AVR_ISA_XMEGA,  bfd_mach_avrxmega2},
   {"atxmega8e5",  AVR_ISA_XMEGA,  bfd_mach_avrxmega2},
   {"atxmega32x1", AVR_ISA_XMEGA,  bfd_mach_avrxmega2},
+  {"attiny416",   AVR_ISA_XMEGA,  bfd_mach_avrxmega3},
+  {"attiny417",   AVR_ISA_XMEGA,  bfd_mach_avrxmega3},
+  {"attiny816",   AVR_ISA_XMEGA,  bfd_mach_avrxmega3},
+  {"attiny817",   AVR_ISA_XMEGA,  bfd_mach_avrxmega3},
   {"atxmega64a3", AVR_ISA_XMEGA,  bfd_mach_avrxmega4},
   {"atxmega64a3u",AVR_ISA_XMEGAU, bfd_mach_avrxmega4},
   {"atxmega64a4u",AVR_ISA_XMEGAU, bfd_mach_avrxmega4},
index 097afac378d8da6293f3c98a5718fa47c5fefccc..838f3cb0219dc590bf49363f5bbf1c0c2b474f9c 100644 (file)
@@ -1,3 +1,13 @@
+2017-05-19  Georg-Johann Lay  <avr@gjlay.de>
+
+       PR ld/21472
+       * emulparams/avrxmega3.sh (RODATA_PM_OFFSET): Set to 0x8000.
+       * scripttempl/avr.sc (__RODATA_PM_OFFSET__) [RODATA_PM_OFFSET]:
+       Use RODATA_PM_OFFSET as default if not already defined.
+       (.data) [!RODATA_PM_OFFSET]: Don't include .rodata and friends.
+       (.rodata) [RODATA_PM_OFFSET]: Put at an offset of
+       __RODATA_PM_OFFSET__.
+
 2017-05-18  Nick Clifton  <nickc@redhat.com>
 
        PR ld/21251
index abaa5b3dbf8c327e0c44d6e73f489a71cb140fe7..7c5a1e5b53749ddc028227b6b60a5fdcd37dd932 100644 (file)
@@ -9,4 +9,5 @@ TEMPLATE_NAME=elf32
 TEXT_LENGTH=1024K
 DATA_ORIGIN=0x802000
 DATA_LENGTH=0xffa0
+RODATA_PM_OFFSET=0x8000
 EXTRA_EM_FILE=avrelf
index b88918089b6df677a9923d87e46e3f4e5f0de3a9..144d32dbc793d0040ce855d19c7fab0506c219d7 100644 (file)
@@ -4,6 +4,17 @@
 # are permitted in any medium without royalty provided the copyright
 # notice and this notice are preserved.
 
+# RODATA_PM_OFFSET
+#         If empty, .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).
+
 cat <<EOF
 /* Copyright (C) 2014-2017 Free Software Foundation, Inc.
 
@@ -21,7 +32,15 @@ __FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH_
 __LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : 1K;
 __SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : 1K;
 __USER_SIGNATURE_REGION_LENGTH__ = DEFINED(__USER_SIGNATURE_REGION_LENGTH__) ? __USER_SIGNATURE_REGION_LENGTH__ : 1K;
+EOF
 
+if test -n "$RODATA_PM_OFFSET"; then
+    cat <<EOF
+__RODATA_PM_OFFSET__ = DEFINED(__RODATA_PM_OFFSET__) ? __RODATA_PM_OFFSET__ : $RODATA_PM_OFFSET;
+EOF
+fi
+
+cat <<EOF
 MEMORY
 {
   text   (rx)   : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__
@@ -187,15 +206,45 @@ SECTIONS
     KEEP (*(.fini0))
     ${RELOCATING+ _etext = . ; }
   } ${RELOCATING+ > 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 <<EOF
+  .rodata ${RELOCATING+ ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__ } ${RELOCATING-0} :
+  {
+    *(.rodata)
+    ${RELOCATING+ *(.rodata*)}
+    *(.gnu.linkonce.r*)
+  } ${RELOCATING+AT> text}
+EOF
+fi
 
+cat <<EOF
   .data        ${RELOCATING-0} :
   {
     ${RELOCATING+ PROVIDE (__data_start = .) ; }
     *(.data)
     ${RELOCATING+ *(.data*)}
+    *(.gnu.linkonce.d*)
+EOF
+
+# Classical devices that don't show flash memory in the SRAM address space
+# need .rodata to be part of .data because the compiler will use LD*
+# instructions and LD* cannot access flash.
+
+if test -z "$RODATA_PM_OFFSET"; then
+    cat <<EOF
     *(.rodata)  /* We need to include .rodata here if gcc is used */
     ${RELOCATING+ *(.rodata*)} /* with -fdata-sections.  */
-    *(.gnu.linkonce.d*)
+    *(.gnu.linkonce.r*)
+EOF
+fi
+
+cat <<EOF
     ${RELOCATING+. = ALIGN(2);}
     ${RELOCATING+ _edata = . ; }
     ${RELOCATING+ PROVIDE (__data_end = .) ; }
This page took 0.047423 seconds and 4 git commands to generate.