PR23570, AVR .noinit section defaults to PROGBITS
authorAlan Modra <amodra@gmail.com>
Tue, 4 Sep 2018 00:43:26 +0000 (10:13 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 6 Sep 2018 04:43:00 +0000 (14:13 +0930)
Revert commit 8744470deab and instead use the standard special_sections
support.

PR 23570
bfd/
* elf32-avr.c (elf_avr_special_sections): New.
(elf_backend_special_sections): Define.
gas/
* config/tc-avr.c: Revert 2018-09-03 change.

bfd/ChangeLog
bfd/elf32-avr.c
gas/ChangeLog
gas/config/tc-avr.c

index bc1cb15..a499105 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-06  Alan Modra  <amodra@gmail.com>
+
+       PR 23570
+       * elf32-avr.c (elf_avr_special_sections): New.
+       (elf_backend_special_sections): Define.
+
 2018-09-04  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
        * elfxx-sparc.c (_bfd_sparc_elf_info_to_howto): Do not issue an
index 6d38d1d..13e28d8 100644 (file)
@@ -708,6 +708,12 @@ static const struct avr_reloc_map avr_reloc_map[] =
   { BFD_RELOC_32_PCREL,                    R_AVR_32_PCREL}
 };
 
+static const struct bfd_elf_special_section elf_avr_special_sections[] =
+{
+  { STRING_COMMA_LEN (".noinit"), 0, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE },
+  { NULL, 0,                     0, 0,            0 }
+};
+
 /* Meant to be filled one day with the wrap around address for the
    specific device.  I.e. should get the value 0x4000 for 16k devices,
    0x8000 for 32k devices and so on.
@@ -4256,5 +4262,6 @@ avr_elf32_property_record_name (struct avr_property_record *rec)
 #define bfd_elf32_bfd_get_relocated_section_contents \
                                        elf32_avr_get_relocated_section_contents
 #define bfd_elf32_new_section_hook     elf_avr_new_section_hook
+#define elf_backend_special_sections   elf_avr_special_sections
 
 #include "elf32-target.h"
index 6d55671..310bf6e 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-06  Alan Modra  <amodra@gmail.com>
+
+       PR 23570
+       * config/tc-avr.c: Revert 2018-09-03 change.
+
 2018-09-04  Daniel Cederman  <cederman@gaisler.com>
 
        * config/tc-sparc.c (md_assemble): Allow non-fpop2 instructions
index edf60f4..d628c95 100644 (file)
@@ -481,13 +481,11 @@ const char EXP_CHARS[] = "eE";
 const char FLT_CHARS[] = "dD";
 
 static void avr_set_arch (int);
-static void avr_set_section (int);
 
 /* The target specific pseudo-ops which we support.  */
 const pseudo_typeS md_pseudo_table[] =
 {
   {"arch", avr_set_arch,       0},
-  {"section", avr_set_section,  0},
   { NULL,      NULL,           0}
 };
 
@@ -704,23 +702,6 @@ avr_set_arch (int dummy ATTRIBUTE_UNUSED)
   bfd_set_arch_mach (stdoutput, TARGET_ARCH, avr_mcu->mach);
 }
 
-static void
-avr_set_section (int push)
-{
-  obj_elf_section (push);
-
-  /* PR 23570.  The .noinit section needs to be explicitly
-     set to the NOBITS type.  */
-  if (seg_info (now_seg)->bss == 0
-      && strcmp (bfd_get_section_name (stdoutput, now_seg), ".noinit") == 0)
-    {
-      bfd_set_section_flags (stdoutput, now_seg, SEC_ALLOC | SEC_RELOC);
-      seg_info (now_seg)->bss = 1;
-      elf_section_type (now_seg) = SHT_NOBITS;
-      elf_section_flags (now_seg) = SHF_ALLOC | SHF_WRITE;
-    }
-}
-
 int
 md_parse_option (int c, const char *arg)
 {