* [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
@ 2017-05-08 11:41 Georg-Johann Lay
2017-05-08 20:24 ` Joerg Wunsch
2017-05-09 5:54 ` Senthil Kumar Selvaraj
0 siblings, 2 replies; 12+ messages in thread
From: Georg-Johann Lay @ 2017-05-08 11:41 UTC (permalink / raw)
To: binutils
Cc: Denis Chertykov, Senthil Kumar Selvaraj, Pitchumani Sivanupandi,
Joerg Wunsch, Nick Clifton
[-- Attachment #1: Type: text/plain, Size: 1921 bytes --]
ATtiny416, ATtiny417, ATtiny816, ATtiny817 are devices which implement
avrxmega2 ISA with the additional feature that flash memory is visible
in the SRAM address range (starting at 0x8000). In order to optimally
support this feature, an according linker description file should be
used per default, i.e. we want a new emulation which comes with this
liker description file.
The patch uses avrxmega3 for this. Actually, avrxmega3 is an already
existing emulation, but one containing no devices so far, and one which
avr-gcc doesn't even generate a multilib variant for.
Besides optimal support by a linker description file, the compiler might
come up with different code for these devices. For example, referencing
__do_copy_data is no more needed for stuff in .rodata. This is a second
reason for why we wand a separate emulation for these devices.
As there are currently no devices in this emulation, the patch doesn't
break anything existing, is just makes use of code that was dead so far.
The relevant portion of avrxmega3.x is the handling of .rodata which
reads similar to the avrtiny.x (PR20849):
__RODATA_PM_OFFSET__= DEFINED(__RODATA_PM_OFFSET__) ?
__RODATA_PM_OFFSET__: 0x8000;
.text :
{
...
} > text
.rodata ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__:
{
*(.rodata)
*(.rodata*)
*(.gnu.linkonce.r*)
} AT> text
.data :
{
...
Ok for master?
If approved, please someone with commit privileges apply the patch.
Johann
ld/
Upgrade the currently unused emulation avrxmega3 to one which
supports avrxmega2 devices with flash memory visible in the
SRAM address range.
PR21472
* scripttempl/avr_rodata.sc: New file.
* emulparams/avrxmega3.sh (SCRIPT_NAME): Use avr_rodata.
(RODATA_PM_OFFSET): Set to 0x8000.
gas/
PR21472
* config/tc-avr.c (mcu_types): Add entries for: attiny416,
attiny417, attiny816, attiny817.
[-- Attachment #2: binutils-avrxmega3.diff --]
[-- Type: text/x-patch, Size: 10384 bytes --]
diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
index 7214c07..79837c8 100644
--- a/gas/config/tc-avr.c
+++ b/gas/config/tc-avr.c
@@ -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},
diff --git a/ld/emulparams/avrxmega3.sh b/ld/emulparams/avrxmega3.sh
index abaa5b3..504c492 100644
--- a/ld/emulparams/avrxmega3.sh
+++ b/ld/emulparams/avrxmega3.sh
@@ -1,6 +1,6 @@
ARCH=avr:103
MACHINE=
-SCRIPT_NAME=avr
+SCRIPT_NAME=avr_rodata
OUTPUT_FORMAT="elf32-avr"
MAXPAGESIZE=1
EMBEDDED=yes
@@ -9,4 +9,5 @@ TEMPLATE_NAME=elf32
TEXT_LENGTH=1024K
DATA_ORIGIN=0x802000
DATA_LENGTH=0xffa0
+RODATA_PM_OFFSET=0x8000
EXTRA_EM_FILE=avrelf
diff --git a/ld/scripttempl/avr_rodata.sc b/ld/scripttempl/avr_rodata.sc
new file mode 100644
index 0000000..eecfedf
--- /dev/null
+++ b/ld/scripttempl/avr_rodata.sc
@@ -0,0 +1,272 @@
+# Copyright (C) 2014-2017 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.
+
+cat <<EOF
+/* Copyright (C) 2014-2017 Free Software Foundation, Inc.
+
+ Copying and distribution of this script, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. */
+
+OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
+OUTPUT_ARCH(${ARCH})
+
+__TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : $TEXT_LENGTH;
+__DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : $DATA_LENGTH;
+__EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? __EEPROM_REGION_LENGTH__ : 64K;
+__FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 1K;
+__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;
+__RODATA_PM_OFFSET__ = DEFINED(__RODATA_PM_OFFSET__) ? __RODATA_PM_OFFSET__ : $RODATA_PM_OFFSET;
+
+MEMORY
+{
+ text (rx) : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__
+ data (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DATA_REGION_LENGTH__
+ eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__
+ fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
+ lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
+ signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
+ user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__
+}
+
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ ${TEXT_DYNAMIC+${DYNAMIC}}
+ .hash ${RELOCATING-0} : { *(.hash) }
+ .dynsym ${RELOCATING-0} : { *(.dynsym) }
+ .dynstr ${RELOCATING-0} : { *(.dynstr) }
+ .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
+ .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
+ .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
+
+ .rel.init ${RELOCATING-0} : { *(.rel.init) }
+ .rela.init ${RELOCATING-0} : { *(.rela.init) }
+ .rel.text ${RELOCATING-0} :
+ {
+ *(.rel.text)
+ ${RELOCATING+*(.rel.text.*)}
+ ${RELOCATING+*(.rel.gnu.linkonce.t*)}
+ }
+ .rela.text ${RELOCATING-0} :
+ {
+ *(.rela.text)
+ ${RELOCATING+*(.rela.text.*)}
+ ${RELOCATING+*(.rela.gnu.linkonce.t*)}
+ }
+ .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
+ .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
+ .rel.rodata ${RELOCATING-0} :
+ {
+ *(.rel.rodata)
+ ${RELOCATING+*(.rel.rodata.*)}
+ ${RELOCATING+*(.rel.gnu.linkonce.r*)}
+ }
+ .rela.rodata ${RELOCATING-0} :
+ {
+ *(.rela.rodata)
+ ${RELOCATING+*(.rela.rodata.*)}
+ ${RELOCATING+*(.rela.gnu.linkonce.r*)}
+ }
+ .rel.data ${RELOCATING-0} :
+ {
+ *(.rel.data)
+ ${RELOCATING+*(.rel.data.*)}
+ ${RELOCATING+*(.rel.gnu.linkonce.d*)}
+ }
+ .rela.data ${RELOCATING-0} :
+ {
+ *(.rela.data)
+ ${RELOCATING+*(.rela.data.*)}
+ ${RELOCATING+*(.rela.gnu.linkonce.d*)}
+ }
+ .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
+ .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
+ .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
+ .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
+ .rel.got ${RELOCATING-0} : { *(.rel.got) }
+ .rela.got ${RELOCATING-0} : { *(.rela.got) }
+ .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
+ .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
+ .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
+ .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
+
+ /* Internal text space or external memory. */
+ .text ${RELOCATING-0} :
+ {
+ *(.vectors)
+ KEEP(*(.vectors))
+
+ /* For data that needs to reside in the lower 64k of progmem. */
+ ${RELOCATING+ *(.progmem.gcc*)}
+
+ /* PR 13812: Placing the trampolines here gives a better chance
+ that they will be in range of the code that uses them. */
+ ${RELOCATING+. = ALIGN(2);}
+ ${CONSTRUCTING+ __trampolines_start = . ; }
+ /* The jump trampolines for the 16-bit limited relocs will reside here. */
+ *(.trampolines)
+ ${RELOCATING+ *(.trampolines*)}
+ ${CONSTRUCTING+ __trampolines_end = . ; }
+
+ /* avr-libc expects these data to reside in lower 64K. */
+ ${RELOCATING+ *libprintf_flt.a:*(.progmem.data)}
+ ${RELOCATING+ *libc.a:*(.progmem.data)}
+
+ ${RELOCATING+ *(.progmem*)}
+
+ ${RELOCATING+. = ALIGN(2);}
+
+ /* For future tablejump instruction arrays for 3 byte pc devices.
+ We don't relax jump/call instructions within these sections. */
+ *(.jumptables)
+ ${RELOCATING+ *(.jumptables*)}
+
+ /* For code that needs to reside in the lower 128k progmem. */
+ *(.lowtext)
+ ${RELOCATING+ *(.lowtext*)}
+
+ ${CONSTRUCTING+ __ctors_start = . ; }
+ ${CONSTRUCTING+ *(.ctors) }
+ ${CONSTRUCTING+ __ctors_end = . ; }
+ ${CONSTRUCTING+ __dtors_start = . ; }
+ ${CONSTRUCTING+ *(.dtors) }
+ ${CONSTRUCTING+ __dtors_end = . ; }
+ KEEP(SORT(*)(.ctors))
+ KEEP(SORT(*)(.dtors))
+
+ /* From this point on, we don't bother about wether the insns are
+ below or above the 16 bits boundary. */
+ *(.init0) /* Start here after reset. */
+ KEEP (*(.init0))
+ *(.init1)
+ KEEP (*(.init1))
+ *(.init2) /* Clear __zero_reg__, set up stack pointer. */
+ KEEP (*(.init2))
+ *(.init3)
+ KEEP (*(.init3))
+ *(.init4) /* Initialize data and BSS. */
+ KEEP (*(.init4))
+ *(.init5)
+ KEEP (*(.init5))
+ *(.init6) /* C++ constructors. */
+ KEEP (*(.init6))
+ *(.init7)
+ KEEP (*(.init7))
+ *(.init8)
+ KEEP (*(.init8))
+ *(.init9) /* Call main(). */
+ KEEP (*(.init9))
+ *(.text)
+ ${RELOCATING+. = ALIGN(2);}
+ ${RELOCATING+ *(.text.*)}
+ ${RELOCATING+. = ALIGN(2);}
+ *(.fini9) /* _exit() starts here. */
+ KEEP (*(.fini9))
+ *(.fini8)
+ KEEP (*(.fini8))
+ *(.fini7)
+ KEEP (*(.fini7))
+ *(.fini6) /* C++ destructors. */
+ KEEP (*(.fini6))
+ *(.fini5)
+ KEEP (*(.fini5))
+ *(.fini4)
+ KEEP (*(.fini4))
+ *(.fini3)
+ KEEP (*(.fini3))
+ *(.fini2)
+ KEEP (*(.fini2))
+ *(.fini1)
+ KEEP (*(.fini1))
+ *(.fini0) /* Infinite loop after program termination. */
+ KEEP (*(.fini0))
+ ${RELOCATING+ _etext = . ; }
+ } ${RELOCATING+ > text}
+
+ .rodata ${RELOCATING+ ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__ } ${RELOCATING-0} :
+ {
+ *(.rodata)
+ ${RELOCATING+ *(.rodata*)}
+ *(.gnu.linkonce.r*)
+ } ${RELOCATING+AT> text}
+
+ .data ${RELOCATING-0} :
+ {
+ ${RELOCATING+ PROVIDE (__data_start = .) ; }
+ *(.data)
+ ${RELOCATING+ *(.data*)}
+ *(.gnu.linkonce.d*)
+ ${RELOCATING+. = ALIGN(2);}
+ ${RELOCATING+ _edata = . ; }
+ ${RELOCATING+ PROVIDE (__data_end = .) ; }
+ } ${RELOCATING+ > data ${RELOCATING+AT> text}}
+
+ .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
+ {
+ ${RELOCATING+ PROVIDE (__bss_start = .) ; }
+ *(.bss)
+ ${RELOCATING+ *(.bss*)}
+ *(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+ PROVIDE (__noinit_end = .) ; }
+ ${RELOCATING+ _end = . ; }
+ ${RELOCATING+ PROVIDE (__heap_start = .) ; }
+ } ${RELOCATING+ > data}
+
+ .eeprom ${RELOCATING-0}:
+ {
+ /* See .data above... */
+ KEEP(*(.eeprom*))
+ ${RELOCATING+ __eeprom_end = . ; }
+ } ${RELOCATING+ > eeprom}
+
+ .fuse ${RELOCATING-0}:
+ {
+ KEEP(*(.fuse))
+ KEEP(*(.lfuse))
+ KEEP(*(.hfuse))
+ KEEP(*(.efuse))
+ } ${RELOCATING+ > fuse}
+
+ .lock ${RELOCATING-0}:
+ {
+ KEEP(*(.lock*))
+ } ${RELOCATING+ > lock}
+
+ .signature ${RELOCATING-0}:
+ {
+ KEEP(*(.signature*))
+ } ${RELOCATING+ > signature}
+
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ .note.gnu.build-id : { *(.note.gnu.build-id) }
+EOF
+
+. $srcdir/scripttempl/DWARF.sc
+
+cat <<EOF
+}
+EOF
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
2017-05-08 11:41 [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM Georg-Johann Lay
@ 2017-05-08 20:24 ` Joerg Wunsch
2017-05-09 8:57 ` Georg-Johann Lay
2017-05-09 5:54 ` Senthil Kumar Selvaraj
1 sibling, 1 reply; 12+ messages in thread
From: Joerg Wunsch @ 2017-05-08 20:24 UTC (permalink / raw)
To: Georg-Johann Lay
Cc: binutils, Denis Chertykov, Senthil Kumar Selvaraj,
Pitchumani Sivanupandi, Nick Clifton
As Georg-Johann Lay wrote:
> Ok for master?
>
> If approved, please someone with commit privileges apply the patch.
No objections against it from avr-libc's point of view. I don't think
we are affected by it anyway.
--
cheers, Joerg .-.-. --... ...-- -.. . DL8DTL
http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
2017-05-08 11:41 [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM Georg-Johann Lay
2017-05-08 20:24 ` Joerg Wunsch
@ 2017-05-09 5:54 ` Senthil Kumar Selvaraj
2017-05-09 9:26 ` Georg-Johann Lay
1 sibling, 1 reply; 12+ messages in thread
From: Senthil Kumar Selvaraj @ 2017-05-09 5:54 UTC (permalink / raw)
To: Georg-Johann Lay
Cc: binutils, Denis Chertykov, Pitchumani Sivanupandi, Joerg Wunsch,
Nick Clifton
Georg-Johann Lay writes:
> ATtiny416, ATtiny417, ATtiny816, ATtiny817 are devices which implement
> avrxmega2 ISA with the additional feature that flash memory is visible
> in the SRAM address range (starting at 0x8000). In order to optimally
> support this feature, an according linker description file should be
> used per default, i.e. we want a new emulation which comes with this
> liker description file.
I'm still not convinced we need a new emulation for this. Sure, we need
a new multilib option in gcc, but can't we do it the way msp8 aka
tiny-stack is handled now? IMO, mapping flash to the data address space
is arch independent, and breaking it out into a separate emulation could
lead to a combinatorial explosion of emulations if devices with that
feature come out for other existing archs. Can't help it for multilibs,
but I'm not sure we need emulations as well.
>
> The patch uses avrxmega3 for this. Actually, avrxmega3 is an already
> existing emulation, but one containing no devices so far, and one which
> avr-gcc doesn't even generate a multilib variant for.
>
> Besides optimal support by a linker description file, the compiler might
> come up with different code for these devices. For example, referencing
> __do_copy_data is no more needed for stuff in .rodata. This is a second
> reason for why we wand a separate emulation for these devices.
Again, can't we do this the way we handle msp8 now i.e. set a global var
based on a command line option (mrodata-in-flash?) and then use it to
modify code gen?
Regards
Senthil
>
> As there are currently no devices in this emulation, the patch doesn't
> break anything existing, is just makes use of code that was dead so far.
>
> The relevant portion of avrxmega3.x is the handling of .rodata which
> reads similar to the avrtiny.x (PR20849):
>
>
> __RODATA_PM_OFFSET__= DEFINED(__RODATA_PM_OFFSET__) ?
> __RODATA_PM_OFFSET__: 0x8000;
>
>
> .text :
> {
> ...
> } > text
> .rodata ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__:
> {
> *(.rodata)
> *(.rodata*)
> *(.gnu.linkonce.r*)
> } AT> text
> .data :
> {
> ...
>
> Ok for master?
>
> If approved, please someone with commit privileges apply the patch.
>
>
> Johann
>
>
> ld/
> Upgrade the currently unused emulation avrxmega3 to one which
> supports avrxmega2 devices with flash memory visible in the
> SRAM address range.
>
> PR21472
> * scripttempl/avr_rodata.sc: New file.
> * emulparams/avrxmega3.sh (SCRIPT_NAME): Use avr_rodata.
> (RODATA_PM_OFFSET): Set to 0x8000.
>
> gas/
> PR21472
> * config/tc-avr.c (mcu_types): Add entries for: attiny416,
> attiny417, attiny816, attiny817.
>
>
> diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
> index 7214c07..79837c8 100644
> --- a/gas/config/tc-avr.c
> +++ b/gas/config/tc-avr.c
> @@ -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},
> diff --git a/ld/emulparams/avrxmega3.sh b/ld/emulparams/avrxmega3.sh
> index abaa5b3..504c492 100644
> --- a/ld/emulparams/avrxmega3.sh
> +++ b/ld/emulparams/avrxmega3.sh
> @@ -1,6 +1,6 @@
> ARCH=avr:103
> MACHINE=
> -SCRIPT_NAME=avr
> +SCRIPT_NAME=avr_rodata
> OUTPUT_FORMAT="elf32-avr"
> MAXPAGESIZE=1
> EMBEDDED=yes
> @@ -9,4 +9,5 @@ TEMPLATE_NAME=elf32
> TEXT_LENGTH=1024K
> DATA_ORIGIN=0x802000
> DATA_LENGTH=0xffa0
> +RODATA_PM_OFFSET=0x8000
> EXTRA_EM_FILE=avrelf
> diff --git a/ld/scripttempl/avr_rodata.sc b/ld/scripttempl/avr_rodata.sc
> new file mode 100644
> index 0000000..eecfedf
> --- /dev/null
> +++ b/ld/scripttempl/avr_rodata.sc
> @@ -0,0 +1,272 @@
> +# Copyright (C) 2014-2017 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.
> +
> +cat <<EOF
> +/* Copyright (C) 2014-2017 Free Software Foundation, Inc.
> +
> + Copying and distribution of this script, with or without modification,
> + are permitted in any medium without royalty provided the copyright
> + notice and this notice are preserved. */
> +
> +OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
> +OUTPUT_ARCH(${ARCH})
> +
> +__TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : $TEXT_LENGTH;
> +__DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : $DATA_LENGTH;
> +__EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? __EEPROM_REGION_LENGTH__ : 64K;
> +__FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 1K;
> +__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;
> +__RODATA_PM_OFFSET__ = DEFINED(__RODATA_PM_OFFSET__) ? __RODATA_PM_OFFSET__ : $RODATA_PM_OFFSET;
> +
> +MEMORY
> +{
> + text (rx) : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__
> + data (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DATA_REGION_LENGTH__
> + eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__
> + fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
> + lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
> + signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
> + user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__
> +}
> +
> +SECTIONS
> +{
> + /* Read-only sections, merged into text segment: */
> + ${TEXT_DYNAMIC+${DYNAMIC}}
> + .hash ${RELOCATING-0} : { *(.hash) }
> + .dynsym ${RELOCATING-0} : { *(.dynsym) }
> + .dynstr ${RELOCATING-0} : { *(.dynstr) }
> + .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
> + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
> + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
> +
> + .rel.init ${RELOCATING-0} : { *(.rel.init) }
> + .rela.init ${RELOCATING-0} : { *(.rela.init) }
> + .rel.text ${RELOCATING-0} :
> + {
> + *(.rel.text)
> + ${RELOCATING+*(.rel.text.*)}
> + ${RELOCATING+*(.rel.gnu.linkonce.t*)}
> + }
> + .rela.text ${RELOCATING-0} :
> + {
> + *(.rela.text)
> + ${RELOCATING+*(.rela.text.*)}
> + ${RELOCATING+*(.rela.gnu.linkonce.t*)}
> + }
> + .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
> + .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
> + .rel.rodata ${RELOCATING-0} :
> + {
> + *(.rel.rodata)
> + ${RELOCATING+*(.rel.rodata.*)}
> + ${RELOCATING+*(.rel.gnu.linkonce.r*)}
> + }
> + .rela.rodata ${RELOCATING-0} :
> + {
> + *(.rela.rodata)
> + ${RELOCATING+*(.rela.rodata.*)}
> + ${RELOCATING+*(.rela.gnu.linkonce.r*)}
> + }
> + .rel.data ${RELOCATING-0} :
> + {
> + *(.rel.data)
> + ${RELOCATING+*(.rel.data.*)}
> + ${RELOCATING+*(.rel.gnu.linkonce.d*)}
> + }
> + .rela.data ${RELOCATING-0} :
> + {
> + *(.rela.data)
> + ${RELOCATING+*(.rela.data.*)}
> + ${RELOCATING+*(.rela.gnu.linkonce.d*)}
> + }
> + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
> + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
> + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
> + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
> + .rel.got ${RELOCATING-0} : { *(.rel.got) }
> + .rela.got ${RELOCATING-0} : { *(.rela.got) }
> + .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
> + .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
> + .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
> + .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
> +
> + /* Internal text space or external memory. */
> + .text ${RELOCATING-0} :
> + {
> + *(.vectors)
> + KEEP(*(.vectors))
> +
> + /* For data that needs to reside in the lower 64k of progmem. */
> + ${RELOCATING+ *(.progmem.gcc*)}
> +
> + /* PR 13812: Placing the trampolines here gives a better chance
> + that they will be in range of the code that uses them. */
> + ${RELOCATING+. = ALIGN(2);}
> + ${CONSTRUCTING+ __trampolines_start = . ; }
> + /* The jump trampolines for the 16-bit limited relocs will reside here. */
> + *(.trampolines)
> + ${RELOCATING+ *(.trampolines*)}
> + ${CONSTRUCTING+ __trampolines_end = . ; }
> +
> + /* avr-libc expects these data to reside in lower 64K. */
> + ${RELOCATING+ *libprintf_flt.a:*(.progmem.data)}
> + ${RELOCATING+ *libc.a:*(.progmem.data)}
> +
> + ${RELOCATING+ *(.progmem*)}
> +
> + ${RELOCATING+. = ALIGN(2);}
> +
> + /* For future tablejump instruction arrays for 3 byte pc devices.
> + We don't relax jump/call instructions within these sections. */
> + *(.jumptables)
> + ${RELOCATING+ *(.jumptables*)}
> +
> + /* For code that needs to reside in the lower 128k progmem. */
> + *(.lowtext)
> + ${RELOCATING+ *(.lowtext*)}
> +
> + ${CONSTRUCTING+ __ctors_start = . ; }
> + ${CONSTRUCTING+ *(.ctors) }
> + ${CONSTRUCTING+ __ctors_end = . ; }
> + ${CONSTRUCTING+ __dtors_start = . ; }
> + ${CONSTRUCTING+ *(.dtors) }
> + ${CONSTRUCTING+ __dtors_end = . ; }
> + KEEP(SORT(*)(.ctors))
> + KEEP(SORT(*)(.dtors))
> +
> + /* From this point on, we don't bother about wether the insns are
> + below or above the 16 bits boundary. */
> + *(.init0) /* Start here after reset. */
> + KEEP (*(.init0))
> + *(.init1)
> + KEEP (*(.init1))
> + *(.init2) /* Clear __zero_reg__, set up stack pointer. */
> + KEEP (*(.init2))
> + *(.init3)
> + KEEP (*(.init3))
> + *(.init4) /* Initialize data and BSS. */
> + KEEP (*(.init4))
> + *(.init5)
> + KEEP (*(.init5))
> + *(.init6) /* C++ constructors. */
> + KEEP (*(.init6))
> + *(.init7)
> + KEEP (*(.init7))
> + *(.init8)
> + KEEP (*(.init8))
> + *(.init9) /* Call main(). */
> + KEEP (*(.init9))
> + *(.text)
> + ${RELOCATING+. = ALIGN(2);}
> + ${RELOCATING+ *(.text.*)}
> + ${RELOCATING+. = ALIGN(2);}
> + *(.fini9) /* _exit() starts here. */
> + KEEP (*(.fini9))
> + *(.fini8)
> + KEEP (*(.fini8))
> + *(.fini7)
> + KEEP (*(.fini7))
> + *(.fini6) /* C++ destructors. */
> + KEEP (*(.fini6))
> + *(.fini5)
> + KEEP (*(.fini5))
> + *(.fini4)
> + KEEP (*(.fini4))
> + *(.fini3)
> + KEEP (*(.fini3))
> + *(.fini2)
> + KEEP (*(.fini2))
> + *(.fini1)
> + KEEP (*(.fini1))
> + *(.fini0) /* Infinite loop after program termination. */
> + KEEP (*(.fini0))
> + ${RELOCATING+ _etext = . ; }
> + } ${RELOCATING+ > text}
> +
> + .rodata ${RELOCATING+ ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__ } ${RELOCATING-0} :
> + {
> + *(.rodata)
> + ${RELOCATING+ *(.rodata*)}
> + *(.gnu.linkonce.r*)
> + } ${RELOCATING+AT> text}
> +
> + .data ${RELOCATING-0} :
> + {
> + ${RELOCATING+ PROVIDE (__data_start = .) ; }
> + *(.data)
> + ${RELOCATING+ *(.data*)}
> + *(.gnu.linkonce.d*)
> + ${RELOCATING+. = ALIGN(2);}
> + ${RELOCATING+ _edata = . ; }
> + ${RELOCATING+ PROVIDE (__data_end = .) ; }
> + } ${RELOCATING+ > data ${RELOCATING+AT> text}}
> +
> + .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
> + {
> + ${RELOCATING+ PROVIDE (__bss_start = .) ; }
> + *(.bss)
> + ${RELOCATING+ *(.bss*)}
> + *(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+ PROVIDE (__noinit_end = .) ; }
> + ${RELOCATING+ _end = . ; }
> + ${RELOCATING+ PROVIDE (__heap_start = .) ; }
> + } ${RELOCATING+ > data}
> +
> + .eeprom ${RELOCATING-0}:
> + {
> + /* See .data above... */
> + KEEP(*(.eeprom*))
> + ${RELOCATING+ __eeprom_end = . ; }
> + } ${RELOCATING+ > eeprom}
> +
> + .fuse ${RELOCATING-0}:
> + {
> + KEEP(*(.fuse))
> + KEEP(*(.lfuse))
> + KEEP(*(.hfuse))
> + KEEP(*(.efuse))
> + } ${RELOCATING+ > fuse}
> +
> + .lock ${RELOCATING-0}:
> + {
> + KEEP(*(.lock*))
> + } ${RELOCATING+ > lock}
> +
> + .signature ${RELOCATING-0}:
> + {
> + KEEP(*(.signature*))
> + } ${RELOCATING+ > signature}
> +
> + /* Stabs debugging sections. */
> + .stab 0 : { *(.stab) }
> + .stabstr 0 : { *(.stabstr) }
> + .stab.excl 0 : { *(.stab.excl) }
> + .stab.exclstr 0 : { *(.stab.exclstr) }
> + .stab.index 0 : { *(.stab.index) }
> + .stab.indexstr 0 : { *(.stab.indexstr) }
> + .comment 0 : { *(.comment) }
> + .note.gnu.build-id : { *(.note.gnu.build-id) }
> +EOF
> +
> +. $srcdir/scripttempl/DWARF.sc
> +
> +cat <<EOF
> +}
> +EOF
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
2017-05-08 20:24 ` Joerg Wunsch
@ 2017-05-09 8:57 ` Georg-Johann Lay
0 siblings, 0 replies; 12+ messages in thread
From: Georg-Johann Lay @ 2017-05-09 8:57 UTC (permalink / raw)
To: Joerg Wunsch
Cc: binutils, Denis Chertykov, Senthil Kumar Selvaraj,
Pitchumani Sivanupandi, Nick Clifton
On 08.05.2017 22:24, Joerg Wunsch wrote:
> As Georg-Johann Lay wrote:
>
>> Ok for master?
>>
>> If approved, please someone with commit privileges apply the patch.
>
> No objections against it from avr-libc's point of view. I don't think
> we are affected by it anyway.
We need to add avrxmega3 to the multilib configuration by hand as
avr-libc doesn't pick up the multilib configuration from gcc as
presented by -print-multi-lib. But this will be an avr-libc
change of course.
Johann
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
2017-05-09 5:54 ` Senthil Kumar Selvaraj
@ 2017-05-09 9:26 ` Georg-Johann Lay
2017-05-09 10:54 ` Nick Clifton
0 siblings, 1 reply; 12+ messages in thread
From: Georg-Johann Lay @ 2017-05-09 9:26 UTC (permalink / raw)
To: Senthil Kumar Selvaraj
Cc: binutils, Denis Chertykov, Pitchumani Sivanupandi, Joerg Wunsch,
Nick Clifton
On 09.05.2017 07:51, Senthil Kumar Selvaraj wrote:
>
> Georg-Johann Lay writes:
>
>> ATtiny416, ATtiny417, ATtiny816, ATtiny817 are devices which implement
>> avrxmega2 ISA with the additional feature that flash memory is visible
>> in the SRAM address range (starting at 0x8000). In order to optimally
>> support this feature, an according linker description file should be
>> used per default, i.e. we want a new emulation which comes with this
>> liker description file.
>
> I'm still not convinced we need a new emulation for this. Sure, we need
> a new multilib option in gcc, but can't we do it the way msp8 aka
> tiny-stack is handled now? IMO, mapping flash to the data address space
> is arch independent, and breaking it out into a separate emulation could
> lead to a combinatorial explosion of emulations if devices with that
> feature come out for other existing archs. Can't help it for multilibs,
> but I'm not sure we need emulations as well.
Well, the most annoying thing is actually the multilib thing as
avr-libc doesn't catch up with avr-gcc automatically. Anyway,
the GNU AVR tools have always strived to give the best code generation
and device support, and sometimes this means we have to introduce
changes that are not confined to gcc alone.
I don't see a way how to provide a linker description file without
supplying a new emulation. Letting the compiler pick a non-standard
ld script is definitely sub-optimal and might introduce even more
work than just activating avrxmega3 for that purpose.
If avrxmega3 is not appropriate, then I am open for any other
name, but the arch id 103, name and features fit nicely between
102 and 104.
As for which devices are still to come and planned, you guys at
atmochip have definitely the best overview and internals information.
However, I'd expect the linear address range feature only for devices
with flash < 64 KiB which all fit the proposed avrxmega3. If I don't
misread the data sheets and there is not an erratum, then even the
small devices with flash <= 8 KiB support JMP and CALL. Hence we
don't need different multilibs to separate that feature.
(avr-libc however uses availability of JMP /CALL to determine the
vector sizes, and with the current handling we would get 4 bytes
for devices with < 16 KiB flash which appears to be wrong.)
And I really don't know what you are planning w.r.t. new devices,
I rather expected AVR to have reached end of life as Microchip
consumed Atmel...
>> The patch uses avrxmega3 for this. Actually, avrxmega3 is an already
>> existing emulation, but one containing no devices so far, and one which
>> avr-gcc doesn't even generate a multilib variant for.
>>
>> Besides optimal support by a linker description file, the compiler might
>> come up with different code for these devices. For example, referencing
>> __do_copy_data is no more needed for stuff in .rodata. This is a second
>> reason for why we wand a separate emulation for these devices.
>
> Again, can't we do this the way we handle msp8 now i.e. set a global var
> based on a command line option (mrodata-in-flash?) and then use it to
> modify code gen?
-msp8 doesn't require a new emulation because it can use the same linker
description like multilib variants without -msp8.
Johann
> Regards
> Senthil
>
>> As there are currently no devices in this emulation, the patch doesn't
>> break anything existing, is just makes use of code that was dead so far.
>>
>> The relevant portion of avrxmega3.x is the handling of .rodata which
>> reads similar to the avrtiny.x (PR20849):
>>
>>
>> __RODATA_PM_OFFSET__= DEFINED(__RODATA_PM_OFFSET__) ?
>> __RODATA_PM_OFFSET__: 0x8000;
>>
>>
>> .text :
>> {
>> ...
>> } > text
>> .rodata ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__:
>> {
>> *(.rodata)
>> *(.rodata*)
>> *(.gnu.linkonce.r*)
>> } AT> text
>> .data :
>> {
>> ...
>>
>> Ok for master?
>>
>> If approved, please someone with commit privileges apply the patch.
>>
>>
>> Johann
>>
>>
>> ld/
>> Upgrade the currently unused emulation avrxmega3 to one which
>> supports avrxmega2 devices with flash memory visible in the
>> SRAM address range.
>>
>> PR21472
>> * scripttempl/avr_rodata.sc: New file.
>> * emulparams/avrxmega3.sh (SCRIPT_NAME): Use avr_rodata.
>> (RODATA_PM_OFFSET): Set to 0x8000.
>>
>> gas/
>> PR21472
>> * config/tc-avr.c (mcu_types): Add entries for: attiny416,
>> attiny417, attiny816, attiny817.
>>
>>
>> diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
>> index 7214c07..79837c8 100644
>> --- a/gas/config/tc-avr.c
>> +++ b/gas/config/tc-avr.c
>> @@ -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},
>> diff --git a/ld/emulparams/avrxmega3.sh b/ld/emulparams/avrxmega3.sh
>> index abaa5b3..504c492 100644
>> --- a/ld/emulparams/avrxmega3.sh
>> +++ b/ld/emulparams/avrxmega3.sh
>> @@ -1,6 +1,6 @@
>> ARCH=avr:103
>> MACHINE=
>> -SCRIPT_NAME=avr
>> +SCRIPT_NAME=avr_rodata
>> OUTPUT_FORMAT="elf32-avr"
>> MAXPAGESIZE=1
>> EMBEDDED=yes
>> @@ -9,4 +9,5 @@ TEMPLATE_NAME=elf32
>> TEXT_LENGTH=1024K
>> DATA_ORIGIN=0x802000
>> DATA_LENGTH=0xffa0
>> +RODATA_PM_OFFSET=0x8000
>> EXTRA_EM_FILE=avrelf
>> diff --git a/ld/scripttempl/avr_rodata.sc b/ld/scripttempl/avr_rodata.sc
>> new file mode 100644
>> index 0000000..eecfedf
>> --- /dev/null
>> +++ b/ld/scripttempl/avr_rodata.sc
>> @@ -0,0 +1,272 @@
>> +# Copyright (C) 2014-2017 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.
>> +
>> +cat <<EOF
>> +/* Copyright (C) 2014-2017 Free Software Foundation, Inc.
>> +
>> + Copying and distribution of this script, with or without modification,
>> + are permitted in any medium without royalty provided the copyright
>> + notice and this notice are preserved. */
>> +
>> +OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
>> +OUTPUT_ARCH(${ARCH})
>> +
>> +__TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : $TEXT_LENGTH;
>> +__DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : $DATA_LENGTH;
>> +__EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? __EEPROM_REGION_LENGTH__ : 64K;
>> +__FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 1K;
>> +__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;
>> +__RODATA_PM_OFFSET__ = DEFINED(__RODATA_PM_OFFSET__) ? __RODATA_PM_OFFSET__ : $RODATA_PM_OFFSET;
>> +
>> +MEMORY
>> +{
>> + text (rx) : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__
>> + data (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DATA_REGION_LENGTH__
>> + eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__
>> + fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
>> + lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
>> + signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
>> + user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__
>> +}
>> +
>> +SECTIONS
>> +{
>> + /* Read-only sections, merged into text segment: */
>> + ${TEXT_DYNAMIC+${DYNAMIC}}
>> + .hash ${RELOCATING-0} : { *(.hash) }
>> + .dynsym ${RELOCATING-0} : { *(.dynsym) }
>> + .dynstr ${RELOCATING-0} : { *(.dynstr) }
>> + .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
>> + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
>> + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
>> +
>> + .rel.init ${RELOCATING-0} : { *(.rel.init) }
>> + .rela.init ${RELOCATING-0} : { *(.rela.init) }
>> + .rel.text ${RELOCATING-0} :
>> + {
>> + *(.rel.text)
>> + ${RELOCATING+*(.rel.text.*)}
>> + ${RELOCATING+*(.rel.gnu.linkonce.t*)}
>> + }
>> + .rela.text ${RELOCATING-0} :
>> + {
>> + *(.rela.text)
>> + ${RELOCATING+*(.rela.text.*)}
>> + ${RELOCATING+*(.rela.gnu.linkonce.t*)}
>> + }
>> + .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
>> + .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
>> + .rel.rodata ${RELOCATING-0} :
>> + {
>> + *(.rel.rodata)
>> + ${RELOCATING+*(.rel.rodata.*)}
>> + ${RELOCATING+*(.rel.gnu.linkonce.r*)}
>> + }
>> + .rela.rodata ${RELOCATING-0} :
>> + {
>> + *(.rela.rodata)
>> + ${RELOCATING+*(.rela.rodata.*)}
>> + ${RELOCATING+*(.rela.gnu.linkonce.r*)}
>> + }
>> + .rel.data ${RELOCATING-0} :
>> + {
>> + *(.rel.data)
>> + ${RELOCATING+*(.rel.data.*)}
>> + ${RELOCATING+*(.rel.gnu.linkonce.d*)}
>> + }
>> + .rela.data ${RELOCATING-0} :
>> + {
>> + *(.rela.data)
>> + ${RELOCATING+*(.rela.data.*)}
>> + ${RELOCATING+*(.rela.gnu.linkonce.d*)}
>> + }
>> + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
>> + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
>> + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
>> + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
>> + .rel.got ${RELOCATING-0} : { *(.rel.got) }
>> + .rela.got ${RELOCATING-0} : { *(.rela.got) }
>> + .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
>> + .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
>> + .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
>> + .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
>> +
>> + /* Internal text space or external memory. */
>> + .text ${RELOCATING-0} :
>> + {
>> + *(.vectors)
>> + KEEP(*(.vectors))
>> +
>> + /* For data that needs to reside in the lower 64k of progmem. */
>> + ${RELOCATING+ *(.progmem.gcc*)}
>> +
>> + /* PR 13812: Placing the trampolines here gives a better chance
>> + that they will be in range of the code that uses them. */
>> + ${RELOCATING+. = ALIGN(2);}
>> + ${CONSTRUCTING+ __trampolines_start = . ; }
>> + /* The jump trampolines for the 16-bit limited relocs will reside here. */
>> + *(.trampolines)
>> + ${RELOCATING+ *(.trampolines*)}
>> + ${CONSTRUCTING+ __trampolines_end = . ; }
>> +
>> + /* avr-libc expects these data to reside in lower 64K. */
>> + ${RELOCATING+ *libprintf_flt.a:*(.progmem.data)}
>> + ${RELOCATING+ *libc.a:*(.progmem.data)}
>> +
>> + ${RELOCATING+ *(.progmem*)}
>> +
>> + ${RELOCATING+. = ALIGN(2);}
>> +
>> + /* For future tablejump instruction arrays for 3 byte pc devices.
>> + We don't relax jump/call instructions within these sections. */
>> + *(.jumptables)
>> + ${RELOCATING+ *(.jumptables*)}
>> +
>> + /* For code that needs to reside in the lower 128k progmem. */
>> + *(.lowtext)
>> + ${RELOCATING+ *(.lowtext*)}
>> +
>> + ${CONSTRUCTING+ __ctors_start = . ; }
>> + ${CONSTRUCTING+ *(.ctors) }
>> + ${CONSTRUCTING+ __ctors_end = . ; }
>> + ${CONSTRUCTING+ __dtors_start = . ; }
>> + ${CONSTRUCTING+ *(.dtors) }
>> + ${CONSTRUCTING+ __dtors_end = . ; }
>> + KEEP(SORT(*)(.ctors))
>> + KEEP(SORT(*)(.dtors))
>> +
>> + /* From this point on, we don't bother about wether the insns are
>> + below or above the 16 bits boundary. */
>> + *(.init0) /* Start here after reset. */
>> + KEEP (*(.init0))
>> + *(.init1)
>> + KEEP (*(.init1))
>> + *(.init2) /* Clear __zero_reg__, set up stack pointer. */
>> + KEEP (*(.init2))
>> + *(.init3)
>> + KEEP (*(.init3))
>> + *(.init4) /* Initialize data and BSS. */
>> + KEEP (*(.init4))
>> + *(.init5)
>> + KEEP (*(.init5))
>> + *(.init6) /* C++ constructors. */
>> + KEEP (*(.init6))
>> + *(.init7)
>> + KEEP (*(.init7))
>> + *(.init8)
>> + KEEP (*(.init8))
>> + *(.init9) /* Call main(). */
>> + KEEP (*(.init9))
>> + *(.text)
>> + ${RELOCATING+. = ALIGN(2);}
>> + ${RELOCATING+ *(.text.*)}
>> + ${RELOCATING+. = ALIGN(2);}
>> + *(.fini9) /* _exit() starts here. */
>> + KEEP (*(.fini9))
>> + *(.fini8)
>> + KEEP (*(.fini8))
>> + *(.fini7)
>> + KEEP (*(.fini7))
>> + *(.fini6) /* C++ destructors. */
>> + KEEP (*(.fini6))
>> + *(.fini5)
>> + KEEP (*(.fini5))
>> + *(.fini4)
>> + KEEP (*(.fini4))
>> + *(.fini3)
>> + KEEP (*(.fini3))
>> + *(.fini2)
>> + KEEP (*(.fini2))
>> + *(.fini1)
>> + KEEP (*(.fini1))
>> + *(.fini0) /* Infinite loop after program termination. */
>> + KEEP (*(.fini0))
>> + ${RELOCATING+ _etext = . ; }
>> + } ${RELOCATING+ > text}
>> +
>> + .rodata ${RELOCATING+ ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__ } ${RELOCATING-0} :
>> + {
>> + *(.rodata)
>> + ${RELOCATING+ *(.rodata*)}
>> + *(.gnu.linkonce.r*)
>> + } ${RELOCATING+AT> text}
>> +
>> + .data ${RELOCATING-0} :
>> + {
>> + ${RELOCATING+ PROVIDE (__data_start = .) ; }
>> + *(.data)
>> + ${RELOCATING+ *(.data*)}
>> + *(.gnu.linkonce.d*)
>> + ${RELOCATING+. = ALIGN(2);}
>> + ${RELOCATING+ _edata = . ; }
>> + ${RELOCATING+ PROVIDE (__data_end = .) ; }
>> + } ${RELOCATING+ > data ${RELOCATING+AT> text}}
>> +
>> + .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
>> + {
>> + ${RELOCATING+ PROVIDE (__bss_start = .) ; }
>> + *(.bss)
>> + ${RELOCATING+ *(.bss*)}
>> + *(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+ PROVIDE (__noinit_end = .) ; }
>> + ${RELOCATING+ _end = . ; }
>> + ${RELOCATING+ PROVIDE (__heap_start = .) ; }
>> + } ${RELOCATING+ > data}
>> +
>> + .eeprom ${RELOCATING-0}:
>> + {
>> + /* See .data above... */
>> + KEEP(*(.eeprom*))
>> + ${RELOCATING+ __eeprom_end = . ; }
>> + } ${RELOCATING+ > eeprom}
>> +
>> + .fuse ${RELOCATING-0}:
>> + {
>> + KEEP(*(.fuse))
>> + KEEP(*(.lfuse))
>> + KEEP(*(.hfuse))
>> + KEEP(*(.efuse))
>> + } ${RELOCATING+ > fuse}
>> +
>> + .lock ${RELOCATING-0}:
>> + {
>> + KEEP(*(.lock*))
>> + } ${RELOCATING+ > lock}
>> +
>> + .signature ${RELOCATING-0}:
>> + {
>> + KEEP(*(.signature*))
>> + } ${RELOCATING+ > signature}
>> +
>> + /* Stabs debugging sections. */
>> + .stab 0 : { *(.stab) }
>> + .stabstr 0 : { *(.stabstr) }
>> + .stab.excl 0 : { *(.stab.excl) }
>> + .stab.exclstr 0 : { *(.stab.exclstr) }
>> + .stab.index 0 : { *(.stab.index) }
>> + .stab.indexstr 0 : { *(.stab.indexstr) }
>> + .comment 0 : { *(.comment) }
>> + .note.gnu.build-id : { *(.note.gnu.build-id) }
>> +EOF
>> +
>> +. $srcdir/scripttempl/DWARF.sc
>> +
>> +cat <<EOF
>> +}
>> +EOF
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
2017-05-09 9:26 ` Georg-Johann Lay
@ 2017-05-09 10:54 ` Nick Clifton
2017-05-10 7:26 ` Pitchumani Sivanupandi
2017-05-10 10:19 ` [patch,avr] Take #2 " Georg-Johann Lay
0 siblings, 2 replies; 12+ messages in thread
From: Nick Clifton @ 2017-05-09 10:54 UTC (permalink / raw)
To: Georg-Johann Lay, Senthil Kumar Selvaraj
Cc: binutils, Denis Chertykov, Pitchumani Sivanupandi, Joerg Wunsch
Hi Georg-Johann,
>> On 09.05.2017 07:51, Senthil Kumar Selvaraj wrote:
>> I'm still not convinced we need a new emulation for this.
I would really prefer it if you two can come to an agreement about
the best way to handle this. I am not adverse to adding a new emulation
if this is what you want, but I would be worried if this leads to an
explosion in the number of linker scripts later on.
> I don't see a way how to provide a linker description file without
> supplying a new emulation.
How about defining __RODATA_PM_OFFSET__ on the linker command line
and using the current avrtiny.sc script ?
>>> diff --git a/ld/emulparams/avrxmega3.sh b/ld/emulparams/avrxmega3.sh
>>> index abaa5b3..504c492 100644
>>> --- a/ld/emulparams/avrxmega3.sh
>>> +++ b/ld/emulparams/avrxmega3.sh
>>> @@ -1,6 +1,6 @@
>>> ARCH=avr:103
>>> MACHINE=
>>> -SCRIPT_NAME=avr
>>> +SCRIPT_NAME=avr_rodata
I would much prefer it if you did not create a new script, but instead added
parametrisation to the current avr and avrtiny scripts. (In fact it would be
even better if you could combine avr.sc and avrtiny.sc and just have one script).
The reason for this is that the more scripts you have, the greater the chances
of making an error or missing one out when it comes to future changes.
Take a look at the elf.sc script. It is used by lots of different targets, but
it is highly customizable via definitions in the target's specific emulparams
files.
The alternative approach, which I would also consider to be reasonable, is to have
a base avr script that defines all of the things that are consistent between all
three proposed avr linker scripts and to include this script into smaller,
avr-variant scripts that just defines those things that are specific to that variant.
Kind of like how the DWARF.sc script is included into the elf.sc script.
Cheers
Nick
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
2017-05-09 10:54 ` Nick Clifton
@ 2017-05-10 7:26 ` Pitchumani Sivanupandi
2017-05-10 10:26 ` Georg-Johann Lay
2017-05-10 10:19 ` [patch,avr] Take #2 " Georg-Johann Lay
1 sibling, 1 reply; 12+ messages in thread
From: Pitchumani Sivanupandi @ 2017-05-10 7:26 UTC (permalink / raw)
To: Nick Clifton, Georg-Johann Lay, Senthil Kumar Selvaraj
Cc: binutils, Denis Chertykov, Joerg Wunsch
[-- Attachment #1: Type: text/plain, Size: 3939 bytes --]
On Tuesday 09 May 2017 04:24 PM, Nick Clifton wrote:
> Hi Georg-Johann,
>
>>> On 09.05.2017 07:51, Senthil Kumar Selvaraj wrote:
>>> I'm still not convinced we need a new emulation for this.
> I would really prefer it if you two can come to an agreement about
> the best way to handle this. I am not adverse to adding a new emulation
> if this is what you want, but I would be worried if this leads to an
> explosion in the number of linker scripts later on.
>
>
>> I don't see a way how to provide a linker description file without
>> supplying a new emulation.
> How about defining __RODATA_PM_OFFSET__ on the linker command line
> and using the current avrtiny.sc script ?
>
>
>>>> diff --git a/ld/emulparams/avrxmega3.sh b/ld/emulparams/avrxmega3.sh
>>>> index abaa5b3..504c492 100644
>>>> --- a/ld/emulparams/avrxmega3.sh
>>>> +++ b/ld/emulparams/avrxmega3.sh
>>>> @@ -1,6 +1,6 @@
>>>> ARCH=avr:103
>>>> MACHINE=
>>>> -SCRIPT_NAME=avr
>>>> +SCRIPT_NAME=avr_rodata
> I would much prefer it if you did not create a new script, but instead added
> parametrisation to the current avr and avrtiny scripts. (In fact it would be
> even better if you could combine avr.sc and avrtiny.sc and just have one script).
>
> The reason for this is that the more scripts you have, the greater the chances
> of making an error or missing one out when it comes to future changes.
>
> Take a look at the elf.sc script. It is used by lots of different targets, but
> it is highly customizable via definitions in the target's specific emulparams
> files.
>
> The alternative approach, which I would also consider to be reasonable, is to have
> a base avr script that defines all of the things that are consistent between all
> three proposed avr linker scripts and to include this script into smaller,
> avr-variant scripts that just defines those things that are specific to that variant.
> Kind of like how the DWARF.sc script is included into the elf.sc script.
We have tentative patch to put rodata in flash conditionally (e.g.
option flag) that
seems to be working.
gcc:
Based on flag, put rodata in new section (tentatively named
.rodataFlash). Also generates
new multilib (e.g. avrxmega2/flash-rodata) for architecture with
-mflash-rodata flag.
Can enable this flag for devices with linear memory.
binutils:
It is similar to avrtiny change made to put rodata in flash. But the
section name
is .rodataFlash. Sections named .rodata will go to data (i.e.
-mflash-rodata not enabled).
avr-libc: change needed to identify the new multilib structure (to be done).
Tested following example with attiny817 simulator that comes with Atmel
Studio.
1 volatile int var;
2 const short svar = 34;
3 const char * const hello = "hello world";
4 volatile char cvar[12];
5 void main ()
6 {
7 while (1)
8 {
9 var = svar;
10 strcpy (cvar, hello);
11 }
12 }
$ avr-objdump -h test.elf
test.new.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .data 00000000 00803e00 000000b0 00000164 2**0
CONTENTS, ALLOC, LOAD, DATA
1 .text 000000a0 00000000 00000000 000000b4 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .rodataFlash 00000010 000080a0 000000a0 00000154 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .bss 0000000e 00803e00 00803e00 00000164 2**0
ALLOC
4 .stab 00000204 00000000 00000000 00000164 2**2
CONTENTS, READONLY, DEBUGGING
5 .stabstr 0000009c 00000000 00000000 00000368 2**0
CONTENTS, READONLY, DEBUGGING
6 .comment 00000029 00000000 00000000 00000404 2**0
CONTENTS, READONLY
7 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 00000430 2**2
CONTENTS, READONLY
Regards,
Pitchumani
[-- Attachment #2: flash_rodata_binutils.patch --]
[-- Type: text/x-patch, Size: 1058 bytes --]
diff --git a/ld/scripttempl/avr.sc b/ld/scripttempl/avr.sc
index b889180..69025b8 100644
--- a/ld/scripttempl/avr.sc
+++ b/ld/scripttempl/avr.sc
@@ -21,6 +21,7 @@ __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;
+__RODATA_PM_OFFSET__ = DEFINED(__RODATA_PM_OFFSET__) ? __RODATA_PM_OFFSET__ : 0x8000;
MEMORY
{
@@ -188,6 +189,13 @@ SECTIONS
${RELOCATING+ _etext = . ; }
} ${RELOCATING+ > text}
+ .rodataFlash ${RELOCATING+ ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__ } ${RELOCATING-0} :
+ {
+ *(.rodataFlash)
+ ${RELOCATING+ *(.rodataFlash*)}
+ *(.gnu.linkonce.r*)
+ } ${RELOCATING+AT> text}
+
.data ${RELOCATING-0} :
{
${RELOCATING+ PROVIDE (__data_start = .) ; }
[-- Attachment #3: flash_rodata_gcc.patch --]
[-- Type: text/x-patch, Size: 6613 bytes --]
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index 648a125..6371b70 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -9956,6 +9956,20 @@ avr_asm_asm_output_aligned_bss (FILE *file, tree decl, const char *name,
}
+/* Unnamed section callback for rodata_section
+ to track need of __do_copy_data. */
+
+static void
+avr_output_rodata_section_asm_op (const void *data)
+{
+ if (!TARGET_FLASH_RODATA)
+ avr_need_copy_data_p = true;
+
+ /* Dispatch to default. */
+ output_section_asm_op (data);
+}
+
+
/* Unnamed section callback for data_section
to track need of __do_copy_data. */
@@ -10000,7 +10014,7 @@ avr_asm_init_sections (void)
/* Override section callbacks to keep track of `avr_need_clear_bss_p'
resp. `avr_need_copy_data_p'. */
- readonly_data_section->unnamed.callback = avr_output_data_section_asm_op;
+ readonly_data_section->unnamed.callback = avr_output_rodata_section_asm_op;
data_section->unnamed.callback = avr_output_data_section_asm_op;
bss_section->unnamed.callback = avr_output_bss_section_asm_op;
}
@@ -10012,10 +10026,10 @@ avr_asm_init_sections (void)
static void
avr_asm_named_section (const char *name, unsigned int flags, tree decl)
{
+ const char *old_prefix = ".rodata";
if (flags & AVR_SECTION_PROGMEM)
{
addr_space_t as = (flags & AVR_SECTION_PROGMEM) / SECTION_MACH_DEP;
- const char *old_prefix = ".rodata";
const char *new_prefix = avr_addrspace[as].section_name;
if (STR_PREFIX_P (name, old_prefix))
@@ -10029,6 +10043,14 @@ avr_asm_named_section (const char *name, unsigned int flags, tree decl)
default_elf_asm_named_section (new_prefix, flags, decl);
return;
}
+ else if (STR_PREFIX_P(name, old_prefix) && TARGET_FLASH_RODATA)
+ {
+ const char *new_prefix = ".rodataFlash";
+ const char *sname = ACONCAT ((new_prefix,
+ name + strlen (old_prefix), NULL));
+ default_elf_asm_named_section (sname, flags, decl);
+ return;
+ }
if (!avr_need_copy_data_p)
avr_need_copy_data_p = (STR_PREFIX_P (name, ".data")
@@ -10271,6 +10293,21 @@ avr_asm_select_section (tree decl, int reloc, unsigned HOST_WIDE_INT align)
return progmem_section[as];
}
+ else if (sect->named.name)
+ {
+ const char * name = sect->named.name;
+ const char * old_prefix = ".rodata";
+ const char * new_prefix = ".rodataFlash";
+
+ if (STR_PREFIX_P (name, old_prefix))
+ {
+ const char *sname = ACONCAT ((new_prefix,
+ name + strlen (old_prefix), NULL));
+ return get_section (sname,
+ sect->common.flags & ~SECTION_DECLARED,
+ sect->named.decl);
+ }
+ }
return sect;
}
diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h
index 3dfa8c3..7d4c8fb 100644
--- a/gcc/config/avr/avr.h
+++ b/gcc/config/avr/avr.h
@@ -382,6 +382,9 @@ typedef struct avr_args
#define BSS_SECTION_ASM_OP "\t.section .bss"
+#undef READONLY_DATA_SECTION_ASM_OP
+#define READONLY_DATA_SECTION_ASM_OP (TARGET_FLASH_RODATA ? "\t.section .rodataFlash, \"a\",@progbits" : "\t.section .rodata")
+
/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
There are no shared libraries on this target, and these sections are
placed in the read-only program memory, so they are not writable. */
diff --git a/gcc/config/avr/avr.opt b/gcc/config/avr/avr.opt
index a1edec9..5442931 100644
--- a/gcc/config/avr/avr.opt
+++ b/gcc/config/avr/avr.opt
@@ -66,6 +66,10 @@ mtiny-stack
Target Report Mask(TINY_STACK)
Change only the low 8 bits of the stack pointer.
+mflash-rodata
+Target Report Mask(FLASH_RODATA)
+Keep the rodata in flash and generate code accordingly.
+
mrelax
Target Report
Relax branches.
diff --git a/gcc/config/avr/t-avr b/gcc/config/avr/t-avr
index e725d58..f7024cb 100644
--- a/gcc/config/avr/t-avr
+++ b/gcc/config/avr/t-avr
@@ -97,6 +97,7 @@ install-device-specs: s-device-specs installdirs
s-mlib: $(srcdir)/config/avr/t-multilib
-$(srcdir)/config/avr/t-multilib: $(srcdir)/config/avr/genmultilib.awk \
- $(AVR_MCUS)
- $(AWK) -f $< -v FORMAT=Makefile $< $(AVR_MCUS) > $@
+#$(srcdir)/config/avr/t-multilib: $(srcdir)/config/avr/genmultilib.awk \
+# $(AVR_MCUS)
+# $(AWK) -f $< -v FORMAT=Makefile $< $(AVR_MCUS) > $@
+
diff --git a/gcc/config/avr/t-multilib b/gcc/config/avr/t-multilib
index 8389422..d29e98a 100644
--- a/gcc/config/avr/t-multilib
+++ b/gcc/config/avr/t-multilib
@@ -21,21 +21,31 @@
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
-MULTILIB_OPTIONS = mmcu=avr2/mmcu=avr25/mmcu=avr3/mmcu=avr31/mmcu=avr35/mmcu=avr4/mmcu=avr5/mmcu=avr51/mmcu=avr6/mmcu=avrxmega2/mmcu=avrxmega4/mmcu=avrxmega5/mmcu=avrxmega6/mmcu=avrxmega7/mmcu=avrtiny msp8
+MULTI_ARCH_OPTIONS = mmcu=avr2/mmcu=avr25/mmcu=avr3/mmcu=avr31/mmcu=avr35/mmcu=avr4/mmcu=avr5/mmcu=avr51/mmcu=avr6/mmcu=avrxmega2/mmcu=avrxmega4/mmcu=avrxmega5/mmcu=avrxmega6/mmcu=avrxmega7/mmcu=avrtiny
+MULTI_ARCH_DIRNAMES = avr2 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 avrxmega2 avrxmega4 avrxmega5 avrxmega6 avrxmega7 avrtiny
-MULTILIB_DIRNAMES = avr2 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 avrxmega2 avrxmega4 avrxmega5 avrxmega6 avrxmega7 avrtiny tiny-stack avr25/tiny-stack
+MULTI_FEATURE_OPTIONS = msp8/mflash-rodata
+MULTI_FEATURE_DIRNAMES = tiny-stack flash-rodata
+
+MULTILIB_REQUIRED += *mmcu=avr2
+MULTILIB_REQUIRED += *mmcu=avr2/msp8
+MULTILIB_REQUIRED += *mmcu=avr25
+MULTILIB_REQUIRED += *mmcu=avr25/msp8
+MULTILIB_REQUIRED += *mmcu=avr3
+MULTILIB_REQUIRED += *mmcu=avr31
+MULTILIB_REQUIRED += *mmcu=avr35
+MULTILIB_REQUIRED += *mmcu=avr4
+MULTILIB_REQUIRED += *mmcu=avr5
+MULTILIB_REQUIRED += *mmcu=avr51
+MULTILIB_REQUIRED += *mmcu=avr6
+MULTILIB_REQUIRED += *mmcu=avrxmega2
+MULTILIB_REQUIRED += *mmcu=avrxmega2/mflash-rodata
+MULTILIB_REQUIRED += *mmcu=avrxmega4
+MULTILIB_REQUIRED += *mmcu=avrxmega5
+MULTILIB_REQUIRED += *mmcu=avrxmega6
+MULTILIB_REQUIRED += *mmcu=avrxmega7
+MULTILIB_REQUIRED += *mmcu=avrtiny
+
+MULTILIB_OPTIONS = $(MULTI_ARCH_OPTIONS) $(MULTI_FEATURE_OPTIONS)
+MULTILIB_DIRNAMES = $(MULTI_ARCH_DIRNAMES) $(MULTI_FEATURE_DIRNAMES)
-MULTILIB_EXCEPTIONS = \
- mmcu=avr3/msp8 \
- mmcu=avr31/msp8 \
- mmcu=avr35/msp8 \
- mmcu=avr4/msp8 \
- mmcu=avr5/msp8 \
- mmcu=avr51/msp8 \
- mmcu=avr6/msp8 \
- mmcu=avrxmega2/msp8 \
- mmcu=avrxmega4/msp8 \
- mmcu=avrxmega5/msp8 \
- mmcu=avrxmega6/msp8 \
- mmcu=avrxmega7/msp8 \
- mmcu=avrtiny/msp8
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch,avr] Take #2 PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
2017-05-09 10:54 ` Nick Clifton
2017-05-10 7:26 ` Pitchumani Sivanupandi
@ 2017-05-10 10:19 ` Georg-Johann Lay
2017-05-19 14:11 ` Nick Clifton
1 sibling, 1 reply; 12+ messages in thread
From: Georg-Johann Lay @ 2017-05-10 10:19 UTC (permalink / raw)
To: Nick Clifton, Senthil Kumar Selvaraj
Cc: binutils, Denis Chertykov, Pitchumani Sivanupandi, Joerg Wunsch
[-- Attachment #1: Type: text/plain, Size: 2240 bytes --]
On 09.05.2017 12:54, Nick Clifton wrote:
> Hi Georg-Johann,
>>>> diff --git a/ld/emulparams/avrxmega3.sh b/ld/emulparams/avrxmega3.sh
>>>> index abaa5b3..504c492 100644
>>>> --- a/ld/emulparams/avrxmega3.sh
>>>> +++ b/ld/emulparams/avrxmega3.sh
>>>> @@ -1,6 +1,6 @@
>>>> ARCH=avr:103
>>>> MACHINE=
>>>> -SCRIPT_NAME=avr
>>>> +SCRIPT_NAME=avr_rodata
>
> I would much prefer it if you did not create a new script, but instead added
> parametrisation to the current avr and avrtiny scripts. (In fact it would be
> even better if you could combine avr.sc and avrtiny.sc and just have one script).
>
> The reason for this is that the more scripts you have, the greater the chances
> of making an error or missing one out when it comes to future changes.
Ah, now I understand the objection. It was because I added a new
template script, not because of the new avrxmega3.x etc.
So here is a patch that maker avr.sc more generic and uses
RODATA_PM_OFFSET to achieve is.
> Take a look at the elf.sc script. It is used by lots of different targets, but
> it is highly customizable via definitions in the target's specific emulparams
> files.
>
> The alternative approach, which I would also consider to be reasonable, is to have
> a base avr script that defines all of the things that are consistent between all
> three proposed avr linker scripts and to include this script into smaller,
> avr-variant scripts that just defines those things that are specific to that variant.
> Kind of like how the DWARF.sc script is included into the elf.sc script.
>
> Cheers
> Nick
I didn't unite avr.sc with avrtiny.sc though which is a different story.
ld/
Upgrade the currently unused emulation avrxmega3 to one which
supports avrxmega2 devices with flash memory visible in the
SRAM address range.
PR21472
* 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/
PR21472
* config/tc-avr.c (mcu_types): Add entries for: attiny416,
attiny417, attiny816, attiny817.
[-- Attachment #2: binutils-avrxmega3-v2.diff --]
[-- Type: text/x-patch, Size: 3931 bytes --]
diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
index 7214c07..79837c8 100644
--- a/gas/config/tc-avr.c
+++ b/gas/config/tc-avr.c
@@ -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},
diff --git a/ld/emulparams/avrxmega3.sh b/ld/emulparams/avrxmega3.sh
index abaa5b3..7c5a1e5 100644
--- a/ld/emulparams/avrxmega3.sh
+++ b/ld/emulparams/avrxmega3.sh
@@ -9,4 +9,5 @@ TEMPLATE_NAME=elf32
TEXT_LENGTH=1024K
DATA_ORIGIN=0x802000
DATA_LENGTH=0xffa0
+RODATA_PM_OFFSET=0x8000
EXTRA_EM_FILE=avrelf
diff --git a/ld/scripttempl/avr.sc b/ld/scripttempl/avr.sc
index b889180..144d32d 100644
--- a/ld/scripttempl/avr.sc
+++ b/ld/scripttempl/avr.sc
@@ -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 = .) ; }
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
2017-05-10 7:26 ` Pitchumani Sivanupandi
@ 2017-05-10 10:26 ` Georg-Johann Lay
2017-05-11 7:05 ` Pitchumani Sivanupandi
0 siblings, 1 reply; 12+ messages in thread
From: Georg-Johann Lay @ 2017-05-10 10:26 UTC (permalink / raw)
To: Pitchumani Sivanupandi, Nick Clifton, Senthil Kumar Selvaraj
Cc: binutils, Denis Chertykov, Joerg Wunsch
On 10.05.2017 09:26, Pitchumani Sivanupandi wrote:
> On Tuesday 09 May 2017 04:24 PM, Nick Clifton wrote:
>> Hi Georg-Johann,
>>
>>>> On 09.05.2017 07:51, Senthil Kumar Selvaraj wrote:
>>>> I'm still not convinced we need a new emulation for this.
>> I would really prefer it if you two can come to an agreement about
>> the best way to handle this. I am not adverse to adding a new emulation
>> if this is what you want, but I would be worried if this leads to an
>> explosion in the number of linker scripts later on.
>>
>>
>>> I don't see a way how to provide a linker description file without
>>> supplying a new emulation.
>> How about defining __RODATA_PM_OFFSET__ on the linker command line
>> and using the current avrtiny.sc script ?
>>
>>
>>>>> diff --git a/ld/emulparams/avrxmega3.sh b/ld/emulparams/avrxmega3.sh
>>>>> index abaa5b3..504c492 100644
>>>>> --- a/ld/emulparams/avrxmega3.sh
>>>>> +++ b/ld/emulparams/avrxmega3.sh
>>>>> @@ -1,6 +1,6 @@
>>>>> ARCH=avr:103
>>>>> MACHINE=
>>>>> -SCRIPT_NAME=avr
>>>>> +SCRIPT_NAME=avr_rodata
>> I would much prefer it if you did not create a new script, but instead
>> added
>> parametrisation to the current avr and avrtiny scripts. (In fact it
>> would be
>> even better if you could combine avr.sc and avrtiny.sc and just have
>> one script).
>>
>> The reason for this is that the more scripts you have, the greater the
>> chances
>> of making an error or missing one out when it comes to future changes.
>>
>> Take a look at the elf.sc script. It is used by lots of different
>> targets, but
>> it is highly customizable via definitions in the target's specific
>> emulparams
>> files.
>>
>> The alternative approach, which I would also consider to be
>> reasonable, is to have
>> a base avr script that defines all of the things that are consistent
>> between all
>> three proposed avr linker scripts and to include this script into
>> smaller,
>> avr-variant scripts that just defines those things that are specific
>> to that variant.
>> Kind of like how the DWARF.sc script is included into the elf.sc script.
> We have tentative patch to put rodata in flash conditionally (e.g.
> option flag) that
> seems to be working.
>
> gcc:
> Based on flag, put rodata in new section (tentatively named
> .rodataFlash). Also generates
This is not sound, IMO. Amongst the problems this might cause are:
* Testsuite problems because of off .rodata name.
* Assembler programs might still use .rodata.
* Placement of .gnu.linkonce.r is not handled.
* The handling of .progmem appears to be broken.
Anyway, this is all GCC stuff.
You you explain why a new ld script is so bad?
Johann
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
2017-05-10 10:26 ` Georg-Johann Lay
@ 2017-05-11 7:05 ` Pitchumani Sivanupandi
2017-05-11 8:55 ` Georg-Johann Lay
0 siblings, 1 reply; 12+ messages in thread
From: Pitchumani Sivanupandi @ 2017-05-11 7:05 UTC (permalink / raw)
To: Georg-Johann Lay, Nick Clifton, Senthil Kumar Selvaraj
Cc: binutils, Denis Chertykov, Joerg Wunsch
On Wednesday 10 May 2017 03:56 PM, Georg-Johann Lay wrote:
> On 10.05.2017 09:26, Pitchumani Sivanupandi wrote:
>> On Tuesday 09 May 2017 04:24 PM, Nick Clifton wrote:
>>> Hi Georg-Johann,
>>>
>>>>> On 09.05.2017 07:51, Senthil Kumar Selvaraj wrote:
>>>>> I'm still not convinced we need a new emulation for this.
>>> I would really prefer it if you two can come to an agreement about
>>> the best way to handle this. I am not adverse to adding a new
>>> emulation
>>> if this is what you want, but I would be worried if this leads to an
>>> explosion in the number of linker scripts later on.
>>>
>>>
>>>> I don't see a way how to provide a linker description file without
>>>> supplying a new emulation.
>>> How about defining __RODATA_PM_OFFSET__ on the linker command line
>>> and using the current avrtiny.sc script ?
>>>
>>>
>>>>>> diff --git a/ld/emulparams/avrxmega3.sh b/ld/emulparams/avrxmega3.sh
>>>>>> index abaa5b3..504c492 100644
>>>>>> --- a/ld/emulparams/avrxmega3.sh
>>>>>> +++ b/ld/emulparams/avrxmega3.sh
>>>>>> @@ -1,6 +1,6 @@
>>>>>> ARCH=avr:103
>>>>>> MACHINE=
>>>>>> -SCRIPT_NAME=avr
>>>>>> +SCRIPT_NAME=avr_rodata
>>> I would much prefer it if you did not create a new script, but instead
>>> added
>>> parametrisation to the current avr and avrtiny scripts. (In fact it
>>> would be
>>> even better if you could combine avr.sc and avrtiny.sc and just have
>>> one script).
>>>
>>> The reason for this is that the more scripts you have, the greater the
>>> chances
>>> of making an error or missing one out when it comes to future changes.
>>>
>>> Take a look at the elf.sc script. It is used by lots of different
>>> targets, but
>>> it is highly customizable via definitions in the target's specific
>>> emulparams
>>> files.
>>>
>>> The alternative approach, which I would also consider to be
>>> reasonable, is to have
>>> a base avr script that defines all of the things that are consistent
>>> between all
>>> three proposed avr linker scripts and to include this script into
>>> smaller,
>>> avr-variant scripts that just defines those things that are specific
>>> to that variant.
>>> Kind of like how the DWARF.sc script is included into the elf.sc
>>> script.
>> We have tentative patch to put rodata in flash conditionally (e.g.
>> option flag) that
>> seems to be working.
>>
>> gcc:
>> Based on flag, put rodata in new section (tentatively named
>> .rodataFlash). Also generates
>
> This is not sound, IMO. Amongst the problems this might cause are:
>
> * Testsuite problems because of off .rodata name.
-fdata-sections manipulates the section names, Is it ok if the proposed
section name follows that format (e.g. .rodata.__flash or .rodata.progmem)?
> * Assembler programs might still use .rodata.
It'd still work though, just that the contents won't go to flash. Not sure
if it's a deal breaker - even now, do_copy_data doesn't get linked in
if C code doesn't generate .data/.rodata/.gnu.linkonce* and
.data/.rodata section
is used only in assembler programs.
> * Placement of .gnu.linkonce.r is not handled.
>
> * The handling of .progmem appears to be broken.
>
> Anyway, this is all GCC stuff.
Yes, that patch is tentative. Detecting linear memory and adding options to
avr specs file are few other things to be done.
> You you explain why a new ld script is so bad?
Linker script is ok, it's the new emulation that's a concern.
As explained earlier by Senthil, it doesn't sound good adding new emulation
if future devices in other emulations are made with linear memory. Another
reason is that we could place the .rodata* in flash optionally for
devices with
non-linear memory (thinking of supporting this feature if possible).
Regards,
Pitchumani
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
2017-05-11 7:05 ` Pitchumani Sivanupandi
@ 2017-05-11 8:55 ` Georg-Johann Lay
0 siblings, 0 replies; 12+ messages in thread
From: Georg-Johann Lay @ 2017-05-11 8:55 UTC (permalink / raw)
To: Pitchumani Sivanupandi, Nick Clifton, Senthil Kumar Selvaraj
Cc: binutils, Denis Chertykov, Joerg Wunsch
On 11.05.2017 09:05, Pitchumani Sivanupandi wrote:
> On Wednesday 10 May 2017 03:56 PM, Georg-Johann Lay wrote:
>> On 10.05.2017 09:26, Pitchumani Sivanupandi wrote:
>>> On Tuesday 09 May 2017 04:24 PM, Nick Clifton wrote:
>>>> Hi Georg-Johann,
>>>>
>>>>>> On 09.05.2017 07:51, Senthil Kumar Selvaraj wrote:
>>>>>> I'm still not convinced we need a new emulation for this.
>>>> I would really prefer it if you two can come to an agreement about
>>>> the best way to handle this. I am not adverse to adding a new
>>>> emulation
>>>> if this is what you want, but I would be worried if this leads to an
>>>> explosion in the number of linker scripts later on.
>>>>
>>>>
>>>>> I don't see a way how to provide a linker description file without
>>>>> supplying a new emulation.
>>>> How about defining __RODATA_PM_OFFSET__ on the linker command line
>>>> and using the current avrtiny.sc script ?
>>>>
>>>>
>>>>>>> diff --git a/ld/emulparams/avrxmega3.sh b/ld/emulparams/avrxmega3.sh
>>>>>>> index abaa5b3..504c492 100644
>>>>>>> --- a/ld/emulparams/avrxmega3.sh
>>>>>>> +++ b/ld/emulparams/avrxmega3.sh
>>>>>>> @@ -1,6 +1,6 @@
>>>>>>> ARCH=avr:103
>>>>>>> MACHINE=
>>>>>>> -SCRIPT_NAME=avr
>>>>>>> +SCRIPT_NAME=avr_rodata
>>>> I would much prefer it if you did not create a new script, but instead
>>>> added
>>>> parametrisation to the current avr and avrtiny scripts. (In fact it
>>>> would be
>>>> even better if you could combine avr.sc and avrtiny.sc and just have
>>>> one script).
>>>>
>>>> The reason for this is that the more scripts you have, the greater the
>>>> chances
>>>> of making an error or missing one out when it comes to future changes.
>>>>
>>>> Take a look at the elf.sc script. It is used by lots of different
>>>> targets, but
>>>> it is highly customizable via definitions in the target's specific
>>>> emulparams
>>>> files.
>>>>
>>>> The alternative approach, which I would also consider to be
>>>> reasonable, is to have
>>>> a base avr script that defines all of the things that are consistent
>>>> between all
>>>> three proposed avr linker scripts and to include this script into
>>>> smaller,
>>>> avr-variant scripts that just defines those things that are specific
>>>> to that variant.
>>>> Kind of like how the DWARF.sc script is included into the elf.sc
>>>> script.
>>> We have tentative patch to put rodata in flash conditionally (e.g.
>>> option flag) that
>>> seems to be working.
>>>
>>> gcc:
>>> Based on flag, put rodata in new section (tentatively named
>>> .rodataFlash). Also generates
>>
>> This is not sound, IMO. Amongst the problems this might cause are:
>>
>> * Testsuite problems because of off .rodata name.
> -fdata-sections manipulates the section names, Is it ok if the proposed
> section name follows that format (e.g. .rodata.__flash or .rodata.progmem)?
From my experience we can expect problems if we try to patch .rodata
and that are hard to fix, one reason being the weird varasm of gcc.
So I'd strongly recommend *not* to hack .rodata in the compiler.
>> * Assembler programs might still use .rodata.
> It'd still work though, just that the contents won't go to flash. Not sure
> if it's a deal breaker - even now, do_copy_data doesn't get linked in
> if C code doesn't generate .data/.rodata/.gnu.linkonce* and
> .data/.rodata section
> is used only in assembler programs.
>> * Placement of .gnu.linkonce.r is not handled.
>>
>> * The handling of .progmem appears to be broken.
>>
>> Anyway, this is all GCC stuff.
As said, It's preferred to avoid GCC problems in the first place and
do what you'd do as programmer: Use proper ld script.
I can understand that Mircochip rejects all changes that go in a
different direction than what Microchip has locally in their sources.
But what I am proposing does not render anything existing invalid
or incompatible. You can still use avrxmega2 in your device file
archives and everything will work out fine.
We could of course add an option to binutils that changes ld script
selection without changing the emulation, but that's unnecessarily
complicated and I don't see the advantage to avoid my any means a
new -mmcu=
> Yes, that patch is tentative. Detecting linear memory and adding options to
> avr specs file are few other things to be done.
>> You you explain why a new ld script is so bad?
> Linker script is ok, it's the new emulation that's a concern.
> As explained earlier by Senthil, it doesn't sound good adding new emulation
> if future devices in other emulations are made with linear memory. Another
> reason is that we could place the .rodata* in flash optionally for
> devices with
> non-linear memory (thinking of supporting this feature if possible).
I still don't get it. We currently have 17 emulations supported, and
this adds another 1 or 2. We have more than 250 devices described in
gcc. What is it what new emulation is bad? Local changes at
Microchip?
Johann
> Regards,
> Pitchumani
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch,avr] Take #2 PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM.
2017-05-10 10:19 ` [patch,avr] Take #2 " Georg-Johann Lay
@ 2017-05-19 14:11 ` Nick Clifton
0 siblings, 0 replies; 12+ messages in thread
From: Nick Clifton @ 2017-05-19 14:11 UTC (permalink / raw)
To: Georg-Johann Lay, Senthil Kumar Selvaraj
Cc: binutils, Denis Chertykov, Pitchumani Sivanupandi, Joerg Wunsch
Hi Georg-Johann,
> So here is a patch that maker avr.sc more generic and uses
> RODATA_PM_OFFSET to achieve is.
I like it. So much that I bought the company. No sorry - that was
an old TV advert. I liked it so much that I checked the patch in for
you. :-)
> I didn't unite avr.sc with avrtiny.sc though which is a different story.
True - maybe one day. But I do not see it as a priority.
Cheers
Nick
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2017-05-19 14:10 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-08 11:41 [patch,avr] PR21472: Upgrade emulation avrxmega3 so it has .rodata in flash instead of in SRAM Georg-Johann Lay
2017-05-08 20:24 ` Joerg Wunsch
2017-05-09 8:57 ` Georg-Johann Lay
2017-05-09 5:54 ` Senthil Kumar Selvaraj
2017-05-09 9:26 ` Georg-Johann Lay
2017-05-09 10:54 ` Nick Clifton
2017-05-10 7:26 ` Pitchumani Sivanupandi
2017-05-10 10:26 ` Georg-Johann Lay
2017-05-11 7:05 ` Pitchumani Sivanupandi
2017-05-11 8:55 ` Georg-Johann Lay
2017-05-10 10:19 ` [patch,avr] Take #2 " Georg-Johann Lay
2017-05-19 14:11 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).