]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd: avoid elf-properties.c for ELF-free targets
authorJan Beulich <jbeulich@suse.com>
Fri, 9 Jan 2026 07:43:38 +0000 (08:43 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 9 Jan 2026 07:43:38 +0000 (08:43 +0100)
It is absurd to build this file when it's not possibly used. Move its
references to where other elf-*.* are and introduce a compiler define
(paralleling what gas uses, as having the same purpose) to isolate out
ELF-specific pieces in compress.c (which is where the references into
elf-properties.c are coming from).

bfd/Makefile.am
bfd/Makefile.in
bfd/compress.c
bfd/configure
bfd/configure.ac

index cdd4bb637668d149ea79d55b1a75c1050153c04c..deee8b95e073cde823c4322c45e22e41cf1976b6 100644 (file)
@@ -76,7 +76,7 @@ BFD_H = bfd.h
 # debugger).
 BFD32_LIBS = \
        archive.lo archures.lo bfd.lo bfdio.lo cache.lo \
-       coff-bfd.lo compress.lo corefile.lo elf-properties.lo format.lo \
+       coff-bfd.lo compress.lo corefile.lo format.lo \
        hash.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo \
        section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo \
        binary.lo ihex.lo srec.lo tekhex.lo verilog.lo
@@ -85,7 +85,7 @@ BFD64_LIBS = archive64.lo
 
 BFD32_LIBS_CFILES = \
        archive.c archures.c bfd.c bfdio.c cache.c coff-bfd.c \
-       compress.c corefile.c elf-properties.c format.c hash.c \
+       compress.c corefile.c format.c hash.c \
        libbfd.c linker.c merge.c opncls.c reloc.c \
        section.c simple.c stab-syms.c stabs.c syms.c targets.c \
        binary.c ihex.c srec.c tekhex.c verilog.c
@@ -289,6 +289,7 @@ BFD32_BACKENDS = \
        elf-ifunc.lo \
        elf-m10200.lo \
        elf-m10300.lo \
+       elf-properties.lo \
        elf-sframe.lo \
        elf-strtab.lo \
        elf-vxworks.lo \
@@ -422,6 +423,7 @@ BFD32_BACKENDS_CFILES = \
        elf-ifunc.c \
        elf-m10200.c \
        elf-m10300.c \
+       elf-properties.c \
        elf-sframe.c \
        elf-strtab.c \
        elf-vxworks.c \
index 6ef28568ed77f84816d8aaee385b124797c2f721..f68632253329748c5f3f837d35e9f7c90a0edcad 100644 (file)
@@ -181,10 +181,10 @@ am__installdirs = "$(DESTDIR)$(bfdlibdir)" "$(DESTDIR)$(infodir)" \
 LTLIBRARIES = $(bfdlib_LTLIBRARIES) $(noinst_LTLIBRARIES)
 am__DEPENDENCIES_1 =
 am__objects_1 = archive.lo archures.lo bfd.lo bfdio.lo cache.lo \
-       coff-bfd.lo compress.lo corefile.lo elf-properties.lo \
-       format.lo hash.lo libbfd.lo linker.lo merge.lo opncls.lo \
-       reloc.lo section.lo simple.lo stab-syms.lo stabs.lo syms.lo \
-       targets.lo binary.lo ihex.lo srec.lo tekhex.lo verilog.lo
+       coff-bfd.lo compress.lo corefile.lo format.lo hash.lo \
+       libbfd.lo linker.lo merge.lo opncls.lo reloc.lo section.lo \
+       simple.lo stab-syms.lo stabs.lo syms.lo targets.lo binary.lo \
+       ihex.lo srec.lo tekhex.lo verilog.lo
 am_libbfd_la_OBJECTS = $(am__objects_1)
 libbfd_la_OBJECTS = $(am_libbfd_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -545,7 +545,7 @@ BFD_H = bfd.h
 # debugger).
 BFD32_LIBS = \
        archive.lo archures.lo bfd.lo bfdio.lo cache.lo \
-       coff-bfd.lo compress.lo corefile.lo elf-properties.lo format.lo \
+       coff-bfd.lo compress.lo corefile.lo format.lo \
        hash.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo \
        section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo \
        binary.lo ihex.lo srec.lo tekhex.lo verilog.lo
@@ -553,7 +553,7 @@ BFD32_LIBS = \
 BFD64_LIBS = archive64.lo
 BFD32_LIBS_CFILES = \
        archive.c archures.c bfd.c bfdio.c cache.c coff-bfd.c \
-       compress.c corefile.c elf-properties.c format.c hash.c \
+       compress.c corefile.c format.c hash.c \
        libbfd.c linker.c merge.c opncls.c reloc.c \
        section.c simple.c stab-syms.c stabs.c syms.c targets.c \
        binary.c ihex.c srec.c tekhex.c verilog.c
@@ -758,6 +758,7 @@ BFD32_BACKENDS = \
        elf-ifunc.lo \
        elf-m10200.lo \
        elf-m10300.lo \
+       elf-properties.lo \
        elf-sframe.lo \
        elf-strtab.lo \
        elf-vxworks.lo \
@@ -891,6 +892,7 @@ BFD32_BACKENDS_CFILES = \
        elf-ifunc.c \
        elf-m10200.c \
        elf-m10300.c \
+       elf-properties.c \
        elf-sframe.c \
        elf-strtab.c \
        elf-vxworks.c \
index 48bf221baca19b94aeb731b5abef580da782b7e8..c9710178f39eaeaab141ee2dfcc047d30da89e2d 100644 (file)
@@ -24,7 +24,9 @@
 #include <zstd.h>
 #endif
 #include "bfd.h"
+#ifdef OBJ_MAYBE_ELF
 #include "elf-bfd.h"
+#endif
 #include "libbfd.h"
 #include "safe-ctype.h"
 #include "libiberty.h"
@@ -155,6 +157,7 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
 
   switch (bfd_get_flavour (abfd))
     {
+#ifdef OBJ_MAYBE_ELF
     case bfd_target_elf_flavour:
       if ((abfd->flags & BFD_COMPRESS_GABI) != 0)
        {
@@ -195,6 +198,7 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
 
       /* Clear the SHF_COMPRESSED bit.  */
       elf_section_flags (sec) &= ~SHF_COMPRESSED;
+#endif /* OBJ_MAYBE_ELF */
       /* Fall through.  */
 
     default:
@@ -215,12 +219,14 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
    compression header is valid.  */
 
 static bool
-bfd_check_compression_header (bfd *abfd, bfd_byte *contents,
-                             asection *sec,
-                             enum compression_type *ch_type,
-                             bfd_size_type *uncompressed_size,
-                             unsigned int *uncompressed_alignment_power)
+bfd_check_compression_header (bfd *abfd ATTRIBUTE_UNUSED,
+                             bfd_byte *contents ATTRIBUTE_UNUSED,
+                             asection *sec ATTRIBUTE_UNUSED,
+                             enum compression_type *ch_type ATTRIBUTE_UNUSED,
+                             bfd_size_type *uncompressed_size ATTRIBUTE_UNUSED,
+                             unsigned int *uncompressed_alignment_power ATTRIBUTE_UNUSED)
 {
+#ifdef OBJ_MAYBE_ELF
   if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
       && (elf_section_flags (sec) & SHF_COMPRESSED) != 0)
     {
@@ -250,6 +256,7 @@ bfd_check_compression_header (bfd *abfd, bfd_byte *contents,
          return true;
        }
     }
+#endif /* OBJ_MAYBE_ELF */
 
   return false;
 }
@@ -266,8 +273,10 @@ DESCRIPTION
 */
 
 int
-bfd_get_compression_header_size (bfd *abfd, asection *sec)
+bfd_get_compression_header_size (bfd *abfd ATTRIBUTE_UNUSED,
+                                asection *sec ATTRIBUTE_UNUSED)
 {
+#ifdef OBJ_MAYBE_ELF
   if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
     {
       if (sec == NULL)
@@ -283,6 +292,7 @@ bfd_get_compression_header_size (bfd *abfd, asection *sec)
       else
        return sizeof (Elf64_External_Chdr);
     }
+#endif /* OBJ_MAYBE_ELF */
 
   return 0;
 }
@@ -303,11 +313,10 @@ DESCRIPTION
 */
 
 bool
-bfd_convert_section_setup (bfd *ibfd, asection *isec, bfd *obfd,
-                          const char **new_name, bfd_size_type *new_size)
+bfd_convert_section_setup (bfd *ibfd ATTRIBUTE_UNUSED, asection *isec,
+                          bfd *obfd, const char **new_name,
+                          bfd_size_type *new_size)
 {
-  bfd_size_type hdr_size;
-
   if ((isec->flags & SEC_DEBUGGING) != 0
       && (isec->flags & SEC_HAS_CONTENTS) != 0)
     {
@@ -340,6 +349,7 @@ bfd_convert_section_setup (bfd *ibfd, asection *isec, bfd *obfd,
     }
   *new_size = bfd_section_size (isec);
 
+#ifdef OBJ_MAYBE_ELF
   /* Do nothing if either input or output aren't ELF.  */
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
@@ -362,7 +372,7 @@ bfd_convert_section_setup (bfd *ibfd, asection *isec, bfd *obfd,
     return true;
 
   /* Do nothing if the input section isn't a SHF_COMPRESSED section. */
-  hdr_size = bfd_get_compression_header_size (ibfd, isec);
+  bfd_size_type hdr_size = bfd_get_compression_header_size (ibfd, isec);
   if (hdr_size == 0)
     return true;
 
@@ -371,6 +381,9 @@ bfd_convert_section_setup (bfd *ibfd, asection *isec, bfd *obfd,
     *new_size += sizeof (Elf64_External_Chdr) - sizeof (Elf32_External_Chdr);
   else
     *new_size -= sizeof (Elf64_External_Chdr) - sizeof (Elf32_External_Chdr);
+
+#endif /* OBJ_MAYBE_ELF */
+
   return true;
 }
 
@@ -392,9 +405,13 @@ DESCRIPTION
 */
 
 bool
-bfd_convert_section_contents (bfd *ibfd, sec_ptr isec, bfd *obfd,
-                             bfd_byte **ptr, bfd_size_type *ptr_size)
+bfd_convert_section_contents (bfd *ibfd ATTRIBUTE_UNUSED,
+                             sec_ptr isec ATTRIBUTE_UNUSED,
+                             bfd *obfd ATTRIBUTE_UNUSED,
+                             bfd_byte **ptr ATTRIBUTE_UNUSED,
+                             bfd_size_type *ptr_size ATTRIBUTE_UNUSED)
 {
+#ifdef OBJ_MAYBE_ELF
   bfd_byte *contents;
   bfd_size_type ihdr_size, ohdr_size, size;
   Elf_Internal_Chdr chdr;
@@ -499,6 +516,8 @@ bfd_convert_section_contents (bfd *ibfd, sec_ptr isec, bfd *obfd,
     }
 
   *ptr_size = size;
+#endif /* OBJ_MAYBE_ELF */
+
   return true;
 }
 
@@ -666,8 +685,10 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec)
   if (compressed_size >= uncompressed_size)
     {
       memcpy (buffer, input_buffer, uncompressed_size);
+#ifdef OBJ_MAYBE_ELF
       if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
        elf_section_flags (sec) &= ~SHF_COMPRESSED;
+#endif
       sec->compress_status = COMPRESS_SECTION_NONE;
     }
   else
index 0caff54a9e0744bdbf3e5612c47b960d9bf8ea07..fc36a79f184cc55062d8babc57bb75c6b37e65a1 100755 (executable)
@@ -15829,7 +15829,7 @@ selarchs="$f"
 tb=
 
 elf="elf.lo elflink.lo elf-attrs.lo elf-strtab.lo elf-eh-frame.lo
-     elf-sframe.lo dwarf1.lo dwarf2.lo"
+     elf-properties.lo elf-sframe.lo dwarf1.lo dwarf2.lo"
 coffgen="coffgen.lo dwarf2.lo"
 coff="cofflink.lo $coffgen"
 ecoff="ecofflink.lo $coffgen"
@@ -16176,6 +16176,7 @@ if test x${all_targets} = xtrue ; then
     esac
   done
   assocvecs=$f
+  TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF"
 else   # all_targets is true
   # Only set these if they will be nonempty, for the clever echo.
   havevecs=
@@ -16186,6 +16187,12 @@ else   # all_targets is true
     selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
   test -n "$selarchs" &&
     selarchs=`echo $selarchs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
+
+  for i in $bfd_backends ; do
+    case "$i" in
+    elf.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF" ;;
+    esac
+  done
 fi     # all_targets is true
 
 # 64-bit archives need a 64-bit bfd_vma.
index a390761faeb6fb17dc2859d3c980920e0e1b927f..c5e24545dc9cfdadf1b98170076f0bc32e97c6ac 100644 (file)
@@ -370,7 +370,7 @@ selarchs="$f"
 tb=
 
 elf="elf.lo elflink.lo elf-attrs.lo elf-strtab.lo elf-eh-frame.lo
-     elf-sframe.lo dwarf1.lo dwarf2.lo"
+     elf-properties.lo elf-sframe.lo dwarf1.lo dwarf2.lo"
 coffgen="coffgen.lo dwarf2.lo"
 coff="cofflink.lo $coffgen"
 ecoff="ecofflink.lo $coffgen"
@@ -717,6 +717,7 @@ if test x${all_targets} = xtrue ; then
     esac
   done
   assocvecs=$f
+  TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF"
 else   # all_targets is true
   # Only set these if they will be nonempty, for the clever echo.
   havevecs=
@@ -727,6 +728,12 @@ else       # all_targets is true
     selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
   test -n "$selarchs" &&
     selarchs=`echo $selarchs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
+
+  for i in $bfd_backends ; do
+    case "$i" in
+    elf.*) TDEFINES="$TDEFINES -DOBJ_MAYBE_ELF" ;;
+    esac
+  done
 fi     # all_targets is true
 
 # 64-bit archives need a 64-bit bfd_vma.