[PATCH v2 4/5] bfd: avoid elf-solaris2.c for non-Solaris targets
Jan Beulich
jbeulich@suse.com
Mon Mar 2 07:44:55 GMT 2026
Even if small, it is wasteful to build this file when it's not actually
used. Limit it to Solaris targets and introduce a compiler define
(paralleling OBJ_MAYBE_ELF, as having similar purpose) to guard internals.
---
In principle it should be possible to get away entirely without
OBJ_MAYBE_ELF_SOLARIS2, by using solely the HAVE_..._vec defines.
---
v2: Re-base.
--- a/bfd/configure
+++ b/bfd/configure
@@ -15848,8 +15848,8 @@ elf64_powerpc="elf64-ppc.lo elf64-gen.lo
elf32_riscv="elf32-riscv.lo elfxx-riscv.lo elf-ifunc.lo elf32.lo elf-attrs.lo"
elf64_riscv="elf64-riscv.lo elf64.lo elfxx-riscv.lo elf-ifunc.lo elf32.lo elf-attrs.lo"
elf_tic6x="elf32-tic6x.lo elf32.lo elf-attrs.lo"
-elfxx_x86="elfxx-x86.lo elf-ifunc.lo elf-solaris2.lo elf-vxworks.lo"
-elfxx_sparc="elfxx-sparc.lo elf-solaris2.lo elf-vxworks.lo elf-attrs.lo $elf"
+elfxx_x86="elfxx-x86.lo elf-ifunc.lo elf-vxworks.lo"
+elfxx_sparc="elfxx-sparc.lo elf-vxworks.lo elf-attrs.lo $elf"
for vec in $selvecs
do
target_size=32
@@ -15932,7 +15932,7 @@ do
i386_coff_lynx_vec) tb="$tb cf-i386lynx.lo lynx-core.lo $coff" ;;
i386_elf32_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
i386_elf32_fbsd_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
- i386_elf32_sol2_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
+ i386_elf32_sol2_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf-solaris2.lo elf32.lo $elf" ;;
i386_elf32_vxworks_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
i386_mach_o_vec) tb="$tb mach-o-i386.lo" ;;
i386_msdos_vec) tb="$tb i386msdos.lo" ;;
@@ -16070,11 +16070,11 @@ do
sh_pe_le_vec) tb="$tb pe-sh.lo coff-sh.lo peigen.lo $coff" ;;
sh_pei_le_vec) tb="$tb pei-sh.lo coff-sh.lo peigen.lo $coff" ;;
sparc_elf32_vec) tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc" ;;
- sparc_elf32_sol2_vec) tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc" ;;
+ sparc_elf32_sol2_vec) tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc elf-solaris2.lo" ;;
sparc_elf32_vxworks_vec) tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc" ;;
sparc_elf64_vec) tb="$tb elf64-sparc.lo elf64.lo $elfxx_sparc"; target_size=64 ;;
sparc_elf64_fbsd_vec) tb="$tb elf64-sparc.lo elf64.lo $elfxx_sparc"; target_size=64 ;;
- sparc_elf64_sol2_vec) tb="$tb elf64-sparc.lo elf64.lo $elfxx_sparc"; target_size=64 ;;
+ sparc_elf64_sol2_vec) tb="$tb elf64-sparc.lo elf64.lo $elfxx_sparc elf-solaris2.lo"; target_size=64 ;;
spu_elf32_vec) tb="$tb elf32-spu.lo elf32.lo $elf" ;;
sym_vec) tb="$tb xsym.lo" ;;
tic30_coff_vec) tb="$tb coff-tic30.lo $coffgen" ;;
@@ -16114,7 +16114,7 @@ do
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-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_elf64_sol2_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf-solaris2.lo 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 ;;
@@ -16192,6 +16192,7 @@ if test x${all_targets} = xtrue ; then
done
assocvecs=$f
TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF -DOBJ_MAYBE_ELF_ATTRIBUTES -DOBJ_MAYBE_ELF_SFRAME"
+ TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SOLARIS2"
else # all_targets is true
# Only set these if they will be nonempty, for the clever echo.
havevecs=
@@ -16208,6 +16209,7 @@ else # all_targets is true
elf.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF" ;;
elf-attrs.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_ATTRIBUTES" ;;
elf-sframe.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SFRAME" ;;
+ elf-solaris2.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SOLARIS2" ;;
esac
done
fi # all_targets is true
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -389,8 +389,8 @@ elf64_powerpc="elf64-ppc.lo elf64-gen.lo
elf32_riscv="elf32-riscv.lo elfxx-riscv.lo elf-ifunc.lo elf32.lo elf-attrs.lo"
elf64_riscv="elf64-riscv.lo elf64.lo elfxx-riscv.lo elf-ifunc.lo elf32.lo elf-attrs.lo"
elf_tic6x="elf32-tic6x.lo elf32.lo elf-attrs.lo"
-elfxx_x86="elfxx-x86.lo elf-ifunc.lo elf-solaris2.lo elf-vxworks.lo"
-elfxx_sparc="elfxx-sparc.lo elf-solaris2.lo elf-vxworks.lo elf-attrs.lo $elf"
+elfxx_x86="elfxx-x86.lo elf-ifunc.lo elf-vxworks.lo"
+elfxx_sparc="elfxx-sparc.lo elf-vxworks.lo elf-attrs.lo $elf"
for vec in $selvecs
do
target_size=32
@@ -473,7 +473,7 @@ do
i386_coff_lynx_vec) tb="$tb cf-i386lynx.lo lynx-core.lo $coff" ;;
i386_elf32_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
i386_elf32_fbsd_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
- i386_elf32_sol2_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
+ i386_elf32_sol2_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf-solaris2.lo elf32.lo $elf" ;;
i386_elf32_vxworks_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
i386_mach_o_vec) tb="$tb mach-o-i386.lo" ;;
i386_msdos_vec) tb="$tb i386msdos.lo" ;;
@@ -611,11 +611,11 @@ do
sh_pe_le_vec) tb="$tb pe-sh.lo coff-sh.lo peigen.lo $coff" ;;
sh_pei_le_vec) tb="$tb pei-sh.lo coff-sh.lo peigen.lo $coff" ;;
sparc_elf32_vec) tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc" ;;
- sparc_elf32_sol2_vec) tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc" ;;
+ sparc_elf32_sol2_vec) tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc elf-solaris2.lo" ;;
sparc_elf32_vxworks_vec) tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc" ;;
sparc_elf64_vec) tb="$tb elf64-sparc.lo elf64.lo $elfxx_sparc"; target_size=64 ;;
sparc_elf64_fbsd_vec) tb="$tb elf64-sparc.lo elf64.lo $elfxx_sparc"; target_size=64 ;;
- sparc_elf64_sol2_vec) tb="$tb elf64-sparc.lo elf64.lo $elfxx_sparc"; target_size=64 ;;
+ sparc_elf64_sol2_vec) tb="$tb elf64-sparc.lo elf64.lo $elfxx_sparc elf-solaris2.lo"; target_size=64 ;;
spu_elf32_vec) tb="$tb elf32-spu.lo elf32.lo $elf" ;;
sym_vec) tb="$tb xsym.lo" ;;
tic30_coff_vec) tb="$tb coff-tic30.lo $coffgen" ;;
@@ -655,7 +655,7 @@ do
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-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_elf64_sol2_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf-solaris2.lo 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 ;;
@@ -733,6 +733,7 @@ if test x${all_targets} = xtrue ; then
done
assocvecs=$f
TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF -DOBJ_MAYBE_ELF_ATTRIBUTES -DOBJ_MAYBE_ELF_SFRAME"
+ TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SOLARIS2"
else # all_targets is true
# Only set these if they will be nonempty, for the clever echo.
havevecs=
@@ -749,6 +750,7 @@ else # all_targets is true
elf.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF" ;;
elf-attrs.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_ATTRIBUTES" ;;
elf-sframe.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SFRAME" ;;
+ elf-solaris2.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SOLARIS2" ;;
esac
done
fi # all_targets is true
--- a/bfd/elf-solaris2.h
+++ b/bfd/elf-solaris2.h
@@ -20,6 +20,8 @@
extern const char *const elf_solaris2_global_syms[];
+#ifdef OBJ_MAYBE_ELF_SOLARIS2
+
extern bool elf_solaris2_add_symbol_hook
(bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **,
flagword *, asection **, bfd_vma *) ATTRIBUTE_HIDDEN;
@@ -32,3 +34,19 @@ is_solaris2_abi_global_sym (const char *
return true;
return false;
}
+
+#else /* !OBJ_MAYBE_ELF_SOLARIS2 */
+
+static inline bool
+elf_solaris2_add_symbol_hook (bfd *abfd ATTRIBUTE_UNUSED,
+ struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ Elf_Internal_Sym *isym ATTRIBUTE_UNUSED,
+ const char **name ATTRIBUTE_UNUSED,
+ flagword *flags ATTRIBUTE_UNUSED,
+ asection **sec ATTRIBUTE_UNUSED,
+ bfd_vma *value ATTRIBUTE_UNUSED)
+{
+ return true;
+}
+
+#endif /* OBJ_MAYBE_ELF_SOLARIS2 */
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -4651,6 +4651,8 @@ elf_i386_fbsd_init_file_header (bfd *abf
#undef elf_backend_init_file_header
+#ifdef OBJ_MAYBE_ELF_SOLARIS2
+
/* Solaris 2. */
#undef TARGET_LITTLE_SYM
@@ -4688,6 +4690,8 @@ elf_i386_fbsd_init_file_header (bfd *abf
#include "elf32-target.h"
+#endif /* OBJ_MAYBE_ELF_SOLARIS2 */
+
/* Intel MCU support. */
static bool
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -275,6 +275,8 @@ elf32_sparc_reloc_type_class (const stru
#include "elf32-target.h"
+#ifdef OBJ_MAYBE_ELF_SOLARIS2
+
/* Solaris 2. */
#undef TARGET_BIG_SYM
@@ -315,6 +317,8 @@ elf32_sparc_copy_solaris_special_section
#include "elf32-target.h"
+#endif /* OBJ_MAYBE_ELF_SOLARIS2 */
+
/* A final_write_processing hook that does both the SPARC- and VxWorks-
specific handling. */
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -1005,6 +1005,8 @@ static const struct elf_size_info elf64_
#include "elf64-target.h"
+#ifdef OBJ_MAYBE_ELF_SOLARIS2
+
/* Solaris 2. */
static bool
@@ -1059,3 +1061,5 @@ elf64_sparc_copy_solaris_special_section
#define elf_backend_copy_special_section_fields elf64_sparc_copy_solaris_special_section_fields
#include "elf64-target.h"
+
+#endif /* OBJ_MAYBE_ELF_SOLARIS2 */
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -6435,6 +6435,8 @@ elf_x86_64_special_sections[]=
#include "elf64-target.h"
+#ifdef OBJ_MAYBE_ELF_SOLARIS2
+
/* Solaris 2 support. */
static bool
@@ -6487,6 +6489,8 @@ elf_x86_64_solaris2_add_symbol_hook (bfd
#include "elf64-target.h"
+#endif /* OBJ_MAYBE_ELF_SOLARIS2 */
+
/* Restore defaults. */
#undef ELF_OSABI
#undef ELF_OSABI_EXACT
More information about the Binutils
mailing list