diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8b2decfec7..ea57ab79fc 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,16 @@ +2003-06-19 Alan Modra + + * elf64-ppc.c (toc_adjusting_stub_needed): New function. + (ppc64_elf_next_input_section): Use it here to set has_gp_reloc. + Return error condition. + (ppc64_elf_size_stubs): Restrict toc adjusting stubs to sections + that have has_gp_reloc set. + (struct ppc_link_hash_table): Add stub_count. + (ppc_build_one_stub): Increment it. + (ppc64_elf_link_hash_table_create): zmalloc rather than clearing + individual fields. + * elf64-ppc.h (ppc64_elf_next_input_section): Update prototype. + 2003-06-18 Alan Modra * elflink.h (elf_gc_record_vtentry): Revert last change. Correct @@ -419,7 +432,7 @@ for X_STORMY16_REL_12 reloc. * elf.c (bfd_elf_get_needed_list): Use is_elf_hash_table to check - the type of the has table in the bfd_link_info structure. + the type of the hash table in the bfd_link_info structure. (bfd_elf_get_runpath_list): Likewise. 2003-05-19 Roland McGrath @@ -563,7 +576,7 @@ * elf32-sh.c (sh_elf_adjust_dynamic_symbol): For weak symbols, copy ELF_LINK_NON_GOT_REF from weakdef. - (allocate_dynrelocs): For undef weak syms with non-default + (allocate_dynrelocs): For undef weak syms with non-default visibility, a) don't allocate plt entries, b) don't allocate .got relocs, c) discard dyn rel space (sh_elf_relocate_section): d) don't generate .got relocs, e) @@ -1299,7 +1312,7 @@ 2003-03-25 Stan Cox Nick Clifton - Contribute support for Intel's iWMMXt chip - an ARM variant: + Contribute support for Intel's iWMMXt chip - an ARM variant: * archures.c: Add bfd_mach_arm_iWMMXt. * reloc.c: Add BFD_RELOC_ARM_CP_OFF_IMM_S2. @@ -1314,7 +1327,7 @@ * cpu-arm.c (processors): Add iWMMXt. (arch_inf): Likewise. * elf32-arm.h (arm_object_p): Handle note section. - (elf32_arm_merge_private_bfd_data): Allow iWMMXt object files to + (elf32_arm_merge_private_bfd_data): Allow iWMMXt object files to be linked with XScale ones. (elf32_arm_section_flags): New function: Set flags on note section. (elf32_arm_final_write_processing): Handle note section. @@ -1807,7 +1820,7 @@ variables, structure fields or function params to tls_mask or similar to better reflect usage. (struct got_entry): Comment. - (struct ppc_link_hash_entry): Expand comment, and renumber TLS_*. + (struct ppc_link_hash_entry): Expand comment, and renumber TLS_*. (get_tls_mask): Rename from get_tls_type. 2003-02-09 Alan Modra @@ -2158,13 +2171,11 @@ 2003-01-23 Nick Clifton * Add sh2e support: - 2002-04-02 Elena Zannoni - - * archures.c (bfd_mach_sh2e): Added. - * bfd-in2.h: Rebuilt. - * cpu-sh.c (arch_info_struct): Added SH2e. - * elf32-sh.c (sh_elf_set_mach_from_flags): Handle EF_SH2E. + * archures.c (bfd_mach_sh2e): Added. + * bfd-in2.h: Rebuilt. + * cpu-sh.c (arch_info_struct): Added SH2e. + * elf32-sh.c (sh_elf_set_mach_from_flags): Handle EF_SH2E. 2003-01-23 Alan Modra @@ -3079,7 +3090,7 @@ 2002-11-07 Michal Ludvig - * dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info, + * dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info, _bfd_dwarf2_find_nearest_line): Use bfd_simple_get_relocated_section_contents() instead of bfd_get_section_contents(). @@ -3637,7 +3648,7 @@ * Makefile.am: Add entries for elf32-sh64-lin.c and elf64-sh64-lin.c. Regenerate. * Makefile.in: Regenerate. - * config.bfd: Change sh64eb-*-linux* and sh64-*-linux* + * config.bfd: Change sh64eb-*-linux* and sh64-*-linux* to use sh64 vectors rather than sh vectors. * configure.in: Add bfd_elf32_sh64lin_vec, bfd_elf32_sh64blin_vec, bfd_elf64_sh64lin_vec, bfd_elf64_sh64blin_vec. @@ -4063,7 +4074,7 @@ 2002-08-28 Catherine Moore - * elf32-v850.c (v850_elf_reloc_map): Add new relocs. + * elf32-v850.c (v850_elf_reloc_map): Add new relocs. (v850-elf-reloc): Don't resolve pc relative relocs. (v850_elf_ignore_reloc): New routine. (v850_elf_final_link_relocate): Handle new relocs. @@ -5072,7 +5083,7 @@ 2002-07-04 Alan Modra - * section.c (_bfd_strip_section_from_output): Remove unnecessary + * section.c (_bfd_strip_section_from_output): Remove unnecessary link order code. Don't actually remove the output section here; Just set a flag for the linker to do so. * elflink.c (_bfd_elf_link_renumber_dynsyms): Test for removed @@ -5367,7 +5378,7 @@ * elf64-hppa.c (elf64_hppa_mark_milli_and_exported_functions): New function. - (allocate_global_data_dlt): Don't add millicode symbols to dynamic + (allocate_global_data_dlt): Don't add millicode symbols to dynamic symbol table. (allocate_global_data_opd, allocate_dynrel_entries): Likewise. (elf64_hppa_size_dynamic_sections): Revise to use @@ -6244,7 +6255,7 @@ 2002-05-18 Tom Rix - * coff64-rs6000.c (_bfd_xcoff64_swap_aux_out): Fix C_FILE auxent. + * coff64-rs6000.c (_bfd_xcoff64_swap_aux_out): Fix C_FILE auxent. 2002-05-17 Alan Modra @@ -7177,7 +7188,7 @@ * coff-rs6000.c (_bfd_xcoff_stat_arch_elt): Renamed from _bfd_xcoff_generic_stat_arch_elt. Fix format check. - * coff64-rs6000.c : Use _bfd_xcoff_stat_arch_elt. + * coff64-rs6000.c : Use _bfd_xcoff_stat_arch_elt. 2002-03-19 Tom Rix @@ -7444,7 +7455,7 @@ 2002-02-20 Peter Schauer - * osf-core.c (osf_core_vec): OSF/1 (Digital Unix) core files are + * osf-core.c (osf_core_vec): OSF/1 (Digital Unix) core files are little endian. 2002-02-19 Martin Schwidefsky @@ -7490,7 +7501,7 @@ * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sh64.c (sh_elf64_relocate_section): Likewise. - * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. + * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Handle _bfd_elf_section_offset returning -2 the same way as -1. @@ -7718,7 +7729,7 @@ datalabel_got_offset. (sh_elf_link_hash_newfunc): Initialize it. (sh_elf_relocate_section): Augment the scope of - seen_stt_datalabel. Introduce GOTPLT support. Extend GOTPC, PLT, + seen_stt_datalabel. Introduce GOTPLT support. Extend GOTPC, PLT, GOT and GOTOFF handling to new SHmedia relocation types. Support GOT_BIAS. (sh_elf_check_relocs): Likewise. @@ -7765,14 +7776,14 @@ match official numbers and names; moved unmaching ones to the range 0xf2-0xff. * elf32-sh64.c, elf64-sh64.c: Likewise. - 2001-03-12 DJ Delorie + 2001-03-12 DJ Delorie * elf32-sh.c (sh_elf_relax_section): Don't relax SHmedia sections. - 2001-03-12 DJ Delorie + 2001-03-12 DJ Delorie * elf32-sh64.c (shmedia_prepare_reloc): Validate relocs that must be aligned. * elf64-sh64.c (sh_elf64_relocate_section): Ditto. - 2001-01-14 Hans-Peter Nilsson + 2001-01-14 Hans-Peter Nilsson * elf32-sh64.c (bfd_elf32_bfd_copy_private_section_data): Define. (sh64_elf_fake_sections): Set type to SHT_SH5_CR_SORTED for a .cranges section with SEC_SORT_ENTRIES set. @@ -7783,9 +7794,9 @@ start address if called by linker. 2001-01-08 Ben Elliston * elf32-sh64.c (sh64_elf_final_write_processing): Activate - Hans-Peter Nilsson's set bit 0 patch from 2001-01-06. + Hans-Peter Nilsson's set bit 0 patch from 2001-01-06. * elf64-sh64.c (sh64_elf64_final_write_processing): Ditto. - 2001-01-06 Hans-Peter Nilsson + 2001-01-06 Hans-Peter Nilsson * elf64-sh64.c (sh_elf64_howto_table): No open brace at start of line. Add comments before all entries. : Correct and clarify describing @@ -7805,7 +7816,7 @@ clarify describing comment. Add comments before all entries. (sh_elf_relocate_section) : Do not honour STO_SH5_ISA32; instead call reloc_dangerous callback. - 2001-01-06 Hans-Peter Nilsson + 2001-01-06 Hans-Peter Nilsson Sort .cranges section in final link. Prepare to set bit 0 on entry address. * elf32-sh64.c (struct sh64_find_section_vma_data): New. @@ -7828,7 +7839,7 @@ * elf32-sh64.c (sh64_elf64_final_write_processing): New, (but temporarily disabled) setting bit 0 on entry address. (elf_backend_final_write_processing): Define. - 2001-01-05 Hans-Peter Nilsson + 2001-01-05 Hans-Peter Nilsson * elf32-sh.c (sh_elf_howto_table) : Adjust fields to be a proper relocation for PTA and PTB rather than a marker. : New case. * Makefile.am (elf32-sh64.lo): Add dependency on sh64-opc.h. * Makefile.in: Regenerate. - 2000-12-30 Hans-Peter Nilsson + 2000-12-30 Hans-Peter Nilsson * elf64-sh64.c (sh64_elf64_fake_sections): Set SHF_SH5_ISA32 for all code sections. (sh_elf64_set_mach_from_flags): Change from EF_SH64 to EF_SH5. @@ -7859,11 +7870,11 @@ (sh64_elf_copy_private_data): Add missing "return true". (sh64_elf_set_mach_from_flags): Change from EF_SH64 to EF_SH5. (sh_elf64_merge_private_data): Ditto. - 2000-12-19 Hans-Peter Nilsson + 2000-12-19 Hans-Peter Nilsson * elf64-sh64.c (sh64_elf64_fake_sections): New, copy of elf64-sh64.c:sh64_elf_fake_sections. (elf_backend_fake_sections): Define as sh64_elf64_fake_sections. - 2000-12-18 Hans-Peter Nilsson + 2000-12-18 Hans-Peter Nilsson * elf32-sh64.c (sh64_elf_copy_private_data_internal): Delete. (sh64_elf_final_write_processing): New. (elf_backend_final_write_processing): Define. @@ -7872,7 +7883,7 @@ sh64_elf_copy_private_data_internal, just copy e_flags field. (sh64_elf_merge_private_data): Do not call sh64_elf_copy_private_data_internal. - 2000-12-12 Hans-Peter Nilsson + 2000-12-12 Hans-Peter Nilsson Remove EF_SH64_ABI64, let ELF size make difference. Remove SH64-specific BFD section flag. * elf32-sh64.c (sh64_elf_fake_sections): Recognize section as @@ -7888,7 +7899,7 @@ * section.c (Section flags definitions): Don't define SEC_SH_ISA_SHMEDIA. (bfd-in2.h): Regenerate. - 2000-12-09 Hans-Peter Nilsson + 2000-12-09 Hans-Peter Nilsson Make DataLabel references work with partial linking. * elf32-sh64.c: Fix formatting. (sh64_elf_link_output_symbol_hook): New. @@ -7901,7 +7912,7 @@ sh64_elf64_link_output_symbol_hook. (sh64_elf64_add_symbol_hook): Make DataLabel symbol just global undefined if partial linking. Adjust sanity check. - 2000-12-07 Hans-Peter Nilsson + 2000-12-07 Hans-Peter Nilsson Implement semantics for inter-file DataLabel references. * elf64-sh64.c (DATALABEL_SUFFIX): Define. (sh64_elf64_add_symbol_hook): New. @@ -7917,13 +7928,13 @@ * elf32-sh.c (sh_elf_relocate_section): If passing an indirect symbol with st_type STT_DATALABEL on the way to a symbol with st_other STO_SH5_ISA32, do not bitor 1 to the relocation. - 2000-12-05 Hans-Peter Nilsson + 2000-12-05 Hans-Peter Nilsson Pass through STT_DATALABEL. * elf32-sh64.c (sh64_elf_get_symbol_type): New. (elf_backend_get_symbol_type): Define. * elf64-sh64.c (sh64_elf64_get_symbol_type): New. (elf_backend_get_symbol_type): Define. - 2000-11-30 Hans-Peter Nilsson + 2000-11-30 Hans-Peter Nilsson * elf32-sh64.c: Tweak comments. (sh64_elf_copy_private_data_internal): Add prototype. (bfd_elf32_bfd_set_private_flags): Define. @@ -7947,7 +7958,7 @@ * configure: Regenerate. * po/POTFILES.in: Regenerate. * po/bfd.pot: Regenerate. - 2000-11-29 Hans-Peter Nilsson + 2000-11-29 Hans-Peter Nilsson * elf32-sh64.c (sh64_elf_set_mach_from_flags): Do not recognize anything else but EF_SH64 and EF_SH64_ABI64. (sh64_elf_merge_private_data): Emit error for anything else but @@ -7957,7 +7968,7 @@ * configure.in: Add cofflink.lo to bfd_elf32_sh64_vec and bfd_elf32_sh64l_vec as a temporary measure. * configure: Regenerate. - 2000-11-27 Hans-Peter Nilsson + 2000-11-27 Hans-Peter Nilsson * cpu-sh.c (arch_info_struct): Include sh5 item unconditionalized. * config.bfd (sh64-*-elf*): Do not set targ_cflags. @@ -7975,7 +7986,7 @@ : Ditto. (sh_elf_set_mach_from_flags): Remove code refusing deleted EF_SH64_32BIT_ABI flag. - 2000-11-26 Hans-Peter Nilsson + 2000-11-26 Hans-Peter Nilsson * elf32-sh.c (sh_elf_howto_table) : Set pcrel_offset to true. @@ -7984,7 +7995,7 @@ : Ditto if h->other & STO_SH5_ISA32. * elf32-sh64.c (shmedia_prepare_reloc): Add rel->r_addend to relocation. - 2000-11-24 Hans-Peter Nilsson + 2000-11-24 Hans-Peter Nilsson * Makefile.am (BFD32_BACKENDS): Add elf32-sh64.lo. (BFD32_BACKENDS_CFILES): Add elf32-sh64.c. Regenerate dependencies. @@ -8207,7 +8218,7 @@ * peXXigen.c (pe_print_idata): Rearrange message to aid in translation. - (pe_print_pdata): Rearrange message to aid in translation. + (pe_print_pdata): Rearrange message to aid in translation. * libbfd.c (warn_deprecated): Rearrange error message to aid in translation. @@ -8704,7 +8715,7 @@ * ptrace-core.c (ptrace_unix_core_file_p): Likewise. * trad-core.c (trad_unix_core_file_p): Likewise. - * hppabsd-core.c (hppabsd_core_core_file_p): Clean up after errors + * hppabsd-core.c (hppabsd_core_core_file_p): Clean up after errors with bfd_release and bfd_section_list_clear. * hpux-core.c (hpux_core_core_file_p): Likewise. * irix-core.c (irix_core_core_file_p): Likewise. diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index b00e41b5d9..8ffae99bdf 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -2803,6 +2803,9 @@ struct ppc_link_hash_table bfd_vma offset; } tlsld_got; + /* Statistics. */ + unsigned long stub_count[ppc_stub_plt_call]; + /* Set if we should emit symbols for stubs. */ unsigned int emit_stub_syms; @@ -2893,6 +2896,8 @@ static bfd_boolean ppc_build_one_stub PARAMS ((struct bfd_hash_entry *, PTR)); static bfd_boolean ppc_size_one_stub PARAMS ((struct bfd_hash_entry *, PTR)); +static int toc_adjusting_stub_needed + PARAMS ((struct bfd_link_info *, asection *)); static void group_sections PARAMS ((struct ppc_link_hash_table *, bfd_size_type, bfd_boolean)); static bfd_boolean ppc64_elf_relocate_section @@ -3031,7 +3036,7 @@ ppc64_elf_link_hash_table_create (abfd) struct ppc_link_hash_table *htab; bfd_size_type amt = sizeof (struct ppc_link_hash_table); - htab = (struct ppc_link_hash_table *) bfd_malloc (amt); + htab = (struct ppc_link_hash_table *) bfd_zmalloc (amt); if (htab == NULL) return NULL; @@ -3049,41 +3054,6 @@ ppc64_elf_link_hash_table_create (abfd) if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc)) return NULL; - htab->stub_bfd = NULL; - htab->add_stub_section = NULL; - htab->layout_sections_again = NULL; - htab->stub_group = NULL; - htab->no_multi_toc = 0; - htab->multi_toc_needed = 0; - htab->toc_curr = 0; - htab->sgot = NULL; - htab->srelgot = NULL; - htab->splt = NULL; - htab->srelplt = NULL; - htab->sdynbss = NULL; - htab->srelbss = NULL; - htab->sglink = NULL; - htab->sfpr = NULL; - htab->sbrlt = NULL; - htab->srelbrlt = NULL; - htab->tls_sec = NULL; - htab->tls_get_addr = NULL; - htab->tlsld_got.refcount = 0; - htab->emit_stub_syms = 0; - htab->stub_error = 0; - htab->has_14bit_branch = 0; - htab->have_undefweak = 0; - htab->stub_iteration = 0; - htab->sym_sec.abfd = NULL; - /* Initializing two fields of the union is just cosmetic. We really - only care about glist, but when compiled on a 32-bit host the - bfd_vma fields are larger. Setting the bfd_vma to zero makes - debugger inspection of these fields look nicer. */ - htab->elf.init_refcount.refcount = 0; - htab->elf.init_refcount.glist = NULL; - htab->elf.init_offset.offset = 0; - htab->elf.init_offset.glist = NULL; - return &htab->elf.root; } @@ -6221,6 +6191,7 @@ ppc_build_one_stub (gen_entry, in_arg) stub_bfd = stub_sec->owner; + htab->stub_count[(int) stub_entry->stub_type - 1] += 1; switch (stub_entry->stub_type) { case ppc_stub_long_branch: @@ -6598,17 +6569,77 @@ ppc64_elf_reinit_toc (output_bfd, info) htab->toc_curr = TOC_BASE_OFF; } +/* No toc references were found in ISEC. If the code in ISEC makes no + calls, then there's no need to use toc adjusting stubs when branching + into ISEC. Actually, indirect calls from ISEC are OK as they will + load r2. */ + +static int +toc_adjusting_stub_needed (info, isec) + struct bfd_link_info *info; + asection *isec; +{ + bfd_byte *contents; + bfd_size_type i; + int ret; + int branch_ok; + + /* Hack for linux kernel. .fixup contains branches, but only back to + the function that hit an exception. */ + branch_ok = strcmp (isec->name, ".fixup") == 0; + + contents = elf_section_data (isec)->this_hdr.contents; + if (contents == NULL) + { + contents = bfd_malloc (isec->_raw_size); + if (contents == NULL) + return -1; + if (! bfd_get_section_contents (isec->owner, isec, contents, + (file_ptr) 0, isec->_raw_size)) + { + free (contents); + return -1; + } + if (info->keep_memory) + elf_section_data (isec)->this_hdr.contents = contents; + } + + /* Code scan, because we don't necessarily have relocs on calls to + static functions. */ + ret = 0; + for (i = 0; i < isec->_raw_size; i += 4) + { + unsigned long insn = bfd_get_32 (isec->owner, contents + i); + /* Is this a branch? */ + if ((insn & (0x1f << 26)) == (18 << 26) + /* If branch and link, it's a function call. */ + && ((insn & 1) != 0 + /* Sibling calls use a plain branch. I don't know a way + of deciding whether a branch is really a sibling call. */ + || !branch_ok)) + { + ret = 1; + break; + } + } + + if (elf_section_data (isec)->this_hdr.contents != contents) + free (contents); + return ret; +} + /* The linker repeatedly calls this function for each input section, in the order that input sections are linked into output sections. Build lists of input sections to determine groupings between which we may insert linker stubs. */ -void +bfd_boolean ppc64_elf_next_input_section (info, isec) struct bfd_link_info *info; asection *isec; { struct ppc_link_hash_table *htab = ppc_hash_table (info); + int ret; if ((isec->output_section->flags & SEC_CODE) != 0 && isec->output_section->index <= htab->top_index) @@ -6626,13 +6657,20 @@ ppc64_elf_next_input_section (info, isec) to use the right TOC (obviously). Also, make sure that .opd gets the correct TOC value. */ if (isec->has_gp_reloc || (isec->flags & SEC_CODE) == 0) - if (elf_gp (isec->owner) != 0) - htab->toc_curr = elf_gp (isec->owner); + { + if (elf_gp (isec->owner) != 0) + htab->toc_curr = elf_gp (isec->owner); + } + else if ((ret = toc_adjusting_stub_needed (info, isec)) < 0) + return FALSE; + else + isec->has_gp_reloc = ret; /* Functions that don't use the TOC can belong in any TOC group. Use the last TOC base. This happens to make _init and _fini pasting work. */ htab->stub_group[isec->id].toc_off = htab->toc_curr; + return TRUE; } /* See whether we can group stub sections together. Grouping stub @@ -6904,7 +6942,9 @@ ppc64_elf_size_stubs (output_bfd, stub_bfd, info, group_size, if (sym_sec != NULL && sym_sec->output_section != NULL && (htab->stub_group[sym_sec->id].toc_off - != htab->stub_group[section->id].toc_off)) + != htab->stub_group[section->id].toc_off) + && sym_sec->has_gp_reloc + && section->has_gp_reloc) stub_type = ppc_stub_long_branch_r2off; } diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h index 1968c4e526..cf720b4798 100644 --- a/bfd/elf64-ppc.h +++ b/bfd/elf64-ppc.h @@ -33,7 +33,7 @@ void ppc64_elf_next_toc_section PARAMS ((struct bfd_link_info *, asection *)); void ppc64_elf_reinit_toc PARAMS ((bfd *, struct bfd_link_info *)); -void ppc64_elf_next_input_section +bfd_boolean ppc64_elf_next_input_section PARAMS ((struct bfd_link_info *, asection *)); bfd_boolean ppc64_elf_size_stubs PARAMS ((bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,