From 6c19c432c91630be82a0c0c37ec97eef875faa0d Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Fri, 11 Sep 2020 09:18:09 +0530 Subject: [PATCH] [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 Tamar Christina * 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. --- bfd/ChangeLog | 9 +++++++++ bfd/elf-bfd.h | 9 ++++++--- bfd/elf-m10300.c | 13 +++++++++++-- bfd/elf-vxworks.c | 8 ++++++++ bfd/elf-vxworks.h | 1 + bfd/elf32-arc.c | 10 +++++++++- bfd/elf32-arm.c | 13 +++++++++++-- bfd/elf32-bfin.c | 21 ++++++++++++++++++--- bfd/elf32-cr16.c | 12 ++++++++++-- bfd/elf32-cris.c | 12 ++++++++++-- bfd/elf32-csky.c | 10 +++++++++- bfd/elf32-frv.c | 13 +++++++++++-- bfd/elf32-hppa.c | 10 +++++++++- bfd/elf32-i386.c | 10 +++++++++- bfd/elf32-lm32.c | 9 ++++++++- bfd/elf32-m32r.c | 12 ++++++++++-- bfd/elf32-m68k.c | 10 +++++++++- bfd/elf32-microblaze.c | 10 +++++++++- bfd/elf32-mips.c | 14 +++++++++++--- bfd/elf32-nds32.c | 10 +++++++++- bfd/elf32-nios2.c | 10 +++++++++- bfd/elf32-or1k.c | 9 ++++++++- bfd/elf32-ppc.c | 2 +- bfd/elf32-s390.c | 10 +++++++++- bfd/elf32-score.c | 10 +++++++++- bfd/elf32-sh.c | 10 +++++++++- bfd/elf32-sparc.c | 12 ++++++++++-- bfd/elf32-tic6x.c | 12 ++++++++++-- bfd/elf32-tilegx.c | 9 ++++++++- bfd/elf32-tilepro.c | 15 ++++++++++++--- bfd/elf32-vax.c | 10 +++++++++- bfd/elf32-wasm32.c | 10 +++++++++- bfd/elf32-xtensa.c | 10 +++++++++- bfd/elf64-alpha.c | 10 +++++++++- bfd/elf64-hppa.c | 10 +++++++++- bfd/elf64-ia64-vms.c | 10 +++++++++- bfd/elf64-mips.c | 10 +++++++++- bfd/elf64-ppc.c | 10 +++++++++- bfd/elf64-ppc.h | 2 ++ bfd/elf64-s390.c | 10 +++++++++- bfd/elf64-sparc.c | 10 +++++++++- bfd/elf64-tilegx.c | 9 ++++++++- bfd/elf64-x86-64.c | 10 +++++++++- bfd/elflink.c | 12 ++++++++++-- bfd/elfn32-mips.c | 11 ++++++++++- bfd/elfnn-aarch64.c | 15 +++++++++++++-- bfd/elfnn-ia64.c | 10 +++++++++- bfd/elfnn-loongarch.c | 12 ++++++++++-- bfd/elfnn-riscv.c | 15 ++++++++++++--- bfd/elfxx-mips.c | 2 +- bfd/elfxx-target.h | 2 +- bfd/elfxx-tilegx.c | 5 +++-- bfd/elfxx-x86.c | 2 +- 53 files changed, 451 insertions(+), 71 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6b3981a1640..49550c9aedc 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2020-10-20 Siddhesh Poyarekar + Tamar Christina + + * 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 * elfxx-aarch64.c (reencode_ldst_pos_imm): Support loads and diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index d05ca3d9a84..a8150d1ce91 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -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); diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index 8184ce9d50c..0aafcf22503 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; } @@ -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" diff --git a/bfd/elf-vxworks.c b/bfd/elf-vxworks.c index 68f92880a8a..6f5274d8be4 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 1765c5734d8..4c91d64dffa 100644 --- a/bfd/elf-vxworks.h +++ b/bfd/elf-vxworks.h @@ -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); diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index d94113154db..c54740674df 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 5b8f5e5a0e6..4339d044ca9 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -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 diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c index 98812133741..3d77665bf62 100644 --- a/bfd/elf32-bfin.c +++ b/bfd/elf32-bfin.c @@ -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 diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c index 9764ae76be9..3091dc974d2 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; } @@ -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" diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 00b5f7745e8..abe1dc63610 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-csky.c b/bfd/elf32-csky.c index 87a879ea011..5da74d0b420 100644 --- a/bfd/elf32-csky.c +++ b/bfd/elf32-csky.c @@ -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. */ diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c index 02e334f31bb..051984b862c 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. */ @@ -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 diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 153a3ce11e1..ccbe6eecd8a 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -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 diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index fb5ed161f50..69314e9dbae 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -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 diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index 3dc84920e08..c501d13bd17 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -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 diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 825cb23bbb6..38de7377a6c 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -3635,7 +3635,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 @@ -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 diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 6991e70019f..212beef3d00 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 d09b3f7095d..5c0788ce8b9 100644 --- a/bfd/elf32-microblaze.c +++ b/bfd/elf32-microblaze.c @@ -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 diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index a4c88c6b089..8825384caa6 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 519c8283361..88293260755 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -13902,6 +13902,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 @@ -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 diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c index 93e503bbd79..909f6e999d3 100644 --- a/bfd/elf32-nios2.c +++ b/bfd/elf32-nios2.c @@ -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" diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index 2a06b3e19e6..49e1935e66f 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -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 diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 42273ca06fe..a01e904de42 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -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 diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 2934f18c8b8..b65be2a3697 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 c868707347c..68f564f05b8 100644 --- a/bfd/elf32-score.c +++ b/bfd/elf32-score.c @@ -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 diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 73b861e18f3..06c8f82855a 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -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 diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index 1bfd40e9ae5..e66a0e38d3b 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 c90daf941fc..801b2290906 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -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 \ diff --git a/bfd/elf32-tilegx.c b/bfd/elf32-tilegx.c index 10dd4effe77..4c7f122afaf 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 2495539c7f7..d9b0987c8b3 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 4e290d55fed..1e558165904 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -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 diff --git a/bfd/elf32-wasm32.c b/bfd/elf32-wasm32.c index 999ab58d7db..42065f48218 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 f1839e61950..f58c400bec9 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -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 diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index f850db93890..82154a44344 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -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; +} 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" diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index 030e6e3a189..272ecdd5654 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -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 diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c index 59cc6b6fe85..4bfc78f7623 100644 --- a/bfd/elf64-ia64-vms.c +++ b/bfd/elf64-ia64-vms.c @@ -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 diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c index 6fa9d44300c..4e3e1aa8e1d 100644 --- a/bfd/elf64-mips.c +++ b/bfd/elf64-mips.c @@ -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; +} /* 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 diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index f4d2bf053c3..29cd537aab6 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -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 */ diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h index 5dbffc9ee2e..c1c839dc96d 100644 --- a/bfd/elf64-ppc.h +++ b/bfd/elf64-ppc.h @@ -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 *); diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index e780efa7181..4d63e1b22cd 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -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 diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index e9f03cf8e3a..cbda9ec0109 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 aae2b098f0f..55892d126ca 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 b5718e71121..3c505f99207 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -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 diff --git a/bfd/elflink.c b/bfd/elflink.c index 5a070a26e35..ed203a03b3f 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -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, diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c index 1ae51a4648c..b82c0c2bd2c 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 bd37caf7858..e4c2bad6bc2 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -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 diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c index c27b4990223..3473a4db3ac 100644 --- a/bfd/elfnn-ia64.c +++ b/bfd/elfnn-ia64.c @@ -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; +} #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 diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index 8aaf157b303..1d9a1d40078 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -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) { diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 8f9f0d8a86a..f880de401a0 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -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 diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 97a406a8d1a..ca88031b0e4 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -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 diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 0579f64d1a0..964c38e0e1c 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 c190eb920f6..05f3281d082 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; } diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index acb2cc8528d..b527f621fe1 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -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 -- 2.47.2