]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: hide emulation struct format_ops instances when not needed
authorJan Beulich <jbeulich@suse.com>
Fri, 4 Oct 2024 07:42:45 +0000 (09:42 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 4 Oct 2024 07:42:45 +0000 (09:42 +0200)
Most targets don't even support emulations, so this data (and certain
functions) are entirely dead code for them.

gas/config/obj-aout.c
gas/config/obj-aout.h
gas/config/obj-coff.c
gas/config/obj-coff.h
gas/config/obj-ecoff.c
gas/config/obj-elf.c
gas/config/obj-elf.h

index 8916443482046be18439864e7e77b92f46725362..523740049ae0fd1d837442fc0fa1301f3a641a17 100644 (file)
@@ -221,14 +221,16 @@ obj_aout_type (int ignore ATTRIBUTE_UNUSED)
   s_ignore (0);
 }
 
-/* Support for an AOUT emulation.  */
+static const pseudo_typeS aout_pseudo_table[];
 
-static void
+void
 aout_pop_insert (void)
 {
   pop_insert (aout_pseudo_table);
 }
 
+#ifdef USE_EMULATIONS /* Support for an AOUT emulation.  */
+
 static int
 obj_aout_s_get_other (symbolS *sym)
 {
@@ -327,7 +329,9 @@ const struct format_ops aout_format_ops =
   0    /* adjust_symtab.  */
 };
 
-const pseudo_typeS aout_pseudo_table[] =
+#endif /* USE_EMULATIONS */
+
+static const pseudo_typeS aout_pseudo_table[] =
 {
   {"line", obj_aout_line, 0},  /* Source code line number.  */
   {"ln", obj_aout_line, 0},    /* COFF line number that we use anyway.  */
index 9f5e7ddb81aba4709c48b84664e698505aa8e5a1..dd25d147026004b2b60db0d894e3c5cd74fc549b 100644 (file)
 
 #define OUTPUT_FLAVOR bfd_target_aout_flavour
 
-extern const pseudo_typeS aout_pseudo_table[];
-
+extern void aout_pop_insert (void);
 #ifndef obj_pop_insert
-#define obj_pop_insert() pop_insert (aout_pseudo_table)
+#define obj_pop_insert() aout_pop_insert ()
 #endif
 
 /* Symbol table entry data type.  */
index 4f5973a18c9611f537d978d4805535068fdde0b4..845fcc89441540230de5a1e317fe9110cbddf1a7 100644 (file)
@@ -1856,7 +1856,7 @@ symbol_dump (void)
 
 #endif /* DEBUG */
 
-const pseudo_typeS coff_pseudo_table[] =
+static const pseudo_typeS coff_pseudo_table[] =
 {
   {"ABORT", s_abort, 0},
   /* We accept the .bss directive for backward compatibility with
@@ -1897,14 +1897,14 @@ const pseudo_typeS coff_pseudo_table[] =
 };
 \f
 
-/* Support for a COFF emulation.  */
-
-static void
+void
 coff_pop_insert (void)
 {
   pop_insert (coff_pseudo_table);
 }
 
+#ifdef USE_EMULATIONS /* Support for a COFF emulation.  */
+
 static int
 coff_separate_stab_sections (void)
 {
@@ -1947,3 +1947,5 @@ const struct format_ops coff_format_ops =
   coff_obj_symbol_clone_hook,
   coff_adjust_symtab
 };
+
+#endif /* USE_EMULATIONS */
index 277d02599e8a56ce3256354fa740f8751b3e2a65..23f54ff65861523f48254c04ef81da0ef43ea2c3 100644 (file)
@@ -270,12 +270,9 @@ extern symbolS *coff_last_function;
 #endif
 #endif
 
-/* Sanity check.  */
-
-extern const pseudo_typeS coff_pseudo_table[];
-
+extern void coff_pop_insert (void);
 #ifndef obj_pop_insert
-#define obj_pop_insert() pop_insert (coff_pseudo_table)
+#define obj_pop_insert() coff_pop_insert ()
 #endif
 
 /* In COFF, if a symbol is defined using .def/.val SYM/.endef, it's OK
index 7ef9bb4b7786d1d4bb7e3de52839cd2c8fa74bb2..c79d57d6f63b17ea0a0ba076e9510857ed519646 100644 (file)
@@ -195,30 +195,6 @@ obj_ecoff_set_ext (symbolS *sym, EXTR *ext)
   (*debug_swap->swap_ext_out) (stdoutput, ext, esym->native);
 }
 
-static int
-ecoff_sec_sym_ok_for_reloc (asection *sec ATTRIBUTE_UNUSED)
-{
-  return 1;
-}
-
-static void
-obj_ecoff_frob_symbol (symbolS *sym, int *puntp ATTRIBUTE_UNUSED)
-{
-  ecoff_frob_symbol (sym);
-}
-
-static void
-ecoff_pop_insert (void)
-{
-  pop_insert (obj_pseudo_table);
-}
-
-static int
-ecoff_separate_stab_sections (void)
-{
-  return 0;
-}
-
 /* These are the pseudo-ops we support in this file.  Only those
    relating to debugging information are supported here.
 
@@ -282,6 +258,32 @@ const pseudo_typeS obj_pseudo_table[] =
   { NULL,      s_ignore,               0 }
 };
 
+#ifdef USE_EMULATIONS
+
+static int
+ecoff_sec_sym_ok_for_reloc (asection *sec ATTRIBUTE_UNUSED)
+{
+  return 1;
+}
+
+static void
+obj_ecoff_frob_symbol (symbolS *sym, int *puntp ATTRIBUTE_UNUSED)
+{
+  ecoff_frob_symbol (sym);
+}
+
+static void
+ecoff_pop_insert (void)
+{
+  pop_insert (obj_pseudo_table);
+}
+
+static int
+ecoff_separate_stab_sections (void)
+{
+  return 0;
+}
+
 const struct format_ops ecoff_format_ops =
 {
   bfd_target_ecoff_flavour,
@@ -321,3 +323,5 @@ const struct format_ops ecoff_format_ops =
   ecoff_symbol_clone_hook,
   0    /* adjust_symtab.  */
 };
+
+#endif /* USE_EMULATIONS */
index 1bed3ff0ff2250ef73c89304c0a5b6a3e3675796..b9aaca9abb04d1ed447b98f577420d399555bacd 100644 (file)
@@ -199,48 +199,6 @@ elf_pop_insert (void)
     pop_insert (ecoff_debug_pseudo_table);
 }
 
-static bfd_vma
-elf_s_get_size (symbolS *sym)
-{
-  return S_GET_SIZE (sym);
-}
-
-static void
-elf_s_set_size (symbolS *sym, bfd_vma sz)
-{
-  S_SET_SIZE (sym, sz);
-}
-
-static bfd_vma
-elf_s_get_align (symbolS *sym)
-{
-  return S_GET_ALIGN (sym);
-}
-
-static void
-elf_s_set_align (symbolS *sym, bfd_vma align)
-{
-  S_SET_ALIGN (sym, align);
-}
-
-int
-elf_s_get_other (symbolS *sym)
-{
-  return elf_symbol (symbol_get_bfdsym (sym))->internal_elf_sym.st_other;
-}
-
-static void
-elf_s_set_other (symbolS *sym, int other)
-{
-  S_SET_OTHER (sym, other);
-}
-
-static int
-elf_sec_sym_ok_for_reloc (asection *sec)
-{
-  return obj_sec_sym_ok_for_reloc (sec);
-}
-
 void
 elf_file_symbol (const char *s)
 {
@@ -3190,38 +3148,6 @@ elf_frob_file_after_relocs (void)
 #endif /* NEED_ECOFF_DEBUG */
 }
 
-static void
-elf_process_stab (int what ATTRIBUTE_UNUSED,
-                 const char *string ATTRIBUTE_UNUSED,
-                 int type ATTRIBUTE_UNUSED,
-                 int other ATTRIBUTE_UNUSED,
-                 int desc ATTRIBUTE_UNUSED)
-{
-#ifdef NEED_ECOFF_DEBUG
-  if (ECOFF_DEBUGGING)
-    ecoff_stab (what, string, type, other, desc);
-#endif
-}
-
-static int
-elf_separate_stab_sections (void)
-{
-#ifdef NEED_ECOFF_DEBUG
-  return (!ECOFF_DEBUGGING);
-#else
-  return 1;
-#endif
-}
-
-static void
-elf_init_stab_section (segT stab, segT stabstr)
-{
-#ifdef NEED_ECOFF_DEBUG
-  if (!ECOFF_DEBUGGING)
-#endif
-    obj_elf_init_stab_section (stab, stabstr);
-}
-
 /* This is called when the assembler starts.  */
 
 void
@@ -3265,6 +3191,84 @@ elf_end (void)
     }
 }
 
+#ifdef USE_EMULATIONS
+
+static bfd_vma
+elf_s_get_size (symbolS *sym)
+{
+  return S_GET_SIZE (sym);
+}
+
+static void
+elf_s_set_size (symbolS *sym, bfd_vma sz)
+{
+  S_SET_SIZE (sym, sz);
+}
+
+static bfd_vma
+elf_s_get_align (symbolS *sym)
+{
+  return S_GET_ALIGN (sym);
+}
+
+static void
+elf_s_set_align (symbolS *sym, bfd_vma align)
+{
+  S_SET_ALIGN (sym, align);
+}
+
+int
+elf_s_get_other (symbolS *sym)
+{
+  return elf_symbol (symbol_get_bfdsym (sym))->internal_elf_sym.st_other;
+}
+
+static void
+elf_s_set_other (symbolS *sym, int other)
+{
+  S_SET_OTHER (sym, other);
+}
+
+static int
+elf_sec_sym_ok_for_reloc (asection *sec)
+{
+  return obj_sec_sym_ok_for_reloc (sec);
+}
+
+#ifdef NEED_ECOFF_DEBUG
+static void
+elf_process_stab (int what ATTRIBUTE_UNUSED,
+                 const char *string ATTRIBUTE_UNUSED,
+                 int type ATTRIBUTE_UNUSED,
+                 int other ATTRIBUTE_UNUSED,
+                 int desc ATTRIBUTE_UNUSED)
+{
+  if (ECOFF_DEBUGGING)
+    ecoff_stab (what, string, type, other, desc);
+}
+#else
+# define elf_process_stab NULL
+#endif
+
+static int
+elf_separate_stab_sections (void)
+{
+#ifdef NEED_ECOFF_DEBUG
+  return (!ECOFF_DEBUGGING);
+#else
+  return 1;
+#endif
+}
+
+#ifdef NEED_ECOFF_DEBUG
+static void
+elf_init_stab_section (segT stab, segT stabstr)
+{
+  if (!ECOFF_DEBUGGING)
+    obj_elf_init_stab_section (stab, stabstr);
+}
+#endif
+
 const struct format_ops elf_format_ops =
 {
   bfd_target_elf_flavour,
@@ -3290,7 +3294,11 @@ const struct format_ops elf_format_ops =
   elf_copy_symbol_attributes,
   elf_process_stab,
   elf_separate_stab_sections,
+#ifdef NEED_ECOFF_DEBUG
   elf_init_stab_section,
+#else
+  obj_elf_init_stab_section,
+#endif
   elf_sec_sym_ok_for_reloc,
   elf_pop_insert,
 #ifdef NEED_ECOFF_DEBUG
@@ -3303,3 +3311,5 @@ const struct format_ops elf_format_ops =
   elf_obj_symbol_clone_hook,
   elf_adjust_symtab
 };
+
+#endif /* USE_EMULATIONS */
index 7b5d2fe2b80541a32f731d199045b50b219fe952..179711ec30df3e48382939a84066aa8ef96289b8 100644 (file)
@@ -150,7 +150,8 @@ extern void elf_end (void);
 
 int elf_s_get_other (symbolS *);
 #ifndef S_GET_OTHER
-#define S_GET_OTHER(S) (elf_s_get_other (S))
+#define S_GET_OTHER(S) \
+  (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other)
 #endif
 #ifndef S_SET_OTHER
 #define S_SET_OTHER(S,V) \