[PATCH v2 5/5] bfd: avoid elf-vxworks.c for non-VxWorks targets

Jan Beulich jbeulich@suse.com
Mon Mar 2 07:46:38 GMT 2026


It is wasteful to build this file when it's not actually used. Limit it to
VxWorks targets and introduce a compiler define (paralleling
OBJ_MAYBE_ELF, as having similar purpose) to guard internals.

By adding more #ifdef-ary, more savings may be possible. For now, besides
those guarding the vector definitions, only ones necessary to avoid the
need for elf_vxworks_*() inline stubs are being added. Somewhat similarly
tighter #ifdef around the definitions of *_elf*_vxworks*_vec (using
HAVE_..._vec) may yield further savings.
---
In principle it should be possible to get away entirely without
OBJ_MAYBE_ELF_VXWORKS, by using solely the HAVE_..._vec defines. At least
in elf-vxworks.h that would likely get unwieldy, though.
---
v2: Re-base.

--- a/bfd/configure
+++ b/bfd/configure
@@ -15838,18 +15838,18 @@ 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 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_arm="elf32-arm.lo elf32.lo elf-attrs.lo"
 elf_csky="elf32-csky.lo elf32.lo elf-attrs.lo"
-elf32_mips="elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo elf-attrs.lo"
-elfn32_mips="elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo elf-attrs.lo"
-elf64_mips="elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo elf-attrs.lo"
-elf32_powerpc="elf32-ppc.lo elf-vxworks.lo elf32.lo elf-attrs.lo"
+elf32_mips="elf32-mips.lo elfxx-mips.lo elf32.lo elf-attrs.lo"
+elfn32_mips="elfn32-mips.lo elfxx-mips.lo elf32.lo elf-attrs.lo"
+elf64_mips="elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo elf-attrs.lo"
+elf32_powerpc="elf32-ppc.lo elf32.lo elf-attrs.lo"
 elf64_powerpc="elf64-ppc.lo elf64-gen.lo elf64.lo elf-attrs.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-vxworks.lo"
-elfxx_sparc="elfxx-sparc.lo elf-vxworks.lo elf-attrs.lo $elf"
+elfxx_x86="elfxx-x86.lo elf-ifunc.lo"
+elfxx_sparc="elfxx-sparc.lo elf-attrs.lo $elf"
 for vec in $selvecs
 do
     target_size=32
@@ -15881,8 +15881,8 @@ do
     arm_elf32_le_vec)		 tb="$tb $elf_arm $elf" ;;
     arm_elf32_fdpic_be_vec)	 tb="$tb $elf_arm $elf" ;;
     arm_elf32_fdpic_le_vec)	 tb="$tb $elf_arm $elf" ;;
-    arm_elf32_vxworks_be_vec)	 tb="$tb $elf_arm $elf" ;;
-    arm_elf32_vxworks_le_vec)	 tb="$tb $elf_arm $elf" ;;
+    arm_elf32_vxworks_be_vec)	 tb="$tb $elf_arm elf-vxworks.lo $elf" ;;
+    arm_elf32_vxworks_le_vec)	 tb="$tb $elf_arm elf-vxworks.lo $elf" ;;
     arm_pe_be_vec)		 tb="$tb pe-arm.lo peigen.lo $coff" ;;
     arm_pe_le_vec)		 tb="$tb pe-arm.lo peigen.lo $coff" ;;
     arm_pe_wince_be_vec)	 tb="$tb pe-arm-wince.lo pe-arm.lo peigen.lo $coff" ;;
@@ -15933,7 +15933,7 @@ do
     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 elf-solaris2.lo elf32.lo $elf" ;;
-    i386_elf32_vxworks_vec)	 tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
+    i386_elf32_vxworks_vec)	 tb="$tb elf32-i386.lo $elfxx_x86 elf-vxworks.lo elf32.lo $elf" ;;
     i386_mach_o_vec)		 tb="$tb mach-o-i386.lo" ;;
     i386_msdos_vec)		 tb="$tb i386msdos.lo" ;;
     i386_pe_vec)		 tb="$tb pe-i386.lo peigen.lo $coff" ;;
@@ -15994,8 +15994,8 @@ do
     mips_elf32_trad_le_vec)	 tb="$tb $elf32_mips $elf $ecoff" ;;
     mips_elf32_tradfbsd_be_vec)  tb="$tb $elf32_mips $elf $ecoff" ;;
     mips_elf32_tradfbsd_le_vec)  tb="$tb $elf32_mips $elf $ecoff" ;;
-    mips_elf32_vxworks_be_vec)	 tb="$tb $elf32_mips $elf $ecoff" ;;
-    mips_elf32_vxworks_le_vec)	 tb="$tb $elf32_mips $elf $ecoff" ;;
+    mips_elf32_vxworks_be_vec)	 tb="$tb $elf32_mips elf-vxworks.lo $elf $ecoff" ;;
+    mips_elf32_vxworks_le_vec)	 tb="$tb $elf32_mips elf-vxworks.lo $elf $ecoff" ;;
     mips_elf64_be_vec)		 tb="$tb $elf64_mips $elf $ecoff"; target_size=64 ;;
     mips_elf64_le_vec)		 tb="$tb $elf64_mips $elf $ecoff"; target_size=64 ;;
     mips_elf64_trad_be_vec)	 tb="$tb $elf64_mips $elf $ecoff"; target_size=64 ;;
@@ -16029,7 +16029,7 @@ do
     powerpc_elf32_vec)		 tb="$tb $elf32_powerpc $elf" ;;
     powerpc_elf32_le_vec)	 tb="$tb $elf32_powerpc $elf" ;;
     powerpc_elf32_fbsd_vec)	 tb="$tb $elf32_powerpc $elf" ;;
-    powerpc_elf32_vxworks_vec)	 tb="$tb $elf32_powerpc $elf" ;;
+    powerpc_elf32_vxworks_vec)	 tb="$tb $elf32_powerpc elf-vxworks.lo $elf" ;;
     powerpc_elf64_vec)		 tb="$tb $elf64_powerpc $elf"; target_size=64 ;;
     powerpc_elf64_le_vec)	 tb="$tb $elf64_powerpc $elf"; target_size=64 ;;
     powerpc_elf64_fbsd_vec)	 tb="$tb $elf64_powerpc $elf"; target_size=64 ;;
@@ -16057,21 +16057,21 @@ do
     sh_coff_le_vec)		 tb="$tb coff-sh.lo $coff" ;;
     sh_coff_small_vec)		 tb="$tb coff-sh.lo $coff" ;;
     sh_coff_small_le_vec)	 tb="$tb coff-sh.lo $coff" ;;
-    sh_elf32_vec)		 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_le_vec)		 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_fdpic_be_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_fdpic_le_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_linux_vec)		 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_linux_be_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_nbsd_vec)		 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_nbsd_le_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_vec)		 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_le_vec)		 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_fdpic_be_vec)	 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_fdpic_le_vec)	 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_linux_vec)		 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_linux_be_vec)	 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_nbsd_vec)		 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_nbsd_le_vec)	 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
     sh_elf32_vxworks_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
     sh_elf32_vxworks_le_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
     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 elf-solaris2.lo" ;;
-    sparc_elf32_vxworks_vec)	 tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc" ;;
+    sparc_elf32_vxworks_vec)	 tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc elf-vxworks.lo" ;;
     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 elf-solaris2.lo"; target_size=64 ;;
@@ -16192,7 +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"
+  TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SOLARIS2 -DOBJ_MAYBE_ELF_VXWORKS"
 else	# all_targets is true
   # Only set these if they will be nonempty, for the clever echo.
   havevecs=
@@ -16210,6 +16210,7 @@ else	# all_targets is true
     elf-attrs.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_ATTRIBUTES" ;;
     elf-sframe.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SFRAME" ;;
     elf-solaris2.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SOLARIS2" ;;
+    elf-vxworks.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_VXWORKS" ;;
     esac
   done
 fi	# all_targets is true
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -379,18 +379,18 @@ 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 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_arm="elf32-arm.lo elf32.lo elf-attrs.lo"
 elf_csky="elf32-csky.lo elf32.lo elf-attrs.lo"
-elf32_mips="elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo elf-attrs.lo"
-elfn32_mips="elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo elf-attrs.lo"
-elf64_mips="elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo elf-attrs.lo"
-elf32_powerpc="elf32-ppc.lo elf-vxworks.lo elf32.lo elf-attrs.lo"
+elf32_mips="elf32-mips.lo elfxx-mips.lo elf32.lo elf-attrs.lo"
+elfn32_mips="elfn32-mips.lo elfxx-mips.lo elf32.lo elf-attrs.lo"
+elf64_mips="elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo elf-attrs.lo"
+elf32_powerpc="elf32-ppc.lo elf32.lo elf-attrs.lo"
 elf64_powerpc="elf64-ppc.lo elf64-gen.lo elf64.lo elf-attrs.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-vxworks.lo"
-elfxx_sparc="elfxx-sparc.lo elf-vxworks.lo elf-attrs.lo $elf"
+elfxx_x86="elfxx-x86.lo elf-ifunc.lo"
+elfxx_sparc="elfxx-sparc.lo elf-attrs.lo $elf"
 for vec in $selvecs
 do
     target_size=32
@@ -422,8 +422,8 @@ do
     arm_elf32_le_vec)		 tb="$tb $elf_arm $elf" ;;
     arm_elf32_fdpic_be_vec)	 tb="$tb $elf_arm $elf" ;;
     arm_elf32_fdpic_le_vec)	 tb="$tb $elf_arm $elf" ;;
-    arm_elf32_vxworks_be_vec)	 tb="$tb $elf_arm $elf" ;;
-    arm_elf32_vxworks_le_vec)	 tb="$tb $elf_arm $elf" ;;
+    arm_elf32_vxworks_be_vec)	 tb="$tb $elf_arm elf-vxworks.lo $elf" ;;
+    arm_elf32_vxworks_le_vec)	 tb="$tb $elf_arm elf-vxworks.lo $elf" ;;
     arm_pe_be_vec)		 tb="$tb pe-arm.lo peigen.lo $coff" ;;
     arm_pe_le_vec)		 tb="$tb pe-arm.lo peigen.lo $coff" ;;
     arm_pe_wince_be_vec)	 tb="$tb pe-arm-wince.lo pe-arm.lo peigen.lo $coff" ;;
@@ -474,7 +474,7 @@ do
     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 elf-solaris2.lo elf32.lo $elf" ;;
-    i386_elf32_vxworks_vec)	 tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
+    i386_elf32_vxworks_vec)	 tb="$tb elf32-i386.lo $elfxx_x86 elf-vxworks.lo elf32.lo $elf" ;;
     i386_mach_o_vec)		 tb="$tb mach-o-i386.lo" ;;
     i386_msdos_vec)		 tb="$tb i386msdos.lo" ;;
     i386_pe_vec)		 tb="$tb pe-i386.lo peigen.lo $coff" ;;
@@ -535,8 +535,8 @@ do
     mips_elf32_trad_le_vec)	 tb="$tb $elf32_mips $elf $ecoff" ;;
     mips_elf32_tradfbsd_be_vec)  tb="$tb $elf32_mips $elf $ecoff" ;;
     mips_elf32_tradfbsd_le_vec)  tb="$tb $elf32_mips $elf $ecoff" ;;
-    mips_elf32_vxworks_be_vec)	 tb="$tb $elf32_mips $elf $ecoff" ;;
-    mips_elf32_vxworks_le_vec)	 tb="$tb $elf32_mips $elf $ecoff" ;;
+    mips_elf32_vxworks_be_vec)	 tb="$tb $elf32_mips elf-vxworks.lo $elf $ecoff" ;;
+    mips_elf32_vxworks_le_vec)	 tb="$tb $elf32_mips elf-vxworks.lo $elf $ecoff" ;;
     mips_elf64_be_vec)		 tb="$tb $elf64_mips $elf $ecoff"; target_size=64 ;;
     mips_elf64_le_vec)		 tb="$tb $elf64_mips $elf $ecoff"; target_size=64 ;;
     mips_elf64_trad_be_vec)	 tb="$tb $elf64_mips $elf $ecoff"; target_size=64 ;;
@@ -570,7 +570,7 @@ do
     powerpc_elf32_vec)		 tb="$tb $elf32_powerpc $elf" ;;
     powerpc_elf32_le_vec)	 tb="$tb $elf32_powerpc $elf" ;;
     powerpc_elf32_fbsd_vec)	 tb="$tb $elf32_powerpc $elf" ;;
-    powerpc_elf32_vxworks_vec)	 tb="$tb $elf32_powerpc $elf" ;;
+    powerpc_elf32_vxworks_vec)	 tb="$tb $elf32_powerpc elf-vxworks.lo $elf" ;;
     powerpc_elf64_vec)		 tb="$tb $elf64_powerpc $elf"; target_size=64 ;;
     powerpc_elf64_le_vec)	 tb="$tb $elf64_powerpc $elf"; target_size=64 ;;
     powerpc_elf64_fbsd_vec)	 tb="$tb $elf64_powerpc $elf"; target_size=64 ;;
@@ -598,21 +598,21 @@ do
     sh_coff_le_vec)		 tb="$tb coff-sh.lo $coff" ;;
     sh_coff_small_vec)		 tb="$tb coff-sh.lo $coff" ;;
     sh_coff_small_le_vec)	 tb="$tb coff-sh.lo $coff" ;;
-    sh_elf32_vec)		 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_le_vec)		 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_fdpic_be_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_fdpic_le_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_linux_vec)		 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_linux_be_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_nbsd_vec)		 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
-    sh_elf32_nbsd_le_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_vec)		 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_le_vec)		 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_fdpic_be_vec)	 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_fdpic_le_vec)	 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_linux_vec)		 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_linux_be_vec)	 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_nbsd_vec)		 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
+    sh_elf32_nbsd_le_vec)	 tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo $coff" ;;
     sh_elf32_vxworks_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
     sh_elf32_vxworks_le_vec)	 tb="$tb elf32-sh.lo elf-vxworks.lo elf32.lo $elf coff-sh.lo $coff" ;;
     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 elf-solaris2.lo" ;;
-    sparc_elf32_vxworks_vec)	 tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc" ;;
+    sparc_elf32_vxworks_vec)	 tb="$tb elf32-sparc.lo elf32.lo $elfxx_sparc elf-vxworks.lo" ;;
     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 elf-solaris2.lo"; target_size=64 ;;
@@ -733,7 +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"
+  TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SOLARIS2 -DOBJ_MAYBE_ELF_VXWORKS"
 else	# all_targets is true
   # Only set these if they will be nonempty, for the clever echo.
   havevecs=
@@ -751,6 +751,7 @@ else	# all_targets is true
     elf-attrs.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_ATTRIBUTES" ;;
     elf-sframe.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SFRAME" ;;
     elf-solaris2.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_SOLARIS2" ;;
+    elf-vxworks.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF_VXWORKS" ;;
     esac
   done
 fi	# all_targets is true
--- a/bfd/elf-vxworks.h
+++ b/bfd/elf-vxworks.h
@@ -19,6 +19,8 @@
 #include "elf/common.h"
 #include "elf/internal.h"
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
+
 bool elf_vxworks_add_symbol_hook
   (bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **,
    flagword *, asection **, bfd_vma *) ATTRIBUTE_HIDDEN;
@@ -38,3 +40,11 @@ bool elf_vxworks_finish_dynamic_entry
   (bfd *, Elf_Internal_Dyn *) ATTRIBUTE_HIDDEN;
 bool _bfd_elf_maybe_vxworks_add_dynamic_tags
   (bfd *, struct bfd_link_info *, bool) ATTRIBUTE_HIDDEN;
+
+#else /* !OBJ_MAYBE_ELF_VXWORKS */
+
+static inline bool _bfd_elf_maybe_vxworks_add_dynamic_tags (
+  bfd *output_bfd, struct bfd_link_info *info, bool need_dynamic_reloc)
+{ return _bfd_elf_add_dynamic_tags (output_bfd, info, need_dynamic_reloc); }
+
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -3916,6 +3916,7 @@ elf32_arm_create_dynamic_sections (bfd *
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return false;
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
   if (htab->root.target_os == is_vxworks)
     {
       if (!elf_vxworks_create_dynamic_sections (dynobj, info, &htab->srelplt2))
@@ -3939,6 +3940,7 @@ elf32_arm_create_dynamic_sections (bfd *
 	elf_elfheader (dynobj)->e_ident[EI_CLASS] = ELFCLASS32;
     }
   else
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
     {
       /* PR ld/16017
 	 Test for thumb only architectures.  Note - we cannot just call
@@ -17263,9 +17265,11 @@ elf32_arm_finish_dynamic_sections (bfd *
 	  switch (dyn.d_tag)
 	    {
 	    default:
+#ifdef OBJ_MAYBE_ELF_VXWORKS
 	      if (htab->root.target_os == is_vxworks
 		  && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
 		bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 	      break;
 
 	    case DT_HASH:
@@ -19757,17 +19761,23 @@ elf32_arm_additional_program_headers (bf
    file.  */
 
 static bool
-elf32_arm_add_symbol_hook (bfd *abfd, struct bfd_link_info *info,
-			   Elf_Internal_Sym *sym, const char **namep,
-			   flagword *flagsp, asection **secp, bfd_vma *valp)
+elf32_arm_add_symbol_hook (bfd *abfd ATTRIBUTE_UNUSED,
+			   struct bfd_link_info *info,
+			   Elf_Internal_Sym *sym ATTRIBUTE_UNUSED,
+			   const char **namep ATTRIBUTE_UNUSED,
+			   flagword *flagsp ATTRIBUTE_UNUSED,
+			   asection **secp ATTRIBUTE_UNUSED,
+			   bfd_vma *valp ATTRIBUTE_UNUSED)
 {
   if (elf32_arm_hash_table (info) == NULL)
     return false;
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
   if (elf32_arm_hash_table (info)->root.target_os == is_vxworks
       && !elf_vxworks_add_symbol_hook (abfd, info, sym, namep,
 				       flagsp, secp, valp))
     return false;
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 
   return true;
 }
@@ -20340,6 +20350,8 @@ elf32_arm_fdpic_omit_section_dynsym (bfd
 #undef ELF_OSABI_EXACT
 #undef elf_backend_omit_section_dynsym
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
+
 /* VxWorks Targets.  */
 
 #undef	TARGET_LITTLE_SYM
@@ -20401,6 +20413,7 @@ elf32_arm_vxworks_final_write_processing
 
 #include "elf32-target.h"
 
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 
 /* Merge backend specific data from an object file to the output
    object file when linking.  */
@@ -20524,10 +20537,13 @@ elf32_arm_merge_private_bfd_data (bfd *i
     }
 
   /* Not sure what needs to be checked for EABI versions >= 1.  */
-  /* VxWorks libraries do not use these flags.  */
-  if (get_elf_backend_data (obfd) != &elf32_arm_vxworks_bed
+  if (EF_ARM_EABI_VERSION (in_flags) == EF_ARM_EABI_UNKNOWN
+#ifdef OBJ_MAYBE_ELF_VXWORKS
+      /* VxWorks libraries do not use these flags.  */
+      && get_elf_backend_data (obfd) != &elf32_arm_vxworks_bed
       && get_elf_backend_data (ibfd) != &elf32_arm_vxworks_bed
-      && EF_ARM_EABI_VERSION (in_flags) == EF_ARM_EABI_UNKNOWN)
+#endif
+      )
     {
       if ((in_flags & EF_ARM_APCS_26) != (out_flags & EF_ARM_APCS_26))
 	{
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -4741,6 +4741,8 @@ elf32_iamcu_elf_object_p (bfd *abfd)
 #define ELF_MACHINE_CODE		EM_386
 #undef	elf_backend_object_p
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
+
 /* VxWorks support.  */
 
 #undef	TARGET_LITTLE_SYM
@@ -4780,3 +4782,5 @@ elf32_iamcu_elf_object_p (bfd *abfd)
 #define elf32_bed				elf32_i386_vxworks_bed
 
 #include "elf32-target.h"
+
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -3611,7 +3611,7 @@ mips_elf32_reloc_type_lookup_rel (bfd *a
 
 /* Given a BFD reloc type, return a howto structure; RELA wrapper.  */
 
-static reloc_howto_type *
+static ATTRIBUTE_UNUSED reloc_howto_type *
 mips_elf32_reloc_type_lookup_rela (bfd *abfd, bfd_reloc_code_real_type code)
 {
   return mips_elf32_reloc_type_lookup (abfd, code,
@@ -3684,7 +3684,7 @@ mips_elf32_reloc_name_lookup_rel (bfd *a
 
 /* Given an ELF reloc name, return a howto structure; RELA wrapper.  */
 
-static reloc_howto_type *
+static ATTRIBUTE_UNUSED reloc_howto_type *
 mips_elf32_reloc_name_lookup_rela (bfd *abfd ATTRIBUTE_UNUSED,
 				   const char *r_name)
 {
@@ -4176,6 +4176,9 @@ static const struct ecoff_debug_swap mip
 #undef elf_backend_write_core_note
 
 #include "elf32-target.h"
+
+#ifdef OBJ_MAYBE_ELF_VXWORKS
+
 /* Implement elf_backend_final_write_processing for VxWorks.  */
 
 static bool
@@ -4257,3 +4260,5 @@ mips_vxworks_final_write_processing (bfd
 #undef bfd_elf32_get_synthetic_symtab
 
 #include "elf32-target.h"
+
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -2476,9 +2476,11 @@ ppc_elf_create_dynamic_sections (bfd *ab
 	return false;
     }
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
   if (htab->elf.target_os == is_vxworks
       && !elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
     return false;
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 
   s = htab->elf.splt;
   flags = SEC_ALLOC | SEC_CODE | SEC_LINKER_CREATED;
@@ -9991,9 +9993,11 @@ ppc_elf_finish_dynamic_sections (bfd *ou
 	      continue;
 
 	    default:
+#ifdef OBJ_MAYBE_ELF_VXWORKS
 	      if (htab->elf.target_os == is_vxworks
 		  && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
 		break;
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 	      continue;
 	    }
 
@@ -10441,6 +10445,8 @@ ppc_elf_finish_dynamic_sections (bfd *ou
 
 #include "elf32-target.h"
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
+
 /* VxWorks Target */
 
 #undef TARGET_LITTLE_SYM
@@ -10556,3 +10562,5 @@ ppc_elf_vxworks_final_write_processing (
 #define elf32_bed				ppc_elf_vxworks_bed
 
 #include "elf32-target.h"
+
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -88,7 +88,7 @@ static reloc_howto_type sh_vxworks_howto
 static bool
 vxworks_object_p (bfd *abfd ATTRIBUTE_UNUSED)
 {
-#if !defined SH_TARGET_ALREADY_DEFINED
+#if defined (OBJ_MAYBE_ELF_VXWORKS) && !defined (SH_TARGET_ALREADY_DEFINED)
   extern const bfd_target sh_elf32_vxworks_le_vec;
   extern const bfd_target sh_elf32_vxworks_vec;
 
@@ -2461,11 +2461,13 @@ sh_elf_create_dynamic_sections (bfd *abf
 	}
     }
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
   if (htab->root.target_os == is_vxworks)
     {
       if (!elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
 	return false;
     }
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 
   return true;
 }
@@ -6278,9 +6280,11 @@ sh_elf_finish_dynamic_sections (bfd *out
 	  switch (dyn.d_tag)
 	    {
 	    default:
+#ifdef OBJ_MAYBE_ELF_VXWORKS
 	      if (htab->root.target_os == is_vxworks
 		  && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
 		bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 	      break;
 
 	    case DT_PLTGOT:
@@ -6689,6 +6693,8 @@ sh_elf_encode_eh_address (bfd *abfd,
 
 #include "elf32-target.h"
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
+
 /* VxWorks support.  */
 #undef	TARGET_BIG_SYM
 #define	TARGET_BIG_SYM			sh_elf32_vxworks_vec
@@ -6727,4 +6733,6 @@ sh_elf_encode_eh_address (bfd *abfd,
 
 #include "elf32-target.h"
 
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
+
 #endif /* not SH_TARGET_ALREADY_DEFINED */
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -319,6 +319,8 @@ elf32_sparc_copy_solaris_special_section
 
 #endif /* OBJ_MAYBE_ELF_SOLARIS2 */
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
+
 /* A final_write_processing hook that does both the SPARC- and VxWorks-
    specific handling.  */
 
@@ -369,3 +371,5 @@ elf32_sparc_vxworks_final_write_processi
 #define elf32_bed				sparc_elf_vxworks_bed
 
 #include "elf32-target.h"
+
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -8259,10 +8259,12 @@ _bfd_mips_elf_create_dynamic_sections (b
   if (!_bfd_elf_create_dynamic_sections (abfd, info))
     return false;
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
   /* Do the usual VxWorks handling.  */
   if (htab->root.target_os == is_vxworks
       && !elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
     return false;
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 
   return true;
 }
@@ -10408,9 +10410,11 @@ _bfd_mips_elf_late_size_sections (bfd *o
 	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_PLTGOT, 0))
 	    return false;
 	}
+#ifdef OBJ_MAYBE_ELF_VXWORKS
       if (htab->root.target_os == is_vxworks
 	  && !elf_vxworks_add_dynamic_entries (output_bfd, info))
 	return false;
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
     }
 
   return true;
@@ -12185,9 +12189,11 @@ _bfd_mips_elf_finish_dynamic_sections (b
 
 	    default:
 	      swap_out_p = false;
+#ifdef OBJ_MAYBE_ELF_VXWORKS
 	      if (htab->root.target_os == is_vxworks
 		  && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
 		swap_out_p = true;
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 	      break;
 	    }
 
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -1212,6 +1212,7 @@ _bfd_sparc_elf_create_dynamic_sections (
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return false;
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
   if (htab->elf.target_os == is_vxworks)
     {
       if (!elf_vxworks_create_dynamic_sections (dynobj, info, &htab->srelplt2))
@@ -1231,6 +1232,7 @@ _bfd_sparc_elf_create_dynamic_sections (
 	    = 4 * ARRAY_SIZE (sparc_vxworks_exec_plt_entry);
 	}
     }
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 
   if (!htab->elf.splt || !htab->elf.srelplt || !htab->elf.sdynbss
       || (!bfd_link_pic (info) && !htab->elf.srelbss))
@@ -4514,9 +4516,11 @@ sparc_finish_dyn (bfd *output_bfd, struc
 	      bed->s->swap_dyn_out (output_bfd, &dyn, dyncon);
 	    }
 	}
+#ifdef OBJ_MAYBE_ELF_VXWORKS
       else if (htab->elf.target_os == is_vxworks
 	       && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
 	bed->s->swap_dyn_out (output_bfd, &dyn, dyncon);
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
       else if (abi_64_p && dyn.d_tag == DT_SPARC_REGISTER)
 	{
 	  if (stt_regidx == -1)
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -2846,9 +2846,11 @@ _bfd_x86_elf_finish_dynamic_sections (bf
       switch (dyn.d_tag)
 	{
 	default:
+#ifdef OBJ_MAYBE_ELF_VXWORKS
 	  if (htab->elf.target_os == is_vxworks
 	      && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
 	    break;
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 	  continue;
 
 	case DT_PLTGOT:
@@ -4690,6 +4692,7 @@ _bfd_x86_elf_link_setup_gnu_properties
       htab->plt.eh_frame_plt = htab->lazy_plt->eh_frame_plt;
     }
 
+#ifdef OBJ_MAYBE_ELF_VXWORKS
   if (htab->elf.target_os == is_vxworks
       && !elf_vxworks_create_dynamic_sections (dynobj, info,
 					       &htab->srelplt2))
@@ -4697,6 +4700,7 @@ _bfd_x86_elf_link_setup_gnu_properties
       info->callbacks->fatal (_("%P: failed to create VxWorks dynamic sections\n"));
       return pbfd;
     }
+#endif /* OBJ_MAYBE_ELF_VXWORKS */
 
   /* Since create_dynamic_sections isn't always called, but GOT
      relocations need GOT relocations, create them here so that we



More information about the Binutils mailing list