summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddesh.poyarekar@arm.com>2020-09-11 09:18:09 +0530
committerLuis Machado <luis.machado@linaro.org>2020-10-20 15:04:07 -0300
commitf938669f01a7e36c384dd34d4ad73b26bbeb41e0 (patch)
tree70207c840e131293e35041a93029b1ca1f3be7c0
parentd2beed31c500be36f991a0a7f5596665979b054b (diff)
downloadbinutils-gdb-f938669f01a7e36c384dd34d4ad73b26bbeb41e0.tar.gz
[Morello] Expand GOT entry sizes for C64
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.
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/elf-bfd.h9
-rw-r--r--bfd/elf-m10300.c13
-rw-r--r--bfd/elf-vxworks.c8
-rw-r--r--bfd/elf-vxworks.h1
-rw-r--r--bfd/elf32-arc.c10
-rw-r--r--bfd/elf32-arm.c23
-rw-r--r--bfd/elf32-bfin.c21
-rw-r--r--bfd/elf32-cr16.c11
-rw-r--r--bfd/elf32-cris.c12
-rw-r--r--bfd/elf32-frv.c13
-rw-r--r--bfd/elf32-hppa.c10
-rw-r--r--bfd/elf32-i386.c10
-rw-r--r--bfd/elf32-lm32.c9
-rw-r--r--bfd/elf32-m32r.c12
-rw-r--r--bfd/elf32-m68k.c10
-rw-r--r--bfd/elf32-microblaze.c10
-rw-r--r--bfd/elf32-mips.c14
-rw-r--r--bfd/elf32-nds32.c10
-rw-r--r--bfd/elf32-nios2.c10
-rw-r--r--bfd/elf32-or1k.c9
-rw-r--r--bfd/elf32-ppc.c2
-rw-r--r--bfd/elf32-s390.c10
-rw-r--r--bfd/elf32-score.c10
-rw-r--r--bfd/elf32-sh.c10
-rw-r--r--bfd/elf32-sparc.c12
-rw-r--r--bfd/elf32-tic6x.c12
-rw-r--r--bfd/elf32-tilegx.c9
-rw-r--r--bfd/elf32-tilepro.c15
-rw-r--r--bfd/elf32-vax.c10
-rw-r--r--bfd/elf32-wasm32.c10
-rw-r--r--bfd/elf32-xtensa.c10
-rw-r--r--bfd/elf64-alpha.c10
-rw-r--r--bfd/elf64-hppa.c10
-rw-r--r--bfd/elf64-ia64-vms.c10
-rw-r--r--bfd/elf64-mips.c10
-rw-r--r--bfd/elf64-ppc.c10
-rw-r--r--bfd/elf64-ppc.h2
-rw-r--r--bfd/elf64-s390.c10
-rw-r--r--bfd/elf64-sparc.c10
-rw-r--r--bfd/elf64-tilegx.c9
-rw-r--r--bfd/elf64-x86-64.c10
-rw-r--r--bfd/elflink.c12
-rw-r--r--bfd/elfn32-mips.c11
-rw-r--r--bfd/elfnn-aarch64.c15
-rw-r--r--bfd/elfnn-ia64.c10
-rw-r--r--bfd/elfnn-riscv.c15
-rw-r--r--bfd/elfxx-mips.c2
-rw-r--r--bfd/elfxx-target.h2
-rw-r--r--bfd/elfxx-tilegx.c5
50 files changed, 440 insertions, 67 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index bf9e320b44b..2b03b838951 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,4 +1,13 @@
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
stores with alternate base.
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 173267ffa27..98165af1335 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1503,9 +1503,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. */
@@ -2612,6 +2612,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);
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index 7a2b67569b0..efa2401966b 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -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;
}
@@ -5463,6 +5463,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
@@ -5516,11 +5524,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"
diff --git a/bfd/elf-vxworks.c b/bfd/elf-vxworks.c
index f8a57e1a7dc..45d58170176 100644
--- a/bfd/elf-vxworks.c
+++ b/bfd/elf-vxworks.c
@@ -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;
+}
diff --git a/bfd/elf-vxworks.h b/bfd/elf-vxworks.h
index 47a099fca72..949a83ceccb 100644
--- a/bfd/elf-vxworks.h
+++ b/bfd/elf-vxworks.h
@@ -35,3 +35,4 @@ bfd_boolean elf_vxworks_add_dynamic_entries (bfd *, struct bfd_link_info *);
bfd_boolean elf_vxworks_finish_dynamic_entry (bfd *, Elf_Internal_Dyn *);
bfd_boolean _bfd_elf_maybe_vxworks_add_dynamic_tags
(bfd *, struct bfd_link_info *, bfd_boolean);
+bfd_vma elf_vxworks_got_header_size (struct bfd_link_info* info);
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index a05f697b657..61852e988ad 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -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
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 2f6bd885550..00a8a101ebe 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -9633,7 +9633,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);
plt_header_size = htab->plt_header_size;
}
BFD_ASSERT (splt != NULL && srel != NULL);
@@ -20228,6 +20229,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
@@ -20288,6 +20297,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
@@ -20300,7 +20310,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
@@ -20892,6 +20901,14 @@ elf32_arm_symbian_plt_sym_val (bfd_vma i, const asection *plt,
return plt->vma + 4 * ARRAY_SIZE (elf32_arm_symbian_plt_entry) * i;
}
+/* Determine the size of the header of for the GOT section. */
+
+static bfd_vma
+elf32_arm_symbian_got_header_size (struct bfd_link_info* info ATTRIBUTE_UNUSED)
+{
+ return 12;
+}
+
#undef elf32_bed
#define elf32_bed elf32_arm_symbian_bed
@@ -20917,7 +20934,7 @@ elf32_arm_symbian_plt_sym_val (bfd_vma i, const asection *plt,
/* There is no .got section for BPABI objects, and hence no header. */
#undef elf_backend_got_header_size
-#define elf_backend_got_header_size 0
+#define elf_backend_got_header_size elf32_arm_symbian_got_header_size
/* Similarly, there is no .got.plt section. */
#undef elf_backend_want_got_plt
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index ab928530db6..7e9b155631f 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -3224,7 +3224,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. */
@@ -4683,6 +4683,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. */
@@ -5381,6 +5388,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 },
@@ -5440,7 +5455,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"
@@ -5453,7 +5468,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
diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c
index c93fd9da8f8..7853f9e3c89 100644
--- a/bfd/elf32-cr16.c
+++ b/bfd/elf32-cr16.c
@@ -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;
}
@@ -2792,6 +2792,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"
@@ -2838,6 +2846,7 @@ _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
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index 61f4b24fe02..012f8a1a2e3 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -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
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index 9908c0112a5..a5ff0d9cb10 100644
--- a/bfd/elf32-frv.c
+++ b/bfd/elf32-frv.c
@@ -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. */
@@ -6759,6 +6759,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
@@ -6784,7 +6793,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
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index b9b1dad1aef..469a686c8c9 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -4432,6 +4432,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
@@ -4469,7 +4477,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
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 7ae881be0ad..db84a9a67d6 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -4330,6 +4330,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
@@ -4342,7 +4350,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
diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c
index 1751b66bae6..41d39837e75 100644
--- a/bfd/elf32-lm32.c
+++ b/bfd/elf32-lm32.c
@@ -2370,6 +2370,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
@@ -2393,7 +2400,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
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 533d662ee89..ca15d4d57b4 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -3645,7 +3645,15 @@ m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
default: return reloc_class_normal;
}
}
-
+
+/* 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
@@ -3683,7 +3691,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
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index b9b8bec6aa8..910f9c54e36 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -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
diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index 1b5c2efcd6e..a6af15e0d34 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -3409,6 +3409,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"
@@ -3438,7 +3446,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
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index b17d51620ea..bd3c151b486 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -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
};
-
+
+/* 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
diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c
index 233af38c230..c54507127e4 100644
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -13911,6 +13911,14 @@ nds32_elf_unify_tls_model (bfd *inbfd, asection *insec, bfd_byte *incontents,
}
/* End TLS model conversion. */
+
+/* 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
@@ -13962,7 +13970,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
diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
index 153bfadc619..ee6513b332a 100644
--- a/bfd/elf32-nios2.c
+++ b/bfd/elf32-nios2.c
@@ -6004,6 +6004,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[] =
{
@@ -6081,7 +6089,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"
diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index 38406eda3d6..a7cfdb8a605 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -3238,6 +3238,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
@@ -3270,7 +3277,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
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 66265ef6009..c1c7cea482a 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -10436,7 +10436,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
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 158f909d05a..3c29ae1d9fb 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -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
diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index 80380573d5e..d2188c5e68f 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -4408,6 +4408,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. */
@@ -4492,7 +4500,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
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 04949463ebf..d2220653d01 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -6548,6 +6548,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"
@@ -6615,7 +6623,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
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index 4be618cc554..60e167709c9 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -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
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index 5f5abd591fe..cde6ce9c327 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -1756,7 +1756,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);
@@ -4222,6 +4222,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
@@ -4253,7 +4261,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 \
diff --git a/bfd/elf32-tilegx.c b/bfd/elf32-tilegx.c
index dd7560d160a..9c6b3fb22e8 100644
--- a/bfd/elf32-tilegx.c
+++ b/bfd/elf32-tilegx.c
@@ -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
diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c
index 35114667394..8189aabab5e 100644
--- a/bfd/elf32-tilepro.c
+++ b/bfd/elf32-tilepro.c
@@ -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
diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c
index 58a4a8bdfbe..ab2e011c838 100644
--- a/bfd/elf32-vax.c
+++ b/bfd/elf32-vax.c
@@ -1848,6 +1848,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
@@ -1886,7 +1894,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
diff --git a/bfd/elf32-wasm32.c b/bfd/elf32-wasm32.c
index 400d754c6ac..fd87ed4721d 100644
--- a/bfd/elf32-wasm32.c
+++ b/bfd/elf32-wasm32.c
@@ -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"
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 5824c599ca8..dc06f324635 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -11473,6 +11473,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. */
@@ -11502,7 +11510,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
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 7b708f1e9d9..74af9078a48 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -5325,6 +5325,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;
+}
static const struct bfd_elf_special_section elf64_alpha_special_sections[] =
{
@@ -5499,7 +5507,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"
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index bf8207e3a7a..8450302a98a 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -3905,6 +3905,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 },
@@ -4020,7 +4028,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
diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c
index 5ce8775459e..0d713438268 100644
--- a/bfd/elf64-ia64-vms.c
+++ b/bfd/elf64-ia64-vms.c
@@ -5420,6 +5420,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 = {
@@ -5513,7 +5521,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
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index a07c39f1fd1..a6b4e1eb78e 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -4639,6 +4639,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;
+}
/* ECOFF swapping routines. These are used when dealing with the
.mdebug section, which is in the ECOFF debugging format. */
@@ -4777,7 +4785,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
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 157c454d854..5b55ec9ebff 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -77,7 +77,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
@@ -17712,6 +17712,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 */
diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h
index 0492fd7fad5..34c7c70847e 100644
--- a/bfd/elf64-ppc.h
+++ b/bfd/elf64-ppc.h
@@ -109,3 +109,5 @@ bfd_boolean ppc64_elf_size_stubs
(struct bfd_link_info *);
bfd_boolean ppc64_elf_build_stubs
(struct bfd_link_info *, char **);
+bfd_vma ppc64_elf_got_header_size
+ (struct struct bfd_link_info *) \ No newline at end of file
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 0522850a5d8..a69895f5226 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -3792,6 +3792,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;
+}
+
bfd_boolean
bfd_elf_s390_set_options (struct bfd_link_info *info,
struct s390_elf_params *params)
@@ -3859,7 +3867,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
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index 8d352252b63..d537d810cd9 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -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
diff --git a/bfd/elf64-tilegx.c b/bfd/elf64-tilegx.c
index 1cb78555229..4b329c2e185 100644
--- a/bfd/elf64-tilegx.c
+++ b/bfd/elf64-tilegx.c
@@ -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
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 549a8be6a6a..1e5a166d9c1 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -5161,6 +5161,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[]=
{
@@ -5191,7 +5199,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
diff --git a/bfd/elflink.c b/bfd/elflink.c
index e23d189b983..5117cb593f2 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -189,7 +189,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)
{
@@ -14403,7 +14403,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)
@@ -14839,6 +14839,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,
diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c
index 16febe7d04d..50155fb5abd 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -4028,6 +4028,15 @@ elf32_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
+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
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index c945572ed91..9d53ca71b59 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -7982,7 +7982,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;
}
@@ -10315,6 +10315,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). */
@@ -10459,6 +10468,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
@@ -10470,7 +10482,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
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index 292c00b6d03..b6a49ce73ee 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -4991,6 +4991,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;
+}
#define TARGET_LITTLE_SYM ia64_elfNN_le_vec
#define TARGET_LITTLE_NAME "elfNN-ia64-little"
@@ -5068,7 +5076,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
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index a5b2c8a198c..d6cb2e1e0da 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -421,7 +421,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)
{
@@ -1448,7 +1448,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;
}
@@ -4952,6 +4953,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;
+}
+
#define TARGET_LITTLE_SYM riscv_elfNN_vec
#define TARGET_LITTLE_NAME "elfNN-littleriscv"
@@ -4975,6 +4984,7 @@ riscv_elf_obj_attrs_arg_type (int tag)
#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_info_to_howto_rel NULL
#define elf_info_to_howto riscv_info_to_howto_rela
@@ -4989,7 +4999,6 @@ riscv_elf_obj_attrs_arg_type (int tag)
#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
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index c0970fb85d0..d26abb8f3ad 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -9378,7 +9378,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
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index a137c4681f1..d527a604f0f 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -532,7 +532,7 @@
#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
diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c
index abe344c0c86..039a21fc190 100644
--- a/bfd/elfxx-tilegx.c
+++ b/bfd/elfxx-tilegx.c
@@ -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;
}