]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[Morello] Expand GOT entry sizes for C64
authorSiddhesh Poyarekar <siddesh.poyarekar@arm.com>
Fri, 11 Sep 2020 03:48:09 +0000 (09:18 +0530)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 22:53:21 +0000 (15:53 -0700)
Expand GOT slots based on whether we are emitting C64 relocations.
This patch only has infrastructure changes, i.e. it only makes
got_header_size a function and adjusts across architectures.

bfd/ChangeLog:

2020-10-20  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>
    Tamar Christina  <tamar.christina@arm.com>

* elf-bfd.h (elf_backend_data): Make got_header_size a
function.  Add callbacks to all targets that use it.
* elflink.c (_bfd_elf_create_got_section,
bfd_elf_gc_common_finalize_got_offsets,
_bfd_elf_common_section): Adjust got_header_size usage.

53 files changed:
bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf-m10300.c
bfd/elf-vxworks.c
bfd/elf-vxworks.h
bfd/elf32-arc.c
bfd/elf32-arm.c
bfd/elf32-bfin.c
bfd/elf32-cr16.c
bfd/elf32-cris.c
bfd/elf32-csky.c
bfd/elf32-frv.c
bfd/elf32-hppa.c
bfd/elf32-i386.c
bfd/elf32-lm32.c
bfd/elf32-m32r.c
bfd/elf32-m68k.c
bfd/elf32-microblaze.c
bfd/elf32-mips.c
bfd/elf32-nds32.c
bfd/elf32-nios2.c
bfd/elf32-or1k.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-score.c
bfd/elf32-sh.c
bfd/elf32-sparc.c
bfd/elf32-tic6x.c
bfd/elf32-tilegx.c
bfd/elf32-tilepro.c
bfd/elf32-vax.c
bfd/elf32-wasm32.c
bfd/elf32-xtensa.c
bfd/elf64-alpha.c
bfd/elf64-hppa.c
bfd/elf64-ia64-vms.c
bfd/elf64-mips.c
bfd/elf64-ppc.c
bfd/elf64-ppc.h
bfd/elf64-s390.c
bfd/elf64-sparc.c
bfd/elf64-tilegx.c
bfd/elf64-x86-64.c
bfd/elflink.c
bfd/elfn32-mips.c
bfd/elfnn-aarch64.c
bfd/elfnn-ia64.c
bfd/elfnn-loongarch.c
bfd/elfnn-riscv.c
bfd/elfxx-mips.c
bfd/elfxx-target.h
bfd/elfxx-tilegx.c
bfd/elfxx-x86.c

index 6b3981a1640ae6f738eeaa29eaa8458bec51fa2d..49550c9aedce585450bc44df4f128838bdfd60b6 100644 (file)
@@ -1,3 +1,12 @@
+2020-10-20  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>
+           Tamar Christina  <tamar.christina@arm.com>
+
+       * elf-bfd.h (elf_backend_data): Make got_header_size a
+       function.  Add callbacks to all targets that use it.
+       * elflink.c (_bfd_elf_create_got_section,
+       bfd_elf_gc_common_finalize_got_offsets,
+       _bfd_elf_common_section): Adjust got_header_size usage.
+
 2020-10-20  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>
 
        * elfxx-aarch64.c (reencode_ldst_pos_imm): Support loads and
index d05ca3d9a847e2e5e63d00b7f85a6ef3f73c387f..a8150d1ce91b25df12e2ce17650cbec597ca724e 100644 (file)
@@ -1544,9 +1544,9 @@ struct elf_backend_data
   /* An array of target specific special sections.  */
   const struct bfd_elf_special_section *special_sections;
 
-  /* The size in bytes of the header for the GOT.  This includes the
-     so-called reserved entries on some systems.  */
-  bfd_vma got_header_size;
+  /* The size in bytes of the header for the GOT using configuration in INFO.
+     This includes the so-called reserved entries on some systems.  */
+  bfd_vma (*got_header_size) (struct bfd_link_info * info);
 
   /* The size of the GOT entry for the symbol pointed to by H if non-NULL,
      otherwise by the local symbol with index SYMNDX in IBFD.  */
@@ -2670,6 +2670,9 @@ extern unsigned int _bfd_elf_common_section_index
 extern asection *_bfd_elf_common_section
   (asection *);
 
+extern bfd_vma _bfd_elf_default_got_header_size
+(struct bfd_link_info *);
+
 extern bfd_vma _bfd_elf_default_got_elt_size
 (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, bfd *,
  unsigned long);
index 8184ce9d50c16047c596753c90e86868bfa72bf2..0aafcf22503ea2c6b998e2c76096aa865ed1553e 100644 (file)
@@ -765,7 +765,7 @@ _bfd_mn10300_elf_create_got_section (bfd * abfd,
     return false;
 
   /* The first bit of the global offset table is the header.  */
-  s->size += bed->got_header_size;
+  s->size += bed->got_header_size (info);
 
   return true;
 }
@@ -5457,6 +5457,14 @@ mn10300_elf_mkobject (bfd *abfd)
                                  MN10300_ELF_DATA);
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+_bfd_mn10300_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 #define bfd_elf32_mkobject     mn10300_elf_mkobject
 
 #ifndef ELF_ARCH
@@ -5510,11 +5518,12 @@ mn10300_elf_mkobject (bfd *abfd)
   _bfd_mn10300_copy_indirect_symbol
 #define elf_backend_reloc_type_class \
   _bfd_mn10300_elf_reloc_type_class
+#define elf_backend_got_header_size \
+  _bfd_mn10300_elf_got_header_size
 
 #define elf_backend_want_got_plt       1
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
-#define elf_backend_got_header_size    12
 #define elf_backend_dtrel_excludes_plt 1
 
 #include "elf32-target.h"
index 68f92880a8ae5094a531e9f8aacaa5cd1ae43388..6f5274d8be43b4f174c0456dca7eecf89755fdb0 100644 (file)
@@ -309,3 +309,11 @@ _bfd_elf_maybe_vxworks_add_dynamic_tags (bfd *output_bfd,
              || htab->target_os != is_vxworks
              || elf_vxworks_add_dynamic_entries (output_bfd, info)));
 }
+
+/* Determine the size of the header of for the GOT section.  */
+
+bfd_vma
+elf_vxworks_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 4 * 3;
+}
index 1765c5734d8774e0f0d149b578e0e366c807ab09..4c91d64dffad324d7958b0167e62719208baa8d8 100644 (file)
@@ -35,3 +35,4 @@ bool elf_vxworks_add_dynamic_entries (bfd *, struct bfd_link_info *);
 bool elf_vxworks_finish_dynamic_entry (bfd *, Elf_Internal_Dyn *);
 bool _bfd_elf_maybe_vxworks_add_dynamic_tags
   (bfd *, struct bfd_link_info *, bool);
+bfd_vma elf_vxworks_got_header_size (struct bfd_link_info* info);
index d94113154dbe634e4d98180f85fa1c96afda147e..c54740674dfbb4deeb396f2d41a100cd259bbf93 100644 (file)
@@ -2850,6 +2850,14 @@ const struct elf_size_info arc_elf32_size_info =
 
 #define elf_backend_size_info          arc_elf32_size_info
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf_arc_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 /* GDB expects general purpose registers to be in section .reg.  However Linux
    kernel doesn't create this section and instead writes registers to NOTE
    section.  It is up to the binutils to create a pseudo-section .reg from the
@@ -3127,13 +3135,13 @@ arc_elf_relax_section (bfd *abfd, asection *sec,
 
 #define elf_backend_finish_dynamic_sections  elf_arc_finish_dynamic_sections
 #define elf_backend_size_dynamic_sections    elf_arc_size_dynamic_sections
+#define elf_backend_got_header_size         elf_arc_got_header_size
 
 #define elf_backend_can_gc_sections    1
 #define elf_backend_want_got_plt       1
 #define elf_backend_plt_readonly       1
 #define elf_backend_rela_plts_and_copies_p 1
 #define elf_backend_want_plt_sym       0
-#define elf_backend_got_header_size    12
 #define elf_backend_dtrel_excludes_plt 1
 
 #define elf_backend_may_use_rel_p      0
index 5b8f5e5a0e6c8b781e6159f77fd43a6b82a42e05..4339d044ca909a401e16399bb44d0fda2c5d6088 100644 (file)
@@ -9655,7 +9655,8 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
       sgot = htab->root.sgotplt;
       srel = htab->root.srelplt;
 
-      got_header_size = get_elf_backend_data (output_bfd)->got_header_size;
+      got_header_size
+       = get_elf_backend_data (output_bfd)->got_header_size (info);
     }
   BFD_ASSERT (splt != NULL && srel != NULL);
 
@@ -20243,6 +20244,14 @@ elf32_arm_backend_symbol_processing (bfd *abfd, asymbol *sym)
     sym->flags |= BSF_KEEP;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf32_arm_backend_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 #undef  elf_backend_copy_special_section_fields
 #define elf_backend_copy_special_section_fields elf32_arm_copy_special_section_fields
 
@@ -20302,6 +20311,7 @@ elf32_arm_backend_symbol_processing (bfd *abfd, asymbol *sym)
 #define elf_backend_add_symbol_hook            elf32_arm_add_symbol_hook
 #define elf_backend_count_additional_relocs    elf32_arm_count_additional_relocs
 #define elf_backend_symbol_processing          elf32_arm_backend_symbol_processing
+#define elf_backend_got_header_size            elf32_arm_backend_got_header_size
 
 #define elf_backend_can_refcount       1
 #define elf_backend_can_gc_sections    1
@@ -20314,7 +20324,6 @@ elf32_arm_backend_symbol_processing (bfd *abfd, asymbol *sym)
 #define elf_backend_default_use_rela_p 0
 #define elf_backend_dtrel_excludes_plt 1
 
-#define elf_backend_got_header_size    12
 #define elf_backend_extern_protected_data 1
 
 #undef elf_backend_obj_attrs_vendor
index 98812133741a71672ab93dfc2dbcbbaf9bbe615f..3d77665bf624eda053245e57d7fc292e5eadd23d 100644 (file)
@@ -3234,7 +3234,7 @@ _bfin_create_got_section (bfd *abfd, struct bfd_link_info *info)
     }
 
   /* The first bit of the global offset table is the header.  */
-  s->size += bed->got_header_size;
+  s->size += bed->got_header_size (info);
 
   /* This is the machine-specific part.  Create and initialize section
      data for the got.  */
@@ -4695,6 +4695,13 @@ bfinfdpic_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
   return true;
 }
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+bfinfdpic_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
 
 /* Set the right machine number for a Blackfin ELF file.  */
 
@@ -5393,6 +5400,14 @@ bfd_bfin_elf32_create_embedded_relocs (bfd *abfd,
   return false;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf32_bfin_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 struct bfd_elf_special_section const elf32_bfin_special_sections[] =
 {
   { ".l1.text",                8, -2, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
@@ -5452,7 +5467,7 @@ struct bfd_elf_special_section const elf32_bfin_special_sections[] =
 #define elf_backend_want_got_plt 0
 #define elf_backend_plt_readonly 1
 #define elf_backend_want_plt_sym 0
-#define elf_backend_got_header_size    12
+#define elf_backend_got_header_size     elf32_bfin_got_header_size
 #define elf_backend_rela_normal                1
 
 #include "elf32-target.h"
@@ -5465,7 +5480,7 @@ struct bfd_elf_special_section const elf32_bfin_special_sections[] =
 #define        elf32_bed                       elf32_bfinfdpic_bed
 
 #undef elf_backend_got_header_size
-#define elf_backend_got_header_size    0
+#define elf_backend_got_header_size     bfinfdpic_got_header_size
 
 #undef elf_backend_relocate_section
 #define elf_backend_relocate_section   bfinfdpic_relocate_section
index 9764ae76be9805157369ae51e9768e73aec0b6cb..3091dc974d2f7049eebe19e02e6a5b746859ba5e 100644 (file)
@@ -633,7 +633,7 @@ _bfd_cr16_elf_create_got_section (bfd * abfd, struct bfd_link_info * info)
     return false;
 
   /* The first bit of the global offset table is the header.  */
-  s->size += bed->got_header_size;
+  s->size += bed->got_header_size (info);
 
   return true;
 }
@@ -2789,6 +2789,14 @@ _bfd_cr16_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSE
     }
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+_bfd_cr16_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 /* Definitions for setting CR16 target vector.  */
 #define TARGET_LITTLE_SYM                cr16_elf32_vec
 #define TARGET_LITTLE_NAME               "elf32-cr16"
@@ -2835,12 +2843,12 @@ _bfd_cr16_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSE
                                   _bfd_cr16_elf_finish_dynamic_sections
 
 #define elf_backend_reloc_type_class   _bfd_cr16_elf_reloc_type_class
+#define elf_backend_got_header_size    _bfd_cr16_elf_got_header_size
 
 
 #define elf_backend_want_got_plt       1
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
-#define elf_backend_got_header_size    12
 #define elf_backend_dtrel_excludes_plt 1
 
 #include "elf32-target.h"
index 00b5f7745e8944c119abb1efa5f5c2c782db6986..abe1dc63610cceda2d7fd1be80bec256d2b9339d 100644 (file)
@@ -3988,6 +3988,14 @@ elf_cris_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
     }
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf_cris_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 /* The elf_backend_got_elt_size worker.  For one symbol, we can have up to
    two GOT entries from three types with two different sizes.  We handle
    it as a single entry, so we can use the regular offset-calculation
@@ -4107,8 +4115,8 @@ elf_cris_got_elt_size (bfd *abfd ATTRIBUTE_UNUSED,
 #define elf_backend_want_got_plt       1
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
-#define elf_backend_got_header_size    12
-#define elf_backend_got_elt_size elf_cris_got_elt_size
+#define elf_backend_got_header_size    elf_cris_got_header_size
+#define elf_backend_got_elt_size       elf_cris_got_elt_size
 #define elf_backend_dtrel_excludes_plt 1
 #define elf_backend_want_dynrelro      1
 
index 87a879ea01182e22727f56d55134437090b7bf57..5da74d0b42023f547c025a0e14813f6fff1cbc57 100644 (file)
@@ -5304,6 +5304,14 @@ elf32_csky_obj_attrs_handle_unknown (bfd *abfd ATTRIBUTE_UNUSED,
   return true;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+csky_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 /* End of external entry points for sizing and building linker stubs.  */
 
 /* CPU-related basic API.  */
@@ -5352,7 +5360,7 @@ elf32_csky_obj_attrs_handle_unknown (bfd *abfd ATTRIBUTE_UNUSED,
 #define elf_backend_plt_readonly              1
 #define elf_backend_want_got_sym              1
 #define elf_backend_want_dynrelro             1
-#define elf_backend_got_header_size           12
+#define elf_backend_got_header_size           csky_elf_got_header_size
 #define elf_backend_want_got_plt              1
 
 /* C-SKY coredump support.  */
index 02e334f31bb755d798818e2a8cea0825febc2cc9..051984b862c2316394807c6e1ad8c52be75e0241 100644 (file)
@@ -4214,7 +4214,7 @@ _frv_create_got_section (bfd *abfd, struct bfd_link_info *info)
     }
 
   /* The first bit of the global offset table is the header.  */
-  s->size += bed->got_header_size;
+  s->size += bed->got_header_size (info);
 
   /* This is the machine-specific part.  Create and initialize section
      data for the got.  */
@@ -6758,6 +6758,15 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 
   return true;
 }
+
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+frv_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
 #define ELF_ARCH               bfd_arch_frv
 #define ELF_MACHINE_CODE       EM_CYGNUS_FRV
 #define ELF_MAXPAGESIZE                0x1000
@@ -6783,7 +6792,7 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 #define bfd_elf32_bfd_print_private_bfd_data   frv_elf_print_private_bfd_data
 
 #define elf_backend_want_got_sym       1
-#define elf_backend_got_header_size    0
+#define elf_backend_got_header_size    frv_elf_got_header_size
 #define elf_backend_want_got_plt       0
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
index 153a3ce11e1052cd1ed1d22080de8f5a106e7b3b..ccbe6eecd8add0b5bb9dc6ffc298aa01ea7a00cc 100644 (file)
@@ -4430,6 +4430,14 @@ elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type)
     return type;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf32_hppa_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 8;
+}
+
 /* Misc BFD support code.  */
 #define bfd_elf32_bfd_is_local_label_name    elf_hppa_is_local_label_name
 #define bfd_elf32_bfd_reloc_type_lookup             elf_hppa_reloc_type_lookup
@@ -4467,7 +4475,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type)
 #define elf_backend_want_got_plt            0
 #define elf_backend_plt_readonly            0
 #define elf_backend_want_plt_sym            0
-#define elf_backend_got_header_size         8
+#define elf_backend_got_header_size         elf32_hppa_got_header_size
 #define elf_backend_want_dynrelro           1
 #define elf_backend_rela_normal                     1
 #define elf_backend_dtrel_excludes_plt      1
index fb5ed161f50c4cde39e8d7b24fe843fe18aaad09..69314e9dbae1040b2d8407fe3bea82b0b802e6ec 100644 (file)
@@ -4400,6 +4400,14 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
   return _bfd_x86_elf_link_setup_gnu_properties (info, &init_table);
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf_i386_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 #define TARGET_LITTLE_SYM              i386_elf32_vec
 #define TARGET_LITTLE_NAME             "elf32-i386"
 #define ELF_ARCH                       bfd_arch_i386
@@ -4412,7 +4420,7 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
 #define elf_backend_want_got_plt       1
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
-#define elf_backend_got_header_size    12
+#define elf_backend_got_header_size    elf_i386_got_header_size
 #define elf_backend_plt_alignment      4
 #define elf_backend_dtrel_excludes_plt 1
 #define elf_backend_extern_protected_data 1
index 3dc84920e086b5ea89a784c013663213e8e2a68e..c501d13bd17b321c79d732613cd3365ab0a7207d 100644 (file)
@@ -2367,6 +2367,13 @@ lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
   return true;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+lm32_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
 
 #define ELF_ARCH               bfd_arch_lm32
 #define ELF_TARGET_ID          LM32_ELF_DATA
@@ -2390,7 +2397,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 #define elf_backend_plt_readonly               1
 #define elf_backend_want_got_plt               1
 #define elf_backend_want_plt_sym               0
-#define elf_backend_got_header_size            12
+#define elf_backend_got_header_size            lm32_elf_got_header_size
 #define elf_backend_dtrel_excludes_plt         1
 #define bfd_elf32_bfd_link_hash_table_create   lm32_elf_link_hash_table_create
 #define elf_backend_check_relocs               lm32_elf_check_relocs
index 825cb23bbb6ef9fbb5ec6f131ad185a4ce8de3cb..38de7377a6ce5e45cdc3e329aa8a5de9019c4c78 100644 (file)
@@ -3635,7 +3635,15 @@ m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
     default:              return reloc_class_normal;
     }
 }
-\f
+
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+m32r_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 #define ELF_ARCH               bfd_arch_m32r
 #define ELF_TARGET_ID          M32R_ELF_DATA
 #define ELF_MACHINE_CODE       EM_M32R
@@ -3673,7 +3681,7 @@ m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
 #define elf_backend_want_got_plt 1
 #define elf_backend_plt_readonly 1
 #define elf_backend_want_plt_sym 0
-#define elf_backend_got_header_size 12
+#define elf_backend_got_header_size    m32r_elf_got_header_size
 #define elf_backend_dtrel_excludes_plt 1
 
 #define elf_backend_may_use_rel_p      1
index 6991e70019f73ad6b3ed58407b23c587ee9a794c..212beef3d004eedda059b99dd8188974c74b1377 100644 (file)
@@ -4617,6 +4617,14 @@ elf_m68k_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
   return true;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf32_m68k_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 #define TARGET_BIG_SYM                 m68k_elf32_vec
 #define TARGET_BIG_NAME                        "elf32-m68k"
 #define ELF_MACHINE_CODE               EM_68K
@@ -4660,7 +4668,7 @@ elf_m68k_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 #define elf_backend_want_got_plt 1
 #define elf_backend_plt_readonly 1
 #define elf_backend_want_plt_sym 0
-#define elf_backend_got_header_size    12
+#define elf_backend_got_header_size    elf32_m68k_got_header_size
 #define elf_backend_rela_normal                1
 #define elf_backend_dtrel_excludes_plt 1
 
index d09b3f7095db60eeb1aa86ab734a6b19cfc6c3bc..5c0788ce8b9247ec769df68a1a470ade7f73e02d 100644 (file)
@@ -3393,6 +3393,14 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
   return true;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+microblaze_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 #define TARGET_LITTLE_SYM      microblaze_elf32_le_vec
 #define TARGET_LITTLE_NAME     "elf32-microblazeel"
 
@@ -3422,7 +3430,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
 #define elf_backend_can_refcount               1
 #define elf_backend_want_got_plt               1
 #define elf_backend_plt_readonly               1
-#define elf_backend_got_header_size            12
+#define elf_backend_got_header_size            microblaze_elf_got_header_size
 #define elf_backend_want_dynrelro              1
 #define elf_backend_rela_normal                        1
 #define elf_backend_dtrel_excludes_plt         1
index a4c88c6b089ef2a2613793cd0f628c706276bffd..8825384caa6308a1690ffb040d9cf8293b649396 100644 (file)
@@ -2495,7 +2495,15 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
   /* Function to read in symbolic data.  */
   _bfd_mips_elf_read_ecoff_info
 };
-\f
+
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf32_mips_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 4 * MIPS_RESERVED_GOTNO;
+}
+
 #define ELF_ARCH                       bfd_arch_mips
 #define ELF_TARGET_ID                  MIPS_ELF_DATA
 #define ELF_MACHINE_CODE               EM_MIPS
@@ -2550,7 +2558,7 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #define elf_backend_grok_psinfo                elf32_mips_grok_psinfo
 #define elf_backend_ecoff_debug_swap   &mips_elf32_ecoff_debug_swap
 
-#define elf_backend_got_header_size    (4 * MIPS_RESERVED_GOTNO)
+#define elf_backend_got_header_size    elf32_mips_got_header_size
 #define elf_backend_want_dynrelro      1
 #define elf_backend_may_use_rel_p      1
 #define elf_backend_may_use_rela_p     0
@@ -2696,7 +2704,7 @@ mips_vxworks_final_write_processing (bfd *abfd)
 #undef elf_backend_default_use_rela_p
 #define elf_backend_default_use_rela_p         1
 #undef elf_backend_got_header_size
-#define elf_backend_got_header_size            (4 * 3)
+#define elf_backend_got_header_size            elf_vxworks_got_header_size
 #undef elf_backend_dtrel_excludes_plt
 #define elf_backend_dtrel_excludes_plt         1
 
index 519c82833615a34522d41e2d2ee068076a1d2a0a..8829326075531a40eb753f8114495a212d90f8bc 100644 (file)
@@ -13902,6 +13902,14 @@ nds32_elf_unify_tls_model (bfd *inbfd, asection *insec, bfd_byte *incontents,
 }
 
 /* End TLS model conversion.  */
+\f
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+nds32_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
 
 #define ELF_ARCH                               bfd_arch_nds32
 #define ELF_MACHINE_CODE                       EM_NDS32
@@ -13953,7 +13961,7 @@ nds32_elf_unify_tls_model (bfd *inbfd, asection *insec, bfd_byte *incontents,
 #define elf_backend_want_got_plt               1
 #define elf_backend_plt_readonly               1
 #define elf_backend_want_plt_sym               0
-#define elf_backend_got_header_size            12
+#define elf_backend_got_header_size            nds32_elf_got_header_size
 #define elf_backend_may_use_rel_p              1
 #define elf_backend_default_use_rela_p         1
 #define elf_backend_may_use_rela_p             1
index 93e503bbd797328e93809deab1290482e779436a..909f6e999d37ad85c8ef1fd9c8e25eae3032b148 100644 (file)
@@ -6000,6 +6000,14 @@ nios2_elf32_can_make_relative_eh_frame (bfd *input_bfd ATTRIBUTE_UNUSED,
   return false;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+nios2_elf32_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 /* Implement elf_backend_special_sections.  */
 const struct bfd_elf_special_section elf32_nios2_special_sections[] =
 {
@@ -6077,7 +6085,7 @@ const struct bfd_elf_special_section elf32_nios2_special_sections[] =
 #define TARGET_BIG_SYM                 nios2_elf32_be_vec
 #define TARGET_BIG_NAME                        "elf32-bignios2"
 
-#define elf_backend_got_header_size    12
+#define elf_backend_got_header_size    nios2_elf32_got_header_size
 #define elf_backend_default_execstack  0
 
 #include "elf32-target.h"
index 2a06b3e19e6c54067adb7e9c582b9949a10571ad..49e1935e66ff30e1c01cd9b03054eec41618abae 100644 (file)
@@ -3366,6 +3366,13 @@ or1k_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
   return true;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+or1k_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
 
 #define ELF_ARCH                       bfd_arch_or1k
 #define ELF_MACHINE_CODE               EM_OR1K
@@ -3398,7 +3405,7 @@ or1k_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 #define elf_backend_plt_readonly               1
 #define elf_backend_want_got_plt               1
 #define elf_backend_want_plt_sym               0
-#define elf_backend_got_header_size            12
+#define elf_backend_got_header_size            or1k_elf_got_header_size
 #define elf_backend_dtrel_excludes_plt         1
 #define elf_backend_want_dynrelro              1
 
index 42273ca06fe740fa82e3b6d3143f6632b50b7a60..a01e904de421a0cef346b0258a93292d79b2d354 100644 (file)
@@ -10534,7 +10534,7 @@ ppc_elf_vxworks_final_write_processing (bfd *abfd)
 #undef elf_backend_plt_readonly
 #define elf_backend_plt_readonly               1
 #undef elf_backend_got_header_size
-#define elf_backend_got_header_size            12
+#define elf_backend_got_header_size            elf_vxworks_got_header_size
 #undef elf_backend_dtrel_excludes_plt
 #define elf_backend_dtrel_excludes_plt         1
 
index 2934f18c8b8ca2a320418f5b10338ca440f67a51..b65be2a3697f0fad6486153202a71077aa64492b 100644 (file)
@@ -3890,6 +3890,14 @@ elf32_s390_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   return true;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf_s390_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 
 #define TARGET_BIG_SYM s390_elf32_vec
 #define TARGET_BIG_NAME        "elf32-s390"
@@ -3904,7 +3912,7 @@ elf32_s390_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 #define elf_backend_want_got_plt       1
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
-#define elf_backend_got_header_size    12
+#define elf_backend_got_header_size    elf_s390_got_header_size
 #define elf_backend_want_dynrelro      1
 #define elf_backend_rela_normal                1
 
index c868707347c28bb09936a4817b9abd27531595aa..68f564f05b80c1e34a512a09c590c14c31791054 100644 (file)
@@ -4395,6 +4395,14 @@ elf32_score_new_section_hook (bfd *abfd, asection *sec)
     return s7_elf32_score_new_section_hook (abfd, sec);
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf32_score_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 4 * SCORE_RESERVED_GOTNO;
+}
+
 
 /* s3_s7: don't need to split.  */
 
@@ -4479,7 +4487,7 @@ _bfd_score_elf_common_definition (Elf_Internal_Sym *sym)
 #define elf_backend_grok_psinfo                  _bfd_score_elf_grok_psinfo
 #define elf_backend_can_gc_sections      1
 #define elf_backend_want_plt_sym         0
-#define elf_backend_got_header_size      (4 * SCORE_RESERVED_GOTNO)
+#define elf_backend_got_header_size       elf32_score_got_header_size
 #define elf_backend_plt_header_size      0
 #define elf_backend_collect              true
 #define elf_backend_type_change_ok       true
index 73b861e18f3e2f180d9a7698472e63ce4e0b6d32..06c8f82855aab1a2a38499783b6cf75e566f8ae6 100644 (file)
@@ -6546,6 +6546,14 @@ sh_elf_encode_eh_address (bfd *abfd,
   return DW_EH_PE_datarel | DW_EH_PE_sdata4;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+sh_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 12;
+}
+
 #if !defined SH_TARGET_ALREADY_DEFINED
 #define TARGET_BIG_SYM         sh_elf32_vec
 #define TARGET_BIG_NAME                "elf32-sh"
@@ -6613,7 +6621,7 @@ sh_elf_encode_eh_address (bfd *abfd,
 #define elf_backend_want_got_plt       1
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
-#define elf_backend_got_header_size    12
+#define elf_backend_got_header_size    sh_elf_got_header_size
 #define elf_backend_dtrel_excludes_plt 1
 
 #define elf_backend_linux_prpsinfo32_ugid16    true
index 1bfd40e9ae583792d10c4e6542383ccd5caf4998..e66a0e38d3b8c4b152f591318641b3ce3c4d536f 100644 (file)
@@ -216,6 +216,14 @@ elf32_sparc_reloc_type_class (const struct bfd_link_info *info,
     }
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf32_sparc_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 4;
+}
+
 #define TARGET_BIG_SYM sparc_elf32_vec
 #define TARGET_BIG_NAME        "elf32-sparc"
 #define ELF_ARCH       bfd_arch_sparc
@@ -267,7 +275,7 @@ elf32_sparc_reloc_type_class (const struct bfd_link_info *info,
 #define elf_backend_want_got_plt 0
 #define elf_backend_plt_readonly 0
 #define elf_backend_want_plt_sym 1
-#define elf_backend_got_header_size 4
+#define elf_backend_got_header_size    elf32_sparc_got_header_size
 #define elf_backend_want_dynrelro 1
 #define elf_backend_rela_normal 1
 
@@ -335,7 +343,7 @@ elf32_sparc_vxworks_final_write_processing (bfd *abfd)
 #undef  elf_backend_plt_readonly
 #define elf_backend_plt_readonly               1
 #undef  elf_backend_got_header_size
-#define elf_backend_got_header_size            12
+#define elf_backend_got_header_size            elf_vxworks_got_header_size
 #undef  elf_backend_dtrel_excludes_plt
 #define elf_backend_dtrel_excludes_plt         1
 #undef  elf_backend_add_symbol_hook
index c90daf941fc3eee6bf2964e02040336766885fbd..801b229090696f99e3fb8d4414f4d1148964531c 100644 (file)
@@ -1759,7 +1759,7 @@ elf32_tic6x_finish_dynamic_symbol (bfd * output_bfd,
         For static executables, we don't reserve anything.  */
 
       plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
-      got_section_offset = plt_index + bed->got_header_size / 4;
+      got_section_offset = plt_index + bed->got_header_size (info) / 4;
       got_dp_offset = got_section_offset + htab->params.dsbt_size;
       rela_offset = plt_index * sizeof (Elf32_External_Rela);
 
@@ -4212,6 +4212,14 @@ elf32_tic6x_write_section (bfd *output_bfd,
 
 #define        elf32_bed               elf32_tic6x_bed
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf32_tic6x_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 8;
+}
+
 #define TARGET_LITTLE_SYM      tic6x_elf32_le_vec
 #define TARGET_LITTLE_NAME     "elf32-tic6x-le"
 #define TARGET_BIG_SYM         tic6x_elf32_be_vec
@@ -4243,7 +4251,7 @@ elf32_tic6x_write_section (bfd *output_bfd,
 #define elf_backend_want_dynrelro      1
 #define elf_backend_plt_readonly       1
 #define elf_backend_rela_normal                1
-#define elf_backend_got_header_size     8
+#define elf_backend_got_header_size     elf32_tic6x_got_header_size
 #define elf_backend_fake_sections       elf32_tic6x_fake_sections
 #define elf_backend_gc_mark_extra_sections elf32_tic6x_gc_mark_extra_sections
 #define elf_backend_create_dynamic_sections \
index 10dd4effe777b82cc1850bf85f965914da77bcac..4c7f122afafbfb23e377f2c13999c26fdae717ed 100644 (file)
@@ -80,6 +80,13 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
   return true;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+tilegx_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 4;
+}
 
 #define ELF_ARCH               bfd_arch_tilegx
 #define ELF_TARGET_ID          TILEGX_ELF_DATA
@@ -126,7 +133,7 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 /* Align PLT mod 64 byte L2 line size. */
 #define elf_backend_plt_alignment 6
 #define elf_backend_want_plt_sym 1
-#define elf_backend_got_header_size 4
+#define elf_backend_got_header_size         tilegx_elf_got_header_size
 #define elf_backend_want_dynrelro 1
 #define elf_backend_rela_normal 1
 #define elf_backend_default_execstack 0
index 2495539c7f7f153aa3fdb32fce4db7c793592dee..d9b0987c8b39a4fec6b2926510769811d54c04b5 100644 (file)
@@ -1228,7 +1228,7 @@ tilepro_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
   htab->sgot = s;
 
   /* The first bit of the global offset table is the header.  */
-  s->size += bed->got_header_size;
+  s->size += bed->got_header_size (info);
 
   if (bed->want_got_plt)
     {
@@ -2311,7 +2311,8 @@ tilepro_elf_size_dynamic_sections (bfd *output_bfd,
              || htab->splt->size == 0)
          && (htab->sgot == NULL
              || (htab->sgot->size
-                 == get_elf_backend_data (output_bfd)->got_header_size)))
+                 == get_elf_backend_data (output_bfd)->
+                       got_header_size (info))))
        htab->sgotplt->size = 0;
     }
 
@@ -3719,6 +3720,14 @@ tilepro_additional_program_headers (bfd *abfd,
   return count;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+tilepro_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return GOT_ENTRY_SIZE;
+}
+
 #define ELF_ARCH               bfd_arch_tilepro
 #define ELF_TARGET_ID          TILEPRO_ELF_DATA
 #define ELF_MACHINE_CODE       EM_TILEPRO
@@ -3762,7 +3771,7 @@ tilepro_additional_program_headers (bfd *abfd,
 /* Align PLT mod 64 byte L2 line size. */
 #define elf_backend_plt_alignment 6
 #define elf_backend_want_plt_sym 1
-#define elf_backend_got_header_size GOT_ENTRY_SIZE
+#define elf_backend_got_header_size         tilepro_elf_got_header_size
 #define elf_backend_want_dynrelro 1
 #define elf_backend_rela_normal 1
 #define elf_backend_default_execstack 0
index 4e290d55fed4022de34143349f9e42b4c3a58cb5..1e558165904d27fb05bf0018f35e35e1b85b82af 100644 (file)
@@ -1847,6 +1847,14 @@ elf_vax_plt_sym_val (bfd_vma i, const asection *plt,
   return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf_vax_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 16;
+}
+
 #define TARGET_LITTLE_SYM              vax_elf32_vec
 #define TARGET_LITTLE_NAME             "elf32-vax"
 #define ELF_MACHINE_CODE               EM_VAX
@@ -1885,7 +1893,7 @@ elf_vax_plt_sym_val (bfd_vma i, const asection *plt,
 #define elf_backend_want_got_plt       1
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
-#define elf_backend_got_header_size    16
+#define elf_backend_got_header_size    elf_vax_got_header_size
 #define elf_backend_rela_normal                1
 #define elf_backend_dtrel_excludes_plt 1
 
index 999ab58d7dbfe4db5e6912959e2b8eb7968fa2e0..42065f482189f70f35084ac639f9c011226668f4 100644 (file)
@@ -127,6 +127,14 @@ elf32_wasm32_info_to_howto_rela (bfd *abfd,
   return cache_ptr->howto != NULL;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf32_wasm32_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
 #define ELF_ARCH               bfd_arch_wasm32
 #define ELF_TARGET_ID          EM_WEBASSEMBLY
 #define ELF_MACHINE_CODE       EM_WEBASSEMBLY
@@ -152,6 +160,6 @@ elf32_wasm32_info_to_howto_rela (bfd *abfd,
 
 #define elf_backend_want_got_plt       1
 #define elf_backend_plt_readonly       1
-#define elf_backend_got_header_size    0
+#define elf_backend_got_header_size    elf32_wasm32_got_header_size
 
 #include "elf32-target.h"
index f1839e61950be1d4789ed653f4aa9106a5f0da28..f58c400bec987ee06ba4dddfe7264c6ed0b456f0 100644 (file)
@@ -11488,6 +11488,14 @@ xtensa_callback_required_dependence (bfd *abfd,
   return ok;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf_xtensa_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 4;
+}
+
 /* The default literal sections should always be marked as "code" (i.e.,
    SHF_EXECINSTR).  This is particularly important for the Linux kernel
    module loader so that the literals are not placed after the text.  */
@@ -11517,7 +11525,7 @@ static const struct bfd_elf_special_section elf_xtensa_special_sections[] =
 #define elf_backend_can_gc_sections    1
 #define elf_backend_can_refcount       1
 #define elf_backend_plt_readonly       1
-#define elf_backend_got_header_size    4
+#define elf_backend_got_header_size    elf_xtensa_got_header_size
 #define elf_backend_want_dynbss                0
 #define elf_backend_want_got_plt       1
 #define elf_backend_dtrel_excludes_plt 1
index f850db938907d90ad5f09823b2f8edb86a5e2a83..82154a44344704ac305a4b2625a96bc28a48c5a7 100644 (file)
@@ -5327,6 +5327,14 @@ elf64_alpha_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
       return reloc_class_normal;
     }
 }
+
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf64_alpha_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
 \f
 static const struct bfd_elf_special_section elf64_alpha_special_sections[] =
 {
@@ -5501,7 +5509,7 @@ static const struct elf_size_info alpha_elf_size_info =
 #define elf_backend_want_got_plt 0
 #define elf_backend_plt_readonly 0
 #define elf_backend_want_plt_sym 1
-#define elf_backend_got_header_size 0
+#define elf_backend_got_header_size elf64_alpha_got_header_size
 #define elf_backend_dtrel_excludes_plt 1
 
 #include "elf64-target.h"
index 030e6e3a189aa711c6eeba8d1459b2ab00bdab16..272ecdd565467624a3a79976f0eba819c7d09b67 100644 (file)
@@ -3904,6 +3904,14 @@ elf64_hppa_relocate_section (bfd *output_bfd,
   return true;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf64_hppa_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
 static const struct bfd_elf_special_section elf64_hppa_special_sections[] =
 {
   { STRING_COMMA_LEN (".tbss"),         0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_HP_TLS },
@@ -4019,7 +4027,7 @@ const struct elf_size_info hppa64_elf_size_info =
 #define elf_backend_want_got_plt       0
 #define elf_backend_plt_readonly       0
 #define elf_backend_want_plt_sym       0
-#define elf_backend_got_header_size     0
+#define elf_backend_got_header_size     elf64_hppa_got_header_size
 #define elf_backend_type_change_ok     true
 #define elf_backend_get_symbol_type    elf64_hppa_elf_get_symbol_type
 #define elf_backend_reloc_type_class   elf64_hppa_reloc_type_class
index 59cc6b6fe85986087f6c4949dd328c02dfce58b8..4bfc78f7623f47b043cb279a19854212a662b875 100644 (file)
@@ -5414,6 +5414,14 @@ elf64_ia64_vms_mkobject (bfd *abfd)
     (abfd, sizeof (struct elf64_ia64_vms_obj_tdata), IA64_ELF_DATA);
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf64_ia64_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
 
 /* Size-dependent data and functions.  */
 static const struct elf_size_info elf64_ia64_vms_size_info = {
@@ -5507,7 +5515,7 @@ static const struct elf_size_info elf64_ia64_vms_size_info = {
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
 #define elf_backend_plt_alignment      5
-#define elf_backend_got_header_size    0
+#define elf_backend_got_header_size    elf64_ia64_got_header_size
 #define elf_backend_want_got_plt       1
 #define elf_backend_may_use_rel_p      1
 #define elf_backend_may_use_rela_p     1
index 6fa9d44300c5d62abbc2874eda054e3e3665b7e4..4e3e1aa8e1d883ca44eee669f7b7fabced7b708b 100644 (file)
@@ -4632,6 +4632,14 @@ elf64_mips_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
       }
     }
 }
+
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf64_mips_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 8 * MIPS_RESERVED_GOTNO;
+}
 \f
 /* ECOFF swapping routines.  These are used when dealing with the
    .mdebug section, which is in the ECOFF debugging format.  */
@@ -4770,7 +4778,7 @@ const struct elf_size_info mips_elf64_size_info =
 #define elf_backend_grok_prstatus      elf64_mips_grok_prstatus
 #define elf_backend_grok_psinfo                elf64_mips_grok_psinfo
 
-#define elf_backend_got_header_size    (8 * MIPS_RESERVED_GOTNO)
+#define elf_backend_got_header_size    elf64_mips_got_header_size
 #define elf_backend_want_dynrelro      1
 
 /* MIPS ELF64 can use a mixture of REL and RELA, but some Relocations
index f4d2bf053c330c80a29e338fc0adf375f2e3e402..29cd537aab65545b35664fbe38f4d27a0b2bccae 100644 (file)
@@ -81,7 +81,7 @@ static bfd_vma opd_entry_value
 #define elf_backend_want_plt_sym 0
 #define elf_backend_plt_alignment 3
 #define elf_backend_plt_not_loaded 1
-#define elf_backend_got_header_size 8
+#define elf_backend_got_header_size ppc64_elf_got_header_size
 #define elf_backend_want_dynrelro 1
 #define elf_backend_can_gc_sections 1
 #define elf_backend_can_refcount 1
@@ -18332,6 +18332,14 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd,
   return true;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+bfd_vma
+ppc64_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 8;
+}
+
 #include "elf64-target.h"
 
 /* FreeBSD support */
index 5dbffc9ee2edb96ca7d225c92717d5682c95a080..c1c839dc96d29d5439e38bd8a16a84cdcb6e13b5 100644 (file)
@@ -109,3 +109,5 @@ bool ppc64_elf_size_stubs
 (struct bfd_link_info *);
 bool ppc64_elf_build_stubs
   (struct bfd_link_info *, char **);
+bfd_vma ppc64_elf_got_header_size
+  (struct bfd_link_info *);
index e780efa7181fdabad846926b1e25eef5cdb02348..4d63e1b22cd31ffea06a4e3c373b39d59b6c7802 100644 (file)
@@ -3793,6 +3793,14 @@ elf_s390_modify_segment_map (bfd *abfd, struct bfd_link_info *info)
   return true;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf_s390_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 24;
+}
+
 bool
 bfd_elf_s390_set_options (struct bfd_link_info *info,
                          struct s390_elf_params *params)
@@ -3860,7 +3868,7 @@ const struct elf_size_info s390_elf64_size_info =
 #define elf_backend_want_got_plt       1
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
-#define elf_backend_got_header_size    24
+#define elf_backend_got_header_size    elf_s390_got_header_size
 #define elf_backend_want_dynrelro      1
 #define elf_backend_rela_normal                1
 
index e9f03cf8e3a86bb79da458726ae3c3e1363c11eb..cbda9ec01091451007395fa35332f193f9d4362a 100644 (file)
@@ -829,6 +829,14 @@ elf64_sparc_reloc_type_class (const struct bfd_link_info *info,
     }
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf64_sparc_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 8;
+}
+
 /* Relocations in the 64 bit SPARC ELF ABI are more complex than in
    standard ELF, because R_SPARC_OLO10 has secondary addend in
    ELF64_R_TYPE_DATA field.  This structure is used to redirect the
@@ -963,7 +971,7 @@ const struct elf_size_info elf64_sparc_size_info =
 #define elf_backend_want_got_plt 0
 #define elf_backend_plt_readonly 0
 #define elf_backend_want_plt_sym 1
-#define elf_backend_got_header_size 8
+#define elf_backend_got_header_size elf64_sparc_got_header_size
 #define elf_backend_want_dynrelro 1
 #define elf_backend_rela_normal 1
 
index aae2b098f0fc846c9f881cde7eb98e3306142f35..55892d126ca60b5c0bdfa4f2c421bb801406efe4 100644 (file)
@@ -80,6 +80,13 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
   return true;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+tilegx_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 8;
+}
 
 #define ELF_ARCH               bfd_arch_tilegx
 #define ELF_TARGET_ID          TILEGX_ELF_DATA
@@ -127,7 +134,7 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 /* Align PLT mod 64 byte L2 line size. */
 #define elf_backend_plt_alignment 6
 #define elf_backend_want_plt_sym 1
-#define elf_backend_got_header_size 8
+#define elf_backend_got_header_size tilegx_elf_got_header_size
 #define elf_backend_want_dynrelro 1
 #define elf_backend_rela_normal 1
 #define elf_backend_default_execstack 0
index b5718e71121fc58d6bf7277b81f57a45bdd42890..3c505f99207260c4a6f228aae6220b8595af1560 100644 (file)
@@ -5235,6 +5235,14 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info)
   return _bfd_x86_elf_link_setup_gnu_properties (info, &init_table);
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf_x86_64_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return GOT_ENTRY_SIZE * 3;
+}
+
 static const struct bfd_elf_special_section
 elf_x86_64_special_sections[]=
 {
@@ -5264,7 +5272,7 @@ elf_x86_64_special_sections[]=
 #define elf_backend_want_got_plt           1
 #define elf_backend_plt_readonly           1
 #define elf_backend_want_plt_sym           0
-#define elf_backend_got_header_size        (GOT_ENTRY_SIZE*3)
+#define elf_backend_got_header_size        elf_x86_64_got_header_size
 #define elf_backend_rela_normal                    1
 #define elf_backend_plt_alignment          4
 #define elf_backend_extern_protected_data   1
index 5a070a26e35509784c6c7615b7f9c477251c2234..ed203a03b3f0b4b8b355b95ebd42d7da0745a686 100644 (file)
@@ -187,7 +187,7 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
     }
 
   /* The first bit of the global offset table is the header.  */
-  s->size += bed->got_header_size;
+  s->size += bed->got_header_size (info);
 
   if (bed->want_got_sym)
     {
@@ -14629,7 +14629,7 @@ bfd_elf_gc_common_finalize_got_offsets (bfd *abfd,
   if (bed->want_got_plt)
     gotoff = 0;
   else
-    gotoff = bed->got_header_size;
+    gotoff = bed->got_header_size (info);
 
   /* Do the local .got entries first.  */
   for (i = info->input_bfds; i; i = i->link.next)
@@ -15065,6 +15065,14 @@ _bfd_elf_common_section (asection *sec ATTRIBUTE_UNUSED)
   return bfd_com_section_ptr;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+bfd_vma
+_bfd_elf_default_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
 bfd_vma
 _bfd_elf_default_got_elt_size (bfd *abfd,
                               struct bfd_link_info *info ATTRIBUTE_UNUSED,
index 1ae51a4648ce3989fe8bc3e8d86ee0a54a00a5e4..b82c0c2bd2c29692172ba8344877459ccb2fb6cd 100644 (file)
@@ -4028,6 +4028,15 @@ elf32_mips_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
     }
 }
 \f
+
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elf32_mips_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 4 * MIPS_RESERVED_GOTNO;
+}
+
 /* Depending on the target vector we generate some version of Irix
    executables or "normal" MIPS ELF ABI executables.  */
 static irix_compat_t
@@ -4153,7 +4162,7 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
                                        elf_n32_mips_grok_freebsd_prstatus
 #define elf_backend_ecoff_debug_swap   &mips_elf32_ecoff_debug_swap
 
-#define elf_backend_got_header_size    (4 * MIPS_RESERVED_GOTNO)
+#define elf_backend_got_header_size    elf32_mips_got_header_size
 #define elf_backend_want_dynrelro      1
 
 /* MIPS n32 ELF can use a mixture of REL and RELA, but some Relocations
index bd37caf7858ee2454697d177bce807947ebed75c..e4c2bad6bc2610be2bcabd1dd88073caf9e678c8 100644 (file)
@@ -7985,7 +7985,7 @@ aarch64_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
     }
 
   /* The first bit of the global offset table is the header.  */
-  s->size += bed->got_header_size;
+  s->size += bed->got_header_size (info);
 
   return true;
 }
@@ -10411,6 +10411,15 @@ aarch64_elfNN_swap_symbol_out (bfd *abfd,
   bfd_elfNN_swap_symbol_out (abfd, &newsym, cdst, shndx);
 }
 
+/* Define the size of a GOT header, which is the minimum size of the GOT section
+   when one is needed.  */
+
+static bfd_vma
+elfNN_aarch64_got_header_size (struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{
+  return GOT_ENTRY_SIZE * 3;
+}
+
 /* We use this so we can override certain functions
    (though currently we don't).  */
 
@@ -10560,6 +10569,9 @@ const struct elf_size_info elfNN_aarch64_size_info =
 #define elf_backend_merge_gnu_properties       \
   elfNN_aarch64_merge_gnu_properties
 
+#define elf_backend_got_header_size            \
+  elfNN_aarch64_got_header_size
+
 #define elf_backend_can_refcount       1
 #define elf_backend_can_gc_sections    1
 #define elf_backend_plt_readonly       1
@@ -10571,7 +10583,6 @@ const struct elf_size_info elfNN_aarch64_size_info =
 #define elf_backend_default_use_rela_p 1
 #define elf_backend_rela_normal               1
 #define elf_backend_dtrel_excludes_plt 1
-#define elf_backend_got_header_size (GOT_ENTRY_SIZE * 3)
 #define elf_backend_default_execstack  0
 #define elf_backend_extern_protected_data 1
 #define elf_backend_hash_symbol elf_aarch64_hash_symbol
index c27b49902239912f788eef50df615a9f05839626..3473a4db3ac51e3756e7306f2bb1417029f5b347 100644 (file)
@@ -4982,6 +4982,14 @@ static void
 ignore_errors (const char *fmt ATTRIBUTE_UNUSED, ...)
 {
 }
+
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+elfNN_ia64_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
 \f
 #define TARGET_LITTLE_SYM              ia64_elfNN_le_vec
 #define TARGET_LITTLE_NAME             "elfNN-ia64-little"
@@ -5059,7 +5067,7 @@ ignore_errors (const char *fmt ATTRIBUTE_UNUSED, ...)
 #define elf_backend_can_gc_sections    1
 #define elf_backend_want_plt_sym       0
 #define elf_backend_plt_alignment      5
-#define elf_backend_got_header_size    0
+#define elf_backend_got_header_size    elfNN_ia64_got_header_size
 #define elf_backend_want_got_plt       1
 #define elf_backend_may_use_rel_p      1
 #define elf_backend_may_use_rela_p     1
index 8aaf157b303ec8bda30a2be99c061f304027c19e..1d9a1d40078ea29580733855e4e38a4ef3596628 100644 (file)
@@ -128,7 +128,15 @@ struct loongarch_elf_link_hash_table
 /* #define elf_backend_can_refcount 1 */
 #define elf_backend_want_got_sym 1
 
-#define elf_backend_got_header_size (GOT_ENTRY_SIZE * 1)
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+loongarch_backend_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return GOT_ENTRY_SIZE * 1;
+}
+
+#define elf_backend_got_header_size loongarch_backend_got_header_size
 
 #define elf_backend_want_dynrelro 1
 /* #define elf_backend_rela_normal 1
@@ -440,7 +448,7 @@ loongarch_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
   htab->sgot = s;
 
   /* The first bit of the global offset table is the header.  */
-  s->size += bed->got_header_size;
+  s->size += bed->got_header_size (info);
 
   if (bed->want_got_plt)
     {
index 8f9f0d8a86a3a793b627b0de653b83a5df3338db..f880de401a01d9b9ec4d462a03447333f5301506 100644 (file)
@@ -456,7 +456,7 @@ riscv_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
   htab->sgot = s;
 
   /* The first bit of the global offset table is the header.  */
-  s->size += bed->got_header_size;
+  s->size += bed->got_header_size (info);
 
   if (bed->want_got_plt)
     {
@@ -1498,7 +1498,8 @@ riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
              || htab->elf.splt->size == 0)
          && (htab->elf.sgot == NULL
              || (htab->elf.sgot->size
-                 == get_elf_backend_data (output_bfd)->got_header_size)))
+                 == get_elf_backend_data (output_bfd)->
+                       got_header_size (info))))
        htab->elf.sgotplt->size = 0;
     }
 
@@ -5131,6 +5132,14 @@ riscv_elf_obj_attrs_arg_type (int tag)
   return (tag & 1) != 0 ? ATTR_TYPE_FLAG_STR_VAL : ATTR_TYPE_FLAG_INT_VAL;
 }
 
+/* Determine the size of the header of for the GOT section.  */
+
+static bfd_vma
+riscv_elf_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+  return ARCH_SIZE / 8;
+}
+
 /* Do not choose mapping symbols as a function name.  */
 
 static bfd_size_type
@@ -5264,6 +5273,7 @@ riscv_elf_merge_symbol_attribute (struct elf_link_hash_entry *h,
 #define elf_backend_plt_sym_val                        riscv_elf_plt_sym_val
 #define elf_backend_grok_prstatus              riscv_elf_grok_prstatus
 #define elf_backend_grok_psinfo                        riscv_elf_grok_psinfo
+#define elf_backend_got_header_size            riscv_elf_got_header_size
 #define elf_backend_object_p                   riscv_elf_object_p
 #define elf_backend_write_core_note            riscv_write_core_note
 #define elf_backend_maybe_function_sym         riscv_maybe_function_sym
@@ -5284,7 +5294,6 @@ riscv_elf_merge_symbol_attribute (struct elf_link_hash_entry *h,
 #define elf_backend_plt_readonly               1
 #define elf_backend_plt_alignment              4
 #define elf_backend_want_plt_sym               1
-#define elf_backend_got_header_size            (ARCH_SIZE / 8)
 #define elf_backend_want_dynrelro              1
 #define elf_backend_rela_normal                        1
 #define elf_backend_default_execstack          0
index 97a406a8d1a982662d6eb2937fd9d995a116942b..ca88031b0e423767330e685383a58047b4fbb474 100644 (file)
@@ -9362,7 +9362,7 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
             are reserved.  */
          if (htab->root.target_os != is_vxworks)
            htab->plt_got_index
-             += (get_elf_backend_data (dynobj)->got_header_size
+             += (get_elf_backend_data (dynobj)->got_header_size (info)
                  / MIPS_ELF_GOT_SIZE (dynobj));
 
          /* On VxWorks, also allocate room for the header's
index 0579f64d1a031fe25ef11d57bcf2e85934a6e52d..964c38e0e1c5ccaacfd2e02c5cdc4c5e0904f8ee 100644 (file)
 #define elf_backend_core_find_build_id _bfd_elfNN_core_find_build_id
 #endif
 #ifndef elf_backend_got_header_size
-#define elf_backend_got_header_size    0
+#define elf_backend_got_header_size    _bfd_elf_default_got_header_size
 #endif
 #ifndef elf_backend_got_elt_size
 #define elf_backend_got_elt_size _bfd_elf_default_got_elt_size
index c190eb920f64c4669960a6e6eda68b746c89cdbe..05f3281d08229fb5c6b203dce9e585dbb7f1254b 100644 (file)
@@ -1443,7 +1443,7 @@ tilegx_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
   htab->sgot = s;
 
   /* The first bit of the global offset table is the header.  */
-  s->size += bed->got_header_size;
+  s->size += bed->got_header_size (info);
 
   if (bed->want_got_plt)
     {
@@ -2557,7 +2557,8 @@ tilegx_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
              || htab->elf.splt->size == 0)
          && (htab->elf.sgot == NULL
              || (htab->elf.sgot->size
-                 == get_elf_backend_data (output_bfd)->got_header_size)))
+                 == get_elf_backend_data (output_bfd)->
+                       got_header_size (info))))
        htab->elf.sgotplt->size = 0;
     }
 
index acb2cc8528db8f69bd5168da42cd64bcdabd1905..b527f621fe1fd0000d4b7be1b5c0b23a674c03b8 100644 (file)
@@ -2215,7 +2215,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd,
         entries and there is no reference to _GLOBAL_OFFSET_TABLE_.  */
       if ((htab->elf.hgot == NULL
           || !htab->got_referenced)
-         && (htab->elf.sgotplt->size == bed->got_header_size)
+         && (htab->elf.sgotplt->size == bed->got_header_size (info))
          && (htab->elf.splt == NULL
              || htab->elf.splt->size == 0)
          && (htab->elf.sgot == NULL