This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Change the .section directive for the AVR assembler so that the .noinit section is always given the


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8744470deabb6a2fae35be0f66c60ee4ba094c1d

commit 8744470deabb6a2fae35be0f66c60ee4ba094c1d
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Sep 3 17:06:05 2018 +0100

    Change the .section directive for the AVR assembler so that the .noinit section is always given the ELF NOBITS section type.
    
    	PR gas/23570
    	* config/tc-avr.c (md_pseudo_table): Add entry for "secction".
    	(avr_set_section): New function.  Ensures that the .noinit section
    	gets the NOBITS ELF section type.

Diff:
---
 gas/ChangeLog       |  7 +++++++
 gas/config/tc-avr.c | 19 +++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 56aae60..07ab7c7 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,10 @@
+2018-09-03  Nick Clifton  <nickc@redhat.com>
+
+	PR gas/23570
+	* config/tc-avr.c (md_pseudo_table): Add entry for "secction".
+	(avr_set_section): New function.  Ensures that the .noinit section
+	gets the NOBITS ELF section type.
+
 2018-08-31  Kito Cheng  <kito@andestech.com>
 
 	* testsuite/gas/riscv/c-fld-fsd-fail.d: New.
diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
index d628c95..edf60f4 100644
--- a/gas/config/tc-avr.c
+++ b/gas/config/tc-avr.c
@@ -481,11 +481,13 @@ 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}
 };
 
@@ -702,6 +704,23 @@ 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)
 {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]