diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 8d18a318643..f97986cd5b9 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -2537,7 +2537,6 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = { #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag #define elf_backend_adjust_dynamic_symbol \ _bfd_mips_elf_adjust_dynamic_symbol -#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections #define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections #define elf_backend_init_index_section _bfd_elf_init_1_index_section #define elf_backend_relocate_section _bfd_mips_elf_relocate_section diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c index 78bece0e072..736e5f5c36d 100644 --- a/bfd/elf64-mips.c +++ b/bfd/elf64-mips.c @@ -4748,8 +4748,6 @@ const struct elf_size_info mips_elf64_size_info = #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag #define elf_backend_adjust_dynamic_symbol \ _bfd_mips_elf_adjust_dynamic_symbol -#define elf_backend_early_size_sections \ - _bfd_mips_elf_early_size_sections #define elf_backend_late_size_sections \ _bfd_mips_elf_late_size_sections #define elf_backend_init_index_section _bfd_elf_init_1_index_section diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c index 52d6e4410cd..c84a6ab3673 100644 --- a/bfd/elfn32-mips.c +++ b/bfd/elfn32-mips.c @@ -4138,7 +4138,6 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = { #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag #define elf_backend_adjust_dynamic_symbol \ _bfd_mips_elf_adjust_dynamic_symbol -#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections #define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections #define elf_backend_init_index_section _bfd_elf_init_1_index_section #define elf_backend_relocate_section _bfd_mips_elf_relocate_section diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 87e2ce5093d..f2a1441fdf7 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -9644,48 +9644,6 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info, return _bfd_elf_adjust_dynamic_copy (info, h, s); } -/* This function is called after all the input files have been read, - and the input sections have been assigned to output sections. We - check for any mips16 stub sections that we can discard. */ - -bool -_bfd_mips_elf_early_size_sections (bfd *output_bfd, - struct bfd_link_info *info) -{ - asection *sect; - struct mips_elf_link_hash_table *htab; - struct mips_htab_traverse_info hti; - - htab = mips_elf_hash_table (info); - BFD_ASSERT (htab != NULL); - - /* The .reginfo section has a fixed size. */ - sect = bfd_get_section_by_name (output_bfd, ".reginfo"); - if (sect != NULL) - { - bfd_set_section_size (sect, sizeof (Elf32_External_RegInfo)); - sect->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; - } - - /* The .MIPS.abiflags section has a fixed size. */ - sect = bfd_get_section_by_name (output_bfd, ".MIPS.abiflags"); - if (sect != NULL) - { - bfd_set_section_size (sect, sizeof (Elf_External_ABIFlags_v0)); - sect->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; - } - - hti.info = info; - hti.output_bfd = output_bfd; - hti.error = false; - mips_elf_link_hash_traverse (mips_elf_hash_table (info), - mips_elf_check_symbols, &hti); - if (hti.error) - return false; - - return true; -} - /* If the link uses a GOT, lay it out and work out its size. */ static bool @@ -9990,7 +9948,8 @@ mips_elf_set_plt_sym_value (struct mips_elf_link_hash_entry *h, void *data) return true; } -/* Set the sizes of the dynamic sections. */ +/* Set the sizes of the dynamic sections, some mips non-dynamic sections, + and check for any mips16 stub sections that we can discard. */ bool _bfd_mips_elf_late_size_sections (bfd *output_bfd, @@ -10000,14 +9959,39 @@ _bfd_mips_elf_late_size_sections (bfd *output_bfd, asection *s, *sreldyn; bool reltext; struct mips_elf_link_hash_table *htab; + struct mips_htab_traverse_info hti; htab = mips_elf_hash_table (info); BFD_ASSERT (htab != NULL); - dynobj = elf_hash_table (info)->dynobj; + + /* The .reginfo section has a fixed size. */ + s = bfd_get_section_by_name (output_bfd, ".reginfo"); + if (s != NULL) + { + bfd_set_section_size (s, sizeof (Elf32_External_RegInfo)); + s->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; + } + + /* The .MIPS.abiflags section has a fixed size. */ + s = bfd_get_section_by_name (output_bfd, ".MIPS.abiflags"); + if (s != NULL) + { + bfd_set_section_size (s, sizeof (Elf_External_ABIFlags_v0)); + s->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS; + } + + hti.info = info; + hti.output_bfd = output_bfd; + hti.error = false; + mips_elf_link_hash_traverse (htab, mips_elf_check_symbols, &hti); + if (hti.error) + return false; + + dynobj = htab->root.dynobj; if (dynobj == NULL) return true; - if (elf_hash_table (info)->dynamic_sections_created) + if (htab->root.dynamic_sections_created) { /* Set the contents of the .interp section to the interpreter. */ if (bfd_link_executable (info) && !info->nointerp) @@ -10147,7 +10131,7 @@ _bfd_mips_elf_late_size_sections (bfd *output_bfd, } } else if (bfd_link_executable (info) - && ! mips_elf_hash_table (info)->use_rld_obj_head + && !htab->use_rld_obj_head && startswith (name, ".rld_map")) { /* We add a room for __rld_map. It will be filled in by the @@ -10156,7 +10140,7 @@ _bfd_mips_elf_late_size_sections (bfd *output_bfd, } else if (SGI_COMPAT (output_bfd) && startswith (name, ".compact_rel")) - s->size += mips_elf_hash_table (info)->compact_rel_size; + s->size += htab->compact_rel_size; else if (s == htab->root.splt) { /* If the last PLT entry has a branch delay slot, allocate @@ -10196,7 +10180,7 @@ _bfd_mips_elf_late_size_sections (bfd *output_bfd, } } - if (elf_hash_table (info)->dynamic_sections_created) + if (htab->root.dynamic_sections_created) { /* Add some entries to the .dynamic section. We fill in the values later, in _bfd_mips_elf_finish_dynamic_sections, but we @@ -14944,7 +14928,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info) input_section->flags &= ~SEC_HAS_CONTENTS; } - /* Size has been set in _bfd_mips_elf_early_size_sections. */ + /* Size has been set in _bfd_mips_elf_late_size_sections. */ BFD_ASSERT(o->size == sizeof (Elf_External_ABIFlags_v0)); /* Skip this section later on (I don't think this currently @@ -15003,7 +14987,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info) input_section->flags &= ~SEC_HAS_CONTENTS; } - /* Size has been set in _bfd_mips_elf_early_size_sections. */ + /* Size has been set in _bfd_mips_elf_late_size_sections. */ BFD_ASSERT(o->size == sizeof (Elf32_External_RegInfo)); /* Skip this section later on (I don't think this currently diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h index ad47e7634bb..85fb3da78f8 100644 --- a/bfd/elfxx-mips.h +++ b/bfd/elfxx-mips.h @@ -67,8 +67,6 @@ extern bool _bfd_mips_elf_check_relocs (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); extern bool _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *, struct elf_link_hash_entry *); -extern bool _bfd_mips_elf_early_size_sections - (bfd *, struct bfd_link_info *); extern bool _bfd_mips_elf_late_size_sections (bfd *, struct bfd_link_info *); extern int _bfd_mips_elf_relocate_section