[binutils-gdb] bfd: avoid elf-sframe.c for SFrame-unaware targets

Jan Beulich via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6c2464bdb04db99062dad7393dc3d23aa984f0db

commit 6c2464bdb04db99062dad7393dc3d23aa984f0db
Author: Jan Beulich <[email protected]>
Date:   Fri Mar 13 07:51:46 2026 +0100

    bfd: avoid elf-sframe.c for SFrame-unaware targets
    
    It is wasteful to build this file when it's not actually used. Limit it
    to targets actually using SFrame and introduce a compiler define
    (paralleling OBJ_MAYBE_ELF, as having similar purpose) to guard internal
    function decls.

Diff:
---
 bfd/configure    | 15 ++++++++-------
 bfd/configure.ac | 15 ++++++++-------
 bfd/elf-bfd.h    | 37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 14 deletions(-)

diff --git a/bfd/configure b/bfd/configure
index ccaf53b0914..0d55a4128e1 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -15829,14 +15829,14 @@ selarchs="$f"
 tb=
 
 elf="elf.lo elflink.lo elf-strtab.lo elf-eh-frame.lo elf-properties.lo
-     elf-sframe.lo dwarf1.lo dwarf2.lo"
+     dwarf1.lo dwarf2.lo"
 coffgen="coffgen.lo dwarf2.lo"
 coff="cofflink.lo $coffgen"
 ecoff="ecofflink.lo $coffgen"
 xcoff="xcofflink.lo $coffgen"
 
 elf32_aarch64="elf32-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf32.lo elf-attrs.lo"
-elf64_aarch64="elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo elf-attrs.lo"
+elf64_aarch64="elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo elf-attrs.lo elf-sframe.lo"
 elf_arc="elf32-arc.lo elf32.lo elf-attrs.lo"
 elf_arm="elf32-arm.lo elf32.lo elf-attrs.lo elf-vxworks.lo"
 elf_csky="elf32-csky.lo elf32.lo elf-attrs.lo"
@@ -16050,7 +16050,7 @@ do
     rx_elf32_le_vec)		 tb="$tb elf32-rx.lo elf32.lo $elf" ;;
     rx_elf32_linux_le_vec)	 tb="$tb elf32-rx.lo elf32.lo $elf" ;;
     s390_elf32_vec)		 tb="$tb elf32-s390.lo elf32.lo elf-attrs.lo $elf" ;;
-    s390_elf64_vec)		 tb="$tb elf64-s390.lo elf64.lo elf-attrs.lo $elf"; target_size=64 ;;
+    s390_elf64_vec)		 tb="$tb elf64-s390.lo elf64.lo elf-attrs.lo elf-sframe.lo $elf"; target_size=64 ;;
     score_elf32_be_vec)		 tb="$tb elf32-score.lo elf32-score7.lo elf32.lo elf64.lo $elf"; want64=true; target_size=64 ;;
     score_elf32_le_vec)		 tb="$tb elf32-score.lo elf32-score7.lo elf32.lo elf64.lo $elf"; want64=true; target_size=64 ;;
     sh_coff_vec)		 tb="$tb coff-sh.lo $coff" ;;
@@ -16112,9 +16112,9 @@ do
     wasm32_elf32_vec)            tb="$tb elf32-wasm32.lo elf32.lo $elf" ;;
     x86_64_coff_vec)		 tb="$tb coff-x86_64.lo $coff"; target_size=64 ;;
     x86_64_elf32_vec)		 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo elf32.lo $elf"; target_size=64 ;;
-    x86_64_elf64_vec)		 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
-    x86_64_elf64_fbsd_vec)	 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
-    x86_64_elf64_sol2_vec)	 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
+    x86_64_elf64_vec)		 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo elf-sframe.lo $elf"; target_size=64 ;;
+    x86_64_elf64_fbsd_vec)	 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo elf-sframe.lo $elf"; target_size=64 ;;
+    x86_64_elf64_sol2_vec)	 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo elf-sframe.lo $elf"; target_size=64 ;;
     x86_64_mach_o_vec)		 tb="$tb mach-o-x86-64.lo" ;;
     x86_64_pe_vec)		 tb="$tb pe-x86_64.lo pex64igen.lo $coff"; target_size=64 ;;
     x86_64_pe_big_vec)		 tb="$tb pe-x86_64.lo pex64igen.lo $coff"; target_size=64 ;;
@@ -16191,7 +16191,7 @@ if test x${all_targets} = xtrue ; then
     esac
   done
   assocvecs=$f
-  TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF -DOBJ_MAYBE_ELF_ATTRIBUTES"
+  TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF -DOBJ_MAYBE_ELF_ATTRIBUTES -DOBJ_MAYBE_ELF_SFRAME"
 else	# all_targets is true
   # Only set these if they will be nonempty, for the clever echo.
   havevecs=
@@ -16207,6 +16207,7 @@ else	# all_targets is true
     case "$i" in
     elf.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF" ;;
     elf-attrs.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_ATTRIBUTES" ;;
+    elf-sframe.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SFRAME" ;;
     esac
   done
 fi	# all_targets is true
diff --git a/bfd/configure.ac b/bfd/configure.ac
index 877ba4a64f2..06e02a2d507 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -370,14 +370,14 @@ selarchs="$f"
 tb=
 
 elf="elf.lo elflink.lo elf-strtab.lo elf-eh-frame.lo elf-properties.lo
-     elf-sframe.lo dwarf1.lo dwarf2.lo"
+     dwarf1.lo dwarf2.lo"
 coffgen="coffgen.lo dwarf2.lo"
 coff="cofflink.lo $coffgen"
 ecoff="ecofflink.lo $coffgen"
 xcoff="xcofflink.lo $coffgen"
 
 elf32_aarch64="elf32-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf32.lo elf-attrs.lo"
-elf64_aarch64="elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo elf-attrs.lo"
+elf64_aarch64="elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo elf-attrs.lo elf-sframe.lo"
 elf_arc="elf32-arc.lo elf32.lo elf-attrs.lo"
 elf_arm="elf32-arm.lo elf32.lo elf-attrs.lo elf-vxworks.lo"
 elf_csky="elf32-csky.lo elf32.lo elf-attrs.lo"
@@ -591,7 +591,7 @@ do
     rx_elf32_le_vec)		 tb="$tb elf32-rx.lo elf32.lo $elf" ;;
     rx_elf32_linux_le_vec)	 tb="$tb elf32-rx.lo elf32.lo $elf" ;;
     s390_elf32_vec)		 tb="$tb elf32-s390.lo elf32.lo elf-attrs.lo $elf" ;;
-    s390_elf64_vec)		 tb="$tb elf64-s390.lo elf64.lo elf-attrs.lo $elf"; target_size=64 ;;
+    s390_elf64_vec)		 tb="$tb elf64-s390.lo elf64.lo elf-attrs.lo elf-sframe.lo $elf"; target_size=64 ;;
     score_elf32_be_vec)		 tb="$tb elf32-score.lo elf32-score7.lo elf32.lo elf64.lo $elf"; want64=true; target_size=64 ;;
     score_elf32_le_vec)		 tb="$tb elf32-score.lo elf32-score7.lo elf32.lo elf64.lo $elf"; want64=true; target_size=64 ;;
     sh_coff_vec)		 tb="$tb coff-sh.lo $coff" ;;
@@ -653,9 +653,9 @@ do
     wasm32_elf32_vec)            tb="$tb elf32-wasm32.lo elf32.lo $elf" ;;
     x86_64_coff_vec)		 tb="$tb coff-x86_64.lo $coff"; target_size=64 ;;
     x86_64_elf32_vec)		 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo elf32.lo $elf"; target_size=64 ;;
-    x86_64_elf64_vec)		 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
-    x86_64_elf64_fbsd_vec)	 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
-    x86_64_elf64_sol2_vec)	 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
+    x86_64_elf64_vec)		 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo elf-sframe.lo $elf"; target_size=64 ;;
+    x86_64_elf64_fbsd_vec)	 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo elf-sframe.lo $elf"; target_size=64 ;;
+    x86_64_elf64_sol2_vec)	 tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo elf-sframe.lo $elf"; target_size=64 ;;
     x86_64_mach_o_vec)		 tb="$tb mach-o-x86-64.lo" ;;
     x86_64_pe_vec)		 tb="$tb pe-x86_64.lo pex64igen.lo $coff"; target_size=64 ;;
     x86_64_pe_big_vec)		 tb="$tb pe-x86_64.lo pex64igen.lo $coff"; target_size=64 ;;
@@ -732,7 +732,7 @@ if test x${all_targets} = xtrue ; then
     esac
   done
   assocvecs=$f
-  TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF -DOBJ_MAYBE_ELF_ATTRIBUTES"
+  TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF -DOBJ_MAYBE_ELF_ATTRIBUTES -DOBJ_MAYBE_ELF_SFRAME"
 else	# all_targets is true
   # Only set these if they will be nonempty, for the clever echo.
   havevecs=
@@ -748,6 +748,7 @@ else	# all_targets is true
     case "$i" in
     elf.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF" ;;
     elf-attrs.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_ATTRIBUTES" ;;
+    elf-sframe.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SFRAME" ;;
     esac
   done
 fi	# all_targets is true
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 58db4eb81b0..3d2fad49aa4 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2631,6 +2631,8 @@ extern bool _bfd_elf_eh_frame_entry_present
 extern bool _bfd_elf_maybe_strip_eh_frame_hdr
   (struct bfd_link_info *) ATTRIBUTE_HIDDEN;
 
+#ifdef OBJ_MAYBE_ELF_SFRAME
+
 extern bool _bfd_elf_sframe_present
   (struct bfd_link_info *) ATTRIBUTE_HIDDEN;
 extern bool _bfd_elf_sframe_present_input_bfds
@@ -2650,6 +2652,41 @@ extern bool _bfd_elf_write_section_sframe
 extern bool _bfd_elf_set_section_sframe
   (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
 
+#else /* !OBJ_MAYBE_ELF_SFRAME */
+
+static inline bool _bfd_elf_sframe_present
+  (struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{ return false; }
+static inline bool _bfd_elf_sframe_present_input_bfds
+  (struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{ return false; }
+static inline bool _bfd_elf_parse_sframe
+  (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info ATTRIBUTE_UNUSED,
+   asection *sec ATTRIBUTE_UNUSED,
+   struct elf_reloc_cookie *cookie ATTRIBUTE_UNUSED)
+{ return false; }
+static inline bool _bfd_elf_discard_section_sframe
+  (asection *sec ATTRIBUTE_UNUSED,
+  bool (*reloc_symbol_deleted_p) (bfd_vma, void *) ATTRIBUTE_UNUSED,
+  struct elf_reloc_cookie *cookie ATTRIBUTE_UNUSED)
+{ return false; }
+static inline bool _bfd_elf_merge_section_sframe
+  (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info ATTRIBUTE_UNUSED,
+   asection *sec ATTRIBUTE_UNUSED, bfd_byte *contents ATTRIBUTE_UNUSED)
+{ return false; }
+static inline bfd_vma _bfd_elf_sframe_section_offset
+  (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info ATTRIBUTE_UNUSED,
+   asection *sec ATTRIBUTE_UNUSED, bfd_vma offset)
+{ return offset; }
+static inline bool _bfd_elf_write_section_sframe
+  (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{ return true; }
+static inline bool _bfd_elf_set_section_sframe
+  (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{ return false; }
+
+#endif /* OBJ_MAYBE_ELF_SFRAME */
+
 extern bool _bfd_elf_hash_symbol
   (struct elf_link_hash_entry *) ATTRIBUTE_HIDDEN;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.