From 2c6f3e56cbba35365ce0f558e9bfbb122a63a63d Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Fri, 27 Nov 2020 10:45:35 +0000 Subject: ELF: Support .noinit and .persistent sections The ".persistent" section is for data that should be initialized during load, but not during application reset. The ".noinit" section is for data that should not be initialized during load or application reset. Targets utilizing the elf.sc linker script template can define HAVE_{NOINIT,PERSISTENT}=yes to include the .noinit or .persistent output sections in the generated linker script. Targets with existing support for .noinit did not handle unique .noinit.* and .gnu.linkonce.n.* sections the .noinit output section, this patch also fixes that. bfd/ChangeLog: * elf.c (special_sections_g): Add .gnu.linkonce.n and .gnu.linkonce.p. (special_sections_n): Add .noinit. (special_sections_p): Add .persistent. binutils/ChangeLog: * testsuite/lib/binutils-common.exp (supports_noinit_section): New. (supports_persistent_section): New. gas/ChangeLog: * testsuite/gas/elf/elf.exp: Run new tests. * testsuite/gas/elf/section25.d: New test. * testsuite/gas/elf/section25.s: New test. * testsuite/gas/elf/section26.d: New test. * testsuite/gas/elf/section26.s: New test. ld/ChangeLog: * emulparams/armelf.sh (OTHER_SECTIONS): Remove .noinit section definition. Define HAVE_{NOINIT,PERSISTENT}=yes. * scripttempl/avr.sc (.noinit): Add .noinit.* and .gnu.linkonce.n.* input section wildcard patterns. * scripttempl/elf.sc: Define .noinit and .persistent sections when HAVE_NOINIT or HAVE_PERSISTENT are defined to "yes". * scripttempl/elf32msp430.sc (.noinit): Add .noinit.* and .gnu.linkonce.n.*. input section wildcard patterns. (.persistent): Add .persistent.* and .gnu.linkonce.p.*. input section wildcard patterns. * scripttempl/elfarcv2.sc (.noinit): Add .noinit.* and .gnu.linkonce.n.*. input section wildcard patterns. * scripttempl/pru.sc: Likewise. * testsuite/ld-elf/noinit-sections-1.d: New test. * testsuite/ld-elf/noinit-sections-2.d: New test. * testsuite/ld-elf/noinit-sections-2.l: New test. * testsuite/ld-elf/noinit-sections.s: New test. * testsuite/ld-elf/persistent-sections-1.d: New test. * testsuite/ld-elf/persistent-sections-2.d: New test. * testsuite/ld-elf/persistent-sections-2.l: New test. * testsuite/ld-elf/persistent-sections.s: New test. --- binutils/ChangeLog | 5 ++++ binutils/testsuite/lib/binutils-common.exp | 39 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) (limited to 'binutils') diff --git a/binutils/ChangeLog b/binutils/ChangeLog index e03c892..212fd64 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2020-11-27 Jozef Lawrynowicz + + * testsuite/lib/binutils-common.exp (supports_noinit_section): New. + (supports_persistent_section): New. + 2020-11-23 Nick Alcock * readelf.c (dump_section_as_ctf): Call ctf_arc_symsect_endianness. diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp index a43639b..e83d121 100644 --- a/binutils/testsuite/lib/binutils-common.exp +++ b/binutils/testsuite/lib/binutils-common.exp @@ -345,6 +345,45 @@ proc check_relro_support { } { return $relro_available_saved } +# Check for support of the .noinit section, used for data that is not +# initialized at load, or during the application's initialization sequence. +proc supports_noinit_section {} { + # .noinit is only supported by ELF targets. + if { ![is_elf_format] } { + return 0; + } + + # Targets that set HAVE_NOINIT=yes in their emulparams script utilizing + # elf.sc, or explicitly define a .noinit section in their linker script. + # + # arc-*-* is not included here, since it only supports .noinit with the + # non-default arcv2elf emulation. + if {[istarget "arm-*-*"] + || [istarget "avr-*-*"] + || [istarget "msp430-*-*"] + || [istarget "pru-*-*"] } { + return 1; + } + return 0; +} + +# Check for support of the .persistent section, used for data that is +# initialized at load, but not during the application's initialization sequence. +proc supports_persistent_section {} { + # .persistent is only supported by ELF targets. + if { ![is_elf_format] } { + return 0; + } + + # Targets that set HAVE_PERSISTENT=yes in their emulparams script utilizing + # elf.sc, or explicitly define a .persistent section in their linker script. + if { [istarget "arm-*-*"] + || [istarget "msp430-*-*"] } { + return 1; + } + return 0; +} + # Compare two files line-by-line. FILE_1 is the actual output and FILE_2 # is the expected output. Ignore blank lines in either file. # -- cgit v1.1