]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Move BFD_FAKE_SECTION to libbfd.h
authorAlan Modra <amodra@gmail.com>
Mon, 24 Feb 2025 06:27:53 +0000 (16:57 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 3 Mar 2025 21:53:16 +0000 (08:23 +1030)
BFD_FAKE_SECTION and its sidekick GLOBAL_SYM_INIT don't need to be
cluttering bfd.h, and probably shouldn't be used outside bfd/.  To
make them internal to bfd, make the bfd ecoff small common section
declaration global so it can be used instead of a duplicate in
gas/ecoff.c.  Oddly this needs to go in bfd/ecofflink.c rather than
bfd/ecoff.c as the former is compiled for all targets needing the
ecoff small common section (some via a call in gas/config/obj-elf.c to
a function in gas/ecoff.c) while the latter is not.

While doing this rename ecoff_scom_section to _bfd_ecoff_scom_section
and remove support for traditional C from GLOBAL_SYM_INIT.

bfd/bfd-in2.h
bfd/ecoff-bfd.h
bfd/ecoff.c
bfd/ecofflink.c
bfd/libbfd.h
bfd/section.c
gas/ecoff.c

index c29ff2bbc669f61ec6bc0858133593922e88885c..7a8318e19af4f42132aa4fe68c22fcdc9c858053 100644 (file)
@@ -976,57 +976,6 @@ discarded_section (const asection *sec)
          && sec->sec_info_type != SEC_INFO_TYPE_JUST_SYMS);
 }
 
-#define BFD_FAKE_SECTION(SEC, SYM, NAME, IDX, FLAGS)                   \
-  /* name, next, prev, id,  section_id, index, flags, user_set_vma, */ \
-  {  NAME, NULL, NULL, IDX, 0,          0,     FLAGS, 0,               \
-                                                                      \
-  /* linker_mark, linker_has_input, gc_mark, decompress_status,     */ \
-     0,           0,                1,       0,                        \
-                                                                      \
-  /* segment_mark, sec_info_type, use_rela_p, mmapped_p, alloced,   */ \
-     0,            0,             0,          0,         0,            \
-                                                                      \
-  /* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5,    */ \
-     0,        0,        0,        0,        0,        0,              \
-                                                                      \
-  /* vma, lma, size, rawsize, compressed_size,                      */ \
-     0,   0,   0,    0,       0,                                       \
-                                                                      \
-  /* output_offset, output_section, relocation, orelocation,        */ \
-     0,             &SEC,           NULL,       NULL,                  \
-                                                                      \
-  /* reloc_count, alignment_power, filepos, rel_filepos,            */ \
-     0,           0,               0,       0,                         \
-                                                                      \
-  /* line_filepos, userdata, contents, lineno, lineno_count,        */ \
-     0,            NULL,     NULL,     NULL,   0,                      \
-                                                                      \
-  /* entsize, kept_section, moving_line_filepos,                    */ \
-     0,       NULL,         0,                                         \
-                                                                      \
-  /* target_index, used_by_bfd, constructor_chain, owner,           */ \
-     0,            NULL,        NULL,              NULL,               \
-                                                                      \
-  /* symbol,                                                        */ \
-     (struct bfd_symbol *) SYM,                                        \
-                                                                      \
-  /* map_head, map_tail, already_assigned, type                     */ \
-     { NULL }, { NULL }, NULL,             0                           \
-                                                                      \
-    }
-
-/* We use a macro to initialize the static asymbol structures because
-   traditional C does not permit us to initialize a union member while
-   gcc warns if we don't initialize it.
-   the_bfd, name, value, attr, section [, udata]  */
-#ifdef __STDC__
-#define GLOBAL_SYM_INIT(NAME, SECTION) \
-  { 0, NAME, 0, BSF_SECTION_SYM, SECTION, { 0 }}
-#else
-#define GLOBAL_SYM_INIT(NAME, SECTION) \
-  { 0, NAME, 0, BSF_SECTION_SYM, SECTION }
-#endif
-
 void bfd_section_list_clear (bfd *);
 
 asection *bfd_get_section_by_name (bfd *abfd, const char *name);
index a1371fa6f1f8692e840252c94ee193777d376937..cb86960bca5d6d4410814d784e4cae1447225405 100644 (file)
@@ -18,6 +18,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+extern asection _bfd_ecoff_scom_section;
+
 extern bool bfd_ecoff_set_gp_value
   (bfd *abfd, bfd_vma gp_value);
 extern bool bfd_ecoff_set_regmasks
index 361f48879662486dfbfc51fde82561b7a6a962fa..5f9fa43b88f5fedabfab0d8b3c58c5aecb770c8b 100644 (file)
@@ -661,18 +661,6 @@ _bfd_ecoff_slurp_symbolic_info (bfd *abfd,
 /* ECOFF symbol table routines.  The ECOFF symbol table is described
    in gcc/mips-tfile.c.  */
 
-/* ECOFF uses two common sections.  One is the usual one, and the
-   other is for small objects.  All the small objects are kept
-   together, and then referenced via the gp pointer, which yields
-   faster assembler code.  This is what we use for the small common
-   section.  */
-static asection ecoff_scom_section;
-static const asymbol ecoff_scom_symbol =
-  GLOBAL_SYM_INIT (SCOMMON, &ecoff_scom_section);
-static asection ecoff_scom_section =
-  BFD_FAKE_SECTION (ecoff_scom_section, &ecoff_scom_symbol,
-                   SCOMMON, 0, SEC_IS_COMMON | SEC_SMALL_DATA);
-
 /* Create an empty symbol.  */
 
 asymbol *
@@ -813,7 +801,7 @@ ecoff_set_symbol_info (bfd *abfd,
        }
       /* Fall through.  */
     case scSCommon:
-      asym->section = &ecoff_scom_section;
+      asym->section = &_bfd_ecoff_scom_section;
       asym->flags = 0;
       break;
     case scVarRegister:
@@ -3441,7 +3429,7 @@ ecoff_link_add_externals (bfd *abfd,
            }
          /* Fall through.  */
        case scSCommon:
-         section = &ecoff_scom_section;
+         section = &_bfd_ecoff_scom_section;
          break;
        case scSUndefined:
          section = bfd_und_section_ptr;
index c1934919f81cd95fc58c4b71df1893407a949349..ce1bd41b0fb1c6b58d5541022d83f889ac4089be 100644 (file)
 #include "coff/ecoff.h"
 #include "libcoff.h"
 #include "libecoff.h"
-\f
+
+/* ECOFF uses two common sections.  One is the usual one, and the
+   other is for small objects.  All the small objects are kept
+   together, and then referenced via the gp pointer, which yields
+   faster assembler code.  This is what we use for the small common
+   section.  */
+static const asymbol ecoff_scom_symbol =
+  GLOBAL_SYM_INIT (SCOMMON, &_bfd_ecoff_scom_section);
+asection _bfd_ecoff_scom_section =
+  BFD_FAKE_SECTION (_bfd_ecoff_scom_section, &ecoff_scom_symbol,
+                   SCOMMON, 0, SEC_IS_COMMON | SEC_SMALL_DATA);
+
 /* Routines to swap auxiliary information in and out.  I am assuming
    that the auxiliary information format is always going to be target
    independent.  */
index 86f220380a8fa4cc752bfad4e3000c8b0c899713..4f6f5ea2f8ae385073714172675c7e7fde874cc4 100644 (file)
@@ -3668,6 +3668,49 @@ bool _bfd_unrecognized_reloc
     unsigned int r_type) ATTRIBUTE_HIDDEN;
 
 /* Extracted from section.c.  */
+#define BFD_FAKE_SECTION(SEC, SYM, NAME, IDX, FLAGS)                   \
+  /* name, next, prev, id,  section_id, index, flags, user_set_vma, */ \
+  {  NAME, NULL, NULL, IDX, 0,          0,     FLAGS, 0,               \
+                                                                      \
+  /* linker_mark, linker_has_input, gc_mark, decompress_status,     */ \
+     0,           0,                1,       0,                        \
+                                                                      \
+  /* segment_mark, sec_info_type, use_rela_p, mmapped_p, alloced,   */ \
+     0,            0,             0,          0,         0,            \
+                                                                      \
+  /* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5,    */ \
+     0,        0,        0,        0,        0,        0,              \
+                                                                      \
+  /* vma, lma, size, rawsize, compressed_size,                      */ \
+     0,   0,   0,    0,       0,                                       \
+                                                                      \
+  /* output_offset, output_section, relocation, orelocation,        */ \
+     0,             &SEC,           NULL,       NULL,                  \
+                                                                      \
+  /* reloc_count, alignment_power, filepos, rel_filepos,            */ \
+     0,           0,               0,       0,                         \
+                                                                      \
+  /* line_filepos, userdata, contents, lineno, lineno_count,        */ \
+     0,            NULL,     NULL,     NULL,   0,                      \
+                                                                      \
+  /* entsize, kept_section, moving_line_filepos,                    */ \
+     0,       NULL,         0,                                         \
+                                                                      \
+  /* target_index, used_by_bfd, constructor_chain, owner,           */ \
+     0,            NULL,        NULL,              NULL,               \
+                                                                      \
+  /* symbol,                                                        */ \
+     (struct bfd_symbol *) SYM,                                        \
+                                                                      \
+  /* map_head, map_tail, already_assigned, type                     */ \
+     { NULL }, { NULL }, NULL,             0                           \
+                                                                      \
+  }
+
+#define GLOBAL_SYM_INIT(NAME, SECTION)                                 \
+  /* the_bfd, name, value, attr,            section, udata  */         \
+  {  0,       NAME, 0,     BSF_SECTION_SYM, SECTION, { 0 } }
+
 /* Extracted from stabs.c.  */
 bool _bfd_link_section_stabs
    (bfd *, struct stab_info *, asection *, asection *, void **,
index b1f7564d190d3de147eefcabf976d2a0e2b98673..9460ff916b93f902960a031fb22070c93a02fb23 100644 (file)
@@ -712,6 +712,7 @@ EXTERNAL
 .          && sec->sec_info_type != SEC_INFO_TYPE_JUST_SYMS);
 .}
 .
+INTERNAL
 .#define BFD_FAKE_SECTION(SEC, SYM, NAME, IDX, FLAGS)                  \
 .  {* name, next, prev, id,  section_id, index, flags, user_set_vma, *}        \
 .  {  NAME, NULL, NULL, IDX, 0,          0,     FLAGS, 0,              \
@@ -749,19 +750,11 @@ EXTERNAL
 .  {* map_head, map_tail, already_assigned, type                     *}        \
 .     { NULL }, { NULL }, NULL,             0                          \
 .                                                                      \
-.    }
-.
-.{* We use a macro to initialize the static asymbol structures because
-.   traditional C does not permit us to initialize a union member while
-.   gcc warns if we don't initialize it.
-.   the_bfd, name, value, attr, section [, udata]  *}
-.#ifdef __STDC__
-.#define GLOBAL_SYM_INIT(NAME, SECTION) \
-.  { 0, NAME, 0, BSF_SECTION_SYM, SECTION, { 0 }}
-.#else
-.#define GLOBAL_SYM_INIT(NAME, SECTION) \
-.  { 0, NAME, 0, BSF_SECTION_SYM, SECTION }
-.#endif
+.  }
+.
+.#define GLOBAL_SYM_INIT(NAME, SECTION)                                        \
+.  {* the_bfd, name, value, attr,            section, udata  *}                \
+.  {  0,       NAME, 0,     BSF_SECTION_SYM, SECTION, { 0 } }
 .
 */
 
index b8c9019f2b2de8766a92680b00a8dd0e3771276c..f665f1158a44a8a85e2baeaad049489429825101 100644 (file)
@@ -36,6 +36,7 @@
 #include "aout/stab_gnu.h"
 #include "filenames.h"
 #include "safe-ctype.h"
+#include "ecoff-bfd.h"
 
 /* Why isn't this in coff/sym.h?  */
 #define ST_RFDESCAPE 0xfff
@@ -3549,13 +3550,6 @@ ecoff_stab (int what,
   cur_file_ptr = save_file_ptr;
 }
 \f
-static asection ecoff_scom_section;
-static const asymbol ecoff_scom_symbol =
-  GLOBAL_SYM_INIT (SCOMMON, &ecoff_scom_section);
-static asection ecoff_scom_section =
-  BFD_FAKE_SECTION (ecoff_scom_section, &ecoff_scom_symbol,
-                   SCOMMON, 0, SEC_IS_COMMON | SEC_SMALL_DATA);
-
 /* Frob an ECOFF symbol.  Small common symbols go into a special
    .scommon section rather than bfd_com_section.  */
 
@@ -3566,7 +3560,7 @@ ecoff_frob_symbol (symbolS *sym)
       && S_GET_VALUE (sym) > 0
       && S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput))
     {
-      S_SET_SEGMENT (sym, &ecoff_scom_section);
+      S_SET_SEGMENT (sym, &_bfd_ecoff_scom_section);
     }
 
   /* Double check weak symbols.  */