Compact elf_backend_data

Alan Modra amodra@gmail.com
Sun Jan 4 07:27:25 GMT 2026


	* elf-bfd.h (struct elf_backend_data): Make arch, elf_osabi,
	elf_machine_code and target_os bitfields, and reorder.  Make
	maxpagesize, minpagesize, commonpagesize and p_align unsigned
	int.
	* elfxx-target.h (elfNN_bed): Reorder to suit.  Delete useless
	comments.

diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index b759d469326..717b0912bb8 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1008,35 +1008,35 @@ typedef uint32_t obj_attr_tag_t;
 struct elf_backend_data
 {
   /* The architecture for this backend.  */
-  enum bfd_architecture arch;
+  ENUM_BITFIELD (bfd_architecture) arch : 8;
+
+  /* EI_OSABI.  */
+  unsigned elf_osabi : 8;
+
+  /* The ELF machine code (EM_xxxx) for this backend.  */
+  unsigned elf_machine_code : 16;
 
   /* An identifier used to distinguish different target specific
      extensions to elf_obj_tdata and elf_link_hash_table structures.  */
-  enum elf_target_id target_id;
+  ENUM_BITFIELD (elf_target_id) target_id : 8;
 
   /* Target OS.  */
-  enum elf_target_os target_os;
-
-  /* The ELF machine code (EM_xxxx) for this backend.  */
-  int elf_machine_code;
-
-  /* EI_OSABI.  */
-  int elf_osabi;
+  ENUM_BITFIELD (elf_target_os) target_os : 2;
 
   /* The maximum page size for this backend.  */
-  bfd_vma maxpagesize;
+  unsigned maxpagesize;
 
   /* The minimum page size for this backend.  An input object will not be
      considered page aligned unless its sections are correctly aligned for
      pages at least this large.  May be smaller than maxpagesize.  */
-  bfd_vma minpagesize;
+  unsigned minpagesize;
 
   /* The common page size for this backend.  */
-  bfd_vma commonpagesize;
+  unsigned commonpagesize;
 
   /* The p_align value for this backend.  If it is set, p_align of
       PT_LOAD alignment will be to p_align by default.  */
-  bfd_vma p_align;
+  unsigned p_align;
 
   /* The BFD flags applied to sections created for dynamic linking.  */
   flagword dynamic_sec_flags;
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index ffda07dfe61..88f8a041ea8 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -806,16 +806,16 @@ extern const struct elf_size_info _bfd_elfNN_size_info ATTRIBUTE_HIDDEN;
 
 static const struct elf_backend_data elfNN_bed =
 {
-  ELF_ARCH,			/* arch */
-  ELF_TARGET_ID,		/* target_id */
-  ELF_TARGET_OS,		/* target_os */
-  ELF_MACHINE_CODE,		/* elf_machine_code */
-  ELF_OSABI,			/* elf_osabi  */
-  ELF_MAXPAGESIZE,		/* maxpagesize */
-  ELF_MINPAGESIZE,		/* minpagesize */
-  ELF_COMMONPAGESIZE,		/* commonpagesize */
-  ELF_P_ALIGN,			/* p_align */
-  ELF_DYNAMIC_SEC_FLAGS,	/* dynamic_sec_flags */
+  ELF_ARCH,
+  ELF_OSABI,
+  ELF_MACHINE_CODE,
+  ELF_TARGET_ID,
+  ELF_TARGET_OS,
+  ELF_MAXPAGESIZE,
+  ELF_MINPAGESIZE,
+  ELF_COMMONPAGESIZE,
+  ELF_P_ALIGN,
+  ELF_DYNAMIC_SEC_FLAGS,
   elf_backend_arch_data,
   elf_info_to_howto,
   elf_info_to_howto_rel,

-- 
Alan Modra


More information about the Binutils mailing list