miscellaneous SEC_SMALL_DATA
authorAlan Modra <amodra@gmail.com>
Sun, 1 Mar 2020 23:47:18 +0000 (10:17 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 2 Mar 2020 01:06:19 +0000 (11:36 +1030)
This patch arranges for symbols defined in .sdata and .sbss to be
reported by nm with 'g' and 's' flags, for coff targets that support
.sdata and .sbss.

The assembler changes regarding SEC_SMALL_DATA are really just
documentation.  As far as I'm aware, this won't change any assembler
output.

bfd/
* coff-alpha.c (alpha_ecoff_le_vec): Add SEC_SMALL_DATA to
applicable section flags.
* coff-mips.c (mips_ecoff_le_vec, mips_ecoff_be_vec): Likewise.
(mips_ecoff_bele_vec): Likewise.
* coffcode.h (sec_to_styp_flags): Set SEC_SMALL_DATA for .sdata
and .sbss sections.
* ecoff.c (_bfd_ecoff_new_section_hook): Likewise.
(_bfd_ecoff_styp_to_sec_flags): Likewise.
gas/
* config/tc-m32r.c (md_begin): Set SEC_SMALL_DATA on .scommon section.
* config/tc-mips.c (s_change_sec): Set SEC_SMALL_DATA for .sdata
and .sbss sections.
* config/tc-score.c: Delete !BFD_ASSEMBLER code throughout.
(s3_s_change_sec): Set SEC_SMALL_DATA for .sbss section.
(s3_s_score_lcomm): Likewise.
* config/tc-score7.c: Similarly.
* read.c (bss_alloc): Set SEC_SMALL_DATA for .sbss section.

bfd/ChangeLog
bfd/coff-alpha.c
bfd/coff-mips.c
bfd/coffcode.h
bfd/ecoff.c
gas/ChangeLog
gas/config/tc-m32r.c
gas/config/tc-mips.c
gas/config/tc-score.c
gas/config/tc-score7.c
gas/read.c

index 304efd06877d9f953e6715a3e431955bdade87c1..116b89397da610abcf8b7e9d7fd1ce2b9548a333 100644 (file)
@@ -1,3 +1,14 @@
+2020-03-02  Alan Modra  <amodra@gmail.com>
+
+       * coff-alpha.c (alpha_ecoff_le_vec): Add SEC_SMALL_DATA to
+       applicable section flags.
+       * coff-mips.c (mips_ecoff_le_vec, mips_ecoff_be_vec): Likewise.
+       (mips_ecoff_bele_vec): Likewise.
+       * coffcode.h (sec_to_styp_flags): Set SEC_SMALL_DATA for .sdata
+       and .sbss sections.
+       * ecoff.c (_bfd_ecoff_new_section_hook): Likewise.
+       (_bfd_ecoff_styp_to_sec_flags): Likewise.
+
 2020-03-02  Alan Modra  <amodra@gmail.com>
 
        * elf32-m32r.c (m32r_elf_section_flags): New function.
index 9a3ac089a672a6214b274835c22171182265477a..821e5591a9a9562746abf654dafb40dfada6e477 100644 (file)
@@ -2424,7 +2424,8 @@ const bfd_target alpha_ecoff_le_vec =
    | HAS_LINENO | HAS_DEBUG
    | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
 
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE
+   | SEC_DATA | SEC_SMALL_DATA),
   0,                           /* leading underscore */
   ' ',                         /* ar_pad_char */
   15,                          /* ar_max_namelen */
index 7c0a99194a48c2f82158ee0546651ea354bac645..772175325c919163f3e07b5d0d8ead61485be8cd 100644 (file)
@@ -1440,7 +1440,8 @@ const bfd_target mips_ecoff_le_vec =
    | HAS_LINENO | HAS_DEBUG
    | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
 
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE
+   | SEC_DATA | SEC_SMALL_DATA),
   0,                           /* leading underscore */
   ' ',                         /* ar_pad_char */
   15,                          /* ar_max_namelen */
@@ -1497,7 +1498,8 @@ const bfd_target mips_ecoff_be_vec =
    | HAS_LINENO | HAS_DEBUG
    | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
 
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE
+   | SEC_DATA | SEC_SMALL_DATA),
   0,                           /* leading underscore */
   ' ',                         /* ar_pad_char */
   15,                          /* ar_max_namelen */
@@ -1554,7 +1556,8 @@ const bfd_target mips_ecoff_bele_vec =
    | HAS_LINENO | HAS_DEBUG
    | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
 
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE
+   | SEC_DATA | SEC_SMALL_DATA),
   0,                           /* leading underscore */
   ' ',                         /* ar_pad_char */
   15,                          /* ar_max_namelen */
index cd495dbe6185f933e87ce63e0feb9677fcae98ba..27158a061ccda66629bf1c8eca9cc23dfe6b7e8b 100644 (file)
@@ -717,7 +717,7 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags)
 #ifndef COFF_WITH_PE
 
 static bfd_boolean
-styp_to_sec_flags (bfd *abfd ATTRIBUTE_UNUSED,
+styp_to_sec_flags (bfd *abfd,
                   void * hdr,
                   const char *name,
                   asection *section ATTRIBUTE_UNUSED,
@@ -850,6 +850,11 @@ styp_to_sec_flags (bfd *abfd ATTRIBUTE_UNUSED,
     sec_flags = (SEC_LOAD | SEC_ALLOC);
 #endif /* STYP_SDATA */
 
+  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
+      && (CONST_STRNEQ (name, ".sbss")
+         || CONST_STRNEQ (name, ".sdata")))
+    sec_flags |= SEC_SMALL_DATA;
+
 #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
   /* As a GNU extension, if the name begins with .gnu.linkonce, we
      only link a single copy of the section.  This is used to support
@@ -1312,6 +1317,11 @@ styp_to_sec_flags (bfd *abfd,
        }
     }
 
+  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
+      && (CONST_STRNEQ (name, ".sbss")
+         || CONST_STRNEQ (name, ".sdata")))
+    sec_flags |= SEC_SMALL_DATA;
+
 #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
   /* As a GNU extension, if the name begins with .gnu.linkonce, we
      only link a single copy of the section.  This is used to support
index 9e2efac8e3a36abeb6d0b1b53a6c9ba17b727c60..84eab99398339fa31aae67b68753ce184a212627 100644 (file)
@@ -156,14 +156,14 @@ _bfd_ecoff_new_section_hook (bfd *abfd, asection *section)
     { _INIT,   SEC_ALLOC | SEC_CODE | SEC_LOAD },
     { _FINI,   SEC_ALLOC | SEC_CODE | SEC_LOAD },
     { _DATA,   SEC_ALLOC | SEC_DATA | SEC_LOAD },
-    { _SDATA,  SEC_ALLOC | SEC_DATA | SEC_LOAD },
+    { _SDATA,  SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_SMALL_DATA },
     { _RDATA,  SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY},
-    { _LIT8,   SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY},
-    { _LIT4,   SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY},
+    { _LIT8,   SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY | SEC_SMALL_DATA},
+    { _LIT4,   SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY | SEC_SMALL_DATA},
     { _RCONST, SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY},
     { _PDATA,  SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY},
     { _BSS,    SEC_ALLOC},
-    { _SBSS,   SEC_ALLOC},
+    { _SBSS,   SEC_ALLOC | SEC_SMALL_DATA},
     /* An Irix 4 shared libary.  */
     { _LIB,    SEC_COFF_SHARED_LIBRARY}
   };
@@ -412,16 +412,19 @@ _bfd_ecoff_styp_to_sec_flags (bfd *abfd ATTRIBUTE_UNUSED,
          || styp_flags == STYP_PDATA
          || styp_flags == STYP_RCONST)
        sec_flags |= SEC_READONLY;
+      if (styp_flags & STYP_SDATA)
+       sec_flags |= SEC_SMALL_DATA;
     }
-  else if ((styp_flags & STYP_BSS)
-          || (styp_flags & STYP_SBSS))
+  else if (styp_flags & STYP_SBSS)
+    sec_flags |= SEC_ALLOC | SEC_SMALL_DATA;
+  else if (styp_flags & STYP_BSS)
     sec_flags |= SEC_ALLOC;
   else if ((styp_flags & STYP_INFO) || styp_flags == STYP_COMMENT)
     sec_flags |= SEC_NEVER_LOAD;
   else if ((styp_flags & STYP_LITA)
           || (styp_flags & STYP_LIT8)
           || (styp_flags & STYP_LIT4))
-    sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY;
+    sec_flags |= SEC_DATA |SEC_SMALL_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY;
   else if (styp_flags & STYP_ECOFF_LIB)
     sec_flags |= SEC_COFF_SHARED_LIBRARY;
   else
index d146fe321e7302f772e79e3bbfca29a27756c210..f7011e25246f25f3f3858dc92cd2a8da4b75896a 100644 (file)
@@ -1,3 +1,14 @@
+2020-03-02  Alan Modra  <amodra@gmail.com>
+
+       * config/tc-m32r.c (md_begin): Set SEC_SMALL_DATA on .scommon section.
+       * config/tc-mips.c (s_change_sec): Set SEC_SMALL_DATA for .sdata
+       and .sbss sections.
+       * config/tc-score.c: Delete !BFD_ASSEMBLER code throughout.
+       (s3_s_change_sec): Set SEC_SMALL_DATA for .sbss section.
+       (s3_s_score_lcomm): Likewise.
+       * config/tc-score7.c: Similarly.
+       * read.c (bss_alloc): Set SEC_SMALL_DATA for .sbss section.
+
 2020-02-28  YunQiang Su  <syq@debian.org>
 
        PR gas/25539
index bee0571e21f96588af64ef9042ed2ee20431bd2e..824f67c124b2247d223852445608dd5aacb88994 100644 (file)
@@ -713,7 +713,8 @@ md_begin (void)
 
   /* This is copied from perform_an_assembly_pass.  */
   applicable = bfd_applicable_section_flags (stdoutput);
-  bfd_set_section_flags (sbss_section, applicable & SEC_ALLOC);
+  bfd_set_section_flags (sbss_section,
+                        applicable & (SEC_ALLOC | SEC_SMALL_DATA));
 
   subseg_set (seg, subseg);
 
@@ -721,6 +722,7 @@ md_begin (void)
      but with the name .scommon.  */
   scom_section                = *bfd_com_section_ptr;
   scom_section.name           = ".scommon";
+  scom_section.flags          = SEC_IS_COMMON | SEC_SMALL_DATA;
   scom_section.output_section = & scom_section;
   scom_section.symbol         = & scom_symbol;
   scom_section.symbol_ptr_ptr = & scom_section.symbol;
index a00c69b689574f58ac96e6b16eb2f9b28315b3be..9f78b5a89eeaed5042fb823d196fcb9af02e38b6 100644 (file)
@@ -16365,8 +16365,8 @@ s_change_sec (int sec)
 
     case 's':
       seg = subseg_new (".sdata", (subsegT) get_absolute_expression ());
-      bfd_set_section_flags (seg,
-                            SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA);
+      bfd_set_section_flags (seg, (SEC_ALLOC | SEC_LOAD | SEC_RELOC
+                                  | SEC_DATA | SEC_SMALL_DATA));
       if (strncmp (TARGET_OS, "elf", 3) != 0)
        record_alignment (seg, 4);
       demand_empty_rest_of_line ();
@@ -16374,7 +16374,7 @@ s_change_sec (int sec)
 
     case 'B':
       seg = subseg_new (".sbss", (subsegT) get_absolute_expression ());
-      bfd_set_section_flags (seg, SEC_ALLOC);
+      bfd_set_section_flags (seg, SEC_ALLOC | SEC_SMALL_DATA);
       if (strncmp (TARGET_OS, "elf", 3) != 0)
        record_alignment (seg, 4);
       demand_empty_rest_of_line ();
index 8376d0beb4f9e69abdb32f57a9cc1d9af8ee8855..80c4cbfa4eb6d577addeca4dfaf0687e8ee367b8 100644 (file)
@@ -5569,14 +5569,16 @@ s3_s_change_sec (int sec)
     {
     case 'r':
       seg = subseg_new (s3_RDATA_SECTION_NAME, (subsegT) get_absolute_expression ());
-      bfd_set_section_flags (seg, (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_RELOC | SEC_DATA));
+      bfd_set_section_flags (seg, (SEC_ALLOC | SEC_LOAD | SEC_READONLY
+                                  | SEC_RELOC | SEC_DATA));
       if (strcmp (TARGET_OS, "elf") != 0)
         record_alignment (seg, 4);
       demand_empty_rest_of_line ();
       break;
     case 's':
       seg = subseg_new (".sdata", (subsegT) get_absolute_expression ());
-      bfd_set_section_flags (seg, SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA);
+      bfd_set_section_flags (seg, (SEC_ALLOC | SEC_LOAD | SEC_RELOC
+                                  | SEC_DATA | SEC_SMALL_DATA));
       if (strcmp (TARGET_OS, "elf") != 0)
         record_alignment (seg, 4);
       demand_empty_rest_of_line ();
@@ -5685,17 +5687,10 @@ s3_s_score_ent (int aent)
   if (ISDIGIT (*input_line_pointer) || *input_line_pointer == '-')
     s3_get_number ();
 
-#ifdef BFD_ASSEMBLER
   if ((bfd_section_flags (now_seg) & SEC_CODE) != 0)
     maybe_text = 1;
   else
     maybe_text = 0;
-#else
-  if (now_seg != data_section && now_seg != bss_section)
-    maybe_text = 1;
-  else
-    maybe_text = 0;
-#endif
   if (!maybe_text)
     as_warn (_(".ent or .aent not in text section."));
   if (!aent && s3_cur_proc_ptr)
@@ -5794,17 +5789,10 @@ s3_s_score_end (int x ATTRIBUTE_UNUSED)
   else
     p = NULL;
 
-#ifdef BFD_ASSEMBLER
   if ((bfd_section_flags (now_seg) & SEC_CODE) != 0)
     maybe_text = 1;
   else
     maybe_text = 0;
-#else
-  if (now_seg != data_section && now_seg != bss_section)
-    maybe_text = 1;
-  else
-    maybe_text = 0;
-#endif
 
   if (!maybe_text)
     as_warn (_(".end not in text section"));
@@ -6132,11 +6120,9 @@ s3_s_score_lcomm (int bytes_p)
        {
          bss_seg = subseg_new (".sbss", 1);
          seg_info (bss_seg)->bss = 1;
-#ifdef BFD_ASSEMBLER
-         if (!bfd_set_section_flags (bss_seg, SEC_ALLOC))
+         if (!bfd_set_section_flags (bss_seg, SEC_ALLOC | SEC_SMALL_DATA))
            as_warn (_("error setting flags for \".sbss\": %s"),
                     bfd_errmsg (bfd_get_error ()));
-#endif
        }
     }
 #endif
@@ -6215,12 +6201,8 @@ s3_s_score_lcomm (int bytes_p)
 
   if (
 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
-#ifdef BFD_ASSEMBLER
       (OUTPUT_FLAVOR != bfd_target_aout_flavour
        || (S_GET_OTHER (symbolP) == 0 && S_GET_DESC (symbolP) == 0)) &&
-#else
-      (S_GET_OTHER (symbolP) == 0 && S_GET_DESC (symbolP) == 0) &&
-#endif
 #endif
       (S_GET_SEGMENT (symbolP) == bss_seg || (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0)))
     {
index 3b49f87cf2f38d49b92571e3ecd68f782d02b16f..c3b6e97d34ea8b79a1a95e086b3837c2ee558aff 100644 (file)
@@ -5422,14 +5422,16 @@ s7_s_change_sec (int sec)
     {
     case 'r':
       seg = subseg_new (s7_RDATA_SECTION_NAME, (subsegT) get_absolute_expression ());
-      bfd_set_section_flags (seg, (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_RELOC | SEC_DATA));
+      bfd_set_section_flags (seg, (SEC_ALLOC | SEC_LOAD | SEC_READONLY
+                                  | SEC_RELOC | SEC_DATA));
       if (strcmp (TARGET_OS, "elf") != 0)
         record_alignment (seg, 4);
       demand_empty_rest_of_line ();
       break;
     case 's':
       seg = subseg_new (".sdata", (subsegT) get_absolute_expression ());
-      bfd_set_section_flags (seg, SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA);
+      bfd_set_section_flags (seg, (SEC_ALLOC | SEC_LOAD | SEC_RELOC
+                                  | SEC_DATA | SEC_SMALL_DATA));
       if (strcmp (TARGET_OS, "elf") != 0)
         record_alignment (seg, 4);
       demand_empty_rest_of_line ();
@@ -5539,17 +5541,10 @@ s7_s_score_ent (int aent)
   if (ISDIGIT (*input_line_pointer) || *input_line_pointer == '-')
     s7_get_number ();
 
-#ifdef BFD_ASSEMBLER
   if ((bfd_section_flags (now_seg) & SEC_CODE) != 0)
     maybe_text = 1;
   else
     maybe_text = 0;
-#else
-  if (now_seg != data_section && now_seg != bss_section)
-    maybe_text = 1;
-  else
-    maybe_text = 0;
-#endif
   if (!maybe_text)
     as_warn (_(".ent or .aent not in text section."));
   if (!aent && s7_cur_proc_ptr)
@@ -5649,17 +5644,10 @@ s7_s_score_end (int x ATTRIBUTE_UNUSED)
   else
     p = NULL;
 
-#ifdef BFD_ASSEMBLER
   if ((bfd_section_flags (now_seg) & SEC_CODE) != 0)
     maybe_text = 1;
   else
     maybe_text = 0;
-#else
-  if (now_seg != data_section && now_seg != bss_section)
-    maybe_text = 1;
-  else
-    maybe_text = 0;
-#endif
 
   if (!maybe_text)
     as_warn (_(".end not in text section"));
@@ -5989,14 +5977,13 @@ s7_s_score_lcomm (int bytes_p)
     {
       /* For Score and Alpha ECOFF or ELF, small objects are put in .sbss.  */
       if ((unsigned) temp <= bfd_get_gp_size (stdoutput))
-        {
-          bss_seg = subseg_new (".sbss", 1);
-          seg_info (bss_seg)->bss = 1;
-#ifdef BFD_ASSEMBLER
-          if (!bfd_set_section_flags (bss_seg, SEC_ALLOC))
-            as_warn (_("error setting flags for \".sbss\": %s"), bfd_errmsg (bfd_get_error ()));
-#endif
-        }
+       {
+         bss_seg = subseg_new (".sbss", 1);
+         seg_info (bss_seg)->bss = 1;
+         if (!bfd_set_section_flags (bss_seg, SEC_ALLOC | SEC_SMALL_DATA))
+           as_warn (_("error setting flags for \".sbss\": %s"),
+                    bfd_errmsg (bfd_get_error ()));
+       }
     }
 #endif
 
@@ -6074,12 +6061,8 @@ s7_s_score_lcomm (int bytes_p)
 
   if (
 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
-#ifdef BFD_ASSEMBLER
        (OUTPUT_FLAVOR != bfd_target_aout_flavour
         || (S_GET_OTHER (symbolP) == 0 && S_GET_DESC (symbolP) == 0)) &&
-#else
-       (S_GET_OTHER (symbolP) == 0 && S_GET_DESC (symbolP) == 0) &&
-#endif
 #endif
        (S_GET_SEGMENT (symbolP) == bss_seg || (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0)))
     {
index 784d6a8f79e6a99f9ea17ebe82d62401eb00d22f..cdb4b3a8189eb38b0a47fd3d8699e4ed56167af9 100644 (file)
@@ -2465,7 +2465,7 @@ bss_alloc (symbolS *symbolP, addressT size, unsigned int align)
        {
          bss_seg = subseg_new (".sbss", 1);
          seg_info (bss_seg)->bss = 1;
-         if (!bfd_set_section_flags (bss_seg, SEC_ALLOC))
+         if (!bfd_set_section_flags (bss_seg, SEC_ALLOC | SEC_SMALL_DATA))
            as_warn (_("error setting flags for \".sbss\": %s"),
                     bfd_errmsg (bfd_get_error ()));
        }
This page took 0.041779 seconds and 4 git commands to generate.