diff options
Diffstat (limited to 'contrib/binutils/bfd')
103 files changed, 15819 insertions, 6523 deletions
diff --git a/contrib/binutils/bfd/ChangeLog b/contrib/binutils/bfd/ChangeLog index b0c0d9b..1d3c161 100644 --- a/contrib/binutils/bfd/ChangeLog +++ b/contrib/binutils/bfd/ChangeLog @@ -1,32 +1,1994 @@ +2002-10-11 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (edit_opd): Only zero opd syms when function is + completely removed. + +2002-10-08 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (edit_opd): Correct test for discarded sections. + +2002-10-07 Alan Modra <amodra@bigpond.net.au> + + * elflink.h (elf_link_input_bfd): Remove BFD_VERSION_DATE dependent + code. + + * elf64-ppc.c (ppc64_elf_build_stubs): Increment .glink indx. + +2002-09-28 Alan Modra <amodra@bigpond.net.au> + + * elf.c (map_sections_to_segments): Correct test for start of + writable section in the same page as end of read-only section. + +2002-09-26 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (ppc_build_one_stub): Don't build glink stubs here. + (ppc64_elf_build_stubs): Build them here instead. + +2002-09-23 Daniel Jacobowitz <drow@mvista.com> + + Merge from mainline: + 2002-09-23 Alan Modra <amodra@bigpond.net.au> + * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Zero relocs + for discarded FDEs. Remove redundant assignment. + * elflink.h (elf_bfd_discard_info): Save edited relocs. + + 2002-09-23 Nathan Tallent <eraxxon@alumni.rice.edu> + * dwarf2.c (decode_line_info): Update to correctly decode + the (non-standard DWARF2) out-of-order address sequences + generated by the Intel C++ 6.0 compiler for ia64-Linux. + + 2002-09-22 H.J. Lu <hjl@gnu.org> + * elf64-alpha.c (elf64_alpha_merge_ind_symbols): Don't merge + the relocation count between different .reloc sections. + + 2002-09-22 Mark Elbrecht <snowball3@softhome.net> + * config.bfd: For DJGPP targets, match with any cpu and any machine. + + 2002-09-21 Alan Modra <amodra@bigpond.net.au> + * elfcode.h (elf_slurp_reloc_table_from_section): Make "symcount" + unsigned. Move "symcount" assignment out of loop. + + 2002-09-19 Nathan Tallent <eraxxon@alumni.rice.edu> + * dwarf2.c (_bfd_dwarf2_find_nearest_line): If address length is + zero, set it to 8 for (non-standard) 64-bit DWARF2 formats + (e.g. IRIX64). + + 2002-09-19 Jakub Jelinek <jakub@redhat.com> + * reloc.c (BFD_RELOC_386_TLS_TPOFF, BFD_RELOC_386_TLS_IE, + BFD_RELOC_386_TLS_GOTIE): Add. + * bfd-in2.h, libbfd.h: Rebuilt. + * elf32-i386.c (elf_howto_table): Add R_386_TLS_TPOFF, R_386_TLS_IE + and R_386_TLS_GOTIE. + (elf_i386_reloc_type_lookup): Handle it. + (struct elf_i386_link_hash_entry): Change tls_type type to unsigned + char instead of enum, change GOT_* into defines. + (GOT_TLS_IE_POS, GOT_TLS_IE_NEG, GOT_TLS_IE_BOTH): Define. + (elf_i386_tls_transition): Handle R_386_TLS_IE and R_386_TLS_GOTIE. + (elf_i386_check_relocs): Likewise. Avoid crash if local symbol is + accessed both as normal and TLS symbol. Move R_386_TLS_LDM and + R_386_PLT32 cases so that R_386_TLS_IE can fall through. + Handle R_386_TLS_LE_32 and R_386_TLS_LE in shared libs. + (elf_i386_gc_sweep_hook): Handle R_386_TLS_IE and R_386_TLS_GOTIE. + Handle R_386_TLS_LE_32 and R_386_TLS_LE in shared libs. + (allocate_dynrelocs): Allocate 2 .got and 2 .rel.got entries if + tls_type is GOT_TLS_IE_BOTH. + (elf_i386_size_dynamic_sections): Likewise. + (elf_i386_relocate_section): Handle R_386_TLS_IE and R_386_TLS_GOTIE. + Handle R_386_TLS_LE_32 and R_386_TLS_LE in shared libs. + (elf_i386_finish_dynamic_symbol): Use tls_type & GOT_TLS_IE to catch + all 4 GOT_TLS_* TLS types. + + 2002-09-18 Daniel Jacobowitz <drow@mvista.com> + * elfcode.h (elf_slurp_reloc_table_from_section): Check + correct relocation count. + + 2002-09-17 Daniel Jacobowitz <drow@mvista.com> + * bfd-in.h (bfd_get_dynamic_symcount): Define. + * bfd.c (struct _bfd): Add dynsymcount. + * bfd-in2.h: Regenerated. + * elf.c (_bfd_elf_canonicalize_dynamic_symtab): Set + abfd->dynsymcount. + * elfcode.h (elf_slurp_reloc_table_from_section): Check + for overflow. + + 2002-09-17 Alan Modra <amodra@bigpond.net.au> + * elf64-alpha.c (alpha_elf_size_info): Make static. + + 2002-09-17 Jakub Jelinek <jakub@redhat.com> + * elf32-ppc.c (ppc_elf_finish_dynamic_symbol): Clear .got word + even if generating R_PPC_RELATIVE reloc. + (ppc_elf_relocate_section): Make sure relocation is performed if + skip == -2. Clear memory at r_offset when creating dynamic + relocation. + + 2002-09-16 David O'Brien <obrien@FreeBSD.org> + * elf32-i386-fbsd.c: Always label using the EI_OSABI method. + It is benign for FreeBSD < 4.1. Minor reformatting. + * elf64-alpha-fbsd.c: Likewise. + + 2002-09-16 Nathan Tallent <eraxxon@alumni.rice.edu> + * ecoff.c (_bfd_ecoff_slurp_symbolic_info) <ioptMax>: Fix error + reading ECOFF information: 'ioptMax' refers to the actual *size* + of the optimization symtab, not the number of entries. + + 2002-09-16 Jakub Jelinek <jakub@redhat.com> + * elf_i386_relocate_section (R_386_TLS_TPOFF32): Negate addend. + + 2002-09-13 Daniel Jacobowitz <drow@mvista.com> + * elf32-arm.h (elf32_arm_adjust_dynamic_symbol): Update + ELF_LINK_HASH_NEEDS_PLT logic. + + 2002-09-11 Nick Clifton <nickc@redhat.com> + * po/da.po: New Danish translation file. + * configure.in (LINGUAS): Add 'da'. + * configure: Regenerate. + + 2002-09-11 Jakub Jelinek <jakub@redhat.com> + * elf32-i386.c (dtpoff_base, tpoff): Don't crash if tls_segment is + NULL. + (elf_i386_relocate_section): Return false after printing error about + unresolvable relocation. + + 2002-09-11 Jeffrey Law <law@redhat.com> + * elf32-h8300.c (elf32_h8_relax_section): Fix typo. + + 2002-09-06 Andrew Haley <aph@cambridge.redhat.com> + * elf.c (_bfd_elf_find_nearest_line): Check functionname_ptr and + line_ptr before deciding we've found a symbol. + + 2002-08-29 John David Anglin <dave@hiauly1.hia.nrc.ca> + * bfd-in.h (align_power): Cast constants to bfd_vma type. + * bfd-in2.h (align_power): Likewise. + + 2002-08-24 Kaz Kojima <kkojima@rr.iij4u.or.jp> + * elf32-sh.c (sh_elf_copy_indirect_symbol): New. + (create_got_section, allocate_dynrelocs, readonly_dynrelocs): + Likewise. + (struct elf_sh_pcrel_relocs_copied): Removed. + (struct elf_sh_dyn_relocs): New. + (struct elf_sh_link_hash_entry): Replace pcrel_relocs_copied + field with dyn_relocs. + (struct elf_sh_link_hash_table): Add short-cuts to get dynamic + sections and sym_sec. + (sh_elf_link_hash_newfunc): Clear dyn_relocs. + (sh_elf_link_hash_table_create): Clear shorts-cuts and sym_sec. + (sh_elf_create_dynamic_sections): Use create_got_section instead + of _bfd_elf_create_got_section. + (sh_elf_check_relocs): Likewise. + (sh_elf_create_dynamic_sections): Use short-cuts to the dynamic + sections. + (sh_elf_adjust_dynamic_symbol, sh_elf_size_dynamic_sections, + sh_elf_relocate_section, sh_elf_check_relocs, + sh_elf_finish_dynamic_symbol, sh_elf_finish_dynamic_sections): + Likewise. + (sh_elf_adjust_dynamic_symbol): Handle nocopyreloc. Keep the + dynamic relocations and avoiding the copy relocation when we + didn't find any dynamic relocations in the section which has + contents or is read-only. + (WILL_CALL_FINISH_DYNAMIC_SYMBOL): New. + (sh_elf_size_dynamic_sections): Don't reset the size of + .rela.got section even if dynamic_sections_created flag is off. + Don't use sh_elf_discard_copies. Scan all input bfd and use + allocate_dynrelocs. Call readonly_dynrelocs to determine + whether we need DT_TEXTREL. + (sh_elf_adjust_dynamic_symbol): Use plt.refcount to determine + whether the symbol was never referred to. + (sh_elf_relocate_section): Use WILL_CALL_FINISH_DYNAMIC_SYMBOL. + (sh_elf_gc_sweep_hook): Fill with the real sweep function. + (sh_elf_check_relocs): Call create_got_section if the short-cut + to .got is null. Increment reference counters only instead of + allocating space on dynamic sections here. Don't conditionalize + uninitialized got.offset value when marking the symbol as a + global offset table entry. Keep relocations for symbols satisfied + by a dynamic library to avoid copy relocations for the symbol. + Set dynobj field of an elf hash table if needed. + (sh_elf_finish_dynamic_sections): Handle null section pointer + correctly. + (elf_backend_copy_indirect_symbol): Defined. + (elf_backend_can_refcount): Defined. + + 2002-08-22 Nick Clifton <nickc@redhat.com> + * po/tr.po: Updated Turkish translation. + + 2002-08-21 Stephen Clarke <stephen.clarke@superh.com> + * bfd/elf32-sh.c (sh_elf_size_dynamic_sections): Zero + initialize dynamic section. + * bfd/elf64-sh64.c (sh64_elf64_size_dynamic_sections): + Likewise. + + 2002-08-13 H.J. Lu <hjl@gnu.org> + * elflink.h (NAME(bfd_elf,size_dynamic_sections): Don't count + definitions in shared objects when checking symbol with + undefined version. + + 2002-08-10 H.J. Lu <hjl@gnu.org> + * elflink.h (elf_add_default_symbol): Preserve section across + elf_merge_symbol. + + 2002-08-09 Nick Clifton <nickc@redhat.com> + * po/sv.po: Updated Swedish translation. + + 2002-08-08 Alan Modra <amodra@bigpond.net.au> + * elflink.h (elf_link_output_extsym): Don't output symbols from + SEC_EXCLUDE sections. + + * aoutx.h (aout_link_write_symbols): Correct handling of warning syms. + + 2002-08-08 H.J. Lu <hjl@gnu.org> + * elflink.h (elf_add_default_symbol): Don't warn a defintion + overrides an indirect versioned symbol. + + 2002-08-07 Alan Modra <amodra@bigpond.net.au> + * elf64-ppc.c (edit_opd): Arrange to drop symbols for discarded .opd + entries. + + 2002-08-07 Jakub Jelinek <jakub@redhat.com> + * elf32-i386.c (elf_i386_relocate_section): Fill in proper addend + for R_386_TLS_TPOFF32 relocs against symndx 0. + + 2002-08-07 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> + * elfxx-mips.c (mips_elf_global_got_index): Avoid segfault if + g->global_gotsym is NULL. + + 2002-08-06 Alan Modra <amodra@bigpond.net.au> + * xcofflink.c (xcoff_write_global_symbol): Set n_scnum for abs_section. + + 2002-08-06 Alan Modra <amodra@bigpond.net.au> + * elf64-ppc.c (ppc64_elf_howto_raw): Zero all src_mask entries. + + 2002-08-06 H.J. Lu <hjl@gnu.org> + * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Check symbol + with undefined version if needed. + (elf_link_assign_sym_version): Match a default symbol with a + version without definition. No need to hide the default + definition separately. + + 2002-08-06 Alan Modra <amodra@bigpond.net.au> + * coff-rs6000.c: Formatting fixes. + (xcoff_calculate_relocation): Use PARAMS in declaration. + (xcoff_complain_overflow): Likewise. + (xcoff_ppc_relocate_section): Use old-style function pointer call. + (bfd_xcoff_backend_data): Remove useless comments. + (rs6000coff_vec): Likewise. + (bfd_pmac_xcoff_backend_data): Likewise. + (pmac_xcoff_vec): Likewise. + * coff64-rs6000.c: Formatting fixes. + (xcoff64_calculate_relocation): Use PARAMS in declaration. + (xcoff64_ppc_relocate_section): Use old-style function pointer call. + (bfd_xcoff_backend_data): Remove useless comments. + (rs6000coff64_vec): Likewise. + (bfd_xcoff_aix5_backend_data): Likewise. + (aix5coff64_vec): Likewise. + + 2002-08-06 Alan Modra <amodra@bigpond.net.au> + * coff-rs6000.c: (xcoff_rtype2howto): Don't place reloc address in + addend. + * coff64-rs6000.c: (xcoff64_rtype2howto): Likewise. + + 2002-08-06 Alan Modra <amodra@bigpond.net.au> + * coff-rs6000.c (xcoff_howto_table): Revert some of last change to + mask entries. Use complain_overflow_dont for R_REF. + (xcoff_reloc_type_ba): Revert last change. + (xcoff_reloc_type_br): Likewise. + (xcoff_reloc_type_crel): Likewise. + (xcoff_ppc_relocate_section): Likewise. + * coff64-rs6000.c (xcoff64_reloc_type_br): Likewise. + (xcoff64_ppc_relocate_section): Likewise. + (xcoff64_howto_table): Revert some of last change to mask entries. + Use complain_overflow_dont for R_REF. + + * coff-rs6000.c (xcoff_howto_table): Fix src_mask entries. Make all + relocs with bitsize == 16 have size = 1. + (xcoff_reloc_type_ba): Correct src_mask and dst_mask adjustment. + (xcoff_reloc_type_br): Likewise. + (xcoff_reloc_type_crel): Likewise. + (xcoff_ppc_relocate_section): Set up src_mask and dst_mask correctly. + * coff64-rs6000.c (xcoff64_reloc_type_br): Correct src_mask and + dst_mask adjustment. + (xcoff64_ppc_relocate_section): Set up src_mask and dst_mask correctly. + (xcoff64_howto_table): Fix src_mask entries. Make all relocs with + bitsize == 16 have size = 1. + + 2002-07-31 Nick Clifton <nickc@redhat.com> + * bfd.c (bfd_alt_mach_code): Rename parameter 'index' to + 'alternative' in order to avoid shadowing global symbol of the + same name. + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + * libcoff.h: Regenerate. + + 2002-07-30 Alan Modra <amodra@bigpond.net.au> + * aoutx.h (some_aout_object_p): Clean up tdata properly on error. + * archive.c (bfd_generic_archive_p): Likewise. + * coff-rs6000.c (_bfd_xcoff_archive_p): Likewise. + (_bfd_xcoff_archive_p): Use bfd_scan_vma in place of strtol. + * coff64-rs6000.c (xcoff64_slurp_armap): Likewise. + (xcoff64_archive_p): Likewise. + (xcoff64_openr_next_archived_file): Likewise. + (xcoff64_archive_p): Clean up tdata properly on error. + * coffgen.c (coff_real_object_p): Likewise. + (coff_object_p): Release filehdr and opthdr. + * ecoff.c (_bfd_ecoff_archive_p): Clean up tdata properly on error. + * ieee.c (ieee_archive_p): Likewise. + * ihex.c (ihex_object_p): Likewise. + (ihex_mkobject): Always allocate tdata. + * peicode.h (pe_ILF_object_p): Release bfd_alloc'd buffer on error. + * srec.c (srec_mkobject): Always allocate tdata. + (srec_object_p): Clean up tdata properly on error. + (symbolsrec_object_p): Likewise. + * versados.c (versados_object_p): Likewise. + * vms-misc.c (_bfd_vms_get_record): Use bfd_malloc instead of malloc, + and bfd_realloc instead of realloc. + (add_new_contents): Use bfd_alloc instead of bfd_malloc for sections. + * vms.c (vms_initialize): Always allocate tdata. Use bfd_alloc in + place of bfd_malloc, simplifying error freeing. Free hash table too. + (vms_object_p): Clean up tdata on error. + (vms_mkobject): Don't complain on stderr if vms_initialize fails. + (vms_close_and_cleanup): Adjust for bfd_alloc use. + + 2002-07-17 Ian Rickards <irickard@arm.com> + * dwarf2.c (concat_filename): If we can't establish the directory + just return the filename. + + 2002-07-16 Alan Modra <amodra@bigpond.net.au> + * elflink.h: Formatting fixes, tidy prototypes. + (elf_link_assign_sym_version): Move common code out of loop. + + 2002-07-04 Bruno Haible <bruno@clisp.org> + * elf32-i386.c: Don't defined ELF_ARCH etc. if this file is included + by a target variant implementation. + * elf64-alpha.c: Likewise. + * elf32-i386-fbsd.c: New file. + * elf64-alpha-fbsd.c: New file. + * targets.c: Support bfd_elf32_i386_freebsd_vec and + bfd_elf64_alpha_freebsd_vec. + * configure.in: Accept the vectors bfd_elf32_i386_freebsd_vec, + bfd_elf64_alpha_freebsd_vec. + * Makefile.am (BFD32_BACKENDS): Add elf32-i386-fbsd.lo. + (BFD32_BACKENDS_CFILES): Add elf32-i386-fbsd.c. + (BFD64_BACKENDS): Add elf64-alpha-fbsd.lo. + (BFD64_BACKENDS_CFILES): Add elf64-alpha-fbsd.c. + (elf32-i386-fbsd.lo, elf64-alpha-fbsd.lo): Add dependencies. + * config.bfd: For FreeBSD targets, set targ_defvec to a FreeBSD + specific targets. Define OLD_FREEBSD_ABI_LABEL if appropriate. + +2002-09-21 David O'Brien <obrien@FreeBSD.org> + + Merge from mainline: + 2002-08-17 Andrew Cagney <ac131313@redhat.com> + * elf.c (bfd_elf_get_elf_syms): Change type of `esym' to + `bfd_byte'. + +2002-08-26 Alan Modra <amodra@bigpond.net.au> + + * coffcode.h (coff_set_arch_mach_hook): Handle W65MAGIC. + +2002-08-22 Alan Modra <amodra@bigpond.net.au> + + * configure.in: Unset is_release. + * configure: Regenerate. + + * elf-bfd.h (struct elf_backend_data): Add struct elf_backend_data + param to elf_backend_copy_indirect_symbol. + (_bfd_elf_link_hash_copy_indirect): Likewise. + * elflink.h (elf_add_default_symbol, elf_fix_symbol_flags): Adjust + calls to copy_indirect_symbol. + * elf32-hppa.c (elf32_hppa_copy_indirect_symbol): Likewise. + * elf32-i386.c (elf_i386_copy_indirect_symbol): Likewise. + * elf32-s390.c (elf_s390_copy_indirect_symbol): Likewise. + * elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Likewise. + * elf64-s390.c (elf_s390_copy_indirect_symbol): Likewise. + * elf64-x86-64.c (elf64_x86_64_copy_indirect_symbol): Likewise. + * elfxx-ia64.c (elfNN_ia64_hash_copy_indirect): Likewise. + * elfxx-mips.c (_bfd_mips_elf_copy_indirect_symbol): Likewise. + * elfxx-mips.h (_bfd_mips_elf_copy_indirect_symbol): Likewise. + * elf.c (_bfd_elf_link_hash_copy_indirect): Likewise. Properly + test refcounts for "used" values. + +2002-08-15 Hans-Peter Nilsson <hp@axis.com> + + * elf32-cris.c (elf_cris_discard_excess_program_dynamics): Add + missing check for whether the symbol is referenced by DSO before + unexporting it as an unneeded dynamic symbol. + +2002-08-05 Daniel Jacobowitz <drow@mvista.com> + + * configure.in: Bump version, set is_release. + * configure: Regenerated. + +2002-08-01 Daniel Jacobowitz <drow@mvista.com> + + Merge from mainline: + 2002-07-31 Jakub Jelinek <jakub@redhat.com> + * elf32-i386.c (elf_i386_copy_indirect_symbol): Swap tls_type + if _bfd_elf_link_hash_copy_indirect will swap got.refcount. + +2002-07-30 Daniel Jacobowitz <drow@mvista.com> + + Merge from mainline: + 2002-07-30 Nick Clifton <nickc@redhat.com> + * po/sv.po: Updated Swedish translation. + + 2002-07-30 Jakub Jelinek <jakub@redhat.com> + * elf.c (elf_fake_sections): Fix up .tbss sh_size and sh_type. + + 2002-07-26 Chris Demetriou <cgd@broadcom.com> + * elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Merge ASE + flags into resulting BFD. + + 2002-07-25 Alan Modra <amodra@bigpond.net.au> + * elf-bfd.h (_bfd_elf32_link_record_local_dynamic_symbol): Define + as elf_link_record_local_dynamic_symbol. + (_bfd_elf64_link_record_local_dynamic_symbol): Likewise. + (elf_link_record_local_dynamic_symbol): Declare. Now returns int. + * elflink.h (elf_link_record_local_dynamic_symbol): Move to.. + * elflink.c: .. here. Use bfd_elf_get_elf_syms. Check whether an + attempt is made to record a symbol in a discarded section, and + return `2' in that case. + +2002-07-26 Alan Modra <amodra@bigpond.net.au> + + From John Reiser <jreiser@BitWagon.com> + * elf32-i386.c (elf_i386_link_hash_table_create): Clear + tls_ldm_got.refcount. + +2002-07-25 Nick Clifton <nickc@redhat.com> + + * po/sv.po: Updated Swedish translation. + * po/es.po: Updated Spanish translation. + * po/fr.po: Updated French translation. + +2002-07-24 Nick Clifton <nickc@redhat.com> + + * po/sv.po: Updated Swedish translation. + * po/es.po: Updates Spanish translation. + +2002-07-23 Daniel Jacobowitz <drow@mvista.com> + + * configure.in: Bump version for snapshot. + * configure: Regenerated. + +2002-07-23 Daniel Jacobowitz <drow@mvista.com> + + * po/bfd.pot: Regenerated. + +2002-07-23 Nick Clifton <nickc@redhat.com> + + * elf-bfd.h (struct elf_backend_data): Add new bitfield + 'want_p_paddr_set_to_zero'. + * elfxx-target.h: Set default value for want_p_paddr_set_to_zero + to false; + * elfxx-ia64.c: Set want_p_paddr_set_zero for HPUX target. + * elf.c (copy_private_bfd_data): Test want_p_paddr_set_zero. + +2002-07-23 Gabor Keresztfalvi <keresztg@mail.com> + + * nlmcode.h (nlm_swap_auxiliary_headers_out): Swapped the order of + the MeSsAgEs and CoPyRiGhT tags to make >=NW4.x NLM loaders to + show the Copyright string. + +2002-07-23 Nick Clifton <nickc@redhat.com> + + * po/fr.po: New French translation. + * po/sv.po: New Swedish translation. + +2002-07-23 Alan Modra <amodra@bigpond.net.au> + + * elflink.h (elf_link_input_bfd): Don't change internal symbols + when outputting relocs. + 2002-07-20 Jason Thorpe <thorpej@wasabisystems.com> * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Only insert DT_PLTGOT into the dynamic section if there is a PLT. -2002-05-14 Daniel Jacobowitz <drow@mvista.com> +2002-07-19 Alan Modra <amodra@bigpond.net.au> + + * elfxx-ia64.c: (elfNN_ia64_modify_segment_map): Properly scan + PT_IA_64_UNWIND segments for a given section. + +2002-07-16 Moritz Jodeit <moritz@jodeit.org> + + * peXXigen.c (_bfd_XXi_swap_aouthdr_out): Correct order of memset args. + +2002-07-16 Alan Modra <amodra@bigpond.net.au> + + * elflink.h (elf_link_input_bfd): Don't call reloc_emitter when + reloc section size is zero. Correct reloc output location. + + Merge from mainline. + 2002-07-14 H.J. Lu <hjl@gnu.org> + * elflink.h (elf_link_assign_sym_version): Hide the default + definition if there is a hidden versioned definition. + +2002-07-16 John David Anglin <dave@hiauly1.hia.nrc.ca> + + * elf-hppa.h (elf_hppa_reloc_final_type): Use R_PARISC_PCREL16F as + the final type for the e_fsel selector when generating PA2.0W code. + (elf_hppa_relocate_insn): Provide support for PA2.0W 16-bit format 1 + relocations. + +2002-07-12 Hans-Peter Nilsson <hp@axis.com> + + * elf32-cris.c (cris_elf_relocate_section): Drop nonsensical + dynamic reference test in assertion when initializing GOT with + static contents. Just assert that there are either no dynamic + sections, the symbol is defined in the regular objects or that the + symbol is undef weak. Tweak comment. + (elf_cris_finish_dynamic_symbol): Emit .got reloc for a program + only if the symbol isn't defined in the program and isn't undef + weak. + (elf_cris_adjust_dynamic_symbol): Simplify condition for getting + rid of PLT entry: only do it if the symbol isn't defined in a DSO. + When doing so, clear ELF_LINK_HASH_NEEDS_PLT. Tweak comments. + (elf_cris_discard_excess_program_dynamics): Don't consider + ELF_LINK_HASH_REF_DYNAMIC when omitting .got runtime relocs. + +2002-07-11 Alan Modra <amodra@bigpond.net.au> + + * elf32-i386.c (elf_i386_relocate_section): Don't complain about + unresolved debugging relocs in dynamic applications. + * elf32-s390.c (elf_s390_relocate_section): Likewise. + * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. + * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. + * elf64-s390.c (elf_s390_relocate_section): Likewise. + * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. + * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. + +2002-07-10 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (ONES): Define. + (ppc64_elf_howto_table): Use ONES here to avoid warnings. Fill in + missing src_mask fields. Tweak R_PPC64_NONE, R_PPC64_COPY. Fill + in missing dst_mask fields on R_PPC64_PLT32, R_PPC64_PLTREL32. + + * elf64-ppc.c (ppc64_elf_get_symbol_info): Delete. + (ppc64_elf_set_private_flags): Delete. + (ppc64_elf_section_from_shdr): Delete. + (ppc64_elf_merge_private_bfd_data): Remove flag checking/merging code. + (ppc64_elf_fake_sections): Delete. + (bfd_elf64_bfd_set_private_flags): Don't define. + (bfd_elf64_get_symbol_info): Likewise. + (elf_backend_section_from_shdr): Likewise. + (elf_backend_fake_sections): Likewise. + +2002-07-10 Marco Walther <Marco.Walther@sun.com> + + * elf.c: (assign_section_numbers) Set sh_entsize for .stab only + when not already set. + * elf64-sparc.c: (sparc64_elf_fake_sections): New function. + (elf_backend_fake_sections): Define. + +2002-07-10 Alan Modra <amodra@bigpond.net.au> + + * merge.c (_bfd_merge_section): Remove redundant output_section check. + Formatting. + (_bfd_merge_sections): Don't set SEC_EXCLUDE on unused sections. + +2002-07-09 Hans-Peter Nilsson <hp@axis.com> + + * elf32-cris.c (cris_elf_relocate_section): Move sanity-check for + NULL sym_hashes to just before use. + <case R_CRIS_32_GOTREL>: In test for local symbol, accept also + symbol with non-default visibility. + <case R_CRIS_32_GOTREL, case R_CRIS_32_PLT_GOTREL>: Ditto. + <case R_CRIS_8_PCREL, case R_CRIS_16_PCREL, case R_CRIS_32_PCREL>: + Ditto. + (cris_elf_gc_sweep_hook): Only decrease h->plt.refcount for + symbol with non-default visibility. + (cris_elf_check_relocs): At tests for local symbol before + increasing h->plt.refcount, also check for non-default + visibility. Ditto when checking for local symbol to eliminate + pc-relative runtime relocs. + +2002-07-08 Alan Modra <amodra@bigpond.net.au> + + * elf.c: Formatting. + (IS_SOLARIS_PT_INTERP): Add p_paddr and p_memsz checks. + (INCLUDE_SECTION_IN_SEGMENT): Remove IS_SOLARIS_PT_INTERP. + (copy_private_bfd_data): Set p_vaddr on broken Solaris PT_INTERP + segments. + +2002-07-07 Mark Mitchell <mark@codesourcery.com> + Alan Modra <amodra@bigpond.net.au> + + * cofflink.c (_bfd_coff_final_link): On PE COFF systems, take into + account the impact of relocation count overflow when computing + section offsets. + * coffcode.h (coff_write_relocs): Use obj_pe when deciding whether + or not to apply the PE COFF reloc overflow handling. Fix a + fencepost error in deciding whether or not to use that technique. + +2002-07-07 Alan Modra <amodra@bigpond.net.au> + + * elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, + change type of locsyms. + (bfd_elf_get_elf_syms): Declare. + * elf.c (bfd_elf_get_elf_syms): New function. + (group_signature): Use bfd_elf_get_elf_syms. + (bfd_section_from_r_symndx): Likewise. + * elfcode.h (elf_slurp_symbol_table): Likewise. + * elflink.h (elf_link_is_defined_archive_symbol): Likewise. + (elf_link_add_object_symbols): Likewise. Reorganise to increase + locality of various data structures. Properly free internal relocs. + (elf_bfd_final_link): Properly free internal relocs. + (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. + (elf_link_input_bfd): Likewise. + (elf_gc_mark): Likewise. Properly free internal relocs. + (elf_gc_sweep): Properly free internal relocs. + (elf_reloc_symbol_deleted_p): No need to swap syms in. + (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free + internal relocs. + * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. + Properly free possibly cached info. + (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. + (mn10200_elf_symbol_address_p): Pass in internal syms. Remove + symbol swapping code. + (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. + Properly free possibly cached info. + * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. + (mn10300_elf_relax_delete_bytes): Likewise. + (mn10300_elf_symbol_address_p): Likewise. + (mn10300_elf_get_relocated_section_contents): Likewise. + * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. + (elf32_h8_relax_delete_bytes): Likewise. + (elf32_h8_symbol_address_p): Likewise. + (elf32_h8_get_relocated_section_contents): Likewise. + * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. + (m32r_elf_relax_delete_bytes): Likewise. + (m32r_elf_get_relocated_section_contents): Likewise. + * elf32-sh.c (sh_elf_reloc_loop): Free section contents using + elf_section_data to determine whether cached. + (sh_elf_relax_section): As above for elf-m10200.c. + (sh_elf_relax_delete_bytes): Likewise. + (sh_elf_get_relocated_section_contents): Likewise. + * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. + * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay + reading of local syms. + * elf64-mmix.c (mmix_elf_relax_section): Likewise. + * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. + * elfxx-ia64.c (elfNN_ia64_relax_section): As above. + * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal + relocs. + * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly + free internal relocs and section contents. Don't read symbols. + * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. + (elf32_hppa_size_stubs): Don't free local syms. + * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay + reading of local syms. Use bfd_elf_get_elf_syms. Properly free + possibly cached info. + * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. + * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. + * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and + all_local_syms. + (get_local_syms): Delete function. + (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache + on exit. + (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit. + +2002-07-05 Jim Wilson <wilson@redhat.com> + + * syms.c (decode_section_type): New. + (bfd_decode_symclass): Call decode_section_type. + +2002-07-04 Jakub Jelinek <jakub@redhat.com> + + * merge.c (_bfd_merged_section_offset): Avoid accessing byte before + section content start. + Reported by Michael Schumacher <mike@hightec-rt.com>. + +2002-07-04 Alan Modra <amodra@bigpond.net.au> + + * 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 + sections when setting up output section dynsyms. + +2002-07-04 Alan Modra <amodra@bigpond.net.au> + + * elflink.h (elf_link_add_object_symbols): Revert 1999-09-02 hpux + fudge. + * elf.c (bfd_section_from_shdr): Work around broken hpux shared + libs here instead. + +2002-07-02 Martin Schwidefsky <schwidefsky@de.ibm.com> + + * elf64-s390.c (create_got_section): Set .got section alignment to + 8 bytes. + (elf_s390_check_relocs): Set .rela.dyn section alignment to 8 bytes. + +2002-07-02 Alan Modra <amodra@bigpond.net.au> + + * elf.c (_bfd_elf_reloc_type_class): Fix comment grammar. + +2002-07-01 Matt Thomas <matt@3am-software.com> + + * elf32-vax.c (elf32_vax_print_private_bfd_data): Change EF_* + to EF_VAX_*. + +2002-07-01 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> + + * elfxx-mips.c (ABI_64_P): Fix comment. + (MIPS_ELF_OPTIONS_SECTION_NAME,MIPS_ELF_STUB_SECTION_NAME): Use the + new section names for N64 ABI. + (mips_elf_output_extsym): No special _gp_disp handling for NewABI. + (mips_elf_calculate_relocation): Code formatting. + (mips_elf_create_dynamic_relocation): Likewise. + (_bfd_mips_elf_fake_sections): IRIX6 needs this hack, too. + (_bfd_mips_elf_size_dynamic_sections): Handle GOT_PAGE for any NewABI. + (_bfd_mips_elf_relocate_section): No special handling for R_MIPS_64 + in any NewABI. + (_bfd_mips_elf_finish_dynamic_symbol): No special _gp_disp handling + for NewABI. + (_bfd_mips_elf_modify_segment_map): Handle any N64 ABI. + (_bfd_mips_elf_gc_sweep_hook): NewABI GOT relocs should be handled + here, too. + +2002-07-01 Andreas Schwab <schwab@suse.de> + + * elf64-x86-64.c (elf64_x86_64_relocate_section): Only convert + R_X86_64_64 to R_X86_64_RELATIVE. + +2002-07-01 John David Anglin <dave@hiauly1.hia.nrc.ca> + + * vaxbsd.c: New BFD backend for VAX BSD and Ultrix. + * Makefile.am (BFD32_BACKENDS, BFD32_BACKENDS_CFILES): Add new backend. + Run "make dep-am". + * config.bfd (vax-*-bsd* | vax-*-ultrix*): Use vaxbsd_vec instead of + host_aout_vec. + * configure.in (vaxbsd_vec): Add. + * targets.c (vaxbsd_vec): Add. + * Makefile.in: Rebuild. + * configure: Rebuild. + * po/SRC-POTFILES.in: Rebuild. + +2002-07-01 Alan Modra <amodra@bigpond.net.au> + + * elflink.h (elf_gc_mark): Pass in the section whose relocs we are + examining to gc_mark_hook, rather than the bfd. + (elf_gc_sections): Adjust. + * elf-bfd.h (struct elf_backend_data <gc_mark_hook>): Likewise. + * elf-m10300.c (mn10300_elf_gc_mark_hook): Likewise. + * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. + * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. + * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. + * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. + * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. + * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. + * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. + * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. + * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. + * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. + * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. + * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. + * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. + * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. + * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. + * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. + * elf32-vax.c (elf_vax_gc_mark_hook): Likewise. + * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. + * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. + * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. + * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. + * elf64-sh64.c (sh_elf64_gc_mark_hook): Likewise. + * elfxx-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. + * elfxx-mips.h (_bfd_mips_elf_gc_mark_hook): Likewise. + * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. + * elf32-frv.c (elf32_frv_gc_mark_hook): Likewise. Also remove + redundant local sym tests. + * elf64-ppc.c (struct ppc_link_hash_entry): Add is_entry. + (link_hash_newfunc): Init is_entry. + (ppc64_elf_copy_indirect_symbol): Copy is_entry. + (ppc64_elf_link_hash_table_create): Init all_local_syms. + (create_linkage_sections): Use bfd_make_section_anyway rather than + bfd_make_section. + (ppc64_elf_mark_entry_syms): New function. + (ppc64_elf_check_relocs): Don't bother testing elf_bad_symtab. Set + up opd entry to function section map. + (ppc64_elf_gc_mark_hook): Special case opd section relocs, and + relocs that reference the opd section. + (edit_opd): New function. + (ppc64_elf_size_dynamic_sections): Call get_local_syms and edit_opd. + (ppc64_elf_setup_section_lists): Don't calculate htab->bfd_count here. + (get_local_syms): Do so here. Exit if we already have local syms. + Remove bogus comment imported from elf32-hppa.c. Don't attempt to + read local syms on non-ELF input. + (ppc64_elf_size_stubs): Call _bfd_elf64_link_read_relocs rather + than duplicating it's function here. Adjust free of internal + relocs to suit. + (ppc64_elf_relocate_section): Adjust local syms in opd section. + * elf64-ppc.h (ppc64_elf_mark_entry_syms): Declare. + * elf32-hppa.c (elf32_hppa_size_stubs): Call + _bfd_elf32_link_read_relocs rather than duplicating it's function + here. Adjust free of internal relocs to suit. + +2002-07-01 Andreas Jaeger <aj@suse.de> + + * elf64-x86-64.c (elf64_x86_64_check_relocs): Certain relocations + are not allowed in shared libs code, enforce -fPIC. + +2002-06-29 Hans-Peter Nilsson <hp@bitrange.com> + + * mmo.c (mmo_write_loc_chunk): Don't eliminate leading and + trailing zero-sequences when there's previous left-over data. + +2002-06-27 John David Anglin <dave@hiauly1.hia.nrc.ca> + + * elf64-hppa.c (elf64_hppa_reloc_type_class): New function. + (elf64_hppa_finish_dynamic_sections): Check other_rel_sec, dlt_rel_sec + and opd_rel_sec in order for starting rela section. Check _raw_size. + (elf_backend_reloc_type_class): Define. + +2002-06-27 Kevin Buettner <kevinb@redhat.com> + + * dwarf2.c (decode_line_info): Handle older, non-standard, 64-bit + DWARF2 formats. + +2002-06-27 Alan Modra <amodra@bigpond.net.au> + + * cpu-powerpc.c: Comment on ordering of arch_info. + * elf32-ppc.c (ppc_elf_object_p): New function. + (elf_backend_object_p): Define. + * elf64-ppc.c (ppc64_elf_object_p): New function. + (elf_backend_object_p): Define. + +2002-06-26 Jason Thorpe <thorpej@wasabisystems.com> + + * configure.in (vax-*-netbsd*): Set COREFILE to netbsd-core.lo. + * configure: Regenerate. + +2002-06-25 Jason Eckhardt <jle@rice.edu> + + * dwarf2.c (decode_line_info): Check unit->addr_size + to read in the proper number of prologue bytes. + +2002-06-25 Nick Clifton <nickc@cambridge.redhat.com> + + * config.bfd (powerpc-*-aix5*): Only create a selvecs for + aix5coff64_vec if 64-bit bfd support has been enabled. + (powerpc64-*-aix5*): Only define if 64-bit bfd support has + been enabled. + + * targets.c (_bfd_target_vector[]): Only include + aix5coff64_vec if 64-bit bfd support has been enabled. + +2002-06-25 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (ppc_add_stub): Replace strcpy/strncpy with memcpy. + * elf32-hppa.c (hppa_add_stub): Likewise. + * elflink.c (_bfd_elf_link_record_dynamic_symbol): Likewise. + * elflink.h (elf_add_default_symbol): Fix comment typo. + (elf_add_default_symbol): Replace strcpy and strncpy with memcpy. + (elf_link_add_object_symbols): Likewise. + (elf_link_assign_sym_version): Likewise. + * hash.c (bfd_hash_lookup): Likewise. + * linker.c (_bfd_generic_link_add_one_symbol): Likewise. + * section.c (bfd_get_unique_section_name): Likewise. + * syms.c (_bfd_stab_section_find_nearest_line): Likewise. + * elf.c (_bfd_elf_make_section_from_phdr): Likewise. + (assign_section_numbers): Likewise. + (_bfd_elfcore_make_pseudosection): Likewise. + (elfcore_grok_lwpstatus): Likewise. + (elfcore_grok_win32pstatus): Likewise. + (elfcore_write_note): Constify input params. Use PTR instead of + void *. Include terminating NUL in namesz. Correct padding. + Support NULL "name" param. Use memcpy instead of strcpy. + (elfcore_write_prpsinfo): Constify input params. + (elfcore_write_prstatus): Likewise. Use PTR instead of void *. + (elfcore_write_lwpstatus): Likewise. + (elfcore_write_pstatus): Likewise. + (elfcore_write_prfpreg): Likewise. + (elfcore_write_prxfpreg): Likewise. + * elf-bfd.h (elfcore_write_note): Update declaration. + (elfcore_write_prpsinfo): Likewise. + (elfcore_write_prstatus): Likewise. + (elfcore_write_pstatus): Likewise. + (elfcore_write_prfpreg): Likewise. + (elfcore_write_prxfpreg): Likewise. + (elfcore_write_lwpstatus): Likewise. + +2002-06-25 Jason Eckhardt <jle@rice.edu> + + * ecoff.c (ecoff_set_symbol_info): Set BSF_FUNCTION for + symbols of type stProc and stStaticProc. + +2002-06-25 Nick Clifton <nickc@redhat.com> + + * ecoff.c: VArious formatting fixes. + +2002-06-25 Alan Modra <amodra@bigpond.net.au> + + * coff-rs6000.c (xcoff_generate_rtinit): Fix typo. + +2002-06-25 Alan Modra <amodra@bigpond.net.au> + + * aout-adobe.c: Don't compare against "true" or "false. + * aout-target.h: Likewise. + * aoutx.h: Likewise. + * archive.c: Likewise. + * bout.c: Likewise. + * cache.c: Likewise. + * coff-a29k.c: Likewise. + * coff-alpha.c: Likewise. + * coff-i386.c: Likewise. + * coff-mips.c: Likewise. + * coff-or32.c: Likewise. + * coff64-rs6000.c: Likewise. + * coffcode.h: Likewise. + * coffgen.c: Likewise. + * cpu-ns32k.c: Likewise. + * ecoff.c: Likewise. + * ecofflink.c: Likewise. + * elf.c: Likewise. + * elf32-arm.h: Likewise. + * elf32-cris.c: Likewise. + * elf32-d30v.c: Likewise. + * elf32-i386.c: Likewise. + * elf32-mcore.c: Likewise. + * elf32-ppc.c: Likewise. + * elf32-sh.c: Likewise. + * elf32-sh64.c: Likewise. + * elf32-v850.c: Likewise. + * elf64-alpha.c: Likewise. + * elf64-sh64.c: Likewise. + * elfcode.h: Likewise. + * elfcore.h: Likewise. + * elflink.h: Likewise. + * elfxx-mips.c: Likewise. + * i386os9k.c: Likewise. + * ieee.c: Likewise. + * libbfd.c: Likewise. + * linker.c: Likewise. + * mmo.c: Likewise. + * nlm32-alpha.c: Likewise. + * nlm32-i386.c: Likewise. + * nlm32-ppc.c: Likewise. + * nlm32-sparc.c: Likewise. + * nlmcode.h: Likewise. + * oasys.c: Likewise. + * pdp11.c: Likewise. + * peicode.h: Likewise. + * reloc.c: Likewise. + * som.c: Likewise. + * srec.c: Likewise. + * tekhex.c: Likewise. + * vms.c: Likewise. + * xcofflink.c: Likewise. + * elf64-sparc.c: Edit comment to not use "== false". + + * aoutf1.h: Don't use "? true : false". + * ecoff.c: Likewise. + * format.c: Likewise. + * ieee.c: Likewise. + * linker.c: Likewise. + * mmo.c: Likewise. + * oasys.c: Likewise. + +2002-06-23 H.J. Lu <hjl@gnu.org> + + * elflink.h (elf_link_add_archive_symbols): For the default + version, check references with only one `@' first. + +2002-06-23 John David Anglin <dave@hiauly1.hia.nrc.ca> + + * elf64-hppa.c (elf64_hppa_mark_milli_and_exported_functions): New + function. + (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 + elf64_hppa_mark_milli_and_exported_functions. + (elf64_hppa_finish_dynamic_symbol): Remove code to keep millicode + symbols out of dynamic symbol table. + +2002-06-23 Alan Modra <amodra@bigpond.net.au> + + * Makefile.in: Regenerate. + * libbfd.h: Regenerate. + * bfd-in2.h: Regenerate. + * configure: Regenerate. + * po/SRC-POTFILES.in: Regenerate. + + * elflink.h: Comment typo fixes. + +2002-06-23 H.J. Lu <hjl@gnu.org> + + * elf-bfd.h (elf_link_loaded_list): New structure. + (elf_link_hash_table): Add "loaded". + * elf.c (_bfd_elf_link_hash_table_init): Initialize "loaded". + * elflink.h (elf_link_check_versioned_symbol): New function. + (elf_link_output_extsym): Call elf_link_check_versioned_symbol. + +2002-06-19 Nick Clifton <nickc@cambridge.redhat.com> + + * elflink.h (size_dynamic_sections): If the target does not + support an ELF style hash table, return true, indicating that + nothing needed to be done, rather than false, indicating that the + section's size could not be computed. + +2002-06-18 Dave Brolley <brolley@redhat.com> + + From Catherine Moore, Michael Meissner, Dave Brolley: + * po/SRC-POTFILES.in: Add cpu-frv.c and elf32-frv.c + * targets.c: Support bfd_elf32_frv_vec. + * reloc.c: Add FRV relocs. + * configure.in: Add support for bfd-elf32-frv-vec. + * config.bfd (targ_cpu): Add support for frv-*-elf. + * archures.c: Add frv arch and machines. + * Makefile.am (ALL_MACHINES): Add cpu-frv.lo. + (ALL_MACHINES_CFILES): Add cpu-frv.c. + (BFD32_BACKENDS): Add elf32-frv.lo. + (BFD32_BACKENDS_CFILES): Add elf32-frv.c + (cpu-frv.lo): New target. + (elf32-frv.lo): New target. + * cpu-frv.c: New file. + * elf32-frv.c: New file. + +2002-06-18 Jakub Jelinek <jakub@redhat.com> + + * elfcode.h (elf_object_p): Sanity check eh_shoff == 0 implies + e_shnum == 0. + Only read the first section header if e_shoff is non-zero. + Don't consider e_shstrndx if there are no sections. + +2002-06-17 Tom Rix <trix@redhat.com> + + * elf32-d10v.c (elf_d10v_howto_table): Change R_D10V_10_PCREL_R, + R_D10V_10_PCREL_L and R_D10V_18_PCREL to use + complain_overflow_bitfield. + +2002-06-17 Alan Modra <amodra@bigpond.net.au> + + * opncls.c (bfd_openr): Remove redundant bfd_set_error. + (bfd_fdopenr): Likewise. + (bfd_openstreamr): Likewise. + (bfd_openw): Likewise. + + * targets.c: Sort target vecs. + (_bfd_target_vector): Add aix5coff64_vec, bfd_elf32_sh64_vec, + bfd_elf32_sh64l_vec, bfd_elf32_sh64lnbsd_vec, + bfd_elf32_sh64nbsd_vec, bfd_elf64_sh64_vec, bfd_elf64_sh64l_vec, + bfd_elf64_sh64lnbsd_vec, bfd_elf64_sh64nbsd_vec. + * configure.in: Sort target vecs. Add m88kmach3_vec. + * configure: Regenerate. + +2002-06-16 Hans-Peter Nilsson <hp@bitrange.com> + + * elf64-mmix.c (bpo_reloc_request_sort_fn): Use member + bpo_reloc_no to break sort order ties, not address of items. + +2002-06-16 John David Anglin <dave@hiauly1.hia.nrc.ca> + + * elf-hppa.h (elf_hppa_final_link): Fix formatting in comment. + Skip excluded sections in determing __gp value. + (elf_hppa_final_link_relocate): Use the symbol's address in + R_PARISC_FPTR64 relocations that don't need an opd entry. + * elf64-hppa.c (allocate_dynrel_entries): Simplify code. + (elf64_hppa_finalize_dynreloc): Likewise. + (elf64_hppa_size_dynamic_sections): Move comments and fix typo. + (elf64_hppa_finish_dynamic_symbol): Break up assert. + +2002-06-14 Sergey Grigoriev <serge@leopold.Physik.Uni-Augsburg.DE> + + * pei-i386.c (COFF_SECTION_ALIGNMENT_ENTRIES): Enable 16 byte + alignment for .bss, .data and .text sections so that sse and sse2 + code will work. + * pe-i386.c (COFF_SECTION_ALIGNMENT_ENTRIES): Likewise. + +2002-06013 J"orn Rennecke <joern.rennecke@superh.com> + + config.bfd: Add support for sh[1234]l*-*-elf* | sh3el*-*-elf*, + sh[1234]*-elf*. + +2002-06-12 John David Anglin <dave@hiauly1.hia.nrc.ca> + + * elflink.h (elf_bfd_final_link): Improve error handling for missing + dynamic sections. + + * elf64-hppa.c (allocate_global_data_opd): We don't need an opd entry + for a symbol that has no output section. + (allocate_dynrel_entries): Correct comment. + (elf64_hppa_finalize_dynreloc): Likewise. Don't create an opd entry + unless we want one. + (elf64_hppa_finalize_opd): Prevent segfault if dyn_h is NULL. + (elf64_hppa_finalize_dlt): Likewise. Prevent segfault for symbols + with no section. Remove unnecessary parentheses. - * configure.in: Set is_release=y for 2.12.1 release. - * configure: Likewise. +2002-06-11 Tom Rix <trix@redhat.com> + + * coffcode.h (coff_compute_section_file_positions): Add data + section to AIX loader alignment check. + + * coff-rs6000.c (_bfd_xcoff_mkobject): Set default text section + alignment to 4 bytes. + (_bfd_xcoff_copy_private_bfd_data): Use text and data alignment + power accessor macro. + (do_shared_object_padding): Remove invalid assertion. + +2002-06-10 Richard Sandiford <rsandifo@redhat.com> + + * section.c (_bfd_strip_section_from_output): Set SEC_EXCLUDE + for removed output sections. + +2002-06-10 Geoffrey Keating <geoffk@redhat.com> + + * merge.c (merge_strings): Use htab_create_alloc with calloc, not + htab_alloc. + * elf-strtab.c (_bfd_elf_strtab_finalize): Likewise. + +2002-06-08 H.J. Lu <hjl@gnu.org> + + * elf.c (copy_private_bfd_data): Don't cast to bfd_size_type to + work around a long long bug in gcc 2.96 on mips. + +2002-06-08 Jason Thorpe <thorpej@wasabisystems.com> + + * Makefile.am (BFD32_BACKENDS): Add vax1knetbsd.lo. + (BFD32_BACKENDS_CFILES): Add vax1knetbsd.c. + Regenerate dependency lists. + * Makefile.in: Regenerate. + * config.bfd (vax-*-netbsdelf*, vax-*-netbsdaout*): Add + vax1knetbsd_vec to targ_selvecs. + * configure.in: Add vax1knetbsd_vec. + * configure: Regenerate. + * targets.c (_bfd_target_vector): Add vax1knetbsd_vec. + * vax1knetbsd.c: New file. + * vaxnetbsd.c: Update copyright years. + (TARGET_PAGE_SIZE): Set to 0x1000. + (DEFAULT_MID): Set to M_VAX4K_NETBSD. + +2002-06-08 Matt Thomas <matt@3am-software.com> + + * libaout.h (enum machine_type): Add M_VAX4K_NETBSD. + +2002-06-08 Alan Modra <amodra@bigpond.net.au> + + * elf64-sh64.c (sh64_elf64_link_output_symbol_hook): Make static. + +2002-06-08 Alan Modra <amodra@bigpond.net.au> + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + + * armnetbsd.c: Replace CONST with const. + * corefile.c: Likewise. + * elf32-dlx.c: Likewise. + * elf64-mips.c: Likewise. + * mmo.c: Likewise. + * ns32knetbsd.c: Likewise. + + * elf64-sparc.c (sparc64_elf_add_symbol_hook): Check the hash + table is elf64-sparc. + +2002-06-08 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> + + * elfxx-mips.c (_bfd_mips_elf_relocate_section): Simplify code. + Fix RELA addends to get not shifted in the result. Don't do special + handling of R_MIPS_64 for NewABI. + +2002-06-07 Alan Modra <amodra@bigpond.net.au> + + * aoutx.h (NAME(aout,slurp_symbol_table)): Use bfd_zmalloc. + (NAME(aout,slurp_reloc_table)): Likewise. + * coff-mips.c (mips_relax_section): Use bfd_zalloc. + * coff-rs6000.c (xcoff_write_armap_big): Use bfd_zmalloc. + (xcoff_write_archive_contents_big): Likewise. + (xcoff_generate_rtinit): Likewise. + (xcoff_generate_rtinit): Likewise, and check error return. + * coff64-rs6000.c (xcoff64_generate_rtinit): Likewise. + * coffgen.c (coff_section_symbol): Use bfd_zalloc. + (coff_get_normalized_symtab): Likewise. + (coff_make_empty_symbol): Likewise. + (bfd_coff_set_symbol_class): Likewise. + * cofflink.c (coff_link_add_symbols): Likewise. + * ecoff.c (_bfd_ecoff_make_empty_symbol): Likewise. + * ecofflink.c (ecoff_write_shuffle): Use bfd_zmalloc. + (bfd_ecoff_write_accumulated_debug): Likewise. + * elf64-alpha.c (get_got_entry): Use bfd_zalloc. + * i386linux.c (bfd_i386linux_size_dynamic_sections): Likewise. + * i386lynx.c (NAME(lynx,slurp_reloc_table)): Use bfd_zmalloc. + * ieee.c (do_with_relocs): Use bfd_zalloc. + * m68klinux.c (bfd_m68klinux_size_dynamic_sections): Likewise. + * pdp11.c (NAME(aout,slurp_symbol_table)): Use bfd_zmalloc. + (NAME(aout,slurp_reloc_table)): Likewise. + (NAME(aout,squirt_out_relocs)): Don't memset when zalloc'd. + * reloc16.c (bfd_coff_reloc16_relax_section): Use bfd_zmalloc. + * som.c (som_build_and_write_symbol_table): Likewise. + (som_slurp_string_table): Likewise. + (som_slurp_symbol_table): Likewise. + (som_bfd_ar_write_symbol_stuff): Likewise. + * sparclinux.c (bfd_sparclinux_size_dynamic_sections): Use bfd_zalloc. + * sunos.c (bfd_sunos_size_dynamic_sections): Likewise. + * tekhex.c (find_chunk): Likewise. Get rid of unused "sname". + * vms-gsd.c (_bfd_vms_slurp_gsd): Use bfd_zmalloc. + * xcofflink.c (xcoff_link_add_symbols): Use bfd_zalloc/bfd_zmalloc. + +2002-06-07 Alan Modra <amodra@bigpond.net.au> + + * elf-bfd.h (struct bfd_elf_section_data <group_name>): Replace with + "group" union. + (elf_group_name): Update. + (elf_group_id): Define. + (bfd_elf_set_group_contents): Declare. + * elf.c (elf_fake_sections): Qualify use of elf_group_name. + (set_group_contents): Rename to bfd_elf_set_group_contents. Remove + ATTRIBUTE_UNUSED from failedptrarg. If elf_group_id is set, use + that sym for the signature. + (_bfd_elf_compute_section_file_positions): Don't call + set_group_contents for "ld -r" case. + (swap_out_syms): Use bfd_zalloc. + * elflink.h (elf_link_add_archive_symbols): Likewise. + (NAME(bfd_elf,size_dynamic_sections)): Likewise. + (elf_bfd_final_link): Call bfd_elf_set_group_contents. + +2002-06-07 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (ppc64_elf_relocate_section): Allow unresolved + relocs in opd for non-shared too. + +2002-06-06 Jeffrey Law <law@redhat.com + + * elf32-h8300.c (elf32_h8_relax_section): Ignore uninteresting + relocations. + +2002-06-06 Nick Clifton <nickc@cambridge.redhat.com> + + * merge.c: Include libiberty.h. + * elf-strtab.c: Include libiberty.h. + +2002-06-06 Elias Athanasopoulos <eathan@otenet.gr> + + * peXXigen.c (pe_print_idata): Remove unused variable. + +2002-06-06 David Heine <dlheine@tensilica.com> + + * elf.c (assign_file_positions_for_segments): Remove unallocated + sections from the section to segment mapping for PT_LOAD segments. + Update comment about empty loadable segments. + +2002-06-06 Richard Sandiford <rsandifo@redhat.com> + + * stabs.c (_bfd_link_section_stabs): Check that the symbol offset + is within the .stabstr section. + +2002-06-06 Alan Modra <amodra@bigpond.net.au> + + * elf-bfd.h (struct elf_size_info <swap_symbol_in>): Function args + are "const PTR", not "const PTR *". + (bfd_elf32_swap_symbol_in): Likewise. + (bfd_elf64_swap_symbol_in): Likewise. + * elfcode.h (elf_swap_symbol_in): Change input args to const PTR. + (elf_slurp_symbol_table): Adjust call to elf_swap_symbol_in. + * elflink.h (elf_link_is_defined_archive_symbol): Likewise. + (elf_link_add_object_symbols): Likewise. + (elf_link_record_local_dynamic_symbol): Likewise. + (elf_link_input_bfd): Likewise. + (elf_gc_mark): Likewise. + (elf_reloc_symbol_deleted_p): Likewise. + * elf-m10200.c (mn10200_elf_relax_section): Likewise. + (mn10200_elf_relax_delete_bytes): Likewise. + (mn10200_elf_symbol_address_p): Likewise. + (mn10200_elf_get_relocated_section_contents): Likewise. + * elf-m10300.c (mn10300_elf_relax_section): Likewise. + (mn10300_elf_relax_section): Likewise. + (mn10300_elf_relax_delete_bytes): Likewise. + (mn10300_elf_symbol_address_p): Likewise. + (mn10300_elf_get_relocated_section_contents): Likewise. + * elf32-h8300.c (elf32_h8_relax_section): Likewise. + (elf32_h8_relax_delete_bytes): Likewise. + (elf32_h8_symbol_address_p): Likewise. + (elf32_h8_get_relocated_section_contents): Likewise. + * elf32-hppa.c (get_local_syms): Likewise. + * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Likewise. + * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. + * elf32-sh.c (sh_elf_relax_section): Likewise. + (sh_elf_relax_delete_bytes): Likewise. + (sh_elf_get_relocated_section_contents): Likewise. + * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. + * elf64-alpha.c (elf64_alpha_relax_section): Likewise. + * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. + * elf64-mmix.c (mmix_elf_relax_section): Likewise. + * elf64-ppc.c (get_local_syms): Likewise. + * elf64-sh64.c (sh_elf64_get_relocated_section_contents): Likewise. + * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. + +2002-06-05 J"orn Rennecke <joern.rennecke@superh.com> + + * config.bfd (sh64l*-*-elf*, shl*-*-elf*): New configurations. + +2002-06-05 Alan Modra <amodra@bigpond.net.au> + + * elf.c (group_signature): Swap in the whole symbol, and handle + extracting section symbol names. + (setup_group): Add comment. + (set_group_contents): When called from objcopy or ld, arrange for + section contents to be written. Write group member output section + indices to allow objcopy to reorganize sections. + (_bfd_elf_copy_private_section_data): Copy group info. + + * elf-bfd.h (struct elf_size_info): Add swap_symbol_in field. + (bfd_elf32_swap_symbol_in): Update prototype. + (bfd_elf64_swap_symbol_in): Likewise. + * elfcode.h (elf_swap_symbol_in): Change input args to const PTR *. + (elf_slurp_symbol_table): Adjust call to elf_swap_symbol_in. + * elflink.h (elf_link_is_defined_archive_symbol): Likewise. + (elf_link_add_object_symbols): Likewise. + (elf_link_record_local_dynamic_symbol): Likewise. + (elf_link_input_bfd): Likewise. + (elf_gc_mark): Likewise. + (elf_reloc_symbol_deleted_p): Likewise. + * elf-m10200.c (mn10200_elf_relax_section): Likewise. + (mn10200_elf_relax_delete_bytes): Likewise. + (mn10200_elf_symbol_address_p): Likewise. + (mn10200_elf_get_relocated_section_contents): Likewise. + * elf-m10300.c (mn10300_elf_relax_section): Likewise. + (mn10300_elf_relax_section): Likewise. + (mn10300_elf_relax_delete_bytes): Likewise. + (mn10300_elf_symbol_address_p): Likewise. + (mn10300_elf_get_relocated_section_contents): Likewise. + * elf32-h8300.c (elf32_h8_relax_section): Likewise. + (elf32_h8_relax_delete_bytes): Likewise. + (elf32_h8_symbol_address_p): Likewise. + (elf32_h8_get_relocated_section_contents): Likewise. + * elf32-hppa.c (get_local_syms): Likewise. + * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Likewise. + * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. + * elf32-sh.c (sh_elf_relax_section): Likewise. + (sh_elf_relax_delete_bytes): Likewise. + (sh_elf_get_relocated_section_contents): Likewise. + * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. + * elf64-alpha.c (elf64_alpha_relax_section): Likewise. + * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. + * elf64-mmix.c (mmix_elf_relax_section): Likewise. + * elf64-ppc.c (get_local_syms): Likewise. + * elf64-sh64.c (sh_elf64_get_relocated_section_contents): Likewise. + * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. + * elfcode.h (NAME(_bfd_elf,size_info)): Update initialiser. + * elf64-alpha.c (alpha_elf_size_info): Likewise. + * elf64-hppa.c (hppa64_elf_size_info): Likewise. + * elf64-mips.c (mips_elf64_size_info): Likewise. + * elf64-s390.c (s390_elf64_size_info): Likewise. + * elf64-sparc.c (sparc64_elf_size_info): Likewise. + +2002-06-05 Maciej W. Rozycki <macro@ds2.pg.gda.pl> + + * elf32-mips.c (elf32_mips_ignore_discarded_relocs): Move to... + elfxx-mips.c (_bfd_mips_elf_ignore_discarded_relocs): ... here. + elf64-mips.c (elf_backend_ignore_discarded_relocs): Use + _bfd_mips_elf_ignore_discarded_relocs. + elfxx-mips.h (_bfd_mips_elf_ignore_discarded_relocs): Declare. + +2002-06-05 H.J. Lu <hjl@gnu.org> + + * elfxx-mips.c (mips_elf_calculate_relocation): Call + _bfd_elf_rel_local_sym for STT_SECTION relocations against + the SEC_MERGE section. + +2002-06-05 Alan Modra <amodra@bigpond.net.au> + + * coff-alpha.c: Update copyright date. + * coff-mips.c: Likewise. + * xcoff-target.h: Likewise. + + * bfd-in.h: Remove "taken from the source" comment. + * libbfd-in.h: Likewise. + * libcoff-in.h: Likewise. + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + * libcoff.h: Regenerate. + + * elf.c (bfd_elf_discard_group): Return true. + * elf-bfd.h (bfd_elf_discard_group): Declare. + * bfd-in.h (bfd_elf_discard_group): Don't declare here. + * section.c (bfd_discard_group): Rename to bfd_generic_discard_group. + * bfd.c (bfd_discard_group): Define. + * targets.c (struct bfd_target): Add _bfd_discard_group. + (BFD_JUMP_TABLE_LINK): Here too. + * libbfd-in.h (_bfd_nolink_bfd_discard_group): Define. + * aout-adobe.c (aout_32_bfd_discard_group): Define. + * aout-target.h (MY_bfd_discard_group): Define. + * aout-tic30.c (MY_bfd_discard_group): Define. + * binary.c (binary_bfd_discard_group): Define. + * bout.c (b_out_bfd_discard_group): Define. + * coff-alpha.c (_bfd_ecoff_bfd_discard_group): Define. + * coffcode.h (coff_bfd_discard_group): Define. + * coff-mips.c (_bfd_ecoff_bfd_discard_group): Define. + * elfxx-target.h (bfd_elfNN_bfd_discard_group): Define. + * i386msdos.c (msdos_bfd_discard_group): Define. + * i386os9k.c (os9k_bfd_discard_group): Define. + * ieee.c (ieee_bfd_discard_group): Define. + * ihex.c (ihex_bfd_discard_group): Define. + * mmo.c (mmo_bfd_discard_group): Define. + * nlm-target.h (nlm_bfd_discard_group): Define. + * oasys.c (oasys_bfd_discard_group): Define. + * ppcboot.c (ppcboot_bfd_discard_group): Define. + * som.c (som_bfd_discard_group): Define. + * srec.c (srec_bfd_discard_group): Define. + * tekhex.c (tekhex_bfd_discard_group): Define. + * versados.c (versados_bfd_discard_group): Define. + * vms.c (vms_bfd_discard_group): Define. + * xcoff-target.h (_bfd_xcoff_bfd_discard_group): Define. + * coff64-rs6000.c (rs6000coff64_vec): Update initialiser. + (aix5coff64_vec): Likewise. + * coff-rs6000.c (rs6000coff_vec, pmac_xcoff_vec): Likewise. + +2002-06-04 Jason Thorpe <thorpej@wasabisystems.com> + + * Makefile.am (BFD32_BACKENDS): Add elf32-sh64-com.lo. + (BFD32_BACKENDS_CFILES): Add elf32-sh64-com.c. + (elf32-sh64-com.lo): New dependency list. + * Makefile.in: Regenerate. + * configure.in (bfd_elf32_sh64_vec, bfd_elf32_sh64l_vec) + (bfd_elf32_sh64nbsd_vec, bfd_elf32_sh64lnbsd_vec): Add + elf32-sh64-com.lo. + * configure: Regenerate. + * elf32-sh64.c (sh64_address_in_cranges) + (sh64_get_contents_type, sh64_address_is_shmedia): Move to... + (crange_qsort_cmpb, crange_qsort_cmpl, crange_bsearch_cmpb): + (crange_bsearch_cmpl): Prepend _bfd_sh64_ to name and move to... + * elf32-sh64-com.c: ...here. New file. + +2002-06-04 Alan Modra <amodra@bigpond.net.au> + + * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Remove + ATTRIBUTE_UNUSED on used params. + * elf32-vax.c (elf_vax_gc_mark_hook): Remove unnecessary checks + before calling bfd_section_from_elf_index on local syms. + * elf64-sh64.c (sh_elf64_gc_mark_hook): Likewise. + +2002-06-04 Jason Thorpe <thorpej@wasabisystems.com> + + * Makefile.am (BFD32_BACKENDS): Add elf32-sh64-nbsd.lo. + (BFD32_BACKENDS_CFILES): Add elf32-sh64-nbsd.c. + (BFD64_BACKENDS): Add elf64-sh64-nbsd.lo. + (BFD64_BACKENDS_CFILES): Add elf64-sh64-nbsd.c. + (elf32-sh64-nbsd.lo, elf64-sh64-nbsd.lo): New rules. + * Makefile.in: Regenerate. + * config.bfd (sh5le-*-netbsd*, sh5-*-netbsd*, sh64le-*-netbsd*) + (sh64-*-netbsd*): New targets. + * configure.in: Add bfd_elf32_sh64nbsd_vec, bfd_elf32_sh64lnbsd_vec, + bfd_elf64_sh64nbsd_vec, and bfd_elf64_sh64lnbsd_vec. + * configure: Regenerate. + * elf32-sh64-nbsd.c: New file. + * elf64-sh64-nbsd.c: New file. + * targets.c: Add extern decls for bfd_elf32_sh64nbsd_vec, + bfd_elf32_sh64lnbsd_vec, bfd_elf64_sh64nbsd_vec, and + bfd_elf64_sh64lnbsd_vec. + +2002-06-04 Alan Modra <amodra@bigpond.net.au> + + * elf.c (setup_group): Set SEC_LINK_ONCE on GRP_COMDAT groups. + (bfd_section_from_shdr): Likewise. Set section name of group + sections from signature. + (group_signature): Split out from setup_group. Ensure symbol table + is available. + (bfd_elf_discard_group): New function. + (_bfd_elf_make_section_from_shdr): Don't set SEC_LINK_ONCE on + .gnu.linkonce* sections if they are members of a group. + (set_group_contents): Set GRP_COMDAT flag. + * section.c (bfd_discard_group): New function. + * bfd-in.h (bfd_elf_discard_group): Declare. + * bfd-in2.h: Regenerate. + * elf-bfd.h (struct bfd_elf_section_data): Add linkonce_p field. + (elf_linkonce_p): Define. + +2002-06-04 Alan Modra <amodra@bigpond.net.au> + + * elf.c (bfd_section_from_shdr): Make "name" const. + * elf-bfd.h (elf_backend_section_from_shdr): Likewise. + * elf32-i370.c (i370_elf_section_from_shdr): Likewise. + * elf32-ppc.c (ppc_elf_section_from_shdr): Likewise. + * elf32-sh64.c (sh64_backend_section_from_shdr): Likewise. + * elf32-v850.c (v850_elf_section_from_shdr): Likewise. + * elf64-alpha.c (elf64_alpha_section_from_shdr): Likewise. + * elf64-hppa.c (elf64_hppa_section_from_shdr): Likewise. + * elf64-ppc.c (ppc64_elf_section_from_shdr): Likewise. + * elfxx-ia64.c (elfNN_ia64_section_from_shdr): Likewise. + * elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Likewise. + * elfxx-mips.h (_bfd_mips_elf_section_from_shdr): Likewise. + +2002-06-03 Maciej W. Rozycki <macro@ds2.pg.gda.pl> + + * elfxx-mips.c (ABI_64_P): Use backend's data to determine the + ABI. + +2002-06-02 Kazu Hirata <kazu@cs.umass.edu> + + * elf32-arc.c: Fix formatting. + * elf32-arm.h: Likewise. + * elf32-cris.c: Likewise. + * elf32-dlx.c: Likewise. + * elf32-hppa.c: Likewise. + * elf32-i386.c: Likewise. + * elf32-i386qnx.c: Likewise. + * elf32-or32.c: Likewise. + * elf32-s390.c: Likewise. + * elf32-sh64.c: Likewise. + * elf32-vax.c: Likewise. + * elf32-xstormy16.c: Likewise. + * elf64-alpha.c: Likewise. + * elf64-mmix.c: Likewise. + * elf64-ppc.c: Likewise. + * elf64-s390.c: Likewise. + * elf64-sh64.c: Likewise. + * elf64-x86-64.c: Likewise. + +2002-06-02 Richard Henderson <rth@redhat.com> + + * elf64-alpha.c (elf64_alpha_relocate_section): Don't dereference + null when there are no got entries for a symbol. + (elf64_alpha_relax_find_tls_segment): Rearrange to avoid + uninitialized variable warning. + +2002-06-01 Richard Henderson <rth@redhat.com> + + * elf64-alpha.c (elf64_alpha_relax_with_lituse): Don't test for + undefined symbols here. + (elf64_alpha_relax_section): Do it here. Also test for not + defined in the current module. + (elf64_alpha_relocate_section_r): Split out of ... + (elf64_alpha_relocate_section): ... here. Don't dereference + NULL when looking up local got entries. + +2002-06-01 Richard Henderson <rth@redhat.com> + + * elf64-alpha.c (elf64_alpha_relax_with_lituse): Reject undefined + symbols from JSR relaxation. + (elf64_alpha_size_plt_section_1): New. + (elf64_alpha_calc_dynrel_sizes): Split out .rela.got bits ... + (elf64_alpha_size_rela_got_1): ... here. + (elf64_alpha_size_dynamic_sections): Split out .rela.got bits ... + (elf64_alpha_size_rela_got_section): ... here. + (elf64_alpha_size_plt_section): New. + (elf64_alpha_relax_section): Call them. + (elf64_alpha_size_got_sections): Remove output_bfd arg. + (elf64_alpha_finish_dynamic_symbol): Check gotent use_count. + +2002-06-01 Richard Henderson <rth@redhat.com> + + * elf64-alpha.c (alpha_get_dtprel_base, alpha_get_tprel_base): New. + (elf64_alpha_relocate_section): Use them. Reject LE TLS relocs + in shared libraries. Fix DTPRELHI and TPRELHI value. + (INSN_ADDQ, INSN_RDUNIQ): New. + (struct alpha_relax_info): Add symtab_hdr, tls_segment, first_gotent. + (elf64_alpha_relax_with_lituse): Return boolean. Remove irelend + argument. Reject dynamic symbols. Use LITUSE symbolic constants. + (elf64_alpha_relax_got_load): Rename from relax_without_lituse. + Handle GOTDTPREL and GOTTPREL relocations. + (elf64_alpha_relax_gprelhilo): New. + (elf64_alpha_relax_tls_get_addr): New. + (elf64_alpha_relax_find_tls_segment): New. + (elf64_alpha_relax_section): Handle TLS relocations. + (ALPHA_ELF_LINK_HASH_TLS_IE): New. + (elf64_alpha_check_relocs): Set it. + +2002-06-01 Richard Henderson <rth@redhat.com> + + * elf64-alpha.c (elf64_alpha_relax_section): Don't store computed gp. + + * elf64-alpha.c (elf64_alpha_check_relocs): Fix typo on maybe_dynamic + check; don't suppress dynamic relocs for non-allocated sections. + + * elf64-alpha.c: Remove dead code. + +2002-05-31 Alan Modra <amodra@bigpond.net.au> + + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + * po/SRC-POTFILES.in: Regenerate. + + * elf64-ppc.c (ppc64_elf_size_dynamic_sections): Don't allocate + space for bss .plt. + +2002-05-31 Graeme Peterson <gp@qnx.com> + + * Makefile.am (BFD32_BACKENDS): Add elf32-i386qnx.lo. + (BFD32_BACKENDS_CFILES): Add elf32-i386qnx.c. + Run "make dep-am". + * Makefile.in: Regenerate. + * config.bfd: Add i[3456]86-*-nto-qnx* support. + * configure.in: Add bfd_elf32_i386qnx_vec support. + * configure: Regenerate. + * elf-bfd.h (struct elf_backend_data): Add set_nonloadable_filepos, + is_contained_by_filepos, and copy_private_bfd_data_p. + * elf.c (assign_file_positions_for_segments): Call backend + set_nonloadable_filepos. Fix non-K&R call to _bfd_error_handler. + (IS_CONTAINED_BY_FILEPOS): Define. + (INCLUDE_SECTION_IN_SEGMENT): Also test IS_CONTAINED_BY_FILEPOS. + (copy_private_bfd_data): Use IS_CONTAINED_BY_FILEPOS. Typo fix. + Fix non-K&R call to _bfd_error_handler. + (_bfd_elf_copy_private_section_data): Use backend + copy_private_bfd_data_p. + * elf32-i386.c: Don't include elfxx-target.h when + ELF32_I386_C_INCLUDED is defined. + * elf32-i386qnx.c: New QNX elf backend file. + * elfxx-target.h: Add elf_backend_set_nonloadable_filepos, + elf_backend_is_contained_by_filepos, and + elf_backend_do_copy_private_bfd_data. + * targets.c: Add bfd_target bfd_elf32_i386qnx_vec. + +2002-05-31 Alan Modra <amodra@bigpond.net.au> + + * elfarm-oabi.c (bfd_elf32_arm_add_glue_sections_to_bfd): Define. + Move other similar defines to start of file. + +2002-05-30 Tom Rix <trix@redhat.com> + + * coff-rs6000.c (xcoff_rtype2howto): Handle 16 bit R_RBA. + * coff64-rs6000.c (xcoff64_rtype2howto): Same. + +2002-05-30 Richard Henderson <rth@redhat.com> + + * elf64-alpha.c (ALPHA_ELF_LINK_HASH_LU_TLSGD, + ALPHA_ELF_LINK_HASH_LU_TLSLDM, ALPHA_ELF_LINK_HASH_LU_FUNC): New. + (ALPHA_ELF_GOT_ENTRY_RELOCS_DONE): Remove. + (ALPHA_ELF_GOT_ENTRY_RELOCS_XLATED): Remove. + (struct alpha_elf_got_entry): Add reloc_type, reloc_done, reloc_xlated. + (struct alpha_elf_obj_tdata): Rename total_got_entries and + n_local_got_entries to total_got_size and local_got_size. + (elf64_alpha_howto, elf64_alpha_reloc_map): Update for TLS relocs. + (alpha_got_entry_size): New. + (elf64_alpha_relax_with_lituse): Use it. + (elf64_alpha_relax_without_lituse): Likewise. + (MAX_GOT_SIZE): Rename from MAX_GOT_ENTRIES. + (get_got_entry): New. + (elf64_alpha_check_relocs): Handle TLS relocs. Reorganize. + (elf64_alpha_adjust_dynamic_symbol): Test LU_FUNC as a mask. + (elf64_alpha_merge_ind_symbols): Check gotent->reloc_type. + (elf64_alpha_can_merge_gots, elf64_alpha_merge_gots): Likewise. + (elf64_alpha_calc_got_offsets_for_symbol): Use alpha_got_entry_size. + (elf64_alpha_calc_got_offsets): Likewise. + (alpha_dynamic_entries_for_reloc): New. + (elf64_alpha_calc_dynrel_sizes): Use it. + (elf64_alpha_size_dynamic_sections): Likewise. + (elf64_alpha_relocate_section): Handle TLS relocations. + * reloc.c: Add Alpha TLS relocations. + * bfd-in2.h, libbfd.h: Rebuild. + +2002-05-29 Ralf Habacker <ralf.habacker@freenet.de> + + * peXXigen.c (pe_print_idata): Remove double printed + import table lines; add Bound-To comment. + +2002-05-29 Matt Thomas <matt@3am-software.com> + + * Makefile.am (BFD32_BACKENDS): Add elf32-vax.lo. + (BFD32_BACKENDS_CFILES): Add elf32-vax.c. + (elf32-vax.lo): New rule. + * Makefile.in: Regenerate. + * configure.in (bfd_elf32_vax_vec) + (vaxnetbsd_vec): New vectors. + * configure: Regenerate. + * config.bfd (vax-*-netbsdelf*) + (vax-*-netbsdaout*) + (vax-*-netbsd*): New targets. + * elf32-vax.c: New file. + * reloc.c: Add VAX relocations. + * bfd-in2.h: Regenerate. + * targets.c (_bfd_target_vector): Add bfd_elf32_vax_vec. + +2002-05-29 Jason Thorpe <thorpej@wasabisystems.com> + + * config.bfd (arm-*-netbsd*): Add bfd_elf32_littlearm_vec + and bfd_elf32_bigarm_vec to targ_selvecs. + +2002-05-29 Ralf Habacker <ralf.habacker@freenet.de> + + * peXXigen.c (pe_print_idata): Fix seg faults on printing import tables + with auto-imported symbols. + +2002-05-29 Adam Nemet <anemet@lnxw.com> + + * elf32-arm.h (bfd_elf32_arm_get_bfd_for_interworking): Don't add glue + sections only record bfd. + (bfd_elf32_arm_add_glue_sections_to_bfd): New function. + * bfd-in.h (bfd_elf32_arm_add_glue_sections_to_bfd): Declare it. + * bfd-in2.h: Regenerate. + +2002-05-28 Nick Clifton <nickc@cambridge.redhat.com> + + * syms.c (_bfd_stab_section_find_nearest_line): Move + declaration and initialisation of saw_line and saw_func out of + for loop. + +2002-05-29 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (ppc64_elf_get_symbol_info): New function. + (bfd_elf64_get_symbol_info): Define. + * elfxx-target.h (bfd_elfNN_get_symbol_info): Only define if undef. + +2002-05-29 Andrey Volkov <avolkov@transas.com> + + * cpu-h8300.c: Make default h8300 machine first in machine list. + +2002-05-28 Kuang Hwa Lin <kuang@sbcglobal.net> + + * config.bfd: Added DLX configuraton. + * Makefile.am: Added DLX configuraton. + * configure.in: Added DLX configuraton. + * archures.c: Add DLX architecure. + * reloc.c: Add DLX relocs. + * targets.c: Added DLX target vector. + * configure: Regenerate. + * Makefile.in: Regenreate. + * bfd-in2.h: Regenreate. + * elf32-dlx.c: New file: Support DLX target. + * cpu-dlx.c: New file: Support DLX target. + +2002-05-25 Alan Modra <amodra@bigpond.net.au> + + * elf32-m68k.c (elf32_m68k_print_private_bfd_data): Formatting. + + * elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Revert last change. + (ppc64_elf_check_relocs): Don't set up function descriptor symbol + strings to point inside function code sym string. + (func_desc_adjust): Likewise. + (ppc64_elf_hide_symbol): Rewrite code to look up function code sym. + +2002-05-24 Michal Ludvig <mludvig@suse.cz> + + * elf64-x86-64.c (elf64_x86_64_grok_prstatus): Added. + (elf64_x86_64_grok_psinfo): Added. + +2002-05-24 TAMURA Kent <kent@netbsd.org> + + * config.bfd: Add a target for i386-netbsdpe. + +2002-05-24 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Don't copy is_func + and is_func_descriptor. + (func_desc_adjust): Hide function code sym in shared libs unless + there is a matching exported function descriptor sym. + +2002-05-23 Jakub Jelinek <jakub@redhat.com> + + * elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL + for symbols from SHF_TLS section. + (_bfd_elf_print_private_bfd_data): Add PT_TLS. + (elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections. + (map_sections_to_segments): Build PT_TLS segment if necessary. + (assign_file_positions_for_segments): Likewise. + (get_program_header_size): Account for PT_TLS segment. + (swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from + SEC_THREAD_LOCAL sections to STT_TLS. + * reloc.c: Add 386 and IA-64 TLS relocs. + * section.c (SEC_THREAD_LOCAL): Define. + (SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS): + Remove. + * elflink.h (elf_link_add_object_symbols): Support .tcommon. + (size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS + unconditionally. + (struct elf_final_link_info): Add first_tls_sec. + (elf_bfd_final_link): Set first_tls_sec. + Compute elf_hash_table (info)->tls_segment. + (elf_link_output_extsym): Handle STT_TLS symbols. + (elf_link_input_bfd): Likewise. + * syms.c (BSF_THREAD_LOCAL): Define. + * bfd-in2.h: Rebuilt. + * libbfd.h: Rebuilt. + * elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff, + elf_i386_mkobject, elf_i386_object_p): New functions. + (elf_howto_table): Add TLS relocs. + (elf_i386_reloc_type_lookup): Support TLS relocs. + (elf_i386_info_to_howto_rel): Likewise. + (struct elf_i386_link_hash_entry): Add tls_type. + (struct elf_i386_obj_tdata): New. + (elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type): + New macros. + (struct elf_i386_link_hash_table): Add tls_ldm_got. + (link_hash_newfunc): Clear tls_type. + (elf_i386_check_relocs): Support TLS relocs. + (elf_i386_gc_sweep_hook): Likewise. + (allocate_dynrelocs): Likewise. + (elf_i386_size_dynamic_sections): Likewise. + (elf_i386_relocate_section): Likewise. + (elf_i386_finish_dynamic_symbol): Likewise. + (bfd_elf32_mkobject, elf_backend_object_p): Define. + * elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset, + dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done, + want_tprel, want_dtpmod, want_dtprel. + (elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions. + (ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to + R_IA64_LTOFF_TPREL22. + (elf_code_to_howto_index): Add TLS relocs. + (elfNN_ia64_check_relocs): Support TLS relocs. + (allocate_global_data_got): Account for TLS .got data. + (allocate_dynrel_entries): Account for TLS dynamic relocations. + (elfNN_ia64_install_value): Supprt TLS relocs. + (set_got_entry): Support TLS relocs. + (elfNN_ia64_relocate_section): Likewise. + +2002-05-23 Nick Clifton <nickc@cambridge.redhat.com> + + * elf32-arm.h (elf32_arm_final_link_relocate): For the Thumb + BLX reloc round the relocation up rather than down. + * coff-arm.c (coff_arm_relocate_section): Likewise. + +2002-05-21 H.J. Lu (hjl@gnu.org) + + * linker.c (_bfd_generic_link_add_one_symbol): Allow multiple + definition. + +2002-05-22 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (ppc64_elf_size_stubs): Don't strip .branch_lt. + (ppc64_elf_relocate_section): Handle unresolved relocs in opd. + +2002-05-22 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (ppc64_elf_relocate_section): Return false for + unresolved relocs. + (ppc64_elf_size_dynamic_sections): Check for splt NULL. + +2002-05-21 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> + + * bfd/bfd.c (bfd_get_arch_size): Remove bfd_set_error call for + non-ELF targets. + +2002-05-21 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> + + * elf-bfd.h (elf_backend_emit_relocs): Change prototype to return + an error value. + * elflink.h (elf_link_output_relocs): Likewise. Improve error message. + return with false on error. + (elf_link_input_bfd): Check reloc_emitter return value. + +2002-05-21 Jason Thorpe <thorpej@wasabisystems.com> + + * config.bfd (armeb-*-netbsdelf*): New target. + +2002-05-20 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (ppc_build_one_stub): Point undefined function syms + at the plt call stub. + +2002-05-19 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> + + * cpu-mips.c (mips_compatible): Don't try to check machine + compatibility. + +2002-05-18 Tom Rix <trix@redhat.com> + + * coff64-rs6000.c (_bfd_xcoff64_swap_aux_out): Fix C_FILE auxent. + +2002-05-17 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (ppc64_elf_info_to_howto): Formatting. + (ppc64_elf_relocate_section): Don't warn about reloc overflow when + we've already warned about an undefined symbol. Report more + detail on reloc errors. + +2002-05-17 Alan Modra <amodra@bigpond.net.au> + + * acinclude.m4 (AM_INSTALL_LIBBFD): New. + * configure.in: Invoke AM_INSTALL_LIBBFD. + * Makefile.am (install-data-local): Revert 2002-05-13. Move to.. + (install_libbfd): .. New target. + (uninstall_libbfd): Likewise. + (install-bfdlibLTLIBRARIES): Likewise. + (uninstall-bfdlibLTLIBRARIES): Likewise. + (bfdlibdir): New. + (bfdincludedir): New. + (lib_LTLIBRARIES): Rename to bfdlib_LTLIBRARIES. + * aclocal.m4: Regenerate. + * configure: Regenerate. + * Makefile.in: Regenerate. + +2002-05-17 Stuart Balfour <sbalfour@cisco.com> + + * hash.c (bfd_hash_lookup): Remove computation of len from inside + hash loop. + +2002-05-16 Nick Clifton <nickc@cambridge.redhat.com> + + * config.bfd: Add targets for sh64-linux (little endian and + big endian). + +2002-05-15 Laurent Pinchart <laurent.pinchart@skynet.be> + + * peXXigen.c (pe_print_idata): Do not assume that the first thunk + is located in the same section as the import table. Instead + check, and if necessary load the section containing the thunk. + +2002-05-15 Nick Clifton <nickc@cambridge.redhat.com> + + * aix5ppc-core.c (xcoff64_core_p): Replace bfd_read with + bfd_bread. + (xcoff64_core_file_matches_executable_p): Replace bfd_read + with bfd_bread. + +2002-05-15 Alan Modra <amodra@bigpond.net.au> + + * aix5ppc-core.c: Warning fixes. + * aout-adobe.c (aout_32_bfd_link_just_syms): Define. + * aout-target.h (MY_bfd_link_just_syms): Define. + * aout-tic30.c (MY_bfd_link_just_syms): Define. + * bfd.c (bfd_link_just_syms): Define. + * binary.c (binary_bfd_link_just_syms): Define. + * bout.c (b_out_bfd_link_just_syms): Define. + * coff-rs6000.c (rs6000coff_vec, pmac_xcoff_vec): Update initializer. + * coff64-rs6000.c (rs6000coff64_vec, aix5coff64_vec): Likewise. + * coffcode.h (coff_bfd_link_just_syms): Define. + * elf-bfd.h (enum elf_link_info_type): Add ELF_INFO_TYPE_JUST_SYMS. + (elf_discarded_section): Check for ELF_INFO_TYPE_JUST_SYMS. + (_bfd_elf_link_just_syms): Declare. + * elf.c (_bfd_elf_link_just_syms): New function. + * elf-eh-frame.c (_bfd_elf_maybe_strip_eh_frame_hdr): Check that + sections haven't already been discarded by the linker. + * elflink.h (elf_link_add_object_symbols): Likewise for stab + sections and SEC_MERGE sections. + (elf_bfd_discard_info): Similarly here. + * elfxx-target.h (bfd_elfNN_bfd_link_just_syms): Define. + * i386msdos.c (msdos_bfd_link_just_syms): Define. + * i386os9k.c (os9k_bfd_link_just_syms): Define. + * ieee.c (ieee_bfd_link_just_syms): Define. + * ihex.c (ihex_bfd_link_just_syms): Define. + * libbfd-in.h (_bfd_nolink_bfd_link_just_syms): Define. + (_bfd_generic_link_just_syms): Declare. + * libecoff.h (_bfd_ecoff_bfd_link_just_syms): Define. + * linker.c (_bfd_generic_link_just_syms): New function. + * mmo.c (mmo_bfd_link_just_syms): Define. + * nlm-target.h (nlm_bfd_link_just_syms): Define. + * oasys.c (oasys_bfd_link_just_syms): Define. + * ppcboot.c (ppcboot_bfd_link_just_syms): Define. + * som.c (som_bfd_link_just_syms): Define. + * srec.c (srec_bfd_link_just_syms): Define. + * targets.c (struct bfd_target): Add _bfd_link_just_syms. + (BFD_JUMP_TABLE_LINK): And here. + * tekhex.c (tekhex_bfd_link_just_syms): Define. + * versados.c (versados_bfd_link_just_syms): Define. + * vms.c (vms_bfd_link_just_syms): Define. + * libbfd.h: Regenerate. + * bfd-in2.h: Regenerate. + +2002-05-15 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> + + * elf32-mips.c: Remove superfluous definitions copied from + elfxx-mips.c. + (bfd_elf32_bigmips_vec,bfd_elf32_littlemips_vec): Use the + SGIish vectors to check the special case. + (mips_elf_hi16_reloc): Fix comment. + (mips_elf_got16_reloc): Likewise. + (_bfd_mips_elf32_gprel16_reloc): Likewise. + (elf_reloc_map): Code cleanup. + (mips_reloc_map): Add comment. + (bfd_elf23_bfd_reloc_type_lookup): Code cleanup. + (mips_elf32_rtype_to_howto): Likewise. + (mips_elf32_discard_info): Likewise. + (elf32_mips_irix_compat): Invert logic: Only SGIish vectors + lead to IRIX compatibility now. + +2002-05-15 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> + + * elfxx-mips.c: Call it IRIX, not Irix in comments. + +2002-05-13 Jason Thorpe <thorpej@wasabisystems.com> + + * config.bfd (shle-*-netbsdelf*): Add target which includes + sh64 support. 2002-05-13 David Edelsohn <edelsohn@gnu.org> - * configure.in: Auto-configure HAVE_ST_C_IMPL. + * configure.in: Revert 2002-04-07. Instead, auto-configure + HAVE_ST_C_IMPL. * configure: Regenerate. * config.in: Regenerate. * rs6000-core.c (CNEW_IMPL): Guard use of c_impl with HAVE_ST_C_IMPL or AIX_5_CORE. -2002-05-11 Daniel Jacobowitz <drow@mvista.com> +2002-05-11 Federico G. Schwindt <fgsch@olimpo.com.br> - Merge from mainline (to elf32-mips.c): - 2002-05-03 H.J. Lu (hjl@gnu.org) + * configure.in (sparc*-*-openbsd*): Support sparc64-openbsd + corefiles as well.2 + * configure: Regenerate. - * elfxx-mips.c (mips_elf_link_hash_entry): Add forced_local. - (mips_elf_link_hash_newfunc): Initialize forced_local to false. - (mips_elf_record_global_got_symbol): Call _bfd_mips_elf_hide_symbol - to hide a global symbol. - (_bfd_mips_elf_hide_symbol): Return if forced_local is true. Set - forced_local to true. +2002-05-13 Alan Modra <amodra@bigpond.net.au> + + * Makefile.am (install-data-local): Install headers to + $(exec_prefix)/include. + * Makefile.in: Regenerate. 2002-05-11 Ralf Corsepius <corsepiu@faw.uni-ulm.de> Daniel Jacobowitz <drow@mvista.com> @@ -34,19 +1996,48 @@ * coff-sh.c (sh_reloc_map): Map to R_SH_IMM32 for non-PE. Don't map BFD_RELOC_RVA. +2002-05-11 Federico G. Schwindt <fgsch@olimpo.com.br> + + * config.bfd (alpha*-*-openbsd*, sparc64*-*-openbsd*, + hppa*-*-openbsd*): New targets. + * configure.in (alpha*-*-openbsd*): Set COREFILE. + * configure: Regenerate. + +2002-05-10 Tom Rix <trix@redhat.com> + + * coff64-rs6000.c (xcoff64_reloc_type_br): New function for + xcoff64_ppc_relocate_section. + * coff-rs6000.c : Extern common xcoff_reloc_type functions. + * libxcoff.h: Common xcoff_reloc_type function declaration. + +2002-05-10 Alan Modra <amodra@bigpond.net.au> + + * elf32-i386.c (elf_i386_relocate_section): Remove overflow checks + added in 2002-05-09 commit. + + * elf32-hppa.c (elf32_hppa_size_stubs): Revert part of 2002-05-04, + don't look for stubs on all undefined syms. + 2002-05-09 Alan Modra <amodra@bigpond.net.au> * elf64-ppc.c (RA_REGISTER_MASK, RA_REGISTER_SHIFT): Delete. + (ppc64_elf_howto_raw <R_PPC64_RELATIVE>): Not pc_relative or + pcrel_offset. + + * elf32-i386.c (elf_howto_table): Comments. + (elf_i386_relocate_section): Handle more relocs for relocatable + linking and against SEC_MERGE sections. + +2002-05-08 Alan Modra <amodra@bigpond.net.au> - Merge from mainline - 2002-05-08 Alan Modra <amodra@bigpond.net.au> * elf32-ppc.c (ppc_elf_create_got): New function. (ppc_elf_create_dynamic_sections): Call ppc_elf_create_got before - _bfd_elf_create_dynamic_sections. Correct .plt flags. + _bfd_elf_create_dynamic_sections. Correct .plt flags. (ppc_elf_check_relocs): Use ppc_elf_create_got in place of _bfd_elf_create_got_section. - 2002-05-07 Alan Modra <amodra@bigpond.net.au> +2002-05-07 Alan Modra <amodra@bigpond.net.au> + * elf-bfd.h (struct elf_backend_data): Add rela_normal. * elfxx-target.h (elf_backend_rela_normal): Define. (elfNN_bed): Init rela_normal. @@ -88,11 +2079,21 @@ * elf32-arm.h (elf_backend_rela_normal): Define #ifndef USE_REL. * elf32-m32r.c (elf_backend_rela_normal): Likewise. - 2002-05-06 Alan Modra <amodra@bigpond.net.au> +2002-05-06 Nick Clifton <nickc@cambridge.redhat.com> + + * elf32-arm.h (elf32_arm_final_link_relocate): Convert + 'reloc_signed_max' and 'reloc_signed_min' into half-word offsets. + +2002-05-06 Alan Modra <amodra@bigpond.net.au> + * elflink.h (elf_link_input_bfd <emit_relocs>): Adjust r_offset when not relocatable. Fix reloc_emitter call for K&R. - 2002-05-04 Alan Modra <amodra@bigpond.net.au> +2002-05-04 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (ppc64_elf_relocate_section): Reinstate code + reloading local sym addend mistakenly removed in 2002-05-01 change. + * dwarf2.c (struct line_head): Make prologue_length a bfd_vma. (read_abbrevs): Change "offset" param to bfd_vma. (parse_comp_unit): Change "version" and addr_size to unsigned ints. @@ -105,11 +2106,66 @@ (scan_unit_for_functions): Likewise. (parse_comp_unit): Likewise. - 2002-05-04 Bob Byrnes <byrnes@curl.com> +2002-05-04 Tom Rix <trix@redhat.com> + + * coffswap.h (coff_swap_reloc_in): Remove XCOFF support. + (coff_swap_reloc_out): Same. + * coff-rs6000.c: (xcoff_swap_reloc_in): Moved from coffswap.h. + (xcoff_swap_reloc_out): Same. + (xcoff_rtype2howto): Renamed from _bfd_xcoff_rtype2howto. Special + case some 16 bit relocs. Add reloc value to output. + (xcoff_howto_table): Remove 64 bit R_POS, add 16 bit + R_RBR. Improve names. + (_bfd_xcoff_reloc_type_lookup): Adjust for removal of 64 bit R_POS. + (bfd_xcoff_backend_data): Update with new reloc swap names. + (bfd_pmac_xcoff_backend_data) : Same. + * coff64-rs6000.c: (xcoff64_swap_reloc_in): Moved from coffswap.h. + (xcoff64_swap_reloc_out): Same. + (xcoff64_rtype2howto): Special case some 16 bit relocs and 32 bit + R_POS. Add reloc value to output. + (xcoff64_howto_table): Move 64 bit R_POS to first entry. Add 16 + bit R_RBR. Improve names, masks. + (xcoff64_reloc_type_lookup): Adjust for move of 64 bit R_POS. + (bfd_xcoff_backend_data): Update with new reloc swap names. + (bfd_xcoff_aix5_backend_data) : Same. + +2002-05-04 Alan Modra <amodra@bigpond.net.au> + + * elf32-hppa.c (struct elf32_hppa_link_hash_table): Add + bfd_count top_index, input_list, all_local_syms. + (elf32_hppa_setup_section_lists): New function, split from + elf32_hppa_size_stubs. + (elf32_hppa_next_input_section): Likewise. + (group_sections): Likewise. + (get_local_syms): Likewise. + (elf32_hppa_size_stubs): Adjust for split out functions. Look for + stubs on undefined syms too. + (elf32_hppa_set_gp): Use bfd_link_hash* instead of elf_link_hash*. + Only access htab elf fields when we have an elf hash table. + * elf32-hppa.h (elf32_hppa_setup_section_lists): Declare. + (elf32_hppa_next_input_section): Declare. + +2002-05-04 Bob Byrnes <byrnes@curl.com> + * opncls.c (_bfd_new_bfd_contained_in): Check return value of _bfd_new_bfd. - 2002-05-02 Alan Modra <amodra@bigpond.net.au> +2002-05-03 H.J. Lu (hjl@gnu.org) + + * elfxx-mips.c (mips_elf_link_hash_entry): Add forced_local. + (mips_elf_link_hash_newfunc): Initialize forced_local to false. + (mips_elf_record_global_got_symbol): Call _bfd_mips_elf_hide_symbol + to hide a global symbol. + (_bfd_mips_elf_hide_symbol): Return if forced_local is true. Set + forced_local to true. + +2002-05-02 Richard Henderson <rth@redhat.com> + + * elf64-alpha.c (elf64_alpha_relocate_section): Force relative relocs + vs SHN_UNDEF to zero. + +2002-05-02 Alan Modra <amodra@bigpond.net.au> + * elf64-ppc.c (ppc64_elf_howto_raw <R_PPC64_SECTOFF>): Change to a 16 bit reloc. <R_PPC64_SECTOFF_DS>: Likewise. @@ -118,6 +2174,7 @@ * elf32-ppc.c (ppc_elf_howto_raw <R_PPC_SECTOFF>): Correct. (ppc_elf_reloc_type_lookup): Map from BFD_RELOC_16_BASEREL to SECTOFF reloc. + * elf64-ppc.c (ppc64_elf_addr16_ha_reloc): Delete. (ppc64_elf_ha_reloc): New function. (ppc64_elf_brtaken_reloc): New function. @@ -137,18 +2194,24 @@ (func_desc_adjust): Set have_undefweak. (ppc64_elf_func_desc_adjust): Call func_desc_adjust earlier. Only add the .sfpr blr when have_undefweak. + (ppc64_elf_setup_section_lists): Check hash table flavour. + (ppc64_elf_next_input_section): Move output_section->owner test to + ppc64elf.em. (ppc64_elf_set_toc): Rename to ppc64_elf_toc, remove info param and relocatable test. Return TOCstart and don't set elf_gp. (ppc64_elf_relocate_section): Correct BRTAKEN/BRNTAKEN branch offset calculation. Add assert on weak sym branch tweaks. * elf64-ppc.h (ppc64_elf_set_toc): Delete. (ppc64_elf_toc): Declare. + (ppc64_elf_next_input_section): Update. + +2002-05-01 Alan Modra <amodra@bigpond.net.au> - 2002-05-01 Alan Modra <amodra@bigpond.net.au> * syms.c (_bfd_stab_section_find_nearest_line): Don't bomb on NULL file_name. - 2002-05-01 Alan Modra <amodra@bigpond.net.au> +2002-05-01 Alan Modra <amodra@bigpond.net.au> + * elf64-ppc.c (CROR_151515, CROR_313131): Define. (ppc64_elf_relocate_section): Use them. Don't look for plt calls on R_PPC64_ADDR24 relocs. Require a nop or no link reg on plt @@ -157,92 +2220,116 @@ .sfpr, and correct case where either only savef* or restf* is needed. - 2002-04-09 DJ Delorie <dj@redhat.com> - * elfarm-nabi.c (elf32_arm_howto_table): Fix ABS16 masks. + Long branch stubs, multiple stub sections. + * elf64-ppc.h (ppc64_elf_setup_section_lists): Declare. + (ppc64_elf_next_input_section): Declare. + * elf64-ppc.c: Move linker-only prototypes. + (STUB_SUFFIX): Define. + (enum ppc_stub_type): New. + (struct ppc_stub_hash_entry): New. + (struct ppc_branch_hash_entry): New. + (struct ppc_link_hash_entry): Add stub_cache, oh. + (struct ppc_link_hash_table): Add stub_hash_table etc. Remove + sstub. Add sbrlt, srelbrlt, has_14bit_branch, stub_iteration. + Rename plt_overflow to stub_error. + (ppc_stub_hash_lookup): Define. + (ppc_branch_hash_lookup): Define. + (stub_hash_newfunc): New function. + (branch_hash_newfunc): New function. + (link_hash_newfunc): Init new fields. + (ppc64_elf_link_hash_table_create): Likewise. + (ppc64_elf_link_hash_table_free): New function. + (ppc_stub_name): New function. + (ppc_get_stub_entry): New function. + (ppc_add_stub): New function. + (create_linkage_sections): Use bfd_make_section_anyway. Create + .branch_lt and .rela.branch_lt sections. Don't create .stub. + (ppc64_elf_check_relocs): Set has_14bit_branch on R_PPC64_REL14*, + and set up for plt call stubs. Link func and func desc syms. + (ppc64_elf_gc_sweep_hook): Handle REL14* as per REL24. + (func_desc_adjust): Avoid hash lookup when func desc sym available + via shortcut, and set links when processing. + (ppc64_elf_hide_symbol): Likewise. + (allocate_dynrelocs): Don't allocate stub section here. + (ppc64_elf_size_dynamic_sections): Handle sbrlt and srelbrlt. + Remove sstub code. + (ppc_type_of_stub): New function. + (build_one_stub): Delete. + (ppc_build_one_stub): New function. + (ppc_size_one_stub): New function. + (ppc64_elf_setup_section_lists): New function. + (ppc64_elf_next_input_section): New function. + (group_sections): New function. + (get_local_syms): New function. + (ppc64_elf_size_stubs): Rewrite. + (ppc64_elf_build_stubs): Rewrite. + (ppc64_elf_relocate_section): Look up stub entry for REL24 + relocs. Don't propagate REL14* to dynamic objects. Look for long + branch stubs if REL14* or REL24 relocs won't reach. + (bfd_elf64_bfd_link_hash_table_free): Define. + +2002-04-30 Mark Mitchell <mark@codesourcery.com> + + * bfd/config.bfd: Add support for powerpc-*-windiss. + +2002-04-30 Tom Rix <trix@redhat.com> + + * xcofflink.c (xcoff_link_add_symbols): Always copy undef C_EXT + symbol names into the hash table. + +2002-04-28 Tom Rix <trix@redhat.com> + + * coff-rs6000.c (xcoff_calculate_relocation) : Function table for + calulating relocations. + (xcoff_complain_overflow) : Function table for relocation errors. + (xcoff_ppc_relocate_section): Use relocation and complain function + tables. + (xcoff_complain_overflow_unsigned_func): New complain function. + (xcoff_complain_overflow_signed_func): Same. + (xcoff_complain_overflow_bitfield_func): Same. + (xcoff_complain_overflow_dont_func): Same. + (xcoff_reloc_type_crel): New recot function. + (xcoff_reloc_type_br): Same. + (xcoff_reloc_type_ba): Same. + (xcoff_reloc_type_toc): Same. + (xcoff_reloc_type_rel): Same. + (xcoff_reloc_type_neg): Same. + (xcoff_reloc_type_pos): Same. + (xcoff_reloc_type_fail): Same. + (xcoff_reloc_type_noop): Same. + * libxcoff.h : Declare common parts for xcoff64. + * coff64-rs6000.c (xcoff64_ppc_relocate_section): Use relocation + and complain function tables. + +2002-04-28 Alan Modra <amodra@bigpond.net.au> + + * elf64-x86-64.c (struct elf64_x86_64_dyn_relocs): Comment typo. + * elf32-hppa.c (elf32_hppa_final_link): Formatting. + +2002-04-26 Alan Modra <amodra@bigpond.net.au> -2002-05-06 Nick Clifton <nickc@cambridge.redhat.com> + * opncls.c (bfd_make_readable): Call bfd_section_list_clear. + * xcofflink.c (xcoff_link_add_dynamic_symbols): Likewise. - * elf32-arm.h (elf32_arm_final_link_relocate): Convert - 'reloc_signed_max' and 'reloc_signed_min' into half-word offsets. + * elflink.h (elf_bfd_final_link): Ensure input bfd class is the + same as the output before calling elf_link_input_bfd. -2002-05-02 Richard Henderson <rth@redhat.com> + * coffcode.h (coff_compute_section_file_positions): Set + section_tail after shuffling section list. - * elf64-alpha.c (elf64_alpha_relocate_section): Force relative relocs - vs SHN_UNDEF to zero. +2002-04-24 Christian Groessler <chris@groessler.org> -2002-04-27 Alan Modra <amodra@bigpond.net.au> + * coff-z8k.c (extra_case): Fix R_IMM32 relocations: The + addresses are 23bit with a special layout, not plain 32bit + values. Prevent relocation of immediate values. - Merge from mainline - 2002-04-12 Alan Modra <amodra@bigpond.net.au> - * elf.c (prep_headers): Don't zero EI_OSABI, EI_ABIVERSION or - header pad. +2002-04-24 Chris G. Demetriou <cgd@broadcom.com> - 2002-02-21 Andreas Jaeger <aj@suse.de> - * elf64-x86-64.c: Major rework that introduces all recent changes - to the x86-64 backend. Get a closer match to elf32-i386. - (struct elf64_x86_64_dyn_relocs): Rename from - elf64_x86_64_pcrel_relocs_copied, add additional fields. Change - all users. - (struct elf64_x86_64_link_hash_table): Add short cuts to some - sections. - (link_hash_newfunc): Rename from elf64_x86_64_link_hash_newfunc, - remove casts, initialize new hash members. - (create_got_section): New. - (elf64_x86_64_create_dynamic_sections): New. - (elf64_x86_64_copy_indirect_symbol): New. - (elf64_x86_64_check_relocs): Don't allocate space for dynamic - relocs, .got or .relgot here but do it in allocate_dynrelocs. - Reference count possible .plt and .got entries. Don't test input - section SEC_READONLY here to try to avoid copy relocs, and keep - dyn_relocs regardless of ELF_LINK_NON_GOT_REF. Don't set - DF_TEXTREL here. Delay setting of variables until needed. Cache - pointer to "sreloc" section in elf_section_data. Tweak condition - under which .got created. Report files with bad relocation - section names. - (elf64_x86_64_gc_sweep_hook): Sweep dyn_relocs and local_dynrel. - Reference count possible .plt entries. Don't deallocate .got and - .relgot space here. - (elf64_x86_64_adjust_dynamic_symbol): Handle nocopyreloc. Don't - do copy reloc processing for weakdefs. Remove redundant casts and - aborts. Delay setting of vars until needed. Move creation of - dynamic symbols and allocation of .plt and .rela.plt to - allocate_dynrelocs. Replace BFD_ASSERT with abort. - (WILL_CALL_FINISH_DYNAMIC_SYMBOL): New. - (allocate_dynrelocs): New. - (readonly_dynrelocs): New. - (elf64_x86_64_size_dynamic_sections): Call readonly_dynrelocs. - Allocate space for dyn relocs. Replace BFD_ASSERT with abort. - Zero out the dynamic allocated content space. - (elf64_x86_64_discard_copies): Removed. - (elf64_x86_64_relocate_section): Make use of dynamic section - short-cuts. Localise vars, and delay setting. Better error - reporting, replace BFD_ASSERT with abort. Check - ELF_LINK_HASH_DEF_DYNAMIC to see if a symbol is not defined in the - regular object file and tread the weak definition as the normal - one. Don't discard relocs for undefweak or undefined symbols and - check !DEF_REGULAR as well as DEF_DYNAMIC in test for avoided copy - relocs. - (elf64_x86_64_finish_dynamic_symbol): Don't copy relocs for - symbols that have been forced local. Use same test to decide if - we can use a relative reloc for got as relocate_section. Expand - SHN_UNDEF comment. Move expressions out of function calls. - Replace BFD_ASSERT with abort. - (bfd_elf64_bfd_final_link): Removed. - (elf_backend_copy_indirect_symbol): Define. + * elfxx-mips.c (_bfd_mips_elf_print_private_bfd_data): If MDMX or + MIPS-16 ASE flags are set, print something to indicate that. - * reloc.c: Move sh relocs to where they belong. - * libbfd.h, bfd-in2.h: Regenerate. +2002-04-23 Alan Modra <amodra@bigpond.net.au> - Merge from mainline - 2002-04-26 Alan Modra <amodra@bigpond.net.au> - * opncls.c (bfd_make_readable): Call bfd_section_list_clear. - * xcofflink.c (xcoff_link_add_dynamic_symbols): Likewise. - * elflink.h (elf_bfd_final_link): Ensure input bfd class is the - same as the output before calling elf_link_input_bfd. - * coffcode.h (coff_compute_section_file_positions): Set - section_tail after shuffling section list. - - 2002-04-23 Alan Modra <amodra@bigpond.net.au> * elf32-hppa.c (hppa_type_of_stub): Correct and simplify condition under which a plt call stub is used. (final_link_relocate): Similarly. @@ -254,35 +2341,17 @@ (BL22_RP): Define. (hppa_build_one_stub): Use BL22_RP if has_22bit_branch. (elf32_hppa_check_relocs): Set has_22bit_branch. + * elf32-hppa.c (elf32_hppa_check_relocs): Remove debug message. (final_link_relocate): Likewise. - 2002-04-20 Alan Modra <amodra@bigpond.net.au> - * archures.c (bfd_arch_info): Add comment on list order. - (bfd_default_set_arch_mach): Use bfd_lookup_arch. - * cpu-powerpc.c (bfd_powerpc_archs): Re-order so that the default - is always at head of list. - * bfd-in2.h: Regenerate. - - 2002-04-16 Alan Modra <amodra@bigpond.net.au> - * elf32-m32r.c (m32r_elf_add_symbol_hook): Check the hash table - type rather than just assuming entries are ELF. - * elf32-sh64.c (sh64_elf_add_symbol_hook): Likewise. - * elf64-sh64.c (sh64_elf64_add_symbol_hook): Likewise. - * elf64-sparc.c (sparc64_elf_add_symbol_hook): Likewise. - * elf64-mmix.c (mmix_elf_add_symbol_hook): Use bfd_link_hash_entry - rather than elf_link_hash_entry. - - 2002-04-15 Alan Modra <amodra@bigpond.net.au> - * elf32-ppc.c (ppc_elf_add_symbol_hook): Check the hash table type. +2002-04-22 Jakub Jelinek <jakub@redhat.com> - 2002-04-08 Randolph Chung <tausq@debian.org> - * elf32-hppa.c (hppa_unwind_entry_compare): Move to elf-hppa.h. - (elf32_hppa_final_link): Split out sorting logic to.. - * elf-hppa.h (elf_hppa_sort_unwind): ..here. - (elf_hppa_final_link): Call elf_hppa_sort_unwind. + * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't build + search table if some FDE is DW_EH_PE_aligned encoded either. + (_bfd_elf_write_section_eh_frame): Handle terminating FDE specially. -2002-04-26 Richard Smith <richard@ex-parrot.com> +2002-04-22 Richard Smith <richard@ex-parrot.com> Jakub Jelinek <jakub@redhat.com> * elf-eh-frame.c (struct eh_cie_fde): Add per_encoding_relative. @@ -291,11 +2360,20 @@ (_bfd_elf_write_section_eh_frame): Adjust pcrel encoded personality for CIE/FDE removal. -2002-04-26 Jakub Jelinek <jakub@redhat.com> +2002-04-20 Tom Rix <trix@redhat.com> - * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't build - search table if some FDE is DW_EH_PE_aligned encoded either. - (_bfd_elf_write_section_eh_frame): Handle terminating FDE specially. + * coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Fix C_FILE auxent. + +2002-04-20 Alan Modra <amodra@bigpond.net.au> + + * archures.c (bfd_lookup_arch): Move the list order comment.. + (struct bfd_arch_info): ..to where it belongs. + * bfd-in2.h: Regenerate. + + * archures.c (bfd_lookup_arch): Add comment on list order. + (bfd_default_set_arch_mach): Use bfd_lookup_arch. + * cpu-powerpc.c (bfd_powerpc_archs): Re-order so that the default + is always at head of list. 2002-04-18 Nick Clifton <nickc@cambridge.redhat.com> @@ -303,15 +2381,91 @@ insert_thumb_branch, record_thumb_to_arm_glue): Suppress definition of these functions for ARM_WINCE builds as they are not used. - (SWAP_IN_RELOC_OFFSET, SWAP_OUT_RELOC_OFFSET): Do not define + (SWAP_IN_RELOC_OFFSET, SWAP_OUT_RELOC_OFFSET): Do not define for ARM_WINCE builds. +2002-04-18 Nick Clifton <nickc@cambridge.redhat.com> + + * coff-arm.c (bfd_arm_process_before_allocation): + +2002-04-17 J"orn Rennecke <joern.rennecke@superh.com> + + * cpu-sh.c (scan_mach): Delete. + (arch_info_struct): Replace scan_mach with bfd_default_scan. + (bfd_sh_arch): Likewise. + 2002-04-16 Nick Clifton <nickc@cambridge.redhat.com> * ihex.c (ihex_write_object_contents): Fix check for records crossing 64K boundaries. -2002-04-06 Hans-Peter Nilsson <hp@axis.com> +2002-04-16 Alan Modra <amodra@bigpond.net.au> + + * elf32-m32r.c (m32r_elf_add_symbol_hook): Check the hash table + type rather than just assuming entries are ELF. + * elf32-sh64.c (sh64_elf_add_symbol_hook): Likewise. + * elf64-sh64.c (sh64_elf64_add_symbol_hook): Likewise. + * elf64-sparc.c (sparc64_elf_add_symbol_hook): Likewise. + * elf64-mmix.c (mmix_elf_add_symbol_hook): Use bfd_link_hash_entry + rather than elf_link_hash_entry. + +2002-04-15 Richard Henderson <rth@redhat.com> + + * elf32-mips.c (mips_elf32_object_p): Revert 0404 fragment: allow + n32 binaries. + +2002-04-15 Michael Snyder <msnyder@redhat.com> + + * opncls.c (bfd_close): Write contents if writeable. + Minor formatting tidy-ups. + +2002-04-15 Alan Modra <amodra@bigpond.net.au> + + * elf32-ppc.c (ppc_elf_add_symbol_hook): Check the hash table type. + +2002-04-12 Michael Snyder <msnyder@redhat.com> + + * bfd-in.h (bfd_get_section_lma): New access macro. + Minor white-space fix-up. + +2002-04-12 Alan Modra <amodra@bigpond.net.au> + + * elf.c (prep_headers): Don't zero EI_OSABI, EI_ABIVERSION or + header pad. + +2002-04-09 DJ Delorie <dj@redhat.com> + + * elfarm-nabi.c (elf32_arm_howto_table): Fix ABS16 masks. + +2002-04-09 Casper S. Hornstrup <chorns@users.sourceforge.net> + + * coffcode.h (coff_read_word): New. + (coff_compute_checksum): New. + (coff_apply_checksum): New. + (coff_write_object_contents): Call coff_apply_checksum () to + apply checksum to PE image. + +2002-04-08 Randolph Chung <tausq@debian.org> + + * elf32-hppa.c (hppa_unwind_entry_compare): Move to elf-hppa.h. + (elf32_hppa_final_link): Split out sorting logic to.. + * elf-hppa.h (elf_hppa_sort_unwind): ..here. + (elf_hppa_final_link): Call elf_hppa_sort_unwind. + +2002-04-07 Andrew Cagney <ac131313@redhat.com> + + * configure.in: Add missing ``|'' to powerpc-*-aix4.[4-9]* + pattern. + * configure: Re-generate. + +2002-04-07 Andrew Cagney <ac131313@redhat.com> + + * configure.in: Only define AIX_CORE_DUMPX_CORE when AIX version + is greater or equal to 4.3.3. + * configure: Regenerate. + Fix PR gdb/344. + +2002-04-05 Hans-Peter Nilsson <hp@axis.com> * elf32-cris.c (cris_elf_howto_table) <R_CRIS_16_PCREL, R_CRIS_32_PCREL>: Fix typo in name. @@ -320,17 +2474,140 @@ (elf_cris_adjust_gotplt_to_got): Don't create .rela.got here; assume it's created. +2002-04-04 Daniel Jacobowitz <drow@mvista.com> + + * aout-adobe.c (aout_32_bfd_link_hash_table_free): Define. + * aout-target.h (MY_bfd_link_hash_table_free): Conditionally + define. + * aout-tic30.c (MY_bfd_link_hash_table_free): Likewise. + * bfd.c (bfd_link_hash_table_free): Define. + * binary.c (binary_bfd_link_hash_table_free): Define. + * bout.c (b_out_bfd_link_hash_table_free): Define. + * coff-rs6000.c (rs6000coff_vec): Include + _bfd_generic_link_hash_table_free. + (pmac_xcoff_vec): Likewise. + * coff64-rs6000.c (rs6000coff64_vec): Likewise. + (aix5coff64_vec): Likewise. + * coffcode.h (coff_bfd_link_hash_table_free): Conditionally define. + * elf-m10300.c (elf32_mn10300_link_hash_table_free): New function. + (bfd_elf32_bfd_link_hash_table_free): Define. + * elf32-hppa.c (elf32_hppa_link_hash_table_free): New function. + (bfd_elf32_bfd_link_hash_table_free): Define. + * elfxx-target.h (bfd_elfNN_bfd_link_hash_table_free): Conditionally + define. + * i386msdos.c (msdos_bfd_link_hash_table_free): Define. + * i386os9k.c (os9k_bfd_link_hash_table_free): Define. + * ieee.c (ieee_bfd_link_hash_table_free): Define. + * ihex.c (ihex_bfd_link_hash_table_free): Define. + * libbfd-in.h (_bfd_nolink_bfd_link_hash_table_free): Define. + (_bfd_generic_link_hash_table_free): Add prototype. + * libcoff-in.h (_bfd_xcoff_bfd_link_hash_table_free): Add prototype. + * libecoff.h (_bfd_ecoff_bfd_link_hash_table_free): Define. + * linker.c (_bfd_generic_link_hash_table_free): New function. + * mmo.c (mmo_bfd_link_hash_table_free): Define. + * nlm-target.h (nlm_bfd_link_hash_table_free): Define. + * oasys.c (oasys_bfd_link_hash_table_free): Define. + * ppcboot.c (ppcboot_bfd_link_hash_table_free): Define. + * som.c (som_bfd_link_hash_table_free): Define. + * srec.c (srec_bfd_link_hash_table_free): Define. + * tekhex.c (tekhex_bfd_link_hash_table_free): Define. + * versados.c (versados_bfd_link_hash_table_free): Define. + * vms.c (vms_bfd_link_hash_table_free): New function. + * xcofflink.c (_bfd_xcoff_bfd_link_hash_table_free): New function. + + * coff-arm.c (coff_arm_link_hash_table_create): Use bfd_malloc + instead of bfd_alloc. + * coff-h8300.c (h8300_coff_link_hash_table_create): Likewise. + * coff-mcore.c (coff_mcore_link_hash_table_create): Likewise. + * coff-ppc.c (ppc_coff_link_hash_table_create): Likewise. + * cofflink.c (_bfd_coff_link_hash_table_create): Likewise. + * ecoff.c (_bfd_ecoff_bfd_link_hash_table_create): Likewise. + * elf-m10300.c (elf32_mn10300_link_hash_table_create): Likewise. + * elf.c (_bfd_elf_link_hash_table_create): Likewise. + * elf32-arm.h (elf32_arm_link_hash_table_create): Likewise. + * elf32-cris.c (elf_cris_link_hash_table_create): Likewise. + * elf32-hppa.c (elf32_hppa_link_hash_table_create): Likewise. + * elf32-i386.c (elf_i386_link_hash_table_create): Likewise. + * elf32-m68k.c (elf_m68k_link_hash_table_create): Likewise. + * elf32-s390.c (elf_s390_link_hash_table_create): Likewise. + * elf32-sh.c (sh_elf_link_hash_table_create): Likewise. + * elf64-alpha.c (elf64_alpha_bfd_link_hash_table_create): Likewise. + * elf64-ppc.c (ppc64_elf_link_hash_table_create): Likewise. + * elf64-s390.c (elf_s390_link_hash_table_create): Likewise. + * elf64-sh64.c (sh64_elf64_link_hash_table_create): Likewise. + * elf64-sparc.c (sparc64_elf_bfd_link_hash_table_create): Likewise. + * elf64-x86-64.c (elf64_x86_64_link_hash_table_create): Likewise. + * elfxx-mips.c (_bfd_mips_elf_link_hash_table_create): Likewise. + * linker.c (_bfd_generic_link_hash_table_create): Likewise. + * m68klinux.c (linux_link_hash_table_create): Likewise. + * sparclinux.c (linux_link_hash_table_create): Likewise. + * sunos.c (sunos_link_hash_table_create): Likewise. + * xcofflink.c (_bfd_xcoff_bfd_link_hash_table_create): Likewise. + + * targets.c: Add _bfd_link_hash_table_free to xvec. + + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + * libcoff.h: Regenerate. + 2002-04-04 Alan Modra <amodra@bigpond.net.au> - * configure.in: Bump version to 2.12.1 and comment out is_release. - * configure: Regenerate. * dep-in.sed: Cope with absolute paths. * Makefile.am (dep.sed): Subst TOPDIR, and not INCDIR. Run "make dep-am". * Makefile.in: Regenerate. + * coff-arm.c: Fix copyright date. + * cpu-h8300.c: Likewise. + * cpu-i370.c: Likewise. + * cpu-s390.c: Likewise. + * cpu-mips.c: Likewise. + * po/SRC-POTFILES.in: Regenerate. + +2002-04-04 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de> + + * Makefile.am: Add elfxx-mips.c to the known backends. + (elf32-mips.lo): remove dependency to coff/external.h. + * Makefile.in: Regenerate. + * configure.in: Add elfxx-mips.lo to all vectors using elf32-mips.lo + Remove elf32-mips.lo from 64 bit vectors. Update dependencies + accordingly. + * configure: Regenerate. + * elf-bfd.h: Move all MIPS ELF specific prototypes to elfxx-mips.h. + (irix_compat_t): IRIX compatibility level, moved from elf32-mips.c. + (elf_backend_mips_irix_compat, elf_backend_mips_rtype_to_howto): New + MIPS specific backend functions. + * elf32-mips.c: Moved most code to elfxx-mips.c. + (mips_elf_hi16_reloc): Rename from _bfd_mips_elf_hi16_reloc and make + static. + (mips_elf_lo16_reloc): Likewise, was _bfd_mips_elf_lo16_reloc. + (mips_elf_got16_reloc): Likewise, was _bfd_mips_elf_got16_reloc. + (mips_elf_gprel32_reloc): Likewise, was _bfd_mips_elf_gprel32_reloc. + (mips_elf32_rtype_to_howto): Rename from mips_rtype_to_howto. Changed + interface to allow selection of the right REL or RELA howto table. + (mips_elf32_object_p): Rename from _bfd_mips_elf_object_p and made + static. Let it refuse n32 objects. + (elf32_mips_grok_prstatus): Rename from _bfd_elf32_mips_grok_prstatus. + (elf32_mips_grok_psinfo): Rename from _bfd_elf32_mips_grok_psinfo. + (elf32_mips_discard_info): Rename from _bfd_elf32_mips_discard_info. + (elf32_mips_ignore_discarded_relocs): Rename from + _bfd_elf32_mips_ignore_discarded_relocs. + (elf32_mips_write_section): Rename from _bfd_elf32_mips_write_section. + (elf32_mips_irix_compat): New function, replaces IRIX_COMPAT. + (elf_mips_howto_table_rela): Remove. + * elf64-mips.c: Moved most code to elfxx-mips.c. + (bfd_elf64_bfd_reloc_type_lookup): Make static. + (mips_elf64_rtype_to_howto): New function. + (mips_elf64_object_p): Likewise. + (elf64_mips_irix_compat): Likewise. + * elfxx-mips.c: New file containing common code merged together from + elf32-mips.c and elf64-mips.c. + * elfxx-mips.h: New file containing MIPS specific prototypes from + elf-bfd.h. + * elfxx-target.h: Add handling for elf_backend_mips_irix_compat and + elf_backend_mips_rtype_to_howto. + +2002-04-04 Alan Modra <amodra@bigpond.net.au> - Merge from mainline - 2002-04-04 Alan Modra <amodra@bigpond.net.au> * srec.c (MAXCHUNK, Chunk): Revise comments. (srec_write_record): Correct buffer size. (srec_write_header): Do without intermediate buffer. @@ -339,21 +2616,37 @@ (srec_write_symbols): Pass file and symbol names directly to bfd_bwrite so sprintf won't overflow buffer. - 2002-04-03 Jakub Jelinek <jakub@redhat.com> +2002-04-03 Jakub Jelinek <jakub@redhat.com> + * elf32-sparc.c (elf32_sparc_relocate_section): Don't emit dynamic PC relative relocs against hidden symbols. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. - 2002-04-03 Alan Modra <amodra@bigpond.net.au> +2002-04-03 Alan Modra <amodra@bigpond.net.au> + * elf.c (_bfd_elf_make_section_from_shdr): When setting section LMAs, loop over segments until p_vaddr and p_memsz specify an extent enclosing the section. - 2002-04-02 Nick Clifton <nickc@cambridge.redhat.com> +2002-04-02 Nick Clifton <nickc@cambridge.redhat.com> + * ihex.c (ihex_write_object_contents): Do not allow records to cross a 64K boundary - wrap if necessary. - 2002-03-28 Alan Modra <amodra@bigpond.net.au> +2002-04-01 Nathan Williams <nathanw@wasabisystems.com> + + * elf.c (elfcore_netbsd_get_lwpid): Fix off-by-one error + which caused the returned LWP ID to always be 0. + +2002-04-01 Richard Henderson <rth@redhat.com> + + * elf32-sparc.c (WILL_CALL_FINISH_DYNAMIC_SYMBOL): New. + (elf32_sparc_relocate_section): Use it to figure out when to + initialize .got entries. + * elf64-sparc.c: Similarly. + +2002-03-28 Alan Modra <amodra@bigpond.net.au> + * linker.c (link_action): Ignore duplicate warning syms. (_bfd_generic_link_write_global_symbol): Follow warning symbol link. * elflink.h (elf_adjust_dynstr_offsets): Likewise. @@ -404,7 +2697,8 @@ * elf64-s390.c (allocate_dynrelocs): Likewise. (readonly_dynrelocs): Likewise. * elf64-sh64.c (sh64_elf64_discard_copies): Likewise. - * elf64-x86-64.c (elf64_x86_64_discard_copies): Likewise. + * elf64-x86-64.c (allocate_dynrelocs): Likewise. + (readonly_dynrelocs): Likewise. * elfxx-ia64.c (elfNN_ia64_global_dyn_sym_thunk): Likewise. * aoutx.h (aout_link_write_other_symbol): Likewise. * cofflink.c (_bfd_coff_write_task_globals): Likewise. @@ -416,7 +2710,9 @@ * sunos.c (sunos_scan_dynamic_symbol): Likewise. * xcofflink.c (xcoff_build_ldsyms): Likewise. (xcoff_write_global_symbol): Likewise. + * cofflink.c (_bfd_coff_final_link): Formatting. + * cpu-mips.c (mips_compatible): Make static, prototype. * elf32-i386.c (elf_i386_check_relocs): Formatting. * elf32-sh.c (sh_elf_size_dynamic_sections): Likewise. * elf64-alpha.c (elf64_alpha_output_extsym): Likewise. @@ -425,80 +2721,54 @@ * elflink.h (elf_link_find_version_dependencies): Remove duplicate prototype. - 2002-03-21 Richard Earnshaw <rearnsha@arm.com> - * elf32-arm.h (elf32_arm_final_link_relocate <case R_ARM_GOTOFF>, - <case R_ARM_GOT>): Handle relocations to Thumb functions. +2002-03-27 Nick Clifton <nickc@cambridge.redhat.com> - 2002-03-19 Hans-Peter Nilsson <hp@bitrange.com> - * elflink.h (NAME(bfd_elf,record_link_assignment)): Don't set - STT_NOTYPE symbols to STT_OBJECT. + * coff-arm.c (SWAP_IN_RELOC_OFFSET): Define. + (SWAP_OUT_RELOC_OFFSET): Define. - 2002-03-13 Alan Modra <amodra@bigpond.net.au> - * archures.c (bfd_default_compatible): Test bits_per_word. - * cpu-i386.c (i386_compatible): Remove. Replace occurrences with - bfd_default_compatible. - * cpu-i370.c (i370_compatible): Likewise. - * cpu-sparc.c (sparc_compatible): Likewise. - * cpu-h8300.c (compatible): Test in->arch == out->arch. +2002-03-27 Gregory Steuck <greg@nest.cx> - 2002-02-19 Martin Schwidefsky <schwidefsky@de.ibm.com> - * archures.c (bfd_mach_s390_esa): Rename to bfd_mach_s390_31. - (bfd_mach_s390_esame): Rename to bfd_mach_s390_64. - * bfd-in2.h: Regenerate. - * cpu-s390.c (arch_info_struct): Use renamed architecture defines. - Replace architecture name "s390" with "s390:31-bit" and "s390:esame" - with "s390:64-bit". - * elf32-s390.c (elf_howto_table): Add 32 bit pc relative relocations. - (elf_s390_reloc_type_lookup): Likewise. - (elf_s390_check_relocs): Likewise. - (elf_s390_gc_sweep_hook): Likewise. - (elf_s390_relocate_section): Likewise. - (elf_s390_object_p): Use renamed architecture define. - * elf64-s390.c (elf_s390_object_p): Use renamed architecture define. + * elf.c (_bfd_elf_get_symtab_upper_bound): Leave space for + terminating NULL if empty symbol table. + (_bfd_elf_get_dynamic_symtab_upper_bound): Likewise. -2002-04-03 Alan Modra <amodra@bigpond.net.au> +2002-03-26 H.J. Lu (hjl@gnu.org) - Merge from mainline. - 2002-03-28 Alan Modra <amodra@bigpond.net.au> - * cpu-mips.c (mips_compatible): Make static, prototype. + * elflink.h (elf_link_input_bfd): Revert the last change since + the gcc exception handling isn't fixed yet. - 2002-03-14 Alan Modra <amodra@bigpond.net.au> - * cpu-mips.c (mips_compatible): New. Don't check bits_per_word. - (N): Use the above. +2002-03-26 H.J. Lu (hjl@gnu.org) -2002-04-01 Nathan Williams <nathanw@wasabisystems.com> + * elflink.h (elf_link_input_bfd): Complain about relocations + against local symbols in discarded sections. - * elf.c (elfcore_netbsd_get_lwpid): Fix off-by-one error - which caused the returned LWP ID to always be 0. +2002-03-26 Alan Modra <amodra@bigpond.net.au> -2002-04-01 Richard Henderson <rth@redhat.com> + * elflink.h (elf_gc_mark): Don't recurse into non-ELF sections. - * elf32-sparc.c (WILL_CALL_FINISH_DYNAMIC_SYMBOL): New. - (elf32_sparc_relocate_section): Use it to figure out when to - initialize .got entries. - * elf64-sparc.c: Similarly. +2002-03-23 Alan Modra <amodra@bigpond.net.au> -2002-03-28 Alan Modra <amodra@bigpond.net.au> + * elf.c (_bfd_elf_make_section_from_shdr): Don't set lma based on + section file offset for !SEC_LOAD sections. - * aclocal.m4: Regenerate. - * config.in: Regenerate. - * Makefile.am: Run "make dep-am". - * Makefile.in: Regenerate. +2002-03-21 Richard Earnshaw <rearnsha@arm.com> - Merge from mainline - 2002-03-27 Gregory Steuck <greg@nest.cx> - * elf.c (_bfd_elf_get_symtab_upper_bound): Leave space for - terminating NULL if empty symbol table. - (_bfd_elf_get_dynamic_symtab_upper_bound): Likewise. + * elf32-arm.h (elf32_arm_final_link_relocate <case R_ARM_GOTOFF>, + <case R_ARM_GOT>): Handle relocations to Thumb functions. - 2002-03-26 Alan Modra <amodra@bigpond.net.au> - * elflink.h (elf_gc_mark): Don't recurse into non-ELF sections. +2002-03-21 Alan Modra <amodra@bigpond.net.au> - 2002-03-23 Alan Modra <amodra@bigpond.net.au> - * elf.c (_bfd_elf_make_section_from_shdr): Don't set lma based on - section file offset for !SEC_LOAD sections. + * coff64-rs6000.c (_bfd_xcoff64_put_symbol_name): Prototype. + Whitespace changes. + * archive.c: Update copyright date. + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + * Makefile.am: Run "make dep-am" + * Makefile.in: Regenerate. + * po/SRC-POTFILES.in: Regenerate. + +2002-03-20 Daniel Jacobowitz <drow@mvista.com> - 2002-03-20 Daniel Jacobowitz <drow@mvista.com> * dwarf2.c (struct funcinfo): Move up. (lookup_address_in_function_table): New argument function_ptr. Set it. @@ -510,42 +2780,128 @@ * syms.c (_bfd_stab_section_find_nearest_line): Use the first N_SLINE encountered if we see an N_FUN before any N_SLINE. - 2002-03-18 Alan Modra <amodra@bigpond.net.au> +2002-03-20 Tom Rix <trix@redhat.com> + + * 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. + +2002-03-19 Tom Rix <trix@redhat.com> + + * xcofflink.c (_bfd_xcoff_bfd_link_add_symbols): Look through all + dynamic objects in archives. + +2002-03-19 Hans-Peter Nilsson <hp@bitrange.com> + + * elflink.h (NAME(bfd_elf,record_link_assignment)): Don't set + STT_NOTYPE symbols to STT_OBJECT. + +2002-03-18 Jan Hubicka <jh@suse.cz> + + * cpu-i386.c (bfd_x86_64_arch): Rename to "i386:x86-64" + +2002-03-18 Tom Rix <trix@redhat.com> + + * aix5ppc.core.c : New file for AIX 5 64 bit core support. + * bfd-in.h : Add bfd_xcoff_ar_archive_set_magic declaration. + * coff-rs6000 (do_pad) : New function for archive padding. + (do_copy) : New function for object file copying in archives. + (do_shared_object_padding) : New function for padding shared + objects to their text section alignment in archives. + (bfd_xcoff_ar_achive_set_magic) : Stub. + (xcoff_write_armap_big) : Use do_copy and do_pad. + (xcoff_write_archive_contents_big) : Use do_shared_object_padding, + do_copy and do_pad. + * coff64-rs6000.c (xcoff64_write_ojbect_contents) : Use + bfd_xcoff_magic_number. + (xcoff64_bad_format_hook) : New function for _bfd_bad_format_hook + fop. + (xcoff_backend_data_r) : Use xcoff64_bad_format_hook. + (bfd_xcoff_aix5_backend_data) : New Aix 5 backend data. + (aix5coff64_vec) : New Aix 5 target aix5coff64-rs6000. + * rs6000-core.c : Update copyright date. + * xcofflink.c (bfd_xcoff_size_dynamic_sections): Check for NULL + csectpp. + * coffcode.h (coff_new_section_hook) : Use new accessor macros. + (coff_set_arch_mach_hook) : Add Aix 5 U64_TOCMAGIC magic #. + (coff_set_flags) : Use bfd_xcoff_magic_number. + * libxcoff.h (bfd_xcoff_is_xcoff64): Add U64_TOCMAGIC. + * configure.in : Add powerpc-*-aix5 and rs6000-*-aix5 support. + * Makefile.am : Same. + * config.bfd : Same. + * targets.c : Same. + * configure : Regnerate. + * Makefile.in : Same. + * bfd-in2.h : Same. + +2002-03-18 Nick Clifton <nickc@cambridge.redhat.com> + + * po/fr.po: Updated version. + +2002-03-18 Alan Modra <amodra@bigpond.net.au> + * libbfd.c (bfd_write_bigendian_4byte_int): Return true iff success. * libbfd.h: Regenerate. * archive.c (coff_write_armap): Pass on failures from bfd_write_bigendian_4byte_int. - 2002-03-14 H.J. Lu <hjl@gnu.org> +2002-03-14 H.J. Lu <hjl@gnu.org> + * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Set the BFD error to bfd_error_nonrepresentable_section for reinit_array section in DSO. - 2002-03-14 Nick Clifton <nickc@cambridge.redhat.com> +2002-03-14 Nick Clifton <nickc@cambridge.redhat.com> + * coffcode.h (coff_slurp_symbol_table): When adding BSF_WEAK flag, OR it in rather than replacing previously selected flags. + * elfxx-target.h (TARGET_BIG_SYM): Set ar_max_namelen to 15. (TARGET_LITTLE_SYM): Set ar_max_namelen to 15. - 2002-03-14 Alan Modra <amodra@bigpond.net.au> +2002-03-14 Alan Modra <amodra@bigpond.net.au> + + * cpu-mips.c (mips_compatible): New. Don't check bits_per_word. + (N): Use the above. * elflink.h (elf_bfd_final_link): Revert last change. Instead, ensure reloc size matches before calling elf_link_input_bfd. Add an assert to check reloc size when counting output relocs. - 2002-03-14 Nick Clifton <nickc@cambridge.redhat.com> +2002-03-14 Nick Clifton <nickc@cambridge.redhat.com> + * mmo.c (mmo_get_loc): Return NULL rather than false. - 2002-03-13 Alan Modra <amodra@bigpond.net.au> +2002-03-13 Nick Clifton <nickc@cambridge.redhat.com> + + * po/fr.po: Updated version. + +2002-03-13 Alan Modra <amodra@bigpond.net.au> + + * archures.c (bfd_default_compatible): Test bits_per_word. + * cpu-i386.c (i386_compatible): Remove. Replace occurrences with + bfd_default_compatible. + * cpu-i370.c (i370_compatible): Likewise. + * cpu-sparc.c (sparc_compatible): Likewise. + * cpu-h8300.c (compatible): Test in->arch == out->arch. + * elflink.h: Formatting fixes. (elf_link_output_extsym): Merge undefined and undef weak cases. + * elflink.h (elf_bfd_final_link): Only call elf_link_input_bfd when word size of input matches output word size. - 2002-03-07 H.J. Lu (hjl@gnu.org) +2002-03-12 Andreas Jaeger <aj@suse.de> + + * cpu-i386.c (i386_compatible): New. Use it instead of + bfd_default_compatible. + +2002-03-07 H.J. Lu (hjl@gnu.org) + * coff-sh.c (shcoff_reloc_map): Use bfd_reloc_code_real_type as the type for bfd_reloc_val. - 2002-03-05 John David Anglin <dave@hiauly1.hia.nrc.ca> +2002-03-05 John David Anglin <dave@hiauly1.hia.nrc.ca> + * elf-hppa.h (elf_hppa_is_dynamic_loader_symbol): New function. (elf_hppa_relocate_section): Ignore undefined dynamic loader symbols. (elf_hppa_final_link_relocate): Correct relocations for indirect @@ -558,35 +2914,53 @@ * elf32-hppa.c (final_link_relocate): Revise relocation selectors as per "Processor-Specific ELF for PA_RISC, Version 1.43" document. - 2002-03-05 Jakub Jelinek <jakub@redhat.com> +2002-03-05 Jakub Jelinek <jakub@redhat.com> + * merge.c (_bfd_merge_sections): Don't segfault if there is nothing to merge due to GC. - 2002-03-05 Alan Modra <amodra@bigpond.net.au> +2002-03-05 Alan Modra <amodra@bigpond.net.au> + * elf32-hppa.c (clobber_millicode_symbols): Remove hack to keep symbols that have been forced local. + * elflink.h (elf_bfd_final_link): Call elf_link_output_extsym to output forced local syms for non-shared link. (elf_link_output_extsym): Tweak condition for calling backend adjust_dynamic_symbol so that previous behaviour is kept. Whitespace changes throughout file. - 2002-03-04 H.J. Lu <hjl@gnu.org> +2002-03-04 H.J. Lu <hjl@gnu.org> + * elf.c (bfd_section_from_shdr): Handle special sections, .init_array, .fini_array and .preinit_array. (elf_fake_sections): Likewise. + * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Create the DT entry only if the section is in output for .init_array, .fini_array and .preinit_array. Complain about .preinit_array section in DSO. (elf_bfd_final_link): Warn zero size for .init_array, .fini_array and .preinit_array sections. + * elfxx-ia64.c (elfNN_ia64_section_from_shdr): Remove SHT_INIT_ARRAY, SHT_FINI_ARRAY and SHT_PREINIT_ARRAY. (elfNN_ia64_fake_sections): Remove .init_array, .fini_array and .preinit_array. - 2002-03-01 David Mosberger <davidm@hpl.hp.com> +2002-03-04 Alan Modra <amodra@bigpond.net.au> + + * configure.in (WIN32LIBADD): Don't eval PICFLAG assignment. + * configure: Regenerate. + +2002-03-02 Tom Rix <trix@redhat.com> + + * coff64-rs6000.c (xcoff64_howto_table): Replace howto types with + symbolic equiv. + * coff-rs6000.c (xcoff_howto_table): Same. + +2002-03-01 David Mosberger <davidm@hpl.hp.com> + * elflink.h (size_dynamic_sections): If section named ".preinit_array" exists, create DT_PREINIT_ARRAY and DT_PREINIT_ARRAYSZ entries in dynamic table. Analogously for @@ -595,46 +2969,6 @@ DT_FINI_ARRAYSZ, DT_PREINIT_ARRAY, DT_INIT_ARRAY, and DT_FINI_ARRAY. - 2002-02-19 Frank Ch. Eigler <fche@redhat.com> - * syms.c (stt[]): Sorted. Added .init/.fini -> "t" mapping. - - 2002-02-13 Nick Clifton <nickc@cambridge.redhat.com> - * elf.c (_bfd_elf_make_section_from_shdr): Do not insist on - non-zero physical addresses when adjusting the LMAs of new - sections. - - 2002-02-11 Michael Snyder <msnyder@redhat.com> - * elf-bfd.h (elfcore_write_lwpstatus): Add prototype. - * elf.c (elfcore_grok_pstatus): Add prototype. - (elfcore_grok_lwpstatus): Add prototype. - (elfcore_write_lwpstatus): New function. - (elfcore_write_pstatus): Fix typo, eliminate unnecessary memcpy. - -2002-03-20 Tom Rix <trix@redhat.com> - - * 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. - -Mon Mar 18 18:06:54 CET 2002 Jan Hubicka <jh@suse.cz> - - * cpu-i386.c (bfd_x86_64_arch): Rename to "i386:x86-64" - -2002-03-07 Daniel Jacobowitz <drow@mvista.com> - - * configure.in: Set is_release=y for 2.12 release. - * configure: Likewise. - -2002-03-07 Daniel Jacobowitz <drow@mvista.com> - - * configure.in: Bump version to 2.12. - * configure: Likewise. - -2002-03-05 Alan Modra <amodra@bigpond.net.au> - - * configure.in (WIN32LIBADD): Don't eval PICFLAG assignment. - * configure: Regenerate. - 2002-02-26 Andrew Macleod <amacleod@cygnus.com> * elflink.h (elf_bfd_final_link): Don't crash on SHN_UNDEF local @@ -642,34 +2976,104 @@ Mon Mar 18 18:06:54 CET 2002 Jan Hubicka <jh@suse.cz> 2002-02-25 Alan Modra <amodra@bigpond.net.au> + * elf64-hppa.h: Update copyright date. + * elf64-ppc.c (ppc64_elf_check_relocs): Warning fix. (ppc64_elf_relocate_section): Don't generate power4 style branch hints for *_BRTAKEN and *_BRNTAKEN relocs. - * elf64-ppc.c (STFD_FR0_0R1, LFD_FR0_0R1, BLR): Define. - (struct ppc_link_hash_table): Add sfpr. - (ppc64_elf_link_hash_table_create): Init it. - (ppc64_elf_create_dynamic_sections): Split creation of .stub and - .glink out to.. - (create_linkage_sections): ..here. Make .sfpr too. - (ppc64_elf_check_relocs): Call create_linkage_sections, and set - dynobj early. - (MIN_SAVE_FPR, MAX_SAVE_FPR): Define. - (ppc64_elf_func_desc_adjust): Look for missing ._savef* and - ._restf* functions, and create as needed. - (func_desc_adjust): Only force_local for shared libs. - 2002-02-22 Jakub Jelinek <jakub@redhat.com> * elf64-sh64.c (sh_elf64_relocate_section): Fix a typo from my last patch. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. +2002-02-21 Andreas Jaeger <aj@suse.de> + + * elf64-x86-64.c: Major rework that introduces all recent changes + to the x86-64 backend. Get a closer match to elf32-i386. + (struct elf64_x86_64_dyn_relocs): Rename from + elf64_x86_64_pcrel_relocs_copied, add additional fields. Change + all users. + (struct elf64_x86_64_link_hash_table): Add short cuts to some + sections. + (link_hash_newfunc): Rename from elf64_x86_64_link_hash_newfunc, + remove casts, initialize new hash members. + (create_got_section): New. + (elf64_x86_64_create_dynamic_sections): New. + (elf64_x86_64_copy_indirect_symbol): New. + (elf64_x86_64_check_relocs): Don't allocate space for dynamic + relocs, .got or .relgot here but do it in allocate_dynrelocs. + Reference count possible .plt and .got entries. Don't test input + section SEC_READONLY here to try to avoid copy relocs, and keep + dyn_relocs regardless of ELF_LINK_NON_GOT_REF. Don't set + DF_TEXTREL here. Delay setting of variables until needed. Cache + pointer to "sreloc" section in elf_section_data. Tweak condition + under which .got created. Report files with bad relocation + section names. + (elf64_x86_64_gc_sweep_hook): Sweep dyn_relocs and local_dynrel. + Reference count possible .plt entries. Don't deallocate .got and + .relgot space here. + (elf64_x86_64_adjust_dynamic_symbol): Handle nocopyreloc. Don't + do copy reloc processing for weakdefs. Remove redundant casts and + aborts. Delay setting of vars until needed. Move creation of + dynamic symbols and allocation of .plt and .rela.plt to + allocate_dynrelocs. Replace BFD_ASSERT with abort. + (WILL_CALL_FINISH_DYNAMIC_SYMBOL): New. + (allocate_dynrelocs): New. + (readonly_dynrelocs): New. + (elf64_x86_64_size_dynamic_sections): Call readonly_dynrelocs. + Allocate space for dyn relocs. Replace BFD_ASSERT with abort. + Zero out the dynamic allocated content space. + (elf64_x86_64_discard_copies): Removed. + (elf64_x86_64_relocate_section): Make use of dynamic section + short-cuts. Localise vars, and delay setting. Better error + reporting, replace BFD_ASSERT with abort. Check + ELF_LINK_HASH_DEF_DYNAMIC to see if a symbol is not defined in the + regular object file and tread the weak definition as the normal + one. Don't discard relocs for undefweak or undefined symbols and + check !DEF_REGULAR as well as DEF_DYNAMIC in test for avoided copy + relocs. + (elf64_x86_64_finish_dynamic_symbol): Don't copy relocs for + symbols that have been forced local. Use same test to decide if + we can use a relative reloc for got as relocate_section. Expand + SHN_UNDEF comment. Move expressions out of function calls. + Replace BFD_ASSERT with abort. + (bfd_elf64_bfd_final_link): Removed. + (elf_backend_copy_indirect_symbol): Define. + +2002-02-20 Tom Rix <trix@redhat.com> + + * coff-rs6000.c (xcoff_howto_table): Add 16 bit R_BA. + (_bfd_xcoff_reloc_type_lookup): Use it. + * coff64-rs6000.c (xcoff64_howto_table): Same. + (xcoff64_reloc_type_lookup): Same. + 2002-02-20 Peter Schauer <pes@regent.e-technik.tu-muenchen.de> * osf-core.c (osf_core_vec): OSF/1 (Digital Unix) core files are little endian. +2002-02-19 Martin Schwidefsky <schwidefsky@de.ibm.com> + + * archures.c (bfd_mach_s390_esa): Rename to bfd_mach_s390_31. + (bfd_mach_s390_esame): Rename to bfd_mach_s390_64. + * bfd-in2.h: Regenerate. + * cpu-s390.c (arch_info_struct): Use renamed architecture defines. + Replace architecture name "s390" with "s390:31-bit" and "s390:esame" + with "s390:64-bit". + * elf32-s390.c (elf_howto_table): Add 32 bit pc relative relocations. + (elf_s390_reloc_type_lookup): Likewise. + (elf_s390_check_relocs): Likewise. + (elf_s390_gc_sweep_hook): Likewise. + (elf_s390_relocate_section): Likewise. + (elf_s390_object_p): Use renamed architecture define. + * elf64-s390.c (elf_s390_object_p): Use renamed architecture define. + +2002-02-19 Frank Ch. Eigler <fche@redhat.com> + + * syms.c (stt[]): Sorted. Added .init/.fini -> "t" mapping. + 2002-02-19 Jakub Jelinek <jakub@redhat.com> * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Enable @@ -702,14 +3106,37 @@ Mon Mar 18 18:06:54 CET 2002 Jan Hubicka <jh@suse.cz> and BFD_ASSERT. * elf64-mips.c (mips_elf64_create_dynamic_relocation): Likewise. -2002-02-18 John David Anglin <dave@hiauly1.hia.nrc.ca> +2002-02-18 Tom Rix <trix@redhat.com> - * elf-hppa.h (elf_hppa_reloc_final_type): New function stripped - from _bfd_elf_hppa_gen_reloc_type. - (_bfd_elf_hppa_gen_reloc_type): Remove duplicate prototype. - * elf32-hppa.h (elf32_hppa_reloc_final_type): Add protptype. - * elf32-hppa.c: Include elf32-hppa.h before elf-hppa.h. - * elf64-hppa.h (elf64_hppa_reloc_final_type): Add protptype. + * xcofflink.c (bfd_xcoff_link_gernate_rtinit): Add -brtl support. + (bfd_xcoff_size_dynamic_sections): Same. + * bfd-in.h (bfd_xcoff_link_generate_rtinit): Same. + (bfd_xcoff_size_dynamic_sections): Same. + * coff-rs6000.c (xcoff_generate_rtinit): Same. + * coff-rs646000.c (xcoff64_generate_rtinit): Same. + * libxcoff.h (struct xcoff_backend_data_rec): Same. + * xcofflink.c (xcoff_build_ldsyms, xcoff_link_add_symbols): Clean. + * bfd-in2.h: Regenerate. + +2002-02-18 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (STFD_FR0_0R1, LFD_FR0_0R1, BLR): Define. + (struct ppc_link_hash_table): Add sfpr. + (ppc64_elf_link_hash_table_create): Init it. + (ppc64_elf_create_dynamic_sections): Split creation of .stub and + .glink out to.. + (create_linkage_sections): ..here. Make .sfpr too. + (ppc64_elf_check_relocs): Call create_linkage_sections, and set + dynobj early. + (MIN_SAVE_FPR, MAX_SAVE_FPR): Define. + (ppc64_elf_func_desc_adjust): Look for missing ._savef* and + ._restf* functions, and create as needed. + (func_desc_adjust): Only force_local for shared libs. + +2002-02-18 David O'Brien <obrien@FreeBSD.org> + + * configure.in: Bump version number post 2.12 branching. + * configure: Regenerate. 2002-02-17 Hans-Peter Nilsson <hp@bitrange.com> @@ -736,22 +3163,51 @@ Mon Mar 18 18:06:54 CET 2002 Jan Hubicka <jh@suse.cz> * elf64-alpha.c (elf64_alpha_relocate_section) [BRSGP]: A target section with no got matches any got. Simplify error generaion. -2002-02-14 Alan Modra <amodra@bigpond.net.au> +2002-02-15 Alan Modra <amodra@bigpond.net.au> + + Support arbitrary length fill patterns. + * linker.c (bfd_new_link_order): Zero all fields with bfd_zalloc. + (_bfd_default_link_order): Remove bfd_fill_link_order code. + Call default_data_link_order. + (default_fill_link_order): Delete. + (default_data_link_order): New function. + * elf32-mips.c (_bfd_mips_elf_final_link): Replace occurrences + of bfd_fill_link_order with bfd_data_link_order. + * elf64-alpha.c (elf64_alpha_final_link): Likewise. + * elf64-mips.c (mips_elf64_final_link): Likewise. - * elf.c (elf_fake_sections): Use SHT_NOBITS when SEC_NEVER_LOAD. + * bfd.c (bfd_scan_vma): Clamp overflows to max bfd_vma value. + Correct value returned in "end" for "0x<non-hex>". -2002-02-13 Hans-Peter Nilsson <hp@bitrange.com> +2002-02-14 Nick Clifton <nickc@cambridge.redhat.com> - * config.bfd (sh-*-linux*, sh-*-elf* | sh-*-rtemself*): Add sh64 - vectors. - (sh-*-netbsdelf*): New, to trump sh*-*-netbsdelf* and add sh64 - vectors. + * cpu-arm.c (processors): Replace 'arch' field with 'mach'. + (scan): Test against 'mach' field in info structure. + +2002-02-14 Alan Modra <amodra@bigpond.net.au> + + * elf.c (elf_fake_sections): Use SHT_NOBITS when SEC_NEVER_LOAD. -2002-02-13 Matt Fredette <fredette@netbsd.org> +2002-02-14 Matt Fredette <fredette@netbsd.org> * elf32-m68k.c (elf32_m68k_print_private_bfd_data): Recognize EF_M68000. +2002-02-13 Nick Clifton <nickc@cambridge.redhat.com> + + * elf.c (_bfd_elf_make_section_from_shdr): Do not insist on + non-zero physical addresses when adjusting the LMAs of new + sections. + +2002-02-12 John David Anglin <dave@hiauly1.hia.nrc.ca> + + * elf-hppa.h (elf_hppa_reloc_final_type): New function stripped + from _bfd_elf_hppa_gen_reloc_type. + (_bfd_elf_hppa_gen_reloc_type): Remove duplicate prototype. + * elf32-hppa.h (elf32_hppa_reloc_final_type): Add protptype. + * elf32-hppa.c: Include elf32-hppa.h before elf-hppa.h. + * elf64-hppa.h (elf64_hppa_reloc_final_type): Add protptype. + 2002-02-12 Alexandre Oliva <aoliva@redhat.com> * elf-m10300.c (mn10300_elf_relax_section): Skip section before @@ -766,6 +3222,14 @@ Mon Mar 18 18:06:54 CET 2002 Jan Hubicka <jh@suse.cz> DT_PPC64_OPD and DT_PPC64_OPDSZ tags. (ppc64_elf_finish_dynamic_sections): Set values for them. +2002-02-11 Michael Snyder <msnyder@redhat.com> + + * elf-bfd.h (elfcore_write_lwpstatus): Add prototype. + * elf.c (elfcore_grok_pstatus): Add prototype. + (elfcore_grok_lwpstatus): Add prototype. + (elfcore_write_lwpstatus): New function. + (elfcore_write_pstatus): Fix typo, eliminate unnecessary memcpy. + 2002-02-11 Alexandre Oliva <aoliva@redhat.com> * elf32-sh.c: Added missing prototypes. @@ -776,6 +3240,14 @@ Mon Mar 18 18:06:54 CET 2002 Jan Hubicka <jh@suse.cz> (sh_elf64_relocate_section): Fix info argument passed to _bfd_elf_section_offset. +2002-02-11 Alan Modra <amodra@bigpond.net.au> + + * Makefile.am: "make dep-am". + * Makefile.in: Regenerate. + * aclocal.m4: Regenerate. + * config.in: Regenerate. + * configure: Regenerate. + 2002-02-10 Daniel Jacobowitz <drow@mvista.com> * coff-rs6000.c (xcoff_generate_rtinit): Silence uninitialized @@ -785,6 +3257,13 @@ Mon Mar 18 18:06:54 CET 2002 Jan Hubicka <jh@suse.cz> * trad-core.c (trad_unix_core_file_p): Silence pointer/integer cast warnings for the common case. +2002-02-10 Hans-Peter Nilsson <hp@bitrange.com> + + * config.bfd (sh-*-linux*, sh-*-elf* | sh-*-rtemself*): Add sh64 + vectors. + (sh-*-netbsdelf*): New, to trump sh*-*-netbsdelf* and add sh64 + vectors. + 2002-02-09 Richard Henderson <rth@redhat.com> * elf64-alpha.c (elf64_alpha_howto): Add R_ALPHA_BRSGP. diff --git a/contrib/binutils/bfd/Makefile.am b/contrib/binutils/bfd/Makefile.am index 411351b..f56ceb0 100644 --- a/contrib/binutils/bfd/Makefile.am +++ b/contrib/binutils/bfd/Makefile.am @@ -9,8 +9,10 @@ MKDEP = gcc -MM SUBDIRS = doc po docdir = doc +bfdlibdir = @bfdlibdir@ +bfdincludedir = @bfdincludedir@ -lib_LTLIBRARIES = libbfd.la +bfdlib_LTLIBRARIES = libbfd.la WARN_CFLAGS = @WARN_CFLAGS@ AM_CFLAGS = $(WARN_CFLAGS) @@ -54,7 +56,9 @@ ALL_MACHINES = \ cpu-cris.lo \ cpu-d10v.lo \ cpu-d30v.lo \ + cpu-dlx.lo \ cpu-fr30.lo \ + cpu-frv.lo \ cpu-h8300.lo \ cpu-h8500.lo \ cpu-hppa.lo \ @@ -102,7 +106,9 @@ ALL_MACHINES_CFILES = \ cpu-cris.c \ cpu-d10v.c \ cpu-d30v.c \ + cpu-dlx.c \ cpu-fr30.c \ + cpu-frv.c \ cpu-h8300.c \ cpu-h8500.c \ cpu-hppa.c \ @@ -196,12 +202,16 @@ BFD32_BACKENDS = \ elf32-cris.lo \ elf32-d10v.lo \ elf32-d30v.lo \ + elf32-dlx.lo \ elf32-fr30.lo \ + elf32-frv.lo \ elf32-gen.lo \ elf32-h8300.lo \ elf32-hppa.lo \ elf32-i370.lo \ elf32-i386.lo \ + elf32-i386-fbsd.lo \ + elf32-i386qnx.lo \ elf32-i860.lo \ elf32-i960.lo \ elf32-ia64.lo \ @@ -213,6 +223,7 @@ BFD32_BACKENDS = \ elf-m10200.lo \ elf-m10300.lo \ elf32-mcore.lo \ + elfxx-mips.lo \ elf32-mips.lo \ elf32-openrisc.lo \ elf32-or32.lo \ @@ -222,9 +233,12 @@ BFD32_BACKENDS = \ elf32-sh.lo \ elf32-sh-lin.lo \ elf32-sh64.lo \ + elf32-sh64-com.lo \ elf32-sh-nbsd.lo \ + elf32-sh64-nbsd.lo \ elf32-sparc.lo \ elf32-v850.lo \ + elf32-vax.lo \ elf32-xstormy16.lo \ elf32.lo \ elflink.lo \ @@ -283,6 +297,8 @@ BFD32_BACKENDS = \ sparcnetbsd.lo \ sunos.lo \ vaxnetbsd.lo \ + vax1knetbsd.lo \ + vaxbsd.lo \ versados.lo \ vms.lo \ vms-gsd.lo \ @@ -344,12 +360,16 @@ BFD32_BACKENDS_CFILES = \ elf32-cris.c \ elf32-d10v.c \ elf32-d30v.c \ + elf32-dlx.c \ elf32-fr30.c \ + elf32-frv.c \ elf32-gen.c \ elf32-h8300.c \ elf32-hppa.c \ elf32-i370.c \ elf32-i386.c \ + elf32-i386-fbsd.c \ + elf32-i386qnx.c \ elf32-i860.c \ elf32-i960.c \ elf32-m32r.c \ @@ -360,18 +380,22 @@ BFD32_BACKENDS_CFILES = \ elf-m10200.c \ elf-m10300.c \ elf32-mcore.c \ + elfxx-mips.c \ elf32-mips.c \ elf32-openrisc.c \ elf32-or32.c \ elf32-pj.c \ elf32-ppc.c \ elf32-sh64.c \ + elf32-sh64-com.c \ elf32-s390.c \ elf32-sh.c \ elf32-sh-lin.c \ elf32-sh-nbsd.c \ + elf32-sh64-nbsd.c \ elf32-sparc.c \ elf32-v850.c \ + elf32-vax.c \ elf32-xstormy16.c \ elf32.c \ elflink.c \ @@ -429,6 +453,8 @@ BFD32_BACKENDS_CFILES = \ sparcnetbsd.c \ sunos.c \ vaxnetbsd.c \ + vax1knetbsd.c \ + vaxbsd.c \ versados.c \ vms.c \ vms-gsd.c \ @@ -441,6 +467,7 @@ BFD32_BACKENDS_CFILES = \ # target_vector in targets.c if configured with --enable-targets=all # and --enable-64-bit-bfd. BFD64_BACKENDS = \ + aix5ppc-core.lo \ aout64.lo \ coff-alpha.lo \ coff64-rs6000.lo \ @@ -448,12 +475,14 @@ BFD64_BACKENDS = \ efi-app-ia64.lo \ elf64-x86-64.lo \ elf64-alpha.lo \ + elf64-alpha-fbsd.lo \ elf64-hppa.lo \ elf64-ia64.lo \ elf64-gen.lo \ elf64-mips.lo \ elf64-mmix.lo \ elf64-sh64.lo \ + elf64-sh64-nbsd.lo \ elf64-ppc.lo \ elf64-s390.lo \ elf64-sparc.lo \ @@ -464,6 +493,7 @@ BFD64_BACKENDS = \ pepigen.lo BFD64_BACKENDS_CFILES = \ + aix5ppc-core.c \ aout64.c \ coff-alpha.c \ coff64-rs6000.c \ @@ -471,6 +501,7 @@ BFD64_BACKENDS_CFILES = \ efi-app-ia64.c \ elf64-x86-64.c \ elf64-alpha.c \ + elf64-alpha-fbsd.c \ elf64-hppa.c \ elf64-gen.c \ elf64-mips.c \ @@ -478,6 +509,7 @@ BFD64_BACKENDS_CFILES = \ elf64-ppc.c \ elf64-s390.c \ elf64-sh64.c \ + elf64-sh64-nbsd.c \ elf64-sparc.c \ elf64.c \ mmo.c \ @@ -668,14 +700,35 @@ $(BFD32_LIBS) \ $(BFD64_BACKENDS) \ $(OPTIONAL_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS) -# Install BFD include file, and others that it needs. -install-data-local: $(BFD_H) +install-bfdlibLTLIBRARIES: @INSTALL_LIBBFD_TRUE@install_libbfd @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(includedir) - $(INSTALL_DATA) $(BFD_H) $(DESTDIR)$(includedir)/bfd.h - $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(DESTDIR)$(includedir)/ansidecl.h - $(INSTALL_DATA) $(INCDIR)/symcat.h $(DESTDIR)$(includedir)/symcat.h - $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(DESTDIR)$(includedir)/bfdlink.h + +uninstall-bfdlibLTLIBRARIES: @INSTALL_LIBBFD_TRUE@uninstall_libbfd + @$(NORMAL_UNINSTALL) + +.PHONY: install_libbfd uninstall_libbfd +install_libbfd: $(bfdlib_LTLIBRARIES) $(BFD_H) + $(mkinstalldirs) $(DESTDIR)$(bfdlibdir) + $(mkinstalldirs) $(DESTDIR)$(bfdincludedir) + @list='$(bfdlib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(bfdlibdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(bfdlibdir)/$$p; \ + else :; fi; \ + done + $(INSTALL_DATA) $(BFD_H) $(DESTDIR)$(bfdincludedir)/bfd.h + $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(DESTDIR)$(bfdincludedir)/ansidecl.h + $(INSTALL_DATA) $(INCDIR)/symcat.h $(DESTDIR)$(bfdincludedir)/symcat.h + $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(DESTDIR)$(bfdincludedir)/bfdlink.h + +uninstall_libbfd: + list='$(bfdlib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bfdlibdir)/$$p; \ + done + rm -f $(DESTDIR)$(bfdincludedir)/bfd.h + rm -f $(DESTDIR)$(bfdincludedir)/ansidecl.h + rm -f $(DESTDIR)$(bfdincludedir)/symcat.h + rm -f $(DESTDIR)$(bfdincludedir)/bfdlink.h Makefile: $(srcdir)/configure.in @@ -787,7 +840,6 @@ DISTCLEANFILES = $(BUILD_CFILES) $(BUILD_HFILES) config.status: $(srcdir)/configure $(srcdir)/config.bfd $(srcdir)/configure.host $(SHELL) ./config.status --recheck - # What appears below is generated by a hacked mkdep using gcc -MM. # DO NOT DELETE THIS LINE -- mkdep uses it. @@ -827,7 +879,8 @@ stabs.lo: stabs.c $(INCDIR)/filenames.h $(INCDIR)/aout/stab_gnu.h \ $(INCDIR)/aout/stab.def $(INCDIR)/safe-ctype.h stab-syms.lo: stab-syms.c libaout.h $(INCDIR)/bfdlink.h \ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab.def -merge.lo: merge.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h +merge.lo: merge.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ + $(INCDIR)/libiberty.h dwarf2.lo: dwarf2.c $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/dwarf2.h @@ -840,7 +893,9 @@ cpu-avr.lo: cpu-avr.c $(INCDIR)/filenames.h cpu-cris.lo: cpu-cris.c $(INCDIR)/filenames.h cpu-d10v.lo: cpu-d10v.c $(INCDIR)/filenames.h cpu-d30v.lo: cpu-d30v.c $(INCDIR)/filenames.h +cpu-dlx.lo: cpu-dlx.c $(INCDIR)/filenames.h cpu-fr30.lo: cpu-fr30.c $(INCDIR)/filenames.h +cpu-frv.lo: cpu-frv.c $(INCDIR)/filenames.h cpu-h8300.lo: cpu-h8300.c $(INCDIR)/filenames.h cpu-h8500.lo: cpu-h8500.c $(INCDIR)/filenames.h cpu-hppa.lo: cpu-hppa.c $(INCDIR)/filenames.h @@ -1056,10 +1111,18 @@ elf32-d30v.lo: elf32-d30v.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(INCDIR)/elf/d30v.h $(INCDIR)/elf/reloc-macros.h \ elf32-target.h +elf32-dlx.lo: elf32-dlx.c $(INCDIR)/filenames.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(INCDIR)/elf/dlx.h $(INCDIR)/elf/reloc-macros.h \ + elf32-target.h elf32-fr30.lo: elf32-fr30.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(INCDIR)/elf/fr30.h $(INCDIR)/elf/reloc-macros.h \ elf32-target.h +elf32-frv.lo: elf32-frv.c $(INCDIR)/filenames.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(INCDIR)/elf/frv.h $(INCDIR)/elf/reloc-macros.h \ + elf32-target.h elf32-gen.lo: elf32-gen.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h elf32-target.h @@ -1078,6 +1141,14 @@ elf32-i386.lo: elf32-i386.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/elf/i386.h $(INCDIR)/elf/reloc-macros.h \ elf32-target.h +elf32-i386-fbsd.lo: elf32-i386-fbsd.c elf32-i386.c $(INCDIR)/filenames.h \ + $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/i386.h \ + $(INCDIR)/elf/reloc-macros.h elf32-target.h +elf32-i386qnx.lo: elf32-i386qnx.c elf32-i386.c $(INCDIR)/filenames.h \ + $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/i386.h \ + $(INCDIR)/elf/reloc-macros.h elf32-target.h elf32-i860.lo: elf32-i860.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(INCDIR)/elf/i860.h $(INCDIR)/elf/reloc-macros.h \ @@ -1116,12 +1187,17 @@ elf32-mcore.lo: elf32-mcore.c $(INCDIR)/filenames.h \ $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/mcore.h \ $(INCDIR)/elf/reloc-macros.h elf32-target.h +elfxx-mips.lo: elfxx-mips.c $(INCDIR)/filenames.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h elfxx-mips.h $(INCDIR)/elf/mips.h \ + $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \ + $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h elf32-mips.lo: elf32-mips.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ genlink.h elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ - $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h \ - $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \ - $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h \ - ecoffswap.h elf32-target.h + $(INCDIR)/elf/external.h elfxx-mips.h $(INCDIR)/elf/mips.h \ + $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \ + $(INCDIR)/coff/internal.h $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h \ + $(INCDIR)/coff/external.h ecoffswap.h elf32-target.h elf32-openrisc.lo: elf32-openrisc.c $(INCDIR)/filenames.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/openrisc.h \ @@ -1144,6 +1220,10 @@ elf32-sh64.lo: elf32-sh64.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/bfdlink.h $(srcdir)/../opcodes/sh64-opc.h \ elf32-sh.c $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h \ elf32-target.h +elf32-sh64-com.lo: elf32-sh64-com.c $(INCDIR)/filenames.h \ + elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ + $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/sh.h \ + $(INCDIR)/elf/reloc-macros.h $(srcdir)/../opcodes/sh64-opc.h elf32-s390.lo: elf32-s390.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/elf/s390.h $(INCDIR)/elf/reloc-macros.h \ @@ -1160,6 +1240,11 @@ elf32-sh-nbsd.lo: elf32-sh-nbsd.c elf32-sh.c $(INCDIR)/filenames.h \ $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/sh.h \ $(INCDIR)/elf/reloc-macros.h elf32-target.h +elf32-sh64-nbsd.lo: elf32-sh64-nbsd.c elf32-sh64.c \ + $(INCDIR)/filenames.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + $(srcdir)/../opcodes/sh64-opc.h elf32-sh.c $(INCDIR)/elf/sh.h \ + $(INCDIR)/elf/reloc-macros.h elf32-target.h elf32-sparc.lo: elf32-sparc.c $(INCDIR)/filenames.h \ $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/sparc.h \ @@ -1169,6 +1254,10 @@ elf32-v850.lo: elf32-v850.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/elf/v850.h $(INCDIR)/elf/reloc-macros.h \ $(INCDIR)/libiberty.h elf32-target.h +elf32-vax.lo: elf32-vax.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ + elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ + $(INCDIR)/elf/external.h $(INCDIR)/elf/vax.h $(INCDIR)/elf/reloc-macros.h \ + elf32-target.h elf32-xstormy16.lo: elf32-xstormy16.c $(INCDIR)/filenames.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/xstormy16.h \ @@ -1183,7 +1272,7 @@ elflink.lo: elflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ $(INCDIR)/elf/external.h elf-strtab.lo: elf-strtab.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ - $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h + $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h $(INCDIR)/libiberty.h elf-eh-frame.lo: elf-eh-frame.c $(INCDIR)/filenames.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/dwarf2.h @@ -1353,6 +1442,12 @@ sunos.lo: sunos.c $(INCDIR)/bfdlink.h libaout.h aoutf1.h \ vaxnetbsd.lo: vaxnetbsd.c netbsd.h $(INCDIR)/filenames.h \ libaout.h $(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h +vax1knetbsd.lo: vax1knetbsd.c netbsd.h $(INCDIR)/filenames.h \ + libaout.h $(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \ + $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h +vaxbsd.lo: vaxbsd.c $(INCDIR)/filenames.h libaout.h \ + $(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \ + $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h versados.lo: versados.c $(INCDIR)/filenames.h $(INCDIR)/libiberty.h vms.lo: vms.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ vms.h @@ -1367,6 +1462,7 @@ vms-tir.lo: vms-tir.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ xcofflink.lo: xcofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/xcoff.h libcoff.h \ libxcoff.h +aix5ppc-core.lo: aix5ppc-core.c aout64.lo: aout64.c aoutx.h $(INCDIR)/filenames.h $(INCDIR)/safe-ctype.h \ $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h @@ -1387,8 +1483,8 @@ efi-app-ia64.lo: efi-app-ia64.c $(INCDIR)/filenames.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \ $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.h elf64-x86-64.lo: elf64-x86-64.c $(INCDIR)/filenames.h \ - elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ - $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/x86-64.h \ + $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/x86-64.h \ $(INCDIR)/elf/reloc-macros.h elf64-target.h elf64-alpha.lo: elf64-alpha.c $(INCDIR)/filenames.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ @@ -1397,6 +1493,13 @@ elf64-alpha.lo: elf64-alpha.c $(INCDIR)/filenames.h \ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h libcoff.h \ libecoff.h ecoffswap.h elf64-target.h +elf64-alpha-fbsd.lo: elf64-alpha-fbsd.c elf64-alpha.c $(INCDIR)/filenames.h \ + elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ + $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/alpha.h \ + $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/internal.h \ + $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \ + $(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h libcoff.h \ + libecoff.h ecoffswap.h elf64-target.h elf64-hppa.lo: elf64-hppa.c $(INCDIR)/alloca-conf.h \ $(INCDIR)/filenames.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ @@ -1407,10 +1510,11 @@ elf64-gen.lo: elf64-gen.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/bfdlink.h elf64-target.h elf64-mips.lo: elf64-mips.c $(INCDIR)/filenames.h $(INCDIR)/aout/ar.h \ $(INCDIR)/bfdlink.h genlink.h elf-bfd.h $(INCDIR)/elf/common.h \ - $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h \ - $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \ - $(INCDIR)/coff/internal.h $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h \ - ecoffswap.h elf64-target.h + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elfxx-mips.h \ + $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h \ + $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \ + $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h ecoffswap.h \ + elf64-target.h elf64-mmix.lo: elf64-mmix.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(INCDIR)/elf/mmix.h $(INCDIR)/elf/reloc-macros.h \ @@ -1427,6 +1531,10 @@ elf64-sh64.lo: elf64-sh64.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h \ elf64-target.h +elf64-sh64-nbsd.lo: elf64-sh64-nbsd.c elf64-sh64.c \ + $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h elf64-target.h elf64-sparc.lo: elf64-sparc.c $(INCDIR)/filenames.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/opcode/sparc.h \ diff --git a/contrib/binutils/bfd/Makefile.in b/contrib/binutils/bfd/Makefile.in index 643196a..6744de0 100644 --- a/contrib/binutils/bfd/Makefile.in +++ b/contrib/binutils/bfd/Makefile.in @@ -133,8 +133,10 @@ MKDEP = gcc -MM SUBDIRS = doc po docdir = doc +bfdlibdir = @bfdlibdir@ +bfdincludedir = @bfdincludedir@ -lib_LTLIBRARIES = libbfd.la +bfdlib_LTLIBRARIES = libbfd.la WARN_CFLAGS = @WARN_CFLAGS@ AM_CFLAGS = $(WARN_CFLAGS) @@ -180,7 +182,9 @@ ALL_MACHINES = \ cpu-cris.lo \ cpu-d10v.lo \ cpu-d30v.lo \ + cpu-dlx.lo \ cpu-fr30.lo \ + cpu-frv.lo \ cpu-h8300.lo \ cpu-h8500.lo \ cpu-hppa.lo \ @@ -229,7 +233,9 @@ ALL_MACHINES_CFILES = \ cpu-cris.c \ cpu-d10v.c \ cpu-d30v.c \ + cpu-dlx.c \ cpu-fr30.c \ + cpu-frv.c \ cpu-h8300.c \ cpu-h8500.c \ cpu-hppa.c \ @@ -324,12 +330,16 @@ BFD32_BACKENDS = \ elf32-cris.lo \ elf32-d10v.lo \ elf32-d30v.lo \ + elf32-dlx.lo \ elf32-fr30.lo \ + elf32-frv.lo \ elf32-gen.lo \ elf32-h8300.lo \ elf32-hppa.lo \ elf32-i370.lo \ elf32-i386.lo \ + elf32-i386-fbsd.lo \ + elf32-i386qnx.lo \ elf32-i860.lo \ elf32-i960.lo \ elf32-ia64.lo \ @@ -341,6 +351,7 @@ BFD32_BACKENDS = \ elf-m10200.lo \ elf-m10300.lo \ elf32-mcore.lo \ + elfxx-mips.lo \ elf32-mips.lo \ elf32-openrisc.lo \ elf32-or32.lo \ @@ -350,9 +361,12 @@ BFD32_BACKENDS = \ elf32-sh.lo \ elf32-sh-lin.lo \ elf32-sh64.lo \ + elf32-sh64-com.lo \ elf32-sh-nbsd.lo \ + elf32-sh64-nbsd.lo \ elf32-sparc.lo \ elf32-v850.lo \ + elf32-vax.lo \ elf32-xstormy16.lo \ elf32.lo \ elflink.lo \ @@ -411,6 +425,8 @@ BFD32_BACKENDS = \ sparcnetbsd.lo \ sunos.lo \ vaxnetbsd.lo \ + vax1knetbsd.lo \ + vaxbsd.lo \ versados.lo \ vms.lo \ vms-gsd.lo \ @@ -473,12 +489,16 @@ BFD32_BACKENDS_CFILES = \ elf32-cris.c \ elf32-d10v.c \ elf32-d30v.c \ + elf32-dlx.c \ elf32-fr30.c \ + elf32-frv.c \ elf32-gen.c \ elf32-h8300.c \ elf32-hppa.c \ elf32-i370.c \ elf32-i386.c \ + elf32-i386-fbsd.c \ + elf32-i386qnx.c \ elf32-i860.c \ elf32-i960.c \ elf32-m32r.c \ @@ -489,18 +509,22 @@ BFD32_BACKENDS_CFILES = \ elf-m10200.c \ elf-m10300.c \ elf32-mcore.c \ + elfxx-mips.c \ elf32-mips.c \ elf32-openrisc.c \ elf32-or32.c \ elf32-pj.c \ elf32-ppc.c \ elf32-sh64.c \ + elf32-sh64-com.c \ elf32-s390.c \ elf32-sh.c \ elf32-sh-lin.c \ elf32-sh-nbsd.c \ + elf32-sh64-nbsd.c \ elf32-sparc.c \ elf32-v850.c \ + elf32-vax.c \ elf32-xstormy16.c \ elf32.c \ elflink.c \ @@ -558,6 +582,8 @@ BFD32_BACKENDS_CFILES = \ sparcnetbsd.c \ sunos.c \ vaxnetbsd.c \ + vax1knetbsd.c \ + vaxbsd.c \ versados.c \ vms.c \ vms-gsd.c \ @@ -571,6 +597,7 @@ BFD32_BACKENDS_CFILES = \ # target_vector in targets.c if configured with --enable-targets=all # and --enable-64-bit-bfd. BFD64_BACKENDS = \ + aix5ppc-core.lo \ aout64.lo \ coff-alpha.lo \ coff64-rs6000.lo \ @@ -578,12 +605,14 @@ BFD64_BACKENDS = \ efi-app-ia64.lo \ elf64-x86-64.lo \ elf64-alpha.lo \ + elf64-alpha-fbsd.lo \ elf64-hppa.lo \ elf64-ia64.lo \ elf64-gen.lo \ elf64-mips.lo \ elf64-mmix.lo \ elf64-sh64.lo \ + elf64-sh64-nbsd.lo \ elf64-ppc.lo \ elf64-s390.lo \ elf64-sparc.lo \ @@ -595,6 +624,7 @@ BFD64_BACKENDS = \ BFD64_BACKENDS_CFILES = \ + aix5ppc-core.c \ aout64.c \ coff-alpha.c \ coff64-rs6000.c \ @@ -602,6 +632,7 @@ BFD64_BACKENDS_CFILES = \ efi-app-ia64.c \ elf64-x86-64.c \ elf64-alpha.c \ + elf64-alpha-fbsd.c \ elf64-hppa.c \ elf64-gen.c \ elf64-mips.c \ @@ -609,6 +640,7 @@ BFD64_BACKENDS_CFILES = \ elf64-ppc.c \ elf64-s390.c \ elf64-sh64.c \ + elf64-sh64-nbsd.c \ elf64-sparc.c \ elf64.c \ mmo.c \ @@ -732,7 +764,7 @@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ libbfd_a_LIBADD = libbfd_a_OBJECTS = -LTLIBRARIES = $(lib_LTLIBRARIES) +LTLIBRARIES = $(bfdlib_LTLIBRARIES) libbfd_la_OBJECTS = archive.lo archures.lo bfd.lo cache.lo coffgen.lo \ corefile.lo format.lo init.lo libbfd.lo opncls.lo reloc.lo section.lo \ @@ -853,33 +885,17 @@ distclean-libtool: maintainer-clean-libtool: -mostlyclean-libLTLIBRARIES: +mostlyclean-bfdlibLTLIBRARIES: -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) +clean-bfdlibLTLIBRARIES: + -test -z "$(bfdlib_LTLIBRARIES)" || rm -f $(bfdlib_LTLIBRARIES) -distclean-libLTLIBRARIES: +distclean-bfdlibLTLIBRARIES: -maintainer-clean-libLTLIBRARIES: - -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(libdir) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \ - $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \ - else :; fi; \ - done - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ - done +maintainer-clean-bfdlibLTLIBRARIES: libbfd.la: $(libbfd_la_OBJECTS) $(libbfd_la_DEPENDENCIES) - $(LINK) -rpath $(libdir) $(libbfd_la_LDFLAGS) $(libbfd_la_OBJECTS) $(libbfd_la_LIBADD) $(LIBS) + $(LINK) -rpath $(bfdlibdir) $(libbfd_la_LDFLAGS) $(libbfd_la_OBJECTS) $(libbfd_la_LIBADD) $(LIBS) # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. @@ -1041,16 +1057,16 @@ install-info: install-info-recursive all-recursive-am: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive -install-exec-am: install-libLTLIBRARIES +install-exec-am: install-exec: install-exec-recursive -install-data-am: install-data-local +install-data-am: install-bfdlibLTLIBRARIES install-data: install-data-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-recursive -uninstall-am: uninstall-libLTLIBRARIES +uninstall-am: uninstall-bfdlibLTLIBRARIES uninstall: uninstall-recursive all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) config.h all-redirect: all-recursive-am @@ -1058,7 +1074,7 @@ install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: installdirs-recursive installdirs-am: - $(mkinstalldirs) $(DESTDIR)$(libdir) + $(mkinstalldirs) $(DESTDIR)$(bfdlibdir) mostlyclean-generic: @@ -1075,19 +1091,19 @@ distclean-generic: maintainer-clean-generic: mostlyclean-am: mostlyclean-hdr mostlyclean-noinstLIBRARIES \ mostlyclean-compile mostlyclean-libtool \ - mostlyclean-libLTLIBRARIES mostlyclean-tags \ + mostlyclean-bfdlibLTLIBRARIES mostlyclean-tags \ mostlyclean-generic mostlyclean: mostlyclean-recursive clean-am: clean-hdr clean-noinstLIBRARIES clean-compile clean-libtool \ - clean-libLTLIBRARIES clean-tags clean-generic \ + clean-bfdlibLTLIBRARIES clean-tags clean-generic \ mostlyclean-am clean: clean-recursive distclean-am: distclean-hdr distclean-noinstLIBRARIES distclean-compile \ - distclean-libtool distclean-libLTLIBRARIES \ + distclean-libtool distclean-bfdlibLTLIBRARIES \ distclean-tags distclean-generic clean-am -rm -f libtool @@ -1097,8 +1113,9 @@ distclean: distclean-recursive maintainer-clean-am: maintainer-clean-hdr \ maintainer-clean-noinstLIBRARIES \ maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-libLTLIBRARIES maintainer-clean-tags \ - maintainer-clean-generic distclean-am + maintainer-clean-bfdlibLTLIBRARIES \ + maintainer-clean-tags maintainer-clean-generic \ + distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." @@ -1110,22 +1127,22 @@ mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile mostlyclean-libtool distclean-libtool \ -clean-libtool maintainer-clean-libtool mostlyclean-libLTLIBRARIES \ -distclean-libLTLIBRARIES clean-libLTLIBRARIES \ -maintainer-clean-libLTLIBRARIES uninstall-libLTLIBRARIES \ -install-libLTLIBRARIES install-data-recursive uninstall-data-recursive \ -install-exec-recursive uninstall-exec-recursive installdirs-recursive \ -uninstalldirs-recursive all-recursive check-recursive \ -installcheck-recursive info-recursive dvi-recursive \ -mostlyclean-recursive distclean-recursive clean-recursive \ +clean-libtool maintainer-clean-libtool mostlyclean-bfdlibLTLIBRARIES \ +distclean-bfdlibLTLIBRARIES clean-bfdlibLTLIBRARIES \ +maintainer-clean-bfdlibLTLIBRARIES uninstall-bfdlibLTLIBRARIES \ +install-bfdlibLTLIBRARIES install-data-recursive \ +uninstall-data-recursive install-exec-recursive \ +uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ +all-recursive check-recursive installcheck-recursive info-recursive \ +dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ dvi-am dvi check check-am installcheck-am installcheck install-info-am \ install-info all-recursive-am install-exec-am install-exec \ -install-data-local install-data-am install-data install-am install \ -uninstall-am uninstall all-redirect all-am all installdirs-am \ -installdirs mostlyclean-generic distclean-generic clean-generic \ -maintainer-clean-generic clean mostlyclean distclean maintainer-clean +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs-am installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean po/SRC-POTFILES.in: @MAINT@ Makefile $(SRC_POTFILES) @@ -1226,14 +1243,35 @@ $(BFD32_LIBS) \ $(BFD64_BACKENDS) \ $(OPTIONAL_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS) -# Install BFD include file, and others that it needs. -install-data-local: $(BFD_H) +install-bfdlibLTLIBRARIES: @INSTALL_LIBBFD_TRUE@install_libbfd @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(includedir) - $(INSTALL_DATA) $(BFD_H) $(DESTDIR)$(includedir)/bfd.h - $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(DESTDIR)$(includedir)/ansidecl.h - $(INSTALL_DATA) $(INCDIR)/symcat.h $(DESTDIR)$(includedir)/symcat.h - $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(DESTDIR)$(includedir)/bfdlink.h + +uninstall-bfdlibLTLIBRARIES: @INSTALL_LIBBFD_TRUE@uninstall_libbfd + @$(NORMAL_UNINSTALL) + +.PHONY: install_libbfd uninstall_libbfd +install_libbfd: $(bfdlib_LTLIBRARIES) $(BFD_H) + $(mkinstalldirs) $(DESTDIR)$(bfdlibdir) + $(mkinstalldirs) $(DESTDIR)$(bfdincludedir) + @list='$(bfdlib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(bfdlibdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(bfdlibdir)/$$p; \ + else :; fi; \ + done + $(INSTALL_DATA) $(BFD_H) $(DESTDIR)$(bfdincludedir)/bfd.h + $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(DESTDIR)$(bfdincludedir)/ansidecl.h + $(INSTALL_DATA) $(INCDIR)/symcat.h $(DESTDIR)$(bfdincludedir)/symcat.h + $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(DESTDIR)$(bfdincludedir)/bfdlink.h + +uninstall_libbfd: + list='$(bfdlib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bfdlibdir)/$$p; \ + done + rm -f $(DESTDIR)$(bfdincludedir)/bfd.h + rm -f $(DESTDIR)$(bfdincludedir)/ansidecl.h + rm -f $(DESTDIR)$(bfdincludedir)/symcat.h + rm -f $(DESTDIR)$(bfdincludedir)/bfdlink.h Makefile: $(srcdir)/configure.in @@ -1371,7 +1409,8 @@ stabs.lo: stabs.c $(INCDIR)/filenames.h $(INCDIR)/aout/stab_gnu.h \ $(INCDIR)/aout/stab.def $(INCDIR)/safe-ctype.h stab-syms.lo: stab-syms.c libaout.h $(INCDIR)/bfdlink.h \ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab.def -merge.lo: merge.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h +merge.lo: merge.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ + $(INCDIR)/libiberty.h dwarf2.lo: dwarf2.c $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/dwarf2.h @@ -1384,7 +1423,9 @@ cpu-avr.lo: cpu-avr.c $(INCDIR)/filenames.h cpu-cris.lo: cpu-cris.c $(INCDIR)/filenames.h cpu-d10v.lo: cpu-d10v.c $(INCDIR)/filenames.h cpu-d30v.lo: cpu-d30v.c $(INCDIR)/filenames.h +cpu-dlx.lo: cpu-dlx.c $(INCDIR)/filenames.h cpu-fr30.lo: cpu-fr30.c $(INCDIR)/filenames.h +cpu-frv.lo: cpu-frv.c $(INCDIR)/filenames.h cpu-h8300.lo: cpu-h8300.c $(INCDIR)/filenames.h cpu-h8500.lo: cpu-h8500.c $(INCDIR)/filenames.h cpu-hppa.lo: cpu-hppa.c $(INCDIR)/filenames.h @@ -1600,10 +1641,18 @@ elf32-d30v.lo: elf32-d30v.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(INCDIR)/elf/d30v.h $(INCDIR)/elf/reloc-macros.h \ elf32-target.h +elf32-dlx.lo: elf32-dlx.c $(INCDIR)/filenames.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(INCDIR)/elf/dlx.h $(INCDIR)/elf/reloc-macros.h \ + elf32-target.h elf32-fr30.lo: elf32-fr30.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(INCDIR)/elf/fr30.h $(INCDIR)/elf/reloc-macros.h \ elf32-target.h +elf32-frv.lo: elf32-frv.c $(INCDIR)/filenames.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(INCDIR)/elf/frv.h $(INCDIR)/elf/reloc-macros.h \ + elf32-target.h elf32-gen.lo: elf32-gen.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h elf32-target.h @@ -1622,6 +1671,14 @@ elf32-i386.lo: elf32-i386.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/elf/i386.h $(INCDIR)/elf/reloc-macros.h \ elf32-target.h +elf32-i386-fbsd.lo: elf32-i386-fbsd.c elf32-i386.c $(INCDIR)/filenames.h \ + $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/i386.h \ + $(INCDIR)/elf/reloc-macros.h elf32-target.h +elf32-i386qnx.lo: elf32-i386qnx.c elf32-i386.c $(INCDIR)/filenames.h \ + $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/i386.h \ + $(INCDIR)/elf/reloc-macros.h elf32-target.h elf32-i860.lo: elf32-i860.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(INCDIR)/elf/i860.h $(INCDIR)/elf/reloc-macros.h \ @@ -1660,12 +1717,17 @@ elf32-mcore.lo: elf32-mcore.c $(INCDIR)/filenames.h \ $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/mcore.h \ $(INCDIR)/elf/reloc-macros.h elf32-target.h +elfxx-mips.lo: elfxx-mips.c $(INCDIR)/filenames.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h elfxx-mips.h $(INCDIR)/elf/mips.h \ + $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \ + $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h elf32-mips.lo: elf32-mips.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ genlink.h elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ - $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h \ - $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \ - $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h \ - ecoffswap.h elf32-target.h + $(INCDIR)/elf/external.h elfxx-mips.h $(INCDIR)/elf/mips.h \ + $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \ + $(INCDIR)/coff/internal.h $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h \ + $(INCDIR)/coff/external.h ecoffswap.h elf32-target.h elf32-openrisc.lo: elf32-openrisc.c $(INCDIR)/filenames.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/openrisc.h \ @@ -1688,6 +1750,10 @@ elf32-sh64.lo: elf32-sh64.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/bfdlink.h $(srcdir)/../opcodes/sh64-opc.h \ elf32-sh.c $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h \ elf32-target.h +elf32-sh64-com.lo: elf32-sh64-com.c $(INCDIR)/filenames.h \ + elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ + $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/sh.h \ + $(INCDIR)/elf/reloc-macros.h $(srcdir)/../opcodes/sh64-opc.h elf32-s390.lo: elf32-s390.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/elf/s390.h $(INCDIR)/elf/reloc-macros.h \ @@ -1704,6 +1770,11 @@ elf32-sh-nbsd.lo: elf32-sh-nbsd.c elf32-sh.c $(INCDIR)/filenames.h \ $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/sh.h \ $(INCDIR)/elf/reloc-macros.h elf32-target.h +elf32-sh64-nbsd.lo: elf32-sh64-nbsd.c elf32-sh64.c \ + $(INCDIR)/filenames.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + $(srcdir)/../opcodes/sh64-opc.h elf32-sh.c $(INCDIR)/elf/sh.h \ + $(INCDIR)/elf/reloc-macros.h elf32-target.h elf32-sparc.lo: elf32-sparc.c $(INCDIR)/filenames.h \ $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/sparc.h \ @@ -1713,6 +1784,10 @@ elf32-v850.lo: elf32-v850.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/elf/v850.h $(INCDIR)/elf/reloc-macros.h \ $(INCDIR)/libiberty.h elf32-target.h +elf32-vax.lo: elf32-vax.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ + elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ + $(INCDIR)/elf/external.h $(INCDIR)/elf/vax.h $(INCDIR)/elf/reloc-macros.h \ + elf32-target.h elf32-xstormy16.lo: elf32-xstormy16.c $(INCDIR)/filenames.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/xstormy16.h \ @@ -1727,7 +1802,7 @@ elflink.lo: elflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ $(INCDIR)/elf/external.h elf-strtab.lo: elf-strtab.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ - $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h + $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h $(INCDIR)/libiberty.h elf-eh-frame.lo: elf-eh-frame.c $(INCDIR)/filenames.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/dwarf2.h @@ -1897,6 +1972,12 @@ sunos.lo: sunos.c $(INCDIR)/bfdlink.h libaout.h aoutf1.h \ vaxnetbsd.lo: vaxnetbsd.c netbsd.h $(INCDIR)/filenames.h \ libaout.h $(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h +vax1knetbsd.lo: vax1knetbsd.c netbsd.h $(INCDIR)/filenames.h \ + libaout.h $(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \ + $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h +vaxbsd.lo: vaxbsd.c $(INCDIR)/filenames.h libaout.h \ + $(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/aout64.h \ + $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h versados.lo: versados.c $(INCDIR)/filenames.h $(INCDIR)/libiberty.h vms.lo: vms.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ vms.h @@ -1911,6 +1992,7 @@ vms-tir.lo: vms-tir.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ xcofflink.lo: xcofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/xcoff.h libcoff.h \ libxcoff.h +aix5ppc-core.lo: aix5ppc-core.c aout64.lo: aout64.c aoutx.h $(INCDIR)/filenames.h $(INCDIR)/safe-ctype.h \ $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h @@ -1931,8 +2013,8 @@ efi-app-ia64.lo: efi-app-ia64.c $(INCDIR)/filenames.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \ $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.h elf64-x86-64.lo: elf64-x86-64.c $(INCDIR)/filenames.h \ - elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ - $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/x86-64.h \ + $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/x86-64.h \ $(INCDIR)/elf/reloc-macros.h elf64-target.h elf64-alpha.lo: elf64-alpha.c $(INCDIR)/filenames.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ @@ -1941,6 +2023,13 @@ elf64-alpha.lo: elf64-alpha.c $(INCDIR)/filenames.h \ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h libcoff.h \ libecoff.h ecoffswap.h elf64-target.h +elf64-alpha-fbsd.lo: elf64-alpha-fbsd.c elf64-alpha.c $(INCDIR)/filenames.h \ + elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ + $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/alpha.h \ + $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/internal.h \ + $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \ + $(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h libcoff.h \ + libecoff.h ecoffswap.h elf64-target.h elf64-hppa.lo: elf64-hppa.c $(INCDIR)/alloca-conf.h \ $(INCDIR)/filenames.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ @@ -1951,10 +2040,11 @@ elf64-gen.lo: elf64-gen.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/bfdlink.h elf64-target.h elf64-mips.lo: elf64-mips.c $(INCDIR)/filenames.h $(INCDIR)/aout/ar.h \ $(INCDIR)/bfdlink.h genlink.h elf-bfd.h $(INCDIR)/elf/common.h \ - $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h \ - $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \ - $(INCDIR)/coff/internal.h $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h \ - ecoffswap.h elf64-target.h + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elfxx-mips.h \ + $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h \ + $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \ + $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h ecoffswap.h \ + elf64-target.h elf64-mmix.lo: elf64-mmix.c $(INCDIR)/filenames.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(INCDIR)/elf/mmix.h $(INCDIR)/elf/reloc-macros.h \ @@ -1971,6 +2061,10 @@ elf64-sh64.lo: elf64-sh64.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h \ elf64-target.h +elf64-sh64-nbsd.lo: elf64-sh64-nbsd.c elf64-sh64.c \ + $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h elf64-target.h elf64-sparc.lo: elf64-sparc.c $(INCDIR)/filenames.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/opcode/sparc.h \ diff --git a/contrib/binutils/bfd/acinclude.m4 b/contrib/binutils/bfd/acinclude.m4 index 5391294..b3c6ccff 100644 --- a/contrib/binutils/bfd/acinclude.m4 +++ b/contrib/binutils/bfd/acinclude.m4 @@ -123,3 +123,27 @@ ifelse(yes,no,[ AC_DEFUN([CY_WITH_NLS],) AC_SUBST(INTLLIBS) ]) + +AC_DEFUN([AM_INSTALL_LIBBFD], +[AC_MSG_CHECKING([whether to install libbfd]) + AC_ARG_ENABLE(install-libbfd, +[ --install-libbfd controls installation of libbfd and related headers], + install_libbfd_p=$enableval, + if test "${host}" = "${target}" -o "$enable_shared" = "yes"; then + install_libbfd_p=yes + else + install_libbfd_p=no + fi) + AC_MSG_RESULT($install_libbfd_p) + AM_CONDITIONAL(INSTALL_LIBBFD, test $install_libbfd_p = yes) + # libbfd.a is a host library containing target dependent code + bfdlibdir='$(libdir)' + bfdincludedir='$(includedir)' + if test "${host}" != "${target}"; then + bfdlibdir='$(exec_prefix)/$(host_alias)/$(target_alias)/lib' + bfdincludedir='$(exec_prefix)/$(host_alias)/$(target_alias)/include' + fi + AC_SUBST(bfdlibdir) + AC_SUBST(bfdincludedir) +] +) diff --git a/contrib/binutils/bfd/aclocal.m4 b/contrib/binutils/bfd/aclocal.m4 index 4446fc1..b6dfcbe 100644 --- a/contrib/binutils/bfd/aclocal.m4 +++ b/contrib/binutils/bfd/aclocal.m4 @@ -136,6 +136,43 @@ AC_DEFUN([CY_WITH_NLS],) AC_SUBST(INTLLIBS) ]) +AC_DEFUN([AM_INSTALL_LIBBFD], +[AC_MSG_CHECKING([whether to install libbfd]) + AC_ARG_ENABLE(install-libbfd, +[ --install-libbfd controls installation of libbfd and related headers], + install_libbfd_p=$enableval, + if test "${host}" = "${target}" -o "$enable_shared" = "yes"; then + install_libbfd_p=yes + else + install_libbfd_p=no + fi) + AC_MSG_RESULT($install_libbfd_p) + AM_CONDITIONAL(INSTALL_LIBBFD, test $install_libbfd_p = yes) + # libbfd.a is a host library containing target dependent code + bfdlibdir='$(libdir)' + bfdincludedir='$(includedir)' + if test "${host}" != "${target}"; then + bfdlibdir='$(exec_prefix)/$(host_alias)/$(target_alias)/lib' + bfdincludedir='$(exec_prefix)/$(host_alias)/$(target_alias)/include' + fi + AC_SUBST(bfdlibdir) + AC_SUBST(bfdincludedir) +] +) + +# Define a conditional. + +AC_DEFUN([AM_CONDITIONAL], +[AC_SUBST($1_TRUE) +AC_SUBST($1_FALSE) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi]) + # Do all the work for Automake. This macro actually does too much -- # some checks are only needed if your package does certain things. # But this isn't really a big deal. @@ -271,16 +308,3 @@ AC_DEFUN([AM_MAINTAINER_MODE], ] ) -# Define a conditional. - -AC_DEFUN([AM_CONDITIONAL], -[AC_SUBST($1_TRUE) -AC_SUBST($1_FALSE) -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi]) - diff --git a/contrib/binutils/bfd/aout-target.h b/contrib/binutils/bfd/aout-target.h index ccedb93..b2acc09 100644 --- a/contrib/binutils/bfd/aout-target.h +++ b/contrib/binutils/bfd/aout-target.h @@ -1,6 +1,6 @@ /* Define a target vector and some small routines for a variant of a.out. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001 + 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -207,7 +207,7 @@ static boolean MY(mkobject) (abfd) bfd *abfd; { - if (NAME(aout,mkobject) (abfd) == false) + if (! NAME(aout,mkobject) (abfd)) return false; #if 0 /* Sizes get set in set_sizes callback, later, after we know the architecture and machine. */ @@ -513,6 +513,9 @@ MY_bfd_final_link (abfd, info) #ifndef MY_bfd_merge_sections #define MY_bfd_merge_sections bfd_generic_merge_sections #endif +#ifndef MY_bfd_discard_group +#define MY_bfd_discard_group bfd_generic_discard_group +#endif #ifndef MY_bfd_reloc_type_lookup #define MY_bfd_reloc_type_lookup NAME(aout,reloc_type_lookup) #endif @@ -528,9 +531,15 @@ MY_bfd_final_link (abfd, info) #ifndef MY_bfd_link_hash_table_create #define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create) #endif +#ifndef MY_bfd_link_hash_table_free +#define MY_bfd_link_hash_table_free _bfd_generic_link_hash_table_free +#endif #ifndef MY_bfd_link_add_symbols #define MY_bfd_link_add_symbols NAME(aout,link_add_symbols) #endif +#ifndef MY_bfd_link_just_syms +#define MY_bfd_link_just_syms _bfd_generic_link_just_syms +#endif #ifndef MY_bfd_link_split_section #define MY_bfd_link_split_section _bfd_generic_link_split_section #endif diff --git a/contrib/binutils/bfd/aoutf1.h b/contrib/binutils/bfd/aoutf1.h index 0f773a1..80d69d9 100644 --- a/contrib/binutils/bfd/aoutf1.h +++ b/contrib/binutils/bfd/aoutf1.h @@ -748,7 +748,7 @@ sunos4_core_file_matches_executable_p (core_bfd, exec_bfd) return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr), (char *) exec_hdr (exec_bfd), - sizeof (struct internal_exec)) == 0) ? true : false; + sizeof (struct internal_exec)) == 0); } #define MY_set_sizes sunos4_set_sizes diff --git a/contrib/binutils/bfd/aoutx.h b/contrib/binutils/bfd/aoutx.h index 3c9cd4f..83e9732 100644 --- a/contrib/binutils/bfd/aoutx.h +++ b/contrib/binutils/bfd/aoutx.h @@ -533,7 +533,7 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p) obj_aout_sym_hashes (abfd) = NULL; if (! NAME(aout,make_sections) (abfd)) - return NULL; + goto error_ret; obj_datasec (abfd)->_raw_size = execp->a_data; obj_bsssec (abfd)->_raw_size = execp->a_bss; @@ -655,13 +655,13 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p) obj_textsec (abfd)->next = obj_datasec (abfd); obj_datasec (abfd)->next = obj_bsssec (abfd); #endif + return result; } - else - { - free (rawptr); - abfd->tdata.aout_data = oldrawptr; - } - return result; + + error_ret: + bfd_release (abfd, rawptr); + abfd->tdata.aout_data = oldrawptr; + return NULL; } /* @@ -1310,9 +1310,9 @@ aout_get_external_symbols (abfd) count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE; #ifdef USE_MMAP - if (bfd_get_file_window (abfd, - obj_sym_filepos (abfd), exec_hdr (abfd)->a_syms, - &obj_aout_sym_window (abfd), true) == false) + if (! bfd_get_file_window (abfd, obj_sym_filepos (abfd), + exec_hdr (abfd)->a_syms, + &obj_aout_sym_window (abfd), true)) return false; syms = (struct external_nlist *) obj_aout_sym_window (abfd).data; #else @@ -1352,8 +1352,8 @@ aout_get_external_symbols (abfd) stringsize = GET_WORD (abfd, string_chars); #ifdef USE_MMAP - if (bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize, - &obj_aout_string_window (abfd), true) == false) + if (! bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize, + &obj_aout_string_window (abfd), true)) return false; strings = (char *) obj_aout_string_window (abfd).data; #else @@ -1837,11 +1837,9 @@ NAME(aout,slurp_symbol_table) (abfd) cached_size = obj_aout_external_sym_count (abfd); cached_size *= sizeof (aout_symbol_type); - cached = (aout_symbol_type *) bfd_malloc (cached_size); + cached = (aout_symbol_type *) bfd_zmalloc (cached_size); if (cached == NULL && cached_size != 0) return false; - if (cached_size != 0) - memset (cached, 0, (size_t) cached_size); /* Convert from external symbol information to internal. */ if (! (NAME(aout,translate_symbol_table) @@ -2411,10 +2409,9 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols) count = reloc_size / each_size; amt = count * sizeof (arelent); - reloc_cache = (arelent *) bfd_malloc (amt); + reloc_cache = (arelent *) bfd_zmalloc (amt); if (reloc_cache == NULL && count != 0) return false; - memset (reloc_cache, 0, (size_t) amt); relocs = bfd_malloc (reloc_size); if (relocs == NULL && reloc_size != 0) @@ -4189,7 +4186,8 @@ aout_link_write_symbols (finfo, input_bfd) /* Use the name from the hash table, in case the symbol was wrapped. */ - if (h != NULL) + if (h != NULL + && h->root.type != bfd_link_hash_warning) name = h->root.root.string; /* If this is an indirect or warning symbol, then change @@ -4211,7 +4209,6 @@ aout_link_write_symbols (finfo, input_bfd) /* If the symbol has already been written out, skip it. */ if (h != (struct aout_link_hash_entry *) NULL - && h->root.type != bfd_link_hash_warning && h->written) { if ((type & N_TYPE) == N_INDR diff --git a/contrib/binutils/bfd/archive.c b/contrib/binutils/bfd/archive.c index e9e07c5..d7ac214 100644 --- a/contrib/binutils/bfd/archive.c +++ b/contrib/binutils/bfd/archive.c @@ -603,8 +603,6 @@ bfd_generic_archive_p (abfd) char armag[SARMAG + 1]; bfd_size_type amt; - tdata_hold = abfd->tdata.aout_ar_data; - if (bfd_bread ((PTR) armag, (bfd_size_type) SARMAG, abfd) != SARMAG) { if (bfd_get_error () != bfd_error_system_call) @@ -621,13 +619,15 @@ bfd_generic_archive_p (abfd) return 0; #endif - /* We are setting bfd_ardata(abfd) here, but since bfd_ardata - involves a cast, we can't do it as the left operand of assignment. */ - amt = sizeof (struct artdata); - abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt); + tdata_hold = bfd_ardata (abfd); + amt = sizeof (struct artdata); + bfd_ardata (abfd) = (struct artdata *) bfd_zalloc (abfd, amt); if (bfd_ardata (abfd) == NULL) - return NULL; + { + bfd_ardata (abfd) = tdata_hold; + return NULL; + } bfd_ardata (abfd)->first_file_filepos = SARMAG; bfd_ardata (abfd)->cache = NULL; @@ -636,21 +636,13 @@ bfd_generic_archive_p (abfd) bfd_ardata (abfd)->extended_names = NULL; bfd_ardata (abfd)->tdata = NULL; - if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd))) + if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd)) + || !BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd))) { - bfd_release (abfd, bfd_ardata (abfd)); - abfd->tdata.aout_ar_data = tdata_hold; if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); - return NULL; - } - - if (!BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd))) - { bfd_release (abfd, bfd_ardata (abfd)); - abfd->tdata.aout_ar_data = tdata_hold; - if (bfd_get_error () != bfd_error_system_call) - bfd_set_error (bfd_error_wrong_format); + bfd_ardata (abfd) = tdata_hold; return NULL; } @@ -686,9 +678,9 @@ bfd_generic_archive_p (abfd) release bfd_ardata. FIXME. */ (void) bfd_close (first); bfd_release (abfd, bfd_ardata (abfd)); - abfd->tdata.aout_ar_data = tdata_hold; #endif bfd_set_error (bfd_error_wrong_object_format); + bfd_ardata (abfd) = tdata_hold; return NULL; } /* And we ought to close `first' here too. */ @@ -1746,7 +1738,7 @@ _bfd_write_archive_contents (arch) if (makemap && hasobjects) { - if (_bfd_compute_and_write_armap (arch, (unsigned int) elength) != true) + if (! _bfd_compute_and_write_armap (arch, (unsigned int) elength)) return false; } @@ -1876,8 +1868,8 @@ _bfd_compute_and_write_armap (arch, elength) current != (bfd *) NULL; current = current->next, elt_no++) { - if ((bfd_check_format (current, bfd_object) == true) - && ((bfd_get_file_flags (current) & HAS_SYMS))) + if (bfd_check_format (current, bfd_object) + && (bfd_get_file_flags (current) & HAS_SYMS) != 0) { long storage; long symcount; diff --git a/contrib/binutils/bfd/archures.c b/contrib/binutils/bfd/archures.c index 40102e8..063e4fb 100644 --- a/contrib/binutils/bfd/archures.c +++ b/contrib/binutils/bfd/archures.c @@ -193,6 +193,7 @@ DESCRIPTION .#define bfd_mach_d10v_ts2 2 .#define bfd_mach_d10v_ts3 3 . bfd_arch_d30v, {* Mitsubishi D30V *} +. bfd_arch_dlx, {* DLX *} . bfd_arch_m68hc11, {* Motorola 68HC11 *} . bfd_arch_m68hc12, {* Motorola 68HC12 *} . bfd_arch_z8k, {* Zilog Z8000 *} @@ -246,6 +247,13 @@ DESCRIPTION .#define bfd_mach_am33 330 . bfd_arch_fr30, .#define bfd_mach_fr30 0x46523330 +. bfd_arch_frv, +.#define bfd_mach_frv 0 +.#define bfd_mach_frvsimple 1 +.#define bfd_mach_fr300 300 +.#define bfd_mach_fr400 400 +.#define bfd_mach_frvtomcat 499 {* fr500 prototype *} +.#define bfd_mach_fr500 500 . bfd_arch_mcore, . bfd_arch_ia64, {* HP/Intel ia64 *} .#define bfd_mach_ia64_elf64 0 @@ -312,7 +320,9 @@ extern const bfd_arch_info_type bfd_avr_arch; extern const bfd_arch_info_type bfd_cris_arch; extern const bfd_arch_info_type bfd_d10v_arch; extern const bfd_arch_info_type bfd_d30v_arch; +extern const bfd_arch_info_type bfd_dlx_arch; extern const bfd_arch_info_type bfd_fr30_arch; +extern const bfd_arch_info_type bfd_frv_arch; extern const bfd_arch_info_type bfd_h8300_arch; extern const bfd_arch_info_type bfd_h8500_arch; extern const bfd_arch_info_type bfd_hppa_arch; @@ -365,7 +375,9 @@ static const bfd_arch_info_type * const bfd_archures_list[] = &bfd_cris_arch, &bfd_d10v_arch, &bfd_d30v_arch, + &bfd_dlx_arch, &bfd_fr30_arch, + &bfd_frv_arch, &bfd_h8300_arch, &bfd_h8500_arch, &bfd_hppa_arch, diff --git a/contrib/binutils/bfd/armnetbsd.c b/contrib/binutils/bfd/armnetbsd.c index e899adb..d82e98f 100644 --- a/contrib/binutils/bfd/armnetbsd.c +++ b/contrib/binutils/bfd/armnetbsd.c @@ -1,5 +1,5 @@ /* BFD back-end for NetBSD/ARM a.out-ish binaries. - Copyright 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -44,7 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" /* To ensure following declaration is OK */ -CONST struct reloc_howto_struct * +const struct reloc_howto_struct * MY_bfd_reloc_type_lookup PARAMS ((bfd * abfd AND bfd_reloc_code_real_type code)); diff --git a/contrib/binutils/bfd/bfd-in.h b/contrib/binutils/bfd/bfd-in.h index bd8a915..807a440 100644 --- a/contrib/binutils/bfd/bfd-in.h +++ b/contrib/binutils/bfd/bfd-in.h @@ -4,21 +4,21 @@ Free Software Foundation, Inc. Contributed by Cygnus Support. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __BFD_H_SEEN__ #define __BFD_H_SEEN__ @@ -328,12 +328,13 @@ alent; /* Object and core file sections. */ #define align_power(addr, align) \ - ( ((addr) + ((1<<(align))-1)) & (-1 << (align))) + (((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align))) typedef struct sec *sec_ptr; #define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0) #define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0) +#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0) #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0) #define bfd_section_name(bfd, ptr) ((ptr)->name) #define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr)) @@ -345,7 +346,7 @@ typedef struct sec *sec_ptr; #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0) -#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true) +#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = (boolean)true), true) #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true) #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true) @@ -525,6 +526,8 @@ extern void warn_deprecated #define bfd_get_outsymbols(abfd) ((abfd)->outsymbols) #define bfd_count_sections(abfd) ((abfd)->section_count) +#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount) + #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char) #define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean) (bool)), true) @@ -745,9 +748,12 @@ extern boolean bfd_xcoff_record_link_assignment extern boolean bfd_xcoff_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *, unsigned long, unsigned long, unsigned long, boolean, - int, boolean, boolean, struct sec **)); + int, boolean, boolean, struct sec **, boolean)); extern boolean bfd_xcoff_link_generate_rtinit - PARAMS ((bfd *, const char *, const char *)); + PARAMS ((bfd *, const char *, const char *, boolean)); + +/* XCOFF support routines for ar. */ +extern boolean bfd_xcoff_ar_archive_set_magic PARAMS ((bfd *, char *)); /* Externally visible COFF routines. */ @@ -799,6 +805,9 @@ extern boolean bfd_elf32_arm_process_before_allocation extern boolean bfd_elf32_arm_get_bfd_for_interworking PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean bfd_elf32_arm_add_glue_sections_to_bfd + PARAMS ((bfd *, struct bfd_link_info *)); + /* TI COFF load page support. */ extern void bfd_ticoff_set_section_load_page PARAMS ((struct sec *, int)); @@ -806,4 +815,3 @@ extern void bfd_ticoff_set_section_load_page extern int bfd_ticoff_get_section_load_page PARAMS ((struct sec *)); -/* And more from the source. */ diff --git a/contrib/binutils/bfd/bfd-in2.h b/contrib/binutils/bfd/bfd-in2.h index a69b375..bad4281 100644 --- a/contrib/binutils/bfd/bfd-in2.h +++ b/contrib/binutils/bfd/bfd-in2.h @@ -10,21 +10,21 @@ Free Software Foundation, Inc. Contributed by Cygnus Support. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __BFD_H_SEEN__ #define __BFD_H_SEEN__ @@ -334,12 +334,13 @@ alent; /* Object and core file sections. */ #define align_power(addr, align) \ - ( ((addr) + ((1<<(align))-1)) & (-1 << (align))) + (((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align))) typedef struct sec *sec_ptr; #define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0) #define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0) +#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0) #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0) #define bfd_section_name(bfd, ptr) ((ptr)->name) #define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr)) @@ -351,7 +352,7 @@ typedef struct sec *sec_ptr; #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0) -#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true) +#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = (boolean)true), true) #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true) #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true) @@ -531,6 +532,8 @@ extern void warn_deprecated #define bfd_get_outsymbols(abfd) ((abfd)->outsymbols) #define bfd_count_sections(abfd) ((abfd)->section_count) +#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount) + #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char) #define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean) (bool)), true) @@ -751,9 +754,12 @@ extern boolean bfd_xcoff_record_link_assignment extern boolean bfd_xcoff_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *, unsigned long, unsigned long, unsigned long, boolean, - int, boolean, boolean, struct sec **)); + int, boolean, boolean, struct sec **, boolean)); extern boolean bfd_xcoff_link_generate_rtinit - PARAMS ((bfd *, const char *, const char *)); + PARAMS ((bfd *, const char *, const char *, boolean)); + +/* XCOFF support routines for ar. */ +extern boolean bfd_xcoff_ar_archive_set_magic PARAMS ((bfd *, char *)); /* Externally visible COFF routines. */ @@ -805,6 +811,9 @@ extern boolean bfd_elf32_arm_process_before_allocation extern boolean bfd_elf32_arm_get_bfd_for_interworking PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean bfd_elf32_arm_add_glue_sections_to_bfd + PARAMS ((bfd *, struct bfd_link_info *)); + /* TI COFF load page support. */ extern void bfd_ticoff_set_section_load_page PARAMS ((struct sec *, int)); @@ -812,10 +821,11 @@ extern void bfd_ticoff_set_section_load_page extern int bfd_ticoff_get_section_load_page PARAMS ((struct sec *)); -/* And more from the source. */ +/* Extracted from init.c. */ void bfd_init PARAMS ((void)); +/* Extracted from opncls.c. */ bfd * bfd_openr PARAMS ((const char *filename, const char *target)); @@ -843,6 +853,7 @@ bfd_make_writable PARAMS ((bfd *abfd)); boolean bfd_make_readable PARAMS ((bfd *abfd)); +/* Extracted from libbfd.c. */ /* Byte swapping macros for user section data. */ @@ -983,6 +994,7 @@ bfd_make_readable PARAMS ((bfd *abfd)); #define H_GET_S8 bfd_h_get_signed_8 +/* Extracted from section.c. */ /* This structure is used for a comdat section, as in PE. A comdat section is associated with a particular symbol. When the linker sees a comdat section, it keeps only one of the sections with a @@ -1064,12 +1076,6 @@ typedef struct sec standard data. */ #define SEC_CONSTRUCTOR 0x100 - /* The section is a constructor, and should be placed at the - end of the text, data, or bss section(?). */ -#define SEC_CONSTRUCTOR_TEXT 0x1100 -#define SEC_CONSTRUCTOR_DATA 0x2100 -#define SEC_CONSTRUCTOR_BSS 0x3100 - /* The section has contents - a data section could be <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be <<SEC_HAS_CONTENTS>> */ @@ -1090,6 +1096,9 @@ typedef struct sec sections. */ #define SEC_COFF_SHARED_LIBRARY 0x800 + /* The section contains thread local data. */ +#define SEC_THREAD_LOCAL 0x1000 + /* The section has GOT references. This flag is only for the linker, and is currently only used by the elf32-hppa back end. It will be set if global offset table references were detected @@ -1446,6 +1455,10 @@ bfd_copy_private_section_data PARAMS ((bfd *ibfd, asection *isec, void _bfd_strip_section_from_output PARAMS ((struct bfd_link_info *info, asection *section)); +boolean +bfd_generic_discard_group PARAMS ((bfd *abfd, asection *group)); + +/* Extracted from archures.c. */ enum bfd_architecture { bfd_arch_unknown, /* File arch not known. */ @@ -1572,6 +1585,7 @@ enum bfd_architecture #define bfd_mach_d10v_ts2 2 #define bfd_mach_d10v_ts3 3 bfd_arch_d30v, /* Mitsubishi D30V */ + bfd_arch_dlx, /* DLX */ bfd_arch_m68hc11, /* Motorola 68HC11 */ bfd_arch_m68hc12, /* Motorola 68HC12 */ bfd_arch_z8k, /* Zilog Z8000 */ @@ -1625,6 +1639,13 @@ enum bfd_architecture #define bfd_mach_am33 330 bfd_arch_fr30, #define bfd_mach_fr30 0x46523330 + bfd_arch_frv, +#define bfd_mach_frv 0 +#define bfd_mach_frvsimple 1 +#define bfd_mach_fr300 300 +#define bfd_mach_fr400 400 +#define bfd_mach_frvtomcat 499 /* fr500 prototype */ +#define bfd_mach_fr500 500 bfd_arch_mcore, bfd_arch_ia64, /* HP/Intel ia64 */ #define bfd_mach_ia64_elf64 0 @@ -1718,6 +1739,7 @@ unsigned int bfd_arch_mach_octets_per_byte PARAMS ((enum bfd_architecture arch, unsigned long machine)); +/* Extracted from reloc.c. */ typedef enum bfd_reloc_status { /* No errors detected. */ @@ -2143,6 +2165,21 @@ share a common GP, and the target address is adjusted for STO_ALPHA_STD_GPLOAD. */ BFD_RELOC_ALPHA_BRSGP, +/* Alpha thread-local storage relocations. */ + BFD_RELOC_ALPHA_TLSGD, + BFD_RELOC_ALPHA_TLSLDM, + BFD_RELOC_ALPHA_DTPMOD64, + BFD_RELOC_ALPHA_GOTDTPREL16, + BFD_RELOC_ALPHA_DTPREL64, + BFD_RELOC_ALPHA_DTPREL_HI16, + BFD_RELOC_ALPHA_DTPREL_LO16, + BFD_RELOC_ALPHA_DTPREL16, + BFD_RELOC_ALPHA_GOTTPREL16, + BFD_RELOC_ALPHA_TPREL64, + BFD_RELOC_ALPHA_TPREL_HI16, + BFD_RELOC_ALPHA_TPREL_LO16, + BFD_RELOC_ALPHA_TPREL16, + /* Bits 27..2 of the relocation address shifted right 2 bits; simple reloc otherwise. */ BFD_RELOC_MIPS_JMP, @@ -2197,6 +2234,17 @@ to compensate for the borrow when the low bits are added. */ BFD_RELOC_MIPS_RELGOT, BFD_RELOC_MIPS_JALR, +/* Fujitsu Frv Relocations. */ + BFD_RELOC_FRV_LABEL16, + BFD_RELOC_FRV_LABEL24, + BFD_RELOC_FRV_LO16, + BFD_RELOC_FRV_HI16, + BFD_RELOC_FRV_GPREL12, + BFD_RELOC_FRV_GPRELU12, + BFD_RELOC_FRV_GPREL32, + BFD_RELOC_FRV_GPRELHI, + BFD_RELOC_FRV_GPRELLO, + /* i386/elf relocations */ BFD_RELOC_386_GOT32, @@ -2207,6 +2255,18 @@ to compensate for the borrow when the low bits are added. */ BFD_RELOC_386_RELATIVE, BFD_RELOC_386_GOTOFF, BFD_RELOC_386_GOTPC, + BFD_RELOC_386_TLS_TPOFF, + BFD_RELOC_386_TLS_IE, + BFD_RELOC_386_TLS_GOTIE, + BFD_RELOC_386_TLS_LE, + BFD_RELOC_386_TLS_GD, + BFD_RELOC_386_TLS_LDM, + BFD_RELOC_386_TLS_LDO_32, + BFD_RELOC_386_TLS_IE_32, + BFD_RELOC_386_TLS_LE_32, + BFD_RELOC_386_TLS_DTPMOD32, + BFD_RELOC_386_TLS_DTPOFF32, + BFD_RELOC_386_TLS_TPOFF32, /* x86-64/elf relocations */ BFD_RELOC_X86_64_GOT32, @@ -2511,6 +2571,15 @@ of the container. */ /* This is a 32-bit pc-relative reloc. */ BFD_RELOC_D30V_32_PCREL, +/* DLX relocs */ + BFD_RELOC_DLX_HI16_S, + +/* DLX relocs */ + BFD_RELOC_DLX_LO16, + +/* DLX relocs */ + BFD_RELOC_DLX_JMP26, + /* Mitsubishi M32R relocs. This is a 24 bit absolute address. */ BFD_RELOC_M32R_24, @@ -2918,12 +2987,25 @@ this offset in the reloc's section offset. */ BFD_RELOC_IA64_IPLTMSB, BFD_RELOC_IA64_IPLTLSB, BFD_RELOC_IA64_COPY, + BFD_RELOC_IA64_LTOFF22X, + BFD_RELOC_IA64_LDXMOV, + BFD_RELOC_IA64_TPREL14, BFD_RELOC_IA64_TPREL22, + BFD_RELOC_IA64_TPREL64I, BFD_RELOC_IA64_TPREL64MSB, BFD_RELOC_IA64_TPREL64LSB, - BFD_RELOC_IA64_LTOFF_TP22, - BFD_RELOC_IA64_LTOFF22X, - BFD_RELOC_IA64_LDXMOV, + BFD_RELOC_IA64_LTOFF_TPREL22, + BFD_RELOC_IA64_DTPMOD64MSB, + BFD_RELOC_IA64_DTPMOD64LSB, + BFD_RELOC_IA64_LTOFF_DTPMOD22, + BFD_RELOC_IA64_DTPREL14, + BFD_RELOC_IA64_DTPREL22, + BFD_RELOC_IA64_DTPREL64I, + BFD_RELOC_IA64_DTPREL32MSB, + BFD_RELOC_IA64_DTPREL32LSB, + BFD_RELOC_IA64_DTPREL64MSB, + BFD_RELOC_IA64_DTPREL64LSB, + BFD_RELOC_IA64_LTOFF_DTPREL22, /* Motorola 68HC11 reloc. This is the 8 bits high part of an absolute address. */ @@ -3021,6 +3103,11 @@ This is the 3 bits of a value. */ BFD_RELOC_XSTORMY16_REL_12, BFD_RELOC_XSTORMY16_24, BFD_RELOC_XSTORMY16_FPTR16, + +/* Relocations used by VAX ELF. */ + BFD_RELOC_VAX_GLOB_DAT, + BFD_RELOC_VAX_JMP_SLOT, + BFD_RELOC_VAX_RELATIVE, BFD_RELOC_UNUSED }; typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; reloc_howto_type * @@ -3029,6 +3116,7 @@ bfd_reloc_type_lookup PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); const char * bfd_get_reloc_code_name PARAMS ((bfd_reloc_code_real_type code)); +/* Extracted from syms.c. */ typedef struct symbol_cache_entry { @@ -3134,6 +3222,9 @@ typedef struct symbol_cache_entry as well. */ #define BSF_DEBUGGING_RELOC 0x20000 + /* This symbol is thread local. Used in ELF. */ +#define BSF_THREAD_LOCAL 0x40000 + flagword flags; /* A pointer to the section to which this symbol is @@ -3198,6 +3289,7 @@ bfd_copy_private_symbol_data PARAMS ((bfd *ibfd, asymbol *isym, bfd *obfd, asymb BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ (ibfd, isymbol, obfd, osymbol)) +/* Extracted from bfd.c. */ struct _bfd { /* The filename the application opened the BFD with. */ @@ -3292,6 +3384,9 @@ struct _bfd /* Symbol table for output BFD (with symcount entries). */ struct symbol_cache_entry **outsymbols; + /* Used for slurped dynamic symbol tables. */ + unsigned int dynsymcount; + /* Pointer to structure which contains architecture information. */ const struct bfd_arch_info *arch_info; @@ -3497,12 +3592,21 @@ bfd_set_private_flags PARAMS ((bfd *abfd, flagword flags)); #define bfd_merge_sections(abfd, link_info) \ BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info)) +#define bfd_discard_group(abfd, sec) \ + BFD_SEND (abfd, _bfd_discard_group, (abfd, sec)) + #define bfd_link_hash_table_create(abfd) \ BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) +#define bfd_link_hash_table_free(abfd, hash) \ + BFD_SEND (abfd, _bfd_link_hash_table_free, (hash)) + #define bfd_link_add_symbols(abfd, info) \ BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) +#define bfd_link_just_syms(sec, info) \ + BFD_SEND (abfd, _bfd_link_just_syms, (sec, info)) + #define bfd_final_link(abfd, info) \ BFD_SEND (abfd, _bfd_final_link, (abfd, info)) @@ -3532,6 +3636,7 @@ extern bfd_byte *bfd_get_relocated_section_contents boolean bfd_alt_mach_code PARAMS ((bfd *abfd, int index)); +/* Extracted from archive.c. */ symindex bfd_get_next_mapent PARAMS ((bfd *abfd, symindex previous, carsym **sym)); @@ -3541,6 +3646,7 @@ bfd_set_archive_head PARAMS ((bfd *output, bfd *new_head)); bfd * bfd_openr_next_archived_file PARAMS ((bfd *archive, bfd *previous)); +/* Extracted from corefile.c. */ const char * bfd_core_file_failing_command PARAMS ((bfd *abfd)); @@ -3550,6 +3656,7 @@ bfd_core_file_failing_signal PARAMS ((bfd *abfd)); boolean core_file_matches_executable_p PARAMS ((bfd *core_bfd, bfd *exec_bfd)); +/* Extracted from targets.c. */ #define BFD_SEND(bfd, message, arglist) \ ((*((bfd)->xvec->message)) arglist) @@ -3825,11 +3932,14 @@ CONCAT2 (NAME,_sizeof_headers), \ CONCAT2 (NAME,_bfd_get_relocated_section_contents), \ CONCAT2 (NAME,_bfd_relax_section), \ CONCAT2 (NAME,_bfd_link_hash_table_create), \ +CONCAT2 (NAME,_bfd_link_hash_table_free), \ CONCAT2 (NAME,_bfd_link_add_symbols), \ +CONCAT2 (NAME,_bfd_link_just_syms), \ CONCAT2 (NAME,_bfd_final_link), \ CONCAT2 (NAME,_bfd_link_split_section), \ CONCAT2 (NAME,_bfd_gc_sections), \ -CONCAT2 (NAME,_bfd_merge_sections) +CONCAT2 (NAME,_bfd_merge_sections), \ +CONCAT2 (NAME,_bfd_discard_group) int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean)); bfd_byte *(*_bfd_get_relocated_section_contents) PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, @@ -3842,9 +3952,15 @@ CONCAT2 (NAME,_bfd_merge_sections) different information in this table. */ struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *)); + /* Release the memory associated with the linker hash table. */ + void (*_bfd_link_hash_table_free) PARAMS ((struct bfd_link_hash_table *)); + /* Add symbols from this object file into the hash table. */ boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *)); + /* Indicate that we are only retrieving symbol values from this section. */ + void (*_bfd_link_just_syms) PARAMS ((asection *, struct bfd_link_info *)); + /* Do a link based on the link_order structures attached to each section of the BFD. */ boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *)); @@ -3858,6 +3974,9 @@ CONCAT2 (NAME,_bfd_merge_sections) /* Attempt to merge SEC_MERGE sections. */ boolean (*_bfd_merge_sections) PARAMS ((bfd *, struct bfd_link_info *)); + /* Discard members of a group. */ + boolean (*_bfd_discard_group) PARAMS ((bfd *, struct sec *)); + /* Routines to handle dynamic symbols and relocs. */ #define BFD_JUMP_TABLE_DYNAMIC(NAME) \ CONCAT2 (NAME,_get_dynamic_symtab_upper_bound), \ @@ -3896,6 +4015,7 @@ bfd_target_list PARAMS ((void)); const bfd_target * bfd_search_for_target PARAMS ((int (* search_func) (const bfd_target *, void *), void *)); +/* Extracted from format.c. */ boolean bfd_check_format PARAMS ((bfd *abfd, bfd_format format)); diff --git a/contrib/binutils/bfd/bfd.c b/contrib/binutils/bfd/bfd.c index 73bb17e..cfd7772 100644 --- a/contrib/binutils/bfd/bfd.c +++ b/contrib/binutils/bfd/bfd.c @@ -128,6 +128,9 @@ CODE_FRAGMENT . {* Symbol table for output BFD (with symcount entries). *} . struct symbol_cache_entry **outsymbols; . +. {* Used for slurped dynamic symbol tables. *} +. unsigned int dynsymcount; +. . {* Pointer to structure which contains architecture information. *} . const struct bfd_arch_info *arch_info; . @@ -749,7 +752,6 @@ bfd_get_arch_size (abfd) if (abfd->xvec->flavour == bfd_target_elf_flavour) return (get_elf_backend_data (abfd))->s->arch_size; - bfd_set_error (bfd_error_wrong_format); return -1; } @@ -1008,7 +1010,8 @@ DESCRIPTION in hex if a leading "0x" or "0X" is found, otherwise in octal if a leading zero is found, otherwise in decimal. - Overflow is not detected. + If the value would overflow, the maximum <<bfd_vma>> value is + returned. */ bfd_vma @@ -1018,48 +1021,64 @@ bfd_scan_vma (string, end, base) int base; { bfd_vma value; - int digit; + bfd_vma cutoff; + unsigned int cutlim; + int overflow; /* Let the host do it if possible. */ if (sizeof (bfd_vma) <= sizeof (unsigned long)) return (bfd_vma) strtoul (string, (char **) end, base); - /* A negative base makes no sense, and we only need to go as high as hex. */ - if ((base < 0) || (base > 16)) - return (bfd_vma) 0; - if (base == 0) { if (string[0] == '0') { if ((string[1] == 'x') || (string[1] == 'X')) base = 16; - /* XXX should we also allow "0b" or "0B" to set base to 2? */ else base = 8; } - else - base = 10; } - if ((base == 16) && - (string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X'))) - string += 2; - /* XXX should we also skip over "0b" or "0B" if base is 2? */ + if ((base < 2) || (base > 36)) + base = 10; + + if (base == 16 + && string[0] == '0' + && (string[1] == 'x' || string[1] == 'X') + && ISXDIGIT (string[2])) + { + string += 2; + } + + cutoff = (~ (bfd_vma) 0) / (bfd_vma) base; + cutlim = (~ (bfd_vma) 0) % (bfd_vma) base; + value = 0; + overflow = 0; + while (1) + { + unsigned int digit; -/* Speed could be improved with a table like hex_value[] in gas. */ -#define HEX_VALUE(c) \ - (ISXDIGIT (c) \ - ? (ISDIGIT (c) \ - ? (c - '0') \ - : (10 + c - (ISLOWER (c) ? 'a' : 'A'))) \ - : 42) + digit = *string; + if (ISDIGIT (digit)) + digit = digit - '0'; + else if (ISALPHA (digit)) + digit = TOUPPER (digit) - 'A' + 10; + else + break; + if (digit >= (unsigned int) base) + break; + if (value > cutoff || (value == cutoff && digit > cutlim)) + overflow = 1; + value = value * base + digit; + ++string; + } - for (value = 0; (digit = HEX_VALUE (* string)) < base; string ++) - value = value * base + digit; + if (overflow) + value = ~ (bfd_vma) 0; - if (end) - * end = string; + if (end != NULL) + *end = string; return value; } @@ -1169,12 +1188,21 @@ DESCRIPTION .#define bfd_merge_sections(abfd, link_info) \ . BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info)) . +.#define bfd_discard_group(abfd, sec) \ +. BFD_SEND (abfd, _bfd_discard_group, (abfd, sec)) +. .#define bfd_link_hash_table_create(abfd) \ . BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) . +.#define bfd_link_hash_table_free(abfd, hash) \ +. BFD_SEND (abfd, _bfd_link_hash_table_free, (hash)) +. .#define bfd_link_add_symbols(abfd, info) \ . BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) . +.#define bfd_link_just_syms(sec, info) \ +. BFD_SEND (abfd, _bfd_link_just_syms, (sec, info)) +. .#define bfd_final_link(abfd, info) \ . BFD_SEND (abfd, _bfd_final_link, (abfd, info)) . @@ -1309,27 +1337,27 @@ FUNCTION bfd_alt_mach_code SYNOPSIS - boolean bfd_alt_mach_code(bfd *abfd, int index); + boolean bfd_alt_mach_code(bfd *abfd, int alternative); DESCRIPTION When more than one machine code number is available for the same machine type, this function can be used to switch between - the preferred one (index == 0) and any others. Currently, + the preferred one (alternative == 0) and any others. Currently, only ELF supports this feature, with up to two alternate machine codes. */ boolean -bfd_alt_mach_code (abfd, index) +bfd_alt_mach_code (abfd, alternative) bfd *abfd; - int index; + int alternative; { if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) { int code; - switch (index) + switch (alternative) { case 0: code = get_elf_backend_data (abfd)->elf_machine_code; diff --git a/contrib/binutils/bfd/binary.c b/contrib/binutils/bfd/binary.c index 705ac8f..fc972b2 100644 --- a/contrib/binutils/bfd/binary.c +++ b/contrib/binutils/bfd/binary.c @@ -1,5 +1,5 @@ /* BFD back-end for binary objects. - Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 + Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com> @@ -337,7 +337,10 @@ binary_sizeof_headers (abfd, exec) #define binary_bfd_relax_section bfd_generic_relax_section #define binary_bfd_gc_sections bfd_generic_gc_sections #define binary_bfd_merge_sections bfd_generic_merge_sections +#define binary_bfd_discard_group bfd_generic_discard_group #define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create +#define binary_bfd_link_hash_table_free _bfd_generic_link_hash_table_free +#define binary_bfd_link_just_syms _bfd_generic_link_just_syms #define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols #define binary_bfd_final_link _bfd_generic_final_link #define binary_bfd_link_split_section _bfd_generic_link_split_section diff --git a/contrib/binutils/bfd/cache.c b/contrib/binutils/bfd/cache.c index 4e5ef2e..df01a1f 100644 --- a/contrib/binutils/bfd/cache.c +++ b/contrib/binutils/bfd/cache.c @@ -1,5 +1,5 @@ /* BFD library -- caching of file descriptors. - Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001 + Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002 Free Software Foundation, Inc. Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com). @@ -277,7 +277,7 @@ bfd_open_file (abfd) break; case both_direction: case write_direction: - if (abfd->opened_once == true) + if (abfd->opened_once) { abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RUB); if (abfd->iostream == NULL) diff --git a/contrib/binutils/bfd/coff-alpha.c b/contrib/binutils/bfd/coff-alpha.c index 4056e2c..6d5ac17 100644 --- a/contrib/binutils/bfd/coff-alpha.c +++ b/contrib/binutils/bfd/coff-alpha.c @@ -1,5 +1,5 @@ /* BFD back-end for ALPHA Extended-Coff files. - Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Modified from coff-mips.c by Steve Chamberlain <sac@cygnus.com> and Ian Lance Taylor <ian@cygnus.com>. @@ -795,7 +795,7 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order, gp = _bfd_get_gp_value (abfd); if (gp == 0) { - if (relocateable != false) + if (relocateable) { asection *sec; bfd_vma lo; @@ -2356,6 +2356,7 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data = #define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections #define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections +#define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group const bfd_target ecoffalpha_little_vec = { diff --git a/contrib/binutils/bfd/coff-arm.c b/contrib/binutils/bfd/coff-arm.c index c92cbe6..5e7f907 100644 --- a/contrib/binutils/bfd/coff-arm.c +++ b/contrib/binutils/bfd/coff-arm.c @@ -947,14 +947,14 @@ coff_arm_link_hash_table_create (abfd) struct coff_arm_link_hash_table * ret; bfd_size_type amt = sizeof (struct coff_arm_link_hash_table); - ret = (struct coff_arm_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct coff_arm_link_hash_table *) bfd_malloc (amt); if (ret == (struct coff_arm_link_hash_table *) NULL) return NULL; if (! _bfd_coff_link_hash_table_init (& ret->root, abfd, _bfd_coff_link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return (struct bfd_link_hash_table *) NULL; } @@ -1701,21 +1701,23 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, || signed_check < reloc_signed_min) overflow = true; - /* For the BLX(1) instruction remove bit 0 of the adjusted offset. - Bit 0 can only be set if the upper insn is at a half-word boundary, - since the destination address, an ARM instruction, must always be - on a word boundary. The semantics of the BLX (1) instruction, - however, are that bit 0 in the offset must always be 0, and the - corresponding bit 1 in the target address will be set from bit - 1 of the source address. */ - if ((x & 0x18000000) == 0x08000000) - relocation &= ~0x2; - - /* Put the relocation into the correct bits. */ + /* Put the relocation into the correct bits. + For a BLX instruction, make sure that the relocation is rounded up + to a word boundary. This follows the semantics of the instruction + which specifies that bit 1 of the target address will come from bit + 1 of the base address. */ if (bfd_big_endian (input_bfd)) - relocation = (((relocation & 0xffe) >> 1) | ((relocation << 4) & 0x07ff0000)); + { + if ((x & 0x1800) == 0x0800 && (relocation & 0x02)) + relocation += 2; + relocation = (((relocation & 0xffe) >> 1) | ((relocation << 4) & 0x07ff0000)); + } else - relocation = (((relocation & 0xffe) << 15) | ((relocation >> 12) & 0x7ff)); + { + if ((x & 0x18000000) == 0x08000000 && (relocation & 0x02)) + relocation += 2; + relocation = (((relocation & 0xffe) << 15) | ((relocation >> 12) & 0x7ff)); + } /* Add the relocation to the correct bits of X. */ x = ((x & ~howto->dst_mask) | relocation); diff --git a/contrib/binutils/bfd/coff-i386.c b/contrib/binutils/bfd/coff-i386.c index 72c58a4..dbeaef1 100644 --- a/contrib/binutils/bfd/coff-i386.c +++ b/contrib/binutils/bfd/coff-i386.c @@ -1,6 +1,6 @@ /* BFD back-end for Intel 386 COFF files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001 + 2000, 2001, 2002 Free Software Foundation, Inc. Written by Cygnus Support. @@ -117,7 +117,7 @@ coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, When we link PE and non-PE object files together to generate a non-PE executable, we have to compensate it here. */ - if (howto->pc_relative == true && howto->pcrel_offset == true) + if (howto->pc_relative && howto->pcrel_offset) diff = -(1 << howto->size); else diff = -reloc_entry->addend; diff --git a/contrib/binutils/bfd/coff-ppc.c b/contrib/binutils/bfd/coff-ppc.c index f2bdfe5..4f8b15e 100644 --- a/contrib/binutils/bfd/coff-ppc.c +++ b/contrib/binutils/bfd/coff-ppc.c @@ -1,6 +1,6 @@ /* BFD back-end for PowerPC Microsoft Portable Executable files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001 + 2000, 2001, 2002 Free Software Foundation, Inc. Original version pieced together by Kim Knuttila (krk@cygnus.com) @@ -204,13 +204,13 @@ ppc_coff_link_hash_table_create (abfd) struct ppc_coff_link_hash_table *ret; bfd_size_type amt = sizeof (struct ppc_coff_link_hash_table); - ret = (struct ppc_coff_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct ppc_coff_link_hash_table *) bfd_malloc (amt); if (ret == NULL) return NULL; if (! ppc_coff_link_hash_table_init (ret, abfd, ppc_coff_link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return (struct bfd_link_hash_table *) NULL; } return &ret->root.root; diff --git a/contrib/binutils/bfd/coff-rs6000.c b/contrib/binutils/bfd/coff-rs6000.c index 46ac5c8..5a0b8aa 100644 --- a/contrib/binutils/bfd/coff-rs6000.c +++ b/contrib/binutils/bfd/coff-rs6000.c @@ -1,6 +1,5 @@ /* BFD back-end for IBM RS/6000 "XCOFF" files. - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001 + Copyright 1990-1999, 2000, 2001, 2002 Free Software Foundation, Inc. FIXME: Can someone provide a transliteration of this name into ASCII? Using the following chars caused a compiler warning on HIUX (so I replaced @@ -55,9 +54,11 @@ extern void _bfd_xcoff_swap_sym_in PARAMS ((bfd *, PTR, PTR)); extern unsigned int _bfd_xcoff_swap_sym_out PARAMS ((bfd *, PTR, PTR)); extern void _bfd_xcoff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR)); extern unsigned int _bfd_xcoff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR)); +static void xcoff_swap_reloc_in PARAMS ((bfd *, PTR, PTR)); +static unsigned int xcoff_swap_reloc_out PARAMS ((bfd *, PTR, PTR)); -/* Forward declare _bfd_xcoff_rtype2howto for coffcode.h macro. */ -void _bfd_xcoff_rtype2howto PARAMS ((arelent *, struct internal_reloc *)); +/* Forward declare xcoff_rtype2howto for coffcode.h macro. */ +void xcoff_rtype2howto PARAMS ((arelent *, struct internal_reloc *)); /* coffcode.h needs these to be defined. */ #define RS6000COFF_C 1 @@ -75,14 +76,15 @@ void _bfd_xcoff_rtype2howto PARAMS ((arelent *, struct internal_reloc *)); #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3) #define COFF_LONG_FILENAMES #define NO_COFF_SYMBOLS -#define RTYPE2HOWTO(cache_ptr, dst) _bfd_xcoff_rtype2howto (cache_ptr, dst) +#define RTYPE2HOWTO(cache_ptr, dst) xcoff_rtype2howto (cache_ptr, dst) #define coff_mkobject _bfd_xcoff_mkobject #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name #define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup #ifdef AIX_CORE -extern const bfd_target * rs6000coff_core_p (); -extern boolean rs6000coff_core_file_matches_executable_p (); +extern const bfd_target * rs6000coff_core_p PARAMS ((bfd *abfd)); +extern boolean rs6000coff_core_file_matches_executable_p + PARAMS ((bfd *cbfd, bfd *ebfd)); extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd)); extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd)); #define CORE_FILE_P rs6000coff_core_p @@ -105,6 +107,9 @@ extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd)); #define coff_SWAP_sym_out _bfd_xcoff_swap_sym_out #define coff_SWAP_aux_in _bfd_xcoff_swap_aux_in #define coff_SWAP_aux_out _bfd_xcoff_swap_aux_out +#define coff_swap_reloc_in xcoff_swap_reloc_in +#define coff_swap_reloc_out xcoff_swap_reloc_out +#define NO_COFF_RELOCS #include "coffcode.h" @@ -144,8 +149,64 @@ static bfd_vma xcoff_loader_symbol_offset static bfd_vma xcoff_loader_reloc_offset PARAMS ((bfd *, struct internal_ldhdr *)); static boolean xcoff_generate_rtinit - PARAMS((bfd *, const char *, const char *)); + PARAMS((bfd *, const char *, const char *, boolean)); +static boolean do_pad PARAMS((bfd *, unsigned int)); +static boolean do_copy PARAMS((bfd *, bfd *)); +static boolean do_shared_object_padding PARAMS ((bfd *, bfd *, ufile_ptr *, int)); + +/* Relocation functions */ +static boolean xcoff_reloc_type_br PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); + +static boolean xcoff_complain_overflow_dont_func + PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS)); +static boolean xcoff_complain_overflow_bitfield_func + PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS)); +static boolean xcoff_complain_overflow_signed_func + PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS)); +static boolean xcoff_complain_overflow_unsigned_func + PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS)); + +boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION]) + PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)) = +{ + xcoff_reloc_type_pos, /* R_POS (0x00) */ + xcoff_reloc_type_neg, /* R_NEG (0x01) */ + xcoff_reloc_type_rel, /* R_REL (0x02) */ + xcoff_reloc_type_toc, /* R_TOC (0x03) */ + xcoff_reloc_type_fail, /* R_RTB (0x04) */ + xcoff_reloc_type_toc, /* R_GL (0x05) */ + xcoff_reloc_type_toc, /* R_TCL (0x06) */ + xcoff_reloc_type_fail, /* (0x07) */ + xcoff_reloc_type_ba, /* R_BA (0x08) */ + xcoff_reloc_type_fail, /* (0x09) */ + xcoff_reloc_type_br, /* R_BR (0x0a) */ + xcoff_reloc_type_fail, /* (0x0b) */ + xcoff_reloc_type_pos, /* R_RL (0x0c) */ + xcoff_reloc_type_pos, /* R_RLA (0x0d) */ + xcoff_reloc_type_fail, /* (0x0e) */ + xcoff_reloc_type_noop, /* R_REF (0x0f) */ + xcoff_reloc_type_fail, /* (0x10) */ + xcoff_reloc_type_fail, /* (0x11) */ + xcoff_reloc_type_toc, /* R_TRL (0x12) */ + xcoff_reloc_type_toc, /* R_TRLA (0x13) */ + xcoff_reloc_type_fail, /* R_RRTBI (0x14) */ + xcoff_reloc_type_fail, /* R_RRTBA (0x15) */ + xcoff_reloc_type_ba, /* R_CAI (0x16) */ + xcoff_reloc_type_crel, /* R_CREL (0x17) */ + xcoff_reloc_type_ba, /* R_RBA (0x18) */ + xcoff_reloc_type_ba, /* R_RBAC (0x19) */ + xcoff_reloc_type_br, /* R_RBR (0x1a) */ + xcoff_reloc_type_ba, /* R_RBRC (0x1b) */ +}; +boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW]) + PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS)) = +{ + xcoff_complain_overflow_dont_func, + xcoff_complain_overflow_bitfield_func, + xcoff_complain_overflow_signed_func, + xcoff_complain_overflow_unsigned_func, +}; /* We use our own tdata type. Its first field is the COFF tdata type, so the COFF routines are compatible. */ @@ -176,7 +237,7 @@ _bfd_xcoff_mkobject (abfd) xcoff_data (abfd)->debug_indices = NULL; /* text section alignment is different than the default */ - /* xcoff_data (abfd)->text_align_power = 5; */ + bfd_xcoff_text_align_power (abfd) = 2; return true; } @@ -217,8 +278,8 @@ _bfd_xcoff_copy_private_bfd_data (ibfd, obfd) else ox->snentry = sec->output_section->target_index; } - ox->text_align_power = ix->text_align_power; - ox->data_align_power = ix->data_align_power; + bfd_xcoff_text_align_power (obfd) = bfd_xcoff_text_align_power (ibfd); + bfd_xcoff_data_align_power (obfd) = bfd_xcoff_data_align_power (ibfd); ox->modtype = ix->modtype; ox->cputype = ix->cputype; ox->maxdata = ix->maxdata; @@ -517,7 +578,7 @@ end: reloc_howto_type xcoff_howto_table[] = { /* Standard 32 bit relocation. */ - HOWTO (0, /* type */ + HOWTO (R_POS, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -532,7 +593,7 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* 32 bit relocation, but store negative value. */ - HOWTO (1, /* type */ + HOWTO (R_NEG, /* type */ 0, /* rightshift */ -2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -547,7 +608,7 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* 32 bit PC relative relocation. */ - HOWTO (2, /* type */ + HOWTO (R_REL, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -562,7 +623,7 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* 16 bit TOC relative relocation. */ - HOWTO (3, /* type */ + HOWTO (R_TOC, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ @@ -577,7 +638,7 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* I don't really know what this is. */ - HOWTO (4, /* type */ + HOWTO (R_RTB, /* type */ 1, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -592,9 +653,9 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* External TOC relative symbol. */ - HOWTO (5, /* type */ + HOWTO (R_GL, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -607,9 +668,9 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* Local TOC relative symbol. */ - HOWTO (6, /* type */ + HOWTO (R_TCL, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -624,7 +685,7 @@ reloc_howto_type xcoff_howto_table[] = EMPTY_HOWTO (7), /* Non modifiable absolute branch. */ - HOWTO (8, /* type */ + HOWTO (R_BA, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ @@ -632,16 +693,16 @@ reloc_howto_type xcoff_howto_table[] = 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ 0, /* special_function */ - "R_BA", /* name */ + "R_BA_26", /* name */ true, /* partial_inplace */ - 0x3fffffc, /* src_mask */ - 0x3fffffc, /* dst_mask */ + 0x03fffffc, /* src_mask */ + 0x03fffffc, /* dst_mask */ false), /* pcrel_offset */ EMPTY_HOWTO (9), /* Non modifiable relative branch. */ - HOWTO (0xa, /* type */ + HOWTO (R_BR, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ @@ -658,9 +719,9 @@ reloc_howto_type xcoff_howto_table[] = EMPTY_HOWTO (0xb), /* Indirect load. */ - HOWTO (0xc, /* type */ + HOWTO (R_RL, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -673,9 +734,9 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* Load address. */ - HOWTO (0xd, /* type */ + HOWTO (R_RLA, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -690,13 +751,13 @@ reloc_howto_type xcoff_howto_table[] = EMPTY_HOWTO (0xe), /* Non-relocating reference. */ - HOWTO (0xf, /* type */ + HOWTO (R_REF, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ + complain_overflow_dont, /* complain_on_overflow */ 0, /* special_function */ "R_REF", /* name */ false, /* partial_inplace */ @@ -708,9 +769,9 @@ reloc_howto_type xcoff_howto_table[] = EMPTY_HOWTO (0x11), /* TOC relative indirect load. */ - HOWTO (0x12, /* type */ + HOWTO (R_TRL, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -723,9 +784,9 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* TOC relative load address. */ - HOWTO (0x13, /* type */ + HOWTO (R_TRLA, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -738,7 +799,7 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* Modifiable relative branch. */ - HOWTO (0x14, /* type */ + HOWTO (R_RRTBI, /* type */ 1, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -753,7 +814,7 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* Modifiable absolute branch. */ - HOWTO (0x15, /* type */ + HOWTO (R_RRTBA, /* type */ 1, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -768,9 +829,9 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* Modifiable call absolute indirect. */ - HOWTO (0x16, /* type */ + HOWTO (R_CAI, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -783,9 +844,9 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* Modifiable call relative. */ - HOWTO (0x17, /* type */ + HOWTO (R_CREL, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -798,7 +859,7 @@ reloc_howto_type xcoff_howto_table[] = false), /* pcrel_offset */ /* Modifiable branch absolute. */ - HOWTO (0x18, /* type */ + HOWTO (R_RBA, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ @@ -808,12 +869,12 @@ reloc_howto_type xcoff_howto_table[] = 0, /* special_function */ "R_RBA", /* name */ true, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ + 0x03fffffc, /* src_mask */ + 0x03fffffc, /* dst_mask */ false), /* pcrel_offset */ /* Modifiable branch absolute. */ - HOWTO (0x19, /* type */ + HOWTO (R_RBAC, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -823,12 +884,12 @@ reloc_howto_type xcoff_howto_table[] = 0, /* special_function */ "R_RBAC", /* name */ true, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ false), /* pcrel_offset */ /* Modifiable branch relative. */ - HOWTO (0x1a, /* type */ + HOWTO (R_RBR, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ @@ -836,16 +897,16 @@ reloc_howto_type xcoff_howto_table[] = 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ 0, /* special_function */ - "R_RBR", /* name */ + "R_RBR_26", /* name */ true, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ + 0x03fffffc, /* src_mask */ + 0x03fffffc, /* dst_mask */ false), /* pcrel_offset */ /* Modifiable branch absolute. */ - HOWTO (0x1b, /* type */ + HOWTO (R_RBRC, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -857,36 +918,75 @@ reloc_howto_type xcoff_howto_table[] = 0xffff, /* dst_mask */ false), /* pcrel_offset */ - HOWTO (0, /* type */ - 0, /* rightshift */ - 4, /* size (0 = byte, 1 = short, 2 = long) */ - 64, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - 0, /* special_function */ - "R_POS", /* name */ - true, /* partial_inplace */ - MINUS_ONE, /* src_mask */ - MINUS_ONE, /* dst_mask */ - false) /* pcrel_offset */ + /* 16 bit Non modifiable absolute branch. */ + HOWTO (R_BA, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + 0, /* special_function */ + "R_BA_16", /* name */ + true, /* partial_inplace */ + 0xfffc, /* src_mask */ + 0xfffc, /* dst_mask */ + false), /* pcrel_offset */ + + /* Modifiable branch relative. */ + HOWTO (R_RBR, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "R_RBR_16", /* name */ + true, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* Modifiable branch relative. */ + HOWTO (R_RBA, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "R_RBA_16", /* name */ + true, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ }; void -_bfd_xcoff_rtype2howto (relent, internal) +xcoff_rtype2howto (relent, internal) arelent *relent; struct internal_reloc *internal; { - relent->howto = xcoff_howto_table + internal->r_type; - - /* Check for relocs we don't know of. */ - if (internal->r_type - >= sizeof (xcoff_howto_table) / sizeof (xcoff_howto_table[0])) - abort (); - if (internal->r_type != relent->howto->type) + if (internal->r_type > R_RBRC) abort (); + /* Default howto layout works most of the time */ + relent->howto = &xcoff_howto_table[internal->r_type]; + + /* Special case some 16 bit reoloc */ + if (15 == (internal->r_size & 0x1f)) + { + if (R_BA == internal->r_type) + relent->howto = &xcoff_howto_table[0x1c]; + else if (R_RBR == internal->r_type) + relent->howto = &xcoff_howto_table[0x1d]; + else if (R_RBA == internal->r_type) + relent->howto = &xcoff_howto_table[0x1e]; + } + /* The r_size field of an XCOFF reloc encodes the bitsize of the relocation, as well as indicating whether it is signed or not. Doublecheck that the relocation information gathered from the @@ -894,14 +994,8 @@ _bfd_xcoff_rtype2howto (relent, internal) for R_REF relocs. */ if (relent->howto->dst_mask != 0 && (relent->howto->bitsize - != ((unsigned int) internal->r_size & 0x3f) + 1)) + != ((unsigned int) internal->r_size & 0x1f) + 1)) abort (); -#if 0 - if ((internal->r_size & 0x80) != 0 - ? (relent->howto->complain_on_overflow != complain_overflow_signed) - : (relent->howto->complain_on_overflow != complain_overflow_bitfield)) - abort (); -#endif } reloc_howto_type * @@ -913,6 +1007,8 @@ _bfd_xcoff_reloc_type_lookup (abfd, code) { case BFD_RELOC_PPC_B26: return &xcoff_howto_table[0xa]; + case BFD_RELOC_PPC_BA16: + return &xcoff_howto_table[0x1c]; case BFD_RELOC_PPC_BA26: return &xcoff_howto_table[8]; case BFD_RELOC_PPC_TOC16: @@ -920,8 +1016,6 @@ _bfd_xcoff_reloc_type_lookup (abfd, code) case BFD_RELOC_32: case BFD_RELOC_CTOR: return &xcoff_howto_table[0]; - case BFD_RELOC_64: - return &xcoff_howto_table[0x1c]; default: return NULL; } @@ -973,7 +1067,17 @@ _bfd_xcoff_reloc_type_lookup (abfd, code) /* XCOFF archives use this as a magic string. Note that both strings have the same length. */ +/* Set the magic for archive. */ +boolean +bfd_xcoff_ar_archive_set_magic (abfd, magic) + bfd *abfd ATTRIBUTE_UNUSED; + char *magic ATTRIBUTE_UNUSED; +{ + /* Not supported yet. */ + return false; + /* bfd_xcoff_archive_set_magic (abfd, magic); */ +} /* Read in the armap of an XCOFF archive. */ @@ -1135,10 +1239,11 @@ const bfd_target * _bfd_xcoff_archive_p (abfd) bfd *abfd; { + struct artdata *tdata_hold; char magic[SXCOFFARMAG]; - bfd_size_type amt; + bfd_size_type amt = SXCOFFARMAG; - if (bfd_bread ((PTR) magic, (bfd_size_type) SXCOFFARMAG, abfd) != SXCOFFARMAG) + if (bfd_bread ((PTR) magic, amt, abfd) != amt) { if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); @@ -1152,13 +1257,12 @@ _bfd_xcoff_archive_p (abfd) return NULL; } - /* We are setting bfd_ardata(abfd) here, but since bfd_ardata - involves a cast, we can't do it as the left operand of - assignment. */ + tdata_hold = bfd_ardata (abfd); + amt = sizeof (struct artdata); - abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt); + bfd_ardata (abfd) = (struct artdata *) bfd_zalloc (abfd, amt); if (bfd_ardata (abfd) == (struct artdata *) NULL) - return NULL; + goto error_ret_restore; bfd_ardata (abfd)->cache = NULL; bfd_ardata (abfd)->archive_head = NULL; @@ -1175,13 +1279,12 @@ _bfd_xcoff_archive_p (abfd) memcpy (hdr.magic, magic, SXCOFFARMAG); /* Now read the rest of the file header. */ - if (bfd_bread ((PTR) &hdr.memoff, - (bfd_size_type) SIZEOF_AR_FILE_HDR - SXCOFFARMAG, abfd) - != SIZEOF_AR_FILE_HDR - SXCOFFARMAG) + amt = SIZEOF_AR_FILE_HDR - SXCOFFARMAG; + if (bfd_bread ((PTR) &hdr.memoff, amt, abfd) != amt) { if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); - return NULL; + goto error_ret; } bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff, @@ -1190,7 +1293,7 @@ _bfd_xcoff_archive_p (abfd) amt = SIZEOF_AR_FILE_HDR; bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt); if (bfd_ardata (abfd)->tdata == NULL) - return NULL; + goto error_ret; memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR); } @@ -1203,33 +1306,32 @@ _bfd_xcoff_archive_p (abfd) memcpy (hdr.magic, magic, SXCOFFARMAG); /* Now read the rest of the file header. */ - if (bfd_bread ((PTR) &hdr.memoff, - (bfd_size_type) SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG, abfd) - != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG) + amt = SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG; + if (bfd_bread ((PTR) &hdr.memoff, amt, abfd) != amt) { if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); - return NULL; + goto error_ret; } - /* XXX This actually has to be a call to strtoll (at least on 32-bit - machines) since the field width is 20 and there numbers with more - than 32 bits can be represented. */ - bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff, - (char **) NULL, 10); + bfd_ardata (abfd)->first_file_filepos = bfd_scan_vma (hdr.firstmemoff, + (const char **) 0, + 10); amt = SIZEOF_AR_FILE_HDR_BIG; bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt); if (bfd_ardata (abfd)->tdata == NULL) - return NULL; + goto error_ret; memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG); } if (! _bfd_xcoff_slurp_armap (abfd)) { + error_ret: bfd_release (abfd, bfd_ardata (abfd)); - abfd->tdata.aout_ar_data = (struct artdata *) NULL; + error_ret_restore: + bfd_ardata (abfd) = tdata_hold; return NULL; } @@ -1558,6 +1660,84 @@ static char buff20[XCOFFARMAGBIG_ELEMENT_SIZE + 1]; (v) = bfd_scan_vma (buff20, (const char **) NULL, 10) static boolean +do_pad (abfd, number) + bfd *abfd; + unsigned int number; +{ + bfd_byte b = 0; + + /* Limit pad to <= 4096. */ + if (number > 4096) + return false; + + while (number--) + if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1) + return false; + + return true; +} + +static boolean +do_copy (out_bfd, in_bfd) + bfd *out_bfd; + bfd *in_bfd; +{ + bfd_size_type remaining; + bfd_byte buffer[DEFAULT_BUFFERSIZE]; + + if (bfd_seek (in_bfd, (file_ptr) 0, SEEK_SET) != 0) + return false; + + remaining = arelt_size (in_bfd); + + while (remaining >= DEFAULT_BUFFERSIZE) + { + if (bfd_bread (buffer, DEFAULT_BUFFERSIZE, in_bfd) != DEFAULT_BUFFERSIZE + || bfd_bwrite (buffer, DEFAULT_BUFFERSIZE, out_bfd) != DEFAULT_BUFFERSIZE) + return false; + + remaining -= DEFAULT_BUFFERSIZE; + } + + if (remaining) + { + if (bfd_bread (buffer, remaining, in_bfd) != remaining + || bfd_bwrite (buffer, remaining, out_bfd) != remaining) + return false; + } + + return true; +} + +static boolean +do_shared_object_padding (out_bfd, in_bfd, offset, ar_header_size) + bfd *out_bfd; + bfd *in_bfd; + ufile_ptr *offset; + int ar_header_size; +{ + if (bfd_check_format (in_bfd, bfd_object) + && bfd_get_flavour (in_bfd) == bfd_target_xcoff_flavour + && (in_bfd->flags & DYNAMIC) != 0) + { + bfd_size_type pad = 0; + int text_align_power; + + text_align_power = bfd_xcoff_text_align_power (in_bfd); + + pad = 1 << text_align_power; + pad -= (*offset + ar_header_size) & (pad - 1); + + if (! do_pad (out_bfd, pad)) + return false; + + *offset += pad; + } + + return true; +} + +static boolean xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) bfd *abfd; unsigned int elength ATTRIBUTE_UNUSED; @@ -1652,10 +1832,9 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) + str_32 + (str_32 & 1); symbol_table = NULL; - symbol_table = (bfd_byte *) bfd_malloc (symbol_table_size); + symbol_table = (bfd_byte *) bfd_zmalloc (symbol_table_size); if (symbol_table == NULL) return false; - memset (symbol_table, 0, symbol_table_size); hdr = (struct xcoff_ar_hdr_big *) symbol_table; @@ -1756,10 +1935,9 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) + str_64 + (str_64 & 1); symbol_table = NULL; - symbol_table = (bfd_byte *) bfd_malloc (symbol_table_size); + symbol_table = (bfd_byte *) bfd_zmalloc (symbol_table_size); if (symbol_table == NULL) return false; - memset (symbol_table, 0, symbol_table_size); hdr = (struct xcoff_ar_hdr_big *) symbol_table; @@ -1986,28 +2164,12 @@ xcoff_write_archive_contents_old (abfd) if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0) return false; - while (remaining != 0) - { - bfd_size_type amt; - bfd_byte buffer[DEFAULT_BUFFERSIZE]; - - amt = sizeof buffer; - if (amt > remaining) - amt = remaining; - if (bfd_bread (buffer, amt, sub) != amt - || bfd_bwrite (buffer, amt, abfd) != amt) - return false; - remaining -= amt; - } - if ((size & 1) != 0) - { - bfd_byte b; - - b = '\0'; - if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1) - return false; - } + if (! do_copy (abfd, sub)) + return false; + + if (! do_pad (abfd, size & 1)) + return false; } sprintf (fhdr.lastmemoff, "%ld", (long) prevoff); @@ -2018,9 +2180,9 @@ xcoff_write_archive_contents_old (abfd) sprintf (fhdr.memoff, "%ld", (long) nextoff); memset (&ahdr, 0, sizeof ahdr); - sprintf (ahdr.size, "%ld", (long) (XCOFFARMAG_ELEMENT_SIZE + - count * XCOFFARMAG_ELEMENT_SIZE + - total_namlen)); + sprintf (ahdr.size, "%ld", (long) (XCOFFARMAG_ELEMENT_SIZE + + count * XCOFFARMAG_ELEMENT_SIZE + + total_namlen)); sprintf (ahdr.prevoff, "%ld", (long) prevoff); sprintf (ahdr.date, "%d", 0); sprintf (ahdr.uid, "%d", 0); @@ -2074,14 +2236,9 @@ xcoff_write_archive_contents_old (abfd) if (bfd_bwrite ((PTR) name, namlen + 1, abfd) != namlen + 1) return false; } - if ((size & 1) != 0) - { - bfd_byte b; - b = '\0'; - if (bfd_bwrite ((PTR) &b, (bfd_size_type) 1, abfd) != 1) - return false; - } + if (! do_pad (abfd, size & 1)) + return false; /* Write out the armap, if appropriate. */ if (! makemap || ! hasobjects) @@ -2128,15 +2285,26 @@ xcoff_write_archive_contents_big (abfd) bfd_byte *member_table, *mt; bfd_vma member_table_size; + memset (&fhdr, 0, SIZEOF_AR_FILE_HDR_BIG); memcpy (fhdr.magic, XCOFFARMAGBIG, SXCOFFARMAG); - PRINT20 (fhdr.firstmemoff, SIZEOF_AR_FILE_HDR_BIG); - PRINT20 (fhdr.freeoff, 0); - /* Calculate count and total_namlen */ + if (bfd_seek (abfd, (file_ptr) SIZEOF_AR_FILE_HDR_BIG, SEEK_SET) != 0) + return false; + + /* Calculate count and total_namlen. */ + makemap = bfd_has_map (abfd); + hasobjects = false; for (current_bfd = abfd->archive_head, count = 0, total_namlen = 0; current_bfd != NULL; current_bfd = current_bfd->next, count++) - total_namlen += strlen (normalize_filename (current_bfd)) + 1; + { + total_namlen += strlen (normalize_filename (current_bfd)) + 1; + + if (makemap + && ! hasobjects + && bfd_check_format (current_bfd, bfd_object)) + hasobjects = true; + } offsets = NULL; if (count) @@ -2145,11 +2313,7 @@ xcoff_write_archive_contents_big (abfd) if (offsets == NULL) return false; } - if (bfd_seek (abfd, (file_ptr) SIZEOF_AR_FILE_HDR_BIG, SEEK_SET) != 0) - return false; - makemap = bfd_has_map (abfd); - hasobjects = false; prevoff = 0; nextoff = SIZEOF_AR_FILE_HDR_BIG; for (current_bfd = abfd->archive_head, i = 0; @@ -2161,12 +2325,6 @@ xcoff_write_archive_contents_big (abfd) struct xcoff_ar_hdr_big *ahdrp; bfd_size_type remaining; - if (makemap && ! hasobjects) - { - if (bfd_check_format (current_bfd, bfd_object)) - hasobjects = true; - } - name = normalize_filename (current_bfd); namlen = strlen (name); @@ -2221,6 +2379,14 @@ xcoff_write_archive_contents_big (abfd) BFD_ASSERT (nextoff == bfd_tell (abfd)); + /* Check for xcoff shared objects. + Their text section needs to be aligned wrt the archive file position. + This requires extra padding before the archive header. */ + if (! do_shared_object_padding (abfd, current_bfd, & nextoff, + SIZEOF_AR_HDR_BIG + namlen + + SXCOFFARFMAG)) + return false; + offsets[i] = nextoff; prevoff = nextoff; @@ -2237,31 +2403,19 @@ xcoff_write_archive_contents_big (abfd) if (bfd_seek (current_bfd, (file_ptr) 0, SEEK_SET) != 0) return false; - while (remaining != 0) - { - bfd_size_type amt; - bfd_byte buffer[DEFAULT_BUFFERSIZE]; - - amt = sizeof buffer; - if (amt > remaining) - amt = remaining; - if (bfd_bread (buffer, amt, current_bfd) != amt - || bfd_bwrite (buffer, amt, abfd) != amt) - return false; - remaining -= amt; - } - - if ((size & 1) != 0) - { - bfd_byte b; - b = '\0'; - if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1) - return false; - } + if (! do_copy (abfd, current_bfd)) + return false; + + if (! do_pad (abfd, size & 1)) + return false; } - PRINT20 (fhdr.lastmemoff, prevoff); + if (count) + { + PRINT20 (fhdr.firstmemoff, offsets[0]); + PRINT20 (fhdr.lastmemoff, prevoff); + } /* Write out the member table. Layout : @@ -2294,16 +2448,15 @@ xcoff_write_archive_contents_big (abfd) member_table_size += member_table_size & 1; member_table = NULL; - member_table = (bfd_byte *) bfd_malloc (member_table_size); + member_table = (bfd_byte *) bfd_zmalloc (member_table_size); if (member_table == NULL) return false; - memset (member_table, 0, member_table_size); hdr = (struct xcoff_ar_hdr_big *) member_table; - PRINT20 (hdr->size, (XCOFFARMAGBIG_ELEMENT_SIZE + - count * XCOFFARMAGBIG_ELEMENT_SIZE + - total_namlen + (total_namlen & 1))); + PRINT20 (hdr->size, (XCOFFARMAGBIG_ELEMENT_SIZE + + count * XCOFFARMAGBIG_ELEMENT_SIZE + + total_namlen + (total_namlen & 1))); if (makemap && hasobjects) PRINT20 (hdr->nextoff, nextoff + member_table_size); else @@ -2505,6 +2658,40 @@ xcoff_swap_ldsym_out (abfd, src, d) bfd_put_32 (abfd, src->l_parm, dst->l_parm); } +static void +xcoff_swap_reloc_in (abfd, s, d) + bfd *abfd; + PTR s; + PTR d; +{ + struct external_reloc *src = (struct external_reloc *) s; + struct internal_reloc *dst = (struct internal_reloc *) d; + + memset (dst, 0, sizeof (struct internal_reloc)); + + dst->r_vaddr = bfd_get_32 (abfd, src->r_vaddr); + dst->r_symndx = bfd_get_32 (abfd, src->r_symndx); + dst->r_size = bfd_get_8 (abfd, src->r_size); + dst->r_type = bfd_get_8 (abfd, src->r_type); +} + +static unsigned int +xcoff_swap_reloc_out (abfd, s, d) + bfd *abfd; + PTR s; + PTR d; +{ + struct internal_reloc *src = (struct internal_reloc *) s; + struct external_reloc *dst = (struct external_reloc *) d; + + bfd_put_32 (abfd, src->r_vaddr, dst->r_vaddr); + bfd_put_32 (abfd, src->r_symndx, dst->r_symndx); + bfd_put_8 (abfd, src->r_type, dst->r_type); + bfd_put_8 (abfd, src->r_size, dst->r_size); + + return bfd_coff_relsz (abfd); +} + /* Swap in the ldrel structure. */ static void @@ -2538,12 +2725,578 @@ xcoff_swap_ldrel_out (abfd, src, d) } +boolean +xcoff_reloc_type_noop (input_bfd, input_section, output_bfd, rel, sym, howto, + val, addend, relocation, contents) + bfd *input_bfd ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + struct internal_reloc *rel ATTRIBUTE_UNUSED; + struct internal_syment *sym ATTRIBUTE_UNUSED; + struct reloc_howto_struct *howto ATTRIBUTE_UNUSED; + bfd_vma val ATTRIBUTE_UNUSED; + bfd_vma addend ATTRIBUTE_UNUSED; + bfd_vma *relocation ATTRIBUTE_UNUSED; + bfd_byte *contents ATTRIBUTE_UNUSED; +{ + return true; +} + +boolean +xcoff_reloc_type_fail (input_bfd, input_section, output_bfd, rel, sym, howto, + val, addend, relocation, contents) + bfd *input_bfd; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + struct internal_reloc *rel; + struct internal_syment *sym ATTRIBUTE_UNUSED; + struct reloc_howto_struct *howto ATTRIBUTE_UNUSED; + bfd_vma val ATTRIBUTE_UNUSED; + bfd_vma addend ATTRIBUTE_UNUSED; + bfd_vma *relocation ATTRIBUTE_UNUSED; + bfd_byte *contents ATTRIBUTE_UNUSED; +{ + (*_bfd_error_handler) + (_("%s: unsupported relocation type 0x%02x"), + bfd_get_filename (input_bfd), (unsigned int) rel->r_type); + bfd_set_error (bfd_error_bad_value); + return false; +} + +boolean +xcoff_reloc_type_pos (input_bfd, input_section, output_bfd, rel, sym, howto, + val, addend, relocation, contents) + bfd *input_bfd ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + struct internal_reloc *rel ATTRIBUTE_UNUSED; + struct internal_syment *sym ATTRIBUTE_UNUSED; + struct reloc_howto_struct *howto ATTRIBUTE_UNUSED; + bfd_vma val; + bfd_vma addend; + bfd_vma *relocation; + bfd_byte *contents ATTRIBUTE_UNUSED; +{ + *relocation = val + addend; + return true; +} + +boolean +xcoff_reloc_type_neg (input_bfd, input_section, output_bfd, rel, sym, howto, + val, addend, relocation, contents) + bfd *input_bfd ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + struct internal_reloc *rel ATTRIBUTE_UNUSED; + struct internal_syment *sym ATTRIBUTE_UNUSED; + struct reloc_howto_struct *howto ATTRIBUTE_UNUSED; + bfd_vma val; + bfd_vma addend; + bfd_vma *relocation; + bfd_byte *contents ATTRIBUTE_UNUSED; +{ + *relocation = addend - val; + return true; +} + +boolean +xcoff_reloc_type_rel (input_bfd, input_section, output_bfd, rel, sym, howto, + val, addend, relocation, contents) + bfd *input_bfd ATTRIBUTE_UNUSED; + asection *input_section; + bfd *output_bfd ATTRIBUTE_UNUSED; + struct internal_reloc *rel ATTRIBUTE_UNUSED; + struct internal_syment *sym ATTRIBUTE_UNUSED; + struct reloc_howto_struct *howto; + bfd_vma val; + bfd_vma addend; + bfd_vma *relocation; + bfd_byte *contents ATTRIBUTE_UNUSED; +{ + howto->pc_relative = true; + + /* A PC relative reloc includes the section address. */ + addend += input_section->vma; + + *relocation = val + addend; + *relocation -= (input_section->output_section->vma + + input_section->output_offset); + return true; +} + +boolean +xcoff_reloc_type_toc (input_bfd, input_section, output_bfd, rel, sym, howto, + val, addend, relocation, contents) + bfd *input_bfd; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd; + struct internal_reloc *rel; + struct internal_syment *sym; + struct reloc_howto_struct *howto ATTRIBUTE_UNUSED; + bfd_vma val; + bfd_vma addend ATTRIBUTE_UNUSED; + bfd_vma *relocation; + bfd_byte *contents ATTRIBUTE_UNUSED; +{ + struct xcoff_link_hash_entry *h; + + if (0 > rel->r_symndx) + return false; + + h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx]; + + if (h != NULL && h->smclas != XMC_TD) + { + if (h->toc_section == NULL) + { + (*_bfd_error_handler) + (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"), + bfd_get_filename (input_bfd), rel->r_vaddr, + h->root.root.string); + bfd_set_error (bfd_error_bad_value); + return false; + } + + BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0); + val = (h->toc_section->output_section->vma + + h->toc_section->output_offset); + } + + *relocation = ((val - xcoff_data (output_bfd)->toc) + - (sym->n_value - xcoff_data (input_bfd)->toc)); + return true; +} + +boolean +xcoff_reloc_type_ba (input_bfd, input_section, output_bfd, rel, sym, howto, + val, addend, relocation, contents) + bfd *input_bfd ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + struct internal_reloc *rel ATTRIBUTE_UNUSED; + struct internal_syment *sym ATTRIBUTE_UNUSED; + struct reloc_howto_struct *howto; + bfd_vma val; + bfd_vma addend; + bfd_vma *relocation; + bfd_byte *contents ATTRIBUTE_UNUSED; +{ + howto->src_mask &= ~3; + howto->dst_mask = howto->src_mask; + + *relocation = val + addend; + + return true; +} + +static boolean +xcoff_reloc_type_br (input_bfd, input_section, output_bfd, rel, sym, howto, + val, addend, relocation, contents) + bfd *input_bfd; + asection *input_section; + bfd *output_bfd ATTRIBUTE_UNUSED; + struct internal_reloc *rel; + struct internal_syment *sym ATTRIBUTE_UNUSED; + struct reloc_howto_struct *howto; + bfd_vma val; + bfd_vma addend; + bfd_vma *relocation; + bfd_byte *contents; +{ + struct xcoff_link_hash_entry *h; + + if (0 > rel->r_symndx) + return false; + + h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx]; + + /* If we see an R_BR or R_RBR reloc which is jumping to global + linkage code, and it is followed by an appropriate cror nop + instruction, we replace the cror with lwz r2,20(r1). This + restores the TOC after the glink code. Contrariwise, if the + call is followed by a lwz r2,20(r1), but the call is not + going to global linkage code, we can replace the load with a + cror. */ + if (NULL != h + && bfd_link_hash_defined == h->root.type + && (rel->r_vaddr - input_section->vma + 8 + <= input_section->_cooked_size)) + { + bfd_byte *pnext; + unsigned long next; + + pnext = contents + (rel->r_vaddr - input_section->vma) + 4; + next = bfd_get_32 (input_bfd, pnext); + + /* The _ptrgl function is magic. It is used by the AIX + compiler to call a function through a pointer. */ + if (h->smclas == XMC_GL || strcmp (h->root.root.string, "._ptrgl") == 0) + { + if (next == 0x4def7b82 /* cror 15,15,15 */ + || next == 0x4ffffb82 /* cror 31,31,31 */ + || next == 0x60000000) /* ori r0,r0,0 */ + bfd_put_32 (input_bfd, 0x80410014, pnext); /* lwz r1,20(r1) */ + + } + else + { + if (next == 0x80410014) /* lwz r1,20(r1) */ + bfd_put_32 (input_bfd, 0x60000000, pnext); /* ori r0,r0,0 */ + } + } + else if (NULL != h && bfd_link_hash_undefined == h->root.type) + { + /* Normally, this relocation is against a defined symbol. In the + case where this is a partial link and the output section offset + is greater than 2^25, the linker will return an invalid error + message that the relocation has been truncated. Yes it has been + truncated but no it not important. For this case, disable the + overflow checking. */ + + howto->complain_on_overflow = complain_overflow_dont; + } + + howto->pc_relative = true; + howto->src_mask &= ~3; + howto->dst_mask = howto->src_mask; + + /* A PC relative reloc includes the section address. */ + addend += input_section->vma; + + *relocation = val + addend; + *relocation -= (input_section->output_section->vma + + input_section->output_offset); + return true; +} + +boolean +xcoff_reloc_type_crel (input_bfd, input_section, output_bfd, rel, sym, howto, + val, addend, relocation, contents) + bfd *input_bfd ATTRIBUTE_UNUSED; + asection *input_section; + bfd *output_bfd ATTRIBUTE_UNUSED; + struct internal_reloc *rel ATTRIBUTE_UNUSED; + struct internal_syment *sym ATTRIBUTE_UNUSED; + struct reloc_howto_struct *howto; + bfd_vma val ATTRIBUTE_UNUSED; + bfd_vma addend; + bfd_vma *relocation; + bfd_byte *contents ATTRIBUTE_UNUSED; +{ + howto->pc_relative = true; + howto->src_mask &= ~3; + howto->dst_mask = howto->src_mask; + + /* A PC relative reloc includes the section address. */ + addend += input_section->vma; + + *relocation = val + addend; + *relocation -= (input_section->output_section->vma + + input_section->output_offset); + return true; +} + +static boolean +xcoff_complain_overflow_dont_func (input_bfd, val, relocation, howto) + bfd *input_bfd ATTRIBUTE_UNUSED; + bfd_vma val ATTRIBUTE_UNUSED; + bfd_vma relocation ATTRIBUTE_UNUSED; + struct reloc_howto_struct *howto ATTRIBUTE_UNUSED; +{ + return false; +} + +static boolean +xcoff_complain_overflow_bitfield_func (input_bfd, val, relocation, howto) + bfd *input_bfd; + bfd_vma val; + bfd_vma relocation; + struct reloc_howto_struct *howto; +{ + bfd_vma addrmask, fieldmask, signmask, ss; + bfd_vma a, b, sum; + + /* Get the values to be added together. For signed and unsigned + relocations, we assume that all values should be truncated to + the size of an address. For bitfields, all the bits matter. + See also bfd_check_overflow. */ + fieldmask = N_ONES (howto->bitsize); + addrmask = N_ONES (bfd_arch_bits_per_address (input_bfd)) | fieldmask; + a = relocation; + b = val & howto->src_mask; + + /* Much like unsigned, except no trimming with addrmask. In + addition, the sum overflows if there is a carry out of + the bfd_vma, i.e., the sum is less than either input + operand. */ + a >>= howto->rightshift; + b >>= howto->bitpos; + + /* Bitfields are sometimes used for signed numbers; for + example, a 13-bit field sometimes represents values in + 0..8191 and sometimes represents values in -4096..4095. + If the field is signed and a is -4095 (0x1001) and b is + -1 (0x1fff), the sum is -4096 (0x1000), but (0x1001 + + 0x1fff is 0x3000). It's not clear how to handle this + everywhere, since there is not way to know how many bits + are significant in the relocation, but the original code + assumed that it was fully sign extended, and we will keep + that assumption. */ + signmask = (fieldmask >> 1) + 1; + + if ((a & ~ fieldmask) != 0) + { + /* Some bits out of the field are set. This might not + be a problem: if this is a signed bitfield, it is OK + iff all the high bits are set, including the sign + bit. We'll try setting all but the most significant + bit in the original relocation value: if this is all + ones, we are OK, assuming a signed bitfield. */ + ss = (signmask << howto->rightshift) - 1; + if ((ss | relocation) != ~ (bfd_vma) 0) + return true; + a &= fieldmask; + } + + /* We just assume (b & ~ fieldmask) == 0. */ + + /* We explicitly permit wrap around if this relocation + covers the high bit of an address. The Linux kernel + relies on it, and it is the only way to write assembler + code which can run when loaded at a location 0x80000000 + away from the location at which it is linked. */ + if (howto->bitsize + howto->rightshift + == bfd_arch_bits_per_address (input_bfd)) + return false; + + sum = a + b; + if (sum < a || (sum & ~ fieldmask) != 0) + { + /* There was a carry out, or the field overflow. Test + for signed operands again. Here is the overflow test + is as for complain_overflow_signed. */ + if (((~ (a ^ b)) & (a ^ sum)) & signmask) + return true; + } + + return false; +} + +static boolean +xcoff_complain_overflow_signed_func (input_bfd, val, relocation, howto) + bfd *input_bfd; + bfd_vma val; + bfd_vma relocation; + struct reloc_howto_struct *howto; +{ + bfd_vma addrmask, fieldmask, signmask, ss; + bfd_vma a, b, sum; + + /* Get the values to be added together. For signed and unsigned + relocations, we assume that all values should be truncated to + the size of an address. For bitfields, all the bits matter. + See also bfd_check_overflow. */ + fieldmask = N_ONES (howto->bitsize); + addrmask = N_ONES (bfd_arch_bits_per_address (input_bfd)) | fieldmask; + a = relocation; + b = val & howto->src_mask; + + a = (a & addrmask) >> howto->rightshift; + + /* If any sign bits are set, all sign bits must be set. + That is, A must be a valid negative address after + shifting. */ + signmask = ~ (fieldmask >> 1); + ss = a & signmask; + if (ss != 0 && ss != ((addrmask >> howto->rightshift) & signmask)) + return true; + + /* We only need this next bit of code if the sign bit of B + is below the sign bit of A. This would only happen if + SRC_MASK had fewer bits than BITSIZE. Note that if + SRC_MASK has more bits than BITSIZE, we can get into + trouble; we would need to verify that B is in range, as + we do for A above. */ + signmask = ((~ howto->src_mask) >> 1) & howto->src_mask; + if ((b & signmask) != 0) + { + /* Set all the bits above the sign bit. */ + b -= signmask <<= 1; + } + + b = (b & addrmask) >> howto->bitpos; + + /* Now we can do the addition. */ + sum = a + b; + + /* See if the result has the correct sign. Bits above the + sign bit are junk now; ignore them. If the sum is + positive, make sure we did not have all negative inputs; + if the sum is negative, make sure we did not have all + positive inputs. The test below looks only at the sign + bits, and it really just + SIGN (A) == SIGN (B) && SIGN (A) != SIGN (SUM) + */ + signmask = (fieldmask >> 1) + 1; + if (((~ (a ^ b)) & (a ^ sum)) & signmask) + return true; + + return false; +} + +static boolean +xcoff_complain_overflow_unsigned_func (input_bfd, val, relocation, howto) + bfd *input_bfd; + bfd_vma val; + bfd_vma relocation; + struct reloc_howto_struct *howto; +{ + bfd_vma addrmask, fieldmask; + bfd_vma a, b, sum; + + /* Get the values to be added together. For signed and unsigned + relocations, we assume that all values should be truncated to + the size of an address. For bitfields, all the bits matter. + See also bfd_check_overflow. */ + fieldmask = N_ONES (howto->bitsize); + addrmask = N_ONES (bfd_arch_bits_per_address (input_bfd)) | fieldmask; + a = relocation; + b = val & howto->src_mask; + + /* Checking for an unsigned overflow is relatively easy: + trim the addresses and add, and trim the result as well. + Overflow is normally indicated when the result does not + fit in the field. However, we also need to consider the + case when, e.g., fieldmask is 0x7fffffff or smaller, an + input is 0x80000000, and bfd_vma is only 32 bits; then we + will get sum == 0, but there is an overflow, since the + inputs did not fit in the field. Instead of doing a + separate test, we can check for this by or-ing in the + operands when testing for the sum overflowing its final + field. */ + a = (a & addrmask) >> howto->rightshift; + b = (b & addrmask) >> howto->bitpos; + sum = (a + b) & addrmask; + if ((a | b | sum) & ~ fieldmask) + return true; + + return false; +} /* This is the relocation function for the RS/6000/POWER/PowerPC. This is currently the only processor which uses XCOFF; I hope that - will never change. */ + will never change. -static boolean + I took the relocation type definitions from two documents: + the PowerPC AIX Version 4 Application Binary Interface, First + Edition (April 1992), and the PowerOpen ABI, Big-Endian + 32-Bit Hardware Implementation (June 30, 1994). Differences + between the documents are noted below. + + Unsupported r_type's + + R_RTB: + R_RRTBI: + R_RRTBA: + + These relocs are defined by the PowerPC ABI to be + relative branches which use half of the difference + between the symbol and the program counter. I can't + quite figure out when this is useful. These relocs are + not defined by the PowerOpen ABI. + + Supported r_type's + + R_POS: + Simple positive relocation. + + R_NEG: + Simple negative relocation. + + R_REL: + Simple PC relative relocation. + + R_TOC: + TOC relative relocation. The value in the instruction in + the input file is the offset from the input file TOC to + the desired location. We want the offset from the final + TOC to the desired location. We have: + isym = iTOC + in + iinsn = in + o + osym = oTOC + on + oinsn = on + o + so we must change insn by on - in. + + R_GL: + GL linkage relocation. The value of this relocation + is the address of the entry in the TOC section. + + R_TCL: + Local object TOC address. I can't figure out the + difference between this and case R_GL. + + R_TRL: + TOC relative relocation. A TOC relative load instruction + which may be changed to a load address instruction. + FIXME: We don't currently implement this optimization. + + R_TRLA: + TOC relative relocation. This is a TOC relative load + address instruction which may be changed to a load + instruction. FIXME: I don't know if this is the correct + implementation. + + R_BA: + Absolute branch. We don't want to mess with the lower + two bits of the instruction. + + R_CAI: + The PowerPC ABI defines this as an absolute call which + may be modified to become a relative call. The PowerOpen + ABI does not define this relocation type. + + R_RBA: + Absolute branch which may be modified to become a + relative branch. + + R_RBAC: + The PowerPC ABI defines this as an absolute branch to a + fixed address which may be modified to an absolute branch + to a symbol. The PowerOpen ABI does not define this + relocation type. + + R_RBRC: + The PowerPC ABI defines this as an absolute branch to a + fixed address which may be modified to a relative branch. + The PowerOpen ABI does not define this relocation type. + + R_BR: + Relative branch. We don't want to mess with the lower + two bits of the instruction. + + R_CREL: + The PowerPC ABI defines this as a relative call which may + be modified to become an absolute call. The PowerOpen + ABI does not define this relocation type. + + R_RBR: + A relative branch which may be modified to become an + absolute branch. FIXME: We don't implement this, + although we should for symbols of storage mapping class + XMC_XO. + + R_RL: + The PowerPC AIX ABI describes this as a load which may be + changed to a load address. The PowerOpen ABI says this + is the same as case R_POS. + + R_RLA: + The PowerPC AIX ABI describes this as a load address + which may be changed to a load. The PowerOpen ABI says + this is the same as R_POS. +*/ + +boolean xcoff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, contents, relocs, syms, sections) @@ -2561,7 +3314,6 @@ xcoff_ppc_relocate_section (output_bfd, info, input_bfd, rel = relocs; relend = rel + input_section->reloc_count; - for (; rel < relend; rel++) { long symndx; @@ -2570,7 +3322,10 @@ xcoff_ppc_relocate_section (output_bfd, info, input_bfd, bfd_vma addend; bfd_vma val; struct reloc_howto_struct howto; - bfd_reloc_status_type rstat; + bfd_vma relocation; + bfd_vma value_to_relocate; + bfd_vma address; + bfd_byte *location; /* Relocation type R_REF is a special relocation type which is merely used to prevent garbage collection from occurring for @@ -2578,327 +3333,152 @@ xcoff_ppc_relocate_section (output_bfd, info, input_bfd, if (rel->r_type == R_REF) continue; - symndx = rel->r_symndx; - - if (symndx == -1) - { - h = NULL; - sym = NULL; - addend = 0; - } - else - { - h = obj_xcoff_sym_hashes (input_bfd)[symndx]; - sym = syms + symndx; - addend = - sym->n_value; - - } - - /* We build the howto information on the fly. */ - + /* howto */ howto.type = rel->r_type; howto.rightshift = 0; - howto.size = 2; howto.bitsize = (rel->r_size & 0x1f) + 1; + howto.size = howto.bitsize > 16 ? 2 : 1; howto.pc_relative = false; howto.bitpos = 0; - if ((rel->r_size & 0x80) != 0) - howto.complain_on_overflow = complain_overflow_signed; - else - howto.complain_on_overflow = complain_overflow_bitfield; + howto.complain_on_overflow = (rel->r_size & 0x80 + ? complain_overflow_signed + : complain_overflow_bitfield); howto.special_function = NULL; howto.name = "internal"; howto.partial_inplace = true; - if (howto.bitsize == 32) - howto.src_mask = howto.dst_mask = 0xffffffff; - else - { - howto.src_mask = howto.dst_mask = (1 << howto.bitsize) - 1; - if (howto.bitsize == 16) - howto.size = 1; - } + howto.src_mask = howto.dst_mask = N_ONES(howto.bitsize); howto.pcrel_offset = false; + /* symbol */ val = 0; + addend = 0; + h = NULL; + sym = NULL; + symndx = rel->r_symndx; - if (h == NULL) + if (-1 != symndx) { asection *sec; - - if (symndx == -1) - { - sec = bfd_abs_section_ptr; - val = 0; - } - else + + h = obj_xcoff_sym_hashes (input_bfd)[symndx]; + sym = syms + symndx; + addend = - sym->n_value; + + if (NULL == h) { sec = sections[symndx]; /* Hack to make sure we use the right TOC anchor value - if this reloc is against the TOC anchor. */ - + if this reloc is against the TOC anchor. */ if (sec->name[3] == '0' - && strcmp (sec->name, ".tc0") == 0) - { - val = xcoff_data (output_bfd)->toc; - } + && strcmp (sec->name, ".tc0") == 0) + val = xcoff_data (output_bfd)->toc; else + val = (sec->output_section->vma + + sec->output_offset + + sym->n_value + - sec->vma); + } + else + { + if (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + { + sec = h->root.u.def.section; + val = (h->root.u.def.value + + sec->output_section->vma + + sec->output_offset); + } + else if (h->root.type == bfd_link_hash_common) { + sec = h->root.u.c.p->section; val = (sec->output_section->vma - + sec->output_offset - + sym->n_value - - sec->vma); + + sec->output_offset); + + } + else if ((0 == (h->flags & (XCOFF_DEF_DYNAMIC | XCOFF_IMPORT))) + && ! info->relocateable) + { + if (! ((*info->callbacks->undefined_symbol) + (info, h->root.root.string, input_bfd, input_section, + rel->r_vaddr - input_section->vma, true))) + return false; + + /* Don't try to process the reloc. It can't help, and + it may generate another error. */ + continue; } } } - else - { - if (h->root.type == bfd_link_hash_defined - || h->root.type == bfd_link_hash_defweak) - { - asection *sec; - - sec = h->root.u.def.section; - val = (h->root.u.def.value - + sec->output_section->vma - + sec->output_offset); - } - else if (h->root.type == bfd_link_hash_common) - { - asection *sec; - - sec = h->root.u.c.p->section; - val = (sec->output_section->vma - + sec->output_offset); - } - else if ((h->flags & XCOFF_DEF_DYNAMIC) != 0 - || (h->flags & XCOFF_IMPORT) != 0) - { - /* Every symbol in a shared object is defined somewhere. */ - val = 0; - } - else if (! info->relocateable) - { - if (! ((*info->callbacks->undefined_symbol) - (info, h->root.root.string, input_bfd, input_section, - rel->r_vaddr - input_section->vma, true))) - return false; - - /* Don't try to process the reloc. It can't help, and - it may generate another error. */ - continue; - } - } - /* I took the relocation type definitions from two documents: - the PowerPC AIX Version 4 Application Binary Interface, First - Edition (April 1992), and the PowerOpen ABI, Big-Endian - 32-Bit Hardware Implementation (June 30, 1994). Differences - between the documents are noted below. */ + if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION + || !((*xcoff_calculate_relocation[rel->r_type]) + (input_bfd, input_section, output_bfd, rel, sym, &howto, val, + addend, &relocation, contents))) + return false; + + /* address */ + address = rel->r_vaddr - input_section->vma; + location = contents + address; + + if (address > input_section->_raw_size) + abort(); + + /* Get the value we are going to relocate. */ + if (1 == howto.size) + value_to_relocate = bfd_get_16 (input_bfd, location); + else + value_to_relocate = bfd_get_32 (input_bfd, location); + + /* overflow. + + FIXME: We may drop bits during the addition + which we don't check for. We must either check at every single + operation, which would be tedious, or we must do the computations + in a type larger than bfd_vma, which would be inefficient. */ + + if ((unsigned int) howto.complain_on_overflow + >= XCOFF_MAX_COMPLAIN_OVERFLOW) + abort(); - switch (rel->r_type) + if (((*xcoff_complain_overflow[howto.complain_on_overflow]) + (input_bfd, value_to_relocate, relocation, &howto))) { - case R_RTB: - case R_RRTBI: - case R_RRTBA: - /* These relocs are defined by the PowerPC ABI to be - relative branches which use half of the difference - between the symbol and the program counter. I can't - quite figure out when this is useful. These relocs are - not defined by the PowerOpen ABI. */ - default: - (*_bfd_error_handler) - (_("%s: unsupported relocation type 0x%02x"), - bfd_archive_filename (input_bfd), (unsigned int) rel->r_type); - bfd_set_error (bfd_error_bad_value); - return false; - case R_POS: - /* Simple positive relocation. */ - break; - case R_NEG: - /* Simple negative relocation. */ - val = - val; - break; - case R_REL: - /* Simple PC relative relocation. */ - howto.pc_relative = true; - break; - case R_TOC: - /* TOC relative relocation. The value in the instruction in - the input file is the offset from the input file TOC to - the desired location. We want the offset from the final - TOC to the desired location. We have: - isym = iTOC + in - iinsn = in + o - osym = oTOC + on - oinsn = on + o - so we must change insn by on - in. - */ - case R_GL: - /* Global linkage relocation. The value of this relocation - is the address of the entry in the TOC section. */ - case R_TCL: - /* Local object TOC address. I can't figure out the - difference between this and case R_GL. */ - case R_TRL: - /* TOC relative relocation. A TOC relative load instruction - which may be changed to a load address instruction. - FIXME: We don't currently implement this optimization. */ - case R_TRLA: - /* TOC relative relocation. This is a TOC relative load - address instruction which may be changed to a load - instruction. FIXME: I don't know if this is the correct - implementation. */ - if (h != NULL && h->smclas != XMC_TD) + const char *name; + char buf[SYMNMLEN + 1]; + char reloc_type_name[10]; + + if (symndx == -1) { - if (h->toc_section == NULL) - { - (*_bfd_error_handler) - (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"), - bfd_archive_filename (input_bfd), rel->r_vaddr, - h->root.root.string); - bfd_set_error (bfd_error_bad_value); - return false; - } - - BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0); - val = (h->toc_section->output_section->vma - + h->toc_section->output_offset); - } - - val = ((val - xcoff_data (output_bfd)->toc) - - (sym->n_value - xcoff_data (input_bfd)->toc)); - addend = 0; - break; - case R_BA: - /* Absolute branch. We don't want to mess with the lower - two bits of the instruction. */ - case R_CAI: - /* The PowerPC ABI defines this as an absolute call which - may be modified to become a relative call. The PowerOpen - ABI does not define this relocation type. */ - case R_RBA: - /* Absolute branch which may be modified to become a - relative branch. */ - case R_RBAC: - /* The PowerPC ABI defines this as an absolute branch to a - fixed address which may be modified to an absolute branch - to a symbol. The PowerOpen ABI does not define this - relocation type. */ - case R_RBRC: - /* The PowerPC ABI defines this as an absolute branch to a - fixed address which may be modified to a relative branch. - The PowerOpen ABI does not define this relocation type. */ - howto.src_mask &= ~3; - howto.dst_mask = howto.src_mask; - break; - case R_BR: - /* Relative branch. We don't want to mess with the lower - two bits of the instruction. */ - case R_CREL: - /* The PowerPC ABI defines this as a relative call which may - be modified to become an absolute call. The PowerOpen - ABI does not define this relocation type. */ - case R_RBR: - /* A relative branch which may be modified to become an - absolute branch. FIXME: We don't implement this, - although we should for symbols of storage mapping class - XMC_XO. */ - howto.pc_relative = true; - howto.src_mask &= ~3; - howto.dst_mask = howto.src_mask; - break; - case R_RL: - /* The PowerPC AIX ABI describes this as a load which may be - changed to a load address. The PowerOpen ABI says this - is the same as case R_POS. */ - break; - case R_RLA: - /* The PowerPC AIX ABI describes this as a load address - which may be changed to a load. The PowerOpen ABI says - this is the same as R_POS. */ - break; - } - - /* If we see an R_BR or R_RBR reloc which is jumping to global - linkage code, and it is followed by an appropriate cror nop - instruction, we replace the cror with lwz r2,20(r1). This - restores the TOC after the glink code. Contrariwise, if the - call is followed by a lwz r2,20(r1), but the call is not - going to global linkage code, we can replace the load with a - cror. */ - if ((rel->r_type == R_BR || rel->r_type == R_RBR) - && h != NULL - && h->root.type == bfd_link_hash_defined - && (rel->r_vaddr - input_section->vma + 8 - <= input_section->_cooked_size)) - { - bfd_byte *pnext; - unsigned long next; - - pnext = contents + (rel->r_vaddr - input_section->vma) + 4; - next = bfd_get_32 (input_bfd, pnext); - - /* The _ptrgl function is magic. It is used by the AIX - compiler to call a function through a pointer. */ - if (h->smclas == XMC_GL - || strcmp (h->root.root.string, "._ptrgl") == 0) + name = "*ABS*"; + } + else if (h != NULL) { - if (next == 0x4def7b82 /* cror 15,15,15 */ - || next == 0x4ffffb82 /* cror 31,31,31 */ - || next == 0x60000000) /* ori r0,r0,0 */ - bfd_put_32 (input_bfd, - (bfd_vma) 0x80410014, /* lwz r1,20(r1) */ - pnext); - } - else + name = h->root.root.string; + } + else { - if (next == 0x80410014) /* lwz r1,20(r1) */ - bfd_put_32 (input_bfd, - (bfd_vma) 0x60000000, /* ori r0,r0,0 */ - pnext); + name = _bfd_coff_internal_syment_name (input_bfd, sym, buf); + if (name == NULL) + name = "UNKNOWN"; } + sprintf (reloc_type_name, "0x%02x", rel->r_type); + + if (! ((*info->callbacks->reloc_overflow) + (info, name, reloc_type_name, (bfd_vma) 0, input_bfd, + input_section, rel->r_vaddr - input_section->vma))) + return false; } - - /* A PC relative reloc includes the section address. */ - if (howto.pc_relative) - addend += input_section->vma; - - rstat = _bfd_final_link_relocate (&howto, input_bfd, input_section, - contents, - rel->r_vaddr - input_section->vma, - val, addend); - - switch (rstat) - { - default: - abort (); - case bfd_reloc_ok: - break; - case bfd_reloc_overflow: - { - const char *name; - char buf[SYMNMLEN + 1]; - char howto_name[10]; - - if (symndx == -1) - name = "*ABS*"; - else if (h != NULL) - name = h->root.root.string; - else - { - name = _bfd_coff_internal_syment_name (input_bfd, sym, buf); - - if (name == NULL) - return false; - } - sprintf (howto_name, "0x%02x", rel->r_type); - - if (! ((*info->callbacks->reloc_overflow) - (info, name, howto_name, (bfd_vma) 0, input_bfd, - input_section, rel->r_vaddr - input_section->vma))) - return false; - } - } + + /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE. */ + value_to_relocate = ((value_to_relocate & ~howto.dst_mask) + | (((value_to_relocate & howto.src_mask) + + relocation) & howto.dst_mask)); + + /* Put the value back in the object file. */ + if (1 == howto.size) + bfd_put_16 (input_bfd, value_to_relocate, location); + else + bfd_put_32 (input_bfd, value_to_relocate, location); } return true; @@ -2994,8 +3574,8 @@ xcoff_create_csect_from_smclas (abfd, aux, symbol_name) ".td", NULL, ".sv3264" }; - if ((19 >= aux->x_csect.x_smclas) && - (NULL != names[aux->x_csect.x_smclas])) + if ((19 >= aux->x_csect.x_smclas) + && (NULL != names[aux->x_csect.x_smclas])) { return_value = bfd_make_section_anyway (abfd, names[aux->x_csect.x_smclas]); @@ -3046,20 +3626,20 @@ xcoff_loader_reloc_offset (abfd, ldhdr) bfd *abfd; struct internal_ldhdr *ldhdr; { - return bfd_xcoff_ldhdrsz(abfd) + - (ldhdr->l_nsyms * bfd_xcoff_ldsymsz(abfd)); + return bfd_xcoff_ldhdrsz (abfd) + ldhdr->l_nsyms * bfd_xcoff_ldsymsz (abfd); } static boolean -xcoff_generate_rtinit (abfd, init, fini) +xcoff_generate_rtinit (abfd, init, fini, rtld) bfd *abfd; const char *init; const char *fini; + boolean rtld; { bfd_byte filehdr_ext[FILHSZ]; bfd_byte scnhdr_ext[SCNHSZ]; - bfd_byte syment_ext[SYMESZ * 8]; - bfd_byte reloc_ext[RELSZ * 2]; + bfd_byte syment_ext[SYMESZ * 10]; + bfd_byte reloc_ext[RELSZ * 3]; bfd_byte *data_buffer; bfd_size_type data_buffer_size; bfd_byte *string_table = NULL, *st_tmp = NULL; @@ -3074,9 +3654,9 @@ xcoff_generate_rtinit (abfd, init, fini) char *data_name = ".data"; char *rtinit_name = "__rtinit"; + char *rtld_name = "__rtld"; - if (! bfd_xcoff_rtinit_size (abfd) - || (init == NULL && fini == NULL)) + if (! bfd_xcoff_rtinit_size (abfd)) return false; initsz = (init == NULL ? 0 : 1 + strlen (init)); @@ -3088,7 +3668,7 @@ xcoff_generate_rtinit (abfd, init, fini) filehdr.f_magic = bfd_xcoff_magic_number (abfd); filehdr.f_nscns = 1; filehdr.f_timdat = 0; - filehdr.f_nsyms = 0; /* at least 6, no more than 8 */ + filehdr.f_nsyms = 0; /* at least 6, no more than 10 */ filehdr.f_symptr = 0; /* set below */ filehdr.f_opthdr = 0; filehdr.f_flags = 0; @@ -3130,11 +3710,9 @@ xcoff_generate_rtinit (abfd, init, fini) data_buffer_size = 0x0040 + initsz + finisz; data_buffer_size += (data_buffer_size & 7) ? 8 - (data_buffer_size & 7) : 0; data_buffer = NULL; - data_buffer = (bfd_byte *) bfd_malloc (data_buffer_size); + data_buffer = (bfd_byte *) bfd_zmalloc (data_buffer_size); if (data_buffer == NULL) return false; - - memset (data_buffer, 0, data_buffer_size); if (initsz) { @@ -3168,8 +3746,10 @@ xcoff_generate_rtinit (abfd, init, fini) if (string_table_size) { string_table_size += 4; - string_table = (bfd_byte *)bfd_malloc (string_table_size); - memset (string_table, 0, string_table_size); + string_table = (bfd_byte *) bfd_zmalloc (string_table_size); + if (string_table == NULL) + return false; + val = string_table_size; bfd_h_put_32 (abfd, val, &string_table[0]); st_tmp = string_table + 4; @@ -3179,9 +3759,10 @@ xcoff_generate_rtinit (abfd, init, fini) 0. .data csect 2. __rtinit 4. init function - 6. fini function */ - memset (syment_ext, 0, 8 * SYMESZ); - memset (reloc_ext, 0, 2 * RELSZ); + 6. fini function + 8. __rtld */ + memset (syment_ext, 0, 10 * SYMESZ); + memset (reloc_ext, 0, 3 * RELSZ); /* .data csect */ memset (&syment, 0, sizeof (struct internal_syment)); @@ -3287,6 +3868,32 @@ xcoff_generate_rtinit (abfd, init, fini) scnhdr.s_nreloc += 1; } + if (rtld) + { + memset (&syment, 0, sizeof (struct internal_syment)); + memset (&auxent, 0, sizeof (union internal_auxent)); + memcpy (syment._n._n_name, rtld_name, strlen (rtld_name)); + syment.n_sclass = C_EXT; + syment.n_numaux = 1; + bfd_coff_swap_sym_out (abfd, &syment, + &syment_ext[filehdr.f_nsyms * SYMESZ]); + bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, + syment.n_numaux, + &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]); + + /* reloc */ + memset (&reloc, 0, sizeof (struct internal_reloc)); + reloc.r_vaddr = 0x0000; + reloc.r_symndx = filehdr.f_nsyms; + reloc.r_type = R_POS; + reloc.r_size = 31; + bfd_coff_swap_reloc_out (abfd, &reloc, + &reloc_ext[scnhdr.s_nreloc * RELSZ]); + + filehdr.f_nsyms += 2; + scnhdr.s_nreloc += 1; + } + scnhdr.s_relptr = scnhdr.s_scnptr + data_buffer_size; filehdr.f_symptr = scnhdr.s_relptr + scnhdr.s_nreloc * RELSZ; @@ -3343,84 +3950,81 @@ static unsigned long xcoff_glink_code[9] = static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = { { /* COFF backend, defined in libcoff.h. */ - _bfd_xcoff_swap_aux_in, /* _bfd_coff_swap_aux_in */ - _bfd_xcoff_swap_sym_in, /* _bfd_coff_swap_sym_in */ - coff_swap_lineno_in, /* _bfd_coff_swap_lineno_in */ - _bfd_xcoff_swap_aux_out, /* _bfd_swap_aux_out */ - _bfd_xcoff_swap_sym_out, /* _bfd_swap_sym_out */ - coff_swap_lineno_out, /* _bfd_swap_lineno_out */ - coff_swap_reloc_out, /* _bfd_swap_reloc_out */ - coff_swap_filehdr_out, /* _bfd_swap_filehdr_out */ - coff_swap_aouthdr_out, /* _bfd_swap_aouthdr_out */ - coff_swap_scnhdr_out, /* _bfd_swap_scnhdr_out */ - FILHSZ, /* _bfd_filhsz */ - AOUTSZ, /* _bfd_aoutsz */ - SCNHSZ, /* _bfd_scnhsz */ - SYMESZ, /* _bfd_symesz */ - AUXESZ, /* _bfd_auxesz */ - RELSZ, /* _bfd_relsz */ - LINESZ, /* _bfd_linesz */ - FILNMLEN, /* _bfd_filnmlen */ + _bfd_xcoff_swap_aux_in, + _bfd_xcoff_swap_sym_in, + coff_swap_lineno_in, + _bfd_xcoff_swap_aux_out, + _bfd_xcoff_swap_sym_out, + coff_swap_lineno_out, + xcoff_swap_reloc_out, + coff_swap_filehdr_out, + coff_swap_aouthdr_out, + coff_swap_scnhdr_out, + FILHSZ, + AOUTSZ, + SCNHSZ, + SYMESZ, + AUXESZ, + RELSZ, + LINESZ, + FILNMLEN, true, /* _bfd_coff_long_filenames */ false, /* _bfd_coff_long_section_names */ - (3), /* _bfd_coff_default_section_alignment_power */ + 3, /* _bfd_coff_default_section_alignment_power */ false, /* _bfd_coff_force_symnames_in_strings */ 2, /* _bfd_coff_debug_string_prefix_length */ - coff_swap_filehdr_in, /* _bfd_coff_swap_filehdr_in */ - coff_swap_aouthdr_in, /* _bfd_swap_aouthdr_in */ - coff_swap_scnhdr_in, /* _bfd_swap_scnhdr_in */ - coff_swap_reloc_in, /* _bfd_reloc_in */ - coff_bad_format_hook, /* _bfd_bad_format_hook */ - coff_set_arch_mach_hook, /* _bfd_set_arch_mach_hook */ - coff_mkobject_hook, /* _bfd_mkobject_hook */ - styp_to_sec_flags, /* _bfd_syp_to_sec_flags */ - coff_set_alignment_hook, /* _bfd_set_alignment_hook */ - coff_slurp_symbol_table, /* _bfd_coff_slurp_symbol_table */ - symname_in_debug_hook, /* _coff_symname_in_debug_hook */ - coff_pointerize_aux_hook, /* _bfd_coff_pointerize_aux_hook */ - coff_print_aux, /* bfd_coff_print_aux */ - dummy_reloc16_extra_cases, /* _bfd_coff_reloc16_extra_cases */ - dummy_reloc16_estimate, /* _bfd_coff_reloc16_estimate */ + coff_swap_filehdr_in, + coff_swap_aouthdr_in, + coff_swap_scnhdr_in, + xcoff_swap_reloc_in, + coff_bad_format_hook, + coff_set_arch_mach_hook, + coff_mkobject_hook, + styp_to_sec_flags, + coff_set_alignment_hook, + coff_slurp_symbol_table, + symname_in_debug_hook, + coff_pointerize_aux_hook, + coff_print_aux, + dummy_reloc16_extra_cases, + dummy_reloc16_estimate, NULL, /* bfd_coff_sym_is_global */ - coff_compute_section_file_positions, /* _bfd_coff_compute_section_file_positions */ + coff_compute_section_file_positions, NULL, /* _bfd_coff_start_final_link */ - xcoff_ppc_relocate_section, /* _bfd_coff_relocate_section */ - coff_rtype_to_howto, /* _bfd_coff_rtype_to_howto */ - NULL, /* _bfd_coff_addust_symndx */ - _bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */ - coff_link_output_has_begun, /* _bfd_coff_link_output_has_begun */ - coff_final_link_postscript /* _bfd_coff_final_link_postscript */ + xcoff_ppc_relocate_section, + coff_rtype_to_howto, + NULL, /* _bfd_coff_adjust_symndx */ + _bfd_generic_link_add_one_symbol, + coff_link_output_has_begun, + coff_final_link_postscript }, 0x01DF, /* magic number */ - bfd_arch_rs6000, /* architecture */ - bfd_mach_rs6k, /* machine */ + bfd_arch_rs6000, + bfd_mach_rs6k, /* Function pointers to xcoff specific swap routines. */ - xcoff_swap_ldhdr_in, /* _xcoff_swap_ldhdr_in */ - xcoff_swap_ldhdr_out, /* _xcoff_swap_ldhdr_out */ - xcoff_swap_ldsym_in, /* _xcoff_swap_ldsym_in */ - xcoff_swap_ldsym_out, /* _xcoff_swap_ldsym_out */ - xcoff_swap_ldrel_in, /* _xcoff_swap_ldrel_in */ - xcoff_swap_ldrel_out, /* _xcoff_swap_ldrel_out */ + xcoff_swap_ldhdr_in, + xcoff_swap_ldhdr_out, + xcoff_swap_ldsym_in, + xcoff_swap_ldsym_out, + xcoff_swap_ldrel_in, + xcoff_swap_ldrel_out, /* Sizes. */ - LDHDRSZ, /* _xcoff_ldhdrsz */ - LDSYMSZ, /* _xcoff_ldsymsz */ - LDRELSZ, /* _xcoff_ldrelsz */ + LDHDRSZ, + LDSYMSZ, + LDRELSZ, 12, /* _xcoff_function_descriptor_size */ - SMALL_AOUTSZ, /* _xcoff_small_aout_header_size */ + SMALL_AOUTSZ, /* Versions. */ - 1, /* _xcoff_ldhdr_version */ + 1, /* _xcoff_ldhdr_version */ - /* Xcoff vs xcoff64 putting symbol names. */ - _bfd_xcoff_put_symbol_name, /* _xcoff_put_symbol_name */ - _bfd_xcoff_put_ldsymbol_name, /* _xcoff_put_ldsymbol_name */ - - & xcoff_dynamic_reloc, /* dynamic reloc howto */ - - xcoff_create_csect_from_smclas, /* _xcoff_create_csect_from_smclas */ + _bfd_xcoff_put_symbol_name, + _bfd_xcoff_put_ldsymbol_name, + &xcoff_dynamic_reloc, + xcoff_create_csect_from_smclas, /* Lineno and reloc count overflow. */ xcoff_is_lineno_count_overflow, @@ -3431,14 +4035,14 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = /* glink. */ & xcoff_glink_code[0], - (36), /* _xcoff_glink_size */ + 36, /* _xcoff_glink_size */ /* rtinit */ 64, /* _xcoff_rtinit_size */ - xcoff_generate_rtinit, /* _xcoff_generate_rtinit */ + xcoff_generate_rtinit, }; -/* The transfer vector that leads the outside world to all of the above. */ +/* The transfer vector that leads the outside world to all of the above. */ const bfd_target rs6000coff_vec = { "aixcoff-rs6000", @@ -3446,36 +4050,35 @@ const bfd_target rs6000coff_vec = BFD_ENDIAN_BIG, /* data byte order is big */ BFD_ENDIAN_BIG, /* header byte order is big */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | DYNAMIC | - HAS_SYMS | HAS_LOCALS | WP_TEXT), + (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | DYNAMIC + | HAS_SYMS | HAS_LOCALS | WP_TEXT), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), 0, /* leading char */ '/', /* ar_pad_char */ - 15, /* ar_max_namelen??? FIXMEmgo */ + 15, /* ar_max_namelen */ /* data */ - bfd_getb64, /* bfd_getx64 */ - bfd_getb_signed_64, /* bfd_getx_signed_64 */ - bfd_putb64, /* bfd_putx64 */ - bfd_getb32, /* bfd_getx32 */ - bfd_getb_signed_32, /* bfd_getx_signed_32 */ - bfd_putb32, /* bfd_putx32 */ - bfd_getb16, /* bfd_getx16 */ - bfd_getb_signed_16, /* bfd_getx_signed_16 */ - bfd_putb16, /* bfd_putx16 */ + bfd_getb64, + bfd_getb_signed_64, + bfd_putb64, + bfd_getb32, + bfd_getb_signed_32, + bfd_putb32, + bfd_getb16, + bfd_getb_signed_16, + bfd_putb16, /* hdrs */ - bfd_getb64, /* bfd_h_getx64 */ - bfd_getb_signed_64, /* bfd_h_getx_signed_64 */ - bfd_putb64, /* bfd_h_putx64 */ - bfd_getb32, /* bfd_h_getx32 */ - bfd_getb_signed_32, /* bfd_h_getx_signed_32 */ - bfd_putb32, /* bfd_h_putx32 */ - bfd_getb16, /* bfd_h_getx16 */ - bfd_getb_signed_16, /* bfd_h_getx_signed_16 */ - bfd_putb16, /* bfd_h_putx16 */ + bfd_getb64, + bfd_getb_signed_64, + bfd_putb64, + bfd_getb32, + bfd_getb_signed_32, + bfd_putb32, + bfd_getb16, + bfd_getb_signed_16, + bfd_putb16, { /* bfd_check_format */ _bfd_dummy_target, @@ -3499,204 +4102,186 @@ const bfd_target rs6000coff_vec = }, /* Generic */ - bfd_true, /* _close_and_cleanup */ - bfd_true, /* _bfd_free_cached_info */ - coff_new_section_hook, /* _new_section_hook */ - _bfd_generic_get_section_contents, /* _bfd_get_section_contents */ - /* _bfd_get_section_contents_in_window */ + bfd_true, + bfd_true, + coff_new_section_hook, + _bfd_generic_get_section_contents, _bfd_generic_get_section_contents_in_window, /* Copy */ - _bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */ - /* _bfd_merge_private_bfd_data */ + _bfd_xcoff_copy_private_bfd_data, ((boolean (*) (bfd *, bfd *)) bfd_true), - /* _bfd_copy_pivate_section_data */ ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true), - /* _bfd_copy_private_symbol_data */ ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true), - ((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */ - ((boolean (*) (bfd *, void * )) bfd_true), /* _bfd_print_private_bfd_data */ + ((boolean (*) (bfd *, flagword)) bfd_true), + ((boolean (*) (bfd *, void * )) bfd_true), /* Core */ - coff_core_file_failing_command, /* _core_file_failing_command */ - coff_core_file_failing_signal, /* _core_file_failing_signal */ - /* _core_file_matches_executable_p */ + coff_core_file_failing_command, + coff_core_file_failing_signal, coff_core_file_matches_executable_p, /* Archive */ - _bfd_xcoff_slurp_armap, /* _slurp_armap */ - /* XCOFF archives do not have - anything which corresponds to - an extended name table. */ - bfd_false, /* _slurp_extended_name_table */ - /* _construct_extended_name_table */ + _bfd_xcoff_slurp_armap, + bfd_false, ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false), - bfd_dont_truncate_arname, /* _truncate_arname */ - _bfd_xcoff_write_armap, /* _write_armap */ - _bfd_xcoff_read_ar_hdr, /* _read_ar_hdr */ - _bfd_xcoff_openr_next_archived_file, /* _openr_next_archived_file */ - _bfd_generic_get_elt_at_index, /* _get_elt_at_index */ - _bfd_xcoff_stat_arch_elt, /* _generic_stat_arch_elt */ - /* XCOFF archives do not have - a timestamp. */ - bfd_true, /* _update_armap_timestamp */ + bfd_dont_truncate_arname, + _bfd_xcoff_write_armap, + _bfd_xcoff_read_ar_hdr, + _bfd_xcoff_openr_next_archived_file, + _bfd_generic_get_elt_at_index, + _bfd_xcoff_stat_arch_elt, + bfd_true, /* Symbols */ - coff_get_symtab_upper_bound, /* _get_symtab_upper_bound */ - coff_get_symtab, /* _get_symtab */ - coff_make_empty_symbol, /* _make_empty_symbol */ - coff_print_symbol, /* _print_symbol */ - coff_get_symbol_info, /* _get_symbol_info */ - _bfd_xcoff_is_local_label_name, /* _bfd_is_local_label_name */ - coff_get_lineno, /* _get_lineno */ - coff_find_nearest_line, /* _find_nearest_line */ - coff_bfd_make_debug_symbol, /* _bfd_make_debug_symbol */ - _bfd_generic_read_minisymbols, /* _read_minisymbols */ - _bfd_generic_minisymbol_to_symbol, /* _minsymbol_to_symbol */ + coff_get_symtab_upper_bound, + coff_get_symtab, + coff_make_empty_symbol, + coff_print_symbol, + coff_get_symbol_info, + _bfd_xcoff_is_local_label_name, + coff_get_lineno, + coff_find_nearest_line, + coff_bfd_make_debug_symbol, + _bfd_generic_read_minisymbols, + _bfd_generic_minisymbol_to_symbol, /* Reloc */ - coff_get_reloc_upper_bound, /* _get_reloc_upper_bound */ - coff_canonicalize_reloc, /* _cononicalize_reloc */ - _bfd_xcoff_reloc_type_lookup, /* _bfd_reloc_type_lookup */ + coff_get_reloc_upper_bound, + coff_canonicalize_reloc, + _bfd_xcoff_reloc_type_lookup, /* Write */ - coff_set_arch_mach, /* _set_arch_mach */ - coff_set_section_contents, /* _set_section_contents */ + coff_set_arch_mach, + coff_set_section_contents, /* Link */ - _bfd_xcoff_sizeof_headers, /* _sizeof_headers */ - /* _bfd_get_relocated_section_contents */ + _bfd_xcoff_sizeof_headers, bfd_generic_get_relocated_section_contents, - bfd_generic_relax_section, /* _bfd_relax_section */ - _bfd_xcoff_bfd_link_hash_table_create, /* _bfd_link_hash_table_create */ - _bfd_xcoff_bfd_link_add_symbols, /* _bfd_link_add_symbols */ - _bfd_xcoff_bfd_final_link, /* _bfd_filnal_link */ - _bfd_generic_link_split_section, /* _bfd_link_split_section */ - bfd_generic_gc_sections, /* _bfd_gc_sections */ - bfd_generic_merge_sections, /* _bfd_merge_sections */ + bfd_generic_relax_section, + _bfd_xcoff_bfd_link_hash_table_create, + _bfd_generic_link_hash_table_free, + _bfd_xcoff_bfd_link_add_symbols, + _bfd_generic_link_just_syms, + _bfd_xcoff_bfd_final_link, + _bfd_generic_link_split_section, + bfd_generic_gc_sections, + bfd_generic_merge_sections, + bfd_generic_discard_group, /* Dynamic */ - /* _get_dynamic_symtab_upper_bound */ _bfd_xcoff_get_dynamic_symtab_upper_bound, - _bfd_xcoff_canonicalize_dynamic_symtab, /* _cononicalize_dynamic_symtab */ - _bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */ - _bfd_xcoff_canonicalize_dynamic_reloc, /* _cononicalize_dynamic_reloc */ + _bfd_xcoff_canonicalize_dynamic_symtab, + _bfd_xcoff_get_dynamic_reloc_upper_bound, + _bfd_xcoff_canonicalize_dynamic_reloc, /* Opposite endian version, none exists */ NULL, - /* back end data */ (void *) &bfd_xcoff_backend_data, }; -/* - * xcoff-powermac target - * Old target. - * Only difference between this target and the rs6000 target is the - * the default architecture and machine type used in coffcode.h - * - * PowerPC Macs use the same magic numbers as RS/6000 - * (because that's how they were bootstrapped originally), - * but they are always PowerPC architecture. - */ +/* xcoff-powermac target + Old target. + Only difference between this target and the rs6000 target is the + the default architecture and machine type used in coffcode.h + + PowerPC Macs use the same magic numbers as RS/6000 + (because that's how they were bootstrapped originally), + but they are always PowerPC architecture. */ static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data = { - { /* COFF backend, defined in libcoff.h */ - _bfd_xcoff_swap_aux_in, /* _bfd_coff_swap_aux_in */ - _bfd_xcoff_swap_sym_in, /* _bfd_coff_swap_sym_in */ - coff_swap_lineno_in, /* _bfd_coff_swap_lineno_in */ - _bfd_xcoff_swap_aux_out, /* _bfd_swap_aux_out */ - _bfd_xcoff_swap_sym_out, /* _bfd_swap_sym_out */ - coff_swap_lineno_out, /* _bfd_swap_lineno_out */ - coff_swap_reloc_out, /* _bfd_swap_reloc_out */ - coff_swap_filehdr_out, /* _bfd_swap_filehdr_out */ - coff_swap_aouthdr_out, /* _bfd_swap_aouthdr_out */ - coff_swap_scnhdr_out, /* _bfd_swap_scnhdr_out */ - FILHSZ, /* _bfd_filhsz */ - AOUTSZ, /* _bfd_aoutsz */ - SCNHSZ, /* _bfd_scnhsz */ - SYMESZ, /* _bfd_symesz */ - AUXESZ, /* _bfd_auxesz */ - RELSZ, /* _bfd_relsz */ - LINESZ, /* _bfd_linesz */ - FILNMLEN, /* _bfd_filnmlen */ + { /* COFF backend, defined in libcoff.h. */ + _bfd_xcoff_swap_aux_in, + _bfd_xcoff_swap_sym_in, + coff_swap_lineno_in, + _bfd_xcoff_swap_aux_out, + _bfd_xcoff_swap_sym_out, + coff_swap_lineno_out, + xcoff_swap_reloc_out, + coff_swap_filehdr_out, + coff_swap_aouthdr_out, + coff_swap_scnhdr_out, + FILHSZ, + AOUTSZ, + SCNHSZ, + SYMESZ, + AUXESZ, + RELSZ, + LINESZ, + FILNMLEN, true, /* _bfd_coff_long_filenames */ false, /* _bfd_coff_long_section_names */ - (3), /* _bfd_coff_default_section_alignment_power */ + 3, /* _bfd_coff_default_section_alignment_power */ false, /* _bfd_coff_force_symnames_in_strings */ 2, /* _bfd_coff_debug_string_prefix_length */ - coff_swap_filehdr_in, /* _bfd_coff_swap_filehdr_in */ - coff_swap_aouthdr_in, /* _bfd_swap_aouthdr_in */ - coff_swap_scnhdr_in, /* _bfd_swap_scnhdr_in */ - coff_swap_reloc_in, /* _bfd_reloc_in */ - coff_bad_format_hook, /* _bfd_bad_format_hook */ - coff_set_arch_mach_hook, /* _bfd_set_arch_mach_hook */ - coff_mkobject_hook, /* _bfd_mkobject_hook */ - styp_to_sec_flags, /* _bfd_syp_to_sec_flags */ - coff_set_alignment_hook, /* _bfd_set_alignment_hook */ - coff_slurp_symbol_table, /* _bfd_coff_slurp_symbol_table */ - symname_in_debug_hook, /* _coff_symname_in_debug_hook */ - coff_pointerize_aux_hook, /* _bfd_coff_pointerize_aux_hook */ - coff_print_aux, /* bfd_coff_print_aux */ - dummy_reloc16_extra_cases, /* _bfd_coff_reloc16_extra_cases */ - dummy_reloc16_estimate, /* _bfd_coff_reloc16_estimate */ + coff_swap_filehdr_in, + coff_swap_aouthdr_in, + coff_swap_scnhdr_in, + xcoff_swap_reloc_in, + coff_bad_format_hook, + coff_set_arch_mach_hook, + coff_mkobject_hook, + styp_to_sec_flags, + coff_set_alignment_hook, + coff_slurp_symbol_table, + symname_in_debug_hook, + coff_pointerize_aux_hook, + coff_print_aux, + dummy_reloc16_extra_cases, + dummy_reloc16_estimate, NULL, /* bfd_coff_sym_is_global */ - /* _bfd_coff_compute_section_file_positions */ coff_compute_section_file_positions, NULL, /* _bfd_coff_start_final_link */ - xcoff_ppc_relocate_section, /* _bfd_coff_relocate_section */ - coff_rtype_to_howto, /* _bfd_coff_rtype_to_howto */ - NULL, /* _bfd_coff_addust_symndx */ - _bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */ - coff_link_output_has_begun, /* _bfd_coff_link_output_has_begun */ - coff_final_link_postscript /* _bfd_coff_final_link_postscript */ + xcoff_ppc_relocate_section, + coff_rtype_to_howto, + NULL, /* _bfd_coff_adjust_symndx */ + _bfd_generic_link_add_one_symbol, + coff_link_output_has_begun, + coff_final_link_postscript }, 0x01DF, /* magic number */ - bfd_arch_powerpc, /* architecture */ - bfd_mach_ppc, /* machine */ - - /* function pointers to xcoff specific swap routines */ - xcoff_swap_ldhdr_in, /* _xcoff_swap_ldhdr_in */ - xcoff_swap_ldhdr_out, /* _xcoff_swap_ldhdr_out */ - xcoff_swap_ldsym_in, /* _xcoff_swap_ldsym_in */ - xcoff_swap_ldsym_out, /* _xcoff_swap_ldsym_out */ - xcoff_swap_ldrel_in, /* _xcoff_swap_ldrel_in */ - xcoff_swap_ldrel_out, /* _xcoff_swap_ldrel_out */ - - /* sizes */ - LDHDRSZ, /* _xcoff_ldhdrsz */ - LDSYMSZ, /* _xcoff_ldsymsz */ - LDRELSZ, /* _xcoff_ldrelsz */ - 12, /* _xcoff_function_descriptor_size */ - SMALL_AOUTSZ, /* _xcoff_small_aout_header_size */ + bfd_arch_powerpc, + bfd_mach_ppc, - /* versions */ - 1, /* _xcoff_ldhdr_version */ + /* Function pointers to xcoff specific swap routines. */ + xcoff_swap_ldhdr_in, + xcoff_swap_ldhdr_out, + xcoff_swap_ldsym_in, + xcoff_swap_ldsym_out, + xcoff_swap_ldrel_in, + xcoff_swap_ldrel_out, - /* xcoff vs xcoff64 putting symbol names */ - _bfd_xcoff_put_symbol_name, /* _xcoff_put_symbol_name */ - _bfd_xcoff_put_ldsymbol_name, /* _xcoff_put_ldsymbol_name */ + /* Sizes. */ + LDHDRSZ, + LDSYMSZ, + LDRELSZ, + 12, /* _xcoff_function_descriptor_size */ + SMALL_AOUTSZ, - &xcoff_dynamic_reloc, /* dynamic reloc howto */ + /* Versions. */ + 1, /* _xcoff_ldhdr_version */ - xcoff_create_csect_from_smclas, /* _xcoff_create_csect_from_smclas */ + _bfd_xcoff_put_symbol_name, + _bfd_xcoff_put_ldsymbol_name, + &xcoff_dynamic_reloc, + xcoff_create_csect_from_smclas, - /* lineno and reloc count overflow */ + /* Lineno and reloc count overflow. */ xcoff_is_lineno_count_overflow, xcoff_is_reloc_count_overflow, xcoff_loader_symbol_offset, xcoff_loader_reloc_offset, - /* glink */ + /* glink. */ &xcoff_glink_code[0], - (36), /* _xcoff_glink_size */ + 36, /* _xcoff_glink_size */ /* rtinit */ 0, /* _xcoff_rtinit_size */ - xcoff_generate_rtinit, /* _xcoff_generate_rtinit */ - + xcoff_generate_rtinit, }; /* The transfer vector that leads the outside world to all of the above. */ @@ -3707,36 +4292,35 @@ const bfd_target pmac_xcoff_vec = BFD_ENDIAN_BIG, /* data byte order is big */ BFD_ENDIAN_BIG, /* header byte order is big */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | DYNAMIC | - HAS_SYMS | HAS_LOCALS | WP_TEXT), + (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | DYNAMIC + | HAS_SYMS | HAS_LOCALS | WP_TEXT), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), 0, /* leading char */ '/', /* ar_pad_char */ - 15, /* ar_max_namelen??? FIXMEmgo */ + 15, /* ar_max_namelen */ /* data */ - bfd_getb64, /* bfd_getx64 */ - bfd_getb_signed_64, /* bfd_getx_signed_64 */ - bfd_putb64, /* bfd_putx64 */ - bfd_getb32, /* bfd_getx32 */ - bfd_getb_signed_32, /* bfd_getx_signed_32 */ - bfd_putb32, /* bfd_putx32 */ - bfd_getb16, /* bfd_getx16 */ - bfd_getb_signed_16, /* bfd_getx_signed_16 */ - bfd_putb16, /* bfd_putx16 */ + bfd_getb64, + bfd_getb_signed_64, + bfd_putb64, + bfd_getb32, + bfd_getb_signed_32, + bfd_putb32, + bfd_getb16, + bfd_getb_signed_16, + bfd_putb16, /* hdrs */ - bfd_getb64, /* bfd_h_getx64 */ - bfd_getb_signed_64, /* bfd_h_getx_signed_64 */ - bfd_putb64, /* bfd_h_putx64 */ - bfd_getb32, /* bfd_h_getx32 */ - bfd_getb_signed_32, /* bfd_h_getx_signed_32 */ - bfd_putb32, /* bfd_h_putx32 */ - bfd_getb16, /* bfd_h_getx16 */ - bfd_getb_signed_16, /* bfd_h_getx_signed_16 */ - bfd_putb16, /* bfd_h_putx16 */ + bfd_getb64, + bfd_getb_signed_64, + bfd_putb64, + bfd_getb32, + bfd_getb_signed_32, + bfd_putb32, + bfd_getb16, + bfd_getb_signed_16, + bfd_putb16, { /* bfd_check_format */ _bfd_dummy_target, @@ -3760,92 +4344,81 @@ const bfd_target pmac_xcoff_vec = }, /* Generic */ - bfd_true, /* _close_and_cleanup */ - bfd_true, /* _bfd_free_cached_info */ - coff_new_section_hook, /* _new_section_hook */ - _bfd_generic_get_section_contents, /* _bfd_get_section_contents */ - /* _bfd_get_section_contents_in_window */ + bfd_true, + bfd_true, + coff_new_section_hook, + _bfd_generic_get_section_contents, _bfd_generic_get_section_contents_in_window, /* Copy */ - _bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */ - /* _bfd_merge_private_bfd_data */ + _bfd_xcoff_copy_private_bfd_data, ((boolean (*) (bfd *, bfd *)) bfd_true), - /* _bfd_copy_pivate_section_data */ ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true), - /* _bfd_copy_private_symbol_data */ ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true), - ((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */ - ((boolean (*) (bfd *, void * )) bfd_true), /* _bfd_print_private_bfd_data */ + ((boolean (*) (bfd *, flagword)) bfd_true), + ((boolean (*) (bfd *, void * )) bfd_true), /* Core */ - coff_core_file_failing_command, /* _core_file_failing_command */ - coff_core_file_failing_signal, /* _core_file_failing_signal */ - /* _core_file_matches_executable_p */ + coff_core_file_failing_command, + coff_core_file_failing_signal, coff_core_file_matches_executable_p, /* Archive */ - _bfd_xcoff_slurp_armap, /* _slurp_armap */ - /* XCOFF archives do not have - anything which corresponds to - an extended name table. */ - bfd_false, /* _slurp_extended_name_table */ - /* _construct_extended_name_table */ + _bfd_xcoff_slurp_armap, + bfd_false, ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false), - bfd_dont_truncate_arname, /* _truncate_arname */ - _bfd_xcoff_write_armap, /* _write_armap */ - _bfd_xcoff_read_ar_hdr, /* _read_ar_hdr */ - _bfd_xcoff_openr_next_archived_file, /* _openr_next_archived_file */ - _bfd_generic_get_elt_at_index, /* _get_elt_at_index */ - _bfd_xcoff_stat_arch_elt, /* _generic_stat_arch_elt */ - /* XCOFF archives do not have - a timestamp. */ - bfd_true, /* _update_armap_timestamp */ + bfd_dont_truncate_arname, + _bfd_xcoff_write_armap, + _bfd_xcoff_read_ar_hdr, + _bfd_xcoff_openr_next_archived_file, + _bfd_generic_get_elt_at_index, + _bfd_xcoff_stat_arch_elt, + bfd_true, /* Symbols */ - coff_get_symtab_upper_bound, /* _get_symtab_upper_bound */ - coff_get_symtab, /* _get_symtab */ - coff_make_empty_symbol, /* _make_empty_symbol */ - coff_print_symbol, /* _print_symbol */ - coff_get_symbol_info, /* _get_symbol_info */ - _bfd_xcoff_is_local_label_name, /* _bfd_is_local_label_name */ - coff_get_lineno, /* _get_lineno */ - coff_find_nearest_line, /* _find_nearest_line */ - coff_bfd_make_debug_symbol, /* _bfd_make_debug_symbol */ - _bfd_generic_read_minisymbols, /* _read_minisymbols */ - _bfd_generic_minisymbol_to_symbol, /* _minsymbol_to_symbol */ + coff_get_symtab_upper_bound, + coff_get_symtab, + coff_make_empty_symbol, + coff_print_symbol, + coff_get_symbol_info, + _bfd_xcoff_is_local_label_name, + coff_get_lineno, + coff_find_nearest_line, + coff_bfd_make_debug_symbol, + _bfd_generic_read_minisymbols, + _bfd_generic_minisymbol_to_symbol, /* Reloc */ - coff_get_reloc_upper_bound, /* _get_reloc_upper_bound */ - coff_canonicalize_reloc, /* _cononicalize_reloc */ - _bfd_xcoff_reloc_type_lookup, /* _bfd_reloc_type_lookup */ + coff_get_reloc_upper_bound, + coff_canonicalize_reloc, + _bfd_xcoff_reloc_type_lookup, /* Write */ - coff_set_arch_mach, /* _set_arch_mach */ - coff_set_section_contents, /* _set_section_contents */ + coff_set_arch_mach, + coff_set_section_contents, /* Link */ - _bfd_xcoff_sizeof_headers, /* _sizeof_headers */ - /* _bfd_get_relocated_section_contents */ + _bfd_xcoff_sizeof_headers, bfd_generic_get_relocated_section_contents, - bfd_generic_relax_section, /* _bfd_relax_section */ - _bfd_xcoff_bfd_link_hash_table_create, /* _bfd_link_hash_table_create */ - _bfd_xcoff_bfd_link_add_symbols, /* _bfd_link_add_symbols */ - _bfd_xcoff_bfd_final_link, /* _bfd_filnal_link */ - _bfd_generic_link_split_section, /* _bfd_link_split_section */ - bfd_generic_gc_sections, /* _bfd_gc_sections */ - bfd_generic_merge_sections, /* _bfd_merge_sections */ + bfd_generic_relax_section, + _bfd_xcoff_bfd_link_hash_table_create, + _bfd_generic_link_hash_table_free, + _bfd_xcoff_bfd_link_add_symbols, + _bfd_generic_link_just_syms, + _bfd_xcoff_bfd_final_link, + _bfd_generic_link_split_section, + bfd_generic_gc_sections, + bfd_generic_merge_sections, + bfd_generic_discard_group, /* Dynamic */ - /* _get_dynamic_symtab_upper_bound */ _bfd_xcoff_get_dynamic_symtab_upper_bound, - _bfd_xcoff_canonicalize_dynamic_symtab, /* _cononicalize_dynamic_symtab */ - _bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */ - _bfd_xcoff_canonicalize_dynamic_reloc, /* _cononicalize_dynamic_reloc */ + _bfd_xcoff_canonicalize_dynamic_symtab, + _bfd_xcoff_get_dynamic_reloc_upper_bound, + _bfd_xcoff_canonicalize_dynamic_reloc, /* Opposite endian version, none exists */ NULL, - /* back end data */ (void *) &bfd_pmac_xcoff_backend_data, }; diff --git a/contrib/binutils/bfd/coff64-rs6000.c b/contrib/binutils/bfd/coff64-rs6000.c index 1e9714f..9372f6b 100644 --- a/contrib/binutils/bfd/coff64-rs6000.c +++ b/contrib/binutils/bfd/coff64-rs6000.c @@ -1,24 +1,24 @@ /* BFD back-end for IBM RS/6000 "XCOFF64" files. - Copyright 2000, 2001 + Copyright 2000, 2001, 2002 Free Software Foundation, Inc. Written Clinton Popetz. Contributed by Cygnus Support. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -84,6 +84,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ static void _bfd_xcoff64_swap_lineno_in PARAMS ((bfd *, PTR, PTR)); static unsigned int _bfd_xcoff64_swap_lineno_out PARAMS ((bfd *, PTR, PTR)); +static boolean _bfd_xcoff64_put_symbol_name + PARAMS ((bfd *, struct bfd_strtab_hash *, struct internal_syment *, + const char *)); static boolean _bfd_xcoff64_put_ldsymbol_name PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *, const char *)); @@ -93,6 +96,8 @@ static void _bfd_xcoff64_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR)); static unsigned int _bfd_xcoff64_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR)); +static void xcoff64_swap_reloc_in PARAMS ((bfd *, PTR, PTR)); +static unsigned int xcoff64_swap_reloc_out PARAMS ((bfd *, PTR, PTR)); extern boolean _bfd_xcoff_mkobject PARAMS ((bfd *)); extern boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *)); extern boolean _bfd_xcoff_is_local_label_name PARAMS ((bfd *, const char *)); @@ -129,8 +134,8 @@ static void xcoff64_swap_ldrel_out static boolean xcoff64_write_object_contents PARAMS ((bfd *)); static boolean xcoff64_ppc_relocate_section PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, - struct internal_reloc *, struct internal_syment *, - asection **sections)); + struct internal_reloc *, struct internal_syment *, + asection **)); static boolean xcoff64_slurp_armap PARAMS ((bfd *)); static const bfd_target *xcoff64_archive_p PARAMS ((bfd *)); static bfd *xcoff64_openr_next_archived_file PARAMS ((bfd *, bfd *)); @@ -143,11 +148,47 @@ static bfd_vma xcoff64_loader_symbol_offset PARAMS ((bfd *, struct internal_ldhdr *)); static bfd_vma xcoff64_loader_reloc_offset PARAMS ((bfd *, struct internal_ldhdr *)); -static boolean xcoff64_generate_rtinit - PARAMS((bfd *, const char *, const char *)); +static boolean xcoff64_generate_rtinit + PARAMS ((bfd *, const char *, const char *, boolean)); +static boolean xcoff64_bad_format_hook PARAMS ((bfd *, PTR )); + +/* Relocation functions */ +static boolean xcoff64_reloc_type_br PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); +boolean (*xcoff64_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION]) + PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)) = +{ + xcoff_reloc_type_pos, /* R_POS (0x00) */ + xcoff_reloc_type_neg, /* R_NEG (0x01) */ + xcoff_reloc_type_rel, /* R_REL (0x02) */ + xcoff_reloc_type_toc, /* R_TOC (0x03) */ + xcoff_reloc_type_fail, /* R_RTB (0x04) */ + xcoff_reloc_type_toc, /* R_GL (0x05) */ + xcoff_reloc_type_toc, /* R_TCL (0x06) */ + xcoff_reloc_type_fail, /* (0x07) */ + xcoff_reloc_type_ba, /* R_BA (0x08) */ + xcoff_reloc_type_fail, /* (0x09) */ + xcoff64_reloc_type_br, /* R_BR (0x0a) */ + xcoff_reloc_type_fail, /* (0x0b) */ + xcoff_reloc_type_pos, /* R_RL (0x0c) */ + xcoff_reloc_type_pos, /* R_RLA (0x0d) */ + xcoff_reloc_type_fail, /* (0x0e) */ + xcoff_reloc_type_noop, /* R_REF (0x0f) */ + xcoff_reloc_type_fail, /* (0x10) */ + xcoff_reloc_type_fail, /* (0x11) */ + xcoff_reloc_type_toc, /* R_TRL (0x12) */ + xcoff_reloc_type_toc, /* R_TRLA (0x13) */ + xcoff_reloc_type_fail, /* R_RRTBI (0x14) */ + xcoff_reloc_type_fail, /* R_RRTBA (0x15) */ + xcoff_reloc_type_ba, /* R_CAI (0x16) */ + xcoff_reloc_type_crel, /* R_CREL (0x17) */ + xcoff_reloc_type_ba, /* R_RBA (0x18) */ + xcoff_reloc_type_ba, /* R_RBAC (0x19) */ + xcoff64_reloc_type_br, /* R_RBR (0x1a) */ + xcoff_reloc_type_ba, /* R_RBRC (0x1b) */ +}; -/* coffcode.h needs these to be defined */ +/* coffcode.h needs these to be defined. */ /* Internalcoff.h and coffcode.h modify themselves based on these flags. */ #define XCOFF64 #define RS6000COFF_C 1 @@ -171,8 +212,9 @@ static boolean xcoff64_generate_rtinit #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name #define coff_bfd_reloc_type_lookup xcoff64_reloc_type_lookup #ifdef AIX_CORE -extern const bfd_target * rs6000coff_core_p (); -extern boolean rs6000coff_core_file_matches_executable_p (); +extern const bfd_target * rs6000coff_core_p PARAMS ((bfd *abfd)); +extern boolean rs6000coff_core_file_matches_executable_p + PARAMS((bfd *cbfd, bfd *ebfd)); extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd)); extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd)); #define CORE_FILE_P rs6000coff_core_p @@ -195,7 +237,9 @@ extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd)); #define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out #define coff_SWAP_aux_in _bfd_xcoff64_swap_aux_in #define coff_SWAP_aux_out _bfd_xcoff64_swap_aux_out - +#define coff_swap_reloc_in xcoff64_swap_reloc_in +#define coff_swap_reloc_out xcoff64_swap_reloc_out +#define NO_COFF_RELOCS #include "coffcode.h" @@ -289,7 +333,7 @@ _bfd_xcoff64_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) switch (class) { case C_FILE: - if (ext->x_file.x_n.x_zeroes == 0) + if (ext->x_file.x_n.x_zeroes[0] == 0) { in->x_file.x_n.x_zeroes = 0; in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset); @@ -380,7 +424,7 @@ _bfd_xcoff64_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) switch (class) { case C_FILE: - if (ext->x_file.x_n.x_zeroes == 0) + if (in->x_file.x_n.x_zeroes == 0) { H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes); H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset); @@ -453,9 +497,12 @@ _bfd_xcoff64_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) } static boolean -_bfd_xcoff64_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab, - struct internal_syment *sym, - const char *name) { +_bfd_xcoff64_put_symbol_name (abfd, strtab, sym, name) + bfd *abfd; + struct bfd_strtab_hash *strtab; + struct internal_syment *sym; + const char *name; +{ boolean hash; bfd_size_type indx; @@ -482,7 +529,6 @@ _bfd_xcoff64_put_ldsymbol_name (abfd, ldinfo, ldsym, name) struct internal_ldsym *ldsym; const char *name; { - size_t len; len = strlen (name); @@ -608,6 +654,40 @@ xcoff64_swap_ldsym_out (abfd, src, d) bfd_put_32 (abfd, src->l_parm, dst->l_parm); } +static void +xcoff64_swap_reloc_in (abfd, s, d) + bfd *abfd; + PTR s; + PTR d; +{ + struct external_reloc *src = (struct external_reloc *) s; + struct internal_reloc *dst = (struct internal_reloc *) d; + + memset (dst, 0, sizeof (struct internal_reloc)); + + dst->r_vaddr = bfd_get_64 (abfd, src->r_vaddr); + dst->r_symndx = bfd_get_32 (abfd, src->r_symndx); + dst->r_size = bfd_get_8 (abfd, src->r_size); + dst->r_type = bfd_get_8 (abfd, src->r_type); +} + +static unsigned int +xcoff64_swap_reloc_out (abfd, s, d) + bfd *abfd; + PTR s; + PTR d; +{ + struct internal_reloc *src = (struct internal_reloc *) s; + struct external_reloc *dst = (struct external_reloc *) d; + + bfd_put_64 (abfd, src->r_vaddr, dst->r_vaddr); + bfd_put_32 (abfd, src->r_symndx, dst->r_symndx); + bfd_put_8 (abfd, src->r_type, dst->r_type); + bfd_put_8 (abfd, src->r_size, dst->r_size); + + return bfd_coff_relsz (abfd); +} + /* Swap in the ldrel structure. */ static void @@ -662,13 +742,13 @@ xcoff64_write_object_contents (abfd) bfd_set_error (bfd_error_system_call); - if (abfd->output_has_begun == false) + if (! abfd->output_has_begun) { if (! bfd_coff_compute_section_file_positions (abfd)) return false; } - /* Work out the size of the reloc and linno areas */ + /* Work out the size of the reloc and linno areas. */ reloc_base = obj_relocbase (abfd); for (current = abfd->sections; current != NULL; current = current->next) @@ -677,12 +757,12 @@ xcoff64_write_object_contents (abfd) lineno_base = reloc_base + reloc_size; /* Make a pass through the symbol table to count line number entries and - put them into the correct asections */ + put them into the correct asections. */ lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd); sym_base = lineno_base + lnno_size; - /* Indicate in each section->line_filepos its actual file address */ + /* Indicate in each section->line_filepos its actual file address. */ for (current = abfd->sections; current != NULL; current = current->next) { if (current->lineno_count) @@ -792,7 +872,7 @@ xcoff64_write_object_contents (abfd) if (abfd->flags & EXEC_P) internal_f.f_flags |= F_EXEC; - /* FIXME: this is wrong for PPC_PE! */ + /* FIXME: this is wrong for PPC_PE! */ if (bfd_little_endian (abfd)) internal_f.f_flags |= F_AR32WR; else @@ -805,19 +885,17 @@ xcoff64_write_object_contents (abfd) memset (&internal_a, 0, sizeof internal_a); - - /* This can only be called from the xcoff64 backend so the magic # - must be for xcoff64. */ - internal_f.f_magic = 0757; - - internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC : - (abfd->flags & WP_TEXT) ? RS6K_AOUTHDR_NMAGIC : - RS6K_AOUTHDR_OMAGIC; + internal_f.f_magic = bfd_xcoff_magic_number (abfd); + internal_a.magic = (abfd->flags & D_PAGED + ? RS6K_AOUTHDR_ZMAGIC + : (abfd->flags & WP_TEXT + ? RS6K_AOUTHDR_NMAGIC + : RS6K_AOUTHDR_OMAGIC)); /* FIXME: Does anybody ever set this to another value? */ internal_a.vstamp = 0; - /* Now should write relocs, strings, syms */ + /* Now should write relocs, strings, syms. */ obj_sym_filepos (abfd) = sym_base; internal_f.f_symptr = 0; @@ -990,11 +1068,88 @@ xcoff64_write_object_contents (abfd) return true; } -/* This is the relocation function for the RS/6000/POWER/PowerPC. - This is currently the only processor which uses XCOFF; I hope that - will never change. */ +static boolean +xcoff64_reloc_type_br (input_bfd, input_section, output_bfd, rel, sym, howto, + val, addend, relocation, contents) + bfd *input_bfd; + asection *input_section; + bfd *output_bfd ATTRIBUTE_UNUSED; + struct internal_reloc *rel; + struct internal_syment *sym ATTRIBUTE_UNUSED; + struct reloc_howto_struct *howto; + bfd_vma val; + bfd_vma addend; + bfd_vma *relocation; + bfd_byte *contents; +{ + struct xcoff_link_hash_entry *h; -static boolean + if (0 > rel->r_symndx) + return false; + + h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx]; + + /* If we see an R_BR or R_RBR reloc which is jumping to global + linkage code, and it is followed by an appropriate cror nop + instruction, we replace the cror with ld r2,40(r1). This + restores the TOC after the glink code. Contrariwise, if the + call is followed by a ld r2,40(r1), but the call is not + going to global linkage code, we can replace the load with a + cror. */ + if (NULL != h + && bfd_link_hash_defined == h->root.type + && (rel->r_vaddr - input_section->vma + 8 + <= input_section->_cooked_size)) + { + bfd_byte *pnext; + unsigned long next; + + pnext = contents + (rel->r_vaddr - input_section->vma) + 4; + next = bfd_get_32 (input_bfd, pnext); + + /* The _ptrgl function is magic. It is used by the AIX compiler to call + a function through a pointer. */ + if (h->smclas == XMC_GL || strcmp (h->root.root.string, "._ptrgl") == 0) + { + if (next == 0x4def7b82 /* cror 15,15,15 */ + || next == 0x4ffffb82 /* cror 31,31,31 */ + || next == 0x60000000) /* ori r0,r0,0 */ + bfd_put_32 (input_bfd, 0xe8410028, pnext); /* ld r2,40(r1) */ + } + else + { + if (next == 0xe8410028) /* ld r2,40(r1) */ + bfd_put_32 (input_bfd, 0x60000000, pnext); /* ori r0,r0,0 */ + } + } + else if (NULL != h && bfd_link_hash_undefined == h->root.type) + { + /* Normally, this relocation is against a defined symbol. In the + case where this is a partial link and the output section offset + is greater than 2^25, the linker will return an invalid error + message that the relocation has been truncated. Yes it has been + truncated but no it not important. For this case, disable the + overflow checking. */ + howto->complain_on_overflow = complain_overflow_dont; + } + + howto->pc_relative = true; + howto->src_mask &= ~3; + howto->dst_mask = howto->src_mask; + + /* A PC relative reloc includes the section address. */ + addend += input_section->vma; + + *relocation = val + addend; + *relocation -= (input_section->output_section->vma + + input_section->output_offset); + return true; +} + +/* This is the relocation function for the PowerPC64. + See xcoff_ppc_relocation_section for more information. */ + +boolean xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, input_section, contents, relocs, syms, sections) @@ -1020,7 +1175,10 @@ xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, bfd_vma addend; bfd_vma val; struct reloc_howto_struct howto; - bfd_reloc_status_type rstat; + bfd_vma relocation; + bfd_vma value_to_relocate; + bfd_vma address; + bfd_byte *location; /* Relocation type R_REF is a special relocation type which is merely used to prevent garbage collection from occurring for @@ -1028,65 +1186,38 @@ xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, if (rel->r_type == R_REF) continue; - symndx = rel->r_symndx; - - if (symndx == -1) - { - h = NULL; - sym = NULL; - addend = 0; - } - else - { - h = obj_xcoff_sym_hashes (input_bfd)[symndx]; - sym = syms + symndx; - addend = - sym->n_value; - } - - /* We build the howto information on the fly. */ - + /* howto */ howto.type = rel->r_type; howto.rightshift = 0; - howto.size = 4; howto.bitsize = (rel->r_size & 0x3f) + 1; + howto.size = howto.bitsize > 16 ? (howto.bitsize > 32 ? 4 : 2) : 1; howto.pc_relative = false; howto.bitpos = 0; - if ((rel->r_size & 0x80) != 0) - howto.complain_on_overflow = complain_overflow_signed; - else - howto.complain_on_overflow = complain_overflow_bitfield; + howto.complain_on_overflow = (rel->r_size & 0x80 + ? complain_overflow_signed + : complain_overflow_bitfield); howto.special_function = NULL; howto.name = "internal"; howto.partial_inplace = true; - - if (howto.bitsize == 64) - { - howto.src_mask = howto.dst_mask = MINUS_ONE; - } - else if (howto.bitsize == 32) - { - howto.src_mask = howto.dst_mask = 0xffffffff; - } - else - { - howto.src_mask = howto.dst_mask = (1 << howto.bitsize) - 1; - if (howto.bitsize == 16) - howto.size = 1; - } + howto.src_mask = howto.dst_mask = N_ONES(howto.bitsize); howto.pcrel_offset = false; + /* symbol */ val = 0; + addend = 0; + h = NULL; + sym = NULL; + symndx = rel->r_symndx; - if (h == NULL) + if (-1 != symndx) { asection *sec; - - if (symndx == -1) - { - sec = bfd_abs_section_ptr; - val = 0; - } - else + + h = obj_xcoff_sym_hashes (input_bfd)[symndx]; + sym = syms + symndx; + addend = - sym->n_value; + + if (NULL == h) { sec = sections[symndx]; /* Hack to make sure we use the right TOC anchor value @@ -1099,270 +1230,116 @@ xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, + sec->output_offset + sym->n_value - sec->vma); - } - - } - else - { - - if (h->root.type == bfd_link_hash_defined - || h->root.type == bfd_link_hash_defweak) - { - asection *sec; - - sec = h->root.u.def.section; - val = (h->root.u.def.value - + sec->output_section->vma - + sec->output_offset); - - } - else if (h->root.type == bfd_link_hash_common) - { - asection *sec; - - sec = h->root.u.c.p->section; - val = (sec->output_section->vma - + sec->output_offset); - } - else if ((h->flags & XCOFF_DEF_DYNAMIC) != 0 - || (h->flags & XCOFF_IMPORT) != 0) + } + else { - /* Every symbol in a shared object is defined somewhere. */ - val = 0; - } - else if (! info->relocateable) - { - if (! ((*info->callbacks->undefined_symbol) - (info, h->root.root.string, input_bfd, input_section, - rel->r_vaddr - input_section->vma, true))) - return false; - - /* Don't try to process the reloc. It can't help, and - it may generate another error. */ - continue; - } - } - - /* I took the relocation type definitions from two documents: - the PowerPC AIX Version 4 Application Binary Interface, First - Edition (April 1992), and the PowerOpen ABI, Big-Endian - 32-Bit Hardware Implementation (June 30, 1994). Differences - between the documents are noted below. */ - - switch (rel->r_type) - { - case R_RTB: - case R_RRTBI: - case R_RRTBA: - /* These relocs are defined by the PowerPC ABI to be - relative branches which use half of the difference - between the symbol and the program counter. I can't - quite figure out when this is useful. These relocs are - not defined by the PowerOpen ABI. */ - default: - (*_bfd_error_handler) - (_("%s: unsupported relocation type 0x%02x"), - bfd_archive_filename (input_bfd), (unsigned int) rel->r_type); - bfd_set_error (bfd_error_bad_value); - return false; - case R_POS: - /* Simple positive relocation. */ - break; - case R_NEG: - /* Simple negative relocation. */ - val = - val; - break; - case R_REL: - /* Simple PC relative relocation. */ - howto.pc_relative = true; - break; - case R_TOC: - /* TOC relative relocation. The value in the instruction in - the input file is the offset from the input file TOC to - the desired location. We want the offset from the final - TOC to the desired location. We have: - isym = iTOC + in - iinsn = in + o - osym = oTOC + on - oinsn = on + o - so we must change insn by on - in. - */ - case R_GL: - /* Global linkage relocation. The value of this relocation - is the address of the entry in the TOC section. */ - case R_TCL: - /* Local object TOC address. I can't figure out the - difference between this and case R_GL. */ - case R_TRL: - /* TOC relative relocation. A TOC relative load instruction - which may be changed to a load address instruction. - FIXME: We don't currently implement this optimization. */ - case R_TRLA: - /* TOC relative relocation. This is a TOC relative load - address instruction which may be changed to a load - instruction. FIXME: I don't know if this is the correct - implementation. */ - if (h != NULL && h->smclas != XMC_TD) - { - if (h->toc_section == NULL) + if (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + { + sec = h->root.u.def.section; + val = (h->root.u.def.value + + sec->output_section->vma + + sec->output_offset); + } + else if (h->root.type == bfd_link_hash_common) { - (*_bfd_error_handler) - (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"), - bfd_archive_filename (input_bfd), rel->r_vaddr, - h->root.root.string); - bfd_set_error (bfd_error_bad_value); - return false; + sec = h->root.u.c.p->section; + val = (sec->output_section->vma + + sec->output_offset); + } + else if ((0 == (h->flags & (XCOFF_DEF_DYNAMIC | XCOFF_IMPORT))) + && ! info->relocateable) + { + if (! ((*info->callbacks->undefined_symbol) + (info, h->root.root.string, input_bfd, input_section, + rel->r_vaddr - input_section->vma, true))) + return false; + + /* Don't try to process the reloc. It can't help, and + it may generate another error. */ + continue; } - - BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0); - val = (h->toc_section->output_section->vma - + h->toc_section->output_offset); } - - val = ((val - xcoff_data (output_bfd)->toc) - - (sym->n_value - xcoff_data (input_bfd)->toc)); - - addend = 0; - break; - case R_BA: - /* Absolute branch. We don't want to mess with the lower - two bits of the instruction. */ - case R_CAI: - /* The PowerPC ABI defines this as an absolute call which - may be modified to become a relative call. The PowerOpen - ABI does not define this relocation type. */ - case R_RBA: - /* Absolute branch which may be modified to become a - relative branch. */ - case R_RBAC: - /* The PowerPC ABI defines this as an absolute branch to a - fixed address which may be modified to an absolute branch - to a symbol. The PowerOpen ABI does not define this - relocation type. */ - case R_RBRC: - /* The PowerPC ABI defines this as an absolute branch to a - fixed address which may be modified to a relative branch. - The PowerOpen ABI does not define this relocation type. */ - howto.src_mask &= ~3; - howto.dst_mask = howto.src_mask; - break; - case R_BR: - /* Relative branch. We don't want to mess with the lower - two bits of the instruction. */ - case R_CREL: - /* The PowerPC ABI defines this as a relative call which may - be modified to become an absolute call. The PowerOpen - ABI does not define this relocation type. */ - case R_RBR: - /* A relative branch which may be modified to become an - absolute branch. FIXME: We don't implement this, - although we should for symbols of storage mapping class - XMC_XO. */ - howto.pc_relative = true; - howto.src_mask &= ~3; - howto.dst_mask = howto.src_mask; - howto.size = 2; - howto.complain_on_overflow = complain_overflow_bitfield; - break; - case R_RL: - /* The PowerPC AIX ABI describes this as a load which may be - changed to a load address. The PowerOpen ABI says this - is the same as case R_POS. */ - break; - case R_RLA: - /* The PowerPC AIX ABI describes this as a load address - which may be changed to a load. The PowerOpen ABI says - this is the same as R_POS. */ - break; } - - /* If we see an R_BR or R_RBR reloc which is jumping to global - linkage code, and it is followed by an appropriate cror nop - instruction, we replace the cror with ld r2,40(r1). This - restores the TOC after the glink code. Contrariwise, if the - call is followed by a ld r2,40(r1), but the call is not - going to global linkage code, we can replace the load with a - cror. */ - if ((rel->r_type == R_BR || rel->r_type == R_RBR) - && h != NULL - && h->root.type == bfd_link_hash_defined - && (rel->r_vaddr - input_section->vma + 8 - <= input_section->_cooked_size)) + + if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION + || ((*xcoff64_calculate_relocation[rel->r_type]) + (input_bfd, input_section, output_bfd, rel, sym, &howto, val, + addend, &relocation, contents))) + return false; + + /* address */ + address = rel->r_vaddr - input_section->vma; + location = contents + address; + + if (address > input_section->_raw_size) + abort(); + + /* Get the value we are going to relocate. */ + if (1 == howto.size) + value_to_relocate = bfd_get_16 (input_bfd, location); + else if (2 == howto.size) + value_to_relocate = bfd_get_32 (input_bfd, location); + else + value_to_relocate = bfd_get_64 (input_bfd, location); + + /* overflow. + + FIXME: We may drop bits during the addition + which we don't check for. We must either check at every single + operation, which would be tedious, or we must do the computations + in a type larger than bfd_vma, which would be inefficient. */ + + if ((unsigned int) howto.complain_on_overflow + >= XCOFF_MAX_COMPLAIN_OVERFLOW) + abort(); + + if (((*xcoff_complain_overflow[howto.complain_on_overflow]) + (input_bfd, value_to_relocate, relocation, &howto))) { - bfd_byte *pnext; - unsigned long next; - - pnext = contents + (rel->r_vaddr - input_section->vma) + 4; - next = bfd_get_32 (input_bfd, pnext); - - - /* The _ptrgl function is magic. It is used by the AIX - * compiler to call a function through a pointer. - * - * special case XMC_GL, global linkage - */ - if (h->smclas == XMC_GL - || strcmp (h->root.root.string, "._ptrgl") == 0) + const char *name; + char buf[SYMNMLEN + 1]; + char reloc_type_name[10]; + + if (symndx == -1) { - if (next == 0x4def7b82 /* cror 15,15,15 */ - || next == 0x4ffffb82 /* cror 31,31,31 */ - || next == 0x60000000 /* ori r0,r0,0 */) - bfd_put_32 (input_bfd, (bfd_vma) 0xe8410028 /* ld r2,40(r1) */, - pnext); - } - else + name = "*ABS*"; + } + else if (h != NULL) { - if (next == 0xe8410028 /* ld r2,40(r1) */) - bfd_put_32 (input_bfd, (bfd_vma) 0x60000000 /* ori r0,r0,0 */, - pnext); + name = h->root.root.string; + } + else + { + name = _bfd_coff_internal_syment_name (input_bfd, sym, buf); + if (name == NULL) + name = "UNKNOWN"; } + sprintf (reloc_type_name, "0x%02x", rel->r_type); + + if (! ((*info->callbacks->reloc_overflow) + (info, name, reloc_type_name, (bfd_vma) 0, input_bfd, + input_section, rel->r_vaddr - input_section->vma))) + return false; } - /* A PC relative reloc includes the section address. */ - if (howto.pc_relative) - addend += input_section->vma; - - rstat = _bfd_final_link_relocate (&howto, input_bfd, input_section, - contents, - rel->r_vaddr - input_section->vma, - val, addend); - - switch (rstat) - { - default: - abort (); - case bfd_reloc_ok: - break; - case bfd_reloc_overflow: - { - const char *name; - char buf[SYMNMLEN + 1]; - char howto_name[10]; - - if (symndx == -1) - name = "*ABS*"; - else if (h != NULL) - name = h->root.root.string; - else - { - name = _bfd_coff_internal_syment_name (input_bfd, sym, buf); - if (name == NULL) - return false; - } - sprintf (howto_name, "0x%02x", rel->r_type); - - if (! ((*info->callbacks->reloc_overflow) - (info, name, howto_name, (bfd_vma) 0, input_bfd, - input_section, rel->r_vaddr - input_section->vma))) - return false; - } - } + /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE. */ + value_to_relocate = ((value_to_relocate & ~howto.dst_mask) + | (((value_to_relocate & howto.src_mask) + + relocation) & howto.dst_mask)); + + /* Put the value back in the object file. */ + if (1 == howto.size) + bfd_put_16 (input_bfd, value_to_relocate, location); + else if (2 == howto.size) + bfd_put_32 (input_bfd, value_to_relocate, location); + else + bfd_put_64 (input_bfd, value_to_relocate, location); + } - return true; } - /* The XCOFF reloc table. Actually, XCOFF relocations specify the bitsize and whether they are signed or not, along with a @@ -1370,11 +1347,10 @@ xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, different algorithms for putting in the reloc. Many of these relocs need special_function entries, which I have not written. */ - reloc_howto_type xcoff64_howto_table[] = { /* Standard 64 bit relocation. */ - HOWTO (0, /* type */ + HOWTO (R_POS, /* type */ 0, /* rightshift */ 4, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ @@ -1382,14 +1358,14 @@ reloc_howto_type xcoff64_howto_table[] = 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ 0, /* special_function */ - "R_POS", /* name */ + "R_POS_64", /* name */ true, /* partial_inplace */ MINUS_ONE, /* src_mask */ MINUS_ONE, /* dst_mask */ false), /* pcrel_offset */ /* 64 bit relocation, but store negative value. */ - HOWTO (1, /* type */ + HOWTO (R_NEG, /* type */ 0, /* rightshift */ -4, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ @@ -1404,7 +1380,7 @@ reloc_howto_type xcoff64_howto_table[] = false), /* pcrel_offset */ /* 32 bit PC relative relocation. */ - HOWTO (2, /* type */ + HOWTO (R_REL, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -1419,7 +1395,7 @@ reloc_howto_type xcoff64_howto_table[] = false), /* pcrel_offset */ /* 16 bit TOC relative relocation. */ - HOWTO (3, /* type */ + HOWTO (R_TOC, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ @@ -1433,8 +1409,8 @@ reloc_howto_type xcoff64_howto_table[] = 0xffff, /* dst_mask */ false), /* pcrel_offset */ - /* I don't really know what this is. */ - HOWTO (4, /* type */ + /* I don't really know what this is. */ + HOWTO (R_RTB, /* type */ 1, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -1449,9 +1425,9 @@ reloc_howto_type xcoff64_howto_table[] = false), /* pcrel_offset */ /* External TOC relative symbol. */ - HOWTO (5, /* type */ + HOWTO (R_GL, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -1464,9 +1440,9 @@ reloc_howto_type xcoff64_howto_table[] = false), /* pcrel_offset */ /* Local TOC relative symbol. */ - HOWTO (6, /* type */ + HOWTO (R_TCL, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -1481,7 +1457,7 @@ reloc_howto_type xcoff64_howto_table[] = EMPTY_HOWTO (7), /* Non modifiable absolute branch. */ - HOWTO (8, /* type */ + HOWTO (R_BA, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ @@ -1489,7 +1465,7 @@ reloc_howto_type xcoff64_howto_table[] = 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ 0, /* special_function */ - "R_BA", /* name */ + "R_BA_26", /* name */ true, /* partial_inplace */ 0x3fffffc, /* src_mask */ 0x3fffffc, /* dst_mask */ @@ -1498,7 +1474,7 @@ reloc_howto_type xcoff64_howto_table[] = EMPTY_HOWTO (9), /* Non modifiable relative branch. */ - HOWTO (0xa, /* type */ + HOWTO (R_BR, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ @@ -1515,9 +1491,9 @@ reloc_howto_type xcoff64_howto_table[] = EMPTY_HOWTO (0xb), /* Indirect load. */ - HOWTO (0xc, /* type */ + HOWTO (R_RL, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -1530,9 +1506,9 @@ reloc_howto_type xcoff64_howto_table[] = false), /* pcrel_offset */ /* Load address. */ - HOWTO (0xd, /* type */ + HOWTO (R_RLA, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -1546,14 +1522,14 @@ reloc_howto_type xcoff64_howto_table[] = EMPTY_HOWTO (0xe), - /* Non-relocating reference. */ - HOWTO (0xf, /* type */ + /* Non-relocating reference. */ + HOWTO (R_REF, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ + complain_overflow_dont, /* complain_on_overflow */ 0, /* special_function */ "R_REF", /* name */ false, /* partial_inplace */ @@ -1565,9 +1541,9 @@ reloc_howto_type xcoff64_howto_table[] = EMPTY_HOWTO (0x11), /* TOC relative indirect load. */ - HOWTO (0x12, /* type */ + HOWTO (R_TRL, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -1580,9 +1556,9 @@ reloc_howto_type xcoff64_howto_table[] = false), /* pcrel_offset */ /* TOC relative load address. */ - HOWTO (0x13, /* type */ + HOWTO (R_TRLA, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -1595,7 +1571,7 @@ reloc_howto_type xcoff64_howto_table[] = false), /* pcrel_offset */ /* Modifiable relative branch. */ - HOWTO (0x14, /* type */ + HOWTO (R_RRTBI, /* type */ 1, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -1610,7 +1586,7 @@ reloc_howto_type xcoff64_howto_table[] = false), /* pcrel_offset */ /* Modifiable absolute branch. */ - HOWTO (0x15, /* type */ + HOWTO (R_RRTBA, /* type */ 1, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -1625,9 +1601,9 @@ reloc_howto_type xcoff64_howto_table[] = false), /* pcrel_offset */ /* Modifiable call absolute indirect. */ - HOWTO (0x16, /* type */ + HOWTO (R_CAI, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -1639,10 +1615,10 @@ reloc_howto_type xcoff64_howto_table[] = 0xffff, /* dst_mask */ false), /* pcrel_offset */ - /* Modifiable call relative. */ - HOWTO (0x17, /* type */ + /* Modifiable call relative. */ + HOWTO (R_CREL, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -1655,7 +1631,7 @@ reloc_howto_type xcoff64_howto_table[] = false), /* pcrel_offset */ /* Modifiable branch absolute. */ - HOWTO (0x18, /* type */ + HOWTO (R_RBA, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ @@ -1665,12 +1641,12 @@ reloc_howto_type xcoff64_howto_table[] = 0, /* special_function */ "R_RBA", /* name */ true, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ + 0x03fffffc, /* src_mask */ + 0x03fffffc, /* dst_mask */ false), /* pcrel_offset */ /* Modifiable branch absolute. */ - HOWTO (0x19, /* type */ + HOWTO (R_RBAC, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ @@ -1680,12 +1656,12 @@ reloc_howto_type xcoff64_howto_table[] = 0, /* special_function */ "R_RBAC", /* name */ true, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ false), /* pcrel_offset */ /* Modifiable branch relative. */ - HOWTO (0x1a, /* type */ + HOWTO (R_RBR, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ @@ -1693,16 +1669,16 @@ reloc_howto_type xcoff64_howto_table[] = 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ 0, /* special_function */ - "R_RBR", /* name */ + "R_RBR_26", /* name */ true, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ + 0x03fffffc, /* src_mask */ + 0x03fffffc, /* dst_mask */ false), /* pcrel_offset */ /* Modifiable branch absolute. */ - HOWTO (0x1b, /* type */ + HOWTO (R_RBRC, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -1714,19 +1690,65 @@ reloc_howto_type xcoff64_howto_table[] = 0xffff, /* dst_mask */ false), /* pcrel_offset */ - HOWTO (0, /* type */ + HOWTO (R_POS, /* type */ 0, /* rightshift */ - 4, /* size (0 = byte, 1 = short, 2 = long) */ - 64, /* bitsize */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ 0, /* special_function */ - "R_POS", /* name */ + "R_POS_32", /* name */ true, /* partial_inplace */ - MINUS_ONE, /* src_mask */ - MINUS_ONE, /* dst_mask */ - false) /* pcrel_offset */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* 16 bit Non modifiable absolute branch. */ + HOWTO (R_BA, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + 0, /* special_function */ + "R_BA_16", /* name */ + true, /* partial_inplace */ + 0xfffc, /* src_mask */ + 0xfffc, /* dst_mask */ + false), /* pcrel_offset */ + + /* Modifiable branch relative. */ + HOWTO (R_RBR, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "R_RBR_16", /* name */ + true, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* Modifiable branch absolute. */ + HOWTO (R_RBA, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + 0, /* special_function */ + "R_RBA_16", /* name */ + true, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + }; void @@ -1734,15 +1756,29 @@ xcoff64_rtype2howto (relent, internal) arelent *relent; struct internal_reloc *internal; { - relent->howto = xcoff64_howto_table + internal->r_type; - - /* Check for relocs we don't know of. */ - if (internal->r_type - >= sizeof (xcoff64_howto_table) / sizeof (xcoff64_howto_table[0])) - abort (); - if (internal->r_type != relent->howto->type) + if (internal->r_type > R_RBRC) abort (); + /* Default howto layout works most of the time */ + relent->howto = &xcoff64_howto_table[internal->r_type]; + + /* Special case some 16 bit reoloc */ + if (15 == (internal->r_size & 0x3f)) + { + if (R_BA == internal->r_type) + relent->howto = &xcoff64_howto_table[0x1d]; + else if (R_RBR == internal->r_type) + relent->howto = &xcoff64_howto_table[0x1e]; + else if (R_RBA == internal->r_type) + relent->howto = &xcoff64_howto_table[0x1f]; + } + /* Special case 32 bit */ + else if (31 == (internal->r_size & 0x3f)) + { + if (R_POS == internal->r_type) + relent->howto = &xcoff64_howto_table[0x1c]; + } + /* The r_size field of an XCOFF reloc encodes the bitsize of the relocation, as well as indicating whether it is signed or not. Doublecheck that the relocation information gathered from the @@ -1752,12 +1788,6 @@ xcoff64_rtype2howto (relent, internal) && (relent->howto->bitsize != ((unsigned int) internal->r_size & 0x3f) + 1)) abort (); -#if 0 - if ((internal->r_size & 0x80) != 0 - ? (relent->howto->complain_on_overflow != complain_overflow_signed) - : (relent->howto->complain_on_overflow != complain_overflow_bitfield)) - abort (); -#endif } reloc_howto_type * @@ -1769,22 +1799,22 @@ xcoff64_reloc_type_lookup (abfd, code) { case BFD_RELOC_PPC_B26: return &xcoff64_howto_table[0xa]; + case BFD_RELOC_PPC_BA16: + return &xcoff64_howto_table[0x1d]; case BFD_RELOC_PPC_BA26: return &xcoff64_howto_table[8]; case BFD_RELOC_PPC_TOC16: return &xcoff64_howto_table[3]; case BFD_RELOC_32: case BFD_RELOC_CTOR: - return &xcoff64_howto_table[0]; - case BFD_RELOC_64: return &xcoff64_howto_table[0x1c]; + case BFD_RELOC_64: + return &xcoff64_howto_table[0]; default: return NULL; } } - - /* Read in the armap of an XCOFF archive. */ static boolean @@ -1809,7 +1839,8 @@ xcoff64_slurp_armap (abfd) return true; } - off = strtol (xcoff_ardata_big (abfd)->symoff64, (char **) NULL, 10); + off = bfd_scan_vma (xcoff_ardata_big (abfd)->symoff64, + (const char **) NULL, 10); if (off == 0) { bfd_has_map (abfd) = false; @@ -1830,10 +1861,7 @@ xcoff64_slurp_armap (abfd) if (bfd_seek (abfd, pos, SEEK_CUR) != 0) return false; - /* XXX This actually has to be a call to strtoll (at least on 32-bit - machines) since the field width is 20 and there numbers with more - than 32 bits can be represented. */ - sz = strtol (hdr.size, (char **) NULL, 10); + sz = bfd_scan_vma (hdr.size, (const char **) NULL, 10); /* Read in the entire symbol table. */ contents = (bfd_byte *) bfd_alloc (abfd, sz); @@ -1889,6 +1917,7 @@ static const bfd_target * xcoff64_archive_p (abfd) bfd *abfd; { + struct artdata *tdata_hold; char magic[SXCOFFARMAG]; /* This is the new format. */ struct xcoff_ar_file_hdr_big hdr; @@ -1907,50 +1936,46 @@ xcoff64_archive_p (abfd) return NULL; } - /* We are setting bfd_ardata(abfd) here, but since bfd_ardata - involves a cast, we can't do it as the left operand of - assignment. */ - amt = sizeof (struct artdata); - abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt); - - if (bfd_ardata (abfd) == (struct artdata *) NULL) - return NULL; - - bfd_ardata (abfd)->cache = NULL; - bfd_ardata (abfd)->archive_head = NULL; - bfd_ardata (abfd)->symdefs = NULL; - bfd_ardata (abfd)->extended_names = NULL; - /* Copy over the magic string. */ memcpy (hdr.magic, magic, SXCOFFARMAG); /* Now read the rest of the file header. */ - if (bfd_bread ((PTR) &hdr.memoff, - (bfd_size_type) (SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG), - abfd) != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG) + amt = SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG; + if (bfd_bread ((PTR) &hdr.memoff, amt, abfd) != amt) { if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); return NULL; } - /* XXX This actually has to be a call to strtoll (at least on 32-bit - machines) since the field width is 20 and there numbers with more - than 32 bits can be represented. */ - bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff, - (char **) NULL, 10); + tdata_hold = bfd_ardata (abfd); + + amt = sizeof (struct artdata); + bfd_ardata (abfd) = (struct artdata *) bfd_zalloc (abfd, amt); + if (bfd_ardata (abfd) == (struct artdata *) NULL) + goto error_ret_restore; + + bfd_ardata (abfd)->cache = NULL; + bfd_ardata (abfd)->archive_head = NULL; + bfd_ardata (abfd)->symdefs = NULL; + bfd_ardata (abfd)->extended_names = NULL; + bfd_ardata (abfd)->first_file_filepos = bfd_scan_vma (hdr.firstmemoff, + (const char **) NULL, + 10); amt = SIZEOF_AR_FILE_HDR_BIG; bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt); if (bfd_ardata (abfd)->tdata == NULL) - return NULL; + goto error_ret; memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG); if (! xcoff64_slurp_armap (abfd)) { + error_ret: bfd_release (abfd, bfd_ardata (abfd)); - abfd->tdata.aout_ar_data = (struct artdata *) NULL; + error_ret_restore: + bfd_ardata (abfd) = tdata_hold; return NULL; } @@ -1980,20 +2005,15 @@ xcoff64_openr_next_archived_file (archive, last_file) } else { - /* XXX These actually have to be a calls to strtoll (at least - on 32-bit machines) since the fields's width is 20 and - there numbers with more than 32 bits can be represented. */ - filestart = strtol (arch_xhdr_big (last_file)->nextoff, (char **) NULL, - 10); + filestart = bfd_scan_vma (arch_xhdr_big (last_file)->nextoff, + (const char **) NULL, 10); } - /* XXX These actually have to be calls to strtoll (at least on 32-bit - machines) since the fields's width is 20 and there numbers with more - than 32 bits can be represented. */ + if (filestart == 0 - || filestart == strtol (xcoff_ardata_big (archive)->memoff, - (char **) NULL, 10) - || filestart == strtol (xcoff_ardata_big (archive)->symoff, - (char **) NULL, 10)) + || filestart == bfd_scan_vma (xcoff_ardata_big (archive)->memoff, + (const char **) NULL, 10) + || filestart == bfd_scan_vma (xcoff_ardata_big (archive)->symoff, + (const char **) NULL, 10)) { bfd_set_error (bfd_error_no_more_archived_files); return NULL; @@ -2097,16 +2117,34 @@ xcoff64_loader_reloc_offset (abfd, ldhdr) return (ldhdr->l_rldoff); } -static boolean -xcoff64_generate_rtinit (abfd, init, fini) +static boolean +xcoff64_bad_format_hook (abfd, filehdr) + bfd * abfd; + PTR filehdr; +{ + struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; + + /* Check flavor first. */ + if (bfd_get_flavour (abfd) != bfd_target_xcoff_flavour) + return false; + + if (bfd_xcoff_magic_number (abfd) != internal_f->f_magic) + return false; + + return true; +} + +static boolean +xcoff64_generate_rtinit (abfd, init, fini, rtld) bfd *abfd; const char *init; const char *fini; + boolean rtld; { bfd_byte filehdr_ext[FILHSZ]; - bfd_byte scnhdr_ext[SCNHSZ]; - bfd_byte syment_ext[SYMESZ * 8]; - bfd_byte reloc_ext[RELSZ * 2]; + bfd_byte scnhdr_ext[SCNHSZ * 3]; + bfd_byte syment_ext[SYMESZ * 10]; + bfd_byte reloc_ext[RELSZ * 3]; bfd_byte *data_buffer; bfd_size_type data_buffer_size; bfd_byte *string_table, *st_tmp; @@ -2114,52 +2152,84 @@ xcoff64_generate_rtinit (abfd, init, fini) bfd_vma val; size_t initsz, finisz; struct internal_filehdr filehdr; - struct internal_scnhdr scnhdr; + struct internal_scnhdr text_scnhdr; + struct internal_scnhdr data_scnhdr; + struct internal_scnhdr bss_scnhdr; struct internal_syment syment; union internal_auxent auxent; struct internal_reloc reloc; - + + char *text_name = ".text"; char *data_name = ".data"; + char *bss_name = ".bss"; char *rtinit_name = "__rtinit"; - - if (! bfd_xcoff_rtinit_size (abfd) - || (init == NULL && fini == NULL)) + char *rtld_name = "__rtld"; + + if (! bfd_xcoff_rtinit_size (abfd)) return false; initsz = (init == NULL ? 0 : 1 + strlen (init)); finisz = (fini == NULL ? 0 : 1 + strlen (fini)); - /* file header */ + /* File header. */ memset (filehdr_ext, 0, FILHSZ); memset (&filehdr, 0, sizeof (struct internal_filehdr)); filehdr.f_magic = bfd_xcoff_magic_number (abfd); - filehdr.f_nscns = 1; + filehdr.f_nscns = 3; filehdr.f_timdat = 0; filehdr.f_nsyms = 0; /* at least 6, no more than 8 */ filehdr.f_symptr = 0; /* set below */ filehdr.f_opthdr = 0; filehdr.f_flags = 0; - /* section header */ - memset (scnhdr_ext, 0, SCNHSZ); - memset (&scnhdr, 0, sizeof (struct internal_scnhdr)); - memcpy (scnhdr.s_name, data_name, strlen (data_name)); - scnhdr.s_paddr = 0; - scnhdr.s_vaddr = 0; - scnhdr.s_size = 0; /* set below */ - scnhdr.s_scnptr = FILHSZ + SCNHSZ; - scnhdr.s_relptr = 0; /* set below */ - scnhdr.s_lnnoptr = 0; - scnhdr.s_nreloc = 0; /* either 1 or 2 */ - scnhdr.s_nlnno = 0; - scnhdr.s_flags = STYP_DATA; - - /* .data + /* Section headers. */ + memset (scnhdr_ext, 0, 3 * SCNHSZ); + + /* Text. */ + memset (&text_scnhdr, 0, sizeof (struct internal_scnhdr)); + memcpy (text_scnhdr.s_name, text_name, strlen (text_name)); + text_scnhdr.s_paddr = 0; + text_scnhdr.s_vaddr = 0; + text_scnhdr.s_size = 0; + text_scnhdr.s_scnptr = 0; + text_scnhdr.s_relptr = 0; + text_scnhdr.s_lnnoptr = 0; + text_scnhdr.s_nreloc = 0; + text_scnhdr.s_nlnno = 0; + text_scnhdr.s_flags = STYP_TEXT; + + /* Data. */ + memset (&data_scnhdr, 0, sizeof (struct internal_scnhdr)); + memcpy (data_scnhdr.s_name, data_name, strlen (data_name)); + data_scnhdr.s_paddr = 0; + data_scnhdr.s_vaddr = 0; + data_scnhdr.s_size = 0; /* set below */ + data_scnhdr.s_scnptr = FILHSZ + 3 * SCNHSZ; + data_scnhdr.s_relptr = 0; /* set below */ + data_scnhdr.s_lnnoptr = 0; + data_scnhdr.s_nreloc = 0; /* either 1 or 2 */ + data_scnhdr.s_nlnno = 0; + data_scnhdr.s_flags = STYP_DATA; + + /* Bss. */ + memset (&bss_scnhdr, 0, sizeof (struct internal_scnhdr)); + memcpy (bss_scnhdr.s_name, bss_name, strlen (bss_name)); + bss_scnhdr.s_paddr = 0; /* set below */ + bss_scnhdr.s_vaddr = 0; /* set below */ + bss_scnhdr.s_size = 0; /* set below */ + bss_scnhdr.s_scnptr = 0; + bss_scnhdr.s_relptr = 0; + bss_scnhdr.s_lnnoptr = 0; + bss_scnhdr.s_nreloc = 0; + bss_scnhdr.s_nlnno = 0; + bss_scnhdr.s_flags = STYP_BSS; + + /* .data 0x0000 0x00000000 : rtl 0x0004 0x00000000 : 0x0008 0x00000018 : offset to init, or 0 0x000C 0x00000038 : offset to fini, or 0 - 0x0010 0x00000010 : size of descriptor + 0x0010 0x00000010 : size of descriptor 0x0014 0x00000000 : pad 0x0018 0x00000000 : init, needs a reloc 0x001C 0x00000000 : @@ -2167,29 +2237,27 @@ xcoff64_generate_rtinit (abfd, init, fini) 0x0024 0x00000000 : flags, padded to a word 0x0028 0x00000000 : empty init 0x002C 0x00000000 : - 0x0030 0x00000000 : - 0x0034 0x00000000 : + 0x0030 0x00000000 : + 0x0034 0x00000000 : 0x0038 0x00000000 : fini, needs a reloc 0x003C 0x00000000 : 0x0040 0x00000??? : offset to fini name 0x0044 0x00000000 : flags, padded to a word 0x0048 0x00000000 : empty fini 0x004C 0x00000000 : - 0x0050 0x00000000 : - 0x0054 0x00000000 : + 0x0050 0x00000000 : + 0x0054 0x00000000 : 0x0058 init name 0x0058 + initsz fini name */ data_buffer_size = 0x0058 + initsz + finisz; data_buffer_size += (data_buffer_size & 7) ? 8 - (data_buffer_size & 7) : 0; data_buffer = NULL; - data_buffer = (bfd_byte *)bfd_malloc (data_buffer_size); + data_buffer = (bfd_byte *) bfd_zmalloc (data_buffer_size); if (data_buffer == NULL) return false; - - memset (data_buffer, 0, data_buffer_size); - if (initsz) + if (initsz) { val = 0x18; bfd_put_32 (abfd, val, &data_buffer[0x08]); @@ -2198,7 +2266,7 @@ xcoff64_generate_rtinit (abfd, init, fini) memcpy (&data_buffer[val], init, initsz); } - if (finisz) + if (finisz) { val = 0x38; bfd_put_32 (abfd, val, &data_buffer[0x0C]); @@ -2209,28 +2277,34 @@ xcoff64_generate_rtinit (abfd, init, fini) val = 0x10; bfd_put_32 (abfd, val, &data_buffer[0x10]); - scnhdr.s_size = data_buffer_size; + data_scnhdr.s_size = data_buffer_size; + bss_scnhdr.s_paddr = bss_scnhdr.s_vaddr = data_scnhdr.s_size; - /* string table */ + /* String table. */ string_table_size = 4; string_table_size += strlen (data_name) + 1; string_table_size += strlen (rtinit_name) + 1; string_table_size += initsz; string_table_size += finisz; + if (rtld) + string_table_size += strlen (rtld_name) + 1; + + string_table = (bfd_byte *) bfd_zmalloc (string_table_size); + if (string_table == NULL) + return false; - string_table = (bfd_byte *)bfd_malloc (string_table_size); - memset (string_table, 0, string_table_size); val = string_table_size; bfd_put_32 (abfd, val, &string_table[0]); st_tmp = string_table + 4; - - /* symbols + + /* symbols 0. .data csect 2. __rtinit - 4. init function - 6. fini function */ - memset (syment_ext, 0, 8 * SYMESZ); - memset (reloc_ext, 0, 2 * RELSZ); + 4. init function + 6. fini function + 8. __rtld */ + memset (syment_ext, 0, 10 * SYMESZ); + memset (reloc_ext, 0, 3 * RELSZ); /* .data csect */ memset (&syment, 0, sizeof (struct internal_syment)); @@ -2240,16 +2314,16 @@ xcoff64_generate_rtinit (abfd, init, fini) memcpy (st_tmp, data_name, strlen (data_name)); st_tmp += strlen (data_name) + 1; - syment.n_scnum = 1; + syment.n_scnum = 2; syment.n_sclass = C_HIDEXT; syment.n_numaux = 1; auxent.x_csect.x_scnlen.l = data_buffer_size; auxent.x_csect.x_smtyp = 3 << 3 | XTY_SD; auxent.x_csect.x_smclas = XMC_RW; - bfd_coff_swap_sym_out (abfd, &syment, + bfd_coff_swap_sym_out (abfd, &syment, &syment_ext[filehdr.f_nsyms * SYMESZ]); - bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, - syment.n_numaux, + bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, + syment.n_numaux, &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]); filehdr.f_nsyms += 2; @@ -2259,21 +2333,21 @@ xcoff64_generate_rtinit (abfd, init, fini) syment._n._n_n._n_offset = st_tmp - string_table; memcpy (st_tmp, rtinit_name, strlen (rtinit_name)); st_tmp += strlen (rtinit_name) + 1; - - syment.n_scnum = 1; + + syment.n_scnum = 2; syment.n_sclass = C_EXT; syment.n_numaux = 1; auxent.x_csect.x_smtyp = XTY_LD; auxent.x_csect.x_smclas = XMC_RW; - bfd_coff_swap_sym_out (abfd, &syment, + bfd_coff_swap_sym_out (abfd, &syment, &syment_ext[filehdr.f_nsyms * SYMESZ]); - bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, - syment.n_numaux, + bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, + syment.n_numaux, &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]); filehdr.f_nsyms += 2; - /* init */ - if (initsz) + /* Init. */ + if (initsz) { memset (&syment, 0, sizeof (struct internal_syment)); memset (&auxent, 0, sizeof (union internal_auxent)); @@ -2284,12 +2358,12 @@ xcoff64_generate_rtinit (abfd, init, fini) syment.n_sclass = C_EXT; syment.n_numaux = 1; - bfd_coff_swap_sym_out (abfd, &syment, + bfd_coff_swap_sym_out (abfd, &syment, &syment_ext[filehdr.f_nsyms * SYMESZ]); - bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, - syment.n_numaux, + bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, + syment.n_numaux, &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]); - /* reloc */ + /* Reloc. */ memset (&reloc, 0, sizeof (struct internal_reloc)); reloc.r_vaddr = 0x0018; reloc.r_symndx = filehdr.f_nsyms; @@ -2298,11 +2372,11 @@ xcoff64_generate_rtinit (abfd, init, fini) bfd_coff_swap_reloc_out (abfd, &reloc, &reloc_ext[0]); filehdr.f_nsyms += 2; - scnhdr.s_nreloc += 1; + data_scnhdr.s_nreloc += 1; } - /* finit */ - if (finisz) + /* Finit. */ + if (finisz) { memset (&syment, 0, sizeof (struct internal_syment)); memset (&auxent, 0, sizeof (union internal_auxent)); @@ -2313,34 +2387,68 @@ xcoff64_generate_rtinit (abfd, init, fini) syment.n_sclass = C_EXT; syment.n_numaux = 1; - bfd_coff_swap_sym_out (abfd, &syment, + bfd_coff_swap_sym_out (abfd, &syment, &syment_ext[filehdr.f_nsyms * SYMESZ]); - bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, - syment.n_numaux, + bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, + syment.n_numaux, &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]); - /* reloc */ + /* Reloc. */ memset (&reloc, 0, sizeof (struct internal_reloc)); reloc.r_vaddr = 0x0038; reloc.r_symndx = filehdr.f_nsyms; reloc.r_type = R_POS; reloc.r_size = 63; - bfd_coff_swap_reloc_out (abfd, &reloc, - &reloc_ext[scnhdr.s_nreloc * RELSZ]); + bfd_coff_swap_reloc_out (abfd, &reloc, + &reloc_ext[data_scnhdr.s_nreloc * RELSZ]); + + filehdr.f_nsyms += 2; + data_scnhdr.s_nreloc += 1; + } + + if (rtld) + { + memset (&syment, 0, sizeof (struct internal_syment)); + memset (&auxent, 0, sizeof (union internal_auxent)); + + syment._n._n_n._n_offset = st_tmp - string_table; + memcpy (st_tmp, rtld_name, strlen (rtld_name)); + st_tmp += strlen (rtld_name) + 1; + + syment.n_sclass = C_EXT; + syment.n_numaux = 1; + bfd_coff_swap_sym_out (abfd, &syment, + &syment_ext[filehdr.f_nsyms * SYMESZ]); + bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, + syment.n_numaux, + &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]); + + /* Reloc. */ + memset (&reloc, 0, sizeof (struct internal_reloc)); + reloc.r_vaddr = 0x0000; + reloc.r_symndx = filehdr.f_nsyms; + reloc.r_type = R_POS; + reloc.r_size = 63; + bfd_coff_swap_reloc_out (abfd, &reloc, + &reloc_ext[data_scnhdr.s_nreloc * RELSZ]); filehdr.f_nsyms += 2; - scnhdr.s_nreloc += 1; + data_scnhdr.s_nreloc += 1; + + bss_scnhdr.s_size = 0; } - scnhdr.s_relptr = scnhdr.s_scnptr + data_buffer_size; - filehdr.f_symptr = scnhdr.s_relptr + scnhdr.s_nreloc * RELSZ; + data_scnhdr.s_relptr = data_scnhdr.s_scnptr + data_buffer_size; + filehdr.f_symptr = data_scnhdr.s_relptr + data_scnhdr.s_nreloc * RELSZ; bfd_coff_swap_filehdr_out (abfd, &filehdr, filehdr_ext); bfd_bwrite (filehdr_ext, FILHSZ, abfd); - bfd_coff_swap_scnhdr_out (abfd, &scnhdr, scnhdr_ext); - bfd_bwrite (scnhdr_ext, SCNHSZ, abfd); + bfd_coff_swap_scnhdr_out (abfd, &text_scnhdr, &scnhdr_ext[SCNHSZ * 0]); + bfd_coff_swap_scnhdr_out (abfd, &data_scnhdr, &scnhdr_ext[SCNHSZ * 1]); + bfd_coff_swap_scnhdr_out (abfd, &bss_scnhdr, &scnhdr_ext[SCNHSZ * 2]); + bfd_bwrite (scnhdr_ext, 3 * SCNHSZ, abfd); bfd_bwrite (data_buffer, data_buffer_size, abfd); - bfd_bwrite (reloc_ext, scnhdr.s_nreloc * RELSZ, abfd); + bfd_bwrite (reloc_ext, data_scnhdr.s_nreloc * RELSZ, abfd); bfd_bwrite (syment_ext, filehdr.f_nsyms * SYMESZ, abfd); bfd_bwrite (string_table, string_table_size, abfd); @@ -2369,119 +2477,114 @@ HOWTO (0, /* type */ static unsigned long xcoff64_glink_code[10] = { - 0xe9820000, /* ld r12,0(r2) */ - 0xf8410028, /* std r2,40(r1) */ - 0xe80c0000, /* ld r0,0(r12) */ - 0xe84c0008, /* ld r0,8(r12) */ - 0x7c0903a6, /* mtctr r0 */ - 0x4e800420, /* bctr */ - 0x00000000, /* start of traceback table */ - 0x000ca000, /* traceback table */ - 0x00000000, /* traceback table */ - 0x00000018, /* ??? */ + 0xe9820000, /* ld r12,0(r2) */ + 0xf8410028, /* std r2,40(r1) */ + 0xe80c0000, /* ld r0,0(r12) */ + 0xe84c0008, /* ld r0,8(r12) */ + 0x7c0903a6, /* mtctr r0 */ + 0x4e800420, /* bctr */ + 0x00000000, /* start of traceback table */ + 0x000ca000, /* traceback table */ + 0x00000000, /* traceback table */ + 0x00000018, /* ??? */ }; static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = { - { /* COFF backend, defined in libcoff.h */ - _bfd_xcoff64_swap_aux_in, /* _bfd_coff_swap_aux_in */ - _bfd_xcoff64_swap_sym_in, /* _bfd_coff_swap_sym_in */ - _bfd_xcoff64_swap_lineno_in, /* _bfd_coff_swap_lineno_in */ - _bfd_xcoff64_swap_aux_out, /* _bfd_swap_aux_out */ - _bfd_xcoff64_swap_sym_out, /* _bfd_swap_sym_out */ - _bfd_xcoff64_swap_lineno_out, /* _bfd_swap_lineno_out */ - coff_swap_reloc_out, /* _bfd_swap_reloc_out */ - coff_swap_filehdr_out, /* _bfd_swap_filehdr_out */ - coff_swap_aouthdr_out, /* _bfd_swap_aouthdr_out */ - coff_swap_scnhdr_out, /* _bfd_swap_scnhdr_out */ - FILHSZ, /* _bfd_filhsz */ - AOUTSZ, /* _bfd_aoutsz */ - SCNHSZ, /* _bfd_scnhsz */ - SYMESZ, /* _bfd_symesz */ - AUXESZ, /* _bfd_auxesz */ - RELSZ, /* _bfd_relsz */ - LINESZ, /* _bfd_linesz */ - FILNMLEN, /* _bfd_filnmlen */ - true, /* _bfd_coff_long_filenames */ - false, /* _bfd_coff_long_section_names */ - (3), /* _bfd_coff_default_section_alignment_power */ - true, /* _bfd_coff_force_symnames_in_strings */ - 4, /* _bfd_coff_debug_string_prefix_length */ - coff_swap_filehdr_in, /* _bfd_coff_swap_filehdr_in */ - coff_swap_aouthdr_in, /* _bfd_swap_aouthdr_in */ - coff_swap_scnhdr_in, /* _bfd_swap_scnhdr_in */ - coff_swap_reloc_in, /* _bfd_reloc_in */ - coff_bad_format_hook, /* _bfd_bad_format_hook */ - coff_set_arch_mach_hook, /* _bfd_set_arch_mach_hook */ - coff_mkobject_hook, /* _bfd_mkobject_hook */ - styp_to_sec_flags, /* _bfd_syp_to_sec_flags */ - coff_set_alignment_hook, /* _bfd_set_alignment_hook */ - coff_slurp_symbol_table, /* _bfd_coff_slurp_symbol_table */ - symname_in_debug_hook, /* _coff_symname_in_debug_hook */ - coff_pointerize_aux_hook, /* _bfd_coff_pointerize_aux_hook */ - coff_print_aux, /* bfd_coff_print_aux */ - dummy_reloc16_extra_cases, /* _bfd_coff_reloc16_extra_cases */ - dummy_reloc16_estimate, /* _bfd_coff_reloc16_estimate */ - NULL, /* bfd_coff_sym_is_global */ - /* _bfd_coff_compute_section_file_positions */ + { /* COFF backend, defined in libcoff.h. */ + _bfd_xcoff64_swap_aux_in, + _bfd_xcoff64_swap_sym_in, + _bfd_xcoff64_swap_lineno_in, + _bfd_xcoff64_swap_aux_out, + _bfd_xcoff64_swap_sym_out, + _bfd_xcoff64_swap_lineno_out, + xcoff64_swap_reloc_out, + coff_swap_filehdr_out, + coff_swap_aouthdr_out, + coff_swap_scnhdr_out, + FILHSZ, + AOUTSZ, + SCNHSZ, + SYMESZ, + AUXESZ, + RELSZ, + LINESZ, + FILNMLEN, + true, /* _bfd_coff_long_filenames */ + false, /* _bfd_coff_long_section_names */ + 3, /* _bfd_coff_default_section_alignment_power */ + true, /* _bfd_coff_force_symnames_in_strings */ + 4, /* _bfd_coff_debug_string_prefix_length */ + coff_swap_filehdr_in, + coff_swap_aouthdr_in, + coff_swap_scnhdr_in, + xcoff64_swap_reloc_in, + xcoff64_bad_format_hook, + coff_set_arch_mach_hook, + coff_mkobject_hook, + styp_to_sec_flags, + coff_set_alignment_hook, + coff_slurp_symbol_table, + symname_in_debug_hook, + coff_pointerize_aux_hook, + coff_print_aux, + dummy_reloc16_extra_cases, + dummy_reloc16_estimate, + NULL, /* bfd_coff_sym_is_global */ coff_compute_section_file_positions, - NULL , /* _bfd_coff_start_final_link */ - xcoff64_ppc_relocate_section, /* _bfd_coff_relocate_section */ - coff_rtype_to_howto, /* _bfd_coff_rtype_to_howto */ - NULL , /* _bfd_coff_addust_symndx */ - _bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */ - coff_link_output_has_begun, /* _bfd_coff_link_output_has_begun */ - coff_final_link_postscript /* _bfd_coff_final_link_postscript */ + NULL , /* _bfd_coff_start_final_link */ + xcoff64_ppc_relocate_section, + coff_rtype_to_howto, + NULL, /* _bfd_coff_adjust_symndx */ + _bfd_generic_link_add_one_symbol, + coff_link_output_has_begun, + coff_final_link_postscript }, - 0x01EF, /* magic number */ - bfd_arch_powerpc, /* architecture */ - bfd_mach_ppc_620, /* machine */ - - /* function pointers to xcoff specific swap routines */ - xcoff64_swap_ldhdr_in, /* _xcoff_swap_ldhdr_in */ - xcoff64_swap_ldhdr_out, /* _xcoff_swap_ldhdr_out */ - xcoff64_swap_ldsym_in, /* _xcoff_swap_ldsym_in */ - xcoff64_swap_ldsym_out, /* _xcoff_swap_ldsym_out */ - xcoff64_swap_ldrel_in, /* _xcoff_swap_ldrel_in */ - xcoff64_swap_ldrel_out, /* _xcoff_swap_ldrel_out */ - - /* sizes */ - LDHDRSZ, /* _xcoff_ldhdrsz */ - LDSYMSZ, /* _xcoff_ldsymsz */ - LDRELSZ, /* _xcoff_ldrelsz */ - 24, /* _xcoff_function_descriptor_size */ - 0, /* _xcoff_small_aout_header_size */ - /* versions */ - 2, /* _xcoff_ldhdr_version */ - - /* xcoff vs xcoff64 putting symbol names */ - _bfd_xcoff64_put_symbol_name, /* _xcoff_put_symbol_name */ - _bfd_xcoff64_put_ldsymbol_name, /* _xcoff_put_ldsymbol_name */ - - /* dynamic reloc howto */ + 0x01EF, /* magic number */ + bfd_arch_powerpc, + bfd_mach_ppc_620, + + /* Function pointers to xcoff specific swap routines. */ + xcoff64_swap_ldhdr_in, + xcoff64_swap_ldhdr_out, + xcoff64_swap_ldsym_in, + xcoff64_swap_ldsym_out, + xcoff64_swap_ldrel_in, + xcoff64_swap_ldrel_out, + + /* Sizes. */ + LDHDRSZ, + LDSYMSZ, + LDRELSZ, + 24, /* _xcoff_function_descriptor_size */ + 0, /* _xcoff_small_aout_header_size */ + + /* Versions. */ + 2, /* _xcoff_ldhdr_version */ + + _bfd_xcoff64_put_symbol_name, + _bfd_xcoff64_put_ldsymbol_name, &xcoff64_dynamic_reloc, - xcoff64_create_csect_from_smclas, - /* lineno and reloc count overflow */ + /* Lineno and reloc count overflow. */ xcoff64_is_lineno_count_overflow, xcoff64_is_reloc_count_overflow, xcoff64_loader_symbol_offset, xcoff64_loader_reloc_offset, - /* glink */ + /* glink. */ &xcoff64_glink_code[0], - 40, /* _xcoff_glink_size */ - - /* rtinit */ - 88, /* _xcoff_rtinit_size */ - xcoff64_generate_rtinit, /* _xcoff_generate_rtinit */ + 40, /* _xcoff_glink_size */ + /* rtinit. */ + 88, /* _xcoff_rtinit_size */ + xcoff64_generate_rtinit, }; -/* The transfer vector that leads the outside world to all of the above. */ +/* The transfer vector that leads the outside world to all of the above. */ const bfd_target rs6000coff64_vec = { "aixcoff64-rs6000", @@ -2489,36 +2592,35 @@ const bfd_target rs6000coff64_vec = BFD_ENDIAN_BIG, /* data byte order is big */ BFD_ENDIAN_BIG, /* header byte order is big */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | DYNAMIC | - HAS_SYMS | HAS_LOCALS | WP_TEXT), + (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | DYNAMIC + | HAS_SYMS | HAS_LOCALS | WP_TEXT), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), 0, /* leading char */ '/', /* ar_pad_char */ - 15, /* ar_max_namelen??? FIXMEmgo */ + 15, /* ar_max_namelen */ /* data */ - bfd_getb64, /* bfd_getx64 */ - bfd_getb_signed_64, /* bfd_getx_signed_64 */ - bfd_putb64, /* bfd_putx64 */ - bfd_getb32, /* bfd_getx32 */ - bfd_getb_signed_32, /* bfd_getx_signed_32 */ - bfd_putb32, /* bfd_putx32 */ - bfd_getb16, /* bfd_getx16 */ - bfd_getb_signed_16, /* bfd_getx_signed_16 */ - bfd_putb16, /* bfd_putx16 */ + bfd_getb64, + bfd_getb_signed_64, + bfd_putb64, + bfd_getb32, + bfd_getb_signed_32, + bfd_putb32, + bfd_getb16, + bfd_getb_signed_16, + bfd_putb16, /* hdrs */ - bfd_getb64, /* bfd_h_getx64 */ - bfd_getb_signed_64, /* bfd_h_getx_signed_64 */ - bfd_putb64, /* bfd_h_putx64 */ - bfd_getb32, /* bfd_h_getx32 */ - bfd_getb_signed_32, /* bfd_h_getx_signed_32 */ - bfd_putb32, /* bfd_h_putx32 */ - bfd_getb16, /* bfd_h_getx16 */ - bfd_getb_signed_16, /* bfd_h_getx_signed_16 */ - bfd_putb16, /* bfd_h_putx16 */ + bfd_getb64, + bfd_getb_signed_64, + bfd_putb64, + bfd_getb32, + bfd_getb_signed_32, + bfd_putb32, + bfd_getb16, + bfd_getb_signed_16, + bfd_putb16, { /* bfd_check_format */ _bfd_dummy_target, @@ -2542,92 +2644,320 @@ const bfd_target rs6000coff64_vec = }, /* Generic */ - bfd_true, /* _close_and_cleanup */ - bfd_true, /* _bfd_free_cached_info */ - coff_new_section_hook, /* _new_section_hook */ - _bfd_generic_get_section_contents, /* _bfd_get_section_contents */ - /* _bfd_get_section_contents_in_window */ + bfd_true, + bfd_true, + coff_new_section_hook, + _bfd_generic_get_section_contents, _bfd_generic_get_section_contents_in_window, /* Copy */ - _bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */ - /* _bfd_merge_private_bfd_data */ + _bfd_xcoff_copy_private_bfd_data, ((boolean (*) (bfd *, bfd *)) bfd_true), - /* _bfd_copy_pivate_section_data */ ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true), - /* _bfd_copy_private_symbol_data */ ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true), - ((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */ - ((boolean (*) (bfd *, void * )) bfd_true), /* _bfd_print_private_bfd_data */ + ((boolean (*) (bfd *, flagword)) bfd_true), + ((boolean (*) (bfd *, void * )) bfd_true), /* Core */ - coff_core_file_failing_command, /* _core_file_failing_command */ - coff_core_file_failing_signal, /* _core_file_failing_signal */ - /* _core_file_matches_executable_p */ - coff_core_file_matches_executable_p, + coff_core_file_failing_command, + coff_core_file_failing_signal, + coff_core_file_matches_executable_p, /* Archive */ - xcoff64_slurp_armap, /* _slurp_armap */ - /* XCOFF archives do not have - anything which corresponds to - an extended name table. */ - bfd_false, /* _slurp_extended_name_table */ - /* _construct_extended_name_table */ + xcoff64_slurp_armap, + bfd_false, ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false), - bfd_dont_truncate_arname, /* _truncate_arname */ - _bfd_xcoff_write_armap, /* _write_armap */ - _bfd_xcoff_read_ar_hdr, /* _read_ar_hdr */ - xcoff64_openr_next_archived_file, /* _openr_next_archived_file */ - _bfd_generic_get_elt_at_index, /* _get_elt_at_index */ - _bfd_xcoff_stat_arch_elt, /* _generic_stat_arch_elt */ - /* XCOFF archives do not have - a timestamp. */ - bfd_true, /* _update_armap_timestamp */ + bfd_dont_truncate_arname, + _bfd_xcoff_write_armap, + _bfd_xcoff_read_ar_hdr, + xcoff64_openr_next_archived_file, + _bfd_generic_get_elt_at_index, + _bfd_xcoff_stat_arch_elt, + bfd_true, /* Symbols */ - coff_get_symtab_upper_bound, /* _get_symtab_upper_bound */ - coff_get_symtab, /* _get_symtab */ - coff_make_empty_symbol, /* _make_empty_symbol */ - coff_print_symbol, /* _print_symbol */ - coff_get_symbol_info, /* _get_symbol_info */ - _bfd_xcoff_is_local_label_name, /* _bfd_is_local_label_name */ - coff_get_lineno, /* _get_lineno */ - coff_find_nearest_line, /* _find_nearest_line */ - coff_bfd_make_debug_symbol, /* _bfd_make_debug_symbol */ - _bfd_generic_read_minisymbols, /* _read_minisymbols */ - _bfd_generic_minisymbol_to_symbol, /* _minsymbol_to_symbol */ + coff_get_symtab_upper_bound, + coff_get_symtab, + coff_make_empty_symbol, + coff_print_symbol, + coff_get_symbol_info, + _bfd_xcoff_is_local_label_name, + coff_get_lineno, + coff_find_nearest_line, + coff_bfd_make_debug_symbol, + _bfd_generic_read_minisymbols, + _bfd_generic_minisymbol_to_symbol, /* Reloc */ - coff_get_reloc_upper_bound, /* _get_reloc_upper_bound */ - coff_canonicalize_reloc, /* _cononicalize_reloc */ - xcoff64_reloc_type_lookup, /* _bfd_reloc_type_lookup */ + coff_get_reloc_upper_bound, + coff_canonicalize_reloc, + xcoff64_reloc_type_lookup, /* Write */ - coff_set_arch_mach, /* _set_arch_mach */ - coff_set_section_contents, /* _set_section_contents */ + coff_set_arch_mach, + coff_set_section_contents, /* Link */ - xcoff64_sizeof_headers, /* _sizeof_headers */ - /* _bfd_get_relocated_section_contents */ + xcoff64_sizeof_headers, bfd_generic_get_relocated_section_contents, - bfd_generic_relax_section, /* _bfd_relax_section */ - _bfd_xcoff_bfd_link_hash_table_create, /* _bfd_link_hash_table_create */ - _bfd_xcoff_bfd_link_add_symbols, /* _bfd_link_add_symbols */ - _bfd_xcoff_bfd_final_link, /* _bfd_filnal_link */ - _bfd_generic_link_split_section, /* _bfd_link_split_section */ - bfd_generic_gc_sections, /* _bfd_gc_sections */ - bfd_generic_merge_sections, /* _bfd_merge_sections */ + bfd_generic_relax_section, + _bfd_xcoff_bfd_link_hash_table_create, + _bfd_generic_link_hash_table_free, + _bfd_xcoff_bfd_link_add_symbols, + _bfd_generic_link_just_syms, + _bfd_xcoff_bfd_final_link, + _bfd_generic_link_split_section, + bfd_generic_gc_sections, + bfd_generic_merge_sections, + bfd_generic_discard_group, /* Dynamic */ - /* _get_dynamic_symtab_upper_bound */ _bfd_xcoff_get_dynamic_symtab_upper_bound, - _bfd_xcoff_canonicalize_dynamic_symtab, /* _cononicalize_dynamic_symtab */ - _bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */ - _bfd_xcoff_canonicalize_dynamic_reloc, /* _cononicalize_dynamic_reloc */ + _bfd_xcoff_canonicalize_dynamic_symtab, + _bfd_xcoff_get_dynamic_reloc_upper_bound, + _bfd_xcoff_canonicalize_dynamic_reloc, /* Opposite endian version, none exists */ NULL, - /* back end data */ (void *) &bfd_xcoff_backend_data, }; + +extern const bfd_target *xcoff64_core_p PARAMS ((bfd *)); +extern boolean xcoff64_core_file_matches_executable_p PARAMS((bfd *, bfd *)); +extern char *xcoff64_core_file_failing_command PARAMS ((bfd *)); +extern int xcoff64_core_file_failing_signal PARAMS ((bfd *)); + +/* AIX 5 */ +static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data = +{ + { /* COFF backend, defined in libcoff.h. */ + _bfd_xcoff64_swap_aux_in, + _bfd_xcoff64_swap_sym_in, + _bfd_xcoff64_swap_lineno_in, + _bfd_xcoff64_swap_aux_out, + _bfd_xcoff64_swap_sym_out, + _bfd_xcoff64_swap_lineno_out, + xcoff64_swap_reloc_out, + coff_swap_filehdr_out, + coff_swap_aouthdr_out, + coff_swap_scnhdr_out, + FILHSZ, + AOUTSZ, + SCNHSZ, + SYMESZ, + AUXESZ, + RELSZ, + LINESZ, + FILNMLEN, + true, /* _bfd_coff_long_filenames */ + false, /* _bfd_coff_long_section_names */ + 3, /* _bfd_coff_default_section_alignment_power */ + true, /* _bfd_coff_force_symnames_in_strings */ + 4, /* _bfd_coff_debug_string_prefix_length */ + coff_swap_filehdr_in, + coff_swap_aouthdr_in, + coff_swap_scnhdr_in, + xcoff64_swap_reloc_in, + xcoff64_bad_format_hook, + coff_set_arch_mach_hook, + coff_mkobject_hook, + styp_to_sec_flags, + coff_set_alignment_hook, + coff_slurp_symbol_table, + symname_in_debug_hook, + coff_pointerize_aux_hook, + coff_print_aux, + dummy_reloc16_extra_cases, + dummy_reloc16_estimate, + NULL, /* bfd_coff_sym_is_global */ + coff_compute_section_file_positions, + NULL , /* _bfd_coff_start_final_link */ + xcoff64_ppc_relocate_section, + coff_rtype_to_howto, + NULL, /* _bfd_coff_adjust_symndx */ + _bfd_generic_link_add_one_symbol, + coff_link_output_has_begun, + coff_final_link_postscript + }, + + U64_TOCMAGIC, /* magic number */ + bfd_arch_powerpc, + bfd_mach_ppc_620, + + /* Function pointers to xcoff specific swap routines. */ + xcoff64_swap_ldhdr_in, + xcoff64_swap_ldhdr_out, + xcoff64_swap_ldsym_in, + xcoff64_swap_ldsym_out, + xcoff64_swap_ldrel_in, + xcoff64_swap_ldrel_out, + + /* Sizes. */ + LDHDRSZ, + LDSYMSZ, + LDRELSZ, + 24, /* _xcoff_function_descriptor_size */ + 0, /* _xcoff_small_aout_header_size */ + /* Versions. */ + 2, /* _xcoff_ldhdr_version */ + + _bfd_xcoff64_put_symbol_name, + _bfd_xcoff64_put_ldsymbol_name, + &xcoff64_dynamic_reloc, + xcoff64_create_csect_from_smclas, + + /* Lineno and reloc count overflow. */ + xcoff64_is_lineno_count_overflow, + xcoff64_is_reloc_count_overflow, + + xcoff64_loader_symbol_offset, + xcoff64_loader_reloc_offset, + + /* glink. */ + &xcoff64_glink_code[0], + 40, /* _xcoff_glink_size */ + + /* rtinit. */ + 88, /* _xcoff_rtinit_size */ + xcoff64_generate_rtinit, +}; + +/* The transfer vector that leads the outside world to all of the above. */ +const bfd_target aix5coff64_vec = +{ + "aix5coff64-rs6000", + bfd_target_xcoff_flavour, + BFD_ENDIAN_BIG, /* data byte order is big */ + BFD_ENDIAN_BIG, /* header byte order is big */ + + (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | DYNAMIC + | HAS_SYMS | HAS_LOCALS | WP_TEXT), + + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), + 0, /* leading char */ + '/', /* ar_pad_char */ + 15, /* ar_max_namelen */ + + /* data */ + bfd_getb64, + bfd_getb_signed_64, + bfd_putb64, + bfd_getb32, + bfd_getb_signed_32, + bfd_putb32, + bfd_getb16, + bfd_getb_signed_16, + bfd_putb16, + + /* hdrs */ + bfd_getb64, + bfd_getb_signed_64, + bfd_putb64, + bfd_getb32, + bfd_getb_signed_32, + bfd_putb32, + bfd_getb16, + bfd_getb_signed_16, + bfd_putb16, + + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + xcoff64_archive_p, + xcoff64_core_p + }, + + { /* bfd_set_format */ + bfd_false, + coff_mkobject, + _bfd_generic_mkarchive, + bfd_false + }, + + {/* bfd_write_contents */ + bfd_false, + xcoff64_write_object_contents, + _bfd_xcoff_write_archive_contents, + bfd_false + }, + + /* Generic */ + bfd_true, + bfd_true, + coff_new_section_hook, + _bfd_generic_get_section_contents, + _bfd_generic_get_section_contents_in_window, + + /* Copy */ + _bfd_xcoff_copy_private_bfd_data, + ((boolean (*) (bfd *, bfd *)) bfd_true), + ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true), + ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true), + ((boolean (*) (bfd *, flagword)) bfd_true), + ((boolean (*) (bfd *, void * )) bfd_true), + + /* Core */ + xcoff64_core_file_failing_command, + xcoff64_core_file_failing_signal, + xcoff64_core_file_matches_executable_p, + + /* Archive */ + xcoff64_slurp_armap, + bfd_false, + ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false), + bfd_dont_truncate_arname, + _bfd_xcoff_write_armap, + _bfd_xcoff_read_ar_hdr, + xcoff64_openr_next_archived_file, + _bfd_generic_get_elt_at_index, + _bfd_xcoff_stat_arch_elt, + bfd_true, + + /* Symbols */ + coff_get_symtab_upper_bound, + coff_get_symtab, + coff_make_empty_symbol, + coff_print_symbol, + coff_get_symbol_info, + _bfd_xcoff_is_local_label_name, + coff_get_lineno, + coff_find_nearest_line, + coff_bfd_make_debug_symbol, + _bfd_generic_read_minisymbols, + _bfd_generic_minisymbol_to_symbol, + + /* Reloc */ + coff_get_reloc_upper_bound, + coff_canonicalize_reloc, + xcoff64_reloc_type_lookup, + + /* Write */ + coff_set_arch_mach, + coff_set_section_contents, + + /* Link */ + xcoff64_sizeof_headers, + bfd_generic_get_relocated_section_contents, + bfd_generic_relax_section, + _bfd_xcoff_bfd_link_hash_table_create, + _bfd_generic_link_hash_table_free, + _bfd_xcoff_bfd_link_add_symbols, + _bfd_generic_link_just_syms, + _bfd_xcoff_bfd_final_link, + _bfd_generic_link_split_section, + bfd_generic_gc_sections, + bfd_generic_merge_sections, + bfd_generic_discard_group, + + /* Dynamic */ + _bfd_xcoff_get_dynamic_symtab_upper_bound, + _bfd_xcoff_canonicalize_dynamic_symtab, + _bfd_xcoff_get_dynamic_reloc_upper_bound, + _bfd_xcoff_canonicalize_dynamic_reloc, + + /* Opposite endian version, none exists. */ + NULL, + + (void *) & bfd_xcoff_aix5_backend_data, +}; diff --git a/contrib/binutils/bfd/coffcode.h b/contrib/binutils/bfd/coffcode.h index 5c6704f..212c5c6 100644 --- a/contrib/binutils/bfd/coffcode.h +++ b/contrib/binutils/bfd/coffcode.h @@ -341,6 +341,11 @@ static PTR coff_mkobject_hook PARAMS ((bfd *, PTR, PTR)); #ifdef COFF_WITH_PE static flagword handle_COMDAT PARAMS ((bfd *, flagword, PTR, const char *, asection *)); #endif +#ifdef COFF_IMAGE_WITH_PE +static boolean coff_read_word PARAMS ((bfd *, unsigned int *)); +static unsigned int coff_compute_checksum PARAMS ((bfd *)); +static boolean coff_apply_checksum PARAMS ((bfd *)); +#endif /* void warning(); */ @@ -1493,12 +1498,12 @@ coff_new_section_hook (abfd, section) section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; #ifdef RS6000COFF_C - if (xcoff_data (abfd)->text_align_power != 0 + if (bfd_xcoff_text_align_power (abfd) != 0 && strcmp (bfd_get_section_name (abfd, section), ".text") == 0) - section->alignment_power = xcoff_data (abfd)->text_align_power; - if (xcoff_data (abfd)->data_align_power != 0 + section->alignment_power = bfd_xcoff_text_align_power (abfd); + if (bfd_xcoff_data_align_power (abfd) != 0 && strcmp (bfd_get_section_name (abfd, section), ".data") == 0) - section->alignment_power = xcoff_data (abfd)->data_align_power; + section->alignment_power = bfd_xcoff_data_align_power (abfd); #endif /* Allocate aux records for section symbols, to store size and @@ -1734,7 +1739,7 @@ coff_mkobject_hook (abfd, filehdr, aouthdr) struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; coff_data_type *coff; - if (coff_mkobject (abfd) == false) + if (! coff_mkobject (abfd)) return NULL; coff = coff_data (abfd); @@ -1777,8 +1782,8 @@ coff_mkobject_hook (abfd, filehdr, aouthdr) xcoff->toc = internal_a->o_toc; xcoff->sntoc = internal_a->o_sntoc; xcoff->snentry = internal_a->o_snentry; - xcoff->text_align_power = internal_a->o_algntext; - xcoff->data_align_power = internal_a->o_algndata; + bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext; + bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata; xcoff->modtype = internal_a->o_modtype; xcoff->cputype = internal_a->o_cputype; xcoff->maxdata = internal_a->o_maxdata; @@ -1964,6 +1969,7 @@ coff_set_arch_mach_hook (abfd, filehdr) #ifdef RS6000COFF_C #ifdef XCOFF64 + case U64_TOCMAGIC: case U803XTOCMAGIC: #else case U802ROMAGIC: @@ -2152,6 +2158,13 @@ coff_set_arch_mach_hook (abfd, filehdr) arch = bfd_arch_mcore; break; #endif + +#ifdef W65MAGIC + case W65MAGIC: + arch = bfd_arch_w65; + break; +#endif + default: /* Unreadable input file type */ arch = bfd_arch_obscure; break; @@ -2171,7 +2184,7 @@ symname_in_debug_hook (abfd, sym) bfd * abfd ATTRIBUTE_UNUSED; struct internal_syment *sym; { - return SYMNAME_IN_DEBUG (sym) ? true : false; + return SYMNAME_IN_DEBUG (sym) != 0; } #else @@ -2388,7 +2401,7 @@ coff_write_relocs (abfd, first_undef) return false; #ifdef COFF_WITH_PE - if (s->reloc_count > 0xffff) + if (obj_pe (abfd) && s->reloc_count >= 0xffff) { /* encode real count here as first reloc */ struct internal_reloc n; @@ -2768,14 +2781,8 @@ coff_set_flags (abfd, magicp, flagsp) #ifndef PPCMAGIC case bfd_arch_powerpc: #endif -#ifdef XCOFF64 - if (bfd_get_mach (abfd) == bfd_mach_ppc_620 - && !strncmp (abfd->xvec->name,"aix", 3)) - *magicp = U803XTOCMAGIC; - else -#else - *magicp = U802TOCMAGIC; -#endif + BFD_ASSERT (bfd_get_flavour (abfd) == bfd_target_xcoff_flavour); + *magicp = bfd_xcoff_magic_number (abfd); return true; break; #endif @@ -2822,8 +2829,8 @@ coff_set_arch_mach (abfd, arch, machine) if (! bfd_default_set_arch_mach (abfd, arch, machine)) return false; - if (arch != bfd_arch_unknown && - coff_set_flags (abfd, &dummy1, &dummy2) != true) + if (arch != bfd_arch_unknown + && ! coff_set_flags (abfd, &dummy1, &dummy2)) return false; /* We can't represent this type */ return true; /* We're easy ... */ @@ -3084,8 +3091,10 @@ coff_compute_section_file_positions (abfd) AIX executable is stripped with gnu strip because the default vma of native is 0x10000150 but default for gnu is 0x10000140. Gnu stripped gnu excutable passes this check because the filepos is - 0x0140. */ - if (!strcmp (current->name, _TEXT)) + 0x0140. This problem also show up with 64 bit shared objects. The + data section must also be aligned. */ + if (!strcmp (current->name, _TEXT) + || !strcmp (current->name, _DATA)) { bfd_vma pad; bfd_vma align; @@ -3276,6 +3285,100 @@ coff_add_missing_symbols (abfd) #endif /* 0 */ +#ifdef COFF_IMAGE_WITH_PE + +static unsigned int pelength; +static unsigned int peheader; + +static boolean +coff_read_word (abfd, value) + bfd *abfd; + unsigned int *value; +{ + unsigned char b[2]; + int status; + + status = bfd_bread (b, (bfd_size_type) 2, abfd); + if (status < 1) + { + *value = 0; + return false; + } + + if (status == 1) + *value = (unsigned int) b[0]; + else + *value = (unsigned int) (b[0] + (b[1] << 8)); + + pelength += (unsigned int) status; + + return true; +} + +static unsigned int +coff_compute_checksum (abfd) + bfd *abfd; +{ + boolean more_data; + file_ptr filepos; + unsigned int value; + unsigned int total; + + total = 0; + pelength = 0; + filepos = (file_ptr) 0; + + do + { + if (bfd_seek (abfd, filepos, SEEK_SET) != 0) + return 0; + + more_data = coff_read_word (abfd, &value); + total += value; + total = 0xffff & (total + (total >> 0x10)); + filepos += 2; + } + while (more_data); + + return (0xffff & (total + (total >> 0x10))); +} + +static boolean +coff_apply_checksum (abfd) + bfd *abfd; +{ + unsigned int computed; + unsigned int checksum = 0; + + if (bfd_seek (abfd, 0x3c, SEEK_SET) != 0) + return false; + + if (!coff_read_word (abfd, &peheader)) + return false; + + if (bfd_seek (abfd, peheader + 0x58, SEEK_SET) != 0) + return false; + + checksum = 0; + bfd_bwrite (&checksum, (bfd_size_type) 4, abfd); + + if (bfd_seek (abfd, peheader, SEEK_SET) != 0) + return false; + + computed = coff_compute_checksum (abfd); + + checksum = computed + pelength; + + if (bfd_seek (abfd, peheader + 0x58, SEEK_SET) != 0) + return false; + + bfd_bwrite (&checksum, (bfd_size_type) 4, abfd); + + return true; +} + +#endif /* COFF_IMAGE_WITH_PE */ + /* SUPPRESS 558 */ /* SUPPRESS 529 */ static boolean @@ -3309,7 +3412,7 @@ coff_write_object_contents (abfd) lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd); - if (abfd->output_has_begun == false) + if (! abfd->output_has_begun) { if (! coff_compute_section_file_positions (abfd)) return false; @@ -3324,7 +3427,7 @@ coff_write_object_contents (abfd) { #ifdef COFF_WITH_PE /* we store the actual reloc count in the first reloc's addr */ - if (current->reloc_count > 0xffff) + if (obj_pe (abfd) && current->reloc_count >= 0xffff) reloc_count ++; #endif reloc_count += current->reloc_count; @@ -3355,7 +3458,7 @@ coff_write_object_contents (abfd) reloc_base += current->reloc_count * bfd_coff_relsz (abfd); #ifdef COFF_WITH_PE /* extra reloc to hold real count */ - if (current->reloc_count > 0xffff) + if (obj_pe (abfd) && current->reloc_count >= 0xffff) reloc_base += bfd_coff_relsz (abfd); #endif } @@ -4066,6 +4169,11 @@ coff_write_object_contents (abfd) if (amount != bfd_coff_aoutsz (abfd)) return false; + +#ifdef COFF_IMAGE_WITH_PE + if (! coff_apply_checksum (abfd)) + return false; +#endif } #ifdef RS6000COFF_C else @@ -4095,7 +4203,7 @@ coff_set_section_contents (abfd, section, location, offset, count) file_ptr offset; bfd_size_type count; { - if (abfd->output_has_begun == false) /* set by bfd.c handler */ + if (! abfd->output_has_begun) /* set by bfd.c handler */ { if (! coff_compute_section_file_positions (abfd)) return false; @@ -5049,6 +5157,10 @@ dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, } #endif +#ifndef coff_bfd_link_hash_table_free +#define coff_bfd_link_hash_table_free _bfd_generic_link_hash_table_free +#endif + /* If coff_relocate_section is defined, we can use the optimized COFF backend linker. Otherwise we must continue to use the old linker. */ #ifdef coff_relocate_section @@ -5072,6 +5184,7 @@ dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, #define coff_bfd_final_link _bfd_generic_final_link #endif /* ! defined (coff_relocate_section) */ +#define coff_bfd_link_just_syms _bfd_generic_link_just_syms #define coff_bfd_link_split_section _bfd_generic_link_split_section #ifndef coff_start_final_link @@ -5268,6 +5381,10 @@ static const bfd_coff_backend_data bfd_coff_std_swap_table = #define coff_bfd_merge_sections bfd_generic_merge_sections #endif +#ifndef coff_bfd_discard_group +#define coff_bfd_discard_group bfd_generic_discard_group +#endif + #define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE) \ const bfd_target VAR = \ { \ diff --git a/contrib/binutils/bfd/coffgen.c b/contrib/binutils/bfd/coffgen.c index 88591f1..ee6c8fc 100644 --- a/contrib/binutils/bfd/coffgen.c +++ b/contrib/binutils/bfd/coffgen.c @@ -1,6 +1,6 @@ /* Support for the generic parts of COFF, for BFD. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001 + 2000, 2001, 2002 Free Software Foundation, Inc. Written by Cygnus Support. @@ -178,6 +178,7 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) flagword oflags = abfd->flags; bfd_vma ostart = bfd_get_start_address (abfd); PTR tdata; + PTR tdata_save; bfd_size_type readsize; /* length of file_info */ unsigned int scnhsz; char *external_sections; @@ -206,9 +207,10 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) /* Set up the tdata area. ECOFF uses its own routine, and overrides abfd->flags. */ + tdata_save = abfd->tdata.any; tdata = bfd_coff_mkobject_hook (abfd, (PTR) internal_f, (PTR) internal_a); if (tdata == NULL) - return 0; + goto fail2; scnhsz = bfd_coff_scnhsz (abfd); readsize = (bfd_size_type) nscns * scnhsz; @@ -221,7 +223,7 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) /* Set the arch/mach *before* swapping in sections; section header swapping may depend on arch/mach info. */ - if (bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f) == false) + if (! bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f)) goto fail; /* Now copy data as required; construct all asections etc */ @@ -245,6 +247,8 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) fail: bfd_release (abfd, tdata); + fail2: + abfd->tdata.any = tdata_save; abfd->flags = oflags; bfd_get_start_address (abfd) = ostart; return (const bfd_target *) NULL; @@ -270,12 +274,13 @@ coff_object_p (abfd) filehdr = bfd_alloc (abfd, filhsz); if (filehdr == NULL) - return 0; + return NULL; if (bfd_bread (filehdr, filhsz, abfd) != filhsz) { if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); - return 0; + bfd_release (abfd, filehdr); + return NULL; } bfd_coff_swap_filehdr_in (abfd, filehdr, &internal_f); bfd_release (abfd, filehdr); @@ -288,11 +293,11 @@ coff_object_p (abfd) only read in f_opthdr bytes in the call to bfd_bread. We should also attempt to catch corrupt or non-COFF binaries with a strange value for f_opthdr. */ - if (bfd_coff_bad_format_hook (abfd, &internal_f) == false + if (! bfd_coff_bad_format_hook (abfd, &internal_f) || internal_f.f_opthdr > aoutsz) { bfd_set_error (bfd_error_wrong_format); - return 0; + return NULL; } nscns = internal_f.f_nscns; @@ -302,13 +307,15 @@ coff_object_p (abfd) opthdr = bfd_alloc (abfd, aoutsz); if (opthdr == NULL) - return 0; + return NULL; if (bfd_bread (opthdr, (bfd_size_type) internal_f.f_opthdr, abfd) != internal_f.f_opthdr) { - return 0; + bfd_release (abfd, opthdr); + return NULL; } bfd_coff_swap_aouthdr_in (abfd, opthdr, (PTR) &internal_a); + bfd_release (abfd, opthdr); } return coff_real_object_p (abfd, nscns, &internal_f, @@ -1438,13 +1445,13 @@ coff_section_symbol (abfd, name) combined_entry_type e[10]; }; struct foo *f; - f = (struct foo *) bfd_alloc (abfd, (bfd_size_type) sizeof (*f)); + + f = (struct foo *) bfd_zalloc (abfd, (bfd_size_type) sizeof (*f)); if (!f) { bfd_set_error (bfd_error_no_error); return NULL; } - memset ((char *) f, 0, sizeof (*f)); coff_symbol_from (abfd, sym)->native = csym = f->e; } csym[0].u.syment.n_sclass = C_STAT; @@ -1835,10 +1842,9 @@ coff_get_normalized_symtab (abfd) if (internal_ptr->u.syment._n._n_name[i] == '\0') break; - newstring = (PTR) bfd_alloc (abfd, (bfd_size_type) (i + 1)); + newstring = (PTR) bfd_zalloc (abfd, (bfd_size_type) (i + 1)); if (newstring == NULL) return (NULL); - memset (newstring, 0, i + 1); strncpy (newstring, internal_ptr->u.syment._n._n_name, i); internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring; internal_ptr->u.syment._n._n_n._n_zeroes = 0; @@ -1897,10 +1903,9 @@ coff_make_empty_symbol (abfd) bfd *abfd; { bfd_size_type amt = sizeof (coff_symbol_type); - coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, amt); + coff_symbol_type *new = (coff_symbol_type *) bfd_zalloc (abfd, amt); if (new == NULL) return (NULL); - memset (new, 0, sizeof *new); new->symbol.section = 0; new->native = 0; new->lineno = (alent *) NULL; @@ -2415,7 +2420,7 @@ coff_sizeof_headers (abfd, reloc) { size_t size; - if (reloc == false) + if (! reloc) { size = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd); } @@ -2453,12 +2458,10 @@ bfd_coff_set_symbol_class (abfd, symbol, class) combined_entry_type * native; bfd_size_type amt = sizeof (* native); - native = (combined_entry_type *) bfd_alloc (abfd, amt); + native = (combined_entry_type *) bfd_zalloc (abfd, amt); if (native == NULL) return false; - memset (native, 0, sizeof (* native)); - native->u.syment.n_type = T_NULL; native->u.syment.n_sclass = class; diff --git a/contrib/binutils/bfd/cofflink.c b/contrib/binutils/bfd/cofflink.c index 8a80c14..eb9388f 100644 --- a/contrib/binutils/bfd/cofflink.c +++ b/contrib/binutils/bfd/cofflink.c @@ -119,13 +119,13 @@ _bfd_coff_link_hash_table_create (abfd) struct coff_link_hash_table *ret; bfd_size_type amt = sizeof (struct coff_link_hash_table); - ret = (struct coff_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct coff_link_hash_table *) bfd_malloc (amt); if (ret == NULL) return NULL; if (! _bfd_coff_link_hash_table_init (ret, abfd, _bfd_coff_link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return (struct bfd_link_hash_table *) NULL; } return &ret->root; @@ -342,12 +342,10 @@ coff_link_add_symbols (abfd, info) /* We keep a list of the linker hash table entries that correspond to particular symbols. */ amt = symcount * sizeof (struct coff_link_hash_entry *); - sym_hash = (struct coff_link_hash_entry **) bfd_alloc (abfd, amt); + sym_hash = (struct coff_link_hash_entry **) bfd_zalloc (abfd, amt); if (sym_hash == NULL && symcount != 0) goto error_return; obj_coff_sym_hashes (abfd) = sym_hash; - memset (sym_hash, 0, - (size_t) symcount * sizeof (struct coff_link_hash_entry *)); symesz = bfd_coff_symesz (abfd); BFD_ASSERT (symesz == bfd_coff_auxesz (abfd)); @@ -759,6 +757,10 @@ _bfd_coff_final_link (abfd, info) o->flags |= SEC_RELOC; o->rel_filepos = rel_filepos; rel_filepos += o->reloc_count * relsz; + /* In PE COFF, if there are at least 0xffff relocations an + extra relocation will be written out to encode the count. */ + if (obj_pe (abfd) && o->reloc_count >= 0xffff) + rel_filepos += relsz; } if (bfd_coff_long_section_names (abfd) diff --git a/contrib/binutils/bfd/coffswap.h b/contrib/binutils/bfd/coffswap.h index 454e686..cd147c5 100644 --- a/contrib/binutils/bfd/coffswap.h +++ b/contrib/binutils/bfd/coffswap.h @@ -244,13 +244,7 @@ coff_swap_reloc_in (abfd, src, dst) reloc_dst->r_vaddr = GET_RELOC_VADDR (abfd, reloc_src->r_vaddr); reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); - -#ifdef RS6000COFF_C - reloc_dst->r_type = H_GET_8 (abfd, reloc_src->r_type); - reloc_dst->r_size = H_GET_8 (abfd, reloc_src->r_size); -#else reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); -#endif #ifdef SWAP_IN_RELOC_OFFSET reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); @@ -267,13 +261,7 @@ coff_swap_reloc_out (abfd, src, dst) struct external_reloc *reloc_dst = (struct external_reloc *) dst; PUT_RELOC_VADDR (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); - -#ifdef RS6000COFF_C - H_PUT_8 (abfd, reloc_src->r_type, reloc_dst->r_type); - H_PUT_8 (abfd, reloc_src->r_size, reloc_dst->r_size); -#else H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); -#endif #ifdef SWAP_OUT_RELOC_OFFSET SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); diff --git a/contrib/binutils/bfd/config.bfd b/contrib/binutils/bfd/config.bfd index 58c7315..184bbef 100755 --- a/contrib/binutils/bfd/config.bfd +++ b/contrib/binutils/bfd/config.bfd @@ -35,6 +35,7 @@ alpha*) targ_archs=bfd_alpha_arch ;; arm*) targ_archs=bfd_arm_arch ;; c30*) targ_archs=bfd_tic30_arch ;; c54x*) targ_archs=bfd_tic54x_arch ;; +dlx*) targ_archs=bfd_dlx_arch ;; hppa*) targ_archs=bfd_hppa_arch ;; i[3456]86) targ_archs=bfd_i386_arch ;; i370) targ_archs=bfd_i370_arch ;; @@ -57,7 +58,6 @@ v850*) targ_archs=bfd_v850_arch ;; x86_64) targ_archs=bfd_i386_arch ;; xscale*) targ_archs=bfd_arm_arch ;; z8k*) targ_archs=bfd_z8k_arch ;; -sh*) targ_archs=bfd_sh_arch ;; *) targ_archs=bfd_${targ_cpu}_arch ;; esac @@ -70,7 +70,16 @@ esac case "${targ}" in # START OF targmatch.h #ifdef BFD64 - alpha*-*-netbsd* | alpha*-*-freebsd*) + alpha*-*-freebsd*) + targ_defvec=bfd_elf64_alpha_freebsd_vec + targ_selvecs=ecoffalpha_little_vec + # FreeBSD <= 4.0 supports only the old nonstandard way of ABI labelling. + case "${targ}" in + alpha*-*-freebsd3* | alpha*-*-freebsd4 | alpha*-*-freebsd4.0*) + targ_cflags=-DOLD_FREEBSD_ABI_LABEL ;; + esac + ;; + alpha*-*-netbsd* | alpha*-*-openbsd*) targ_defvec=bfd_elf64_alpha_vec targ_selvecs=ecoffalpha_little_vec ;; @@ -104,7 +113,7 @@ case "${targ}" in targ_defvec=bfd_elf32_ia64_hpux_big_vec targ_selvecs="bfd_elf64_ia64_hpux_big_vec" ;; - sparc64-*-freebsd* | sparc64-*-netbsd*) + sparc64-*-freebsd* | sparc64-*-netbsd* | sparc64-*-openbsd*) targ_defvec=bfd_elf64_sparc_vec targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec" ;; @@ -115,12 +124,17 @@ case "${targ}" in targ_selvecs=bfd_elf32_bigarc_vec ;; + armeb-*-netbsdelf*) + targ_defvec=bfd_elf32_bigarm_vec + targ_selvecs="bfd_elf32_littlearm_vec armnetbsd_vec" + ;; arm-*-netbsdelf*) targ_defvec=bfd_elf32_littlearm_vec targ_selvecs="bfd_elf32_bigarm_vec armnetbsd_vec" ;; arm-*-netbsd* | arm-*-openbsd*) targ_defvec=armnetbsd_vec + targ_selvecs="bfd_elf32_littlearm_vec bfd_elf32_bigarm_vec" targ_underscore=yes ;; arm-*-riscix*) @@ -263,6 +277,11 @@ case "${targ}" in targ_defvec=bfd_elf32_d10v_vec ;; + dlx-*-elf*) + targ_defvec=bfd_elf32_dlx_big_vec + targ_selvecs="bfd_elf32_dlx_big_vec" + ;; + d30v-*-*) targ_defvec=bfd_elf32_d30v_vec ;; @@ -271,6 +290,10 @@ case "${targ}" in targ_defvec=bfd_elf32_fr30_vec ;; + frv-*-elf) + targ_defvec=bfd_elf32_frv_vec + ;; + h8300*-*-elf) targ_defvec=bfd_elf32_h8300_vec @@ -303,7 +326,7 @@ case "${targ}" in targ_defvec=bfd_elf32_hppa_linux_vec targ_selvecs=bfd_elf32_hppa_vec ;; - hppa*-*-*elf* | hppa*-*-lites* | hppa*-*-netbsd* | hppa*-*-sysv4* | hppa*-*-rtems*) + hppa*-*-*elf* | hppa*-*-lites* | hppa*-*-netbsd* | hppa*-*-sysv4* | hppa*-*-rtems* | hppa*-*-openbsd*) targ_defvec=bfd_elf32_hppa_vec targ_selvecs=bfd_elf32_hppa_linux_vec ;; @@ -336,10 +359,14 @@ case "${targ}" in targ_defvec=bfd_elf32_i386_vec targ_selvecs=i386coff_vec ;; + i[3456]86-*-nto-qnx*) + targ_defvec=bfd_elf32_i386qnx_vec + targ_selvecs=i386coff_vec + ;; i[3456]86-*-chorus*) targ_defvec=bfd_elf32_i386_vec ;; - i[3456]86-*-msdosdjgpp* | i[3456]*-*-go32* | i[3456]86-go32-rtems* ) + *-*-msdosdjgpp* | *-*-go32* | *-go32-rtems* ) targ_defvec=go32coff_vec targ_selvecs="go32stubbedcoff_vec i386aout_vec" ;; @@ -370,13 +397,22 @@ case "${targ}" in targ_underscore=yes ;; i[3456]86-*-freebsd*) - targ_defvec=bfd_elf32_i386_vec + targ_defvec=bfd_elf32_i386_freebsd_vec targ_selvecs=i386coff_vec + # FreeBSD <= 4.0 supports only the old nonstandard way of ABI labelling. + case "${targ}" in + i[3456]86-*-freebsd3* | i[3456]86-*-freebsd4 | i[3456]86-*-freebsd4.0*) + targ_cflags=-DOLD_FREEBSD_ABI_LABEL ;; + esac ;; i[3456]86-*-netbsdelf*) targ_defvec=bfd_elf32_i386_vec targ_selvecs=i386netbsd_vec ;; + i[3456]86-*-netbsdpe*) + targ_defvec=i386pe_vec + targ_selvecs="i386pe_vec i386pei_vec bfd_elf32_i386_vec" + ;; i[3456]86-*-netbsdaout* | i[3456]86-*-netbsd* | i[3456]86-*-openbsd*) targ_defvec=i386netbsd_vec targ_selvecs="bfd_elf32_i386_vec i386bsd_vec" @@ -785,11 +821,24 @@ case "${targ}" in targ_selvecs="bfd_elf32_pjl_vec bfd_elf32_pj_vec bfd_elf32_i386_vec" ;; + powerpc-*-aix5*) + targ_defvec=rs6000coff_vec + targ_selvecs="aix5coff64_vec" + want64=true + ;; +#ifdef BFD64 + powerpc64-*-aix5*) + targ_defvec=aix5coff64_vec + targ_selvecs="rs6000coff_vec" + want64=true + ;; +#endif + powerpc-*-aix* | powerpc-*-beos* | rs6000-*-*) targ_defvec=rs6000coff_vec targ64_selvecs=rs6000coff64_vec case "${targ}" in - *-*-aix4.[3456789]* | *-*-aix[56789]*) + *-*-aix4.[3456789]* | *-*-aix[56789]*) want64=true;; *) @@ -812,7 +861,7 @@ case "${targ}" in #endif powerpc-*-*bsd* | powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \ powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-rtems* | \ - powerpc-*-chorus* | powerpc-*-vxworks*) + powerpc-*-chorus* | powerpc-*-vxworks* | powerpc-*-windiss*) targ_defvec=bfd_elf32_powerpc_vec targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec ppcboot_vec" targ64_selvecs="bfd_elf64_powerpc_vec bfd_elf64_powerpcle_vec" @@ -847,11 +896,24 @@ case "${targ}" in #endif #ifdef BFD64 + sh64l*-*-elf*) + targ_defvec=bfd_elf32_sh64l_vec + targ_selvecs="bfd_elf32_sh64_vec bfd_elf64_sh64l_vec bfd_elf64_sh64_vec bfd_elf32_shl_vec bfd_elf32_sh_vec" + targ_underscore=yes + ;; sh64-*-elf*) targ_defvec=bfd_elf32_sh64_vec targ_selvecs="bfd_elf32_sh64l_vec bfd_elf64_sh64_vec bfd_elf64_sh64l_vec bfd_elf32_sh_vec bfd_elf32_shl_vec" targ_underscore=yes ;; + sh64eb-*-linux*) + targ_defvec=bfd_elf32_shblin_vec + targ_selvecs="bfd_elf32_shblin_vec bfd_elf32_sh64_vec bfd_elf64_sh64_vec bfd_elf32_sh_vec" + ;; + sh64-*-linux*) + targ_defvec=bfd_elf32_shlin_vec + targ_selvecs="bfd_elf32_shlin_vec bfd_elf32_sh64l_vec bfd_elf64_sh64l_vec bfd_elf32_shl_vec" + ;; #endif /* BFD64 */ sh-*-linux*) @@ -868,6 +930,33 @@ case "${targ}" in targ_defvec=bfd_elf32_shlin_vec ;; +#ifdef BFD64 + sh5le-*-netbsd*) + targ_defvec=bfd_elf32_sh64lnbsd_vec + targ_selvecs="bfd_elf32_sh64nbsd_vec bfd_elf64_sh64lnbsd_vec bfd_elf64_sh64nbsd_vec" + ;; + sh5-*-netbsd*) + targ_defvec=bfd_elf32_sh64nbsd_vec + targ_selvecs="bfd_elf32_sh64lnbsd_vec bfd_elf64_sh64lnbsd_vec bfd_elf64_sh64nbsd_vec" + ;; + + sh64le-*-netbsd*) + targ_defvec=bfd_elf64_sh64lnbsd_vec + targ_selvecs="bfd_elf64_sh64nbsd_vec bfd_elf32_sh64lnbsd_vec bfd_elf32_sh64nbsd_vec" + ;; + sh64-*-netbsd*) + targ_defvec=bfd_elf64_sh64nbsd_vec + targ_selvecs="bfd_elf64_sh64lnbsd_vec bfd_elf32_sh64lnbsd_vec bfd_elf32_sh64nbsd_vec" + ;; +#endif + + shle-*-netbsdelf*) + targ_defvec=bfd_elf32_shlnbsd_vec + targ_selvecs="bfd_elf32_shnbsd_vec shcoff_vec shlcoff_vec" +#ifdef BFD64 + targ_selvecs="${targ_selvecs} bfd_elf32_sh64_vec bfd_elf32_sh64l_vec bfd_elf64_sh64_vec bfd_elf64_sh64l_vec" +#endif + ;; sh*le-*-netbsdelf*) targ_defvec=bfd_elf32_shlnbsd_vec targ_selvecs="bfd_elf32_shnbsd_vec shcoff_vec shlcoff_vec" @@ -884,7 +973,15 @@ case "${targ}" in targ_selvecs="bfd_elf32_shlnbsd_vec shcoff_vec shlcoff_vec" ;; - sh-*-elf* | sh-*-rtemself*) + shl*-*-elf* | sh[1234]l*-*-elf* | sh3el*-*-elf*) + targ_defvec=bfd_elf32_shl_vec + targ_selvecs="bfd_elf32_sh_vec shlcoff_vec shcoff_vec shlcoff_small_vec shcoff_small_vec" +#ifdef BFD64 + targ_selvecs="${targ_selvecs} bfd_elf32_sh64_vec bfd_elf32_sh64l_vec bfd_elf64_sh64_vec bfd_elf64_sh64l_vec" +#endif + targ_underscore=yes + ;; + sh-*-elf* | sh[1234]*-elf* | sh-*-rtemself*) targ_defvec=bfd_elf32_sh_vec targ_selvecs="bfd_elf32_shl_vec shcoff_vec shlcoff_vec shcoff_small_vec shlcoff_small_vec" #ifdef BFD64 @@ -1014,12 +1111,22 @@ case "${targ}" in v850ea-*-*) targ_defvec=bfd_elf32_v850_vec ;; -#if HAVE_host_aout_vec + + vax-*-netbsdelf*) + targ_defvec=bfd_elf32_vax_vec + targ_selvecs="vaxnetbsd_vec vax1knetbsd_vec" + ;; + + vax-*-netbsdaout* | vax-*-netbsd*) + targ_defvec=vaxnetbsd_vec + targ_selvecs="bfd_elf32_vax_vec vax1knetbsd_vec" + targ_underscore=yes + ;; + vax-*-bsd* | vax-*-ultrix*) - targ_defvec=host_aout_vec + targ_defvec=vaxbsd_vec targ_underscore=yes ;; -#endif vax*-*-*vms*) targ_defvec=vms_vax_vec diff --git a/contrib/binutils/bfd/configure b/contrib/binutils/bfd/configure index 94c88ab..6d12109 100755 --- a/contrib/binutils/bfd/configure +++ b/contrib/binutils/bfd/configure @@ -37,6 +37,8 @@ ac_help="$ac_help --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer" ac_help="$ac_help + --install-libbfd controls installation of libbfd and related headers" +ac_help="$ac_help --disable-nls do not use Native Language Support" ac_help="$ac_help --with-included-gettext use the GNU gettext library included here" @@ -550,12 +552,12 @@ else fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:554: checking for Cygwin environment" >&5 +echo "configure:556: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 559 "configure" +#line 561 "configure" #include "confdefs.h" int main() { @@ -566,7 +568,7 @@ int main() { return __CYGWIN__; ; return 0; } EOF -if { (eval echo configure:570: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:572: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -583,19 +585,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:587: checking for mingw32 environment" >&5 +echo "configure:589: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 592 "configure" +#line 594 "configure" #include "confdefs.h" int main() { return __MINGW32__; ; return 0; } EOF -if { (eval echo configure:599: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:601: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -660,7 +662,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:664: checking host system type" >&5 +echo "configure:666: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -681,7 +683,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:685: checking target system type" >&5 +echo "configure:687: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -699,7 +701,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:703: checking build system type" >&5 +echo "configure:705: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -724,7 +726,7 @@ test "$host_alias" != "$target_alias" && # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:728: checking for $ac_word" >&5 +echo "configure:730: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -754,7 +756,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:758: checking for $ac_word" >&5 +echo "configure:760: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -805,7 +807,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:809: checking for $ac_word" >&5 +echo "configure:811: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -837,7 +839,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:841: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:843: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -848,12 +850,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 852 "configure" +#line 854 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:859: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -879,12 +881,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:883: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:885: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:888: checking whether we are using GNU C" >&5 +echo "configure:890: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -893,7 +895,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:897: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:899: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -912,7 +914,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:916: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:918: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -944,7 +946,7 @@ else fi echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 -echo "configure:948: checking for POSIXized ISC" >&5 +echo "configure:950: checking for POSIXized ISC" >&5 if test -d /etc/conf/kconfig.d && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 then @@ -977,7 +979,7 @@ fi # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:981: checking for a BSD compatible install" >&5 +echo "configure:983: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1030,7 +1032,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:1034: checking whether build environment is sane" >&5 +echo "configure:1036: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -1087,7 +1089,7 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:1091: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:1093: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1116,7 +1118,7 @@ fi PACKAGE=bfd -VERSION=2.12.1 +VERSION=2.13 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } @@ -1133,7 +1135,7 @@ EOF missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:1137: checking for working aclocal" >&5 +echo "configure:1139: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1146,7 +1148,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:1150: checking for working autoconf" >&5 +echo "configure:1152: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1159,7 +1161,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:1163: checking for working automake" >&5 +echo "configure:1165: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1172,7 +1174,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:1176: checking for working autoheader" >&5 +echo "configure:1178: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1185,7 +1187,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:1189: checking for working makeinfo" >&5 +echo "configure:1191: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1199,7 +1201,7 @@ fi # Uncomment the next line to remove the date from the reported bfd version -is_release=y +# is_release=y bfd_version=`echo "${VERSION}" | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$/\1\2\3\4\5/'` @@ -1221,7 +1223,7 @@ fi # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1225: checking for $ac_word" >&5 +echo "configure:1227: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1253,7 +1255,7 @@ fi # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1257: checking for $ac_word" >&5 +echo "configure:1259: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1285,7 +1287,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1289: checking for $ac_word" >&5 +echo "configure:1291: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1400,7 +1402,7 @@ ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 -echo "configure:1404: checking for ld used by GCC" >&5 +echo "configure:1406: checking for ld used by GCC" >&5 case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw @@ -1430,10 +1432,10 @@ echo "configure:1404: checking for ld used by GCC" >&5 esac elif test "$with_gnu_ld" = yes; then echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:1434: checking for GNU ld" >&5 +echo "configure:1436: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:1437: checking for non-GNU ld" >&5 +echo "configure:1439: checking for non-GNU ld" >&5 fi if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1468,7 +1470,7 @@ else fi test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 -echo "configure:1472: checking if the linker ($LD) is GNU ld" >&5 +echo "configure:1474: checking if the linker ($LD) is GNU ld" >&5 if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1485,7 +1487,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6 -echo "configure:1489: checking for $LD option to reload object files" >&5 +echo "configure:1491: checking for $LD option to reload object files" >&5 if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1497,7 +1499,7 @@ reload_flag=$lt_cv_ld_reload_flag test -n "$reload_flag" && reload_flag=" $reload_flag" echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:1501: checking for BSD-compatible nm" >&5 +echo "configure:1503: checking for BSD-compatible nm" >&5 if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1535,7 +1537,7 @@ NM="$lt_cv_path_NM" echo "$ac_t""$NM" 1>&6 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1539: checking whether ln -s works" >&5 +echo "configure:1541: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1556,7 +1558,7 @@ else fi echo $ac_n "checking how to recognise dependant libraries""... $ac_c" 1>&6 -echo "configure:1560: checking how to recognise dependant libraries" >&5 +echo "configure:1562: checking how to recognise dependant libraries" >&5 if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1729,13 +1731,13 @@ file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:1733: checking for object suffix" >&5 +echo "configure:1735: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:1739: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1741: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -1755,7 +1757,7 @@ ac_objext=$ac_cv_objext echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1759: checking for executable suffix" >&5 +echo "configure:1761: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1765,10 +1767,10 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1771: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in - *.c | *.o | *.obj) ;; + *.$ac_ext | *.c | *.o | *.obj) ;; *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; esac done @@ -1792,7 +1794,7 @@ case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6 -echo "configure:1796: checking for ${ac_tool_prefix}file" >&5 +echo "configure:1798: checking for ${ac_tool_prefix}file" >&5 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1854,7 +1856,7 @@ fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then echo $ac_n "checking for file""... $ac_c" 1>&6 -echo "configure:1858: checking for file" >&5 +echo "configure:1860: checking for file" >&5 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1925,7 +1927,7 @@ esac # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1929: checking for $ac_word" >&5 +echo "configure:1931: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1957,7 +1959,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1961: checking for $ac_word" >&5 +echo "configure:1963: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1992,7 +1994,7 @@ fi # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1996: checking for $ac_word" >&5 +echo "configure:1998: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2024,7 +2026,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2028: checking for $ac_word" >&5 +echo "configure:2030: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2091,8 +2093,8 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic" case $host in *-*-irix6*) # Find out which ABI we are using. - echo '#line 2095 "configure"' > conftest.$ac_ext - if { (eval echo configure:2096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + echo '#line 2097 "configure"' > conftest.$ac_ext + if { (eval echo configure:2098: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" @@ -2111,7 +2113,7 @@ case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext - if { (eval echo configure:2115: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + if { (eval echo configure:2117: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case "`/usr/bin/file conftest.o`" in *ELF-32*) HPUX_IA64_MODE="32" @@ -2129,7 +2131,7 @@ ia64-*-hpux*) SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 -echo "configure:2133: checking whether the C compiler needs -belf" >&5 +echo "configure:2135: checking whether the C compiler needs -belf" >&5 if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2142,14 +2144,14 @@ ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$a cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext <<EOF -#line 2146 "configure" +#line 2148 "configure" #include "confdefs.h" int main() { ; return 0; } EOF -if { (eval echo configure:2153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2155: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_cc_needs_belf=yes else @@ -2339,7 +2341,7 @@ if test -z "$target" ; then fi echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:2343: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:2345: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -2361,10 +2363,45 @@ fi MAINT=$MAINTAINER_MODE_TRUE +echo $ac_n "checking whether to install libbfd""... $ac_c" 1>&6 +echo "configure:2368: checking whether to install libbfd" >&5 + # Check whether --enable-install-libbfd or --disable-install-libbfd was given. +if test "${enable_install_libbfd+set}" = set; then + enableval="$enable_install_libbfd" + install_libbfd_p=$enableval +else + if test "${host}" = "${target}" -o "$enable_shared" = "yes"; then + install_libbfd_p=yes + else + install_libbfd_p=no + fi +fi + + echo "$ac_t""$install_libbfd_p" 1>&6 + + +if test $install_libbfd_p = yes; then + INSTALL_LIBBFD_TRUE= + INSTALL_LIBBFD_FALSE='#' +else + INSTALL_LIBBFD_TRUE='#' + INSTALL_LIBBFD_FALSE= +fi + # libbfd.a is a host library containing target dependent code + bfdlibdir='$(libdir)' + bfdincludedir='$(includedir)' + if test "${host}" != "${target}"; then + bfdlibdir='$(exec_prefix)/$(host_alias)/$(target_alias)/lib' + bfdincludedir='$(exec_prefix)/$(host_alias)/$(target_alias)/include' + fi + + + + echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:2368: checking for executable suffix" >&5 +echo "configure:2405: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2374,10 +2411,10 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:2378: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:2415: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in - *.c | *.o | *.obj) ;; + *.$ac_ext | *.c | *.o | *.obj) ;; *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; esac done @@ -2404,7 +2441,7 @@ bfd_default_target_size=32 # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2408: checking for $ac_word" >&5 +echo "configure:2445: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2434,7 +2471,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2438: checking for $ac_word" >&5 +echo "configure:2475: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2485,7 +2522,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2489: checking for $ac_word" >&5 +echo "configure:2526: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2517,7 +2554,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:2521: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:2558: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -2528,12 +2565,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 2532 "configure" +#line 2569 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:2537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2574: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -2559,12 +2596,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:2563: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:2600: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:2568: checking whether we are using GNU C" >&5 +echo "configure:2605: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2573,7 +2610,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2577: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2614: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -2592,7 +2629,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:2596: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:2633: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2624,9 +2661,9 @@ else fi -ALL_LINGUAS="fr tr ja es sv" +ALL_LINGUAS="fr tr ja es sv da" echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:2630: checking how to run the C preprocessor" >&5 +echo "configure:2667: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -2641,13 +2678,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext <<EOF -#line 2645 "configure" +#line 2682 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2651: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2688: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -2658,13 +2695,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext <<EOF -#line 2662 "configure" +#line 2699 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2668: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2705: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -2675,13 +2712,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext <<EOF -#line 2679 "configure" +#line 2716 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2685: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2722: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -2708,7 +2745,7 @@ echo "$ac_t""$CPP" 1>&6 # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2712: checking for $ac_word" >&5 +echo "configure:2749: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2736,12 +2773,12 @@ else fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:2740: checking for ANSI C header files" >&5 +echo "configure:2777: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2745 "configure" +#line 2782 "configure" #include "confdefs.h" #include <stdlib.h> #include <stdarg.h> @@ -2749,7 +2786,7 @@ else #include <float.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2753: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2790: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2766,7 +2803,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 2770 "configure" +#line 2807 "configure" #include "confdefs.h" #include <string.h> EOF @@ -2784,7 +2821,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 2788 "configure" +#line 2825 "configure" #include "confdefs.h" #include <stdlib.h> EOF @@ -2805,7 +2842,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext <<EOF -#line 2809 "configure" +#line 2846 "configure" #include "confdefs.h" #include <ctype.h> #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -2816,7 +2853,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:2820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2840,12 +2877,12 @@ EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:2844: checking for working const" >&5 +echo "configure:2881: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2849 "configure" +#line 2886 "configure" #include "confdefs.h" int main() { @@ -2894,7 +2931,7 @@ ccp = (char const *const *) p; ; return 0; } EOF -if { (eval echo configure:2898: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2935: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -2915,21 +2952,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:2919: checking for inline" >&5 +echo "configure:2956: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <<EOF -#line 2926 "configure" +#line 2963 "configure" #include "confdefs.h" int main() { } $ac_kw foo() { ; return 0; } EOF -if { (eval echo configure:2933: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2970: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -2955,12 +2992,12 @@ EOF esac echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:2959: checking for off_t" >&5 +echo "configure:2996: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2964 "configure" +#line 3001 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -2988,12 +3025,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:2992: checking for size_t" >&5 +echo "configure:3029: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2997 "configure" +#line 3034 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -3023,19 +3060,19 @@ fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:3027: checking for working alloca.h" >&5 +echo "configure:3064: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3032 "configure" +#line 3069 "configure" #include "confdefs.h" #include <alloca.h> int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:3039: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -3056,12 +3093,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:3060: checking for alloca" >&5 +echo "configure:3097: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3065 "configure" +#line 3102 "configure" #include "confdefs.h" #ifdef __GNUC__ @@ -3089,7 +3126,7 @@ int main() { char *p = (char *) alloca(1); ; return 0; } EOF -if { (eval echo configure:3093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -3121,12 +3158,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:3125: checking whether alloca needs Cray hooks" >&5 +echo "configure:3162: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3130 "configure" +#line 3167 "configure" #include "confdefs.h" #if defined(CRAY) && ! defined(CRAY2) webecray @@ -3151,12 +3188,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3155: checking for $ac_func" >&5 +echo "configure:3192: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3160 "configure" +#line 3197 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3179,7 +3216,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3183: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3220: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3206,7 +3243,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:3210: checking stack direction for C alloca" >&5 +echo "configure:3247: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3214,7 +3251,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <<EOF -#line 3218 "configure" +#line 3255 "configure" #include "confdefs.h" find_stack_direction () { @@ -3233,7 +3270,7 @@ main () exit (find_stack_direction() < 0); } EOF -if { (eval echo configure:3237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -3254,21 +3291,21 @@ EOF fi -for ac_hdr in stdlib.h unistd.h sys/stat.h sys/types.h +for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3262: checking for $ac_hdr" >&5 +echo "configure:3299: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3267 "configure" +#line 3304 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3272: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3309: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3297,12 +3334,12 @@ done for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3301: checking for $ac_func" >&5 +echo "configure:3338: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3306 "configure" +#line 3343 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3325,7 +3362,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3329: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3350,7 +3387,7 @@ fi done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:3354: checking for working mmap" >&5 +echo "configure:3391: checking for working mmap" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3358,7 +3395,7 @@ else ac_cv_func_mmap_fixed_mapped=no else cat > conftest.$ac_ext <<EOF -#line 3362 "configure" +#line 3399 "configure" #include "confdefs.h" /* Thanks to Mike Haertel and Jim Avera for this test. @@ -3386,24 +3423,11 @@ else #include <fcntl.h> #include <sys/mman.h> -#if HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif - -#if HAVE_STDLIB_H -# include <stdlib.h> -#endif - -#if HAVE_SYS_STAT_H -# include <sys/stat.h> -#endif - -#if HAVE_UNISTD_H -# include <unistd.h> -#endif - /* This mess was copied from the GNU getpagesize.h. */ #ifndef HAVE_GETPAGESIZE +# ifdef HAVE_UNISTD_H +# include <unistd.h> +# endif /* Assume that all systems that can run configure have sys/param.h. */ # ifndef HAVE_SYS_PARAM_H @@ -3511,7 +3535,7 @@ main() } EOF -if { (eval echo configure:3515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_fixed_mapped=yes else @@ -3539,17 +3563,17 @@ unistd.h values.h sys/param.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3543: checking for $ac_hdr" >&5 +echo "configure:3567: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3548 "configure" +#line 3572 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3553: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3577: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3579,12 +3603,12 @@ done __argz_count __argz_stringify __argz_next do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3583: checking for $ac_func" >&5 +echo "configure:3607: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3588 "configure" +#line 3612 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3607,7 +3631,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3611: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3636,12 +3660,12 @@ done for ac_func in stpcpy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3640: checking for $ac_func" >&5 +echo "configure:3664: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3645 "configure" +#line 3669 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3664,7 +3688,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3668: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3692: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3698,19 +3722,19 @@ EOF if test $ac_cv_header_locale_h = yes; then echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6 -echo "configure:3702: checking for LC_MESSAGES" >&5 +echo "configure:3726: checking for LC_MESSAGES" >&5 if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3707 "configure" +#line 3731 "configure" #include "confdefs.h" #include <locale.h> int main() { return LC_MESSAGES ; return 0; } EOF -if { (eval echo configure:3714: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* am_cv_val_LC_MESSAGES=yes else @@ -3731,7 +3755,7 @@ EOF fi fi echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6 -echo "configure:3735: checking whether NLS is requested" >&5 +echo "configure:3759: checking whether NLS is requested" >&5 # Check whether --enable-nls or --disable-nls was given. if test "${enable_nls+set}" = set; then enableval="$enable_nls" @@ -3751,7 +3775,7 @@ fi EOF echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6 -echo "configure:3755: checking whether included gettext is requested" >&5 +echo "configure:3779: checking whether included gettext is requested" >&5 # Check whether --with-included-gettext or --without-included-gettext was given. if test "${with_included_gettext+set}" = set; then withval="$with_included_gettext" @@ -3770,17 +3794,17 @@ fi ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for libintl.h""... $ac_c" 1>&6 -echo "configure:3774: checking for libintl.h" >&5 +echo "configure:3798: checking for libintl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3779 "configure" +#line 3803 "configure" #include "confdefs.h" #include <libintl.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3784: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3808: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3797,19 +3821,19 @@ fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for gettext in libc""... $ac_c" 1>&6 -echo "configure:3801: checking for gettext in libc" >&5 +echo "configure:3825: checking for gettext in libc" >&5 if eval "test \"`echo '$''{'gt_cv_func_gettext_libc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3806 "configure" +#line 3830 "configure" #include "confdefs.h" #include <libintl.h> int main() { return (int) gettext ("") ; return 0; } EOF -if { (eval echo configure:3813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3837: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gt_cv_func_gettext_libc=yes else @@ -3825,7 +3849,7 @@ echo "$ac_t""$gt_cv_func_gettext_libc" 1>&6 if test "$gt_cv_func_gettext_libc" != "yes"; then echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6 -echo "configure:3829: checking for bindtextdomain in -lintl" >&5 +echo "configure:3853: checking for bindtextdomain in -lintl" >&5 ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3833,7 +3857,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <<EOF -#line 3837 "configure" +#line 3861 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -3844,7 +3868,7 @@ int main() { bindtextdomain() ; return 0; } EOF -if { (eval echo configure:3848: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3872: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3860,19 +3884,19 @@ fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for gettext in libintl""... $ac_c" 1>&6 -echo "configure:3864: checking for gettext in libintl" >&5 +echo "configure:3888: checking for gettext in libintl" >&5 if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3869 "configure" +#line 3893 "configure" #include "confdefs.h" int main() { return (int) gettext ("") ; return 0; } EOF -if { (eval echo configure:3876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3900: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gt_cv_func_gettext_libintl=yes else @@ -3900,7 +3924,7 @@ EOF # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3904: checking for $ac_word" >&5 +echo "configure:3928: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3934,12 +3958,12 @@ fi for ac_func in dcgettext do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3938: checking for $ac_func" >&5 +echo "configure:3962: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3943 "configure" +#line 3967 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3962,7 +3986,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3966: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3990: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3989,7 +4013,7 @@ done # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3993: checking for $ac_word" >&5 +echo "configure:4017: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4025,7 +4049,7 @@ fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4029: checking for $ac_word" >&5 +echo "configure:4053: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4057,7 +4081,7 @@ else fi cat > conftest.$ac_ext <<EOF -#line 4061 "configure" +#line 4085 "configure" #include "confdefs.h" int main() { @@ -4065,7 +4089,7 @@ extern int _nl_msg_cat_cntr; return _nl_msg_cat_cntr ; return 0; } EOF -if { (eval echo configure:4069: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* CATOBJEXT=.gmo DATADIRNAME=share @@ -4097,7 +4121,7 @@ fi # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4101: checking for $ac_word" >&5 +echo "configure:4125: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4131,7 +4155,7 @@ fi # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4135: checking for $ac_word" >&5 +echo "configure:4159: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4167,7 +4191,7 @@ fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4171: checking for $ac_word" >&5 +echo "configure:4195: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4257,7 +4281,7 @@ fi LINGUAS= else echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6 -echo "configure:4261: checking for catalogs to be installed" >&5 +echo "configure:4285: checking for catalogs to be installed" >&5 NEW_LINGUAS= for lang in ${LINGUAS=$ALL_LINGUAS}; do case "$ALL_LINGUAS" in @@ -4285,17 +4309,17 @@ echo "configure:4261: checking for catalogs to be installed" >&5 if test "$CATOBJEXT" = ".cat"; then ac_safe=`echo "linux/version.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for linux/version.h""... $ac_c" 1>&6 -echo "configure:4289: checking for linux/version.h" >&5 +echo "configure:4313: checking for linux/version.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4294 "configure" +#line 4318 "configure" #include "confdefs.h" #include <linux/version.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4299: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4323: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4373,7 +4397,7 @@ fi # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:4377: checking for a BSD compatible install" >&5 +echo "configure:4401: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4456,7 +4480,7 @@ if test "x$cross_compiling" = "xno"; then EXEEXT_FOR_BUILD='$(EXEEXT)' else echo $ac_n "checking for build system executable suffix""... $ac_c" 1>&6 -echo "configure:4460: checking for build system executable suffix" >&5 +echo "configure:4484: checking for build system executable suffix" >&5 if eval "test \"`echo '$''{'bfd_cv_build_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4484,17 +4508,17 @@ for ac_hdr in stddef.h string.h strings.h stdlib.h time.h unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4488: checking for $ac_hdr" >&5 +echo "configure:4512: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4493 "configure" +#line 4517 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4522: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4524,17 +4548,17 @@ for ac_hdr in fcntl.h sys/file.h sys/time.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4528: checking for $ac_hdr" >&5 +echo "configure:4552: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4533 "configure" +#line 4557 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4538: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4562: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4561,12 +4585,12 @@ fi done echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:4565: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:4589: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4570 "configure" +#line 4594 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/time.h> @@ -4575,7 +4599,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:4579: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4603: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -4600,12 +4624,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:4604: checking for $ac_hdr that defines DIR" >&5 +echo "configure:4628: checking for $ac_hdr that defines DIR" >&5 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4609 "configure" +#line 4633 "configure" #include "confdefs.h" #include <sys/types.h> #include <$ac_hdr> @@ -4613,7 +4637,7 @@ int main() { DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:4617: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4641: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -4638,7 +4662,7 @@ done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:4642: checking for opendir in -ldir" >&5 +echo "configure:4666: checking for opendir in -ldir" >&5 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4646,7 +4670,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <<EOF -#line 4650 "configure" +#line 4674 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -4657,7 +4681,7 @@ int main() { opendir() ; return 0; } EOF -if { (eval echo configure:4661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4685: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4679,7 +4703,7 @@ fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:4683: checking for opendir in -lx" >&5 +echo "configure:4707: checking for opendir in -lx" >&5 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4687,7 +4711,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <<EOF -#line 4691 "configure" +#line 4715 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -4698,7 +4722,7 @@ int main() { opendir() ; return 0; } EOF -if { (eval echo configure:4702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4723,12 +4747,12 @@ fi for ac_func in fcntl getpagesize setitimer sysconf fdopen getuid getgid do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4727: checking for $ac_func" >&5 +echo "configure:4751: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4732 "configure" +#line 4756 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -4751,7 +4775,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:4755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4786,12 +4810,12 @@ EOF esac echo $ac_n "checking whether strstr must be declared""... $ac_c" 1>&6 -echo "configure:4790: checking whether strstr must be declared" >&5 +echo "configure:4814: checking whether strstr must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_strstr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4795 "configure" +#line 4819 "configure" #include "confdefs.h" #include <stdio.h> @@ -4812,7 +4836,7 @@ int main() { char *(*pfn) = (char *(*)) strstr ; return 0; } EOF -if { (eval echo configure:4816: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4840: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_strstr=no else @@ -4833,12 +4857,12 @@ EOF fi echo $ac_n "checking whether malloc must be declared""... $ac_c" 1>&6 -echo "configure:4837: checking whether malloc must be declared" >&5 +echo "configure:4861: checking whether malloc must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_malloc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4842 "configure" +#line 4866 "configure" #include "confdefs.h" #include <stdio.h> @@ -4859,7 +4883,7 @@ int main() { char *(*pfn) = (char *(*)) malloc ; return 0; } EOF -if { (eval echo configure:4863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4887: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_malloc=no else @@ -4880,12 +4904,12 @@ EOF fi echo $ac_n "checking whether realloc must be declared""... $ac_c" 1>&6 -echo "configure:4884: checking whether realloc must be declared" >&5 +echo "configure:4908: checking whether realloc must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_realloc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4889 "configure" +#line 4913 "configure" #include "confdefs.h" #include <stdio.h> @@ -4906,7 +4930,7 @@ int main() { char *(*pfn) = (char *(*)) realloc ; return 0; } EOF -if { (eval echo configure:4910: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4934: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_realloc=no else @@ -4927,12 +4951,12 @@ EOF fi echo $ac_n "checking whether free must be declared""... $ac_c" 1>&6 -echo "configure:4931: checking whether free must be declared" >&5 +echo "configure:4955: checking whether free must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_free'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4936 "configure" +#line 4960 "configure" #include "confdefs.h" #include <stdio.h> @@ -4953,7 +4977,7 @@ int main() { char *(*pfn) = (char *(*)) free ; return 0; } EOF -if { (eval echo configure:4957: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4981: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_free=no else @@ -4974,12 +4998,12 @@ EOF fi echo $ac_n "checking whether getenv must be declared""... $ac_c" 1>&6 -echo "configure:4978: checking whether getenv must be declared" >&5 +echo "configure:5002: checking whether getenv must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_getenv'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4983 "configure" +#line 5007 "configure" #include "confdefs.h" #include <stdio.h> @@ -5000,7 +5024,7 @@ int main() { char *(*pfn) = (char *(*)) getenv ; return 0; } EOF -if { (eval echo configure:5004: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5028: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_getenv=no else @@ -5034,7 +5058,9 @@ if test "${target}" = "${host}"; then COREFILE=trad-core.lo TRAD_HEADER='"hosts/alphalinux.h"' ;; - alpha*-*-netbsd*) COREFILE=netbsd-core.lo ;; + alpha*-*-netbsd* | alpha*-*-openbsd*) + COREFILE=netbsd-core.lo + ;; alpha*-*-*) COREFILE=osf-core.lo ;; arm-*-freebsd*) COREFILE='' ;; arm-*-netbsd*) COREFILE=netbsd-core.lo ;; @@ -5156,8 +5182,11 @@ if test "${target}" = "${host}"; then COREFILE=trad-core.lo TRAD_HEADER='"hosts/m68kaux.h"' ;; - m88*-*-sysv4*) ;; - m88*-motorola-sysv*) COREFILE=ptrace-core.lo ;; + m88*-*-sysv4*) + ;; + m88*-motorola-sysv*) + COREFILE=ptrace-core.lo + ;; m88*-*-mach3*) COREFILE=trad-core.lo TRAD_HEADER='"hosts/m88kmach3.h"' @@ -5169,23 +5198,29 @@ if test "${target}" = "${host}"; then ns32k-*-netbsd* | ns32k-*-openbsd*) COREFILE=netbsd-core.lo ;; - rs6000-*-lynx*) COREFILE=lynx-core.lo ;; + rs6000-*-lynx*) + COREFILE=lynx-core.lo + ;; + rs6000-*-aix5.* | powerpc-*-aix5.*) + COREFILE=rs6000-core.lo + COREFLAG="$COREFLAG -DAIX_5_CORE -DAIX_CORE_DUMPX_CORE" + ;; rs6000-*-aix4.[3-9]* | powerpc-*-aix4.[3-9]*) COREFILE=rs6000-core.lo COREFLAG="$COREFLAG -DAIX_CORE_DUMPX_CORE" # Not all versions of AIX with -DAIX_CORE_DUMPX_CORE # have c_impl as a member of struct core_dumpx echo $ac_n "checking for c_impl in struct core_dumpx""... $ac_c" 1>&6 -echo "configure:5180: checking for c_impl in struct core_dumpx" >&5 +echo "configure:5215: checking for c_impl in struct core_dumpx" >&5 cat > conftest.$ac_ext <<EOF -#line 5182 "configure" +#line 5217 "configure" #include "confdefs.h" #include <core.h> int main() { struct core_dumpx c; c.c_impl = 0; ; return 0; } EOF -if { (eval echo configure:5189: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5224: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_ST_C_IMPL 1 @@ -5210,13 +5245,14 @@ rm -f conftest* powerpc-*-*bsd*) COREFILE=netbsd-core.lo ;; s390*-*-*) COREFILE=trad-core.lo ;; sh*-*-netbsd*) COREFILE=netbsd-core.lo ;; - sparc-*-netbsd* | sparc-*-openbsd*) + sparc-*-netbsd* | sparc*-*-openbsd*) COREFILE=netbsd-core.lo ;; tahoe-*-*) COREFILE=trad-core.lo TRAD_HEADER='"hosts/tahoe.h"' ;; + vax-*-netbsd*) COREFILE=netbsd-core.lo ;; vax-*-ultrix2*) COREFILE=trad-core.lo TRAD_HEADER='"hosts/vaxult2.h"' @@ -5252,17 +5288,17 @@ rm -f conftest* do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5256: checking for $ac_hdr" >&5 +echo "configure:5292: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5261 "configure" +#line 5297 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5266: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5302: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5290,12 +5326,12 @@ done if test "$ac_cv_header_sys_procfs_h" = yes; then echo $ac_n "checking for prstatus_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5294: checking for prstatus_t in sys/procfs.h" >&5 +echo "configure:5330: checking for prstatus_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prstatus_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5299 "configure" +#line 5335 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5304,7 +5340,7 @@ int main() { prstatus_t avar ; return 0; } EOF -if { (eval echo configure:5308: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5344: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_prstatus_t=yes else @@ -5326,12 +5362,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_prstatus_t" 1>&6 echo $ac_n "checking for prstatus32_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5330: checking for prstatus32_t in sys/procfs.h" >&5 +echo "configure:5366: checking for prstatus32_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prstatus32_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5335 "configure" +#line 5371 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5340,7 +5376,7 @@ int main() { prstatus32_t avar ; return 0; } EOF -if { (eval echo configure:5344: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5380: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_prstatus32_t=yes else @@ -5362,12 +5398,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_prstatus32_t" 1>&6 echo $ac_n "checking for prstatus_t.pr_who in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5366: checking for prstatus_t.pr_who in sys/procfs.h" >&5 +echo "configure:5402: checking for prstatus_t.pr_who in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_member_prstatus_t_pr_who'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5371 "configure" +#line 5407 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5376,7 +5412,7 @@ int main() { prstatus_t avar; void* aref = (void*) &avar.pr_who ; return 0; } EOF -if { (eval echo configure:5380: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5416: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_member_prstatus_t_pr_who=yes else @@ -5398,12 +5434,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_prstatus_t_pr_who" 1>&6 echo $ac_n "checking for prstatus32_t.pr_who in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5402: checking for prstatus32_t.pr_who in sys/procfs.h" >&5 +echo "configure:5438: checking for prstatus32_t.pr_who in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_member_prstatus32_t_pr_who'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5407 "configure" +#line 5443 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5412,7 +5448,7 @@ int main() { prstatus32_t avar; void* aref = (void*) &avar.pr_who ; return 0; } EOF -if { (eval echo configure:5416: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5452: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_member_prstatus32_t_pr_who=yes else @@ -5434,12 +5470,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_prstatus32_t_pr_who" 1>&6 echo $ac_n "checking for pstatus_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5438: checking for pstatus_t in sys/procfs.h" >&5 +echo "configure:5474: checking for pstatus_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_pstatus_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5443 "configure" +#line 5479 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5448,7 +5484,7 @@ int main() { pstatus_t avar ; return 0; } EOF -if { (eval echo configure:5452: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5488: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_pstatus_t=yes else @@ -5470,12 +5506,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_pstatus_t" 1>&6 echo $ac_n "checking for pxstatus_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5474: checking for pxstatus_t in sys/procfs.h" >&5 +echo "configure:5510: checking for pxstatus_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_pxstatus_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5479 "configure" +#line 5515 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5484,7 +5520,7 @@ int main() { pxstatus_t avar ; return 0; } EOF -if { (eval echo configure:5488: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5524: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_pxstatus_t=yes else @@ -5506,12 +5542,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_pxstatus_t" 1>&6 echo $ac_n "checking for pstatus32_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5510: checking for pstatus32_t in sys/procfs.h" >&5 +echo "configure:5546: checking for pstatus32_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_pstatus32_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5515 "configure" +#line 5551 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5520,7 +5556,7 @@ int main() { pstatus32_t avar ; return 0; } EOF -if { (eval echo configure:5524: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5560: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_pstatus32_t=yes else @@ -5542,12 +5578,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_pstatus32_t" 1>&6 echo $ac_n "checking for prpsinfo_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5546: checking for prpsinfo_t in sys/procfs.h" >&5 +echo "configure:5582: checking for prpsinfo_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prpsinfo_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5551 "configure" +#line 5587 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5556,7 +5592,7 @@ int main() { prpsinfo_t avar ; return 0; } EOF -if { (eval echo configure:5560: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5596: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_prpsinfo_t=yes else @@ -5578,12 +5614,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_prpsinfo_t" 1>&6 echo $ac_n "checking for prpsinfo32_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5582: checking for prpsinfo32_t in sys/procfs.h" >&5 +echo "configure:5618: checking for prpsinfo32_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prpsinfo32_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5587 "configure" +#line 5623 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5592,7 +5628,7 @@ int main() { prpsinfo32_t avar ; return 0; } EOF -if { (eval echo configure:5596: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5632: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_prpsinfo32_t=yes else @@ -5614,12 +5650,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_prpsinfo32_t" 1>&6 echo $ac_n "checking for psinfo_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5618: checking for psinfo_t in sys/procfs.h" >&5 +echo "configure:5654: checking for psinfo_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_psinfo_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5623 "configure" +#line 5659 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5628,7 +5664,7 @@ int main() { psinfo_t avar ; return 0; } EOF -if { (eval echo configure:5632: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5668: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_psinfo_t=yes else @@ -5650,12 +5686,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_psinfo_t" 1>&6 echo $ac_n "checking for psinfo32_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5654: checking for psinfo32_t in sys/procfs.h" >&5 +echo "configure:5690: checking for psinfo32_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_psinfo32_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5659 "configure" +#line 5695 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5664,7 +5700,7 @@ int main() { psinfo32_t avar ; return 0; } EOF -if { (eval echo configure:5668: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5704: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_psinfo32_t=yes else @@ -5686,12 +5722,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_psinfo32_t" 1>&6 echo $ac_n "checking for lwpstatus_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5690: checking for lwpstatus_t in sys/procfs.h" >&5 +echo "configure:5726: checking for lwpstatus_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_lwpstatus_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5695 "configure" +#line 5731 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5700,7 +5736,7 @@ int main() { lwpstatus_t avar ; return 0; } EOF -if { (eval echo configure:5704: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5740: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_lwpstatus_t=yes else @@ -5722,12 +5758,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_lwpstatus_t" 1>&6 echo $ac_n "checking for lwpxstatus_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5726: checking for lwpxstatus_t in sys/procfs.h" >&5 +echo "configure:5762: checking for lwpxstatus_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_lwpxstatus_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5731 "configure" +#line 5767 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5736,7 +5772,7 @@ int main() { lwpxstatus_t avar ; return 0; } EOF -if { (eval echo configure:5740: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5776: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_lwpxstatus_t=yes else @@ -5758,12 +5794,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_lwpxstatus_t" 1>&6 echo $ac_n "checking for lwpstatus_t.pr_context in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5762: checking for lwpstatus_t.pr_context in sys/procfs.h" >&5 +echo "configure:5798: checking for lwpstatus_t.pr_context in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_context'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5767 "configure" +#line 5803 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5772,7 +5808,7 @@ int main() { lwpstatus_t avar; void* aref = (void*) &avar.pr_context ; return 0; } EOF -if { (eval echo configure:5776: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5812: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_context=yes else @@ -5794,12 +5830,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_context" 1>&6 echo $ac_n "checking for lwpstatus_t.pr_reg in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5798: checking for lwpstatus_t.pr_reg in sys/procfs.h" >&5 +echo "configure:5834: checking for lwpstatus_t.pr_reg in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5803 "configure" +#line 5839 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5808,7 +5844,7 @@ int main() { lwpstatus_t avar; void* aref = (void*) &avar.pr_reg ; return 0; } EOF -if { (eval echo configure:5812: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5848: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg=yes else @@ -5830,12 +5866,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg" 1>&6 echo $ac_n "checking for win32_pstatus_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:5834: checking for win32_pstatus_t in sys/procfs.h" >&5 +echo "configure:5870: checking for win32_pstatus_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_win32_pstatus_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5839 "configure" +#line 5875 "configure" #include "confdefs.h" #define _SYSCALL32 @@ -5844,7 +5880,7 @@ int main() { win32_pstatus_t avar ; return 0; } EOF -if { (eval echo configure:5848: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5884: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_win32_pstatus_t=yes else @@ -5985,19 +6021,9 @@ do # This list is alphabetized to make it easy to compare # with the two vector lists in targets.c. For the same reason, # use one entry per line, even though this leads to long lines. - # FIXME: We include cofflink.lo not because it's needed for - # bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec - # which needs it but does not list it. Should be fixed in right place. - bfd_elf32_sh64_vec) tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo" - target_size=64 ;; - bfd_elf32_sh64l_vec) tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo" - target_size=64 ;; - bfd_elf64_sh64_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" - target_size=64 ;; - bfd_elf64_sh64l_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" - target_size=64 ;; a29kcoff_big_vec) tb="$tb coff-a29k.lo cofflink.lo" ;; a_out_adobe_vec) tb="$tb aout-adobe.lo aout32.lo" ;; + aix5coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;; aout0_big_vec) tb="$tb aout0.lo aout32.lo" ;; aout_arm_big_vec) tb="$tb aout-arm.lo aout32.lo" ;; aout_arm_little_vec) tb="$tb aout-arm.lo aout32.lo" ;; @@ -6024,16 +6050,20 @@ do bfd_elf32_bigarc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; bfd_elf32_bigarm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;; bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;; - bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;; bfd_elf32_d10v_vec) tb="$tb elf32-d10v.lo elf32.lo $elf" ;; bfd_elf32_d30v_vec) tb="$tb elf32-d30v.lo elf32.lo $elf" ;; + bfd_elf32_dlx_big_vec) tb="$tb elf32-dlx.lo elf32.lo $elf" ;; bfd_elf32_fr30_vec) tb="$tb elf32-fr30.lo elf32.lo $elf" ;; + bfd_elf32_frv_vec) tb="$tb elf32-frv.lo elf32.lo $elf" ;; bfd_elf32_h8300_vec) tb="$tb elf32-h8300.lo elf32.lo $elf" ;; bfd_elf32_hppa_linux_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;; bfd_elf32_hppa_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;; bfd_elf32_i370_vec) tb="$tb elf32-i370.lo elf32.lo $elf" ;; + bfd_elf32_i386_freebsd_vec) tb="$tb elf32-i386-fbsd.lo elf32.lo $elf" ;; bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;; + bfd_elf32_i386qnx_vec) tb="$tb elf32-i386qnx.lo elf32.lo $elf" ;; bfd_elf32_i860_little_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;; bfd_elf32_i860_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;; bfd_elf32_i960_vec) tb="$tb elf32-i960.lo elf32.lo $elf" ;; @@ -6043,7 +6073,7 @@ do bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;; bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;; - bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;; bfd_elf32_m68hc11_vec) tb="$tb elf32-m68hc11.lo elf32.lo $elf" ;; bfd_elf32_m68hc12_vec) tb="$tb elf32-m68hc12.lo elf32.lo $elf" ;; @@ -6060,6 +6090,13 @@ do bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;; bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;; bfd_elf32_s390_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;; + # FIXME: We include cofflink.lo not because it's needed for + # bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec + # which needs it but does not list it. Should be fixed in right place. + bfd_elf32_sh64_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" target_size=64 ;; + bfd_elf32_sh64l_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" target_size=64 ;; + bfd_elf32_sh64lnbsd_vec) tb="$tb elf32-sh64-nbsd.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" ;; + bfd_elf32_sh64nbsd_vec) tb="$tb elf32-sh64-nbsd.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" ;; bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;; bfd_elf32_shblin_vec) tb="$tb elf32-sh-lin.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;; bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;; @@ -6067,14 +6104,16 @@ do bfd_elf32_shlnbsd_vec) tb="$tb elf32-sh-nbsd.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;; bfd_elf32_shnbsd_vec) tb="$tb elf32-sh-nbsd.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;; bfd_elf32_sparc_vec) tb="$tb elf32-sparc.lo elf32.lo $elf" ;; - bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;; - bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_us_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;; bfd_elf32_v850_vec) tb="$tb elf32-v850.lo elf32.lo $elf" ;; + bfd_elf32_vax_vec) tb="$tb elf32-vax.lo elf32.lo $elf" ;; bfd_elf32_xstormy16_vec) tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;; + bfd_elf64_alpha_freebsd_vec) tb="$tb elf64-alpha-fbsd.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_hppa_linux_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_hppa_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_aix_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; @@ -6083,22 +6122,24 @@ do bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_mmix_vec) tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_powerpc_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_powerpcle_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_s390_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;; + bfd_elf64_sh64_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; + bfd_elf64_sh64l_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; + bfd_elf64_sh64lnbsd_vec) tb="$tb elf64-sh64-nbsd.lo elf64.lo $elf" target_size=64 ;; + bfd_elf64_sh64nbsd_vec) tb="$tb elf64-sh64-nbsd.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; bfd_mmo_vec) tb="$tb mmo.lo" target_size=64 ;; bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;; bfd_powerpcle_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; bfd_powerpcle_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;; - cisco_core_big_vec) tb="$tb cisco-core.lo" ;; - cisco_core_little_vec) tb="$tb cisco-core.lo" ;; cris_aout_vec) tb="$tb aout-cris.lo" ;; demo_64_vec) tb="$tb demo64.lo aout64.lo"; target_size=64 ;; ecoff_big_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;; @@ -6140,6 +6181,7 @@ do m68knetbsd_vec) tb="$tb m68knetbsd.lo aout32.lo" ;; m68ksysvcoff_vec) tb="$tb coff-svm68k.lo cofflink.lo" ;; m88kbcs_vec) tb="$tb coff-m88k.lo" ;; + m88kmach3_vec) tb="$tb m88kmach3.lo aout32.lo" ;; mcore_pe_big_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;; mcore_pe_little_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;; mcore_pei_big_vec) tb="$tb pei-mcore.lo peigen.lo cofflink.lo" ;; @@ -6158,7 +6200,7 @@ do pmac_xcoff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;; ppcboot_vec) tb="$tb ppcboot.lo" ;; riscix_vec) tb="$tb aout32.lo riscix.lo" ;; - rs6000coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo"; target_size=64 ;; + rs6000coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;; rs6000coff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;; shcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;; shcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;; @@ -6173,10 +6215,7 @@ do sparclynx_aout_vec) tb="$tb sparclynx.lo lynx-core.lo aout32.lo" ;; sparclynx_coff_vec) tb="$tb cf-sparclynx.lo lynx-core.lo" ;; sparcnetbsd_vec) tb="$tb sparcnetbsd.lo aout32.lo" ;; - srec_vec) tb="$tb srec.lo" ;; sunos_big_vec) tb="$tb sunos.lo aout32.lo" ;; - symbolsrec_vec) tb="$tb srec.lo" ;; - tekhex_vec) tb="$tb tekhex.lo" ;; tic30_aout_vec) tb="$tb aout-tic30.lo" ;; tic30_coff_vec) tb="$tb coff-tic30.lo" ;; tic54x_coff0_beh_vec) tb="$tb coff-tic54x.lo" ;; @@ -6186,6 +6225,9 @@ do tic54x_coff2_beh_vec) tb="$tb coff-tic54x.lo" ;; tic54x_coff2_vec) tb="$tb coff-tic54x.lo" ;; tic80coff_vec) tb="$tb coff-tic80.lo cofflink.lo" ;; + vaxnetbsd_vec) tb="$tb vaxnetbsd.lo aout32.lo" ;; + vax1knetbsd_vec) tb="$tb vax1knetbsd.lo aout32.lo" ;; + vaxbsd_vec) tb="$tb vaxbsd.lo aout32.lo" ;; versados_vec) tb="$tb versados.lo" ;; vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo"; target_size=64 ;; vms_vax_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo" ;; @@ -6193,6 +6235,13 @@ do we32kcoff_vec) tb="$tb coff-we32k.lo" ;; z8kcoff_vec) tb="$tb coff-z8k.lo reloc16.lo" ;; + # These appear out of order in targets.c + srec_vec) tb="$tb srec.lo" ;; + symbolsrec_vec) tb="$tb srec.lo" ;; + tekhex_vec) tb="$tb tekhex.lo" ;; + cisco_core_big_vec) tb="$tb cisco-core.lo" ;; + cisco_core_little_vec) tb="$tb cisco-core.lo" ;; + "") ;; *) { echo "configure: error: *** unknown target vector $vec" 1>&2; exit 1; } ;; esac @@ -6261,10 +6310,10 @@ case ${host64}-${target64}-${want64} in if test -n "$GCC" ; then bad_64bit_gcc=no; echo $ac_n "checking for gcc version with buggy 64-bit support""... $ac_c" 1>&6 -echo "configure:6265: checking for gcc version with buggy 64-bit support" >&5 +echo "configure:6314: checking for gcc version with buggy 64-bit support" >&5 # Add more tests for gcc versions with non-working 64-bit support here. cat > conftest.$ac_ext <<EOF -#line 6268 "configure" +#line 6317 "configure" #include "confdefs.h" :__GNUC__:__GNUC_MINOR__:__i386__: EOF @@ -6305,21 +6354,21 @@ test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selar test -n "${havevecs}" && tdefaults="${tdefaults} ${havevecs}" -for ac_hdr in stdlib.h unistd.h sys/stat.h sys/types.h +for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:6313: checking for $ac_hdr" >&5 +echo "configure:6362: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6318 "configure" +#line 6367 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:6323: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6372: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -6348,12 +6397,12 @@ done for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:6352: checking for $ac_func" >&5 +echo "configure:6401: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6357 "configure" +#line 6406 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -6376,7 +6425,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:6380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6429: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -6401,7 +6450,7 @@ fi done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:6405: checking for working mmap" >&5 +echo "configure:6454: checking for working mmap" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6409,7 +6458,7 @@ else ac_cv_func_mmap_fixed_mapped=no else cat > conftest.$ac_ext <<EOF -#line 6413 "configure" +#line 6462 "configure" #include "confdefs.h" /* Thanks to Mike Haertel and Jim Avera for this test. @@ -6437,24 +6486,11 @@ else #include <fcntl.h> #include <sys/mman.h> -#if HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif - -#if HAVE_STDLIB_H -# include <stdlib.h> -#endif - -#if HAVE_SYS_STAT_H -# include <sys/stat.h> -#endif - -#if HAVE_UNISTD_H -# include <unistd.h> -#endif - /* This mess was copied from the GNU getpagesize.h. */ #ifndef HAVE_GETPAGESIZE +# ifdef HAVE_UNISTD_H +# include <unistd.h> +# endif /* Assume that all systems that can run configure have sys/param.h. */ # ifndef HAVE_SYS_PARAM_H @@ -6562,7 +6598,7 @@ main() } EOF -if { (eval echo configure:6566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6602: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_fixed_mapped=yes else @@ -6587,12 +6623,12 @@ fi for ac_func in madvise mprotect do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:6591: checking for $ac_func" >&5 +echo "configure:6627: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6596 "configure" +#line 6632 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -6615,7 +6651,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:6619: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6655: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -6821,6 +6857,10 @@ s%@WARN_CFLAGS@%$WARN_CFLAGS%g s%@MAINTAINER_MODE_TRUE@%$MAINTAINER_MODE_TRUE%g s%@MAINTAINER_MODE_FALSE@%$MAINTAINER_MODE_FALSE%g s%@MAINT@%$MAINT%g +s%@INSTALL_LIBBFD_TRUE@%$INSTALL_LIBBFD_TRUE%g +s%@INSTALL_LIBBFD_FALSE@%$INSTALL_LIBBFD_FALSE%g +s%@bfdlibdir@%$bfdlibdir%g +s%@bfdincludedir@%$bfdincludedir%g s%@CPP@%$CPP%g s%@ALLOCA@%$ALLOCA%g s%@USE_NLS@%$USE_NLS%g diff --git a/contrib/binutils/bfd/configure.in b/contrib/binutils/bfd/configure.in index defa540..22292f2 100644 --- a/contrib/binutils/bfd/configure.in +++ b/contrib/binutils/bfd/configure.in @@ -7,9 +7,9 @@ AC_INIT(libbfd.c) AC_CANONICAL_SYSTEM AC_ISC_POSIX -AM_INIT_AUTOMAKE(bfd, 2.12.1) +AM_INIT_AUTOMAKE(bfd, 2.13) # Uncomment the next line to remove the date from the reported bfd version -is_release=y +# is_release=y changequote(,)dnl bfd_version=`echo "${VERSION}" | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$/\1\2\3\4\5/'` @@ -98,6 +98,7 @@ if test -z "$target" ; then fi AM_MAINTAINER_MODE +AM_INSTALL_LIBBFD AC_EXEEXT host64=false @@ -108,7 +109,7 @@ bfd_default_target_size=32 AC_PROG_CC -ALL_LINGUAS="fr tr ja es sv" +ALL_LINGUAS="fr tr ja es sv da" CY_GNU_GETTEXT # Permit host specific settings. @@ -162,7 +163,9 @@ if test "${target}" = "${host}"; then COREFILE=trad-core.lo TRAD_HEADER='"hosts/alphalinux.h"' ;; - alpha*-*-netbsd*) COREFILE=netbsd-core.lo ;; + alpha*-*-netbsd* | alpha*-*-openbsd*) + COREFILE=netbsd-core.lo + ;; alpha*-*-*) COREFILE=osf-core.lo ;; arm-*-freebsd*) COREFILE='' ;; arm-*-netbsd*) COREFILE=netbsd-core.lo ;; @@ -308,8 +311,11 @@ changequote([,])dnl COREFILE=trad-core.lo TRAD_HEADER='"hosts/m68kaux.h"' ;; - m88*-*-sysv4*) ;; - m88*-motorola-sysv*) COREFILE=ptrace-core.lo ;; + m88*-*-sysv4*) + ;; + m88*-motorola-sysv*) + COREFILE=ptrace-core.lo + ;; m88*-*-mach3*) COREFILE=trad-core.lo TRAD_HEADER='"hosts/m88kmach3.h"' @@ -321,7 +327,13 @@ changequote([,])dnl ns32k-*-netbsd* | ns32k-*-openbsd*) COREFILE=netbsd-core.lo ;; - rs6000-*-lynx*) COREFILE=lynx-core.lo ;; + rs6000-*-lynx*) + COREFILE=lynx-core.lo + ;; + rs6000-*-aix5.* | powerpc-*-aix5.*) + COREFILE=rs6000-core.lo + COREFLAG="$COREFLAG -DAIX_5_CORE -DAIX_CORE_DUMPX_CORE" + ;; changequote(,)dnl rs6000-*-aix4.[3-9]* | powerpc-*-aix4.[3-9]*) changequote([,])dnl @@ -346,13 +358,14 @@ changequote([,])dnl powerpc-*-*bsd*) COREFILE=netbsd-core.lo ;; s390*-*-*) COREFILE=trad-core.lo ;; sh*-*-netbsd*) COREFILE=netbsd-core.lo ;; - sparc-*-netbsd* | sparc-*-openbsd*) + sparc-*-netbsd* | sparc*-*-openbsd*) COREFILE=netbsd-core.lo ;; tahoe-*-*) COREFILE=trad-core.lo TRAD_HEADER='"hosts/tahoe.h"' ;; + vax-*-netbsd*) COREFILE=netbsd-core.lo ;; vax-*-ultrix2*) COREFILE=trad-core.lo TRAD_HEADER='"hosts/vaxult2.h"' @@ -522,19 +535,9 @@ do # This list is alphabetized to make it easy to compare # with the two vector lists in targets.c. For the same reason, # use one entry per line, even though this leads to long lines. - # FIXME: We include cofflink.lo not because it's needed for - # bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec - # which needs it but does not list it. Should be fixed in right place. - bfd_elf32_sh64_vec) tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo" - target_size=64 ;; - bfd_elf32_sh64l_vec) tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo" - target_size=64 ;; - bfd_elf64_sh64_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" - target_size=64 ;; - bfd_elf64_sh64l_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" - target_size=64 ;; a29kcoff_big_vec) tb="$tb coff-a29k.lo cofflink.lo" ;; a_out_adobe_vec) tb="$tb aout-adobe.lo aout32.lo" ;; + aix5coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;; aout0_big_vec) tb="$tb aout0.lo aout32.lo" ;; aout_arm_big_vec) tb="$tb aout-arm.lo aout32.lo" ;; aout_arm_little_vec) tb="$tb aout-arm.lo aout32.lo" ;; @@ -561,16 +564,20 @@ do bfd_elf32_bigarc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; bfd_elf32_bigarm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;; bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;; - bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;; bfd_elf32_d10v_vec) tb="$tb elf32-d10v.lo elf32.lo $elf" ;; bfd_elf32_d30v_vec) tb="$tb elf32-d30v.lo elf32.lo $elf" ;; + bfd_elf32_dlx_big_vec) tb="$tb elf32-dlx.lo elf32.lo $elf" ;; bfd_elf32_fr30_vec) tb="$tb elf32-fr30.lo elf32.lo $elf" ;; + bfd_elf32_frv_vec) tb="$tb elf32-frv.lo elf32.lo $elf" ;; bfd_elf32_h8300_vec) tb="$tb elf32-h8300.lo elf32.lo $elf" ;; bfd_elf32_hppa_linux_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;; bfd_elf32_hppa_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;; bfd_elf32_i370_vec) tb="$tb elf32-i370.lo elf32.lo $elf" ;; + bfd_elf32_i386_freebsd_vec) tb="$tb elf32-i386-fbsd.lo elf32.lo $elf" ;; bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;; + bfd_elf32_i386qnx_vec) tb="$tb elf32-i386qnx.lo elf32.lo $elf" ;; bfd_elf32_i860_little_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;; bfd_elf32_i860_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;; bfd_elf32_i960_vec) tb="$tb elf32-i960.lo elf32.lo $elf" ;; @@ -580,7 +587,7 @@ do bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;; bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;; - bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;; bfd_elf32_m68hc11_vec) tb="$tb elf32-m68hc11.lo elf32.lo $elf" ;; bfd_elf32_m68hc12_vec) tb="$tb elf32-m68hc12.lo elf32.lo $elf" ;; @@ -597,6 +604,13 @@ do bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;; bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;; bfd_elf32_s390_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;; + # FIXME: We include cofflink.lo not because it's needed for + # bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec + # which needs it but does not list it. Should be fixed in right place. + bfd_elf32_sh64_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" target_size=64 ;; + bfd_elf32_sh64l_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" target_size=64 ;; + bfd_elf32_sh64lnbsd_vec) tb="$tb elf32-sh64-nbsd.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" ;; + bfd_elf32_sh64nbsd_vec) tb="$tb elf32-sh64-nbsd.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" ;; bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;; bfd_elf32_shblin_vec) tb="$tb elf32-sh-lin.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;; bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;; @@ -604,14 +618,16 @@ do bfd_elf32_shlnbsd_vec) tb="$tb elf32-sh-nbsd.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;; bfd_elf32_shnbsd_vec) tb="$tb elf32-sh-nbsd.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;; bfd_elf32_sparc_vec) tb="$tb elf32-sparc.lo elf32.lo $elf" ;; - bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;; - bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_us_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;; bfd_elf32_v850_vec) tb="$tb elf32-v850.lo elf32.lo $elf" ;; + bfd_elf32_vax_vec) tb="$tb elf32-vax.lo elf32.lo $elf" ;; bfd_elf32_xstormy16_vec) tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;; + bfd_elf64_alpha_freebsd_vec) tb="$tb elf64-alpha-fbsd.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_hppa_linux_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_hppa_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_aix_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; @@ -620,22 +636,24 @@ do bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_mmix_vec) tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_powerpc_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_powerpcle_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_s390_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;; + bfd_elf64_sh64_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; + bfd_elf64_sh64l_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; + bfd_elf64_sh64lnbsd_vec) tb="$tb elf64-sh64-nbsd.lo elf64.lo $elf" target_size=64 ;; + bfd_elf64_sh64nbsd_vec) tb="$tb elf64-sh64-nbsd.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; bfd_mmo_vec) tb="$tb mmo.lo" target_size=64 ;; bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;; bfd_powerpcle_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; bfd_powerpcle_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;; - cisco_core_big_vec) tb="$tb cisco-core.lo" ;; - cisco_core_little_vec) tb="$tb cisco-core.lo" ;; cris_aout_vec) tb="$tb aout-cris.lo" ;; demo_64_vec) tb="$tb demo64.lo aout64.lo"; target_size=64 ;; ecoff_big_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;; @@ -677,6 +695,7 @@ do m68knetbsd_vec) tb="$tb m68knetbsd.lo aout32.lo" ;; m68ksysvcoff_vec) tb="$tb coff-svm68k.lo cofflink.lo" ;; m88kbcs_vec) tb="$tb coff-m88k.lo" ;; + m88kmach3_vec) tb="$tb m88kmach3.lo aout32.lo" ;; mcore_pe_big_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;; mcore_pe_little_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;; mcore_pei_big_vec) tb="$tb pei-mcore.lo peigen.lo cofflink.lo" ;; @@ -695,7 +714,7 @@ do pmac_xcoff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;; ppcboot_vec) tb="$tb ppcboot.lo" ;; riscix_vec) tb="$tb aout32.lo riscix.lo" ;; - rs6000coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo"; target_size=64 ;; + rs6000coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;; rs6000coff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;; shcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;; shcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;; @@ -710,10 +729,7 @@ do sparclynx_aout_vec) tb="$tb sparclynx.lo lynx-core.lo aout32.lo" ;; sparclynx_coff_vec) tb="$tb cf-sparclynx.lo lynx-core.lo" ;; sparcnetbsd_vec) tb="$tb sparcnetbsd.lo aout32.lo" ;; - srec_vec) tb="$tb srec.lo" ;; sunos_big_vec) tb="$tb sunos.lo aout32.lo" ;; - symbolsrec_vec) tb="$tb srec.lo" ;; - tekhex_vec) tb="$tb tekhex.lo" ;; tic30_aout_vec) tb="$tb aout-tic30.lo" ;; tic30_coff_vec) tb="$tb coff-tic30.lo" ;; tic54x_coff0_beh_vec) tb="$tb coff-tic54x.lo" ;; @@ -723,6 +739,9 @@ do tic54x_coff2_beh_vec) tb="$tb coff-tic54x.lo" ;; tic54x_coff2_vec) tb="$tb coff-tic54x.lo" ;; tic80coff_vec) tb="$tb coff-tic80.lo cofflink.lo" ;; + vaxnetbsd_vec) tb="$tb vaxnetbsd.lo aout32.lo" ;; + vax1knetbsd_vec) tb="$tb vax1knetbsd.lo aout32.lo" ;; + vaxbsd_vec) tb="$tb vaxbsd.lo aout32.lo" ;; versados_vec) tb="$tb versados.lo" ;; vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo"; target_size=64 ;; vms_vax_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo" ;; @@ -730,6 +749,13 @@ do we32kcoff_vec) tb="$tb coff-we32k.lo" ;; z8kcoff_vec) tb="$tb coff-z8k.lo reloc16.lo" ;; + # These appear out of order in targets.c + srec_vec) tb="$tb srec.lo" ;; + symbolsrec_vec) tb="$tb srec.lo" ;; + tekhex_vec) tb="$tb tekhex.lo" ;; + cisco_core_big_vec) tb="$tb cisco-core.lo" ;; + cisco_core_little_vec) tb="$tb cisco-core.lo" ;; + "") ;; *) AC_MSG_ERROR(*** unknown target vector $vec) ;; esac diff --git a/contrib/binutils/bfd/corefile.c b/contrib/binutils/bfd/corefile.c index 609c4e6..2414225 100644 --- a/contrib/binutils/bfd/corefile.c +++ b/contrib/binutils/bfd/corefile.c @@ -1,5 +1,5 @@ /* Core file generic interface routines for BFD. - Copyright 1990, 1991, 1992, 1993, 1994, 2000, 2001 + Copyright 1990, 1991, 1992, 1993, 1994, 2000, 2001, 2002 Free Software Foundation, Inc. Written by Cygnus Support. @@ -44,7 +44,7 @@ DESCRIPTION */ -CONST char * +const char * bfd_core_file_failing_command (abfd) bfd *abfd; { diff --git a/contrib/binutils/bfd/cpu-arm.c b/contrib/binutils/bfd/cpu-arm.c index 8cd64e9..9faf648 100644 --- a/contrib/binutils/bfd/cpu-arm.c +++ b/contrib/binutils/bfd/cpu-arm.c @@ -1,70 +1,72 @@ /* BFD support for the ARM processor - Copyright 1994, 1997, 1999, 2000 Free Software Foundation, Inc. + Copyright 1994, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -static const bfd_arch_info_type *compatible +static const bfd_arch_info_type * compatible PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *)); -static boolean scan PARAMS ((const struct bfd_arch_info *, const char *)); +static boolean scan + PARAMS ((const struct bfd_arch_info *, const char *)); /* This routine is provided two arch_infos and works out which ARM machine which would be compatible with both and returns a pointer - to its info structure */ + to its info structure. */ static const bfd_arch_info_type * compatible (a,b) const bfd_arch_info_type * a; const bfd_arch_info_type * b; { - /* If a & b are for different architecture we can do nothing */ + /* If a & b are for different architecture we can do nothing. */ if (a->arch != b->arch) return NULL; - /* If a & b are for the same machine then all is well */ + /* If a & b are for the same machine then all is well. */ if (a->mach == b->mach) return a; - /* Otherwise if either a or b is the 'default' machine then - it can be polymorphed into the other */ + /* Otherwise if either a or b is the 'default' machine + then it can be polymorphed into the other. */ if (a->the_default) return b; if (b->the_default) return a; - /* So far all newer ARM architecture cores are supersets of previous cores */ + /* So far all newer ARM architecture cores are + supersets of previous cores. */ if (a->mach < b->mach) return b; else if (a->mach > b->mach) return a; - /* Never reached! */ + /* Never reached! */ return NULL; } static struct { - enum bfd_architecture arch; - char * name; + unsigned int mach; + char * name; } processors[] = { @@ -103,21 +105,21 @@ scan (info, string) { int i; - /* First test for an exact match */ + /* First test for an exact match. */ if (strcasecmp (string, info->printable_name) == 0) return true; - /* Next check for a processor name instead of an Architecture name */ + /* Next check for a processor name instead of an Architecture name. */ for (i = sizeof (processors) / sizeof (processors[0]); i--;) { - if (strcasecmp (string, processors[ i ].name) == 0) + if (strcasecmp (string, processors [i].name) == 0) break; } - if (i != -1 && info->arch == processors[ i ].arch) + if (i != -1 && info->mach == processors [i].mach) return true; - /* Finally check for the default architecture */ + /* Finally check for the default architecture. */ if (strcasecmp (string, "arm") == 0) return info->the_default; @@ -129,17 +131,17 @@ scan (info, string) static const bfd_arch_info_type arch_info_struct[] = { - N( bfd_mach_arm_2, "armv2", false, & arch_info_struct[1] ), - N( bfd_mach_arm_2a, "armv2a", false, & arch_info_struct[2] ), - N( bfd_mach_arm_3, "armv3", false, & arch_info_struct[3] ), - N( bfd_mach_arm_3M, "armv3m", false, & arch_info_struct[4] ), - N( bfd_mach_arm_4, "armv4", false, & arch_info_struct[5] ), - N( bfd_mach_arm_4T, "armv4t", false, & arch_info_struct[6] ), - N( bfd_mach_arm_5, "armv5", false, & arch_info_struct[7] ), - N( bfd_mach_arm_5T, "armv5t", false, & arch_info_struct[8] ), - N( bfd_mach_arm_5TE, "armv5te", false, & arch_info_struct[9] ), - N( bfd_mach_arm_XScale, "xscale", false, NULL ) + N (bfd_mach_arm_2, "armv2", false, & arch_info_struct[1]), + N (bfd_mach_arm_2a, "armv2a", false, & arch_info_struct[2]), + N (bfd_mach_arm_3, "armv3", false, & arch_info_struct[3]), + N (bfd_mach_arm_3M, "armv3m", false, & arch_info_struct[4]), + N (bfd_mach_arm_4, "armv4", false, & arch_info_struct[5]), + N (bfd_mach_arm_4T, "armv4t", false, & arch_info_struct[6]), + N (bfd_mach_arm_5, "armv5", false, & arch_info_struct[7]), + N (bfd_mach_arm_5T, "armv5t", false, & arch_info_struct[8]), + N (bfd_mach_arm_5TE, "armv5te", false, & arch_info_struct[9]), + N (bfd_mach_arm_XScale, "xscale", false, NULL) }; const bfd_arch_info_type bfd_arm_arch = - N( 0, "arm", true, & arch_info_struct[0] ); + N (0, "arm", true, & arch_info_struct[0]); diff --git a/contrib/binutils/bfd/cpu-powerpc.c b/contrib/binutils/bfd/cpu-powerpc.c index d77b426..5523669 100644 --- a/contrib/binutils/bfd/cpu-powerpc.c +++ b/contrib/binutils/bfd/cpu-powerpc.c @@ -50,7 +50,8 @@ powerpc_compatible (a,b) const bfd_arch_info_type bfd_powerpc_archs[] = { -#if BFD_DEFAULT_TARGET_SIZE == 64 /* default arch must come first. */ +#if BFD_DEFAULT_TARGET_SIZE == 64 + /* Default arch must come first. */ { 64, /* 64 bits in a word */ 64, /* 64 bits in an address */ @@ -65,6 +66,8 @@ const bfd_arch_info_type bfd_powerpc_archs[] = bfd_default_scan, &bfd_powerpc_archs[1] }, + /* elf32-ppc:ppc_elf_object_p relies on the default 32 bit arch + being immediately after the 64 bit default. */ { 32, /* 32 bits in a word */ 32, /* 32 bits in an address */ @@ -80,6 +83,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = &bfd_powerpc_archs[2], }, #else + /* Default arch must come first. */ { 32, /* 32 bits in a word */ 32, /* 32 bits in an address */ @@ -94,6 +98,8 @@ const bfd_arch_info_type bfd_powerpc_archs[] = bfd_default_scan, &bfd_powerpc_archs[1], }, + /* elf64-ppc:ppc64_elf_object_p relies on the default 64 bit arch + being immediately after the 32 bit default. */ { 64, /* 64 bits in a word */ 64, /* 64 bits in an address */ diff --git a/contrib/binutils/bfd/doc/ChangeLog b/contrib/binutils/bfd/doc/ChangeLog index 9f69475..3d1e30a 100644 --- a/contrib/binutils/bfd/doc/ChangeLog +++ b/contrib/binutils/bfd/doc/ChangeLog @@ -1,4 +1,44 @@ -2002-03-28 Alan Modra <amodra@bigpond.net.au> +2002-09-23 Daniel Jacobowitz <drow@mvista.com> + + Merge from mainline: + 2002-08-28 John David Anglin <dave@hiauly1.hia.nrc.ca> + * chew.c (paramstuff, outputdots, perform, bang and usage): Remove + void from function definitions. + +2002-08-13 Alan Modra <amodra@bigpond.net.au> + + * header.sed: Strip tabs. + +2002-06-08 Alan Modra <amodra@bigpond.net.au> + + * Makefile.am: Fix quote style in last change. + * Makefile.in: Regenerate. + +2002-06-07 Alan Modra <amodra@bigpond.net.au> + + * Makefile.am (libbfd.h): Don't use "echo -n". + (libcoff.h, bfd.h): Likewise. + * Makefile.in: Regenerate. + +2002-06-06 Lars Brinkhoff <lars@nocrew.org> + + * bfdint.texi: Change registry@sco.com to registry@caldera.com. + +2002-06-05 Alan Modra <amodra@bigpond.net.au> + + * Makefile.am (libbfd.h): Add "Extracted from.." comment. + (libcoff.h, bfd.h): Likewise. + * Makefile.in: Regenerate. + +2002-05-25 Alan Modra <amodra@bigpond.net.au> + + * chew.c: Use #include "" instead of <> for local header files. + +2002-04-20 Alan Modra <amodra@bigpond.net.au> + + * Makefile.in: Regenerate. + +2002-02-11 Alan Modra <amodra@bigpond.net.au> * Makefile.in: Regenerate. diff --git a/contrib/binutils/bfd/doc/Makefile.am b/contrib/binutils/bfd/doc/Makefile.am index cbfd342..0787143 100644 --- a/contrib/binutils/bfd/doc/Makefile.am +++ b/contrib/binutils/bfd/doc/Makefile.am @@ -209,7 +209,9 @@ libbfd.h: $(LIBBFD_H_DEP) case $$file in \ *-in.h) cat $$file >> $@ ;; \ */header.sed) break ;; \ - *) ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ + *) echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \ + -e 's,$$,. */,' >> $@ ; \ + ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ esac; \ done @@ -226,7 +228,9 @@ libcoff.h: $(LIBCOFF_H_DEP) case $$file in \ *-in.h) cat $$file >> $@ ;; \ */header.sed) break ;; \ - *) ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ + *) echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \ + -e 's,$$,. */,' >> $@ ; \ + ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ esac; \ done @@ -255,7 +259,9 @@ bfd.h: $(BFD_H_DEP) case $$file in \ *-in.h) cat $$file >> $@ ;; \ */header.sed) break ;; \ - *) ./$(MKDOC) -f $(srcdir)/proto.str < $$file >> $@ ;; \ + *) echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \ + -e 's,$$,. */,' >> $@ ; \ + ./$(MKDOC) -f $(srcdir)/proto.str < $$file >> $@ ;; \ esac; \ done echo "#ifdef __cplusplus" >> $@ diff --git a/contrib/binutils/bfd/doc/Makefile.in b/contrib/binutils/bfd/doc/Makefile.in index 0036c0b..8daf537 100644 --- a/contrib/binutils/bfd/doc/Makefile.in +++ b/contrib/binutils/bfd/doc/Makefile.in @@ -121,6 +121,8 @@ bfd_machines = @bfd_machines@ bfd_version = @bfd_version@ bfd_version_date = @bfd_version_date@ bfd_version_string = @bfd_version_string@ +bfdincludedir = @bfdincludedir@ +bfdlibdir = @bfdlibdir@ l = @l@ tdefaults = @tdefaults@ wordsize = @wordsize@ @@ -604,7 +606,9 @@ libbfd.h: $(LIBBFD_H_DEP) case $$file in \ *-in.h) cat $$file >> $@ ;; \ */header.sed) break ;; \ - *) ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ + *) echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \ + -e 's,$$,. */,' >> $@ ; \ + ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ esac; \ done @@ -614,7 +618,9 @@ libcoff.h: $(LIBCOFF_H_DEP) case $$file in \ *-in.h) cat $$file >> $@ ;; \ */header.sed) break ;; \ - *) ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ + *) echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \ + -e 's,$$,. */,' >> $@ ; \ + ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ esac; \ done @@ -624,7 +630,9 @@ bfd.h: $(BFD_H_DEP) case $$file in \ *-in.h) cat $$file >> $@ ;; \ */header.sed) break ;; \ - *) ./$(MKDOC) -f $(srcdir)/proto.str < $$file >> $@ ;; \ + *) echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \ + -e 's,$$,. */,' >> $@ ; \ + ./$(MKDOC) -f $(srcdir)/proto.str < $$file >> $@ ;; \ esac; \ done echo "#ifdef __cplusplus" >> $@ diff --git a/contrib/binutils/bfd/doc/archures.texi b/contrib/binutils/bfd/doc/archures.texi index eb4d180..0faf97d 100644 --- a/contrib/binutils/bfd/doc/archures.texi +++ b/contrib/binutils/bfd/doc/archures.texi @@ -159,6 +159,7 @@ enum bfd_architecture #define bfd_mach_d10v_ts2 2 #define bfd_mach_d10v_ts3 3 bfd_arch_d30v, /* Mitsubishi D30V */ + bfd_arch_dlx, /* DLX */ bfd_arch_m68hc11, /* Motorola 68HC11 */ bfd_arch_m68hc12, /* Motorola 68HC12 */ bfd_arch_z8k, /* Zilog Z8000 */ @@ -212,6 +213,13 @@ enum bfd_architecture #define bfd_mach_am33 330 bfd_arch_fr30, #define bfd_mach_fr30 0x46523330 + bfd_arch_frv, +#define bfd_mach_frv 0 +#define bfd_mach_frvsimple 1 +#define bfd_mach_fr300 300 +#define bfd_mach_fr400 400 +#define bfd_mach_frvtomcat 499 /* fr500 prototype */ +#define bfd_mach_fr500 500 bfd_arch_mcore, bfd_arch_ia64, /* HP/Intel ia64 */ #define bfd_mach_ia64_elf64 0 diff --git a/contrib/binutils/bfd/doc/bfdint.texi b/contrib/binutils/bfd/doc/bfdint.texi index 76fd832..d2996dc 100644 --- a/contrib/binutils/bfd/doc/bfdint.texi +++ b/contrib/binutils/bfd/doc/bfdint.texi @@ -1545,9 +1545,9 @@ Define @samp{ELF_ARCH} to the BFD architecture (an element of the @item Define @samp{ELF_MACHINE_CODE} to the magic number which should appear in the @samp{e_machine} field of the ELF header. As of this writing, -these magic numbers are assigned by SCO; if you want to get a magic +these magic numbers are assigned by Caldera; if you want to get a magic number for a particular processor, try sending a note to -@email{registry@@sco.com}. In the BFD sources, the magic numbers are +@email{registry@@caldera.com}. In the BFD sources, the magic numbers are found in @file{include/elf/common.h}; they have names beginning with @samp{EM_}. @item diff --git a/contrib/binutils/bfd/doc/bfdt.texi b/contrib/binutils/bfd/doc/bfdt.texi index 0b85d3d..a6e0ad9 100644 --- a/contrib/binutils/bfd/doc/bfdt.texi +++ b/contrib/binutils/bfd/doc/bfdt.texi @@ -502,7 +502,8 @@ A base of 0 causes the function to interpret the string in hex if a leading "0x" or "0X" is found, otherwise in octal if a leading zero is found, otherwise in decimal. -Overflow is not detected. +If the value would overflow, the maximum @code{bfd_vma} value is +returned. @findex bfd_copy_private_bfd_data @subsubsection @code{bfd_copy_private_bfd_data} @@ -613,12 +614,21 @@ Stuff which should be documented: #define bfd_merge_sections(abfd, link_info) \ BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info)) +#define bfd_discard_group(abfd, sec) \ + BFD_SEND (abfd, _bfd_discard_group, (abfd, sec)) + #define bfd_link_hash_table_create(abfd) \ BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) +#define bfd_link_hash_table_free(abfd, hash) \ + BFD_SEND (abfd, _bfd_link_hash_table_free, (hash)) + #define bfd_link_add_symbols(abfd, info) \ BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) +#define bfd_link_just_syms(sec, info) \ + BFD_SEND (abfd, _bfd_link_just_syms, (sec, info)) + #define bfd_final_link(abfd, info) \ BFD_SEND (abfd, _bfd_final_link, (abfd, info)) diff --git a/contrib/binutils/bfd/doc/chew.c b/contrib/binutils/bfd/doc/chew.c index 11554eb..bdf76e4 100644 --- a/contrib/binutils/bfd/doc/chew.c +++ b/contrib/binutils/bfd/doc/chew.c @@ -82,7 +82,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ Foo. */ -#include <ansidecl.h> +#include "ansidecl.h" #include "sysdep.h" #include <assert.h> #include <stdio.h> @@ -485,7 +485,7 @@ print_stack_level () */ static void -paramstuff (void) +paramstuff () { unsigned int openp; unsigned int fname; @@ -626,7 +626,7 @@ manglecomments () /* Mod tos so that only lines with leading dots remain */ static void -outputdots (void) +outputdots () { unsigned int idx = 0; string_type out; @@ -1261,7 +1261,7 @@ lookup_word (word) } static void -perform (void) +perform () { tos = stack; @@ -1412,7 +1412,7 @@ compile (string) } static void -bang (void) +bang () { *(long *) ((isp[0])) = isp[-1]; isp -= 2; @@ -1487,7 +1487,7 @@ read_in (str, file) } static void -usage (void) +usage () { fprintf (stderr, "usage: -[d|i|g] <file >file\n"); exit (33); diff --git a/contrib/binutils/bfd/doc/elf.texi b/contrib/binutils/bfd/doc/elf.texi index 4f9434c..101001c 100644 --- a/contrib/binutils/bfd/doc/elf.texi +++ b/contrib/binutils/bfd/doc/elf.texi @@ -1,4 +1,6 @@ -@section ELF backends +@section +ELF backends + BFD support for ELF formats is being worked on. Currently, the best supported back ends are for sparc and i386 (running svr4 or Solaris 2). diff --git a/contrib/binutils/bfd/doc/header.sed b/contrib/binutils/bfd/doc/header.sed index ed27040..c58dc60 100644 --- a/contrib/binutils/bfd/doc/header.sed +++ b/contrib/binutils/bfd/doc/header.sed @@ -1,3 +1,4 @@ +s|[ ][ ]*| |g s|\(.*\) [^ ]*header.sed.*|\1| s|[^ ]*/||g s|^ *|"| diff --git a/contrib/binutils/bfd/doc/reloc.texi b/contrib/binutils/bfd/doc/reloc.texi index 2f462fd..456fc29 100644 --- a/contrib/binutils/bfd/doc/reloc.texi +++ b/contrib/binutils/bfd/doc/reloc.texi @@ -716,6 +716,21 @@ Like BFD_RELOC_23_PCREL_S2, except that the source and target must share a common GP, and the target address is adjusted for STO_ALPHA_STD_GPLOAD. @end deffn +@deffn {} BFD_RELOC_ALPHA_TLSGD +@deffnx {} BFD_RELOC_ALPHA_TLSLDM +@deffnx {} BFD_RELOC_ALPHA_DTPMOD64 +@deffnx {} BFD_RELOC_ALPHA_GOTDTPREL16 +@deffnx {} BFD_RELOC_ALPHA_DTPREL64 +@deffnx {} BFD_RELOC_ALPHA_DTPREL_HI16 +@deffnx {} BFD_RELOC_ALPHA_DTPREL_LO16 +@deffnx {} BFD_RELOC_ALPHA_DTPREL16 +@deffnx {} BFD_RELOC_ALPHA_GOTTPREL16 +@deffnx {} BFD_RELOC_ALPHA_TPREL64 +@deffnx {} BFD_RELOC_ALPHA_TPREL_HI16 +@deffnx {} BFD_RELOC_ALPHA_TPREL_LO16 +@deffnx {} BFD_RELOC_ALPHA_TPREL16 +Alpha thread-local storage relocations. +@end deffn @deffn {} BFD_RELOC_MIPS_JMP Bits 27..2 of the relocation address shifted right 2 bits; simple reloc otherwise. @@ -768,6 +783,17 @@ Relocation against a MIPS literal section. @deffnx {} BFD_RELOC_MIPS_REL16 @deffnx {} BFD_RELOC_MIPS_RELGOT @deffnx {} BFD_RELOC_MIPS_JALR +@deffn {} BFD_RELOC_FRV_LABEL16 +@deffnx {} BFD_RELOC_FRV_LABEL24 +@deffnx {} BFD_RELOC_FRV_LO16 +@deffnx {} BFD_RELOC_FRV_HI16 +@deffnx {} BFD_RELOC_FRV_GPREL12 +@deffnx {} BFD_RELOC_FRV_GPRELU12 +@deffnx {} BFD_RELOC_FRV_GPREL32 +@deffnx {} BFD_RELOC_FRV_GPRELHI +@deffnx {} BFD_RELOC_FRV_GPRELLO +Fujitsu Frv Relocations. +@end deffn MIPS ELF relocations. @end deffn @deffn {} BFD_RELOC_386_GOT32 @@ -778,6 +804,15 @@ MIPS ELF relocations. @deffnx {} BFD_RELOC_386_RELATIVE @deffnx {} BFD_RELOC_386_GOTOFF @deffnx {} BFD_RELOC_386_GOTPC +@deffnx {} BFD_RELOC_386_TLS_LE +@deffnx {} BFD_RELOC_386_TLS_GD +@deffnx {} BFD_RELOC_386_TLS_LDM +@deffnx {} BFD_RELOC_386_TLS_LDO_32 +@deffnx {} BFD_RELOC_386_TLS_IE_32 +@deffnx {} BFD_RELOC_386_TLS_LE_32 +@deffnx {} BFD_RELOC_386_TLS_DTPMOD32 +@deffnx {} BFD_RELOC_386_TLS_DTPOFF32 +@deffnx {} BFD_RELOC_386_TLS_TPOFF32 i386/elf relocations @end deffn @deffn {} BFD_RELOC_X86_64_GOT32 @@ -1083,6 +1118,15 @@ This is a 32-bit absolute reloc. @deffn {} BFD_RELOC_D30V_32_PCREL This is a 32-bit pc-relative reloc. @end deffn +@deffn {} BFD_RELOC_DLX_HI16_S +DLX relocs +@end deffn +@deffn {} BFD_RELOC_DLX_LO16 +DLX relocs +@end deffn +@deffn {} BFD_RELOC_DLX_JMP26 +DLX relocs +@end deffn @deffn {} BFD_RELOC_M32R_24 Mitsubishi M32R relocs. This is a 24 bit absolute address. @@ -1488,12 +1532,25 @@ this offset in the reloc's section offset. @deffnx {} BFD_RELOC_IA64_IPLTMSB @deffnx {} BFD_RELOC_IA64_IPLTLSB @deffnx {} BFD_RELOC_IA64_COPY +@deffnx {} BFD_RELOC_IA64_LTOFF22X +@deffnx {} BFD_RELOC_IA64_LDXMOV +@deffnx {} BFD_RELOC_IA64_TPREL14 @deffnx {} BFD_RELOC_IA64_TPREL22 +@deffnx {} BFD_RELOC_IA64_TPREL64I @deffnx {} BFD_RELOC_IA64_TPREL64MSB @deffnx {} BFD_RELOC_IA64_TPREL64LSB -@deffnx {} BFD_RELOC_IA64_LTOFF_TP22 -@deffnx {} BFD_RELOC_IA64_LTOFF22X -@deffnx {} BFD_RELOC_IA64_LDXMOV +@deffnx {} BFD_RELOC_IA64_LTOFF_TPREL22 +@deffnx {} BFD_RELOC_IA64_DTPMOD64MSB +@deffnx {} BFD_RELOC_IA64_DTPMOD64LSB +@deffnx {} BFD_RELOC_IA64_LTOFF_DTPMOD22 +@deffnx {} BFD_RELOC_IA64_DTPREL14 +@deffnx {} BFD_RELOC_IA64_DTPREL22 +@deffnx {} BFD_RELOC_IA64_DTPREL64I +@deffnx {} BFD_RELOC_IA64_DTPREL32MSB +@deffnx {} BFD_RELOC_IA64_DTPREL32LSB +@deffnx {} BFD_RELOC_IA64_DTPREL64MSB +@deffnx {} BFD_RELOC_IA64_DTPREL64LSB +@deffnx {} BFD_RELOC_IA64_LTOFF_DTPREL22 Intel IA64 Relocations. @end deffn @deffn {} BFD_RELOC_M68HC11_HI8 @@ -1593,6 +1650,11 @@ H8 elf Relocations. @deffnx {} BFD_RELOC_XSTORMY16_FPTR16 Sony Xstormy16 Relocations. @end deffn +@deffn {} BFD_RELOC_VAX_GLOB_DAT +@deffnx {} BFD_RELOC_VAX_JMP_SLOT +@deffnx {} BFD_RELOC_VAX_RELATIVE +Relocations used by VAX ELF. +@end deffn @example diff --git a/contrib/binutils/bfd/doc/section.texi b/contrib/binutils/bfd/doc/section.texi index 520a296..971fd04 100644 --- a/contrib/binutils/bfd/doc/section.texi +++ b/contrib/binutils/bfd/doc/section.texi @@ -188,12 +188,6 @@ typedef struct sec standard data. */ #define SEC_CONSTRUCTOR 0x100 - /* The section is a constructor, and should be placed at the - end of the text, data, or bss section(?). */ -#define SEC_CONSTRUCTOR_TEXT 0x1100 -#define SEC_CONSTRUCTOR_DATA 0x2100 -#define SEC_CONSTRUCTOR_BSS 0x3100 - /* The section has contents - a data section could be @code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}; a debug section could be @code{SEC_HAS_CONTENTS} */ @@ -214,6 +208,9 @@ typedef struct sec sections. */ #define SEC_COFF_SHARED_LIBRARY 0x800 + /* The section contains thread local data. */ +#define SEC_THREAD_LOCAL 0x1000 + /* The section has GOT references. This flag is only for the linker, and is currently only used by the elf32-hppa back end. It will be set if global offset table references were detected @@ -771,7 +768,18 @@ void _bfd_strip_section_from_output @end example @strong{Description}@* Remove @var{section} from the output. If the output section -becomes empty, remove it from the output bfd. @var{info} may -be NULL; if it is not, it is used to decide whether the output -section is empty. +becomes empty, remove it from the output bfd. + +This function won't actually do anything except twiddle flags +if called too late in the linking process, when it's not safe +to remove sections. + +@findex bfd_generic_discard_group +@subsubsection @code{bfd_generic_discard_group} +@strong{Synopsis} +@example +boolean bfd_generic_discard_group (bfd *abfd, asection *group); +@end example +@strong{Description}@* +Remove all members of @var{group} from the output. diff --git a/contrib/binutils/bfd/doc/syms.texi b/contrib/binutils/bfd/doc/syms.texi index 1987e23..cb29e7d 100644 --- a/contrib/binutils/bfd/doc/syms.texi +++ b/contrib/binutils/bfd/doc/syms.texi @@ -243,6 +243,9 @@ typedef struct symbol_cache_entry as well. */ #define BSF_DEBUGGING_RELOC 0x20000 + /* This symbol is thread local. Used in ELF. */ +#define BSF_THREAD_LOCAL 0x40000 + flagword flags; /* A pointer to the section to which this symbol is diff --git a/contrib/binutils/bfd/doc/targets.texi b/contrib/binutils/bfd/doc/targets.texi index c45d6b6..5b8d2b8 100644 --- a/contrib/binutils/bfd/doc/targets.texi +++ b/contrib/binutils/bfd/doc/targets.texi @@ -375,11 +375,14 @@ CONCAT2 (NAME,_sizeof_headers), \ CONCAT2 (NAME,_bfd_get_relocated_section_contents), \ CONCAT2 (NAME,_bfd_relax_section), \ CONCAT2 (NAME,_bfd_link_hash_table_create), \ +CONCAT2 (NAME,_bfd_link_hash_table_free), \ CONCAT2 (NAME,_bfd_link_add_symbols), \ +CONCAT2 (NAME,_bfd_link_just_syms), \ CONCAT2 (NAME,_bfd_final_link), \ CONCAT2 (NAME,_bfd_link_split_section), \ CONCAT2 (NAME,_bfd_gc_sections), \ -CONCAT2 (NAME,_bfd_merge_sections) +CONCAT2 (NAME,_bfd_merge_sections), \ +CONCAT2 (NAME,_bfd_discard_group) int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean)); bfd_byte *(*_bfd_get_relocated_section_contents) PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, @@ -392,9 +395,15 @@ CONCAT2 (NAME,_bfd_merge_sections) different information in this table. */ struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *)); + /* Release the memory associated with the linker hash table. */ + void (*_bfd_link_hash_table_free) PARAMS ((struct bfd_link_hash_table *)); + /* Add symbols from this object file into the hash table. */ boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *)); + /* Indicate that we are only retrieving symbol values from this section. */ + void (*_bfd_link_just_syms) PARAMS ((asection *, struct bfd_link_info *)); + /* Do a link based on the link_order structures attached to each section of the BFD. */ boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *)); @@ -408,6 +417,9 @@ CONCAT2 (NAME,_bfd_merge_sections) /* Attempt to merge SEC_MERGE sections. */ boolean (*_bfd_merge_sections) PARAMS ((bfd *, struct bfd_link_info *)); + /* Discard members of a group. */ + boolean (*_bfd_discard_group) PARAMS ((bfd *, struct sec *)); + /* Routines to handle dynamic symbols and relocs. */ #define BFD_JUMP_TABLE_DYNAMIC(NAME) \ CONCAT2 (NAME,_get_dynamic_symtab_upper_bound), \ diff --git a/contrib/binutils/bfd/dwarf2.c b/contrib/binutils/bfd/dwarf2.c index e3b8e27..5aadadd 100644 --- a/contrib/binutils/bfd/dwarf2.c +++ b/contrib/binutils/bfd/dwarf2.c @@ -13,21 +13,21 @@ based on Fred Fish's (Cygnus Support) implementation of DWARF 1 support in dwarfread.c -This file is part of BFD. + This file is part of BFD. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or (at -your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at + your option) any later version. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -856,13 +856,18 @@ concat_filename (table, file) filename = table->files[file - 1].name; if (IS_ABSOLUTE_PATH(filename)) return filename; - else { char* dirname = (table->files[file - 1].dir ? table->dirs[table->files[file - 1].dir - 1] : table->comp_dir); - return (char*) concat (dirname, "/", filename, NULL); + + /* Not all tools set DW_AT_comp_dir, so dirname may be unknown. The + best we can do is return the filename part. */ + if (dirname == NULL) + return filename; + else + return (char*) concat (dirname, "/", filename, NULL); } } @@ -990,6 +995,13 @@ decode_line_info (unit, stash) line_ptr += 8; offset_size = 8; } + else if (lh.total_length == 0 && unit->addr_size == 8) + { + /* Handle (non-standard) 64-bit DWARF2 formats. */ + lh.total_length = read_4_bytes (abfd, line_ptr); + line_ptr += 4; + offset_size = 8; + } line_end = line_ptr + lh.total_length; lh.version = read_2_bytes (abfd, line_ptr); line_ptr += 2; @@ -1072,13 +1084,19 @@ decode_line_info (unit, stash) { /* State machine registers. */ bfd_vma address = 0; - char* filename = concat_filename (table, 1); + char * filename = concat_filename (table, 1); unsigned int line = 1; unsigned int column = 0; int is_stmt = lh.default_is_stmt; int basic_block = 0; - int end_sequence = 0, need_low_pc = 1; - bfd_vma low_pc = 0; + int end_sequence = 0; + /* eraxxon@alumni.rice.edu: Against the DWARF2 specs, some + compilers generate address sequences that are wildly out of + order using DW_LNE_set_address (e.g. Intel C++ 6.0 compiler + for ia64-Linux). Thus, to determine the low and high + address, we must compare on every DW_LNS_copy, etc. */ + bfd_vma low_pc = 0; + bfd_vma high_pc = 0; /* Decode the table. */ while (! end_sequence) @@ -1087,7 +1105,8 @@ decode_line_info (unit, stash) line_ptr += 1; if (op_code >= lh.opcode_base) - { /* Special operand. */ + { + /* Special operand. */ adj_opcode = op_code - lh.opcode_base; address += (adj_opcode / lh.line_range) * lh.minimum_instruction_length; @@ -1095,29 +1114,30 @@ decode_line_info (unit, stash) /* Append row to matrix using current values. */ add_line_info (table, address, filename, line, column, 0); basic_block = 1; - if (need_low_pc) - { - need_low_pc = 0; - low_pc = address; - } + if (low_pc == 0 || address < low_pc) + low_pc = address; + if (address > high_pc) + high_pc = address; } else switch (op_code) { case DW_LNS_extended_op: - line_ptr += 1; /* Ignore length. */ + /* Ignore length. */ + line_ptr += 1; extended_op = read_1_byte (abfd, line_ptr); line_ptr += 1; + switch (extended_op) { case DW_LNE_end_sequence: end_sequence = 1; add_line_info (table, address, filename, line, column, end_sequence); - if (need_low_pc) - { - need_low_pc = 0; - low_pc = address; - } + arange_add (unit, low_pc, high_pc); + if (low_pc == 0 || address < low_pc) + low_pc = address; + if (address > high_pc) + high_pc = address; arange_add (unit, low_pc, address); break; case DW_LNE_set_address: @@ -1157,11 +1177,10 @@ decode_line_info (unit, stash) case DW_LNS_copy: add_line_info (table, address, filename, line, column, 0); basic_block = 0; - if (need_low_pc) - { - need_low_pc = 0; - low_pc = address; - } + if (low_pc == 0 || address < low_pc) + low_pc = address; + if (address > high_pc) + high_pc = address; break; case DW_LNS_advance_pc: address += lh.minimum_instruction_length @@ -1176,8 +1195,8 @@ decode_line_info (unit, stash) { unsigned int file; - /* The file and directory tables are 0 based, the references - are 1 based. */ + /* The file and directory tables are 0 + based, the references are 1 based. */ file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); line_ptr += bytes_read; filename = concat_filename (table, file); @@ -1202,8 +1221,9 @@ decode_line_info (unit, stash) line_ptr += 2; break; default: - { /* Unknown standard opcode, ignore it. */ + { int i; + /* Unknown standard opcode, ignore it. */ for (i = 0; i < lh.standard_opcode_lengths[op_code]; i++) { (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read); @@ -1222,10 +1242,7 @@ decode_line_info (unit, stash) LINENUMBER_PTR, are pointers to the objects to be filled in. */ static boolean -lookup_address_in_line_info_table (table, - addr, - function, - filename_ptr, +lookup_address_in_line_info_table (table, addr, function, filename_ptr, linenumber_ptr) struct line_info_table* table; bfd_vma addr; @@ -1286,9 +1303,7 @@ lookup_address_in_line_info_table (table, /* If ADDR is within TABLE, set FUNCTIONNAME_PTR, and return true. */ static boolean -lookup_address_in_function_table (table, - addr, - function_ptr, +lookup_address_in_function_table (table, addr, function_ptr, functionname_ptr) struct funcinfo* table; bfd_vma addr; @@ -1654,9 +1669,8 @@ comp_unit_contains_address (unit, addr) false otherwise. */ static boolean -comp_unit_find_nearest_line (unit, addr, - filename_ptr, functionname_ptr, linenumber_ptr, - stash) +comp_unit_find_nearest_line (unit, addr, filename_ptr, functionname_ptr, + linenumber_ptr, stash) struct comp_unit* unit; bfd_vma addr; const char **filename_ptr; @@ -1696,26 +1710,23 @@ comp_unit_find_nearest_line (unit, addr, } function = NULL; - func_p = lookup_address_in_function_table (unit->function_table, - addr, - &function, - functionname_ptr); - line_p = lookup_address_in_line_info_table (unit->line_table, - addr, - function, - filename_ptr, + func_p = lookup_address_in_function_table (unit->function_table, addr, + &function, functionname_ptr); + line_p = lookup_address_in_line_info_table (unit->line_table, addr, + function, filename_ptr, linenumber_ptr); return line_p || func_p; } -/* Locate a section in a BFD containing debugging info. The search starts from the - section after AFTER_SEC, or from the first section in the BFD if AFTER_SEC is - NULL. The search works by examining the names of the sections. There are two - permissiable names. The first is .debug_info. This is the standard DWARF2 name. - The second is a prefix .gnu.linkonce.wi. This is a variation on the .debug_info - section which has a checksum describing the contents appended onto the name. This - allows the linker to identify and discard duplicate debugging sections for - different compilation units. */ +/* Locate a section in a BFD containing debugging info. The search starts + from the section after AFTER_SEC, or from the first section in the BFD if + AFTER_SEC is NULL. The search works by examining the names of the + sections. There are two permissiable names. The first is .debug_info. + This is the standard DWARF2 name. The second is a prefix .gnu.linkonce.wi. + This is a variation on the .debug_info section which has a checksum + describing the contents appended onto the name. This allows the linker to + identify and discard duplicate debugging sections for different + compilation units. */ #define DWARF2_DEBUG_INFO ".debug_info" #define GNU_LINKONCE_INFO ".gnu.linkonce.wi." @@ -1754,8 +1765,7 @@ find_debug_info (abfd, after_sec) boolean _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, filename_ptr, functionname_ptr, - linenumber_ptr, - addr_size, pinfo) + linenumber_ptr, addr_size, pinfo) bfd *abfd; asection *section; asymbol **symbols; @@ -1895,6 +1905,13 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, length = read_8_bytes (abfd, stash->info_ptr + 4); stash->info_ptr += 8; } + else if (length == 0) + { + /* Handle (non-standard) 64-bit DWARF2 formats. */ + offset_size = 8; + length = read_4_bytes (abfd, stash->info_ptr + 4); + stash->info_ptr += 4; + } } else length = read_8_bytes (abfd, stash->info_ptr); diff --git a/contrib/binutils/bfd/ecoff.c b/contrib/binutils/bfd/ecoff.c index 70224cb..c8c56f8 100644 --- a/contrib/binutils/bfd/ecoff.c +++ b/contrib/binutils/bfd/ecoff.c @@ -4,21 +4,21 @@ Original version by Per Bothner. Full support added by Ian Lance Taylor, ian@cygnus.com. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -46,29 +46,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Prototypes for static functions. */ -static int ecoff_get_magic PARAMS ((bfd *abfd)); -static long ecoff_sec_to_styp_flags PARAMS ((const char *name, - flagword flags)); -static boolean ecoff_slurp_symbolic_header PARAMS ((bfd *abfd)); -static boolean ecoff_set_symbol_info PARAMS ((bfd *abfd, SYMR *ecoff_sym, - asymbol *asym, int ext, int weak)); -static void ecoff_emit_aggregate PARAMS ((bfd *abfd, FDR *fdr, - char *string, - RNDXR *rndx, long isym, - const char *which)); -static char *ecoff_type_to_string PARAMS ((bfd *abfd, FDR *fdr, - unsigned int indx)); -static boolean ecoff_slurp_reloc_table PARAMS ((bfd *abfd, asection *section, - asymbol **symbols)); +static int ecoff_get_magic PARAMS ((bfd *)); +static long ecoff_sec_to_styp_flags PARAMS ((const char *, flagword)); +static boolean ecoff_slurp_symbolic_header PARAMS ((bfd *)); +static boolean ecoff_set_symbol_info PARAMS ((bfd *, SYMR *, asymbol *, int, int)); +static void ecoff_emit_aggregate PARAMS ((bfd *, FDR *, char *, RNDXR *, long, const char *)); +static char *ecoff_type_to_string PARAMS ((bfd *, FDR *, unsigned int)); +static boolean ecoff_slurp_reloc_table PARAMS ((bfd *, asection *, asymbol **)); static int ecoff_sort_hdrs PARAMS ((const PTR, const PTR)); -static boolean ecoff_compute_section_file_positions PARAMS ((bfd *abfd)); -static bfd_size_type ecoff_compute_reloc_file_positions PARAMS ((bfd *abfd)); +static boolean ecoff_compute_section_file_positions PARAMS ((bfd *)); +static bfd_size_type ecoff_compute_reloc_file_positions PARAMS ((bfd *)); static boolean ecoff_get_extr PARAMS ((asymbol *, EXTR *)); static void ecoff_set_index PARAMS ((asymbol *, bfd_size_type)); -static unsigned int ecoff_armap_hash PARAMS ((const char *s, - unsigned int *rehash, - unsigned int size, - unsigned int hlog)); +static unsigned int ecoff_armap_hash PARAMS ((const char *, unsigned int *, unsigned int, unsigned int)); /* This stuff is somewhat copied from coffcode.h. */ @@ -105,6 +95,7 @@ _bfd_ecoff_mkobject (abfd) bfd *abfd; { bfd_size_type amt = sizeof (ecoff_data_type); + abfd->tdata.ecoff_obj_data = (struct ecoff_tdata *) bfd_zalloc (abfd, amt); if (abfd->tdata.ecoff_obj_data == NULL) return false; @@ -125,7 +116,7 @@ _bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr) struct internal_aouthdr *internal_a = (struct internal_aouthdr *) aouthdr; ecoff_data_type *ecoff; - if (_bfd_ecoff_mkobject (abfd) == false) + if (! _bfd_ecoff_mkobject (abfd)) return NULL; ecoff = ecoff_data (abfd); @@ -184,10 +175,8 @@ _bfd_ecoff_new_section_hook (abfd, section) || strcmp (section->name, _SBSS) == 0) section->flags |= SEC_ALLOC; else if (strcmp (section->name, _LIB) == 0) - { - /* An Irix 4 shared libary. */ - section->flags |= SEC_COFF_SHARED_LIBRARY; - } + /* An Irix 4 shared libary. */ + section->flags |= SEC_COFF_SHARED_LIBRARY; /* Probably any other section name is SEC_NEVER_LOAD, but I'm uncertain about .init on some systems and I don't know how shared @@ -221,14 +210,14 @@ _bfd_ecoff_set_arch_mach_hook (abfd, filehdr) case MIPS_MAGIC_LITTLE2: case MIPS_MAGIC_BIG2: - /* MIPS ISA level 2: the r6000 */ + /* MIPS ISA level 2: the r6000. */ arch = bfd_arch_mips; mach = 6000; break; case MIPS_MAGIC_LITTLE3: case MIPS_MAGIC_BIG3: - /* MIPS ISA level 3: the r4000 */ + /* MIPS ISA level 3: the r4000. */ arch = bfd_arch_mips; mach = 4000; break; @@ -553,7 +542,6 @@ _bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug) documented section. And the ordering of the sections varies between statically and dynamically linked executables. If bfd supports SEEK_END someday, this code could be simplified. */ - raw_end = 0; #define UPDATE_RAW_END(start, count, size) \ @@ -565,7 +553,9 @@ _bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug) UPDATE_RAW_END (cbDnOffset, idnMax, backend->debug_swap.external_dnr_size); UPDATE_RAW_END (cbPdOffset, ipdMax, backend->debug_swap.external_pdr_size); UPDATE_RAW_END (cbSymOffset, isymMax, backend->debug_swap.external_sym_size); - UPDATE_RAW_END (cbOptOffset, ioptMax, backend->debug_swap.external_opt_size); + /* eraxxon@alumni.rice.edu: ioptMax refers to the size of the + optimization symtab, not the number of entries */ + UPDATE_RAW_END (cbOptOffset, ioptMax, sizeof (char)); UPDATE_RAW_END (cbAuxOffset, iauxMax, sizeof (union aux_ext)); UPDATE_RAW_END (cbSsOffset, issMax, sizeof (char)); UPDATE_RAW_END (cbSsExtOffset, issExtMax, sizeof (char)); @@ -604,6 +594,7 @@ _bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug) debug->off2 = (type) ((char *) raw \ + (internal_symhdr->off1 \ - raw_base)) + FIX (cbLineOffset, line, unsigned char *); FIX (cbDnOffset, external_dnr, PTR); FIX (cbPdOffset, external_pdr, PTR); @@ -661,10 +652,9 @@ _bfd_ecoff_make_empty_symbol (abfd) ecoff_symbol_type *new; bfd_size_type amt = sizeof (ecoff_symbol_type); - new = (ecoff_symbol_type *) bfd_alloc (abfd, amt); + new = (ecoff_symbol_type *) bfd_zalloc (abfd, amt); if (new == (ecoff_symbol_type *) NULL) return (asymbol *) NULL; - memset ((PTR) new, 0, sizeof *new); new->symbol.section = (asection *) NULL; new->fdr = (FDR *) NULL; new->local = false; @@ -727,6 +717,10 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, weak) || ECOFF_IS_STAB (ecoff_sym)) asym->flags |= BSF_DEBUGGING; } + + if (ecoff_sym->st == stProc || ecoff_sym->st == stStaticProc) + asym->flags |= BSF_FUNCTION; + switch (ecoff_sym->sc) { case scNil: @@ -1057,7 +1051,7 @@ _bfd_ecoff_get_symtab (abfd, alocation) ecoff_symbol_type *symbase; ecoff_symbol_type **location = (ecoff_symbol_type **) alocation; - if (_bfd_ecoff_slurp_symbol_table (abfd) == false) + if (! _bfd_ecoff_slurp_symbol_table (abfd)) return -1; if (bfd_get_symcount (abfd) == 0) return 0; @@ -1187,56 +1181,54 @@ ecoff_type_to_string (abfd, fdr, indx) qualifiers[5].type = u.ti.tq5; qualifiers[6].type = tqNil; - /* - * Go get the basic type. - */ + /* Go get the basic type. */ switch (basic_type) { - case btNil: /* undefined */ + case btNil: /* Undefined. */ strcpy (p1, "nil"); break; - case btAdr: /* address - integer same size as pointer */ + case btAdr: /* Address - integer same size as pointer. */ strcpy (p1, "address"); break; - case btChar: /* character */ + case btChar: /* Character. */ strcpy (p1, "char"); break; - case btUChar: /* unsigned character */ + case btUChar: /* Unsigned character. */ strcpy (p1, "unsigned char"); break; - case btShort: /* short */ + case btShort: /* Short. */ strcpy (p1, "short"); break; - case btUShort: /* unsigned short */ + case btUShort: /* Unsigned short. */ strcpy (p1, "unsigned short"); break; - case btInt: /* int */ + case btInt: /* Int. */ strcpy (p1, "int"); break; - case btUInt: /* unsigned int */ + case btUInt: /* Unsigned int. */ strcpy (p1, "unsigned int"); break; - case btLong: /* long */ + case btLong: /* Long. */ strcpy (p1, "long"); break; - case btULong: /* unsigned long */ + case btULong: /* Unsigned long. */ strcpy (p1, "unsigned long"); break; - case btFloat: /* float (real) */ + case btFloat: /* Float (real). */ strcpy (p1, "float"); break; - case btDouble: /* Double (real) */ + case btDouble: /* Double (real). */ strcpy (p1, "double"); break; @@ -1244,83 +1236,83 @@ ecoff_type_to_string (abfd, fdr, indx) 1st word is [ST_RFDESCAPE, offset] pointer to struct def; 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */ - case btStruct: /* Structure (Record) */ + case btStruct: /* Structure (Record). */ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx); ecoff_emit_aggregate (abfd, fdr, p1, &rndx, (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]), "struct"); - indx++; /* skip aux words */ + indx++; /* Skip aux words. */ break; /* Unions add 1-2 aux words: 1st word is [ST_RFDESCAPE, offset] pointer to union def; 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */ - case btUnion: /* Union */ + case btUnion: /* Union. */ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx); ecoff_emit_aggregate (abfd, fdr, p1, &rndx, (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]), "union"); - indx++; /* skip aux words */ + indx++; /* Skip aux words. */ break; /* Enumerations add 1-2 aux words: 1st word is [ST_RFDESCAPE, offset] pointer to enum def; 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */ - case btEnum: /* Enumeration */ + case btEnum: /* Enumeration. */ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx); ecoff_emit_aggregate (abfd, fdr, p1, &rndx, (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]), "enum"); - indx++; /* skip aux words */ + indx++; /* Skip aux words. */ break; - case btTypedef: /* defined via a typedef, isymRef points */ + case btTypedef: /* Defined via a typedef, isymRef points. */ strcpy (p1, "typedef"); break; - case btRange: /* subrange of int */ + case btRange: /* Subrange of int. */ strcpy (p1, "subrange"); break; - case btSet: /* pascal sets */ + case btSet: /* Pascal sets. */ strcpy (p1, "set"); break; - case btComplex: /* fortran complex */ + case btComplex: /* Fortran complex. */ strcpy (p1, "complex"); break; - case btDComplex: /* fortran double complex */ + case btDComplex: /* Fortran double complex. */ strcpy (p1, "double complex"); break; - case btIndirect: /* forward or unnamed typedef */ + case btIndirect: /* Forward or unnamed typedef. */ strcpy (p1, "forward/unamed typedef"); break; - case btFixedDec: /* Fixed Decimal */ + case btFixedDec: /* Fixed Decimal. */ strcpy (p1, "fixed decimal"); break; - case btFloatDec: /* Float Decimal */ + case btFloatDec: /* Float Decimal. */ strcpy (p1, "float decimal"); break; - case btString: /* Varying Length Character String */ + case btString: /* Varying Length Character String. */ strcpy (p1, "string"); break; - case btBit: /* Aligned Bit String */ + case btBit: /* Aligned Bit String. */ strcpy (p1, "bit"); break; - case btPicture: /* Picture */ + case btPicture: /* Picture. */ strcpy (p1, "picture"); break; - case btVoid: /* Void */ + case btVoid: /* Void. */ strcpy (p1, "void"); break; @@ -1331,9 +1323,7 @@ ecoff_type_to_string (abfd, fdr, indx) p1 += strlen (buffer1); - /* - * If this is a bitfield, get the bitsize. - */ + /* If this is a bitfield, get the bitsize. */ if (u.ti.fBitfield) { int bitsize; @@ -1343,20 +1333,16 @@ ecoff_type_to_string (abfd, fdr, indx) p1 += strlen (buffer1); } - /* - * Deal with any qualifiers. - */ + /* Deal with any qualifiers. */ if (qualifiers[0].type != tqNil) { - /* - * Snarf up any array bounds in the correct order. Arrays - * store 5 successive words in the aux. table: - * word 0 RNDXR to type of the bounds (ie, int) - * word 1 Current file descriptor index - * word 2 low bound - * word 3 high bound (or -1 if []) - * word 4 stride size in bits - */ + /* Snarf up any array bounds in the correct order. Arrays + store 5 successive words in the aux. table: + word 0 RNDXR to type of the bounds (ie, int) + word 1 Current file descriptor index + word 2 low bound + word 3 high bound (or -1 if []) + word 4 stride size in bits. */ for (i = 0; i < 7; i++) { if (qualifiers[i].type == tqArray) @@ -1371,9 +1357,7 @@ ecoff_type_to_string (abfd, fdr, indx) } } - /* - * Now print out the qualifiers. - */ + /* Now print out the qualifiers. */ for (i = 0; i < 6; i++) { switch (qualifiers[i].type) @@ -1409,7 +1393,6 @@ ecoff_type_to_string (abfd, fdr, indx) /* Print array bounds reversed (ie, in the order the C programmer writes them). C is such a fun language.... */ - while (i < 5 && qualifiers[i+1].type == tqArray) i++; @@ -1511,7 +1494,7 @@ _bfd_ecoff_print_symbol (abfd, filep, symbol, how) } break; case bfd_print_symbol_all: - /* Print out the symbols in a reasonable way */ + /* Print out the symbols in a reasonable way. */ { char type; int pos; @@ -1585,7 +1568,7 @@ _bfd_ecoff_print_symbol (abfd, filep, symbol, how) order is indicated by a bit in the fdr. */ bigendian = fdr->fBigendian; - /* This switch is basically from gcc/mips-tdump.c */ + /* This switch is basically from gcc/mips-tdump.c. */ switch (ecoff_ext.asym.st) { case stNil: @@ -1678,7 +1661,7 @@ ecoff_slurp_reloc_table (abfd, section, symbols) || (section->flags & SEC_CONSTRUCTOR) != 0) return true; - if (_bfd_ecoff_slurp_symbol_table (abfd) == false) + if (! _bfd_ecoff_slurp_symbol_table (abfd)) return false; amt = section->reloc_count; @@ -1794,7 +1777,7 @@ _bfd_ecoff_canonicalize_reloc (abfd, section, relptr, symbols) { arelent *tblptr; - if (ecoff_slurp_reloc_table (abfd, section, symbols) == false) + if (! ecoff_slurp_reloc_table (abfd, section, symbols)) return -1; tblptr = section->relocation; @@ -2181,7 +2164,7 @@ ecoff_compute_section_file_positions (abfd) if ((current->flags & SEC_HAS_CONTENTS) != 0) file_sofar += current->_raw_size; - /* make sure that this section is of the right size too */ + /* Make sure that this section is of the right size too. */ old_sofar = sofar; sofar = BFD_ALIGN (sofar, 1 << alignment_power); if ((current->flags & SEC_HAS_CONTENTS) != 0) @@ -2268,7 +2251,7 @@ _bfd_ecoff_set_section_contents (abfd, section, location, offset, count) /* This must be done first, because bfd_set_section_contents is going to set output_has_begun to true. */ - if (abfd->output_has_begun == false) + if (! abfd->output_has_begun) { if (! ecoff_compute_section_file_positions (abfd)) return false; @@ -2363,7 +2346,7 @@ bfd_ecoff_set_regmasks (abfd, gprmask, fprmask, cprmask) tdata->fprmask = fprmask; if (cprmask != (unsigned long *) NULL) { - register int i; + int i; for (i = 0; i < 3; i++) tdata->cprmask[i] = cprmask[i]; @@ -2630,13 +2613,12 @@ _bfd_ecoff_write_object_contents (abfd) else if (section.s_flags == 0 || (section.s_flags & STYP_ECOFF_LIB) != 0 || section.s_flags == STYP_COMMENT) - /* Do nothing */ ; + /* Do nothing. */ ; else abort (); } /* Set up the file header. */ - internal_f.f_magic = ecoff_get_magic (abfd); /* We will NOT put a fucking timestamp in the header here. Every @@ -2729,7 +2711,6 @@ _bfd_ecoff_write_object_contents (abfd) } /* Write out the file header and the optional header. */ - if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) goto error_return; @@ -2751,11 +2732,9 @@ _bfd_ecoff_write_object_contents (abfd) symhdr->issExtMax = 0; debug->external_ext = debug->external_ext_end = NULL; debug->ssext = debug->ssext_end = NULL; - if (bfd_ecoff_debug_externals (abfd, debug, &backend->debug_swap, - (((abfd->flags & EXEC_P) == 0) - ? true : false), - ecoff_get_extr, ecoff_set_index) - == false) + if (! bfd_ecoff_debug_externals (abfd, debug, &backend->debug_swap, + (abfd->flags & EXEC_P) == 0, + ecoff_get_extr, ecoff_set_index)) goto error_return; /* Write out the relocs. */ @@ -2859,9 +2838,8 @@ _bfd_ecoff_write_object_contents (abfd) if (bfd_get_symcount (abfd) > 0) { /* Write out the debugging information. */ - if (bfd_ecoff_write_debug (abfd, debug, &backend->debug_swap, - ecoff_data (abfd)->sym_filepos) - == false) + if (! bfd_ecoff_write_debug (abfd, debug, &backend->debug_swap, + ecoff_data (abfd)->sym_filepos)) goto error_return; } } @@ -3060,7 +3038,6 @@ _bfd_ecoff_slurp_armap (abfd) /* This code used to overlay the symdefs over the raw archive data, but that doesn't work on a 64 bit host. */ - stringbase = raw_armap + count * 8 + 8; #ifdef CHECK_ARMAP_HASH @@ -3314,8 +3291,6 @@ _bfd_ecoff_archive_p (abfd) char armag[SARMAG + 1]; bfd_size_type amt; - tdata_hold = abfd->tdata.aout_ar_data; - if (bfd_bread ((PTR) armag, (bfd_size_type) SARMAG, abfd) != SARMAG) { if (bfd_get_error () != bfd_error_system_call) @@ -3329,15 +3304,13 @@ _bfd_ecoff_archive_p (abfd) return NULL; } - /* We are setting bfd_ardata(abfd) here, but since bfd_ardata - involves a cast, we can't do it as the left operand of - assignment. */ - amt = sizeof (struct artdata); - abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt); + tdata_hold = bfd_ardata (abfd); + amt = sizeof (struct artdata); + bfd_ardata (abfd) = (struct artdata *) bfd_zalloc (abfd, amt); if (bfd_ardata (abfd) == (struct artdata *) NULL) { - abfd->tdata.aout_ar_data = tdata_hold; + bfd_ardata (abfd) = tdata_hold; return (const bfd_target *) NULL; } @@ -3348,11 +3321,11 @@ _bfd_ecoff_archive_p (abfd) bfd_ardata (abfd)->extended_names = NULL; bfd_ardata (abfd)->tdata = NULL; - if (_bfd_ecoff_slurp_armap (abfd) == false - || _bfd_ecoff_slurp_extended_name_table (abfd) == false) + if (! _bfd_ecoff_slurp_armap (abfd) + || ! _bfd_ecoff_slurp_extended_name_table (abfd)) { bfd_release (abfd, bfd_ardata (abfd)); - abfd->tdata.aout_ar_data = tdata_hold; + bfd_ardata (abfd) = tdata_hold; return (const bfd_target *) NULL; } @@ -3370,22 +3343,23 @@ _bfd_ecoff_archive_p (abfd) first = bfd_openr_next_archived_file (abfd, (bfd *) NULL); if (first != NULL) { - boolean fail; - first->target_defaulted = false; - fail = false; if (bfd_check_format (first, bfd_object) && first->xvec != abfd->xvec) { +#if 0 + /* We ought to close `first' here, but we can't, because + we have no way to remove it from the archive cache. + It's close to impossible to figure out when we can + release bfd_ardata. FIXME. */ (void) bfd_close (first); bfd_release (abfd, bfd_ardata (abfd)); - abfd->tdata.aout_ar_data = tdata_hold; - bfd_set_error (bfd_error_wrong_format); +#endif + bfd_set_error (bfd_error_wrong_object_format); + bfd_ardata (abfd) = tdata_hold; return NULL; } - - /* We ought to close first here, but we can't, because we - have no way to remove it from the archive cache. FIXME. */ + /* And we ought to close `first' here too. */ } } @@ -3452,7 +3426,7 @@ _bfd_ecoff_bfd_link_hash_table_create (abfd) struct ecoff_link_hash_table *ret; bfd_size_type amt = sizeof (struct ecoff_link_hash_table); - ret = (struct ecoff_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct ecoff_link_hash_table *) bfd_malloc (amt); if (ret == NULL) return NULL; if (! _bfd_link_hash_table_init (&ret->root, abfd, diff --git a/contrib/binutils/bfd/ecofflink.c b/contrib/binutils/bfd/ecofflink.c index 53d6544..5b854af 100644 --- a/contrib/binutils/bfd/ecofflink.c +++ b/contrib/binutils/bfd/ecofflink.c @@ -1,5 +1,5 @@ /* Routines to link ECOFF debugging information. - Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001 + Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>. @@ -1314,12 +1314,12 @@ bfd_ecoff_debug_externals (abfd, debug, swap, relocateable, get_extr, sym_ptr = *sym_ptr_ptr; /* Get the external symbol information. */ - if ((*get_extr) (sym_ptr, &esym) == false) + if (! (*get_extr) (sym_ptr, &esym)) continue; /* If we're producing an executable, move common symbols into bss. */ - if (relocateable == false) + if (! relocateable) { if (esym.asym.sc == scCommon) esym.asym.sc = scBss; @@ -1376,20 +1376,18 @@ bfd_ecoff_debug_one_external (abfd, debug, swap, name, esym) if ((size_t) (debug->ssext_end - debug->ssext) < symhdr->issExtMax + namelen + 1) { - if (ecoff_add_bytes ((char **) &debug->ssext, - (char **) &debug->ssext_end, - symhdr->issExtMax + namelen + 1) - == false) + if (! ecoff_add_bytes ((char **) &debug->ssext, + (char **) &debug->ssext_end, + symhdr->issExtMax + namelen + 1)) return false; } if ((size_t) ((char *) debug->external_ext_end - (char *) debug->external_ext) < (symhdr->iextMax + 1) * external_ext_size) { - if (ecoff_add_bytes ((char **) &debug->external_ext, - (char **) &debug->external_ext_end, - (symhdr->iextMax + 1) * (size_t) external_ext_size) - == false) + if (! ecoff_add_bytes ((char **) &debug->external_ext, + (char **) &debug->external_ext_end, + (symhdr->iextMax + 1) * (size_t) external_ext_size)) return false; } @@ -1650,11 +1648,10 @@ ecoff_write_shuffle (abfd, swap, shuffle, space) bfd_byte *s; i = swap->debug_align - (total & (swap->debug_align - 1)); - s = (bfd_byte *) bfd_malloc ((bfd_size_type) i); + s = (bfd_byte *) bfd_zmalloc ((bfd_size_type) i); if (s == NULL && i != 0) return false; - memset ((PTR) s, 0, i); if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i) { free (s); @@ -1736,10 +1733,10 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) bfd_byte *s; i = swap->debug_align - (total & (swap->debug_align - 1)); - s = (bfd_byte *) bfd_malloc ((bfd_size_type) i); + s = (bfd_byte *) bfd_zmalloc ((bfd_size_type) i); if (s == NULL && i != 0) goto error_return; - memset ((PTR) s, 0, i); + if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i) { free (s); @@ -1761,10 +1758,10 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) i = (swap->debug_align - (debug->symbolic_header.issExtMax & (swap->debug_align - 1))); - s = (bfd_byte *) bfd_malloc ((bfd_size_type) i); + s = (bfd_byte *) bfd_zmalloc ((bfd_size_type) i); if (s == NULL && i != 0) goto error_return; - memset ((PTR) s, 0, i); + if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i) { free (s); diff --git a/contrib/binutils/bfd/elf-bfd.h b/contrib/binutils/bfd/elf-bfd.h index d10fda9..4c7e2f6 100644 --- a/contrib/binutils/bfd/elf-bfd.h +++ b/contrib/binutils/bfd/elf-bfd.h @@ -223,6 +223,12 @@ struct elf_link_local_dynamic_entry Elf_Internal_Sym isym; }; +struct elf_link_loaded_list +{ + struct elf_link_loaded_list *next; + bfd *abfd; +}; + enum elf_link_info_type { ELF_INFO_TYPE_NONE, @@ -230,9 +236,18 @@ enum elf_link_info_type ELF_INFO_TYPE_MERGE, ELF_INFO_TYPE_EH_FRAME, ELF_INFO_TYPE_EH_FRAME_HDR, + ELF_INFO_TYPE_JUST_SYMS, ELF_INFO_TYPE_LAST }; +/* Cached start, size and alignment of PT_TLS segment. */ +struct elf_link_tls_segment +{ + bfd_vma start; + bfd_size_type size; + unsigned int align; +}; + /* ELF linker hash table. */ struct elf_link_hash_table @@ -285,6 +300,12 @@ struct elf_link_hash_table /* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic objects included in the link. */ struct bfd_link_needed_list *runpath; + + /* Cached start, size and alignment of PT_TLS segment. */ + struct elf_link_tls_segment *tls_segment; + + /* A linked list of BFD's loaded in the link. */ + struct elf_link_loaded_list *loaded; }; /* Look up an entry in an ELF linker hash table. */ @@ -341,6 +362,8 @@ struct elf_size_info { PARAMS ((bfd *)); void (*write_relocs) PARAMS ((bfd *, asection *, PTR)); + void (*swap_symbol_in) + PARAMS ((bfd *, const PTR, const PTR, Elf_Internal_Sym *)); void (*swap_symbol_out) PARAMS ((bfd *, const Elf_Internal_Sym *, PTR, PTR)); boolean (*slurp_reloc_table) @@ -394,8 +417,7 @@ enum elf_reloc_type_class { struct elf_reloc_cookie { Elf_Internal_Rela *rels, *rel, *relend; - PTR locsyms; - PTR locsym_shndx; + Elf_Internal_Sym *locsyms; bfd *abfd; size_t locsymcount; size_t extsymoff; @@ -403,6 +425,14 @@ struct elf_reloc_cookie boolean bad_symtab; }; +/* The level of IRIX compatibility we're striving for. */ + +typedef enum { + ict_none, + ict_irix5, + ict_irix6 +} irix_compat_t; + struct elf_backend_data { /* The architecture for this backend. */ @@ -470,7 +500,7 @@ struct elf_backend_data /* A function to handle unusual section types when creating BFD sections from ELF sections. */ boolean (*elf_backend_section_from_shdr) - PARAMS ((bfd *, Elf32_Internal_Shdr *, char *)); + PARAMS ((bfd *, Elf32_Internal_Shdr *, const char *)); /* A function to convert machine dependent section header flags to BFD internal section header flags. */ @@ -649,10 +679,9 @@ struct elf_backend_data PARAMS ((bfd *)); /* This function is called during section gc to discover the section a - particular relocation refers to. It need not be defined for hosts - that have no queer relocation types. */ + particular relocation refers to. */ asection * (*gc_mark_hook) - PARAMS ((bfd *abfd, struct bfd_link_info *, Elf_Internal_Rela *, + PARAMS ((asection *sec, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *h, Elf_Internal_Sym *)); /* This function, if defined, is called during the sweep phase of gc @@ -682,13 +711,14 @@ struct elf_backend_data PARAMS ((bfd *, struct bfd_link_info *, PTR, boolean (*) (PTR, const char *, Elf_Internal_Sym *, asection *))); - /* Copy any information related to dynamic linking from a pre-existing + /* Copy any information related to dynamic linking from a pre-existing symbol to a newly created symbol. Also called to copy flags and other back-end info to a weakdef, in which case the symbol is not newly created and plt/got refcounts and dynamic indices should not be copied. */ void (*elf_backend_copy_indirect_symbol) - PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *)); + PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *, + struct elf_link_hash_entry *)); /* Modify any information related to dynamic linking such that the symbol is not exported. */ @@ -697,7 +727,7 @@ struct elf_backend_data /* Emit relocations. Overrides default routine for emitting relocs, except during a relocatable link, or if all relocs are being emitted. */ - void (*elf_backend_emit_relocs) + boolean (*elf_backend_emit_relocs) PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *)); /* Count relocations. Not called for relocatable links @@ -740,6 +770,30 @@ struct elf_backend_data boolean (*elf_backend_write_section) PARAMS ((bfd *, asection *, bfd_byte *)); + /* This function, if defined, sets up the file positions for non PT_LOAD + segments, especially for segments containing non-allocated sections. */ + void (*set_nonloadable_filepos) + PARAMS ((bfd *, Elf_Internal_Phdr *)); + + /* This function, if defined, returns true if the section is contained + within the segment. File positions are compared. */ + boolean (*is_contained_by_filepos) + PARAMS ((asection *, Elf_Internal_Phdr *)); + + /* This function, if defined, returns true if copy_private_bfd_data + should be called. It provides a way of overriding default + test conditions in _bfd_elf_copy_private_section_data. */ + boolean (*copy_private_bfd_data_p) + PARAMS ((bfd *, asection *, bfd *, asection *)); + + /* The level of IRIX compatibility we're striving for. + MIPS ELF specific function. */ + irix_compat_t (*elf_backend_mips_irix_compat) + PARAMS ((bfd *)); + + reloc_howto_type *(*elf_backend_mips_rtype_to_howto) + PARAMS ((unsigned int, boolean)); + /* The swapping table to use when dealing with ECOFF information. Used for the MIPS ELF .mdebug section. */ const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap; @@ -806,6 +860,10 @@ struct elf_backend_data unsigned can_refcount : 1; unsigned want_got_sym : 1; unsigned want_dynbss : 1; + /* Targets which do not support physical addressing often require + that the p_paddr field in the section header to be set to zero. + This field indicates whether this behavior is required. */ + unsigned want_p_paddr_set_to_zero : 1; }; /* Information stored for each BFD section in an ELF file. This @@ -870,8 +928,13 @@ struct bfd_elf_section_data /* Type of that information. */ enum elf_link_info_type sec_info_type; - /* Group name, if this section is part of a group. */ - const char *group_name; + union { + /* Group name, if this section is a member of a group. */ + const char *name; + + /* Group signature sym, if this is the SHT_GROUP section. */ + struct symbol_cache_entry *id; + } group; /* A linked list of sections in the group. Circular when used by the linker. */ @@ -882,17 +945,23 @@ struct bfd_elf_section_data /* Nonzero if this section uses RELA relocations, rather than REL. */ unsigned int use_rela_p:1; + + /* Nonzero when a group is COMDAT. */ + unsigned int linkonce_p:1; }; #define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd) -#define elf_group_name(sec) (elf_section_data(sec)->group_name) +#define elf_group_name(sec) (elf_section_data(sec)->group.name) +#define elf_group_id(sec) (elf_section_data(sec)->group.id) #define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group) +#define elf_linkonce_p(sec) (elf_section_data(sec)->linkonce_p) /* Return true if section has been discarded. */ #define elf_discarded_section(sec) \ (!bfd_is_abs_section(sec) \ && bfd_is_abs_section((sec)->output_section) \ - && elf_section_data (sec)->sec_info_type != ELF_INFO_TYPE_MERGE) + && elf_section_data (sec)->sec_info_type != ELF_INFO_TYPE_MERGE \ + && elf_section_data (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS) #define get_elf_backend_data(abfd) \ ((struct elf_backend_data *) (abfd)->xvec->backend_data) @@ -1151,6 +1220,9 @@ extern char *bfd_elf_string_from_elf_section PARAMS ((bfd *, unsigned, unsigned)); extern char *bfd_elf_get_str_section PARAMS ((bfd *, unsigned)); +extern Elf_Internal_Sym *bfd_elf_get_elf_syms + PARAMS ((bfd *, Elf_Internal_Shdr *, size_t, size_t, + Elf_Internal_Sym *, PTR, Elf_External_Sym_Shndx *)); extern boolean _bfd_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *)); @@ -1200,7 +1272,8 @@ extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create PARAMS ((bfd *)); extern void _bfd_elf_link_hash_copy_indirect - PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *)); + PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *, + struct elf_link_hash_entry *)); extern void _bfd_elf_link_hash_hide_symbol PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean)); extern boolean _bfd_elf_link_hash_table_init @@ -1210,10 +1283,14 @@ extern boolean _bfd_elf_link_hash_table_init const char *))); extern boolean _bfd_elf_slurp_version_tables PARAMS ((bfd *)); - extern boolean _bfd_elf_merge_sections PARAMS ((bfd *, struct bfd_link_info *)); - +extern boolean bfd_elf_discard_group + PARAMS ((bfd *, struct sec *)); +extern void bfd_elf_set_group_contents + PARAMS ((bfd *, asection *, PTR)); +extern void _bfd_elf_link_just_syms + PARAMS ((asection *, struct bfd_link_info *)); extern boolean _bfd_elf_copy_private_symbol_data PARAMS ((bfd *, asymbol *, bfd *, asymbol *)); extern boolean _bfd_elf_copy_private_section_data @@ -1390,8 +1467,7 @@ extern boolean bfd_elf32_bfd_final_link PARAMS ((bfd *, struct bfd_link_info *)); extern void bfd_elf32_swap_symbol_in - PARAMS ((bfd *, const Elf32_External_Sym *, const Elf_External_Sym_Shndx *, - Elf_Internal_Sym *)); + PARAMS ((bfd *, const PTR, const PTR, Elf_Internal_Sym *)); extern void bfd_elf32_swap_symbol_out PARAMS ((bfd *, const Elf_Internal_Sym *, PTR, PTR)); extern void bfd_elf32_swap_reloc_in @@ -1443,8 +1519,7 @@ extern boolean bfd_elf64_bfd_final_link PARAMS ((bfd *, struct bfd_link_info *)); extern void bfd_elf64_swap_symbol_in - PARAMS ((bfd *, const Elf64_External_Sym *, const Elf_External_Sym_Shndx *, - Elf_Internal_Sym *)); + PARAMS ((bfd *, const PTR, const PTR, Elf_Internal_Sym *)); extern void bfd_elf64_swap_symbol_out PARAMS ((bfd *, const Elf_Internal_Sym *, PTR, PTR)); extern void bfd_elf64_swap_reloc_in @@ -1485,10 +1560,12 @@ extern Elf_Internal_Rela *_bfd_elf64_link_read_relocs #define bfd_elf64_link_record_dynamic_symbol \ _bfd_elf_link_record_dynamic_symbol -extern boolean _bfd_elf32_link_record_local_dynamic_symbol - PARAMS ((struct bfd_link_info *, bfd *, long)); -extern boolean _bfd_elf64_link_record_local_dynamic_symbol +extern int elf_link_record_local_dynamic_symbol PARAMS ((struct bfd_link_info *, bfd *, long)); +#define _bfd_elf32_link_record_local_dynamic_symbol \ + elf_link_record_local_dynamic_symbol +#define _bfd_elf64_link_record_local_dynamic_symbol \ + elf_link_record_local_dynamic_symbol extern boolean _bfd_elf_close_and_cleanup PARAMS ((bfd *)); @@ -1524,99 +1601,20 @@ extern boolean _bfd_elf64_reloc_symbol_deleted_p PARAMS ((bfd_vma, PTR)); /* Exported interface for writing elf corefile notes. */ -extern char *elfcore_write_note - PARAMS ((bfd *, char *, int *, char *, int, void *, int)); -extern char *elfcore_write_prpsinfo - PARAMS ((bfd *, char *, int *, char *, char *)); -extern char *elfcore_write_prstatus - PARAMS ((bfd *, char *, int *, long, int, void *)); -extern char * elfcore_write_pstatus - PARAMS ((bfd *, char *, int *, long, int, void *)); -extern char *elfcore_write_prfpreg - PARAMS ((bfd *, char *, int *, void *, int)); -extern char *elfcore_write_prxfpreg - PARAMS ((bfd *, char *, int *, void *, int)); -extern char *elfcore_write_lwpstatus - PARAMS ((bfd*, char*, int*, long, int, void*)); - -/* MIPS ELF specific routines. */ - -extern boolean _bfd_mips_elf_object_p - PARAMS ((bfd *)); -extern boolean _bfd_mips_elf_section_from_shdr - PARAMS ((bfd *, Elf_Internal_Shdr *, char *)); -extern boolean _bfd_mips_elf_fake_sections - PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); -extern boolean _bfd_mips_elf_section_from_bfd_section - PARAMS ((bfd *, asection *, int *)); -extern boolean _bfd_mips_elf_section_processing - PARAMS ((bfd *, Elf_Internal_Shdr *)); -extern void _bfd_mips_elf_symbol_processing - PARAMS ((bfd *, asymbol *)); -extern boolean _bfd_mips_elf_read_ecoff_info - PARAMS ((bfd *, asection *, struct ecoff_debug_info *)); -extern void _bfd_mips_elf_final_write_processing - PARAMS ((bfd *, boolean)); -extern bfd_reloc_status_type _bfd_mips_elf_hi16_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -extern bfd_reloc_status_type _bfd_mips_elf_lo16_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -extern bfd_reloc_status_type _bfd_mips_elf_gprel16_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -extern bfd_reloc_status_type _bfd_mips_elf_got16_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -extern bfd_reloc_status_type _bfd_mips_elf_gprel32_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -extern boolean _bfd_mips_elf_set_private_flags - PARAMS ((bfd *, flagword)); -extern boolean _bfd_mips_elf_merge_private_bfd_data - PARAMS ((bfd *, bfd *)); -extern boolean _bfd_mips_elf_find_nearest_line - PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, - const char **, unsigned int *)); -extern boolean _bfd_mips_elf_set_section_contents - PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type)); -extern boolean _bfd_mips_elf_create_dynamic_sections - PARAMS ((bfd *, struct bfd_link_info *)); -extern boolean _bfd_mips_elf_add_symbol_hook - PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, - const char **, flagword *, asection **, bfd_vma *)); -extern boolean _bfd_mips_elf_adjust_dynamic_symbol - PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); -extern boolean _bfd_mips_elf_finish_dynamic_symbol - PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, - Elf_Internal_Sym *)); -extern boolean _bfd_mips_elf_finish_dynamic_sections - PARAMS ((bfd *, struct bfd_link_info *)); -extern asection * _bfd_mips_elf_gc_mark_hook - PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, - struct elf_link_hash_entry *, Elf_Internal_Sym *)); -extern boolean _bfd_mips_elf_gc_sweep_hook - PARAMS ((bfd *, struct bfd_link_info *, asection *, - const Elf_Internal_Rela *)); -extern boolean _bfd_mips_elf_always_size_sections - PARAMS ((bfd *, struct bfd_link_info *)); -extern boolean _bfd_mips_elf_size_dynamic_sections - PARAMS ((bfd *, struct bfd_link_info *)); -extern boolean _bfd_mips_elf_check_relocs - PARAMS ((bfd *, struct bfd_link_info *, asection *, - const Elf_Internal_Rela *)); -extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create - PARAMS ((bfd *)); -extern boolean _bfd_mips_elf_print_private_bfd_data - PARAMS ((bfd *, PTR)); -extern boolean _bfd_mips_elf_link_output_symbol_hook - PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *, - asection *)); -extern boolean _bfd_mips_elf_final_link - PARAMS ((bfd *, struct bfd_link_info *)); -extern int _bfd_mips_elf_additional_program_headers - PARAMS ((bfd *)); -extern boolean _bfd_mips_elf_modify_segment_map - PARAMS ((bfd *)); -extern boolean _bfd_mips_elf_relocate_section - PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, - Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); +extern char *elfcore_write_note + PARAMS ((bfd *, char *, int *, const char *, int, const PTR, int)); +extern char *elfcore_write_prpsinfo + PARAMS ((bfd *, char *, int *, const char *, const char *)); +extern char *elfcore_write_prstatus + PARAMS ((bfd *, char *, int *, long, int, const PTR)); +extern char * elfcore_write_pstatus + PARAMS ((bfd *, char *, int *, long, int, const PTR)); +extern char *elfcore_write_prfpreg + PARAMS ((bfd *, char *, int *, const PTR, int)); +extern char *elfcore_write_prxfpreg + PARAMS ((bfd *, char *, int *, const PTR, int)); +extern char *elfcore_write_lwpstatus + PARAMS ((bfd *, char *, int *, long, int, const PTR)); /* SH ELF specific routine. */ diff --git a/contrib/binutils/bfd/elf-eh-frame.c b/contrib/binutils/bfd/elf-eh-frame.c index 6a23edb..713dc8f 100644 --- a/contrib/binutils/bfd/elf-eh-frame.c +++ b/contrib/binutils/bfd/elf-eh-frame.c @@ -627,11 +627,11 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec, goto free_no_table; if ((*reloc_symbol_deleted_p) (buf - ehbuf, cookie)) { - cookie->rel = rel; /* This is a FDE against discarded section, it should be deleted. */ new_size -= hdr.length + 4; sec_info->entry[sec_info->count].removed = 1; + memset (rel, 0, sizeof (*rel)); } else { @@ -787,7 +787,7 @@ _bfd_elf_maybe_strip_eh_frame_hdr (info) struct eh_frame_hdr_info *hdr_info; sec = bfd_get_section_by_name (elf_hash_table (info)->dynobj, ".eh_frame_hdr"); - if (sec == NULL) + if (sec == NULL || bfd_is_abs_section (sec->output_section)) return true; hdr_info @@ -805,7 +805,7 @@ _bfd_elf_maybe_strip_eh_frame_hdr (info) /* Count only sections which have at least a single CIE or FDE. There cannot be any CIE or FDE <= 8 bytes. */ o = bfd_get_section_by_name (abfd, ".eh_frame"); - if (o && o->_raw_size > 8) + if (o && o->_raw_size > 8 && !bfd_is_abs_section (o->output_section)) break; } diff --git a/contrib/binutils/bfd/elf-strtab.c b/contrib/binutils/bfd/elf-strtab.c index ff7d9a4..7a993c2 100644 --- a/contrib/binutils/bfd/elf-strtab.c +++ b/contrib/binutils/bfd/elf-strtab.c @@ -1,28 +1,29 @@ /* ELF strtab with GC and suffix merging support. - Copyright 2001 Free Software Foundation, Inc. + Copyright 2001, 2002 Free Software Foundation, Inc. Written by Jakub Jelinek <jakub@redhat.com>. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" #include "elf-bfd.h" #include "hashtab.h" +#include "libiberty.h" /* An entry in the strtab hash table. */ @@ -351,7 +352,7 @@ _bfd_elf_strtab_finalize (tab) qsort (array, size, sizeof (struct elf_strtab_hash_entry *), cmplengthentry); - last4tab = htab_create (size * 4, NULL, last4_eq, NULL); + last4tab = htab_create_alloc (size * 4, NULL, last4_eq, NULL, calloc, free); if (last4tab == NULL) goto alloc_failure; diff --git a/contrib/binutils/bfd/elf.c b/contrib/binutils/bfd/elf.c index b78eb5f..a7bafb6 100644 --- a/contrib/binutils/bfd/elf.c +++ b/contrib/binutils/bfd/elf.c @@ -2,24 +2,24 @@ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. - This file is part of BFD, the Binary File Descriptor library. +This file is part of BFD, the Binary File Descriptor library. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* SECTION - + ELF backends BFD support for ELF formats is being worked on. @@ -50,10 +50,10 @@ static boolean prep_headers PARAMS ((bfd *)); static boolean swap_out_syms PARAMS ((bfd *, struct bfd_strtab_hash **, int)); static boolean copy_private_bfd_data PARAMS ((bfd *, bfd *)); static char *elf_read PARAMS ((bfd *, file_ptr, bfd_size_type)); +static const char *group_signature PARAMS ((bfd *, Elf_Internal_Shdr *)); static boolean setup_group PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); static void merge_sections_remove_hook PARAMS ((bfd *, asection *)); static void elf_fake_sections PARAMS ((bfd *, asection *, PTR)); -static void set_group_contents PARAMS ((bfd *, asection *, PTR)); static boolean assign_section_numbers PARAMS ((bfd *)); static INLINE int sym_is_global PARAMS ((bfd *, asymbol *)); static boolean elf_map_symbols PARAMS ((bfd *)); @@ -352,6 +352,107 @@ bfd_elf_string_from_elf_section (abfd, shindex, strindex) return ((char *) hdr->contents) + strindex; } +/* Read and convert symbols to internal format. + SYMCOUNT specifies the number of symbols to read, starting from + symbol SYMOFFSET. If any of INTSYM_BUF, EXTSYM_BUF or EXTSHNDX_BUF + are non-NULL, they are used to store the internal symbols, external + symbols, and symbol section index extensions, respectively. */ + +Elf_Internal_Sym * +bfd_elf_get_elf_syms (ibfd, symtab_hdr, symcount, symoffset, + intsym_buf, extsym_buf, extshndx_buf) + bfd *ibfd; + Elf_Internal_Shdr *symtab_hdr; + size_t symcount; + size_t symoffset; + Elf_Internal_Sym *intsym_buf; + PTR extsym_buf; + Elf_External_Sym_Shndx *extshndx_buf; +{ + Elf_Internal_Shdr *shndx_hdr; + PTR alloc_ext; + const bfd_byte *esym; + Elf_External_Sym_Shndx *alloc_extshndx; + Elf_External_Sym_Shndx *shndx; + Elf_Internal_Sym *isym; + Elf_Internal_Sym *isymend; + struct elf_backend_data *bed; + size_t extsym_size; + bfd_size_type amt; + file_ptr pos; + + if (symcount == 0) + return intsym_buf; + + /* Normal syms might have section extension entries. */ + shndx_hdr = NULL; + if (symtab_hdr == &elf_tdata (ibfd)->symtab_hdr) + shndx_hdr = &elf_tdata (ibfd)->symtab_shndx_hdr; + + /* Read the symbols. */ + alloc_ext = NULL; + alloc_extshndx = NULL; + bed = get_elf_backend_data (ibfd); + extsym_size = bed->s->sizeof_sym; + amt = symcount * extsym_size; + pos = symtab_hdr->sh_offset + symoffset * extsym_size; + if (extsym_buf == NULL) + { + alloc_ext = bfd_malloc (amt); + extsym_buf = alloc_ext; + } + if (extsym_buf == NULL + || bfd_seek (ibfd, pos, SEEK_SET) != 0 + || bfd_bread (extsym_buf, amt, ibfd) != amt) + { + intsym_buf = NULL; + goto out; + } + + if (shndx_hdr == NULL || shndx_hdr->sh_size == 0) + extshndx_buf = NULL; + else + { + amt = symcount * sizeof (Elf_External_Sym_Shndx); + pos = shndx_hdr->sh_offset + symoffset * sizeof (Elf_External_Sym_Shndx); + if (extshndx_buf == NULL) + { + alloc_extshndx = (Elf_External_Sym_Shndx *) bfd_malloc (amt); + extshndx_buf = alloc_extshndx; + } + if (extshndx_buf == NULL + || bfd_seek (ibfd, pos, SEEK_SET) != 0 + || bfd_bread (extshndx_buf, amt, ibfd) != amt) + { + intsym_buf = NULL; + goto out; + } + } + + if (intsym_buf == NULL) + { + bfd_size_type amt = symcount * sizeof (Elf_Internal_Sym); + intsym_buf = (Elf_Internal_Sym *) bfd_malloc (amt); + if (intsym_buf == NULL) + goto out; + } + + /* Convert the symbols to internal form. */ + isymend = intsym_buf + symcount; + for (esym = extsym_buf, isym = intsym_buf, shndx = extshndx_buf; + isym < isymend; + esym += extsym_size, isym++, shndx = shndx != NULL ? shndx + 1 : NULL) + (*bed->s->swap_symbol_in) (ibfd, esym, (const PTR) shndx, isym); + + out: + if (alloc_ext != NULL) + free (alloc_ext); + if (alloc_extshndx != NULL) + free (alloc_extshndx); + + return intsym_buf; +} + /* Elf_Internal_Shdr->contents is an array of these for SHT_GROUP sections. The first element is the flags, the rest are section pointers. */ @@ -361,6 +462,43 @@ typedef union elf_internal_group { unsigned int flags; } Elf_Internal_Group; +/* Return the name of the group signature symbol. Why isn't the + signature just a string? */ + +static const char * +group_signature (abfd, ghdr) + bfd *abfd; + Elf_Internal_Shdr *ghdr; +{ + Elf_Internal_Shdr *hdr; + unsigned char esym[sizeof (Elf64_External_Sym)]; + Elf_External_Sym_Shndx eshndx; + Elf_Internal_Sym isym; + unsigned int iname; + unsigned int shindex; + + /* First we need to ensure the symbol table is available. */ + if (! bfd_section_from_shdr (abfd, ghdr->sh_link)) + return NULL; + + /* Go read the symbol. */ + hdr = &elf_tdata (abfd)->symtab_hdr; + if (bfd_elf_get_elf_syms (abfd, hdr, 1, ghdr->sh_info, + &isym, esym, &eshndx) == NULL) + return NULL; + + /* Look up the symbol name. */ + iname = isym.st_name; + shindex = hdr->sh_link; + if (iname == 0 && ELF_ST_TYPE (isym.st_info) == STT_SECTION) + { + iname = elf_elfsections (abfd)[isym.st_shndx]->sh_name; + shindex = elf_elfheader (abfd)->e_shstrndx; + } + + return bfd_elf_string_from_elf_section (abfd, shindex, iname); +} + /* Set next_in_group list pointer, and group name for NEWSECT. */ static boolean @@ -440,6 +578,9 @@ setup_group (abfd, hdr, newsect) if (src == shdr->contents) { dest->flags = idx; + if (shdr->bfd_section != NULL && (idx & GRP_COMDAT)) + shdr->bfd_section->flags + |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; break; } if (idx >= shnum) @@ -492,32 +633,22 @@ setup_group (abfd, hdr, newsect) } else { - struct elf_backend_data *bed; - file_ptr pos; - unsigned char ename[4]; - unsigned long iname; const char *gname; - /* Humbug. Get the name from the group signature - symbol. Why isn't the signature just a string? - Fortunately, the name index is at the same - place in the external symbol for both 32 and 64 - bit ELF. */ - bed = get_elf_backend_data (abfd); - pos = elf_tdata (abfd)->symtab_hdr.sh_offset; - pos += shdr->sh_info * bed->s->sizeof_sym; - if (bfd_seek (abfd, pos, SEEK_SET) != 0 - || bfd_bread (ename, (bfd_size_type) 4, abfd) != 4) + gname = group_signature (abfd, shdr); + if (gname == NULL) return false; - iname = H_GET_32 (abfd, ename); - gname = elf_string_from_elf_strtab (abfd, iname); elf_group_name (newsect) = gname; /* Start a circular list with one element. */ elf_next_in_group (newsect) = newsect; } + + /* If the group section has been created, point to the + new member. */ if (shdr->bfd_section != NULL) elf_next_in_group (shdr->bfd_section) = newsect; + i = num_group - 1; break; } @@ -532,6 +663,25 @@ setup_group (abfd, hdr, newsect) return true; } +boolean +bfd_elf_discard_group (abfd, group) + bfd *abfd ATTRIBUTE_UNUSED; + asection *group; +{ + asection *first = elf_next_in_group (group); + asection *s = first; + + while (s != NULL) + { + s->output_section = bfd_abs_section_ptr; + s = elf_next_in_group (s); + /* These lists are circular. */ + if (s == first) + break; + } + return true; +} + /* Make a BFD section from an ELF section. We store a pointer to the BFD section in the bfd_section field of the header. */ @@ -591,6 +741,8 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name) if (hdr->sh_flags & SHF_GROUP) if (!setup_group (abfd, hdr, newsect)) return false; + if ((hdr->sh_flags & SHF_TLS) != 0) + flags |= SEC_THREAD_LOCAL; /* The debugging sections appear to be recognized only by name, not any sort of flag. */ @@ -618,7 +770,8 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name) The symbols will be defined as weak, so that multiple definitions are permitted. The GNU linker extension is to actually discard all but one of the sections. */ - if (strncmp (name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) == 0) + if (strncmp (name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) == 0 + && elf_next_in_group (newsect) == NULL) flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; bed = get_elf_backend_data (abfd); @@ -651,7 +804,7 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name) /* This section is part of this segment if its file offset plus size lies within the segment's memory span and, if the section is loaded, the extent of the - loaded data lies within the extent of the segment. + loaded data lies within the extent of the segment. Note - we used to check the p_paddr field as well, and refuse to set the LMA if it was 0. This is wrong @@ -794,7 +947,7 @@ merge_sections_remove_hook (abfd, sec) asection *sec; { struct bfd_elf_section_data *sec_data; - + sec_data = elf_section_data (sec); BFD_ASSERT (sec_data->sec_info_type == ELF_INFO_TYPE_MERGE); sec_data->sec_info_type = ELF_INFO_TYPE_NONE; @@ -814,6 +967,19 @@ _bfd_elf_merge_sections (abfd, info) merge_sections_remove_hook); return true; } + +void +_bfd_elf_link_just_syms (sec, info) + asection *sec; + struct bfd_link_info *info; +{ + sec->output_section = bfd_abs_section_ptr; + sec->output_offset = sec->vma; + if (!is_elf_hash_table (info)) + return; + + elf_section_data (sec)->sec_info_type = ELF_INFO_TYPE_JUST_SYMS; +} /* Copy the program header and other data from one object module to another. */ @@ -870,6 +1036,7 @@ _bfd_elf_print_private_bfd_data (abfd, farg) case PT_NOTE: pt = "NOTE"; break; case PT_SHLIB: pt = "SHLIB"; break; case PT_PHDR: pt = "PHDR"; break; + case PT_TLS: pt = "TLS"; break; case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break; default: sprintf (buf, "0x%lx", p->p_type); pt = buf; break; } @@ -1251,10 +1418,12 @@ _bfd_elf_link_hash_newfunc (entry, table, string) old indirect symbol. Also used for copying flags to a weakdef. */ void -_bfd_elf_link_hash_copy_indirect (dir, ind) +_bfd_elf_link_hash_copy_indirect (bed, dir, ind) + struct elf_backend_data *bed; struct elf_link_hash_entry *dir, *ind; { bfd_signed_vma tmp; + bfd_signed_vma lowest_valid = bed->can_refcount; /* Copy down any references that we may have already seen to the symbol which just became indirect. */ @@ -1272,22 +1441,22 @@ _bfd_elf_link_hash_copy_indirect (dir, ind) /* Copy over the global and procedure linkage table refcount entries. These may have been already set up by a check_relocs routine. */ tmp = dir->got.refcount; - if (tmp <= 0) + if (tmp < lowest_valid) { dir->got.refcount = ind->got.refcount; ind->got.refcount = tmp; } else - BFD_ASSERT (ind->got.refcount <= 0); + BFD_ASSERT (ind->got.refcount < lowest_valid); tmp = dir->plt.refcount; - if (tmp <= 0) + if (tmp < lowest_valid) { dir->plt.refcount = ind->plt.refcount; ind->plt.refcount = tmp; } else - BFD_ASSERT (ind->plt.refcount <= 0); + BFD_ASSERT (ind->plt.refcount < lowest_valid); if (dir->dynindx == -1) { @@ -1341,6 +1510,7 @@ _bfd_elf_link_hash_table_init (table, abfd, newfunc) table->bucketcount = 0; table->needed = NULL; table->runpath = NULL; + table->loaded = NULL; table->hgot = NULL; table->stab_info = NULL; table->merge_info = NULL; @@ -1360,13 +1530,13 @@ _bfd_elf_link_hash_table_create (abfd) struct elf_link_hash_table *ret; bfd_size_type amt = sizeof (struct elf_link_hash_table); - ret = (struct elf_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct elf_link_hash_table *) bfd_malloc (amt); if (ret == (struct elf_link_hash_table *) NULL) return NULL; if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return NULL; } @@ -1560,7 +1730,7 @@ bfd_section_from_shdr (abfd, shindex) Elf_Internal_Shdr *hdr = elf_elfsections (abfd)[shindex]; Elf_Internal_Ehdr *ehdr = elf_elfheader (abfd); struct elf_backend_data *bed = get_elf_backend_data (abfd); - char *name; + const char *name; name = elf_string_from_elf_strtab (abfd, hdr->sh_name); @@ -1571,7 +1741,6 @@ bfd_section_from_shdr (abfd, shindex) return true; case SHT_PROGBITS: /* Normal section with contents. */ - case SHT_DYNAMIC: /* Dynamic linking information. */ case SHT_NOBITS: /* .bss section. */ case SHT_HASH: /* .hash section. */ case SHT_NOTE: /* .note section. */ @@ -1580,6 +1749,39 @@ bfd_section_from_shdr (abfd, shindex) case SHT_PREINIT_ARRAY: /* .preinit_array section. */ return _bfd_elf_make_section_from_shdr (abfd, hdr, name); + case SHT_DYNAMIC: /* Dynamic linking information. */ + if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) + return false; + if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB) + { + Elf_Internal_Shdr *dynsymhdr; + + /* The shared libraries distributed with hpux11 have a bogus + sh_link field for the ".dynamic" section. Find the + string table for the ".dynsym" section instead. */ + if (elf_dynsymtab (abfd) != 0) + { + dynsymhdr = elf_elfsections (abfd)[elf_dynsymtab (abfd)]; + hdr->sh_link = dynsymhdr->sh_link; + } + else + { + unsigned int i, num_sec; + + num_sec = elf_numsections (abfd); + for (i = 1; i < num_sec; i++) + { + dynsymhdr = elf_elfsections (abfd)[i]; + if (dynsymhdr->sh_type == SHT_DYNSYM) + { + hdr->sh_link = dynsymhdr->sh_link; + break; + } + } + } + } + break; + case SHT_SYMTAB: /* A symbol table */ if (elf_onesymtab (abfd) == shindex) return true; @@ -1804,7 +2006,12 @@ bfd_section_from_shdr (abfd, shindex) return true; case SHT_GROUP: - /* Make a section for objcopy and relocatable links. */ + /* We need a BFD section for objcopy and relocatable linking, + and it's handy to have the signature available as the section + name. */ + name = group_signature (abfd, hdr); + if (name == NULL) + return false; if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name)) return false; if (hdr->contents != NULL) @@ -1813,6 +2020,10 @@ bfd_section_from_shdr (abfd, shindex) unsigned int n_elt = hdr->sh_size / 4; asection *s; + if (idx->flags & GRP_COMDAT) + hdr->bfd_section->flags + |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; + while (--n_elt != 0) if ((s = (++idx)->shdr->bfd_section) != NULL && elf_next_in_group (s) != NULL) @@ -1845,50 +2056,19 @@ bfd_section_from_r_symndx (abfd, cache, sec, r_symndx) asection *sec; unsigned long r_symndx; { - unsigned char esym_shndx[4]; - unsigned int isym_shndx; Elf_Internal_Shdr *symtab_hdr; - file_ptr pos; - bfd_size_type amt; + unsigned char esym[sizeof (Elf64_External_Sym)]; + Elf_External_Sym_Shndx eshndx; + Elf_Internal_Sym isym; unsigned int ent = r_symndx % LOCAL_SYM_CACHE_SIZE; if (cache->abfd == abfd && cache->indx[ent] == r_symndx) return cache->sec[ent]; symtab_hdr = &elf_tdata (abfd)->symtab_hdr; - pos = symtab_hdr->sh_offset; - if (get_elf_backend_data (abfd)->s->sizeof_sym - == sizeof (Elf64_External_Sym)) - { - pos += r_symndx * sizeof (Elf64_External_Sym); - pos += offsetof (Elf64_External_Sym, st_shndx); - amt = sizeof (((Elf64_External_Sym *) 0)->st_shndx); - } - else - { - pos += r_symndx * sizeof (Elf32_External_Sym); - pos += offsetof (Elf32_External_Sym, st_shndx); - amt = sizeof (((Elf32_External_Sym *) 0)->st_shndx); - } - if (bfd_seek (abfd, pos, SEEK_SET) != 0 - || bfd_bread ((PTR) esym_shndx, amt, abfd) != amt) + if (bfd_elf_get_elf_syms (abfd, symtab_hdr, 1, r_symndx, + &isym, esym, &eshndx) == NULL) return NULL; - isym_shndx = H_GET_16 (abfd, esym_shndx); - - if (isym_shndx == SHN_XINDEX) - { - Elf_Internal_Shdr *shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; - if (shndx_hdr->sh_size != 0) - { - pos = shndx_hdr->sh_offset; - pos += r_symndx * sizeof (Elf_External_Sym_Shndx); - amt = sizeof (Elf_External_Sym_Shndx); - if (bfd_seek (abfd, pos, SEEK_SET) != 0 - || bfd_bread ((PTR) esym_shndx, amt, abfd) != amt) - return NULL; - isym_shndx = H_GET_32 (abfd, esym_shndx); - } - } if (cache->abfd != abfd) { @@ -1897,10 +2077,10 @@ bfd_section_from_r_symndx (abfd, cache, sec, r_symndx) } cache->indx[ent] = r_symndx; cache->sec[ent] = sec; - if (isym_shndx < SHN_LORESERVE || isym_shndx > SHN_HIRESERVE) + if (isym.st_shndx < SHN_LORESERVE || isym.st_shndx > SHN_HIRESERVE) { asection *s; - s = bfd_section_from_elf_index (abfd, isym_shndx); + s = bfd_section_from_elf_index (abfd, isym.st_shndx); if (s != NULL) cache->sec[ent] = s; } @@ -1972,16 +2152,18 @@ _bfd_elf_make_section_from_phdr (abfd, hdr, index, typename) asection *newsect; char *name; char namebuf[64]; + size_t len; int split; split = ((hdr->p_memsz > 0) && (hdr->p_filesz > 0) && (hdr->p_memsz > hdr->p_filesz)); sprintf (namebuf, "%s%d%s", typename, index, split ? "a" : ""); - name = bfd_alloc (abfd, (bfd_size_type) strlen (namebuf) + 1); + len = strlen (namebuf) + 1; + name = bfd_alloc (abfd, (bfd_size_type) len); if (!name) return false; - strcpy (name, namebuf); + memcpy (name, namebuf, len); newsect = bfd_make_section (abfd, name); if (newsect == NULL) return false; @@ -2009,10 +2191,11 @@ _bfd_elf_make_section_from_phdr (abfd, hdr, index, typename) if (split) { sprintf (namebuf, "%s%db", typename, index); - name = bfd_alloc (abfd, (bfd_size_type) strlen (namebuf) + 1); + len = strlen (namebuf) + 1; + name = bfd_alloc (abfd, (bfd_size_type) len); if (!name) return false; - strcpy (name, namebuf); + memcpy (name, namebuf, len); newsect = bfd_make_section (abfd, name); if (newsect == NULL) return false; @@ -2259,8 +2442,23 @@ elf_fake_sections (abfd, asect, failedptrarg) if ((asect->flags & SEC_STRINGS) != 0) this_hdr->sh_flags |= SHF_STRINGS; } - if (elf_group_name (asect) != NULL) + if ((asect->flags & SEC_GROUP) == 0 && elf_group_name (asect) != NULL) this_hdr->sh_flags |= SHF_GROUP; + if ((asect->flags & SEC_THREAD_LOCAL) != 0) + { + this_hdr->sh_flags |= SHF_TLS; + if (asect->_raw_size == 0 && (asect->flags & SEC_HAS_CONTENTS) == 0) + { + struct bfd_link_order *o; + + this_hdr->sh_size = 0; + for (o = asect->link_order_head; o != NULL; o = o->next) + if (this_hdr->sh_size < o->offset + o->size) + this_hdr->sh_size = o->offset + o->size; + if (this_hdr->sh_size) + this_hdr->sh_type = SHT_NOBITS; + } + } /* Check for processor-specific section types. */ if (bed->elf_backend_fake_sections @@ -2281,35 +2479,47 @@ elf_fake_sections (abfd, asect, failedptrarg) /* Fill in the contents of a SHT_GROUP section. */ -static void -set_group_contents (abfd, sec, failedptrarg) +void +bfd_elf_set_group_contents (abfd, sec, failedptrarg) bfd *abfd; asection *sec; - PTR failedptrarg ATTRIBUTE_UNUSED; + PTR failedptrarg; { boolean *failedptr = (boolean *) failedptrarg; unsigned long symindx; - asection *elt; + asection *elt, *first; unsigned char *loc; struct bfd_link_order *l; + boolean gas; if (elf_section_data (sec)->this_hdr.sh_type != SHT_GROUP || *failedptr) return; - /* If called from the assembler, swap_out_syms will have set up - elf_section_syms; If called for "ld -r", the symbols won't yet - be mapped, so emulate elf_bfd_final_link. */ - if (elf_section_syms (abfd) != NULL) - symindx = elf_section_syms (abfd)[sec->index]->udata.i; - else - symindx = elf_section_data (sec)->this_idx; + symindx = 0; + if (elf_group_id (sec) != NULL) + symindx = elf_group_id (sec)->udata.i; + + if (symindx == 0) + { + /* If called from the assembler, swap_out_syms will have set up + elf_section_syms; If called for "ld -r", use target_index. */ + if (elf_section_syms (abfd) != NULL) + symindx = elf_section_syms (abfd)[sec->index]->udata.i; + else + symindx = sec->target_index; + } elf_section_data (sec)->this_hdr.sh_info = symindx; - /* Nor will the contents be allocated for "ld -r". */ + /* The contents won't be allocated for "ld -r" or objcopy. */ + gas = true; if (sec->contents == NULL) { + gas = false; sec->contents = bfd_alloc (abfd, sec->_raw_size); + + /* Arrange for the section to be written out. */ + elf_section_data (sec)->this_hdr.contents = sec->contents; if (sec->contents == NULL) { *failedptr = true; @@ -2319,9 +2529,10 @@ set_group_contents (abfd, sec, failedptrarg) loc = sec->contents + sec->_raw_size; - /* Get the pointer to the first section in the group that we - squirreled away here. */ - elt = elf_next_in_group (sec); + /* Get the pointer to the first section in the group that gas + squirreled away here. objcopy arranges for this to be set to the + start of the input section group. */ + first = elt = elf_next_in_group (sec); /* First element is a flag word. Rest of section is elf section indices for all the sections of the group. Write them backwards @@ -2329,9 +2540,20 @@ set_group_contents (abfd, sec, failedptrarg) directives, not that it matters. */ while (elt != NULL) { + asection *s; + unsigned int idx; + loc -= 4; - H_PUT_32 (abfd, elf_section_data (elt)->this_idx, loc); + s = elt; + if (!gas) + s = s->output_section; + idx = 0; + if (s != NULL) + idx = elf_section_data (s)->this_idx; + H_PUT_32 (abfd, idx, loc); elt = elf_next_in_group (elt); + if (elt == first) + break; } /* If this is a relocatable link, then the above did nothing because @@ -2350,10 +2572,16 @@ set_group_contents (abfd, sec, failedptrarg) } while (elt != elf_next_in_group (l->u.indirect.section)); - loc -= 4; - H_PUT_32 (abfd, 0, loc); + /* With ld -r, merging SHT_GROUP sections results in wasted space + due to allowing for the flag word on each input. We may well + duplicate entries too. */ + while ((loc -= 4) > sec->contents) + H_PUT_32 (abfd, 0, loc); + + if (loc != sec->contents) + abort (); - BFD_ASSERT (loc == sec->contents); + H_PUT_32 (abfd, sec->flags & SEC_LINK_ONCE ? GRP_COMDAT : 0, loc); } /* Assign all ELF section numbers. The dummy first section is handled here @@ -2535,10 +2763,10 @@ assign_section_numbers (abfd) char *alc; len = strlen (sec->name); - alc = (char *) bfd_malloc ((bfd_size_type) len - 2); + alc = (char *) bfd_malloc ((bfd_size_type) (len - 2)); if (alc == NULL) return false; - strncpy (alc, sec->name, len - 3); + memcpy (alc, sec->name, len - 3); alc[len - 3] = '\0'; s = bfd_get_section_by_name (abfd, alc); free (alc); @@ -2547,8 +2775,9 @@ assign_section_numbers (abfd) elf_section_data (s)->this_hdr.sh_link = d->this_idx; /* This is a .stab section. */ - elf_section_data (s)->this_hdr.sh_entsize = - 4 + 2 * bfd_get_arch_size (abfd) / 8; + if (elf_section_data (s)->this_hdr.sh_entsize == 0) + elf_section_data (s)->this_hdr.sh_entsize + = 4 + 2 * bfd_get_arch_size (abfd) / 8; } } break; @@ -2834,9 +3063,9 @@ _bfd_elf_compute_section_file_positions (abfd, link_info) return false; } - if (link_info == NULL || link_info->relocateable) + if (link_info == NULL) { - bfd_map_over_sections (abfd, set_group_contents, &failed); + bfd_map_over_sections (abfd, bfd_elf_set_group_contents, &failed); if (failed) return false; } @@ -2943,6 +3172,8 @@ map_sections_to_segments (abfd) asection **hdrpp; boolean phdr_in_segment = true; boolean writable; + int tls_count = 0; + asection *first_tls = NULL; asection *dynsec, *eh_frame_hdr; bfd_size_type amt; @@ -3086,8 +3317,9 @@ map_sections_to_segments (abfd) } else if (! writable && (hdr->flags & SEC_READONLY) == 0 - && (BFD_ALIGN (last_hdr->lma + last_hdr->_raw_size, maxpagesize) - == hdr->lma)) + && (((last_hdr->lma + last_hdr->_raw_size - 1) + & ~(maxpagesize - 1)) + != (hdr->lma & ~(maxpagesize - 1)))) { /* We don't want to put a writable section in a read only segment, unless they are on the same page in memory @@ -3181,6 +3413,39 @@ map_sections_to_segments (abfd) *pm = m; pm = &m->next; } + if (s->flags & SEC_THREAD_LOCAL) + { + if (! tls_count) + first_tls = s; + tls_count++; + } + } + + /* If there are any SHF_TLS output sections, add PT_TLS segment. */ + if (tls_count > 0) + { + int i; + + amt = sizeof (struct elf_segment_map); + amt += (tls_count - 1) * sizeof (asection *); + m = (struct elf_segment_map *) bfd_zalloc (abfd, amt); + if (m == NULL) + goto error_return; + m->next = NULL; + m->p_type = PT_TLS; + m->count = tls_count; + /* Mandated PF_R. */ + m->p_flags = PF_R; + m->p_flags_valid = 1; + for (i = 0; i < tls_count; ++i) + { + BFD_ASSERT (first_tls->flags & SEC_THREAD_LOCAL); + m->sections[i] = first_tls; + first_tls = first_tls->next; + } + + *pm = m; + pm = &m->next; } /* If there is a .eh_frame_hdr section, throw in a PT_GNU_EH_FRAME @@ -3295,6 +3560,37 @@ assign_file_positions_for_segments (abfd) if (! map_sections_to_segments (abfd)) return false; } + else + { + /* The placement algorithm assumes that non allocated sections are + not in PT_LOAD segments. We ensure this here by removing such + sections from the segment map. */ + for (m = elf_tdata (abfd)->segment_map; + m != NULL; + m = m->next) + { + unsigned int new_count; + unsigned int i; + + if (m->p_type != PT_LOAD) + continue; + + new_count = 0; + for (i = 0; i < m->count; i ++) + { + if ((m->sections[i]->flags & SEC_ALLOC) != 0) + { + if (i != new_count) + m->sections[new_count] = m->sections[i]; + + new_count ++; + } + } + + if (new_count != m->count) + m->count = new_count; + } + } if (bed->elf_backend_modify_segment_map) { @@ -3350,12 +3646,12 @@ assign_file_positions_for_segments (abfd) asection **secpp; /* If elf_segment_map is not from map_sections_to_segments, the - sections may not be correctly ordered. NOTE: sorting should + sections may not be correctly ordered. NOTE: sorting should not be done to the PT_NOTE section of a corefile, which may contain several pseudo-sections artificially created by bfd. Sorting these pseudo-sections breaks things badly. */ - if (m->count > 1 - && !(elf_elfheader (abfd)->e_type == ET_CORE + if (m->count > 1 + && !(elf_elfheader (abfd)->e_type == ET_CORE && m->p_type == PT_NOTE)) qsort (m->sections, (size_t) m->count, sizeof (asection *), elf_sort_sections); @@ -3424,8 +3720,9 @@ assign_file_positions_for_segments (abfd) if (p->p_vaddr < (bfd_vma) off) { - _bfd_error_handler (_("%s: Not enough room for program headers, try linking with -N"), - bfd_get_filename (abfd)); + (*_bfd_error_handler) + (_("%s: Not enough room for program headers, try linking with -N"), + bfd_get_filename (abfd)); bfd_set_error (bfd_error_bad_value); return false; } @@ -3605,6 +3902,20 @@ Error: First section in segment (%s) starts at 0x%x whereas the segment starts a if ((flags & SEC_LOAD) != 0) p->p_filesz += sec->_raw_size; + if (p->p_type == PT_TLS + && sec->_raw_size == 0 + && (sec->flags & SEC_HAS_CONTENTS) == 0) + { + struct bfd_link_order *o; + bfd_vma tbss_size = 0; + + for (o = sec->link_order_head; o != NULL; o = o->next) + if (tbss_size < o->offset + o->size) + tbss_size = o->offset + o->size; + + p->p_memsz += tbss_size; + } + if (align > p->p_align && (p->p_type != PT_LOAD || (abfd->flags & D_PAGED) == 0)) p->p_align = align; @@ -3649,6 +3960,11 @@ Error: First section in segment (%s) starts at 0x%x whereas the segment starts a } } + /* If additional nonloadable filepos adjustments are required, + do them now. */ + if (bed->set_nonloadable_filepos) + (*bed->set_nonloadable_filepos) (abfd, phdrs); + /* Clear out any program headers we allocated but did not use. */ for (; count < alloc; count++, p++) { @@ -3739,6 +4055,16 @@ get_program_header_size (abfd) } } + for (s = abfd->sections; s != NULL; s = s->next) + { + if (s->flags & SEC_THREAD_LOCAL) + { + /* We need a PT_TLS segment. */ + ++segs; + break; + } + } + /* Let the backend count up any program headers it might need. */ if (bed->elf_backend_additional_program_headers) { @@ -4197,6 +4523,7 @@ copy_private_bfd_data (ibfd, obfd) bfd_vma maxpagesize; struct elf_segment_map * phdr_adjust_seg = NULL; unsigned int phdr_adjust_num = 0; + struct elf_backend_data * bed; if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour || bfd_get_flavour (obfd) != bfd_target_elf_flavour) @@ -4205,6 +4532,7 @@ copy_private_bfd_data (ibfd, obfd) if (elf_tdata (ibfd)->phdr == NULL) return true; + bed = get_elf_backend_data (ibfd); iehdr = elf_elfheader (ibfd); map_first = NULL; @@ -4214,44 +4542,53 @@ copy_private_bfd_data (ibfd, obfd) maxpagesize = get_elf_backend_data (obfd)->maxpagesize; /* Returns the end address of the segment + 1. */ -#define SEGMENT_END(segment, start) \ - (start + (segment->p_memsz > segment->p_filesz \ - ? segment->p_memsz : segment->p_filesz)) +#define SEGMENT_END(segment, start) \ + (start + (segment->p_memsz > segment->p_filesz \ + ? segment->p_memsz : segment->p_filesz)) /* Returns true if the given section is contained within the given segment. VMA addresses are compared. */ -#define IS_CONTAINED_BY_VMA(section, segment) \ - (section->vma >= segment->p_vaddr \ - && (section->vma + section->_raw_size) \ - <= (SEGMENT_END (segment, segment->p_vaddr))) +#define IS_CONTAINED_BY_VMA(section, segment) \ + (section->vma >= segment->p_vaddr \ + && (section->vma + section->_raw_size \ + <= (SEGMENT_END (segment, segment->p_vaddr)))) /* Returns true if the given section is contained within the given segment. LMA addresses are compared. */ -#define IS_CONTAINED_BY_LMA(section, segment, base) \ - (section->lma >= base \ - && (section->lma + section->_raw_size) \ - <= SEGMENT_END (segment, base)) +#define IS_CONTAINED_BY_LMA(section, segment, base) \ + (section->lma >= base \ + && (section->lma + section->_raw_size \ + <= SEGMENT_END (segment, base))) + + /* Returns true if the given section is contained within the + given segment. Filepos addresses are compared in an elf + backend function. */ +#define IS_CONTAINED_BY_FILEPOS(sec, seg, bed) \ + (bed->is_contained_by_filepos \ + && (*bed->is_contained_by_filepos) (sec, seg)) /* Special case: corefile "NOTE" section containing regs, prpsinfo etc. */ -#define IS_COREFILE_NOTE(p, s) \ - (p->p_type == PT_NOTE \ - && bfd_get_format (ibfd) == bfd_core \ - && s->vma == 0 && s->lma == 0 \ - && (bfd_vma) s->filepos >= p->p_offset \ - && (bfd_vma) s->filepos + s->_raw_size \ - <= p->p_offset + p->p_filesz) +#define IS_COREFILE_NOTE(p, s) \ + (p->p_type == PT_NOTE \ + && bfd_get_format (ibfd) == bfd_core \ + && s->vma == 0 && s->lma == 0 \ + && (bfd_vma) s->filepos >= p->p_offset \ + && ((bfd_vma) s->filepos + s->_raw_size \ + <= p->p_offset + p->p_filesz)) /* The complicated case when p_vaddr is 0 is to handle the Solaris linker, which generates a PT_INTERP section with p_vaddr and p_memsz set to 0. */ -#define IS_SOLARIS_PT_INTERP(p, s) \ - ( p->p_vaddr == 0 \ - && p->p_filesz > 0 \ - && (s->flags & SEC_HAS_CONTENTS) != 0 \ - && s->_raw_size > 0 \ - && (bfd_vma) s->filepos >= p->p_offset \ - && ((bfd_vma) s->filepos + s->_raw_size \ - <= p->p_offset + p->p_filesz)) +#define IS_SOLARIS_PT_INTERP(p, s) \ + (p->p_vaddr == 0 \ + && p->p_paddr == 0 \ + && p->p_memsz == 0 \ + && p->p_filesz > 0 \ + && (s->flags & SEC_HAS_CONTENTS) != 0 \ + && s->_raw_size > 0 \ + && (bfd_vma) s->filepos >= p->p_offset \ + && ((bfd_vma) s->filepos + s->_raw_size \ + <= p->p_offset + p->p_filesz)) /* Decide if the given section should be included in the given segment. A section will be included if: @@ -4260,23 +4597,25 @@ copy_private_bfd_data (ibfd, obfd) 2. It is an allocated segment, 3. There is an output section associated with it, 4. The section has not already been allocated to a previous segment. */ -#define INCLUDE_SECTION_IN_SEGMENT(section, segment) \ - (((((segment->p_paddr \ - ? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \ - : IS_CONTAINED_BY_VMA (section, segment)) \ - || IS_SOLARIS_PT_INTERP (segment, section)) \ +#define INCLUDE_SECTION_IN_SEGMENT(section, segment, bed) \ + ((((segment->p_paddr \ + ? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \ + : IS_CONTAINED_BY_VMA (section, segment)) \ && (section->flags & SEC_ALLOC) != 0) \ - || IS_COREFILE_NOTE (segment, section)) \ + || IS_COREFILE_NOTE (segment, section) \ + || (IS_CONTAINED_BY_FILEPOS (section, segment, bed) \ + && (section->flags & SEC_ALLOC) == 0)) \ && section->output_section != NULL \ - && section->segment_mark == false) + && ! section->segment_mark) /* Returns true iff seg1 starts after the end of seg2. */ -#define SEGMENT_AFTER_SEGMENT(seg1, seg2) \ - (seg1->p_vaddr >= SEGMENT_END (seg2, seg2->p_vaddr)) +#define SEGMENT_AFTER_SEGMENT(seg1, seg2) \ + (seg1->p_vaddr >= SEGMENT_END (seg2, seg2->p_vaddr)) /* Returns true iff seg1 and seg2 overlap. */ -#define SEGMENT_OVERLAPS(seg1, seg2) \ - (!(SEGMENT_AFTER_SEGMENT (seg1, seg2) || SEGMENT_AFTER_SEGMENT (seg2, seg1))) +#define SEGMENT_OVERLAPS(seg1, seg2) \ + (!(SEGMENT_AFTER_SEGMENT (seg1, seg2) \ + || SEGMENT_AFTER_SEGMENT (seg2, seg1))) /* Initialise the segment mark field. */ for (section = ibfd->sections; section != NULL; section = section->next) @@ -4285,7 +4624,7 @@ copy_private_bfd_data (ibfd, obfd) /* Scan through the segments specified in the program header of the input BFD. For this first scan we look for overlaps in the loadable segments. These can be created by weird - parameters to objcopy. */ + parameters to objcopy. Also, fix some solaris weirdness. */ for (i = 0, segment = elf_tdata (ibfd)->phdr; i < num_segments; i++, segment++) @@ -4293,6 +4632,16 @@ copy_private_bfd_data (ibfd, obfd) unsigned int j; Elf_Internal_Phdr *segment2; + if (segment->p_type == PT_INTERP) + for (section = ibfd->sections; section; section = section->next) + if (IS_SOLARIS_PT_INTERP (segment, section)) + { + /* Mininal change so that the normal section to segment + assigment code will work. */ + segment->p_vaddr = section->vma; + break; + } + if (segment->p_type != PT_LOAD) continue; @@ -4366,7 +4715,7 @@ copy_private_bfd_data (ibfd, obfd) /* Compute how many sections might be placed into this segment. */ section_count = 0; for (section = ibfd->sections; section != NULL; section = section->next) - if (INCLUDE_SECTION_IN_SEGMENT (section, segment)) + if (INCLUDE_SECTION_IN_SEGMENT (section, segment, bed)) ++section_count; /* Allocate a segment map big enough to contain all of the @@ -4409,11 +4758,12 @@ copy_private_bfd_data (ibfd, obfd) { /* Special segments, such as the PT_PHDR segment, may contain no sections, but ordinary, loadable segments should contain - something. */ + something. They are allowed by the ELF spec however, so only + a warning is produced. */ if (segment->p_type == PT_LOAD) - _bfd_error_handler - (_("%s: warning: Empty loadable segment detected\n"), - bfd_archive_filename (ibfd)); + (*_bfd_error_handler) + (_("%s: warning: Empty loadable segment detected, is this intentional ?\n"), + bfd_archive_filename (ibfd)); map->count = 0; *pointer_to_map = map; @@ -4450,7 +4800,9 @@ copy_private_bfd_data (ibfd, obfd) pointers that we are interested in. As these sections get assigned to a segment, they are removed from this array. */ - amt = (bfd_size_type) section_count * sizeof (asection *); + /* Gcc 2.96 miscompiles this code on mips. Don't do casting here + to work around this long long bug. */ + amt = section_count * sizeof (asection *); sections = (asection **) bfd_malloc (amt); if (sections == NULL) return false; @@ -4469,7 +4821,7 @@ copy_private_bfd_data (ibfd, obfd) section != NULL; section = section->next) { - if (INCLUDE_SECTION_IN_SEGMENT (section, segment)) + if (INCLUDE_SECTION_IN_SEGMENT (section, segment, bed)) { output_section = section->output_section; @@ -4477,9 +4829,11 @@ copy_private_bfd_data (ibfd, obfd) /* The Solaris native linker always sets p_paddr to 0. We try to catch that case here, and set it to the - correct value. */ + correct value. Note - some backends require that + p_paddr be left as zero. */ if (segment->p_paddr == 0 && segment->p_vaddr != 0 + && (! bed->want_p_paddr_set_to_zero) && isec == 0 && output_section->lma != 0 && (output_section->vma == (segment->p_vaddr @@ -4495,7 +4849,11 @@ copy_private_bfd_data (ibfd, obfd) /* Match up the physical address of the segment with the LMA address of the output section. */ if (IS_CONTAINED_BY_LMA (output_section, segment, map->p_paddr) - || IS_COREFILE_NOTE (segment, section)) + || IS_CONTAINED_BY_FILEPOS (section, segment, bed) + || IS_COREFILE_NOTE (segment, section) + || (bed->want_p_paddr_set_to_zero && + IS_CONTAINED_BY_VMA (output_section, segment)) + ) { if (matching_lma == 0) matching_lma = output_section->lma; @@ -4564,7 +4922,7 @@ copy_private_bfd_data (ibfd, obfd) } /* Step Three: Loop over the sections again, this time assigning - those that fit to the current segment and remvoing them from the + those that fit to the current segment and removing them from the sections array; but making sure not to leave large gaps. Once all possible sections have been assigned to the current segment it is added to the list of built segments and if sections still remain @@ -4615,7 +4973,7 @@ copy_private_bfd_data (ibfd, obfd) maxpagesize then we need to start a new segment. */ if ((BFD_ALIGN (prev_sec->lma + prev_sec->_raw_size, maxpagesize) - < BFD_ALIGN (output_section->lma, maxpagesize)) + < BFD_ALIGN (output_section->lma, maxpagesize)) || ((prev_sec->lma + prev_sec->_raw_size) > output_section->lma)) { @@ -4728,6 +5086,7 @@ copy_private_bfd_data (ibfd, obfd) #undef SEGMENT_END #undef IS_CONTAINED_BY_VMA #undef IS_CONTAINED_BY_LMA +#undef IS_CONTAINED_BY_FILEPOS #undef IS_COREFILE_NOTE #undef IS_SOLARIS_PT_INTERP #undef INCLUDE_SECTION_IN_SEGMENT @@ -4747,6 +5106,7 @@ _bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec) asection *osec; { Elf_Internal_Shdr *ihdr, *ohdr; + const struct elf_backend_data *bed = get_elf_backend_data (ibfd); if (ibfd->xvec->flavour != bfd_target_elf_flavour || obfd->xvec->flavour != bfd_target_elf_flavour) @@ -4756,24 +5116,31 @@ _bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec) This must be done here, rather than in the copy_private_bfd_data entry point, because the latter is called after the section contents have been set, which means that the program headers have - already been worked out. */ - if (elf_tdata (obfd)->segment_map == NULL - && elf_tdata (ibfd)->phdr != NULL) + already been worked out. The backend function provides a way to + override the test conditions and code path for the call to + copy_private_bfd_data. */ + if (bed->copy_private_bfd_data_p) { - asection *s; + if ((*bed->copy_private_bfd_data_p) (ibfd, isec, obfd, osec)) + if (! copy_private_bfd_data (ibfd, obfd)) + return false; + } + else if (elf_tdata (obfd)->segment_map == NULL && elf_tdata (ibfd)->phdr != NULL) + { + asection *s; - /* Only set up the segments if there are no more SEC_ALLOC - sections. FIXME: This won't do the right thing if objcopy is - used to remove the last SEC_ALLOC section, since objcopy - won't call this routine in that case. */ - for (s = isec->next; s != NULL; s = s->next) - if ((s->flags & SEC_ALLOC) != 0) - break; - if (s == NULL) - { - if (! copy_private_bfd_data (ibfd, obfd)) - return false; - } + /* Only set up the segments if there are no more SEC_ALLOC + sections. FIXME: This won't do the right thing if objcopy is + used to remove the last SEC_ALLOC section, since objcopy + won't call this routine in that case. */ + for (s = isec->next; s != NULL; s = s->next) + if ((s->flags & SEC_ALLOC) != 0) + break; + if (s == NULL) + { + if (! copy_private_bfd_data (ibfd, obfd)) + return false; + } } ihdr = &elf_section_data (isec)->this_hdr; @@ -4787,6 +5154,12 @@ _bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec) || ihdr->sh_type == SHT_GNU_verdef) ohdr->sh_info = ihdr->sh_info; + /* Set things up for objcopy. The output SHT_GROUP section will + have its elf_next_in_group pointing back to the input group + members. */ + elf_next_in_group (osec) = elf_next_in_group (isec); + elf_group_name (osec) = elf_group_name (isec); + elf_section_data (osec)->use_rela_p = elf_section_data (isec)->use_rela_p; @@ -4895,10 +5268,9 @@ swap_out_syms (abfd, sttp, relocatable_p) if (symtab_shndx_hdr->sh_name != 0) { amt = (bfd_size_type) (1 + symcount) * sizeof (Elf_External_Sym_Shndx); - outbound_shndx = bfd_alloc (abfd, amt); + outbound_shndx = bfd_zalloc (abfd, amt); if (outbound_shndx == NULL) return false; - memset (outbound_shndx, 0, (unsigned long) amt); symtab_shndx_hdr->contents = outbound_shndx; symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX; symtab_shndx_hdr->sh_size = amt; @@ -5032,13 +5404,18 @@ swap_out_syms (abfd, sttp, relocatable_p) sym.st_shndx = shndx; } - if ((flags & BSF_FUNCTION) != 0) + if ((flags & BSF_THREAD_LOCAL) != 0) + type = STT_TLS; + else if ((flags & BSF_FUNCTION) != 0) type = STT_FUNC; else if ((flags & BSF_OBJECT) != 0) type = STT_OBJECT; else type = STT_NOTYPE; + if (syms[idx]->section->flags & SEC_THREAD_LOCAL) + type = STT_TLS; + /* Processor-specific types */ if (type_ptr != NULL && bed->elf_backend_get_symbol_type) @@ -5196,7 +5573,11 @@ _bfd_elf_canonicalize_dynamic_symtab (abfd, alocation) asymbol **alocation; { struct elf_backend_data *bed = get_elf_backend_data (abfd); - return bed->s->slurp_symbol_table (abfd, alocation, true); + long symcount = bed->s->slurp_symbol_table (abfd, alocation, true); + + if (symcount >= 0) + bfd_get_dynamic_symcount (abfd) = symcount; + return symcount; } /* Return the size required for the dynamic reloc entries. Any @@ -5665,7 +6046,7 @@ _bfd_elf_find_nearest_line (abfd, section, symbols, offset, functionname_ptr, line_ptr, &elf_tdata (abfd)->line_info)) return false; - if (found) + if (found && (*functionname_ptr || *line_ptr)) return true; if (symbols == NULL) @@ -5704,8 +6085,8 @@ _bfd_elf_set_section_contents (abfd, section, location, offset, count) bfd_signed_vma pos; if (! abfd->output_has_begun - && ! _bfd_elf_compute_section_file_positions - (abfd, (struct bfd_link_info *) NULL)) + && ! (_bfd_elf_compute_section_file_positions + (abfd, (struct bfd_link_info *) NULL))) return false; hdr = &elf_section_data (section)->this_hdr; @@ -5928,15 +6309,17 @@ _bfd_elfcore_make_pseudosection (abfd, name, size, filepos) { char buf[100]; char *threaded_name; + size_t len; asection *sect; /* Build the section name. */ sprintf (buf, "%s/%d", name, elfcore_make_pid (abfd)); - threaded_name = bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1); + len = strlen (buf) + 1; + threaded_name = bfd_alloc (abfd, (bfd_size_type) len); if (threaded_name == NULL) return false; - strcpy (threaded_name, buf); + memcpy (threaded_name, buf, len); sect = bfd_make_section (abfd, threaded_name); if (sect == NULL) @@ -6221,6 +6604,7 @@ elfcore_grok_lwpstatus (abfd, note) lwpstatus_t lwpstat; char buf[100]; char *name; + size_t len; asection *sect; if (note->descsz != sizeof (lwpstat) @@ -6238,10 +6622,11 @@ elfcore_grok_lwpstatus (abfd, note) /* Make a ".reg/999" section. */ sprintf (buf, ".reg/%d", elfcore_make_pid (abfd)); - name = bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1); + len = strlen (buf) + 1; + name = bfd_alloc (abfd, (bfd_size_type) len); if (name == NULL) return false; - strcpy (name, buf); + memcpy (name, buf, len); sect = bfd_make_section (abfd, name); if (sect == NULL) @@ -6267,10 +6652,11 @@ elfcore_grok_lwpstatus (abfd, note) /* Make a ".reg2/999" section */ sprintf (buf, ".reg2/%d", elfcore_make_pid (abfd)); - name = bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1); + len = strlen (buf) + 1; + name = bfd_alloc (abfd, (bfd_size_type) len); if (name == NULL) return false; - strcpy (name, buf); + memcpy (name, buf, len); sect = bfd_make_section (abfd, name); if (sect == NULL) @@ -6302,6 +6688,7 @@ elfcore_grok_win32pstatus (abfd, note) { char buf[30]; char *name; + size_t len; asection *sect; win32_pstatus_t pstatus; @@ -6322,11 +6709,12 @@ elfcore_grok_win32pstatus (abfd, note) /* Make a ".reg/999" section. */ sprintf (buf, ".reg/%d", pstatus.data.thread_info.tid); - name = bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1); + len = strlen (buf) + 1; + name = bfd_alloc (abfd, (bfd_size_type) len); if (name == NULL) return false; - strcpy (name, buf); + memcpy (name, buf, len); sect = bfd_make_section (abfd, name); if (sect == NULL) @@ -6348,11 +6736,12 @@ elfcore_grok_win32pstatus (abfd, note) /* Make a ".module/xxxxxxxx" section. */ sprintf (buf, ".module/%08x", pstatus.data.module_info.base_address); - name = bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1); + len = strlen (buf) + 1; + name = bfd_alloc (abfd, (bfd_size_type) len); if (name == NULL) return false; - strcpy (name, buf); + memcpy (name, buf, len); sect = bfd_make_section (abfd, name); @@ -6486,7 +6875,7 @@ elfcore_grok_netbsd_note (abfd, note) find this note before any of the others, which is fine, since the kernel writes this note out first when it creates a core file. */ - + return elfcore_grok_netbsd_procinfo (abfd, note); } @@ -6494,7 +6883,7 @@ elfcore_grok_netbsd_note (abfd, note) defined for NetBSD core files. If the note type is less than the start of the machine-dependent note types, we don't understand it. */ - + if (note->type < NT_NETBSDCORE_FIRSTMACH) return true; @@ -6539,7 +6928,7 @@ elfcore_grok_netbsd_note (abfd, note) /* Function: elfcore_write_note - Inputs: + Inputs: buffer to hold note name of note type of note @@ -6554,16 +6943,30 @@ elfcore_write_note (abfd, buf, bufsiz, name, type, input, size) bfd *abfd; char *buf; int *bufsiz; - char *name; + const char *name; int type; - void *input; + const PTR input; int size; { Elf_External_Note *xnp; - int namesz = strlen (name); - int newspace = BFD_ALIGN (sizeof (Elf_External_Note) + size + namesz - 1, 4); + size_t namesz; + size_t pad; + size_t newspace; char *p, *dest; + namesz = 0; + pad = 0; + if (name != NULL) + { + struct elf_backend_data *bed; + + namesz = strlen (name) + 1; + bed = get_elf_backend_data (abfd); + pad = -namesz & (bed->s->file_align - 1); + } + + newspace = sizeof (Elf_External_Note) - 1 + namesz + pad + size; + p = realloc (buf, *bufsiz + newspace); dest = p + *bufsiz; *bufsiz += newspace; @@ -6571,8 +6974,18 @@ elfcore_write_note (abfd, buf, bufsiz, name, type, input, size) H_PUT_32 (abfd, namesz, xnp->namesz); H_PUT_32 (abfd, size, xnp->descsz); H_PUT_32 (abfd, type, xnp->type); - strcpy (xnp->name, name); - memcpy (xnp->name + BFD_ALIGN (namesz, 4), input, size); + dest = xnp->name; + if (name != NULL) + { + memcpy (dest, name, namesz); + dest += namesz; + while (pad != 0) + { + *dest++ = '\0'; + --pad; + } + } + memcpy (dest, input, size); return p; } @@ -6582,8 +6995,8 @@ elfcore_write_prpsinfo (abfd, buf, bufsiz, fname, psargs) bfd *abfd; char *buf; int *bufsiz; - char *fname; - char *psargs; + const char *fname; + const char *psargs; { int note_type; char *note_name = "CORE"; @@ -6599,7 +7012,7 @@ elfcore_write_prpsinfo (abfd, buf, bufsiz, fname, psargs) memset (&data, 0, sizeof (data)); strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); - return elfcore_write_note (abfd, buf, bufsiz, + return elfcore_write_note (abfd, buf, bufsiz, note_name, note_type, &data, sizeof (data)); } #endif /* PSINFO_T or PRPSINFO_T */ @@ -6612,7 +7025,7 @@ elfcore_write_prstatus (abfd, buf, bufsiz, pid, cursig, gregs) int *bufsiz; long pid; int cursig; - void *gregs; + const PTR gregs; { prstatus_t prstat; char *note_name = "CORE"; @@ -6621,7 +7034,7 @@ elfcore_write_prstatus (abfd, buf, bufsiz, pid, cursig, gregs) prstat.pr_pid = pid; prstat.pr_cursig = cursig; memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg)); - return elfcore_write_note (abfd, buf, bufsiz, + return elfcore_write_note (abfd, buf, bufsiz, note_name, NT_PRSTATUS, &prstat, sizeof (prstat)); } #endif /* HAVE_PRSTATUS_T */ @@ -6634,7 +7047,7 @@ elfcore_write_lwpstatus (abfd, buf, bufsiz, pid, cursig, gregs) int *bufsiz; long pid; int cursig; - void *gregs; + const PTR gregs; { lwpstatus_t lwpstat; char *note_name = "CORE"; @@ -6653,7 +7066,7 @@ elfcore_write_lwpstatus (abfd, buf, bufsiz, pid, cursig, gregs) gregs, sizeof (lwpstat.pr_context.uc_mcontext.__gregs)); #endif #endif - return elfcore_write_note (abfd, buf, bufsiz, note_name, + return elfcore_write_note (abfd, buf, bufsiz, note_name, NT_LWPSTATUS, &lwpstat, sizeof (lwpstat)); } #endif /* HAVE_LWPSTATUS_T */ @@ -6666,14 +7079,14 @@ elfcore_write_pstatus (abfd, buf, bufsiz, pid, cursig, gregs) int *bufsiz; long pid; int cursig; - void *gregs; + const PTR gregs; { pstatus_t pstat; char *note_name = "CORE"; memset (&pstat, 0, sizeof (pstat)); pstat.pr_pid = pid & 0xffff; - buf = elfcore_write_note (abfd, buf, bufsiz, note_name, + buf = elfcore_write_note (abfd, buf, bufsiz, note_name, NT_PSTATUS, &pstat, sizeof (pstat)); return buf; } @@ -6684,11 +7097,11 @@ elfcore_write_prfpreg (abfd, buf, bufsiz, fpregs, size) bfd *abfd; char *buf; int *bufsiz; - void *fpregs; + const PTR fpregs; int size; { char *note_name = "CORE"; - return elfcore_write_note (abfd, buf, bufsiz, + return elfcore_write_note (abfd, buf, bufsiz, note_name, NT_FPREGSET, fpregs, size); } @@ -6697,11 +7110,11 @@ elfcore_write_prxfpreg (abfd, buf, bufsiz, xfpregs, size) bfd *abfd; char *buf; int *bufsiz; - void *xfpregs; + const PTR xfpregs; int size; { char *note_name = "LINUX"; - return elfcore_write_note (abfd, buf, bufsiz, + return elfcore_write_note (abfd, buf, bufsiz, note_name, NT_PRXFPREG, xfpregs, size); } @@ -6882,7 +7295,7 @@ _bfd_elf_reloc_type_class (rela) return reloc_class_normal; } -/* For RELA architectures, return what the relocation value for +/* For RELA architectures, return the relocation value for a relocation against a local symbol. */ bfd_vma @@ -6921,7 +7334,7 @@ _bfd_elf_rel_local_sym (abfd, sym, psec, addend) Elf_Internal_Sym *sym; asection **psec; bfd_vma addend; -{ +{ asection *sec = *psec; if (elf_section_data (sec)->sec_info_type != ELF_INFO_TYPE_MERGE) diff --git a/contrib/binutils/bfd/elf32-arc.c b/contrib/binutils/bfd/elf32-arc.c index ad7247a..ff5c5f4 100644 --- a/contrib/binutils/bfd/elf32-arc.c +++ b/contrib/binutils/bfd/elf32-arc.c @@ -235,7 +235,7 @@ arc_elf_b22_pcrel (abfd, reloc_entry, symbol, data, input_section, return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message); } - + #define TARGET_LITTLE_SYM bfd_elf32_littlearc_vec #define TARGET_LITTLE_NAME "elf32-littlearc" #define TARGET_BIG_SYM bfd_elf32_bigarc_vec diff --git a/contrib/binutils/bfd/elf32-arm.h b/contrib/binutils/bfd/elf32-arm.h index 7d02127..f41b843 100644 --- a/contrib/binutils/bfd/elf32-arm.h +++ b/contrib/binutils/bfd/elf32-arm.h @@ -58,7 +58,7 @@ static boolean elf32_arm_relocate_section PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); static asection * elf32_arm_gc_mark_hook - PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, + PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *)); static boolean elf32_arm_gc_sweep_hook PARAMS ((bfd *, struct bfd_link_info *, asection *, @@ -236,14 +236,14 @@ elf32_arm_link_hash_table_create (abfd) struct elf32_arm_link_hash_table *ret; bfd_size_type amt = sizeof (struct elf32_arm_link_hash_table); - ret = (struct elf32_arm_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct elf32_arm_link_hash_table *) bfd_malloc (amt); if (ret == (struct elf32_arm_link_hash_table *) NULL) return NULL; if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, elf32_arm_link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return NULL; } @@ -547,31 +547,22 @@ record_thumb_to_arm_glue (link_info, h) return; } -/* Select a BFD to be used to hold the sections used by the glue code. - This function is called from the linker scripts in ld/emultempl/ - {armelf/pe}.em */ +/* Add the glue sections to ABFD. This function is called from the + linker scripts in ld/emultempl/{armelf}.em. */ boolean -bfd_elf32_arm_get_bfd_for_interworking (abfd, info) +bfd_elf32_arm_add_glue_sections_to_bfd (abfd, info) bfd *abfd; struct bfd_link_info *info; { - struct elf32_arm_link_hash_table *globals; flagword flags; asection *sec; - /* If we are only performing a partial link do not bother - getting a bfd to hold the glue. */ + /* If we are only performing a partial + link do not bother adding the glue. */ if (info->relocateable) return true; - globals = elf32_arm_hash_table (info); - - BFD_ASSERT (globals != NULL); - - if (globals->bfd_of_glue_owner != NULL) - return true; - sec = bfd_get_section_by_name (abfd, ARM2THUMB_GLUE_SECTION_NAME); if (sec == NULL) @@ -609,6 +600,32 @@ bfd_elf32_arm_get_bfd_for_interworking (abfd, info) sec->gc_mark = 1; } + return true; +} + +/* Select a BFD to be used to hold the sections used by the glue code. + This function is called from the linker scripts in ld/emultempl/ + {armelf/pe}.em */ + +boolean +bfd_elf32_arm_get_bfd_for_interworking (abfd, info) + bfd *abfd; + struct bfd_link_info *info; +{ + struct elf32_arm_link_hash_table *globals; + + /* If we are only performing a partial link + do not bother getting a bfd to hold the glue. */ + if (info->relocateable) + return true; + + globals = elf32_arm_hash_table (info); + + BFD_ASSERT (globals != NULL); + + if (globals->bfd_of_glue_owner != NULL) + return true; + /* Save the bfd for later use. */ globals->bfd_of_glue_owner = abfd; @@ -622,12 +639,9 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge) int no_pipeline_knowledge; { Elf_Internal_Shdr *symtab_hdr; - Elf_Internal_Rela *free_relocs = NULL; + Elf_Internal_Rela *internal_relocs = NULL; Elf_Internal_Rela *irel, *irelend; bfd_byte *contents = NULL; - bfd_byte *free_contents = NULL; - Elf32_External_Sym *extsyms = NULL; - Elf32_External_Sym *free_extsyms = NULL; asection *sec; struct elf32_arm_link_hash_table *globals; @@ -660,13 +674,15 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge) symtab_hdr = &elf_tdata (abfd)->symtab_hdr; /* Load the relocs. */ - irel = (_bfd_elf32_link_read_relocs (abfd, sec, (PTR) NULL, - (Elf_Internal_Rela *) NULL, false)); + internal_relocs + = _bfd_elf32_link_read_relocs (abfd, sec, (PTR) NULL, + (Elf_Internal_Rela *) NULL, false); - BFD_ASSERT (irel != 0); + if (internal_relocs == NULL) + goto error_return; - irelend = irel + sec->reloc_count; - for (; irel < irelend; irel++) + irelend = internal_relocs + sec->reloc_count; + for (irel = internal_relocs; irel < irelend; irel++) { long r_type; unsigned long r_index; @@ -694,37 +710,12 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge) if (contents == NULL) goto error_return; - free_contents = contents; - if (!bfd_get_section_contents (abfd, sec, contents, (file_ptr) 0, sec->_raw_size)) goto error_return; } } - /* Read this BFD's symbols if we haven't done so already. */ - if (extsyms == NULL) - { - /* Get cached copy if it exists. */ - if (symtab_hdr->contents != NULL) - extsyms = (Elf32_External_Sym *) symtab_hdr->contents; - else - { - /* Go get them off disk. */ - extsyms = ((Elf32_External_Sym *) - bfd_malloc (symtab_hdr->sh_size)); - if (extsyms == NULL) - goto error_return; - - free_extsyms = extsyms; - - if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 - || (bfd_bread (extsyms, symtab_hdr->sh_size, abfd) - != symtab_hdr->sh_size)) - goto error_return; - } - } - /* If the relocation is not against a symbol it cannot concern us. */ h = NULL; @@ -764,17 +755,27 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge) break; } } + + if (contents != NULL + && elf_section_data (sec)->this_hdr.contents != contents) + free (contents); + contents = NULL; + + if (internal_relocs != NULL + && elf_section_data (sec)->relocs != internal_relocs) + free (internal_relocs); + internal_relocs = NULL; } return true; error_return: - if (free_relocs != NULL) - free (free_relocs); - if (free_contents != NULL) - free (free_contents); - if (free_extsyms != NULL) - free (free_extsyms); + if (contents != NULL + && elf_section_data (sec)->this_hdr.contents != contents) + free (contents); + if (internal_relocs != NULL + && elf_section_data (sec)->relocs != internal_relocs) + free (internal_relocs); return false; } @@ -1471,22 +1472,19 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) overflow = true; - /* Put RELOCATION back into the insn. */ - upper_insn = (upper_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 12) & 0x7ff); - lower_insn = (lower_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 1) & 0x7ff); - #ifndef OLD_ARM_ABI if (r_type == R_ARM_THM_XPC22 && ((lower_insn & 0x1800) == 0x0800)) - /* Remove bit zero of the adjusted offset. Bit zero can only be - set if the upper insn is at a half-word boundary, since the - destination address, an ARM instruction, must always be on a - word boundary. The semantics of the BLX (1) instruction, however, - are that bit zero in the offset must always be zero, and the - corresponding bit one in the target address will be set from bit - one of the source address. */ - lower_insn &= ~1; + /* For a BLX instruction, make sure that the relocation is rounded up + to a word boundary. This follows the semantics of the instruction + which specifies that bit 1 of the target address will come from bit + 1 of the base address. */ + relocation = (relocation + 2) & ~ 3; #endif + /* Put RELOCATION back into the insn. */ + upper_insn = (upper_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 12) & 0x7ff); + lower_insn = (lower_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 1) & 0x7ff); + /* Put the relocated value back in the object file: */ bfd_put_16 (input_bfd, upper_insn, hit_data); bfd_put_16 (input_bfd, lower_insn, hit_data + 2); @@ -1526,7 +1524,7 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, signed_check = check | ~((bfd_vma) -1 >> howto->rightshift); relocation |= (bfd_get_16 (input_bfd, hit_data) & (~ howto->dst_mask)); - + bfd_put_16 (input_bfd, relocation, hit_data); /* Assumes two's complement. */ @@ -1535,7 +1533,7 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, return bfd_reloc_ok; } - + case R_ARM_GNU_VTINHERIT: case R_ARM_GNU_VTENTRY: return bfd_reloc_ok; @@ -1560,7 +1558,7 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, if (sgot == NULL) return bfd_reloc_notsupported; - /* If we are addressing a Thumb function, we need to adjust the + /* If we are addressing a Thumb function, we need to adjust the address by one, so that attempts to call the function pointer will correctly interpret it as Thumb code. */ if (sym_flags == STT_ARM_TFUNC) @@ -2209,7 +2207,7 @@ elf32_arm_merge_private_bfd_data (ibfd, obfd) asection *sec; /* Check if we have the same endianess. */ - if (_bfd_generic_verify_endian_match (ibfd, obfd) == false) + if (! _bfd_generic_verify_endian_match (ibfd, obfd)) return false; if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour @@ -2360,7 +2358,7 @@ ERROR: %s uses hardware FP, whereas %s uses software FP"), _bfd_error_handler (_("\ Warning: %s supports interworking, whereas %s does not"), bfd_archive_filename (ibfd), - bfd_get_filename (obfd)); + bfd_get_filename (obfd)); } else { @@ -2515,8 +2513,8 @@ elf32_arm_get_symbol_type (elf_sym, type) } static asection * -elf32_arm_gc_mark_hook (abfd, info, rel, h, sym) - bfd *abfd; +elf32_arm_gc_mark_hook (sec, info, rel, h, sym) + asection *sec; struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; @@ -2546,9 +2544,7 @@ elf32_arm_gc_mark_hook (abfd, info, rel, h, sym) } } else - { - return bfd_section_from_elf_index (abfd, sym->st_shndx); - } + return bfd_section_from_elf_index (sec->owner, sym->st_shndx); return NULL; } @@ -2962,16 +2958,22 @@ elf32_arm_adjust_dynamic_symbol (info, h) if (h->type == STT_FUNC || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) { + /* If we link a program (not a DSO), we'll get rid of unnecessary + PLT entries; we point to the actual symbols -- even for pic + relocs, because a program built with -fpic should have the same + result as one built without -fpic, specifically considering weak + symbols. + FIXME: m68k and i386 differ here, for unclear reasons. */ if (! info->shared - && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0 - && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0) + && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0) { /* This case can occur if we saw a PLT32 reloc in an input - file, but the symbol was never referred to by a dynamic - object. In such a case, we don't actually need to build - a procedure linkage table, and we can just do a PC32 - reloc instead. */ + file, but the symbol was not defined by a dynamic object. + In such a case, we don't actually need to build a + procedure linkage table, and we can just do a PC32 reloc + instead. */ BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0); + h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; return true; } diff --git a/contrib/binutils/bfd/elf32-i386.c b/contrib/binutils/bfd/elf32-i386.c index d74f6ee..d52d5a7 100644 --- a/contrib/binutils/bfd/elf32-i386.c +++ b/contrib/binutils/bfd/elf32-i386.c @@ -45,12 +45,20 @@ static boolean create_got_section static boolean elf_i386_create_dynamic_sections PARAMS((bfd *, struct bfd_link_info *)); static void elf_i386_copy_indirect_symbol - PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *)); + PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *, + struct elf_link_hash_entry *)); +static int elf_i386_tls_transition + PARAMS ((struct bfd_link_info *, int, int)); + +static boolean elf_i386_mkobject + PARAMS((bfd *)); +static boolean elf_i386_object_p + PARAMS((bfd *)); static boolean elf_i386_check_relocs PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *)); static asection *elf_i386_gc_mark_hook - PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, + PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *)); static boolean elf_i386_gc_sweep_hook PARAMS ((bfd *, struct bfd_link_info *, asection *, @@ -65,6 +73,10 @@ static boolean elf_i386_fake_sections PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *)); static boolean elf_i386_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); +static bfd_vma dtpoff_base + PARAMS ((struct bfd_link_info *)); +static bfd_vma tpoff + PARAMS ((struct bfd_link_info *, bfd_vma)); static boolean elf_i386_relocate_section PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); @@ -121,9 +133,27 @@ static reloc_howto_type elf_howto_table[]= R_386_ext_offset is the value to subtract from a reloc type of R_386_16 thru R_386_PC8 to form an index into this table. */ #define R_386_standard ((unsigned int) R_386_GOTPC + 1) -#define R_386_ext_offset ((unsigned int) R_386_16 - R_386_standard) +#define R_386_ext_offset ((unsigned int) R_386_TLS_TPOFF - R_386_standard) - /* The remaining relocs are a GNU extension. */ + /* These relocs are a GNU extension. */ + HOWTO(R_386_TLS_TPOFF, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_TPOFF", + true, 0xffffffff, 0xffffffff, false), + HOWTO(R_386_TLS_IE, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_IE", + true, 0xffffffff, 0xffffffff, false), + HOWTO(R_386_TLS_GOTIE, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_GOTIE", + true, 0xffffffff, 0xffffffff, false), + HOWTO(R_386_TLS_LE, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_LE", + true, 0xffffffff, 0xffffffff, false), + HOWTO(R_386_TLS_GD, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_GD", + true, 0xffffffff, 0xffffffff, false), + HOWTO(R_386_TLS_LDM, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_LDM", + true, 0xffffffff, 0xffffffff, false), HOWTO(R_386_16, 0, 1, 16, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_386_16", true, 0xffff, 0xffff, false), @@ -137,9 +167,31 @@ static reloc_howto_type elf_howto_table[]= bfd_elf_generic_reloc, "R_386_PC8", true, 0xff, 0xff, true), - /* Another gap. */ #define R_386_ext ((unsigned int) R_386_PC8 + 1 - R_386_ext_offset) -#define R_386_vt_offset ((unsigned int) R_386_GNU_VTINHERIT - R_386_ext) +#define R_386_tls_offset ((unsigned int) R_386_TLS_LDO_32 - R_386_ext) + /* These are common with Solaris TLS implementation. */ + HOWTO(R_386_TLS_LDO_32, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_LDO_32", + true, 0xffffffff, 0xffffffff, false), + HOWTO(R_386_TLS_IE_32, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_IE_32", + true, 0xffffffff, 0xffffffff, false), + HOWTO(R_386_TLS_LE_32, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_LE_32", + true, 0xffffffff, 0xffffffff, false), + HOWTO(R_386_TLS_DTPMOD32, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_DTPMOD32", + true, 0xffffffff, 0xffffffff, false), + HOWTO(R_386_TLS_DTPOFF32, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_DTPOFF32", + true, 0xffffffff, 0xffffffff, false), + HOWTO(R_386_TLS_TPOFF32, 0, 2, 32, false, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_TLS_TPOFF32", + true, 0xffffffff, 0xffffffff, false), + + /* Another gap. */ +#define R_386_tls ((unsigned int) R_386_TLS_TPOFF32 + 1 - R_386_tls_offset) +#define R_386_vt_offset ((unsigned int) R_386_GNU_VTINHERIT - R_386_tls) /* GNU extension to record C++ vtable hierarchy. */ HOWTO (R_386_GNU_VTINHERIT, /* type */ @@ -154,7 +206,7 @@ static reloc_howto_type elf_howto_table[]= false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - false), + false), /* pcrel_offset */ /* GNU extension to record C++ vtable member usage. */ HOWTO (R_386_GNU_VTENTRY, /* type */ @@ -169,7 +221,7 @@ static reloc_howto_type elf_howto_table[]= false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - false) + false) /* pcrel_offset */ #define R_386_vt ((unsigned int) R_386_GNU_VTENTRY + 1 - R_386_vt_offset) @@ -236,7 +288,31 @@ elf_i386_reloc_type_lookup (abfd, code) TRACE ("BFD_RELOC_386_GOTPC"); return &elf_howto_table[(unsigned int) R_386_GOTPC ]; - /* The remaining relocs are a GNU extension. */ + /* These relocs are a GNU extension. */ + case BFD_RELOC_386_TLS_TPOFF: + TRACE ("BFD_RELOC_386_TLS_TPOFF"); + return &elf_howto_table[(unsigned int) R_386_TLS_TPOFF - R_386_ext_offset]; + + case BFD_RELOC_386_TLS_IE: + TRACE ("BFD_RELOC_386_TLS_IE"); + return &elf_howto_table[(unsigned int) R_386_TLS_IE - R_386_ext_offset]; + + case BFD_RELOC_386_TLS_GOTIE: + TRACE ("BFD_RELOC_386_TLS_GOTIE"); + return &elf_howto_table[(unsigned int) R_386_TLS_GOTIE - R_386_ext_offset]; + + case BFD_RELOC_386_TLS_LE: + TRACE ("BFD_RELOC_386_TLS_LE"); + return &elf_howto_table[(unsigned int) R_386_TLS_LE - R_386_ext_offset]; + + case BFD_RELOC_386_TLS_GD: + TRACE ("BFD_RELOC_386_TLS_GD"); + return &elf_howto_table[(unsigned int) R_386_TLS_GD - R_386_ext_offset]; + + case BFD_RELOC_386_TLS_LDM: + TRACE ("BFD_RELOC_386_TLS_LDM"); + return &elf_howto_table[(unsigned int) R_386_TLS_LDM - R_386_ext_offset]; + case BFD_RELOC_16: TRACE ("BFD_RELOC_16"); return &elf_howto_table[(unsigned int) R_386_16 - R_386_ext_offset]; @@ -253,6 +329,31 @@ elf_i386_reloc_type_lookup (abfd, code) TRACE ("BFD_RELOC_8_PCREL"); return &elf_howto_table[(unsigned int) R_386_PC8 - R_386_ext_offset]; + /* Common with Sun TLS implementation. */ + case BFD_RELOC_386_TLS_LDO_32: + TRACE ("BFD_RELOC_386_TLS_LDO_32"); + return &elf_howto_table[(unsigned int) R_386_TLS_LDO_32 - R_386_tls_offset]; + + case BFD_RELOC_386_TLS_IE_32: + TRACE ("BFD_RELOC_386_TLS_IE_32"); + return &elf_howto_table[(unsigned int) R_386_TLS_IE_32 - R_386_tls_offset]; + + case BFD_RELOC_386_TLS_LE_32: + TRACE ("BFD_RELOC_386_TLS_LE_32"); + return &elf_howto_table[(unsigned int) R_386_TLS_LE_32 - R_386_tls_offset]; + + case BFD_RELOC_386_TLS_DTPMOD32: + TRACE ("BFD_RELOC_386_TLS_DTPMOD32"); + return &elf_howto_table[(unsigned int) R_386_TLS_DTPMOD32 - R_386_tls_offset]; + + case BFD_RELOC_386_TLS_DTPOFF32: + TRACE ("BFD_RELOC_386_TLS_DTPOFF32"); + return &elf_howto_table[(unsigned int) R_386_TLS_DTPOFF32 - R_386_tls_offset]; + + case BFD_RELOC_386_TLS_TPOFF32: + TRACE ("BFD_RELOC_386_TLS_TPOFF32"); + return &elf_howto_table[(unsigned int) R_386_TLS_TPOFF32 - R_386_tls_offset]; + case BFD_RELOC_VTABLE_INHERIT: TRACE ("BFD_RELOC_VTABLE_INHERIT"); return &elf_howto_table[(unsigned int) R_386_GNU_VTINHERIT @@ -292,8 +393,10 @@ elf_i386_info_to_howto_rel (abfd, cache_ptr, dst) if ((indx = r_type) >= R_386_standard && ((indx = r_type - R_386_ext_offset) - R_386_standard >= R_386_ext - R_386_standard) - && ((indx = r_type - R_386_vt_offset) - R_386_ext - >= R_386_vt - R_386_ext)) + && ((indx = r_type - R_386_tls_offset) - R_386_ext + >= R_386_tls - R_386_ext) + && ((indx = r_type - R_386_vt_offset) - R_386_tls + >= R_386_vt - R_386_tls)) { (*_bfd_error_handler) (_("%s: invalid relocation type %d"), bfd_archive_filename (abfd), (int) r_type); @@ -481,8 +584,59 @@ struct elf_i386_link_hash_entry /* Track dynamic relocs copied for this symbol. */ struct elf_i386_dyn_relocs *dyn_relocs; + +#define GOT_UNKNOWN 0 +#define GOT_NORMAL 1 +#define GOT_TLS_GD 2 +#define GOT_TLS_IE 4 +#define GOT_TLS_IE_POS 5 +#define GOT_TLS_IE_NEG 6 +#define GOT_TLS_IE_BOTH 7 + unsigned char tls_type; }; +#define elf_i386_hash_entry(ent) ((struct elf_i386_link_hash_entry *)(ent)) + +struct elf_i386_obj_tdata +{ + struct elf_obj_tdata root; + + /* tls_type for each local got entry. */ + char *local_got_tls_type; +}; + +#define elf_i386_tdata(abfd) \ + ((struct elf_i386_obj_tdata *) (abfd)->tdata.any) + +#define elf_i386_local_got_tls_type(abfd) \ + (elf_i386_tdata (abfd)->local_got_tls_type) + +static boolean +elf_i386_mkobject (abfd) + bfd *abfd; +{ + bfd_size_type amt = sizeof (struct elf_i386_obj_tdata); + abfd->tdata.any = bfd_zalloc (abfd, amt); + if (abfd->tdata.any == NULL) + return false; + return true; +} + +static boolean +elf_i386_object_p (abfd) + bfd *abfd; +{ + /* Allocate our special target data. */ + struct elf_i386_obj_tdata *new_tdata; + bfd_size_type amt = sizeof (struct elf_i386_obj_tdata); + new_tdata = bfd_zalloc (abfd, amt); + if (new_tdata == NULL) + return false; + new_tdata->root = *abfd->tdata.elf_obj_data; + abfd->tdata.any = new_tdata; + return true; +} + /* i386 ELF linker hash table. */ struct elf_i386_link_hash_table @@ -498,6 +652,11 @@ struct elf_i386_link_hash_table asection *sdynbss; asection *srelbss; + union { + bfd_signed_vma refcount; + bfd_vma offset; + } tls_ldm_got; + /* Small local sym to section mapping cache. */ struct sym_sec_cache sym_sec; }; @@ -533,6 +692,7 @@ link_hash_newfunc (entry, table, string) eh = (struct elf_i386_link_hash_entry *) entry; eh->dyn_relocs = NULL; + eh->tls_type = GOT_UNKNOWN; } return entry; @@ -547,13 +707,13 @@ elf_i386_link_hash_table_create (abfd) struct elf_i386_link_hash_table *ret; bfd_size_type amt = sizeof (struct elf_i386_link_hash_table); - ret = (struct elf_i386_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct elf_i386_link_hash_table *) bfd_malloc (amt); if (ret == NULL) return NULL; if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return NULL; } @@ -564,6 +724,7 @@ elf_i386_link_hash_table_create (abfd) ret->srelplt = NULL; ret->sdynbss = NULL; ret->srelbss = NULL; + ret->tls_ldm_got.refcount = 0; ret->sym_sec.abfd = NULL; return &ret->elf.root; @@ -633,7 +794,8 @@ elf_i386_create_dynamic_sections (dynobj, info) /* Copy the extra info we tack onto an elf_link_hash_entry. */ static void -elf_i386_copy_indirect_symbol (dir, ind) +elf_i386_copy_indirect_symbol (bed, dir, ind) + struct elf_backend_data *bed; struct elf_link_hash_entry *dir, *ind; { struct elf_i386_link_hash_entry *edir, *eind; @@ -675,7 +837,41 @@ elf_i386_copy_indirect_symbol (dir, ind) eind->dyn_relocs = NULL; } - _bfd_elf_link_hash_copy_indirect (dir, ind); + if (ind->root.type == bfd_link_hash_indirect + && dir->got.refcount <= 0) + { + edir->tls_type = eind->tls_type; + eind->tls_type = GOT_UNKNOWN; + } + _bfd_elf_link_hash_copy_indirect (bed, dir, ind); +} + +static int +elf_i386_tls_transition (info, r_type, is_local) + struct bfd_link_info *info; + int r_type; + int is_local; +{ + if (info->shared) + return r_type; + + switch (r_type) + { + case R_386_TLS_GD: + case R_386_TLS_IE_32: + if (is_local) + return R_386_TLS_LE_32; + return R_386_TLS_IE_32; + case R_386_TLS_IE: + case R_386_TLS_GOTIE: + if (is_local) + return R_386_TLS_LE_32; + return r_type; + case R_386_TLS_LDM: + return R_386_TLS_LE_32; + } + + return r_type; } /* Look through the relocs for a section during the first phase, and @@ -708,10 +904,12 @@ elf_i386_check_relocs (abfd, info, sec, relocs) rel_end = relocs + sec->reloc_count; for (rel = relocs; rel < rel_end; rel++) { + unsigned int r_type; unsigned long r_symndx; struct elf_link_hash_entry *h; r_symndx = ELF32_R_SYM (rel->r_info); + r_type = ELF32_R_TYPE (rel->r_info); if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) { @@ -726,46 +924,13 @@ elf_i386_check_relocs (abfd, info, sec, relocs) else h = sym_hashes[r_symndx - symtab_hdr->sh_info]; - switch (ELF32_R_TYPE (rel->r_info)) - { - case R_386_GOT32: - /* This symbol requires a global offset table entry. */ - if (h != NULL) - { - h->got.refcount += 1; - } - else - { - bfd_signed_vma *local_got_refcounts; - - /* This is a global offset table entry for a local symbol. */ - local_got_refcounts = elf_local_got_refcounts (abfd); - if (local_got_refcounts == NULL) - { - bfd_size_type size; + r_type = elf_i386_tls_transition (info, r_type, h == NULL); - size = symtab_hdr->sh_info; - size *= sizeof (bfd_signed_vma); - local_got_refcounts = ((bfd_signed_vma *) - bfd_zalloc (abfd, size)); - if (local_got_refcounts == NULL) - return false; - elf_local_got_refcounts (abfd) = local_got_refcounts; - } - local_got_refcounts[r_symndx] += 1; - } - /* Fall through */ - - case R_386_GOTOFF: - case R_386_GOTPC: - if (htab->sgot == NULL) - { - if (htab->elf.dynobj == NULL) - htab->elf.dynobj = abfd; - if (!create_got_section (htab->elf.dynobj, info)) - return false; - } - break; + switch (r_type) + { + case R_386_TLS_LDM: + htab->tls_ldm_got.refcount += 1; + goto create_got; case R_386_PLT32: /* This symbol requires a procedure linkage table entry. We @@ -784,6 +949,116 @@ elf_i386_check_relocs (abfd, info, sec, relocs) h->plt.refcount += 1; break; + case R_386_TLS_IE_32: + case R_386_TLS_IE: + case R_386_TLS_GOTIE: + if (info->shared) + info->flags |= DF_STATIC_TLS; + /* Fall through */ + + case R_386_GOT32: + case R_386_TLS_GD: + /* This symbol requires a global offset table entry. */ + { + int tls_type, old_tls_type; + + switch (r_type) + { + default: + case R_386_GOT32: tls_type = GOT_NORMAL; break; + case R_386_TLS_GD: tls_type = GOT_TLS_GD; break; + case R_386_TLS_IE_32: + if (ELF32_R_TYPE (rel->r_info) == r_type) + tls_type = GOT_TLS_IE_NEG; + else + /* If this is a GD->IE transition, we may use either of + R_386_TLS_TPOFF and R_386_TLS_TPOFF32. */ + tls_type = GOT_TLS_IE; + break; + case R_386_TLS_IE: + case R_386_TLS_GOTIE: + tls_type = GOT_TLS_IE_POS; break; + } + + if (h != NULL) + { + h->got.refcount += 1; + old_tls_type = elf_i386_hash_entry(h)->tls_type; + } + else + { + bfd_signed_vma *local_got_refcounts; + + /* This is a global offset table entry for a local symbol. */ + local_got_refcounts = elf_local_got_refcounts (abfd); + if (local_got_refcounts == NULL) + { + bfd_size_type size; + + size = symtab_hdr->sh_info; + size *= (sizeof (bfd_signed_vma) + sizeof(char)); + local_got_refcounts = ((bfd_signed_vma *) + bfd_zalloc (abfd, size)); + if (local_got_refcounts == NULL) + return false; + elf_local_got_refcounts (abfd) = local_got_refcounts; + elf_i386_local_got_tls_type (abfd) + = (char *) (local_got_refcounts + symtab_hdr->sh_info); + } + local_got_refcounts[r_symndx] += 1; + old_tls_type = elf_i386_local_got_tls_type (abfd) [r_symndx]; + } + + if ((old_tls_type & GOT_TLS_IE) && (tls_type & GOT_TLS_IE)) + tls_type |= old_tls_type; + /* If a TLS symbol is accessed using IE at least once, + there is no point to use dynamic model for it. */ + else if (old_tls_type != tls_type && old_tls_type != GOT_UNKNOWN + && (old_tls_type != GOT_TLS_GD + || (tls_type & GOT_TLS_IE) == 0)) + { + if ((old_tls_type & GOT_TLS_IE) && tls_type == GOT_TLS_GD) + tls_type = old_tls_type; + else + { + (*_bfd_error_handler) + (_("%s: `%s' accessed both as normal and thread local symbol"), + bfd_archive_filename (abfd), + h ? h->root.root.string : "<local>"); + return false; + } + } + + if (old_tls_type != tls_type) + { + if (h != NULL) + elf_i386_hash_entry (h)->tls_type = tls_type; + else + elf_i386_local_got_tls_type (abfd) [r_symndx] = tls_type; + } + } + /* Fall through */ + + case R_386_GOTOFF: + case R_386_GOTPC: + create_got: + if (htab->sgot == NULL) + { + if (htab->elf.dynobj == NULL) + htab->elf.dynobj = abfd; + if (!create_got_section (htab->elf.dynobj, info)) + return false; + } + if (r_type != R_386_TLS_IE) + break; + /* Fall through */ + + case R_386_TLS_LE_32: + case R_386_TLS_LE: + if (!info->shared) + break; + /* Fall through */ + case R_386_32: case R_386_PC32: if (h != NULL && !info->shared) @@ -824,7 +1099,7 @@ elf_i386_check_relocs (abfd, info, sec, relocs) symbol. */ if ((info->shared && (sec->flags & SEC_ALLOC) != 0 - && (ELF32_R_TYPE (rel->r_info) != R_386_PC32 + && (r_type != R_386_PC32 || (h != NULL && (! info->symbolic || h->root.type == bfd_link_hash_defweak @@ -923,7 +1198,7 @@ elf_i386_check_relocs (abfd, info, sec, relocs) } p->count += 1; - if (ELF32_R_TYPE (rel->r_info) == R_386_PC32) + if (r_type == R_386_PC32) p->pc_count += 1; } break; @@ -954,8 +1229,8 @@ elf_i386_check_relocs (abfd, info, sec, relocs) relocation. */ static asection * -elf_i386_gc_mark_hook (abfd, info, rel, h, sym) - bfd *abfd; +elf_i386_gc_mark_hook (sec, info, rel, h, sym) + asection *sec; struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; @@ -985,9 +1260,7 @@ elf_i386_gc_mark_hook (abfd, info, rel, h, sym) } } else - { - return bfd_section_from_elf_index (abfd, sym->st_shndx); - } + return bfd_section_from_elf_index (sec->owner, sym->st_shndx); return NULL; } @@ -1006,6 +1279,7 @@ elf_i386_gc_sweep_hook (abfd, info, sec, relocs) bfd_signed_vma *local_got_refcounts; const Elf_Internal_Rela *rel, *relend; unsigned long r_symndx; + int r_type; struct elf_link_hash_entry *h; elf_section_data (sec)->local_dynrel = NULL; @@ -1016,11 +1290,21 @@ elf_i386_gc_sweep_hook (abfd, info, sec, relocs) relend = relocs + sec->reloc_count; for (rel = relocs; rel < relend; rel++) - switch (ELF32_R_TYPE (rel->r_info)) + switch ((r_type = elf_i386_tls_transition (info, + ELF32_R_TYPE (rel->r_info), + ELF32_R_SYM (rel->r_info) + >= symtab_hdr->sh_info))) { + case R_386_TLS_LDM: + if (elf_i386_hash_table (info)->tls_ldm_got.refcount > 0) + elf_i386_hash_table (info)->tls_ldm_got.refcount -= 1; + break; + + case R_386_TLS_GD: + case R_386_TLS_IE_32: + case R_386_TLS_IE: + case R_386_TLS_GOTIE: case R_386_GOT32: - case R_386_GOTOFF: - case R_386_GOTPC: r_symndx = ELF32_R_SYM (rel->r_info); if (r_symndx >= symtab_hdr->sh_info) { @@ -1033,7 +1317,15 @@ elf_i386_gc_sweep_hook (abfd, info, sec, relocs) if (local_got_refcounts[r_symndx] > 0) local_got_refcounts[r_symndx] -= 1; } - break; + if (r_type != R_386_TLS_IE) + break; + /* Fall through */ + + case R_386_TLS_LE_32: + case R_386_TLS_LE: + if (!info->shared) + break; + /* Fall through */ case R_386_32: case R_386_PC32: @@ -1173,7 +1465,7 @@ elf_i386_adjust_dynamic_symbol (info, h) } /* If we didn't find any dynamic relocs in read-only sections, then - we'll be keeping the dynamic relocs and avoiding the copy reloc. */ + we'll be keeping the dynamic relocs and avoiding the copy reloc. */ if (p == NULL) { h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF; @@ -1319,10 +1611,18 @@ allocate_dynrelocs (h, inf) h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; } - if (h->got.refcount > 0) + /* If R_386_TLS_{IE_32,IE,GOTIE} symbol is now local to the binary, + make it a R_386_TLS_LE_32 requiring no TLS entry. */ + if (h->got.refcount > 0 + && !info->shared + && h->dynindx == -1 + && (elf_i386_hash_entry(h)->tls_type & GOT_TLS_IE)) + h->got.offset = (bfd_vma) -1; + else if (h->got.refcount > 0) { asection *s; boolean dyn; + int tls_type = elf_i386_hash_entry(h)->tls_type; /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ @@ -1336,8 +1636,23 @@ allocate_dynrelocs (h, inf) s = htab->sgot; h->got.offset = s->_raw_size; s->_raw_size += 4; + /* R_386_TLS_GD needs 2 consecutive GOT slots. */ + if (tls_type == GOT_TLS_GD || tls_type == GOT_TLS_IE_BOTH) + s->_raw_size += 4; dyn = htab->elf.dynamic_sections_created; - if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)) + /* R_386_TLS_IE_32 needs one dynamic relocation, + R_386_TLS_IE resp. R_386_TLS_GOTIE needs one dynamic relocation, + (but if both R_386_TLS_IE_32 and R_386_TLS_IE is present, we + need two), R_386_TLS_GD needs one if local symbol and two if + global. */ + if (tls_type == GOT_TLS_IE_BOTH) + htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rel); + else if ((tls_type == GOT_TLS_GD && h->dynindx == -1) + || (tls_type & GOT_TLS_IE)) + htab->srelgot->_raw_size += sizeof (Elf32_External_Rel); + else if (tls_type == GOT_TLS_GD) + htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rel); + else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)) htab->srelgot->_raw_size += sizeof (Elf32_External_Rel); } else @@ -1483,6 +1798,7 @@ elf_i386_size_dynamic_sections (output_bfd, info) { bfd_signed_vma *local_got; bfd_signed_vma *end_local_got; + char *local_tls_type; bfd_size_type locsymcount; Elf_Internal_Shdr *symtab_hdr; asection *srel; @@ -1524,22 +1840,44 @@ elf_i386_size_dynamic_sections (output_bfd, info) symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; locsymcount = symtab_hdr->sh_info; end_local_got = local_got + locsymcount; + local_tls_type = elf_i386_local_got_tls_type (ibfd); s = htab->sgot; srel = htab->srelgot; - for (; local_got < end_local_got; ++local_got) + for (; local_got < end_local_got; ++local_got, ++local_tls_type) { if (*local_got > 0) { *local_got = s->_raw_size; s->_raw_size += 4; - if (info->shared) - srel->_raw_size += sizeof (Elf32_External_Rel); + if (*local_tls_type == GOT_TLS_GD + || *local_tls_type == GOT_TLS_IE_BOTH) + s->_raw_size += 4; + if (info->shared + || *local_tls_type == GOT_TLS_GD + || (*local_tls_type & GOT_TLS_IE)) + { + if (*local_tls_type == GOT_TLS_IE_BOTH) + srel->_raw_size += 2 * sizeof (Elf32_External_Rel); + else + srel->_raw_size += sizeof (Elf32_External_Rel); + } } else *local_got = (bfd_vma) -1; } } + if (htab->tls_ldm_got.refcount > 0) + { + /* Allocate 2 got entries and 1 dynamic reloc for R_386_TLS_LDM + relocs. */ + htab->tls_ldm_got.offset = htab->sgot->_raw_size; + htab->sgot->_raw_size += 8; + htab->srelgot->_raw_size += sizeof (Elf32_External_Rel); + } + else + htab->tls_ldm_got.offset = -1; + /* Allocate global sym .plt and .got entries, and space for global sym dynamic relocs. */ elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info); @@ -1685,6 +2023,38 @@ elf_i386_fake_sections (abfd, hdr, sec) return true; } +/* Return the base VMA address which should be subtracted from real addresses + when resolving @dtpoff relocation. + This is PT_TLS segment p_vaddr. */ + +static bfd_vma +dtpoff_base (info) + struct bfd_link_info *info; +{ + /* If tls_segment is NULL, we should have signalled an error already. */ + if (elf_hash_table (info)->tls_segment == NULL) + return 0; + return elf_hash_table (info)->tls_segment->start; +} + +/* Return the relocation value for @tpoff relocation + if STT_TLS virtual address is ADDRESS. */ + +static bfd_vma +tpoff (info, address) + struct bfd_link_info *info; + bfd_vma address; +{ + struct elf_link_tls_segment *tls_segment + = elf_hash_table (info)->tls_segment; + + /* If tls_segment is NULL, we should have signalled an error already. */ + if (tls_segment == NULL) + return 0; + return (align_power (tls_segment->size, tls_segment->align) + + tls_segment->start - address); +} + /* Relocate an i386 ELF section. */ static boolean @@ -1715,7 +2085,7 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, relend = relocs + input_section->reloc_count; for (; rel < relend; rel++) { - int r_type; + unsigned int r_type; reloc_howto_type *howto; unsigned long r_symndx; struct elf_link_hash_entry *h; @@ -1726,6 +2096,7 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, boolean unresolved_reloc; bfd_reloc_status_type r; unsigned int indx; + int tls_type; r_type = ELF32_R_TYPE (rel->r_info); if (r_type == (int) R_386_GNU_VTINHERIT @@ -1733,8 +2104,10 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, continue; if ((indx = (unsigned) r_type) >= R_386_standard - && ((indx = (unsigned) r_type - R_386_ext_offset) - R_386_standard - >= R_386_ext - R_386_standard)) + && ((indx = r_type - R_386_ext_offset) - R_386_standard + >= R_386_ext - R_386_standard) + && ((indx = r_type - R_386_tls_offset) - R_386_ext + >= R_386_tls - R_386_ext)) { bfd_set_error (bfd_error_bad_value); return false; @@ -1745,22 +2118,43 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, if (info->relocateable) { + bfd_vma val; + bfd_byte *where; + /* This is a relocatable link. We don't have to change anything, unless the reloc is against a section symbol, in which case we have to adjust according to where the section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - bfd_vma val; + if (r_symndx >= symtab_hdr->sh_info) + continue; - sec = local_sections[r_symndx]; - val = bfd_get_32 (input_bfd, contents + rel->r_offset); - val += sec->output_offset + sym->st_value; - bfd_put_32 (input_bfd, val, contents + rel->r_offset); - } + sym = local_syms + r_symndx; + if (ELF_ST_TYPE (sym->st_info) != STT_SECTION) + continue; + + sec = local_sections[r_symndx]; + val = sec->output_offset; + if (val == 0) + continue; + + where = contents + rel->r_offset; + switch (howto->size) + { + /* FIXME: overflow checks. */ + case 0: + val += bfd_get_8 (input_bfd, where); + bfd_put_8 (input_bfd, val, where); + break; + case 1: + val += bfd_get_16 (input_bfd, where); + bfd_put_16 (input_bfd, val, where); + break; + case 2: + val += bfd_get_32 (input_bfd, where); + bfd_put_32 (input_bfd, val, where); + break; + default: + abort (); } continue; } @@ -1782,24 +2176,62 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, { asection *msec; bfd_vma addend; + bfd_byte *where = contents + rel->r_offset; - if (howto->src_mask != 0xffffffff) + switch (howto->size) { - (*_bfd_error_handler) - (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"), - bfd_archive_filename (input_bfd), - bfd_get_section_name (input_bfd, input_section), - (long) rel->r_offset, howto->name); - return false; + case 0: + addend = bfd_get_8 (input_bfd, where); + if (howto->pc_relative) + { + addend = (addend ^ 0x80) - 0x80; + addend += 1; + } + break; + case 1: + addend = bfd_get_16 (input_bfd, where); + if (howto->pc_relative) + { + addend = (addend ^ 0x8000) - 0x8000; + addend += 2; + } + break; + case 2: + addend = bfd_get_32 (input_bfd, where); + if (howto->pc_relative) + { + addend = (addend ^ 0x80000000) - 0x80000000; + addend += 4; + } + break; + default: + abort (); } - addend = bfd_get_32 (input_bfd, contents + rel->r_offset); msec = sec; - addend = - _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend) - - relocation; + addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend); + addend -= relocation; addend += msec->output_section->vma + msec->output_offset; - bfd_put_32 (input_bfd, addend, contents + rel->r_offset); + + switch (howto->size) + { + case 0: + /* FIXME: overflow checks. */ + if (howto->pc_relative) + addend -= 1; + bfd_put_8 (input_bfd, addend, where); + break; + case 1: + if (howto->pc_relative) + addend -= 2; + bfd_put_16 (input_bfd, addend, where); + break; + case 2: + if (howto->pc_relative) + addend -= 4; + bfd_put_32 (input_bfd, addend, where); + break; + } } } else @@ -2059,25 +2491,505 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, } break; + case R_386_TLS_IE: + if (info->shared) + { + Elf_Internal_Rel outrel; + asection *sreloc; + Elf32_External_Rel *loc; + + outrel.r_offset = rel->r_offset + + input_section->output_section->vma + + input_section->output_offset; + outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE); + sreloc = elf_section_data (input_section)->sreloc; + if (sreloc == NULL) + abort (); + loc = (Elf32_External_Rel *) sreloc->contents; + loc += sreloc->reloc_count++; + bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); + } + /* Fall through */ + + case R_386_TLS_GD: + case R_386_TLS_IE_32: + case R_386_TLS_GOTIE: + r_type = elf_i386_tls_transition (info, r_type, h == NULL); + tls_type = GOT_UNKNOWN; + if (h == NULL && local_got_offsets) + tls_type = elf_i386_local_got_tls_type (input_bfd) [r_symndx]; + else if (h != NULL) + { + tls_type = elf_i386_hash_entry(h)->tls_type; + if (!info->shared && h->dynindx == -1 && (tls_type & GOT_TLS_IE)) + r_type = R_386_TLS_LE_32; + } + if (tls_type == GOT_TLS_IE) + tls_type = GOT_TLS_IE_NEG; + if (r_type == R_386_TLS_GD) + { + if (tls_type == GOT_TLS_IE_POS) + r_type = R_386_TLS_GOTIE; + else if (tls_type & GOT_TLS_IE) + r_type = R_386_TLS_IE_32; + } + + if (r_type == R_386_TLS_LE_32) + { + BFD_ASSERT (! unresolved_reloc); + if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_GD) + { + unsigned int val, type; + bfd_vma roff; + + /* GD->LE transition. */ + BFD_ASSERT (rel->r_offset >= 2); + type = bfd_get_8 (input_bfd, contents + rel->r_offset - 2); + BFD_ASSERT (type == 0x8d || type == 0x04); + BFD_ASSERT (rel->r_offset + 9 <= input_section->_raw_size); + BFD_ASSERT (bfd_get_8 (input_bfd, + contents + rel->r_offset + 4) + == 0xe8); + BFD_ASSERT (rel + 1 < relend); + BFD_ASSERT (ELF32_R_TYPE (rel[1].r_info) == R_386_PLT32); + roff = rel->r_offset + 5; + val = bfd_get_8 (input_bfd, + contents + rel->r_offset - 1); + if (type == 0x04) + { + /* leal foo(,%reg,1), %eax; call ___tls_get_addr + Change it into: + movl %gs:0, %eax; subl $foo@tpoff, %eax + (6 byte form of subl). */ + BFD_ASSERT (rel->r_offset >= 3); + BFD_ASSERT (bfd_get_8 (input_bfd, + contents + rel->r_offset - 3) + == 0x8d); + BFD_ASSERT ((val & 0xc7) == 0x05 && val != (4 << 3)); + memcpy (contents + rel->r_offset - 3, + "\x65\xa1\0\0\0\0\x81\xe8\0\0\0", 12); + } + else + { + BFD_ASSERT ((val & 0xf8) == 0x80 && (val & 7) != 4); + if (rel->r_offset + 10 <= input_section->_raw_size + && bfd_get_8 (input_bfd, + contents + rel->r_offset + 9) == 0x90) + { + /* leal foo(%reg), %eax; call ___tls_get_addr; nop + Change it into: + movl %gs:0, %eax; subl $foo@tpoff, %eax + (6 byte form of subl). */ + memcpy (contents + rel->r_offset - 2, + "\x65\xa1\0\0\0\0\x81\xe8\0\0\0", 12); + roff = rel->r_offset + 6; + } + else + { + /* leal foo(%reg), %eax; call ___tls_get_addr + Change it into: + movl %gs:0, %eax; subl $foo@tpoff, %eax + (5 byte form of subl). */ + memcpy (contents + rel->r_offset - 2, + "\x65\xa1\0\0\0\0\x2d\0\0\0", 11); + } + } + bfd_put_32 (output_bfd, tpoff (info, relocation), + contents + roff); + /* Skip R_386_PLT32. */ + rel++; + continue; + } + else if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_IE) + { + unsigned int val, type; + + /* IE->LE transition: + Originally it can be one of: + movl foo, %eax + movl foo, %reg + addl foo, %reg + We change it into: + movl $foo, %eax + movl $foo, %reg + addl $foo, %reg. */ + BFD_ASSERT (rel->r_offset >= 1); + val = bfd_get_8 (input_bfd, contents + rel->r_offset - 1); + BFD_ASSERT (rel->r_offset + 4 <= input_section->_raw_size); + if (val != 0xa1) + { + BFD_ASSERT (rel->r_offset >= 2); + type = bfd_get_8 (input_bfd, contents + rel->r_offset - 2); + } + if (val == 0xa1) + { + /* movl foo, %eax. */ + bfd_put_8 (output_bfd, 0xb8, contents + rel->r_offset - 2); + } + else if (type == 0x8b) + { + /* movl */ + BFD_ASSERT ((val & 0xc7) == 0x05); + bfd_put_8 (output_bfd, 0xc7, + contents + rel->r_offset - 2); + bfd_put_8 (output_bfd, 0xc0 | ((val >> 3) & 7), + contents + rel->r_offset - 1); + } + else if (type == 0x03) + { + /* addl */ + BFD_ASSERT ((val & 0xc7) == 0x05); + bfd_put_8 (output_bfd, 0x81, + contents + rel->r_offset - 2); + bfd_put_8 (output_bfd, 0xc0 | ((val >> 3) & 7), + contents + rel->r_offset - 1); + } + else + BFD_FAIL (); + bfd_put_32 (output_bfd, -tpoff (info, relocation), + contents + rel->r_offset); + continue; + } + else + { + unsigned int val, type; + + /* {IE_32,GOTIE}->LE transition: + Originally it can be one of: + subl foo(%reg1), %reg2 + movl foo(%reg1), %reg2 + addl foo(%reg1), %reg2 + We change it into: + subl $foo, %reg2 + movl $foo, %reg2 (6 byte form) + addl $foo, %reg2. */ + BFD_ASSERT (rel->r_offset >= 2); + type = bfd_get_8 (input_bfd, contents + rel->r_offset - 2); + val = bfd_get_8 (input_bfd, contents + rel->r_offset - 1); + BFD_ASSERT (rel->r_offset + 4 <= input_section->_raw_size); + BFD_ASSERT ((val & 0xc0) == 0x80 && (val & 7) != 4); + if (type == 0x8b) + { + /* movl */ + bfd_put_8 (output_bfd, 0xc7, + contents + rel->r_offset - 2); + bfd_put_8 (output_bfd, 0xc0 | ((val >> 3) & 7), + contents + rel->r_offset - 1); + } + else if (type == 0x2b) + { + /* subl */ + bfd_put_8 (output_bfd, 0x81, + contents + rel->r_offset - 2); + bfd_put_8 (output_bfd, 0xe8 | ((val >> 3) & 7), + contents + rel->r_offset - 1); + } + else if (type == 0x03) + { + /* addl */ + bfd_put_8 (output_bfd, 0x81, + contents + rel->r_offset - 2); + bfd_put_8 (output_bfd, 0xc0 | ((val >> 3) & 7), + contents + rel->r_offset - 1); + } + else + BFD_FAIL (); + if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_GOTIE) + bfd_put_32 (output_bfd, -tpoff (info, relocation), + contents + rel->r_offset); + else + bfd_put_32 (output_bfd, tpoff (info, relocation), + contents + rel->r_offset); + continue; + } + } + + if (htab->sgot == NULL) + abort (); + + if (h != NULL) + off = h->got.offset; + else + { + if (local_got_offsets == NULL) + abort (); + + off = local_got_offsets[r_symndx]; + } + + if ((off & 1) != 0) + off &= ~1; + else + { + Elf_Internal_Rel outrel; + Elf32_External_Rel *loc; + int dr_type, indx; + + if (htab->srelgot == NULL) + abort (); + + outrel.r_offset = (htab->sgot->output_section->vma + + htab->sgot->output_offset + off); + + indx = h && h->dynindx != -1 ? h->dynindx : 0; + if (r_type == R_386_TLS_GD) + dr_type = R_386_TLS_DTPMOD32; + else if (tls_type == GOT_TLS_IE_POS) + dr_type = R_386_TLS_TPOFF; + else + dr_type = R_386_TLS_TPOFF32; + if (dr_type == R_386_TLS_TPOFF && indx == 0) + bfd_put_32 (output_bfd, relocation - dtpoff_base (info), + htab->sgot->contents + off); + else if (dr_type == R_386_TLS_TPOFF32 && indx == 0) + bfd_put_32 (output_bfd, dtpoff_base (info) - relocation, + htab->sgot->contents + off); + else + bfd_put_32 (output_bfd, 0, + htab->sgot->contents + off); + outrel.r_info = ELF32_R_INFO (indx, dr_type); + loc = (Elf32_External_Rel *) htab->srelgot->contents; + loc += htab->srelgot->reloc_count++; + bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); + + if (r_type == R_386_TLS_GD) + { + if (indx == 0) + { + BFD_ASSERT (! unresolved_reloc); + bfd_put_32 (output_bfd, + relocation - dtpoff_base (info), + htab->sgot->contents + off + 4); + } + else + { + bfd_put_32 (output_bfd, 0, + htab->sgot->contents + off + 4); + outrel.r_info = ELF32_R_INFO (indx, + R_386_TLS_DTPOFF32); + outrel.r_offset += 4; + htab->srelgot->reloc_count++; + loc++; + bfd_elf32_swap_reloc_out (output_bfd, &outrel, + loc); + } + } + else if (tls_type == GOT_TLS_IE_BOTH) + { + bfd_put_32 (output_bfd, + indx == 0 ? relocation - dtpoff_base (info) : 0, + htab->sgot->contents + off + 4); + outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_TPOFF); + outrel.r_offset += 4; + htab->srelgot->reloc_count++; + loc++; + bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); + } + + if (h != NULL) + h->got.offset |= 1; + else + local_got_offsets[r_symndx] |= 1; + } + + if (off >= (bfd_vma) -2) + abort (); + if (r_type == ELF32_R_TYPE (rel->r_info)) + { + relocation = htab->sgot->output_offset + off; + if ((r_type == R_386_TLS_IE || r_type == R_386_TLS_GOTIE) + && tls_type == GOT_TLS_IE_BOTH) + relocation += 4; + if (r_type == R_386_TLS_IE) + relocation += htab->sgot->output_section->vma; + unresolved_reloc = false; + } + else + { + unsigned int val, type; + bfd_vma roff; + + /* GD->IE transition. */ + BFD_ASSERT (rel->r_offset >= 2); + type = bfd_get_8 (input_bfd, contents + rel->r_offset - 2); + BFD_ASSERT (type == 0x8d || type == 0x04); + BFD_ASSERT (rel->r_offset + 9 <= input_section->_raw_size); + BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset + 4) + == 0xe8); + BFD_ASSERT (rel + 1 < relend); + BFD_ASSERT (ELF32_R_TYPE (rel[1].r_info) == R_386_PLT32); + roff = rel->r_offset - 3; + val = bfd_get_8 (input_bfd, contents + rel->r_offset - 1); + if (type == 0x04) + { + /* leal foo(,%reg,1), %eax; call ___tls_get_addr + Change it into: + movl %gs:0, %eax; subl $foo@gottpoff(%reg), %eax. */ + BFD_ASSERT (rel->r_offset >= 3); + BFD_ASSERT (bfd_get_8 (input_bfd, + contents + rel->r_offset - 3) + == 0x8d); + BFD_ASSERT ((val & 0xc7) == 0x05 && val != (4 << 3)); + val >>= 3; + } + else + { + /* leal foo(%reg), %eax; call ___tls_get_addr; nop + Change it into: + movl %gs:0, %eax; subl $foo@gottpoff(%reg), %eax. */ + BFD_ASSERT (rel->r_offset + 10 <= input_section->_raw_size); + BFD_ASSERT ((val & 0xf8) == 0x80 && (val & 7) != 4); + BFD_ASSERT (bfd_get_8 (input_bfd, + contents + rel->r_offset + 9) + == 0x90); + roff = rel->r_offset - 2; + } + memcpy (contents + roff, + "\x65\xa1\0\0\0\0\x2b\x80\0\0\0", 12); + contents[roff + 7] = 0x80 | (val & 7); + /* If foo is used only with foo@gotntpoff(%reg) and + foo@indntpoff, but not with foo@gottpoff(%reg), change + subl $foo@gottpoff(%reg), %eax + into: + addl $foo@gotntpoff(%reg), %eax. */ + if (r_type == R_386_TLS_GOTIE) + { + contents[roff + 6] = 0x03; + if (tls_type == GOT_TLS_IE_BOTH) + off += 4; + } + bfd_put_32 (output_bfd, htab->sgot->output_offset + off, + contents + roff + 8); + /* Skip R_386_PLT32. */ + rel++; + continue; + } + break; + + case R_386_TLS_LDM: + if (! info->shared) + { + unsigned int val; + + /* LD->LE transition: + Ensure it is: + leal foo(%reg), %eax; call ___tls_get_addr. + We change it into: + movl %gs:0, %eax; nop; leal 0(%esi,1), %esi. */ + BFD_ASSERT (rel->r_offset >= 2); + BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset - 2) + == 0x8d); + val = bfd_get_8 (input_bfd, contents + rel->r_offset - 1); + BFD_ASSERT ((val & 0xf8) == 0x80 && (val & 7) != 4); + BFD_ASSERT (rel->r_offset + 9 <= input_section->_raw_size); + BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset + 4) + == 0xe8); + BFD_ASSERT (rel + 1 < relend); + BFD_ASSERT (ELF32_R_TYPE (rel[1].r_info) == R_386_PLT32); + memcpy (contents + rel->r_offset - 2, + "\x65\xa1\0\0\0\0\x90\x8d\x74\x26", 11); + /* Skip R_386_PLT32. */ + rel++; + continue; + } + + if (htab->sgot == NULL) + abort (); + + off = htab->tls_ldm_got.offset; + if (off & 1) + off &= ~1; + else + { + Elf_Internal_Rel outrel; + Elf32_External_Rel *loc; + + if (htab->srelgot == NULL) + abort (); + + outrel.r_offset = (htab->sgot->output_section->vma + + htab->sgot->output_offset + off); + + bfd_put_32 (output_bfd, 0, + htab->sgot->contents + off); + bfd_put_32 (output_bfd, 0, + htab->sgot->contents + off + 4); + outrel.r_info = ELF32_R_INFO (0, R_386_TLS_DTPMOD32); + loc = (Elf32_External_Rel *) htab->srelgot->contents; + loc += htab->srelgot->reloc_count++; + bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); + htab->tls_ldm_got.offset |= 1; + } + relocation = htab->sgot->output_offset + off; + unresolved_reloc = false; + break; + + case R_386_TLS_LDO_32: + if (info->shared) + relocation -= dtpoff_base (info); + else + /* When converting LDO to LE, we must negate. */ + relocation = -tpoff (info, relocation); + break; + + case R_386_TLS_LE_32: + case R_386_TLS_LE: + if (info->shared) + { + Elf_Internal_Rel outrel; + asection *sreloc; + Elf32_External_Rel *loc; + int indx; + + outrel.r_offset = rel->r_offset + + input_section->output_section->vma + + input_section->output_offset; + if (h != NULL && h->dynindx != -1) + indx = h->dynindx; + else + indx = 0; + if (r_type == R_386_TLS_LE_32) + outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_TPOFF32); + else + outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_TPOFF); + sreloc = elf_section_data (input_section)->sreloc; + if (sreloc == NULL) + abort (); + loc = (Elf32_External_Rel *) sreloc->contents; + loc += sreloc->reloc_count++; + bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); + if (indx) + continue; + else if (r_type == R_386_TLS_LE_32) + relocation = dtpoff_base (info) - relocation; + else + relocation -= dtpoff_base (info); + } + else if (r_type == R_386_TLS_LE_32) + relocation = tpoff (info, relocation); + else + relocation = -tpoff (info, relocation); + break; + default: break; } - /* FIXME: Why do we allow debugging sections to escape this error? - More importantly, why do we not emit dynamic relocs for - R_386_32 above in debugging sections (which are ! SEC_ALLOC)? - If we had emitted the dynamic reloc, we could remove the - fudge here. */ + /* Dynamic relocs are not propagated for SEC_DEBUGGING sections + because such sections are not SEC_ALLOC and thus ld.so will + not process them. */ if (unresolved_reloc - && !(info->shared - && (input_section->flags & SEC_DEBUGGING) != 0 + && !((input_section->flags & SEC_DEBUGGING) != 0 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) - (*_bfd_error_handler) - (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"), - bfd_archive_filename (input_bfd), - bfd_get_section_name (input_bfd, input_section), - (long) rel->r_offset, - h->root.root.string); + { + (*_bfd_error_handler) + (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"), + bfd_archive_filename (input_bfd), + bfd_get_section_name (input_bfd, input_section), + (long) rel->r_offset, + h->root.root.string); + return false; + } r = _bfd_final_link_relocate (howto, input_bfd, input_section, contents, rel->r_offset, @@ -2102,7 +3014,6 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, if (r == bfd_reloc_overflow) { - if (! ((*info->callbacks->reloc_overflow) (info, name, howto->name, (bfd_vma) 0, input_bfd, input_section, rel->r_offset))) @@ -2210,12 +3121,14 @@ elf_i386_finish_dynamic_symbol (output_bfd, info, h, sym) the .plt section. Leave the value alone. This is a clue for the dynamic linker, to make function pointer comparisons work between an application and shared - library. */ + library. */ sym->st_shndx = SHN_UNDEF; } } - if (h->got.offset != (bfd_vma) -1) + if (h->got.offset != (bfd_vma) -1 + && elf_i386_hash_entry(h)->tls_type != GOT_TLS_GD + && (elf_i386_hash_entry(h)->tls_type & GOT_TLS_IE) == 0) { Elf_Internal_Rel rel; Elf32_External_Rel *loc; @@ -2430,11 +3343,13 @@ elf_i386_finish_dynamic_sections (output_bfd, info) return true; } +#ifndef ELF_ARCH #define TARGET_LITTLE_SYM bfd_elf32_i386_vec #define TARGET_LITTLE_NAME "elf32-i386" #define ELF_ARCH bfd_arch_i386 #define ELF_MACHINE_CODE EM_386 #define ELF_MAXPAGESIZE 0x1000 +#endif /* ELF_ARCH */ #define elf_backend_can_gc_sections 1 #define elf_backend_can_refcount 1 @@ -2447,6 +3362,9 @@ elf_i386_finish_dynamic_sections (output_bfd, info) #define elf_info_to_howto elf_i386_info_to_howto #define elf_info_to_howto_rel elf_i386_info_to_howto_rel +#define bfd_elf32_mkobject elf_i386_mkobject +#define elf_backend_object_p elf_i386_object_p + #define bfd_elf32_bfd_is_local_label_name elf_i386_is_local_label_name #define bfd_elf32_bfd_link_hash_table_create elf_i386_link_hash_table_create #define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup @@ -2466,4 +3384,6 @@ elf_i386_finish_dynamic_sections (output_bfd, info) #define elf_backend_relocate_section elf_i386_relocate_section #define elf_backend_size_dynamic_sections elf_i386_size_dynamic_sections +#ifndef ELF32_I386_C_INCLUDED #include "elf32-target.h" +#endif diff --git a/contrib/binutils/bfd/elf32-ppc.c b/contrib/binutils/bfd/elf32-ppc.c index 31d9e0c..9abdf61 100644 --- a/contrib/binutils/bfd/elf32-ppc.c +++ b/contrib/binutils/bfd/elf32-ppc.c @@ -43,6 +43,7 @@ static boolean ppc_elf_relax_section PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *)); static bfd_reloc_status_type ppc_elf_addr16_ha_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static boolean ppc_elf_object_p PARAMS ((bfd *)); static boolean ppc_elf_set_private_flags PARAMS ((bfd *, flagword)); static boolean ppc_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *)); @@ -56,7 +57,7 @@ static boolean ppc_elf_create_dynamic_sections static boolean ppc_elf_section_from_shdr PARAMS ((bfd *, Elf32_Internal_Shdr *, - char *)); + const char *)); static boolean ppc_elf_fake_sections PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *)); @@ -70,7 +71,7 @@ static boolean ppc_elf_check_relocs PARAMS ((bfd *, asection *, const Elf_Internal_Rela *)); -static asection * ppc_elf_gc_mark_hook PARAMS ((bfd *abfd, +static asection * ppc_elf_gc_mark_hook PARAMS ((asection *sec, struct bfd_link_info *info, Elf_Internal_Rela *rel, struct elf_link_hash_entry *h, @@ -1380,6 +1381,27 @@ ppc_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section, return bfd_reloc_continue; } +/* Fix bad default arch selected for a 32 bit input bfd when the + default is 64 bit. */ + +static boolean +ppc_elf_object_p (abfd) + bfd *abfd; +{ + if (abfd->arch_info->the_default && abfd->arch_info->bits_per_word == 64) + { + Elf_Internal_Ehdr *i_ehdr = elf_elfheader (abfd); + + if (i_ehdr->e_ident[EI_CLASS] == ELFCLASS32) + { + /* Relies on arch after 64 bit default being 32 bit default. */ + abfd->arch_info = abfd->arch_info->next; + BFD_ASSERT (abfd->arch_info->bits_per_word == 32); + } + } + return true; +} + /* Function to set whether a module needs the -mrelocatable bit set. */ static boolean @@ -1407,7 +1429,7 @@ ppc_elf_merge_private_bfd_data (ibfd, obfd) boolean error; /* Check if we have the same endianess */ - if (_bfd_generic_verify_endian_match (ibfd, obfd) == false) + if (! _bfd_generic_verify_endian_match (ibfd, obfd)) return false; if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour @@ -1490,7 +1512,7 @@ static boolean ppc_elf_section_from_shdr (abfd, hdr, name) bfd *abfd; Elf32_Internal_Shdr *hdr; - char *name; + const char *name; { asection *newsect; flagword flags; @@ -2459,8 +2481,8 @@ ppc_elf_check_relocs (abfd, info, sec, relocs) relocation. */ static asection * -ppc_elf_gc_mark_hook (abfd, info, rel, h, sym) - bfd *abfd; +ppc_elf_gc_mark_hook (sec, info, rel, h, sym) + asection *sec; struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; @@ -2490,9 +2512,7 @@ ppc_elf_gc_mark_hook (abfd, info, rel, h, sym) } } else - { - return bfd_section_from_elf_index (abfd, sym->st_shndx); - } + return bfd_section_from_elf_index (sec->owner, sym->st_shndx); return NULL; } @@ -2723,11 +2743,11 @@ ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym) else { BFD_ASSERT ((h->got.offset & 1) == 0); - bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset); rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_GLOB_DAT); rela.r_addend = 0; } + bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset); bfd_elf32_swap_reloca_out (output_bfd, &rela, ((Elf32_External_Rela *) srela->contents + srela->reloc_count)); @@ -3267,13 +3287,19 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, + sreloc->reloc_count)); ++sreloc->reloc_count; - /* This reloc will be computed at runtime, so there's no - need to do anything now, unless this is a RELATIVE - reloc in an unallocated section. */ - if (skip != -1 - || (input_section->flags & SEC_ALLOC) != 0 - || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE) + if (skip == -1) continue; + + /* This reloc will be computed at runtime. We clear the memory + so that it contains predictable value. */ + if (! skip + && ((input_section->flags & SEC_ALLOC) != 0 + || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE)) + { + relocation = howto->pc_relative ? outrel.r_offset : 0; + addend = 0; + break; + } } /* Arithmetic adjust relocations that aren't going into a @@ -3370,7 +3396,6 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, off &= ~1; else { - bfd_put_32 (output_bfd, relocation, sgot->contents + off); if (info->shared) { @@ -3392,8 +3417,10 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, srelgot->contents) + srelgot->reloc_count)); ++srelgot->reloc_count; + relocation = 0; } + bfd_put_32 (output_bfd, relocation, sgot->contents + off); local_got_offsets[r_symndx] |= 1; } @@ -3797,6 +3824,7 @@ ppc_elf_grok_psinfo (abfd, note) #define bfd_elf32_bfd_set_private_flags ppc_elf_set_private_flags #define bfd_elf32_bfd_final_link _bfd_elf32_gc_common_final_link +#define elf_backend_object_p ppc_elf_object_p #define elf_backend_gc_mark_hook ppc_elf_gc_mark_hook #define elf_backend_gc_sweep_hook ppc_elf_gc_sweep_hook #define elf_backend_section_from_shdr ppc_elf_section_from_shdr diff --git a/contrib/binutils/bfd/elf32-sparc.c b/contrib/binutils/bfd/elf32-sparc.c index a11db81..38200dc 100644 --- a/contrib/binutils/bfd/elf32-sparc.c +++ b/contrib/binutils/bfd/elf32-sparc.c @@ -1,5 +1,5 @@ /* SPARC-specific support for 32-bit ELF - Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -55,7 +55,7 @@ static void elf32_sparc_final_write_processing static enum elf_reloc_type_class elf32_sparc_reloc_type_class PARAMS ((const Elf_Internal_Rela *)); static asection * elf32_sparc_gc_mark_hook - PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, + PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *)); static boolean elf32_sparc_gc_sweep_hook PARAMS ((bfd *, struct bfd_link_info *, asection *, @@ -637,14 +637,13 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs) } static asection * -elf32_sparc_gc_mark_hook (abfd, info, rel, h, sym) - bfd *abfd; +elf32_sparc_gc_mark_hook (sec, info, rel, h, sym) + asection *sec; struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; { - if (h != NULL) { switch (ELF32_R_TYPE (rel->r_info)) @@ -669,9 +668,7 @@ elf32_sparc_gc_mark_hook (abfd, info, rel, h, sym) } } else - { - return bfd_section_from_elf_index (abfd, sym->st_shndx); - } + return bfd_section_from_elf_index (sec->owner, sym->st_shndx); return NULL; } @@ -1564,10 +1561,11 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, break; } - /* ??? Copied from elf32-i386.c, debugging section check and all. */ + /* Dynamic relocs are not propagated for SEC_DEBUGGING sections + because such sections are not SEC_ALLOC and thus ld.so will + not process them. */ if (unresolved_reloc - && !(info->shared - && (input_section->flags & SEC_DEBUGGING) != 0 + && !((input_section->flags & SEC_DEBUGGING) != 0 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) (*_bfd_error_handler) (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"), diff --git a/contrib/binutils/bfd/elf64-alpha.c b/contrib/binutils/bfd/elf64-alpha.c index a24a70c..e1d095d 100644 --- a/contrib/binutils/bfd/elf64-alpha.c +++ b/contrib/binutils/bfd/elf64-alpha.c @@ -73,7 +73,7 @@ static boolean elf64_alpha_mkobject static boolean elf64_alpha_object_p PARAMS((bfd *)); static boolean elf64_alpha_section_from_shdr - PARAMS((bfd *, Elf64_Internal_Shdr *, char *)); + PARAMS((bfd *, Elf64_Internal_Shdr *, const char *)); static boolean elf64_alpha_section_flags PARAMS((flagword *, Elf64_Internal_Shdr *)); static boolean elf64_alpha_fake_sections @@ -106,14 +106,27 @@ static boolean elf64_alpha_calc_got_offsets_for_symbol PARAMS ((struct alpha_elf_link_hash_entry *, PTR)); static void elf64_alpha_calc_got_offsets PARAMS ((struct bfd_link_info *)); static boolean elf64_alpha_size_got_sections - PARAMS ((bfd *, struct bfd_link_info *)); + PARAMS ((struct bfd_link_info *)); +static boolean elf64_alpha_size_plt_section + PARAMS ((struct bfd_link_info *)); +static boolean elf64_alpha_size_plt_section_1 + PARAMS ((struct alpha_elf_link_hash_entry *, PTR)); static boolean elf64_alpha_always_size_sections PARAMS ((bfd *, struct bfd_link_info *)); +static int alpha_dynamic_entries_for_reloc + PARAMS ((int, int, int)); static boolean elf64_alpha_calc_dynrel_sizes PARAMS ((struct alpha_elf_link_hash_entry *, struct bfd_link_info *)); +static boolean elf64_alpha_size_rela_got_section + PARAMS ((struct bfd_link_info *)); +static boolean elf64_alpha_size_rela_got_1 + PARAMS ((struct alpha_elf_link_hash_entry *, struct bfd_link_info *)); static boolean elf64_alpha_add_symbol_hook PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, const char **, flagword *, asection **, bfd_vma *)); +static struct alpha_elf_got_entry *get_got_entry + PARAMS ((bfd *, struct alpha_elf_link_hash_entry *, unsigned long, + unsigned long, bfd_vma)); static boolean elf64_alpha_check_relocs PARAMS((bfd *, struct bfd_link_info *, asection *sec, const Elf_Internal_Rela *)); @@ -121,6 +134,9 @@ static boolean elf64_alpha_adjust_dynamic_symbol PARAMS((struct bfd_link_info *, struct elf_link_hash_entry *)); static boolean elf64_alpha_size_dynamic_sections PARAMS((bfd *, struct bfd_link_info *)); +static boolean elf64_alpha_relocate_section_r + PARAMS((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, + Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); static boolean elf64_alpha_relocate_section PARAMS((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); @@ -148,11 +164,15 @@ struct alpha_elf_link_hash_entry /* Cumulative flags for all the .got entries. */ int flags; - /* Contexts (LITUSE) in which a literal was referenced. */ -#define ALPHA_ELF_LINK_HASH_LU_ADDR 0x01 -#define ALPHA_ELF_LINK_HASH_LU_MEM 0x02 -#define ALPHA_ELF_LINK_HASH_LU_BYTE 0x04 -#define ALPHA_ELF_LINK_HASH_LU_FUNC 0x08 + /* Contexts in which a literal was referenced. */ +#define ALPHA_ELF_LINK_HASH_LU_ADDR 0x01 +#define ALPHA_ELF_LINK_HASH_LU_MEM 0x02 +#define ALPHA_ELF_LINK_HASH_LU_BYTE 0x04 +#define ALPHA_ELF_LINK_HASH_LU_JSR 0x08 +#define ALPHA_ELF_LINK_HASH_LU_TLSGD 0x10 +#define ALPHA_ELF_LINK_HASH_LU_TLSLDM 0x20 +#define ALPHA_ELF_LINK_HASH_LU_FUNC 0x38 +#define ALPHA_ELF_LINK_HASH_TLS_IE 0x40 /* Used to implement multiple .got subsections. */ struct alpha_elf_got_entry @@ -168,13 +188,20 @@ struct alpha_elf_link_hash_entry /* the .got offset for this entry. */ int got_offset; - int flags; + /* How many references to this entry? */ + int use_count; - /* Additional flags. */ -#define ALPHA_ELF_GOT_ENTRY_RELOCS_DONE 0x10 -#define ALPHA_ELF_GOT_ENTRY_RELOCS_XLATED 0x20 + /* The relocation type of this entry. */ + unsigned char reloc_type; - int use_count; + /* How a LITERAL is used. */ + unsigned char flags; + + /* Have we initialized the dynamic relocation for this entry? */ + unsigned char reloc_done; + + /* Have we adjusted this entry for SEC_MERGE? */ + unsigned char reloc_xlated; } *got_entries; /* used to count non-got, non-plt relocations for delayed sizing @@ -324,14 +351,14 @@ elf64_alpha_bfd_link_hash_table_create (abfd) struct alpha_elf_link_hash_table *ret; bfd_size_type amt = sizeof (struct alpha_elf_link_hash_table); - ret = (struct alpha_elf_link_hash_table *) bfd_zalloc (abfd, amt); + ret = (struct alpha_elf_link_hash_table *) bfd_zmalloc (amt); if (ret == (struct alpha_elf_link_hash_table *) NULL) return NULL; if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, elf64_alpha_link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return NULL; } @@ -361,12 +388,12 @@ struct alpha_elf_obj_tdata /* For every got, this is the section. */ asection *got; - /* For every got, this is it's total number of *entries*. */ - int total_got_entries; + /* For every got, this is it's total number of words. */ + int total_got_size; - /* For every got, this is the sum of the number of *entries* required + /* For every got, this is the sum of the number of words required to hold all of the member object's local got. */ - int n_local_got_entries; + int local_got_size; }; #define alpha_elf_tdata(abfd) \ @@ -748,6 +775,203 @@ static reloc_howto_type elf64_alpha_howto_table[] = 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ true), /* pcrel_offset */ + + /* Creates a tls_index for the symbol in the got. */ + HOWTO (R_ALPHA_TLSGD, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "TLSGD", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* Creates a tls_index for the (current) module in the got. */ + HOWTO (R_ALPHA_TLSLDM, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "TLSLDM", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A dynamic relocation for a DTP module entry. */ + HOWTO (R_ALPHA_DTPMOD64, /* type */ + 0, /* rightshift */ + 4, /* size (0 = byte, 1 = short, 2 = long) */ + 64, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + 0, /* special_function */ + "DTPMOD64", /* name */ + false, /* partial_inplace */ + MINUS_ONE, /* src_mask */ + MINUS_ONE, /* dst_mask */ + false), /* pcrel_offset */ + + /* Creates a 64-bit offset in the got for the displacement + from DTP to the target. */ + HOWTO (R_ALPHA_GOTDTPREL, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "GOTDTPREL", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A dynamic relocation for a displacement from DTP to the target. */ + HOWTO (R_ALPHA_DTPREL64, /* type */ + 0, /* rightshift */ + 4, /* size (0 = byte, 1 = short, 2 = long) */ + 64, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + 0, /* special_function */ + "DTPREL64", /* name */ + false, /* partial_inplace */ + MINUS_ONE, /* src_mask */ + MINUS_ONE, /* dst_mask */ + false), /* pcrel_offset */ + + /* The high 16 bits of the displacement from DTP to the target. */ + HOWTO (R_ALPHA_DTPRELHI, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "DTPRELHI", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* The low 16 bits of the displacement from DTP to the target. */ + HOWTO (R_ALPHA_DTPRELLO, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + 0, /* special_function */ + "DTPRELLO", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A 16-bit displacement from DTP to the target. */ + HOWTO (R_ALPHA_DTPREL16, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "DTPREL16", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* Creates a 64-bit offset in the got for the displacement + from TP to the target. */ + HOWTO (R_ALPHA_GOTTPREL, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "GOTTPREL", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A dynamic relocation for a displacement from TP to the target. */ + HOWTO (R_ALPHA_TPREL64, /* type */ + 0, /* rightshift */ + 4, /* size (0 = byte, 1 = short, 2 = long) */ + 64, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + 0, /* special_function */ + "TPREL64", /* name */ + false, /* partial_inplace */ + MINUS_ONE, /* src_mask */ + MINUS_ONE, /* dst_mask */ + false), /* pcrel_offset */ + + /* The high 16 bits of the displacement from TP to the target. */ + HOWTO (R_ALPHA_TPRELHI, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "TPRELHI", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* The low 16 bits of the displacement from TP to the target. */ + HOWTO (R_ALPHA_TPRELLO, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + 0, /* special_function */ + "TPRELLO", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A 16-bit displacement from TP to the target. */ + HOWTO (R_ALPHA_TPREL16, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "TPREL16", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ }; /* A relocation function which doesn't do anything. */ @@ -902,6 +1126,19 @@ static const struct elf_reloc_map elf64_alpha_reloc_map[] = {BFD_RELOC_ALPHA_GPREL_LO16, R_ALPHA_GPRELLOW}, {BFD_RELOC_GPREL16, R_ALPHA_GPREL16}, {BFD_RELOC_ALPHA_BRSGP, R_ALPHA_BRSGP}, + {BFD_RELOC_ALPHA_TLSGD, R_ALPHA_TLSGD}, + {BFD_RELOC_ALPHA_TLSLDM, R_ALPHA_TLSLDM}, + {BFD_RELOC_ALPHA_DTPMOD64, R_ALPHA_DTPMOD64}, + {BFD_RELOC_ALPHA_GOTDTPREL16, R_ALPHA_GOTDTPREL}, + {BFD_RELOC_ALPHA_DTPREL64, R_ALPHA_DTPREL64}, + {BFD_RELOC_ALPHA_DTPREL_HI16, R_ALPHA_DTPRELHI}, + {BFD_RELOC_ALPHA_DTPREL_LO16, R_ALPHA_DTPRELLO}, + {BFD_RELOC_ALPHA_DTPREL16, R_ALPHA_DTPREL16}, + {BFD_RELOC_ALPHA_GOTTPREL16, R_ALPHA_GOTTPREL}, + {BFD_RELOC_ALPHA_TPREL64, R_ALPHA_TPREL64}, + {BFD_RELOC_ALPHA_TPREL_HI16, R_ALPHA_TPRELHI}, + {BFD_RELOC_ALPHA_TPREL_LO16, R_ALPHA_TPRELLO}, + {BFD_RELOC_ALPHA_TPREL16, R_ALPHA_TPREL16}, }; /* Given a BFD reloc type, return a HOWTO structure. */ @@ -936,6 +1173,19 @@ elf64_alpha_info_to_howto (abfd, cache_ptr, dst) BFD_ASSERT (r_type < (unsigned int) R_ALPHA_max); cache_ptr->howto = &elf64_alpha_howto_table[r_type]; } + +/* These two relocations create a two-word entry in the got. */ +#define alpha_got_entry_size(r_type) \ + (r_type == R_ALPHA_TLSGD || r_type == R_ALPHA_TLSLDM ? 16 : 8) + +/* This is PT_TLS segment p_vaddr. */ +#define alpha_get_dtprel_base(tlss) \ + ((tlss)->start) + +/* Main program TLS (whose template starts at PT_TLS p_vaddr) + is assigned offset round(16, PT_TLS p_align). */ +#define alpha_get_tprel_base(tlss) \ + ((tlss)->start - align_power ((bfd_vma) 16, (tlss)->align)) /* These functions do relaxation for Alpha ELF. @@ -958,35 +1208,45 @@ elf64_alpha_info_to_howto (abfd, cache_ptr, dst) #define OP_BR 0x30 #define OP_BSR 0x34 #define INSN_UNOP 0x2ffe0000 +#define INSN_ADDQ 0x40000400 +#define INSN_RDUNIQ 0x0000009e struct alpha_relax_info { bfd *abfd; asection *sec; bfd_byte *contents; + Elf_Internal_Shdr *symtab_hdr; Elf_Internal_Rela *relocs, *relend; struct bfd_link_info *link_info; - boolean changed_contents; - boolean changed_relocs; + struct elf_link_tls_segment *tls_segment; bfd_vma gp; bfd *gotobj; asection *tsec; struct alpha_elf_link_hash_entry *h; + struct alpha_elf_got_entry **first_gotent; struct alpha_elf_got_entry *gotent; + boolean changed_contents; + boolean changed_relocs; unsigned char other; }; -static Elf_Internal_Rela * elf64_alpha_relax_with_lituse - PARAMS((struct alpha_relax_info *info, bfd_vma symval, - Elf_Internal_Rela *irel, Elf_Internal_Rela *irelend)); - -static boolean elf64_alpha_relax_without_lituse +static boolean elf64_alpha_relax_with_lituse PARAMS((struct alpha_relax_info *info, bfd_vma symval, Elf_Internal_Rela *irel)); - static bfd_vma elf64_alpha_relax_opt_call PARAMS((struct alpha_relax_info *info, bfd_vma symval)); - +static boolean elf64_alpha_relax_got_load + PARAMS((struct alpha_relax_info *info, bfd_vma symval, + Elf_Internal_Rela *irel, unsigned long)); +static boolean elf64_alpha_relax_gprelhilo + PARAMS((struct alpha_relax_info *info, bfd_vma symval, + Elf_Internal_Rela *irel, boolean)); +static boolean elf64_alpha_relax_tls_get_addr + PARAMS((struct alpha_relax_info *info, bfd_vma symval, + Elf_Internal_Rela *irel, boolean)); +static struct elf_link_tls_segment *elf64_alpha_relax_find_tls_segment + PARAMS((struct alpha_relax_info *, struct elf_link_tls_segment *)); static boolean elf64_alpha_relax_section PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info, boolean *again)); @@ -1007,13 +1267,13 @@ elf64_alpha_find_reloc_at_ofs (rel, relend, offset, type) return NULL; } -static Elf_Internal_Rela * -elf64_alpha_relax_with_lituse (info, symval, irel, irelend) +static boolean +elf64_alpha_relax_with_lituse (info, symval, irel) struct alpha_relax_info *info; bfd_vma symval; - Elf_Internal_Rela *irel, *irelend; + Elf_Internal_Rela *irel; { - Elf_Internal_Rela *urel; + Elf_Internal_Rela *urel, *irelend = info->relend; int flags, count, i; bfd_signed_vma disp; boolean fits16; @@ -1029,9 +1289,13 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) ("%s: %s+0x%lx: warning: LITERAL relocation against unexpected insn", bfd_archive_filename (info->abfd), info->sec->name, (unsigned long) irel->r_offset)); - return irel; + return true; } + /* Can't relax dynamic symbols. */ + if (alpha_elf_dynamic_symbol_p (&info->h->root, info->link_info)) + return true; + /* Summarize how this particular LITERAL is used. */ for (urel = irel+1, flags = count = 0; urel < irelend; ++urel, ++count) { @@ -1054,25 +1318,27 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) switch (urel->r_addend) { - default: /* 0 = ADDRESS FORMAT */ + case LITUSE_ALPHA_ADDR: + default: /* This type is really just a placeholder to note that all uses cannot be optimized, but to still allow some. */ all_optimized = false; break; - case 1: /* MEM FORMAT */ + case LITUSE_ALPHA_BASE: /* We can always optimize 16-bit displacements. */ /* Extract the displacement from the instruction, sign-extending it if necessary, then test whether it is within 16 or 32 bits displacement from GP. */ insn_disp = insn & 0x0000ffff; - if (insn_disp & 0x00008000) - insn_disp |= 0xffff0000; /* Negative: sign-extend. */ + if (insn_disp & 0x8000) + insn_disp |= ~0xffff; /* Negative: sign-extend. */ xdisp = disp + insn_disp; - fits16 = (xdisp >= - (bfd_signed_vma) 0x00008000 && xdisp < 0x00008000); - fits32 = (xdisp >= - (bfd_signed_vma) 0x80000000 && xdisp < 0x7fff8000); + fits16 = (xdisp >= - (bfd_signed_vma) 0x8000 && xdisp < 0x8000); + fits32 = (xdisp >= - (bfd_signed_vma) 0x80000000 + && xdisp < 0x7fff8000); if (fits16) { @@ -1111,7 +1377,7 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) all_optimized = false; break; - case 2: /* BYTE OFFSET FORMAT */ + case LITUSE_ALPHA_BYTOFF: /* We can always optimize byte instructions. */ /* FIXME: sanity check the insn for byte op. Check that the @@ -1129,16 +1395,20 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) info->changed_contents = true; break; - case 3: /* CALL FORMAT */ + case LITUSE_ALPHA_JSR: + case LITUSE_ALPHA_TLSGD: + case LITUSE_ALPHA_TLSLDM: { - /* If not zero, place to jump without needing pv. */ - bfd_vma optdest = elf64_alpha_relax_opt_call (info, symval); - bfd_vma org = (info->sec->output_section->vma - + info->sec->output_offset - + urel->r_offset + 4); + bfd_vma optdest, org; bfd_signed_vma odisp; + /* If not zero, place to jump without needing pv. */ + optdest = elf64_alpha_relax_opt_call (info, symval); + org = (info->sec->output_section->vma + + info->sec->output_offset + + urel->r_offset + 4); odisp = (optdest ? optdest : symval) - org; + if (odisp >= -0x400000 && odisp < 0x400000) { Elf_Internal_Rela *xrel; @@ -1180,10 +1450,11 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) { Elf_Internal_Rela *gpdisp = (elf64_alpha_find_reloc_at_ofs - (irel, irelend, urel->r_offset + 4, R_ALPHA_GPDISP)); + (info->relocs, irelend, urel->r_offset + 4, + R_ALPHA_GPDISP)); if (gpdisp) { - bfd_byte *p_ldah = info->contents + gpdisp->r_offset; + bfd_byte *p_ldah = info->contents + gpdisp->r_offset; bfd_byte *p_lda = p_ldah + gpdisp->r_addend; unsigned int ldah = bfd_get_32 (info->abfd, p_ldah); unsigned int lda = bfd_get_32 (info->abfd, p_lda); @@ -1213,14 +1484,17 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) got entry by one, possibly eliminating it. */ if (all_optimized) { - info->gotent->use_count -= 1; - alpha_elf_tdata (info->gotent->gotobj)->total_got_entries -= 1; - if (!info->h) - alpha_elf_tdata (info->gotent->gotobj)->n_local_got_entries -= 1; + if (--info->gotent->use_count == 0) + { + int sz = alpha_got_entry_size (R_ALPHA_LITERAL); + alpha_elf_tdata (info->gotobj)->total_got_size -= sz; + if (!info->h) + alpha_elf_tdata (info->gotobj)->local_got_size -= sz; + } /* If the literal instruction is no longer needed (it may have been - reused. We can eliminate it. - ??? For now, I don't want to deal with compacting the section, + reused. We can eliminate it. */ + /* ??? For now, I don't want to deal with compacting the section, so just nop it out. */ if (!lit_reused) { @@ -1233,7 +1507,7 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) } } - return irel + count; + return true; } static bfd_vma @@ -1309,10 +1583,11 @@ elf64_alpha_relax_opt_call (info, symval) } static boolean -elf64_alpha_relax_without_lituse (info, symval, irel) +elf64_alpha_relax_got_load (info, symval, irel, r_type) struct alpha_relax_info *info; bfd_vma symval; Elf_Internal_Rela *irel; + unsigned long r_type; { unsigned int insn; bfd_signed_vma disp; @@ -1322,37 +1597,74 @@ elf64_alpha_relax_without_lituse (info, symval, irel) if (insn >> 26 != OP_LDQ) { + reloc_howto_type *howto = elf64_alpha_howto_table + r_type; ((*_bfd_error_handler) - ("%s: %s+0x%lx: warning: LITERAL relocation against unexpected insn", + ("%s: %s+0x%lx: warning: %s relocation against unexpected insn", bfd_archive_filename (info->abfd), info->sec->name, - (unsigned long) irel->r_offset)); + (unsigned long) irel->r_offset, howto->name)); return true; } - /* So we aren't told much. Do what we can with the address load and - fake the rest. All of the optimizations here require that the - offset from the GP fit in 16 bits. */ + /* Can't relax dynamic symbols. */ + if (alpha_elf_dynamic_symbol_p (&info->h->root, info->link_info)) + return true; - disp = symval - info->gp; - if (disp < -0x8000 || disp >= 0x8000) + /* Can't use local-exec relocations in shared libraries. */ + if (r_type == R_ALPHA_GOTTPREL && info->link_info->shared) return true; - /* On the LITERAL instruction itself, consider exchanging - `ldq R,X(gp)' for `lda R,Y(gp)'. */ + if (r_type == R_ALPHA_LITERAL) + disp = symval - info->gp; + else + { + bfd_vma dtp_base, tp_base; + + BFD_ASSERT (info->tls_segment != NULL); + dtp_base = alpha_get_dtprel_base (info->tls_segment); + tp_base = alpha_get_tprel_base (info->tls_segment); + disp = symval - (r_type == R_ALPHA_GOTDTPREL ? dtp_base : tp_base); + } - insn = (OP_LDA << 26) | (insn & 0x03ff0000); + if (disp < -0x8000 || disp >= 0x8000) + return true; + + /* Exchange LDQ for LDA. In the case of the TLS relocs, we're loading + a constant, so force the base register to be $31. */ + if (r_type == R_ALPHA_LITERAL) + insn = (OP_LDA << 26) | (insn & 0x03ff0000); + else + insn = (OP_LDA << 26) | (insn & (31 << 21)) | (31 << 16); bfd_put_32 (info->abfd, (bfd_vma) insn, info->contents + irel->r_offset); info->changed_contents = true; - irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), R_ALPHA_GPREL16); + switch (r_type) + { + case R_ALPHA_LITERAL: + r_type = R_ALPHA_GPREL16; + break; + case R_ALPHA_GOTDTPREL: + r_type = R_ALPHA_DTPREL16; + break; + case R_ALPHA_GOTTPREL: + r_type = R_ALPHA_TPREL16; + break; + default: + BFD_ASSERT (0); + return false; + } + + irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), r_type); info->changed_relocs = true; /* Reduce the use count on this got entry by one, possibly eliminating it. */ - info->gotent->use_count -= 1; - alpha_elf_tdata (info->gotent->gotobj)->total_got_entries -= 1; - if (!info->h) - alpha_elf_tdata (info->gotent->gotobj)->n_local_got_entries -= 1; + if (--info->gotent->use_count == 0) + { + int sz = alpha_got_entry_size (r_type); + alpha_elf_tdata (info->gotobj)->total_got_size -= sz; + if (!info->h) + alpha_elf_tdata (info->gotobj)->local_got_size -= sz; + } /* ??? Search forward through this basic block looking for insns that use the target register. Stop after an insn modifying the @@ -1371,6 +1683,353 @@ elf64_alpha_relax_without_lituse (info, symval, irel) } static boolean +elf64_alpha_relax_gprelhilo (info, symval, irel, hi) + struct alpha_relax_info *info; + bfd_vma symval; + Elf_Internal_Rela *irel; + boolean hi; +{ + unsigned int insn; + bfd_signed_vma disp; + bfd_byte *pos = info->contents + irel->r_offset; + + /* ??? This assumes that the compiler doesn't render + + array[i] + as + ldah t, array(gp) !gprelhigh + s8addl i, t, t + ldq r, array(t) !gprellow + + which would indeed be the most efficient way to implement this. */ + + return true; + + disp = symval - info->gp; + if (disp < -0x8000 || disp >= 0x8000) + return true; + + if (hi) + { + /* Nop out the high instruction. */ + + bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos); + info->changed_contents = true; + + irel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE); + irel->r_addend = 0; + info->changed_relocs = true; + } + else + { + /* Adjust the low instruction to reference GP directly. */ + + insn = bfd_get_32 (info->abfd, pos); + insn = (insn & 0xffe00000) | (29 << 16); + bfd_put_32 (info->abfd, (bfd_vma) insn, pos); + info->changed_contents = true; + + irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), + R_ALPHA_GPREL16); + info->changed_relocs = true; + } + + return true; +} + +static boolean +elf64_alpha_relax_tls_get_addr (info, symval, irel, is_gd) + struct alpha_relax_info *info; + bfd_vma symval; + Elf_Internal_Rela *irel; + boolean is_gd; +{ + bfd_byte *pos[5]; + unsigned int insn; + Elf_Internal_Rela *gpdisp, *hint; + boolean dynamic, use_gottprel; + + dynamic = alpha_elf_dynamic_symbol_p (&info->h->root, info->link_info); + + /* ??? For LD relaxation, we need a symbol referencing the beginning + of the TLS segment. */ + if (!is_gd) + return true; + + /* If a TLS symbol is accessed using IE at least once, there is no point + to use dynamic model for it. */ + if (is_gd && info->h && (info->h->flags & ALPHA_ELF_LINK_HASH_TLS_IE)) + ; + + /* If the symbol is local, and we've already committed to DF_STATIC_TLS, + then we might as well relax to IE. */ + else if (info->link_info->shared && !dynamic + && (info->link_info->flags & DF_STATIC_TLS)) + ; + + /* Otherwise we must be building an executable to do anything. */ + else if (info->link_info->shared) + return true; + + /* The TLSGD/TLSLDM relocation must be followed by a LITERAL and + the matching LITUSE_TLS relocations. */ + if (irel + 2 >= info->relend) + return true; + if (ELF64_R_TYPE (irel[1].r_info) != R_ALPHA_LITERAL + || ELF64_R_TYPE (irel[2].r_info) != R_ALPHA_LITUSE + || irel[2].r_addend != (is_gd ? LITUSE_ALPHA_TLSGD : LITUSE_ALPHA_TLSLDM)) + return true; + + /* There must be a GPDISP relocation positioned immediately after the + LITUSE relocation. */ + gpdisp = elf64_alpha_find_reloc_at_ofs (info->relocs, info->relend, + irel[2].r_offset + 4, R_ALPHA_GPDISP); + if (!gpdisp) + return true; + + pos[0] = info->contents + irel[0].r_offset; + pos[1] = info->contents + irel[1].r_offset; + pos[2] = info->contents + irel[2].r_offset; + pos[3] = info->contents + gpdisp->r_offset; + pos[4] = pos[3] + gpdisp->r_addend; + + /* Only positions 0 and 1 are allowed to be out of order. */ + if (pos[1] < pos[0]) + { + bfd_byte *tmp = pos[0]; + pos[0] = pos[1]; + pos[1] = tmp; + } + if (pos[1] >= pos[2] || pos[2] >= pos[3] || pos[3] >= pos[4]) + return true; + + /* Reduce the use count on the LITERAL relocation. Do this before we + smash the symndx when we adjust the relocations below. */ + { + struct alpha_elf_got_entry *lit_gotent; + struct alpha_elf_link_hash_entry *lit_h; + unsigned long indx; + + BFD_ASSERT (ELF64_R_SYM (irel[1].r_info) >= info->symtab_hdr->sh_info); + indx = ELF64_R_SYM (irel[1].r_info) - info->symtab_hdr->sh_info; + lit_h = alpha_elf_sym_hashes (info->abfd)[indx]; + + while (lit_h->root.root.type == bfd_link_hash_indirect + || lit_h->root.root.type == bfd_link_hash_warning) + lit_h = (struct alpha_elf_link_hash_entry *) lit_h->root.root.u.i.link; + + for (lit_gotent = lit_h->got_entries; lit_gotent ; + lit_gotent = lit_gotent->next) + if (lit_gotent->gotobj == info->gotobj + && lit_gotent->reloc_type == R_ALPHA_LITERAL + && lit_gotent->addend == irel[1].r_addend) + break; + BFD_ASSERT (lit_gotent); + + if (--lit_gotent->use_count == 0) + { + int sz = alpha_got_entry_size (R_ALPHA_LITERAL); + alpha_elf_tdata (info->gotobj)->total_got_size -= sz; + } + } + + /* Change + + lda $16,x($gp) !tlsgd!1 + ldq $27,__tls_get_addr($gp) !literal!1 + jsr $26,($27)__tls_get_addr !lituse_tlsgd!1 + ldah $29,0($26) !gpdisp!2 + lda $29,0($29) !gpdisp!2 + to + ldq $16,x($gp) !gottprel + unop + call_pal rduniq + addq $16,$0,$0 + unop + or the first pair to + lda $16,x($gp) !tprel + unop + or + ldah $16,x($gp) !tprelhi + lda $16,x($16) !tprello + + as appropriate. */ + + use_gottprel = false; + switch (!dynamic && !info->link_info->shared) + { + case 1: + { + bfd_vma tp_base; + bfd_signed_vma disp; + + BFD_ASSERT (info->tls_segment != NULL); + tp_base = alpha_get_tprel_base (info->tls_segment); + disp = symval - tp_base; + + if (disp >= -0x8000 && disp < 0x8000) + { + insn = (OP_LDA << 26) | (16 << 21) | (31 << 16); + bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]); + bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[1]); + + irel[0].r_offset = pos[0] - info->contents; + irel[0].r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), + R_ALPHA_TPREL16); + irel[1].r_info = ELF64_R_INFO (0, R_ALPHA_NONE); + break; + } + else if (disp >= -(bfd_signed_vma) 0x80000000 + && disp < (bfd_signed_vma) 0x7fff8000) + { + insn = (OP_LDAH << 26) | (16 << 21) | (31 << 16); + bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]); + insn = (OP_LDA << 26) | (16 << 21) | (16 << 16); + bfd_put_32 (info->abfd, (bfd_vma) insn, pos[1]); + + irel[0].r_offset = pos[0] - info->contents; + irel[0].r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), + R_ALPHA_TPRELHI); + irel[1].r_offset = pos[1] - info->contents; + irel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), + R_ALPHA_TPRELLO); + break; + } + } + /* FALLTHRU */ + + default: + use_gottprel = true; + + insn = (OP_LDQ << 26) | (16 << 21) | (29 << 16); + bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]); + bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[1]); + + irel[0].r_offset = pos[0] - info->contents; + irel[0].r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), + R_ALPHA_GOTTPREL); + irel[1].r_info = ELF64_R_INFO (0, R_ALPHA_NONE); + break; + } + + bfd_put_32 (info->abfd, (bfd_vma) INSN_RDUNIQ, pos[2]); + + insn = INSN_ADDQ | (16 << 21) | (0 << 16) | (0 << 0); + bfd_put_32 (info->abfd, (bfd_vma) insn, pos[3]); + + bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[4]); + + irel[2].r_info = ELF64_R_INFO (0, R_ALPHA_NONE); + gpdisp->r_info = ELF64_R_INFO (0, R_ALPHA_NONE); + + hint = elf64_alpha_find_reloc_at_ofs (info->relocs, info->relend, + irel[2].r_offset, R_ALPHA_HINT); + if (hint) + hint->r_info = ELF64_R_INFO (0, R_ALPHA_NONE); + + info->changed_contents = true; + info->changed_relocs = true; + + /* Reduce the use count on the TLSGD/TLSLDM relocation. */ + if (--info->gotent->use_count == 0) + { + int sz = alpha_got_entry_size (info->gotent->reloc_type); + alpha_elf_tdata (info->gotobj)->total_got_size -= sz; + if (!info->h) + alpha_elf_tdata (info->gotobj)->local_got_size -= sz; + } + + /* If we've switched to a GOTTPREL relocation, increment the reference + count on that got entry. */ + if (use_gottprel) + { + struct alpha_elf_got_entry *tprel_gotent; + + for (tprel_gotent = *info->first_gotent; tprel_gotent ; + tprel_gotent = tprel_gotent->next) + if (tprel_gotent->gotobj == info->gotobj + && tprel_gotent->reloc_type == R_ALPHA_GOTTPREL + && tprel_gotent->addend == irel->r_addend) + break; + if (tprel_gotent) + tprel_gotent->use_count++; + else + { + if (info->gotent->use_count == 0) + tprel_gotent = info->gotent; + else + { + tprel_gotent = (struct alpha_elf_got_entry *) + bfd_alloc (info->abfd, sizeof (struct alpha_elf_got_entry)); + if (!tprel_gotent) + return false; + + tprel_gotent->next = *info->first_gotent; + *info->first_gotent = tprel_gotent; + + tprel_gotent->gotobj = info->gotobj; + tprel_gotent->addend = irel->r_addend; + tprel_gotent->got_offset = -1; + tprel_gotent->reloc_done = 0; + tprel_gotent->reloc_xlated = 0; + } + + tprel_gotent->use_count = 1; + tprel_gotent->reloc_type = R_ALPHA_GOTTPREL; + } + } + + return true; +} + +static struct elf_link_tls_segment * +elf64_alpha_relax_find_tls_segment (info, seg) + struct alpha_relax_info *info; + struct elf_link_tls_segment *seg; +{ + bfd *output_bfd = info->sec->output_section->owner; + asection *o; + unsigned int align; + bfd_vma base, end; + + for (o = output_bfd->sections; o ; o = o->next) + if ((o->flags & SEC_THREAD_LOCAL) != 0 + && (o->flags & SEC_LOAD) != 0) + break; + if (!o) + return NULL; + + base = o->vma; + align = 0; + + do + { + bfd_vma size; + + if (bfd_get_section_alignment (output_bfd, o) > align) + align = bfd_get_section_alignment (output_bfd, o); + + size = o->_raw_size; + if (size == 0 && (o->flags & SEC_HAS_CONTENTS) == 0) + { + struct bfd_link_order *lo; + for (lo = o->link_order_head; lo ; lo = lo->next) + if (size < lo->offset + lo->size) + size = lo->offset + lo->size; + } + end = o->vma + size; + o = o->next; + } + while (o && (o->flags & SEC_THREAD_LOCAL)); + + seg->start = base; + seg->size = end - base; + seg->align = align; + + return seg; +} + +static boolean elf64_alpha_relax_section (abfd, sec, link_info, again) bfd *abfd; asection *sec; @@ -1378,16 +2037,12 @@ elf64_alpha_relax_section (abfd, sec, link_info, again) boolean *again; { Elf_Internal_Shdr *symtab_hdr; - Elf_Internal_Shdr *shndx_hdr; Elf_Internal_Rela *internal_relocs; - Elf_Internal_Rela *free_relocs = NULL; Elf_Internal_Rela *irel, *irelend; - bfd_byte *free_contents = NULL; - Elf64_External_Sym *extsyms = NULL; - Elf64_External_Sym *free_extsyms = NULL; - Elf_External_Sym_Shndx *shndx_buf = NULL; + Elf_Internal_Sym *isymbuf = NULL; struct alpha_elf_got_entry **local_got_entries; struct alpha_relax_info info; + struct elf_link_tls_segment tls_segment; /* We are not currently changing any sizes, so only one pass. */ *again = false; @@ -1410,116 +2065,99 @@ elf64_alpha_relax_section (abfd, sec, link_info, again) (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL, link_info->keep_memory)); if (internal_relocs == NULL) - goto error_return; - if (! link_info->keep_memory) - free_relocs = internal_relocs; + return false; memset(&info, 0, sizeof (info)); info.abfd = abfd; info.sec = sec; info.link_info = link_info; + info.symtab_hdr = symtab_hdr; info.relocs = internal_relocs; info.relend = irelend = internal_relocs + sec->reloc_count; - /* Find the GP for this object. */ + /* Find the GP for this object. Do not store the result back via + _bfd_set_gp_value, since this could change again before final. */ info.gotobj = alpha_elf_tdata (abfd)->gotobj; if (info.gotobj) { asection *sgot = alpha_elf_tdata (info.gotobj)->got; - info.gp = _bfd_get_gp_value (info.gotobj); - if (info.gp == 0) - { - info.gp = (sgot->output_section->vma - + sgot->output_offset - + 0x8000); - _bfd_set_gp_value (info.gotobj, info.gp); - } + info.gp = (sgot->output_section->vma + + sgot->output_offset + + 0x8000); + } + + /* Get the section contents. */ + if (elf_section_data (sec)->this_hdr.contents != NULL) + info.contents = elf_section_data (sec)->this_hdr.contents; + else + { + info.contents = (bfd_byte *) bfd_malloc (sec->_raw_size); + if (info.contents == NULL) + goto error_return; + + if (! bfd_get_section_contents (abfd, sec, info.contents, + (file_ptr) 0, sec->_raw_size)) + goto error_return; } + /* Compute the TLS segment information. The version normally found in + elf_hash_table (link_info)->tls_segment isn't built until final_link. + ??? Probably should look into extracting this into a common function. */ + info.tls_segment = elf64_alpha_relax_find_tls_segment (&info, &tls_segment); + for (irel = internal_relocs; irel < irelend; irel++) { bfd_vma symval; - Elf_Internal_Sym isym; struct alpha_elf_got_entry *gotent; + unsigned long r_type = ELF64_R_TYPE (irel->r_info); - if (ELF64_R_TYPE (irel->r_info) != (int) R_ALPHA_LITERAL) - continue; - - /* Get the section contents. */ - if (info.contents == NULL) + /* Early exit for unhandled or unrelaxable relocations. */ + switch (r_type) { - if (elf_section_data (sec)->this_hdr.contents != NULL) - info.contents = elf_section_data (sec)->this_hdr.contents; - else - { - info.contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (info.contents == NULL) - goto error_return; - free_contents = info.contents; - - if (! bfd_get_section_contents (abfd, sec, info.contents, - (file_ptr) 0, sec->_raw_size)) - goto error_return; - } + case R_ALPHA_LITERAL: + case R_ALPHA_GPRELHIGH: + case R_ALPHA_GPRELLOW: + case R_ALPHA_GOTDTPREL: + case R_ALPHA_GOTTPREL: + case R_ALPHA_TLSGD: + case R_ALPHA_TLSLDM: + break; + default: + continue; } - /* Read this BFD's symbols if we haven't done so already. */ - if (extsyms == NULL) + /* Get the value of the symbol referred to by the reloc. */ + if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info) { - bfd_size_type amt; - - if (symtab_hdr->contents != NULL) - extsyms = (Elf64_External_Sym *) symtab_hdr->contents; - else - { - amt = symtab_hdr->sh_info; - amt *= sizeof (Elf64_External_Sym); - extsyms = (Elf64_External_Sym *) bfd_malloc (amt); - if (extsyms == NULL) - goto error_return; - free_extsyms = extsyms; - if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread ((PTR) extsyms, amt, abfd) != amt) - goto error_return; - } + /* A local symbol. */ + Elf_Internal_Sym *isym; - shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; - if (shndx_hdr->sh_size != 0) + /* Read this BFD's local symbols. */ + if (isymbuf == NULL) { - amt = symtab_hdr->sh_info; - amt *= sizeof (Elf_External_Sym_Shndx); - shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (amt); - if (shndx_buf == NULL) - goto error_return; - if (bfd_seek (abfd, shndx_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread ((PTR) shndx_buf, amt, abfd) != amt) + isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents; + if (isymbuf == NULL) + isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr, + symtab_hdr->sh_info, 0, + NULL, NULL, NULL); + if (isymbuf == NULL) goto error_return; } - } - /* Get the value of the symbol referred to by the reloc. */ - if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info) - { - /* A local symbol. */ - Elf64_External_Sym *esym; - Elf_External_Sym_Shndx *shndx; - - esym = extsyms + ELF64_R_SYM (irel->r_info); - shndx = shndx_buf + (shndx_buf ? ELF64_R_SYM (irel->r_info) : 0); - bfd_elf64_swap_symbol_in (abfd, esym, shndx, &isym); - if (isym.st_shndx == SHN_UNDEF) - info.tsec = bfd_und_section_ptr; - else if (isym.st_shndx == SHN_ABS) + isym = isymbuf + ELF64_R_SYM (irel->r_info); + if (isym->st_shndx == SHN_UNDEF) + continue; + else if (isym->st_shndx == SHN_ABS) info.tsec = bfd_abs_section_ptr; - else if (isym.st_shndx == SHN_COMMON) + else if (isym->st_shndx == SHN_COMMON) info.tsec = bfd_com_section_ptr; else - info.tsec = bfd_section_from_elf_index (abfd, isym.st_shndx); + info.tsec = bfd_section_from_elf_index (abfd, isym->st_shndx); info.h = NULL; - info.other = isym.st_other; - gotent = local_got_entries[ELF64_R_SYM(irel->r_info)]; - symval = isym.st_value; + info.other = isym->st_other; + info.first_gotent = &local_got_entries[ELF64_R_SYM(irel->r_info)]; + symval = isym->st_value; } else { @@ -1534,66 +2172,103 @@ elf64_alpha_relax_section (abfd, sec, link_info, again) || h->root.root.type == bfd_link_hash_warning) h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link; - /* We can't do anthing with undefined or dynamic symbols. */ - if (h->root.root.type == bfd_link_hash_undefined - || h->root.root.type == bfd_link_hash_undefweak - || alpha_elf_dynamic_symbol_p (&h->root, link_info)) + /* If the symbol is undefined, we can't do anything with it. */ + if (h->root.root.type == bfd_link_hash_undefweak + || h->root.root.type == bfd_link_hash_undefined) + continue; + + /* If the symbol isn't defined in the current module, again + we can't do anything. */ + if (!(h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) continue; info.h = h; info.tsec = h->root.root.u.def.section; info.other = h->root.other; - gotent = h->got_entries; + info.first_gotent = &h->got_entries; symval = h->root.root.u.def.value; } /* Search for the got entry to be used by this relocation. */ - while (gotent->gotobj != info.gotobj || gotent->addend != irel->r_addend) - gotent = gotent->next; + for (gotent = *info.first_gotent; gotent ; gotent = gotent->next) + if (gotent->gotobj == info.gotobj + && gotent->reloc_type == r_type + && gotent->addend == irel->r_addend) + break; info.gotent = gotent; symval += info.tsec->output_section->vma + info.tsec->output_offset; symval += irel->r_addend; - BFD_ASSERT(info.gotent != NULL); + switch (r_type) + { + case R_ALPHA_LITERAL: + BFD_ASSERT(info.gotent != NULL); - /* If there exist LITUSE relocations immediately following, this - opens up all sorts of interesting optimizations, because we - now know every location that this address load is used. */ + /* If there exist LITUSE relocations immediately following, this + opens up all sorts of interesting optimizations, because we + now know every location that this address load is used. */ + if (irel+1 < irelend + && ELF64_R_TYPE (irel[1].r_info) == R_ALPHA_LITUSE) + { + if (!elf64_alpha_relax_with_lituse (&info, symval, irel)) + goto error_return; + } + else + { + if (!elf64_alpha_relax_got_load (&info, symval, irel, r_type)) + goto error_return; + } + break; - if (irel+1 < irelend && ELF64_R_TYPE (irel[1].r_info) == R_ALPHA_LITUSE) - { - irel = elf64_alpha_relax_with_lituse (&info, symval, irel, irelend); - if (irel == NULL) + case R_ALPHA_GPRELHIGH: + case R_ALPHA_GPRELLOW: + if (!elf64_alpha_relax_gprelhilo (&info, symval, irel, + r_type == R_ALPHA_GPRELHIGH)) goto error_return; - } - else - { - if (!elf64_alpha_relax_without_lituse (&info, symval, irel)) + break; + + case R_ALPHA_GOTDTPREL: + case R_ALPHA_GOTTPREL: + BFD_ASSERT(info.gotent != NULL); + if (!elf64_alpha_relax_got_load (&info, symval, irel, r_type)) goto error_return; + break; + + case R_ALPHA_TLSGD: + case R_ALPHA_TLSLDM: + BFD_ASSERT(info.gotent != NULL); + if (!elf64_alpha_relax_tls_get_addr (&info, symval, irel, + r_type == R_ALPHA_TLSGD)) + goto error_return; + break; } } - if (!elf64_alpha_size_got_sections (abfd, link_info)) + if (!elf64_alpha_size_plt_section (link_info)) + return false; + if (!elf64_alpha_size_got_sections (link_info)) + return false; + if (!elf64_alpha_size_rela_got_section (link_info)) return false; - if (info.changed_relocs) - { - elf_section_data (sec)->relocs = internal_relocs; - } - else if (free_relocs != NULL) + if (isymbuf != NULL + && symtab_hdr->contents != (unsigned char *) isymbuf) { - free (free_relocs); + if (!link_info->keep_memory) + free (isymbuf); + else + { + /* Cache the symbols for elf_link_input_bfd. */ + symtab_hdr->contents = (unsigned char *) isymbuf; + } } - if (info.changed_contents) + if (info.contents != NULL + && elf_section_data (sec)->this_hdr.contents != info.contents) { - elf_section_data (sec)->this_hdr.contents = info.contents; - } - else if (free_contents != NULL) - { - if (! link_info->keep_memory) - free (free_contents); + if (!info.changed_contents && !link_info->keep_memory) + free (info.contents); else { /* Cache the section contents for elf_link_input_bfd. */ @@ -1601,18 +2276,12 @@ elf64_alpha_relax_section (abfd, sec, link_info, again) } } - if (shndx_buf != NULL) - free (shndx_buf); - - if (free_extsyms != NULL) + if (elf_section_data (sec)->relocs != internal_relocs) { - if (! link_info->keep_memory) - free (free_extsyms); + if (!info.changed_relocs) + free (internal_relocs); else - { - /* Cache the symbols for elf_link_input_bfd. */ - symtab_hdr->contents = (unsigned char *) extsyms; - } + elf_section_data (sec)->relocs = internal_relocs; } *again = info.changed_contents || info.changed_relocs; @@ -1620,14 +2289,15 @@ elf64_alpha_relax_section (abfd, sec, link_info, again) return true; error_return: - if (free_relocs != NULL) - free (free_relocs); - if (free_contents != NULL) - free (free_contents); - if (shndx_buf != NULL) - free (shndx_buf); - if (free_extsyms != NULL) - free (free_extsyms); + if (isymbuf != NULL + && symtab_hdr->contents != (unsigned char *) isymbuf) + free (isymbuf); + if (info.contents != NULL + && elf_section_data (sec)->this_hdr.contents != info.contents) + free (info.contents); + if (internal_relocs != NULL + && elf_section_data (sec)->relocs != internal_relocs) + free (internal_relocs); return false; } @@ -1643,7 +2313,7 @@ elf64_alpha_relax_section (abfd, sec, link_info, again) #define PLT_ENTRY_WORD2 0 #define PLT_ENTRY_WORD3 0 -#define MAX_GOT_ENTRIES (64*1024 / 8) +#define MAX_GOT_SIZE (64*1024) #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so" @@ -1656,7 +2326,7 @@ static boolean elf64_alpha_section_from_shdr (abfd, hdr, name) bfd *abfd; Elf64_Internal_Shdr *hdr; - char *name; + const char *name; { asection *newsect; @@ -1908,9 +2578,8 @@ elf64_alpha_read_ecoff_info (abfd, section, debug) if (ext_hdr == NULL && swap->external_hdr_size != 0) goto error_return; - if (bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0, - swap->external_hdr_size) - == false) + if (! bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0, + swap->external_hdr_size)) goto error_return; symhdr = &debug->symbolic_header; @@ -2244,18 +2913,86 @@ elf64_alpha_output_extsym (h, data) return true; } + +/* Search for and possibly create a got entry. */ -/* FIXME: Create a runtime procedure table from the .mdebug section. - -static boolean -mips_elf_create_procedure_table (handle, abfd, info, s, debug) - PTR handle; +static struct alpha_elf_got_entry * +get_got_entry (abfd, h, r_type, r_symndx, r_addend) bfd *abfd; - struct bfd_link_info *info; - asection *s; - struct ecoff_debug_info *debug; -*/ - + struct alpha_elf_link_hash_entry *h; + unsigned long r_type, r_symndx; + bfd_vma r_addend; +{ + struct alpha_elf_got_entry *gotent; + struct alpha_elf_got_entry **slot; + + if (h) + slot = &h->got_entries; + else + { + /* This is a local .got entry -- record for merge. */ + + struct alpha_elf_got_entry **local_got_entries; + + local_got_entries = alpha_elf_tdata(abfd)->local_got_entries; + if (!local_got_entries) + { + bfd_size_type size; + Elf_Internal_Shdr *symtab_hdr; + + symtab_hdr = &elf_tdata(abfd)->symtab_hdr; + size = symtab_hdr->sh_info; + size *= sizeof (struct alpha_elf_got_entry *); + + local_got_entries + = (struct alpha_elf_got_entry **) bfd_zalloc (abfd, size); + if (!local_got_entries) + return NULL; + + alpha_elf_tdata (abfd)->local_got_entries = local_got_entries; + } + + slot = &local_got_entries[r_symndx]; + } + + for (gotent = *slot; gotent ; gotent = gotent->next) + if (gotent->gotobj == abfd + && gotent->reloc_type == r_type + && gotent->addend == r_addend) + break; + + if (!gotent) + { + int entry_size; + bfd_size_type amt; + + amt = sizeof (struct alpha_elf_got_entry); + gotent = (struct alpha_elf_got_entry *) bfd_alloc (abfd, amt); + if (!gotent) + return NULL; + + gotent->gotobj = abfd; + gotent->addend = r_addend; + gotent->got_offset = -1; + gotent->use_count = 1; + gotent->reloc_type = r_type; + gotent->reloc_done = 0; + gotent->reloc_xlated = 0; + + gotent->next = *slot; + *slot = gotent; + + entry_size = alpha_got_entry_size (r_type); + alpha_elf_tdata (abfd)->total_got_size += entry_size; + if (!h) + alpha_elf_tdata(abfd)->local_got_size += entry_size; + } + else + gotent->use_count += 1; + + return gotent; +} + /* Handle dynamic relocations when doing an Alpha ELF link. */ static boolean @@ -2270,9 +3007,8 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) const char *rel_sec_name; Elf_Internal_Shdr *symtab_hdr; struct alpha_elf_link_hash_entry **sym_hashes; - struct alpha_elf_got_entry **local_got_entries; const Elf_Internal_Rela *rel, *relend; - int got_created; + boolean got_created; bfd_size_type amt; if (info->relocateable) @@ -2286,14 +3022,23 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) rel_sec_name = NULL; symtab_hdr = &elf_tdata(abfd)->symtab_hdr; sym_hashes = alpha_elf_sym_hashes(abfd); - local_got_entries = alpha_elf_tdata(abfd)->local_got_entries; - got_created = 0; + got_created = false; relend = relocs + sec->reloc_count; for (rel = relocs; rel < relend; ++rel) { + enum { + NEED_GOT = 1, + NEED_GOT_ENTRY = 2, + NEED_DYNREL = 4 + }; + unsigned long r_symndx, r_type; struct alpha_elf_link_hash_entry *h; + unsigned int gotent_flags; + boolean maybe_dynamic; + unsigned int need; + bfd_vma addend; r_symndx = ELF64_R_SYM (rel->r_info); if (r_symndx < symtab_hdr->sh_info) @@ -2308,125 +3053,40 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) h->root.elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR; } + + /* We can only get preliminary data on whether a symbol is + locally or externally defined, as not all of the input files + have yet been processed. Do something with what we know, as + this may help reduce memory usage and processing time later. */ + maybe_dynamic = false; + if (h && ((info->shared + && (!info->symbolic || info->allow_shlib_undefined)) + || ! (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) + || h->root.root.type == bfd_link_hash_defweak)) + maybe_dynamic = true; + + need = 0; + gotent_flags = 0; r_type = ELF64_R_TYPE (rel->r_info); + addend = rel->r_addend; switch (r_type) { case R_ALPHA_LITERAL: - { - struct alpha_elf_got_entry *gotent; - int flags = 0; - - if (h) - { - /* Search for and possibly create a got entry. */ - for (gotent = h->got_entries; gotent ; gotent = gotent->next) - if (gotent->gotobj == abfd && - gotent->addend == rel->r_addend) - break; - - if (!gotent) - { - amt = sizeof (struct alpha_elf_got_entry); - gotent = ((struct alpha_elf_got_entry *) - bfd_alloc (abfd, amt)); - if (!gotent) - return false; - - gotent->gotobj = abfd; - gotent->addend = rel->r_addend; - gotent->got_offset = -1; - gotent->flags = 0; - gotent->use_count = 1; - - gotent->next = h->got_entries; - h->got_entries = gotent; - - alpha_elf_tdata (abfd)->total_got_entries++; - } - else - gotent->use_count += 1; - } - else - { - /* This is a local .got entry -- record for merge. */ - if (!local_got_entries) - { - bfd_size_type size; - size = symtab_hdr->sh_info; - size *= sizeof (struct alpha_elf_got_entry *); - - local_got_entries = ((struct alpha_elf_got_entry **) - bfd_alloc (abfd, size)); - if (!local_got_entries) - return false; - - memset (local_got_entries, 0, (size_t) size); - alpha_elf_tdata (abfd)->local_got_entries = - local_got_entries; - } - - for (gotent = local_got_entries[ELF64_R_SYM(rel->r_info)]; - gotent != NULL && gotent->addend != rel->r_addend; - gotent = gotent->next) - continue; - if (!gotent) - { - amt = sizeof (struct alpha_elf_got_entry); - gotent = ((struct alpha_elf_got_entry *) - bfd_alloc (abfd, amt)); - if (!gotent) - return false; - - gotent->gotobj = abfd; - gotent->addend = rel->r_addend; - gotent->got_offset = -1; - gotent->flags = 0; - gotent->use_count = 1; - - gotent->next = local_got_entries[ELF64_R_SYM(rel->r_info)]; - local_got_entries[ELF64_R_SYM(rel->r_info)] = gotent; - - alpha_elf_tdata(abfd)->total_got_entries++; - alpha_elf_tdata(abfd)->n_local_got_entries++; - } - else - gotent->use_count += 1; - } - - /* Remember how this literal is used from its LITUSEs. - This will be important when it comes to decide if we can - create a .plt entry for a function symbol. */ - if (rel+1 < relend - && ELF64_R_TYPE (rel[1].r_info) == R_ALPHA_LITUSE) - { - do - { - ++rel; - if (rel->r_addend >= 1 && rel->r_addend <= 3) - flags |= 1 << rel->r_addend; - } - while (rel+1 < relend && - ELF64_R_TYPE (rel[1].r_info) == R_ALPHA_LITUSE); - } - else - { - /* No LITUSEs -- presumably the address is not being - loaded for nothing. */ - flags = ALPHA_ELF_LINK_HASH_LU_ADDR; - } - - gotent->flags |= flags; - if (h) - { - /* Make a guess as to whether a .plt entry will be needed. */ - if ((h->flags |= flags) == ALPHA_ELF_LINK_HASH_LU_FUNC) - h->root.elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; - else - h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; - } - } - /* FALLTHRU */ + need = NEED_GOT | NEED_GOT_ENTRY; + + /* Remember how this literal is used from its LITUSEs. + This will be important when it comes to decide if we can + create a .plt entry for a function symbol. */ + while (++rel < relend && ELF64_R_TYPE (rel->r_info) == R_ALPHA_LITUSE) + if (rel->r_addend >= 1 && rel->r_addend <= 5) + gotent_flags |= 1 << rel->r_addend; + --rel; + + /* No LITUSEs -- presumably the address is used somehow. */ + if (gotent_flags == 0) + gotent_flags = ALPHA_ELF_LINK_HASH_LU_ADDR; + break; case R_ALPHA_GPDISP: case R_ALPHA_GPREL16: @@ -2434,9 +3094,38 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) case R_ALPHA_GPRELHIGH: case R_ALPHA_GPRELLOW: case R_ALPHA_BRSGP: - /* We don't actually use the .got here, but the sections must - be created before the linker maps input sections to output - sections. */ + need = NEED_GOT; + break; + + case R_ALPHA_REFLONG: + case R_ALPHA_REFQUAD: + if (info->shared || maybe_dynamic) + need = NEED_DYNREL; + break; + + case R_ALPHA_TLSGD: + case R_ALPHA_TLSLDM: + case R_ALPHA_GOTDTPREL: + need = NEED_GOT | NEED_GOT_ENTRY; + break; + + case R_ALPHA_GOTTPREL: + need = NEED_GOT | NEED_GOT_ENTRY; + gotent_flags = ALPHA_ELF_LINK_HASH_TLS_IE; + if (info->shared) + info->flags |= DF_STATIC_TLS; + break; + + case R_ALPHA_TPREL64: + if (info->shared || maybe_dynamic) + need = NEED_DYNREL; + if (info->shared) + info->flags |= DF_STATIC_TLS; + break; + } + + if (need & NEED_GOT) + { if (!got_created) { if (!elf64_alpha_create_got_section (abfd, info)) @@ -2450,17 +3139,36 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) got_created = 1; } - break; + } - case R_ALPHA_SREL16: - case R_ALPHA_SREL32: - case R_ALPHA_SREL64: - if (h == NULL) - break; - /* FALLTHRU */ + if (need & NEED_GOT_ENTRY) + { + struct alpha_elf_got_entry *gotent; - case R_ALPHA_REFLONG: - case R_ALPHA_REFQUAD: + gotent = get_got_entry (abfd, h, r_type, r_symndx, addend); + if (!gotent) + return false; + + if (gotent_flags) + { + gotent->flags |= gotent_flags; + if (h) + { + gotent_flags |= h->flags; + h->flags = gotent_flags; + + /* Make a guess as to whether a .plt entry is needed. */ + if ((gotent_flags & ALPHA_ELF_LINK_HASH_LU_FUNC) + && !(gotent_flags & ~ALPHA_ELF_LINK_HASH_LU_FUNC)) + h->root.elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; + else + h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; + } + } + } + + if (need & NEED_DYNREL) + { if (rel_sec_name == NULL) { rel_sec_name = (bfd_elf_string_from_elf_section @@ -2530,15 +3238,15 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) else rent->count++; } - else if (info->shared && (sec->flags & SEC_ALLOC)) + else if (info->shared) { /* If this is a shared library, and the section is to be loaded into memory, we need a RELATIVE reloc. */ sreloc->_raw_size += sizeof (Elf64_External_Rela); - if (sec->flags & SEC_READONLY) + if ((sec->flags & (SEC_READONLY | SEC_ALLOC)) + == (SEC_READONLY | SEC_ALLOC)) info->flags |= DF_TEXTREL; } - break; } } @@ -2570,7 +3278,8 @@ elf64_alpha_adjust_dynamic_symbol (info, h) && ((h->type == STT_FUNC && !(ah->flags & ALPHA_ELF_LINK_HASH_LU_ADDR)) || (h->type == STT_NOTYPE - && ah->flags == ALPHA_ELF_LINK_HASH_LU_FUNC)) + && (ah->flags & ALPHA_ELF_LINK_HASH_LU_FUNC) + && !(ah->flags & ~ALPHA_ELF_LINK_HASH_LU_FUNC))) /* Don't prevent otherwise valid programs from linking by attempting to create a new .got entry somewhere. A Correct Solution would be to add a new .got section to a new object file and let it be merged @@ -2667,8 +3376,13 @@ elf64_alpha_merge_ind_symbols (hi, dummy) { gin = gi->next; for (gs = gsh; gs ; gs = gs->next) - if (gi->gotobj == gs->gotobj && gi->addend == gs->addend) - goto got_found; + if (gi->gotobj == gs->gotobj + && gi->reloc_type == gs->reloc_type + && gi->addend == gs->addend) + { + gi->use_count += gs->use_count; + goto got_found; + } gi->next = hs->got_entries; hs->got_entries = gi; got_found:; @@ -2689,7 +3403,7 @@ elf64_alpha_merge_ind_symbols (hi, dummy) { rin = ri->next; for (rs = rsh; rs ; rs = rs->next) - if (ri->rtype == rs->rtype) + if (ri->rtype == rs->rtype && ri->srel == rs->srel) { rs->count += ri->count; goto found_reloc; @@ -2710,15 +3424,15 @@ static boolean elf64_alpha_can_merge_gots (a, b) bfd *a, *b; { - int total = alpha_elf_tdata (a)->total_got_entries; + int total = alpha_elf_tdata (a)->total_got_size; bfd *bsub; /* Trivial quick fallout test. */ - if (total + alpha_elf_tdata (b)->total_got_entries <= MAX_GOT_ENTRIES) + if (total + alpha_elf_tdata (b)->total_got_size <= MAX_GOT_SIZE) return true; /* By their nature, local .got entries cannot be merged. */ - if ((total += alpha_elf_tdata (b)->n_local_got_entries) > MAX_GOT_ENTRIES) + if ((total += alpha_elf_tdata (b)->local_got_size) > MAX_GOT_SIZE) return false; /* Failing the common trivial comparison, we must effectively @@ -2749,10 +3463,13 @@ elf64_alpha_can_merge_gots (a, b) continue; for (ae = h->got_entries; ae ; ae = ae->next) - if (ae->gotobj == a && ae->addend == be->addend) + if (ae->gotobj == a + && ae->reloc_type == be->reloc_type + && ae->addend == be->addend) goto global_found; - if (++total > MAX_GOT_ENTRIES) + total += alpha_got_entry_size (be->reloc_type); + if (total > MAX_GOT_SIZE) return false; global_found:; } @@ -2768,14 +3485,14 @@ static void elf64_alpha_merge_gots (a, b) bfd *a, *b; { - int total = alpha_elf_tdata (a)->total_got_entries; + int total = alpha_elf_tdata (a)->total_got_size; bfd *bsub; /* Remember local expansion. */ { - int e = alpha_elf_tdata (b)->n_local_got_entries; + int e = alpha_elf_tdata (b)->local_got_size; total += e; - alpha_elf_tdata (a)->n_local_got_entries += e; + alpha_elf_tdata (a)->local_got_size += e; } for (bsub = b; bsub ; bsub = alpha_elf_tdata (bsub)->in_got_link_next) @@ -2825,7 +3542,9 @@ elf64_alpha_merge_gots (a, b) continue; for (ae = *start; ae ; ae = ae->next) - if (ae->gotobj == a && ae->addend == be->addend) + if (ae->gotobj == a + && ae->reloc_type == be->reloc_type + && ae->addend == be->addend) { ae->flags |= be->flags; ae->use_count += be->use_count; @@ -2833,7 +3552,7 @@ elf64_alpha_merge_gots (a, b) goto global_found; } be->gotobj = a; - total += 1; + total += alpha_got_entry_size (be->reloc_type); global_found:; } @@ -2841,7 +3560,7 @@ elf64_alpha_merge_gots (a, b) alpha_elf_tdata (bsub)->gotobj = a; } - alpha_elf_tdata (a)->total_got_entries = total; + alpha_elf_tdata (a)->total_got_size = total; /* Merge the two in_got chains. */ { @@ -2874,7 +3593,7 @@ elf64_alpha_calc_got_offsets_for_symbol (h, arg) = &alpha_elf_tdata (gotent->gotobj)->got->_raw_size; gotent->got_offset = *plge; - *plge += 8; + *plge += alpha_got_entry_size (gotent->reloc_type); } return true; @@ -2916,7 +3635,7 @@ elf64_alpha_calc_got_offsets (info) if (gotent->use_count > 0) { gotent->got_offset = got_offset; - got_offset += 8; + got_offset += alpha_got_entry_size (gotent->reloc_type); } } @@ -2928,8 +3647,7 @@ elf64_alpha_calc_got_offsets (info) /* Constructs the gots. */ static boolean -elf64_alpha_size_got_sections (output_bfd, info) - bfd *output_bfd ATTRIBUTE_UNUSED; +elf64_alpha_size_got_sections (info) struct bfd_link_info *info; { bfd *i, *got_list, *cur_got_obj = NULL; @@ -2950,13 +3668,13 @@ elf64_alpha_size_got_sections (output_bfd, info) /* We are assuming no merging has yet ocurred. */ BFD_ASSERT (this_got == i); - if (alpha_elf_tdata (this_got)->total_got_entries > MAX_GOT_ENTRIES) + if (alpha_elf_tdata (this_got)->total_got_size > MAX_GOT_SIZE) { /* Yikes! A single object file has too many entries. */ (*_bfd_error_handler) (_("%s: .got subsegment exceeds 64K (size %d)"), bfd_archive_filename (i), - alpha_elf_tdata (this_got)->total_got_entries * 8); + alpha_elf_tdata (this_got)->total_got_size); return false; } @@ -3003,9 +3721,80 @@ elf64_alpha_size_got_sections (output_bfd, info) return true; } +/* Called from relax_section to rebuild the PLT in light of + potential changes in the function's status. */ + +static boolean +elf64_alpha_size_plt_section (info) + struct bfd_link_info *info; +{ + asection *splt, *spltrel; + unsigned long entries; + bfd *dynobj; + + dynobj = elf_hash_table(info)->dynobj; + splt = bfd_get_section_by_name(dynobj, ".plt"); + if (splt == NULL) + return true; + + splt->_raw_size = 0; + + alpha_elf_link_hash_traverse (alpha_elf_hash_table (info), + elf64_alpha_size_plt_section_1, splt); + + splt->_cooked_size = splt->_raw_size; + + /* Every plt entry requires a JMP_SLOT relocation. */ + spltrel = bfd_get_section_by_name (dynobj, ".rela.plt"); + if (splt->_raw_size) + entries = (splt->_raw_size - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE; + else + entries = 0; + spltrel->_raw_size = entries * sizeof (Elf64_External_Rela); + spltrel->_cooked_size = spltrel->_raw_size; + + return true; +} + +static boolean +elf64_alpha_size_plt_section_1 (h, data) + struct alpha_elf_link_hash_entry *h; + PTR data; +{ + asection *splt = (asection *) data; + struct alpha_elf_got_entry *gotent; + + /* If we didn't need an entry before, we still don't. */ + if (!(h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)) + return true; + + /* There must still be a LITERAL got entry for the function. */ + for (gotent = h->got_entries; gotent ; gotent = gotent->next) + if (gotent->reloc_type == R_ALPHA_LITERAL + && gotent->use_count > 0) + break; + + /* If there is, reset the PLT offset. If not, there's no longer + a need for the PLT entry. */ + if (gotent) + { + if (splt->_raw_size == 0) + splt->_raw_size = PLT_HEADER_SIZE; + h->root.plt.offset = splt->_raw_size; + splt->_raw_size += PLT_ENTRY_SIZE; + } + else + { + h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; + h->root.plt.offset = -1; + } + + return true; +} + static boolean elf64_alpha_always_size_sections (output_bfd, info) - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; { bfd *i; @@ -3018,7 +3807,7 @@ elf64_alpha_always_size_sections (output_bfd, info) elf64_alpha_merge_ind_symbols, NULL); - if (!elf64_alpha_size_got_sections (output_bfd, info)) + if (!elf64_alpha_size_got_sections (info)) return false; /* Allocate space for all of the .got subsections. */ @@ -3037,6 +3826,40 @@ elf64_alpha_always_size_sections (output_bfd, info) return true; } +/* The number of dynamic relocations required by a static relocation. */ + +static int +alpha_dynamic_entries_for_reloc (r_type, dynamic, shared) + int r_type, dynamic, shared; +{ + switch (r_type) + { + /* May appear in GOT entries. */ + case R_ALPHA_TLSGD: + return (dynamic ? 2 : shared ? 1 : 0); + case R_ALPHA_TLSLDM: + return shared; + case R_ALPHA_LITERAL: + return dynamic || shared; + case R_ALPHA_GOTDTPREL: + case R_ALPHA_GOTTPREL: + return dynamic; + + /* May appear in data sections. */ + case R_ALPHA_REFLONG: + case R_ALPHA_REFQUAD: + return dynamic || shared; + case R_ALPHA_SREL64: + case R_ALPHA_TPREL64: + return dynamic; + + /* Everything else is illegal. We'll issue an error during + relocate_section. */ + default: + return 0; + } +} + /* Work out the sizes of the dynamic relocation entries. */ static boolean @@ -3044,6 +3867,10 @@ elf64_alpha_calc_dynrel_sizes (h, info) struct alpha_elf_link_hash_entry *h; struct bfd_link_info *info; { + boolean dynamic; + struct alpha_elf_reloc_entry *relent; + unsigned long entries; + if (h->root.root.type == bfd_link_hash_warning) h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link; @@ -3062,51 +3889,125 @@ elf64_alpha_calc_dynrel_sizes (h, info) && (h->root.root.type == bfd_link_hash_defined || h->root.root.type == bfd_link_hash_defweak) && !(h->root.root.u.def.section->owner->flags & DYNAMIC)) - { - h->root.elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; - } + h->root.elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; /* If the symbol is dynamic, we'll need all the relocations in their natural form. If this is a shared object, and it has been forced local, we'll need the same number of RELATIVE relocations. */ - if (alpha_elf_dynamic_symbol_p (&h->root, info) || info->shared) + dynamic = alpha_elf_dynamic_symbol_p (&h->root, info); + + for (relent = h->reloc_entries; relent; relent = relent->next) { - struct alpha_elf_reloc_entry *relent; - bfd *dynobj; - struct alpha_elf_got_entry *gotent; - bfd_size_type count; - asection *srel; + entries = alpha_dynamic_entries_for_reloc (relent->rtype, dynamic, + info->shared); + if (entries) + { + relent->srel->_raw_size += + entries * sizeof (Elf64_External_Rela) * relent->count; + if (relent->reltext) + info->flags |= DT_TEXTREL; + } + } - for (relent = h->reloc_entries; relent; relent = relent->next) - if (relent->rtype == R_ALPHA_REFLONG - || relent->rtype == R_ALPHA_REFQUAD) - { - relent->srel->_raw_size += - sizeof (Elf64_External_Rela) * relent->count; - if (relent->reltext) - info->flags |= DT_TEXTREL; - } + return true; +} + +/* Set the sizes of the dynamic relocation sections. */ - dynobj = elf_hash_table(info)->dynobj; - count = 0; +static boolean +elf64_alpha_size_rela_got_section (info) + struct bfd_link_info *info; +{ + unsigned long entries; + bfd *i, *dynobj; + asection *srel; - for (gotent = h->got_entries; gotent ; gotent = gotent->next) - count++; + /* Shared libraries often require RELATIVE relocs, and some relocs + require attention for the main application as well. */ - /* If we are using a .plt entry, subtract one, as the first - reference uses a .rela.plt entry instead. */ - if (h->root.plt.offset != MINUS_ONE) - count--; + entries = 0; + for (i = alpha_elf_hash_table(info)->got_list; + i ; i = alpha_elf_tdata(i)->got_link_next) + { + bfd *j; - if (count > 0) + for (j = i; j ; j = alpha_elf_tdata(j)->in_got_link_next) { - srel = bfd_get_section_by_name (dynobj, ".rela.got"); - BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf64_External_Rela) * count; + struct alpha_elf_got_entry **local_got_entries, *gotent; + int k, n; + + local_got_entries = alpha_elf_tdata(j)->local_got_entries; + if (!local_got_entries) + continue; + + for (k = 0, n = elf_tdata(j)->symtab_hdr.sh_info; k < n; ++k) + for (gotent = local_got_entries[k]; + gotent ; gotent = gotent->next) + if (gotent->use_count > 0) + entries += (alpha_dynamic_entries_for_reloc + (gotent->reloc_type, 0, info->shared)); } } + dynobj = elf_hash_table(info)->dynobj; + srel = bfd_get_section_by_name (dynobj, ".rela.got"); + if (!srel) + { + BFD_ASSERT (entries == 0); + return true; + } + srel->_raw_size = sizeof (Elf64_External_Rela) * entries; + + /* Now do the non-local symbols. */ + alpha_elf_link_hash_traverse (alpha_elf_hash_table (info), + elf64_alpha_size_rela_got_1, info); + + srel->_cooked_size = srel->_raw_size; + + return true; +} + +/* Subroutine of elf64_alpha_size_rela_got_section for doing the + global symbols. */ + +static boolean +elf64_alpha_size_rela_got_1 (h, info) + struct alpha_elf_link_hash_entry *h; + struct bfd_link_info *info; +{ + boolean dynamic; + struct alpha_elf_got_entry *gotent; + unsigned long entries; + + if (h->root.root.type == bfd_link_hash_warning) + h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link; + + /* If the symbol is dynamic, we'll need all the relocations in their + natural form. If this is a shared object, and it has been forced + local, we'll need the same number of RELATIVE relocations. */ + + dynamic = alpha_elf_dynamic_symbol_p (&h->root, info); + + entries = 0; + for (gotent = h->got_entries; gotent ; gotent = gotent->next) + if (gotent->use_count > 0) + entries += alpha_dynamic_entries_for_reloc (gotent->reloc_type, + dynamic, info->shared); + + /* If we are using a .plt entry, subtract one, as the first + reference uses a .rela.plt entry instead. */ + if (h->root.plt.offset != MINUS_ONE) + entries--; + + if (entries > 0) + { + bfd *dynobj = elf_hash_table(info)->dynobj; + asection *srel = bfd_get_section_by_name (dynobj, ".rela.got"); + BFD_ASSERT (srel != NULL); + srel->_raw_size += sizeof (Elf64_External_Rela) * entries; + } + return true; } @@ -3140,27 +4041,9 @@ elf64_alpha_size_dynamic_sections (output_bfd, info) collected information in check_relocs that we can now apply to size the dynamic relocation sections. */ alpha_elf_link_hash_traverse (alpha_elf_hash_table (info), - elf64_alpha_calc_dynrel_sizes, - info); - - /* When building shared libraries, each local .got entry needs a - RELATIVE reloc. */ - if (info->shared) - { - bfd *i; - asection *srel; - bfd_size_type count; - - srel = bfd_get_section_by_name (dynobj, ".rela.got"); - BFD_ASSERT (srel != NULL); + elf64_alpha_calc_dynrel_sizes, info); - for (i = alpha_elf_hash_table(info)->got_list, count = 0; - i != NULL; - i = alpha_elf_tdata(i)->got_link_next) - count += alpha_elf_tdata(i)->n_local_got_entries; - - srel->_raw_size += count * sizeof (Elf64_External_Rela); - } + elf64_alpha_size_rela_got_section (info); } /* else we're not dynamic and by definition we don't need such things. */ @@ -3262,6 +4145,71 @@ elf64_alpha_size_dynamic_sections (output_bfd, info) return true; } +/* Relocate an Alpha ELF section for a relocatable link. + + We don't have to change anything unless the reloc is against a section + symbol, in which case we have to adjust according to where the section + symbol winds up in the output section. */ + +static boolean +elf64_alpha_relocate_section_r (output_bfd, info, input_bfd, input_section, + contents, relocs, local_syms, local_sections) + bfd *output_bfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + bfd *input_bfd; + asection *input_section; + bfd_byte *contents ATTRIBUTE_UNUSED; + Elf_Internal_Rela *relocs; + Elf_Internal_Sym *local_syms; + asection **local_sections; +{ + unsigned long symtab_hdr_sh_info; + Elf_Internal_Rela *rel; + Elf_Internal_Rela *relend; + boolean ret_val = true; + + symtab_hdr_sh_info = elf_tdata (input_bfd)->symtab_hdr.sh_info; + + relend = relocs + input_section->reloc_count; + for (rel = relocs; rel < relend; rel++) + { + unsigned long r_symndx; + Elf_Internal_Sym *sym; + asection *sec; + unsigned long r_type; + + r_type = ELF64_R_TYPE(rel->r_info); + if (r_type >= R_ALPHA_max) + { + (*_bfd_error_handler) + (_("%s: unknown relocation type %d"), + bfd_archive_filename (input_bfd), (int)r_type); + bfd_set_error (bfd_error_bad_value); + ret_val = false; + continue; + } + + r_symndx = ELF64_R_SYM(rel->r_info); + + /* The symbol associated with GPDISP and LITUSE is + immaterial. Only the addend is significant. */ + if (r_type == R_ALPHA_GPDISP || r_type == R_ALPHA_LITUSE) + continue; + + if (r_symndx < symtab_hdr_sh_info) + { + sym = local_syms + r_symndx; + if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) + { + sec = local_sections[r_symndx]; + rel->r_addend += sec->output_offset + sym->st_value; + } + } + } + + return ret_val; +} + /* Relocate an Alpha ELF section. */ static boolean @@ -3279,22 +4227,39 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Shdr *symtab_hdr; Elf_Internal_Rela *rel; Elf_Internal_Rela *relend; - asection *sec, *sgot, *srel, *srelgot; + struct elf_link_tls_segment *tls_segment; + asection *sgot, *srel, *srelgot; bfd *dynobj, *gotobj; - bfd_vma gp; - boolean ret_val = true; + bfd_vma gp, tp_base, dtp_base; + struct alpha_elf_got_entry **local_got_entries; + boolean ret_val; + const char *section_name; + + /* Handle relocatable links with a smaller loop. */ + if (info->relocateable) + return elf64_alpha_relocate_section_r (output_bfd, info, input_bfd, + input_section, contents, relocs, + local_syms, local_sections); + + /* This is a final link. */ + + ret_val = true; - srelgot = srel = NULL; symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; + dynobj = elf_hash_table (info)->dynobj; if (dynobj) - { - srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); - } + srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + else + srelgot = NULL; + + section_name = (bfd_elf_string_from_elf_section + (input_bfd, elf_elfheader(input_bfd)->e_shstrndx, + elf_section_data(input_section)->rel_hdr.sh_name)); + BFD_ASSERT(section_name != NULL); + srel = bfd_get_section_by_name (dynobj, section_name); /* Find the gp value for this input bfd. */ - sgot = NULL; - gp = 0; gotobj = alpha_elf_tdata (input_bfd)->gotobj; if (gotobj) { @@ -3308,66 +4273,97 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, _bfd_set_gp_value (gotobj, gp); } } + else + { + sgot = NULL; + gp = 0; + } + + local_got_entries = alpha_elf_tdata(input_bfd)->local_got_entries; + + tls_segment = elf_hash_table (info)->tls_segment; + if (tls_segment) + { + dtp_base = alpha_get_dtprel_base (tls_segment); + tp_base = alpha_get_tprel_base (tls_segment); + } + else + dtp_base = tp_base = 0; - rel = relocs; relend = relocs + input_section->reloc_count; - for (; rel < relend; rel++) + for (rel = relocs; rel < relend; rel++) { - int r_type; + struct alpha_elf_link_hash_entry *h = NULL; + struct alpha_elf_got_entry *gotent; + bfd_reloc_status_type r; reloc_howto_type *howto; unsigned long r_symndx; - struct alpha_elf_link_hash_entry *h; - Elf_Internal_Sym *sym; - bfd_vma relocation; + Elf_Internal_Sym *sym = NULL; + asection *sec = NULL; + bfd_vma value; bfd_vma addend; - bfd_reloc_status_type r; + boolean dynamic_symbol_p; + boolean undef_weak_ref = false; + unsigned long r_type; r_type = ELF64_R_TYPE(rel->r_info); - if (r_type < 0 || r_type >= (int) R_ALPHA_max) + if (r_type >= R_ALPHA_max) { + (*_bfd_error_handler) + (_("%s: unknown relocation type %d"), + bfd_archive_filename (input_bfd), (int)r_type); bfd_set_error (bfd_error_bad_value); - return false; + ret_val = false; + continue; } - howto = elf64_alpha_howto_table + r_type; + howto = elf64_alpha_howto_table + r_type; r_symndx = ELF64_R_SYM(rel->r_info); - if (info->relocateable) + if (r_symndx < symtab_hdr->sh_info) { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - - /* The symbol associated with GPDISP and LITUSE is - immaterial. Only the addend is significant. */ - if (r_type == R_ALPHA_GPDISP || r_type == R_ALPHA_LITUSE) - continue; + sym = local_syms + r_symndx; + sec = local_sections[r_symndx]; + value = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); - if (r_symndx < symtab_hdr->sh_info) + if (local_got_entries) + gotent = local_got_entries[r_symndx]; + else + gotent = NULL; + + /* Need to adjust local GOT entries' addends for SEC_MERGE + unless it has been done already. */ + if ((sec->flags & SEC_MERGE) + && ELF_ST_TYPE (sym->st_info) == STT_SECTION + && (elf_section_data (sec)->sec_info_type + == ELF_INFO_TYPE_MERGE) + && gotent + && !gotent->reloc_xlated) { - sym = local_syms + r_symndx; - if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) + struct alpha_elf_got_entry *ent; + asection *msec; + + for (ent = gotent; ent; ent = ent->next) { - sec = local_sections[r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; + ent->reloc_xlated = 1; + if (ent->use_count == 0) + continue; + msec = sec; + ent->addend = + _bfd_merged_section_offset (output_bfd, &msec, + elf_section_data (sec)-> + sec_info, + sym->st_value + ent->addend, + (bfd_vma) 0); + ent->addend -= sym->st_value; + ent->addend += msec->output_section->vma + + msec->output_offset + - sec->output_section->vma + - sec->output_offset; } } - continue; - } - - /* This is a final link. */ - - h = NULL; - sym = NULL; - sec = NULL; - - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - sec = local_sections[r_symndx]; - relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); + dynamic_symbol_p = false; } else { @@ -3377,27 +4373,32 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, || h->root.root.type == bfd_link_hash_warning) h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link; + value = 0; if (h->root.root.type == bfd_link_hash_defined || h->root.root.type == bfd_link_hash_defweak) { sec = h->root.root.u.def.section; - if (sec->output_section == NULL) - relocation = 0; - else - { - relocation = (h->root.root.u.def.value - + sec->output_section->vma - + sec->output_offset); - } + /* Detect the cases that sym_sec->output_section is + expected to be NULL -- all cases in which the symbol + is defined in another shared module. This includes + PLT relocs for which we've created a PLT entry and + other relocs for which we're prepared to create + dynamic relocations. */ + /* ??? Just accept it NULL and continue. */ + + if (sec->output_section != NULL) + value = (h->root.root.u.def.value + + sec->output_section->vma + + sec->output_offset); } else if (h->root.root.type == bfd_link_hash_undefweak) - relocation = 0; + undef_weak_ref = true; else if (info->shared && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT) - relocation = 0; + ; else { if (!((*info->callbacks->undefined_symbol) @@ -3405,11 +4406,24 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, input_section, rel->r_offset, (!info->shared || info->no_undefined || ELF_ST_VISIBILITY (h->root.other))))) - ret_val = false; - relocation = 0; + return false; + ret_val = false; + continue; } + + dynamic_symbol_p = alpha_elf_dynamic_symbol_p (&h->root, info); + gotent = h->got_entries; } + addend = rel->r_addend; + value += addend; + + /* Search for the proper got entry. */ + for (; gotent ; gotent = gotent->next) + if (gotent->gotobj == gotobj + && gotent->reloc_type == r_type + && gotent->addend == addend) + break; switch (r_type) { @@ -3419,124 +4433,66 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, BFD_ASSERT(gp != 0); - relocation = (input_section->output_section->vma - + input_section->output_offset - + rel->r_offset); + value = (input_section->output_section->vma + + input_section->output_offset + + rel->r_offset); - p_ldah = contents + rel->r_offset - input_section->vma; + p_ldah = contents + rel->r_offset; p_lda = p_ldah + rel->r_addend; - r = elf64_alpha_do_reloc_gpdisp (input_bfd, gp - relocation, + r = elf64_alpha_do_reloc_gpdisp (input_bfd, gp - value, p_ldah, p_lda); } break; case R_ALPHA_LITERAL: - { - struct alpha_elf_got_entry *gotent; - boolean dynamic_symbol; - - BFD_ASSERT(sgot != NULL); - BFD_ASSERT(gp != 0); - - if (h != NULL) - { - gotent = h->got_entries; - dynamic_symbol = alpha_elf_dynamic_symbol_p (&h->root, info); - } - else - { - gotent = (alpha_elf_tdata(input_bfd)-> - local_got_entries[r_symndx]); - dynamic_symbol = false; - - /* Need to adjust local GOT entries' addends for SEC_MERGE - unless it has been done already. */ - if ((sec->flags & SEC_MERGE) - && ELF_ST_TYPE (sym->st_info) == STT_SECTION - && (elf_section_data (sec)->sec_info_type - == ELF_INFO_TYPE_MERGE) - && (gotent->flags & ALPHA_ELF_GOT_ENTRY_RELOCS_XLATED) == 0) - { - struct alpha_elf_got_entry *ent; - asection *msec; - - for (ent = gotent; ent; ent = ent->next) - { - ent->flags |= ALPHA_ELF_GOT_ENTRY_RELOCS_XLATED; - if (ent->use_count == 0) - continue; - msec = sec; - ent->addend = - _bfd_merged_section_offset (output_bfd, &msec, - elf_section_data (sec)-> - sec_info, - sym->st_value - + ent->addend, - (bfd_vma) 0); - ent->addend -= sym->st_value; - ent->addend += msec->output_section->vma - + msec->output_offset - - sec->output_section->vma - - sec->output_offset; - } - } - } + BFD_ASSERT(sgot != NULL); + BFD_ASSERT(gp != 0); + BFD_ASSERT(gotent != NULL); + BFD_ASSERT(gotent->use_count >= 1); - BFD_ASSERT(gotent != NULL); + if (!gotent->reloc_done) + { + gotent->reloc_done = 1; - while (gotent->gotobj != gotobj || gotent->addend != addend) - gotent = gotent->next; + bfd_put_64 (output_bfd, value, + sgot->contents + gotent->got_offset); - BFD_ASSERT(gotent->use_count >= 1); + /* If the symbol has been forced local, output a + RELATIVE reloc, otherwise it will be handled in + finish_dynamic_symbol. */ + if (info->shared && !dynamic_symbol_p) + { + Elf_Internal_Rela outrel; - /* Initialize the .got entry's value. */ - if (!(gotent->flags & ALPHA_ELF_GOT_ENTRY_RELOCS_DONE)) - { - bfd_put_64 (output_bfd, relocation + addend, - sgot->contents + gotent->got_offset); + BFD_ASSERT(srelgot != NULL); - /* If the symbol has been forced local, output a - RELATIVE reloc, otherwise it will be handled in - finish_dynamic_symbol. */ - if (info->shared && !dynamic_symbol) - { - Elf_Internal_Rela outrel; - - BFD_ASSERT(srelgot != NULL); - - outrel.r_offset = (sgot->output_section->vma - + sgot->output_offset - + gotent->got_offset); - outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE); - outrel.r_addend = relocation + addend; - - bfd_elf64_swap_reloca_out (output_bfd, &outrel, - ((Elf64_External_Rela *) - srelgot->contents) - + srelgot->reloc_count++); - BFD_ASSERT (sizeof (Elf64_External_Rela) - * srelgot->reloc_count - <= srelgot->_cooked_size); - } + outrel.r_offset = (sgot->output_section->vma + + sgot->output_offset + + gotent->got_offset); + outrel.r_info = ELF64_R_INFO (0, R_ALPHA_RELATIVE); + outrel.r_addend = value; - gotent->flags |= ALPHA_ELF_GOT_ENTRY_RELOCS_DONE; - } + bfd_elf64_swap_reloca_out (output_bfd, &outrel, + ((Elf64_External_Rela *) + srelgot->contents) + + srelgot->reloc_count++); + BFD_ASSERT (sizeof (Elf64_External_Rela) + * srelgot->reloc_count + <= srelgot->_cooked_size); + } + } - /* Figure the gprel relocation. */ - addend = 0; - relocation = (sgot->output_section->vma - + sgot->output_offset - + gotent->got_offset); - relocation -= gp; - } - /* overflow handled by _bfd_final_link_relocate */ + value = (sgot->output_section->vma + + sgot->output_offset + + gotent->got_offset); + value -= gp; goto default_reloc; case R_ALPHA_GPREL16: case R_ALPHA_GPREL32: case R_ALPHA_GPRELLOW: - if (h && alpha_elf_dynamic_symbol_p (&h->root, info)) + if (dynamic_symbol_p) { (*_bfd_error_handler) (_("%s: gp-relative relocation against dynamic symbol %s"), @@ -3544,11 +4500,11 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, ret_val = false; } BFD_ASSERT(gp != 0); - relocation -= gp; + value -= gp; goto default_reloc; case R_ALPHA_GPRELHIGH: - if (h && alpha_elf_dynamic_symbol_p (&h->root, info)) + if (dynamic_symbol_p) { (*_bfd_error_handler) (_("%s: gp-relative relocation against dynamic symbol %s"), @@ -3556,27 +4512,34 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, ret_val = false; } BFD_ASSERT(gp != 0); - relocation -= gp; - relocation += addend; - addend = 0; - relocation = (((bfd_signed_vma) relocation >> 16) - + ((relocation >> 15) & 1)); + value -= gp; + value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1); goto default_reloc; case R_ALPHA_HINT: /* A call to a dynamic symbol is definitely out of range of the 16-bit displacement. Don't bother writing anything. */ - if (h && alpha_elf_dynamic_symbol_p (&h->root, info)) + if (dynamic_symbol_p) { r = bfd_reloc_ok; break; } - /* FALLTHRU */ + /* The regular PC-relative stuff measures from the start of + the instruction rather than the end. */ + value -= 4; + goto default_reloc; case R_ALPHA_BRADDR: + if (dynamic_symbol_p) + { + (*_bfd_error_handler) + (_("%s: pc-relative relocation against dynamic symbol %s"), + bfd_archive_filename (input_bfd), h->root.root.root.string); + ret_val = false; + } /* The regular PC-relative stuff measures from the start of the instruction rather than the end. */ - addend -= 4; + value -= 4; goto default_reloc; case R_ALPHA_BRSGP: @@ -3586,12 +4549,12 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, /* The regular PC-relative stuff measures from the start of the instruction rather than the end. */ - addend -= 4; + value -= 4; /* The source and destination gp must be the same. Note that the source will always have an assigned gp, since we forced one in check_relocs, but that the destination may not, as - it might not have had any relocations at all. Also take + it might not have had any relocations at all. Also take care not to crash if H is an undefined symbol. */ if (h != NULL && sec != NULL && alpha_elf_tdata (sec->owner)->gotobj @@ -3639,41 +4602,52 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, case R_ALPHA_REFLONG: case R_ALPHA_REFQUAD: + case R_ALPHA_DTPREL64: + case R_ALPHA_TPREL64: { Elf_Internal_Rela outrel; /* Careful here to remember RELATIVE relocations for global variables for symbolic shared objects. */ - if (h && alpha_elf_dynamic_symbol_p (&h->root, info)) + if (dynamic_symbol_p) { BFD_ASSERT(h->root.dynindx != -1); - outrel.r_info = ELF64_R_INFO(h->root.dynindx, r_type); + outrel.r_info = ELF64_R_INFO (h->root.dynindx, r_type); outrel.r_addend = addend; - addend = 0, relocation = 0; + addend = 0, value = 0; + } + else if (r_type == R_ALPHA_DTPREL64) + { + BFD_ASSERT(tls_segment != NULL); + value -= dtp_base; + goto default_reloc; + } + else if (r_type == R_ALPHA_TPREL64) + { + BFD_ASSERT(tls_segment != NULL); + value -= dtp_base; + goto default_reloc; } else if (info->shared && r_symndx != 0 && (input_section->flags & SEC_ALLOC)) { - outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE); - outrel.r_addend = relocation + addend; + if (r_type == R_ALPHA_REFLONG) + { + (*_bfd_error_handler) + (_("%s: unhandled dynamic relocation against %s"), + bfd_archive_filename (input_bfd), + h->root.root.root.string); + ret_val = false; + } + outrel.r_info = ELF64_R_INFO (0, R_ALPHA_RELATIVE); + outrel.r_addend = value; } else goto default_reloc; - if (!srel) - { - const char *name; - - name = (bfd_elf_string_from_elf_section - (input_bfd, elf_elfheader(input_bfd)->e_shstrndx, - elf_section_data(input_section)->rel_hdr.sh_name)); - BFD_ASSERT(name != NULL); - - srel = bfd_get_section_by_name (dynobj, name); - BFD_ASSERT(srel != NULL); - } + BFD_ASSERT(srel != NULL); outrel.r_offset = _bfd_elf_section_offset (output_bfd, info, input_section, @@ -3693,8 +4667,17 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, } goto default_reloc; + case R_ALPHA_SREL16: case R_ALPHA_SREL32: case R_ALPHA_SREL64: + if (dynamic_symbol_p) + { + (*_bfd_error_handler) + (_("%s: pc-relative relocation against dynamic symbol %s"), + bfd_archive_filename (input_bfd), h->root.root.root.string); + ret_val = false; + } + /* ??? .eh_frame references to discarded sections will be smashed to relocations against SHN_UNDEF. The .eh_frame format allows NULL to be encoded as 0 in any format, so this works here. */ @@ -3703,11 +4686,134 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, + (r_type - R_ALPHA_SREL32 + R_ALPHA_REFLONG)); goto default_reloc; + case R_ALPHA_TLSLDM: + /* Ignore the symbol for the relocation. The result is always + the current module. */ + dynamic_symbol_p = 0; + /* FALLTHRU */ + + case R_ALPHA_TLSGD: + if (!gotent->reloc_done) + { + gotent->reloc_done = 1; + + /* Note that the module index for the main program is 1. */ + bfd_put_64 (output_bfd, !info->shared && !dynamic_symbol_p, + sgot->contents + gotent->got_offset); + + /* If the symbol has been forced local, output a + DTPMOD64 reloc, otherwise it will be handled in + finish_dynamic_symbol. */ + if (info->shared && !dynamic_symbol_p) + { + Elf_Internal_Rela outrel; + + BFD_ASSERT(srelgot != NULL); + + outrel.r_offset = (sgot->output_section->vma + + sgot->output_offset + + gotent->got_offset); + /* ??? Proper dynindx here. */ + outrel.r_info = ELF64_R_INFO (0, R_ALPHA_DTPMOD64); + outrel.r_addend = 0; + + bfd_elf64_swap_reloca_out (output_bfd, &outrel, + ((Elf64_External_Rela *) + srelgot->contents) + + srelgot->reloc_count++); + BFD_ASSERT (sizeof (Elf64_External_Rela) + * srelgot->reloc_count + <= srelgot->_cooked_size); + } + + if (dynamic_symbol_p || r_type == R_ALPHA_TLSLDM) + value = 0; + else + { + BFD_ASSERT(tls_segment != NULL); + value -= dtp_base; + } + bfd_put_64 (output_bfd, value, + sgot->contents + gotent->got_offset + 8); + } + + value = (sgot->output_section->vma + + sgot->output_offset + + gotent->got_offset); + value -= gp; + goto default_reloc; + + case R_ALPHA_DTPRELHI: + case R_ALPHA_DTPRELLO: + case R_ALPHA_DTPREL16: + if (dynamic_symbol_p) + { + (*_bfd_error_handler) + (_("%s: dtp-relative relocation against dynamic symbol %s"), + bfd_archive_filename (input_bfd), h->root.root.root.string); + ret_val = false; + } + BFD_ASSERT(tls_segment != NULL); + value -= dtp_base; + if (r_type == R_ALPHA_DTPRELHI) + value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1); + goto default_reloc; + + case R_ALPHA_TPRELHI: + case R_ALPHA_TPRELLO: + case R_ALPHA_TPREL16: + if (info->shared) + { + (*_bfd_error_handler) + (_("%s: TLS local exec code cannot be linked into shared objects"), + bfd_archive_filename (input_bfd)); + ret_val = false; + } + else if (dynamic_symbol_p) + { + (*_bfd_error_handler) + (_("%s: tp-relative relocation against dynamic symbol %s"), + bfd_archive_filename (input_bfd), h->root.root.root.string); + ret_val = false; + } + BFD_ASSERT(tls_segment != NULL); + value -= tp_base; + if (r_type == R_ALPHA_TPRELHI) + value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1); + goto default_reloc; + + case R_ALPHA_GOTDTPREL: + case R_ALPHA_GOTTPREL: + BFD_ASSERT(sgot != NULL); + BFD_ASSERT(gp != 0); + BFD_ASSERT(gotent != NULL); + BFD_ASSERT(gotent->use_count >= 1); + + if (!gotent->reloc_done) + { + gotent->reloc_done = 1; + + if (dynamic_symbol_p) + value = 0; + else + { + BFD_ASSERT(tls_segment != NULL); + value -= (r_type == R_ALPHA_GOTDTPREL ? dtp_base : tp_base); + } + bfd_put_64 (output_bfd, value, + sgot->contents + gotent->got_offset); + } + + value = (sgot->output_section->vma + + sgot->output_offset + + gotent->got_offset); + value -= gp; + goto default_reloc; + default: default_reloc: r = _bfd_final_link_relocate (howto, input_bfd, input_section, - contents, rel->r_offset, relocation, - addend); + contents, rel->r_offset, value, 0); break; } @@ -3879,20 +4985,58 @@ elf64_alpha_finish_dynamic_symbol (output_bfd, info, h, sym) srel = bfd_get_section_by_name (dynobj, ".rela.got"); BFD_ASSERT (srel != NULL); - outrel.r_info = ELF64_R_INFO (h->dynindx, R_ALPHA_GLOB_DAT); for (gotent = ((struct alpha_elf_link_hash_entry *) h)->got_entries; gotent != NULL; gotent = gotent->next) { - asection *sgot = alpha_elf_tdata (gotent->gotobj)->got; + asection *sgot; + int r_type; + + if (gotent->use_count == 0) + continue; + + sgot = alpha_elf_tdata (gotent->gotobj)->got; outrel.r_offset = (sgot->output_section->vma + sgot->output_offset + gotent->got_offset); + + r_type = gotent->reloc_type; + switch (r_type) + { + case R_ALPHA_LITERAL: + r_type = R_ALPHA_GLOB_DAT; + break; + case R_ALPHA_TLSGD: + r_type = R_ALPHA_DTPMOD64; + break; + case R_ALPHA_GOTDTPREL: + r_type = R_ALPHA_DTPREL64; + break; + case R_ALPHA_GOTTPREL: + r_type = R_ALPHA_TPREL64; + break; + case R_ALPHA_TLSLDM: + default: + abort (); + } + + outrel.r_info = ELF64_R_INFO (h->dynindx, r_type); outrel.r_addend = gotent->addend; bfd_elf64_swap_reloca_out (output_bfd, &outrel, ((Elf64_External_Rela *)srel->contents + srel->reloc_count++)); + + if (gotent->reloc_type == R_ALPHA_TLSGD) + { + outrel.r_offset += 8; + outrel.r_info = ELF64_R_INFO (h->dynindx, R_ALPHA_DTPREL64); + + bfd_elf64_swap_reloca_out (output_bfd, &outrel, + ((Elf64_External_Rela *)srel->contents + + srel->reloc_count++)); + } + BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count <= srel->_cooked_size); } @@ -4116,7 +5260,7 @@ elf64_alpha_final_link (abfd, info) if (p->type != bfd_indirect_link_order) { - if (p->type == bfd_fill_link_order) + if (p->type == bfd_data_link_order) continue; abort (); } @@ -4336,7 +5480,7 @@ elf64_alpha_ecoff_debug_swap = /* Use a non-standard hash bucket size of 8. */ -const struct elf_size_info alpha_elf_size_info = +static const struct elf_size_info alpha_elf_size_info = { sizeof (Elf64_External_Ehdr), sizeof (Elf64_External_Phdr), @@ -4353,6 +5497,7 @@ const struct elf_size_info alpha_elf_size_info = bfd_elf64_write_out_phdrs, bfd_elf64_write_shdrs_and_ehdr, bfd_elf64_write_relocs, + bfd_elf64_swap_symbol_in, bfd_elf64_swap_symbol_out, bfd_elf64_slurp_reloc_table, bfd_elf64_slurp_symbol_table, @@ -4364,11 +5509,13 @@ const struct elf_size_info alpha_elf_size_info = NULL }; +#ifndef ELF_ARCH #define TARGET_LITTLE_SYM bfd_elf64_alpha_vec #define TARGET_LITTLE_NAME "elf64-alpha" #define ELF_ARCH bfd_arch_alpha #define ELF_MACHINE_CODE EM_ALPHA #define ELF_MAXPAGESIZE 0x10000 +#endif /* ELF_ARCH */ #define bfd_elf64_bfd_link_hash_table_create \ elf64_alpha_bfd_link_hash_table_create diff --git a/contrib/binutils/bfd/elf64-ppc.c b/contrib/binutils/bfd/elf64-ppc.c index d25c25f..e431c14 100644 --- a/contrib/binutils/bfd/elf64-ppc.c +++ b/contrib/binutils/bfd/elf64-ppc.c @@ -55,64 +55,10 @@ static bfd_reloc_status_type ppc64_elf_toc64_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); static bfd_reloc_status_type ppc64_elf_unhandled_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static boolean ppc64_elf_set_private_flags - PARAMS ((bfd *, flagword)); +static boolean ppc64_elf_object_p + PARAMS ((bfd *)); static boolean ppc64_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *)); -static boolean ppc64_elf_section_from_shdr - PARAMS ((bfd *, Elf64_Internal_Shdr *, char *)); -static struct bfd_hash_entry *link_hash_newfunc - PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); -static struct bfd_link_hash_table *ppc64_elf_link_hash_table_create - PARAMS ((bfd *)); -static boolean create_linkage_sections - PARAMS ((bfd *, struct bfd_link_info *)); -static boolean create_got_section - PARAMS ((bfd *, struct bfd_link_info *)); -static boolean ppc64_elf_create_dynamic_sections - PARAMS ((bfd *, struct bfd_link_info *)); -static void ppc64_elf_copy_indirect_symbol - PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *)); -static boolean ppc64_elf_check_relocs - PARAMS ((bfd *, struct bfd_link_info *, asection *, - const Elf_Internal_Rela *)); -static asection * ppc64_elf_gc_mark_hook - PARAMS ((bfd *abfd, struct bfd_link_info *info, Elf_Internal_Rela *rel, - struct elf_link_hash_entry *h, Elf_Internal_Sym *sym)); -static boolean ppc64_elf_gc_sweep_hook - PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *sec, - const Elf_Internal_Rela *relocs)); -static boolean func_desc_adjust - PARAMS ((struct elf_link_hash_entry *, PTR)); -static boolean ppc64_elf_func_desc_adjust - PARAMS ((bfd *, struct bfd_link_info *)); -static boolean ppc64_elf_adjust_dynamic_symbol - PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); -static void ppc64_elf_hide_symbol - PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean)); -static boolean allocate_dynrelocs - PARAMS ((struct elf_link_hash_entry *, PTR)); -static boolean readonly_dynrelocs - PARAMS ((struct elf_link_hash_entry *, PTR)); -static enum elf_reloc_type_class ppc64_elf_reloc_type_class - PARAMS ((const Elf_Internal_Rela *)); -static boolean ppc64_elf_size_dynamic_sections - PARAMS ((bfd *, struct bfd_link_info *)); -static bfd_byte *build_plt_stub - PARAMS ((bfd *, bfd_byte *, int, int)); -static boolean build_one_stub - PARAMS ((struct elf_link_hash_entry *, PTR)); -static boolean ppc64_elf_fake_sections - PARAMS ((bfd *, Elf64_Internal_Shdr *, asection *)); -static boolean ppc64_elf_relocate_section - PARAMS ((bfd *, struct bfd_link_info *info, bfd *, asection *, bfd_byte *, - Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms, - asection **)); -static boolean ppc64_elf_finish_dynamic_symbol - PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, - Elf_Internal_Sym *)); -static boolean ppc64_elf_finish_dynamic_sections - PARAMS ((bfd *, struct bfd_link_info *)); /* The name of the dynamic interpreter. This is put in the .interp @@ -158,7 +104,7 @@ static boolean ppc64_elf_finish_dynamic_sections #define CROR_151515 0x4def7b82 #define CROR_313131 0x4ffffb82 -/* .glink entries for the first 32k functions are two instructions. */ +/* .glink entries for the first 32k functions are two instructions. */ #define LI_R0_0 0x38000000 /* li %r0,0 */ #define B_DOT 0x48000000 /* b . */ @@ -175,12 +121,13 @@ static boolean ppc64_elf_finish_dynamic_sections /* Since .opd is an array of descriptors and each entry will end up with identical R_PPC64_RELATIVE relocs, there is really no need to propagate .opd relocs; The dynamic linker should be taught to - relocate .opd without reloc entries. FIXME: .opd should be trimmed - of unused values. */ + relocate .opd without reloc entries. */ #ifndef NO_OPD_RELOCS #define NO_OPD_RELOCS 0 #endif +#define ONES(n) (((bfd_vma) 1 << ((n) - 1) << 1) - 1) + /* Relocation HOWTO's. */ static reloc_howto_type *ppc64_elf_howto_table[(int) R_PPC_max]; @@ -188,11 +135,11 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { /* This reloc does nothing. */ HOWTO (R_PPC64_NONE, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ + 0, /* size (0 = byte, 1 = short, 2 = long) */ + 8, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ + complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_PPC64_NONE", /* name */ false, /* partial_inplace */ @@ -228,7 +175,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_ADDR24", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0x3fffffc, /* dst_mask */ + 0x03fffffc, /* dst_mask */ false), /* pcrel_offset */ /* A standard 16 bit relocation. */ @@ -305,7 +252,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_ADDR14", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xfffc, /* dst_mask */ + 0x0000fffc, /* dst_mask */ false), /* pcrel_offset */ /* An absolute 16 bit branch, for which bit 10 should be set to @@ -322,7 +269,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_ADDR14_BRTAKEN",/* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xfffc, /* dst_mask */ + 0x0000fffc, /* dst_mask */ false), /* pcrel_offset */ /* An absolute 16 bit branch, for which bit 10 should be set to @@ -339,7 +286,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_ADDR14_BRNTAKEN",/* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xfffc, /* dst_mask */ + 0x0000fffc, /* dst_mask */ false), /* pcrel_offset */ /* A relative 26 bit branch; the lower two bits must be zero. */ @@ -354,7 +301,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_REL24", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0x3fffffc, /* dst_mask */ + 0x03fffffc, /* dst_mask */ true), /* pcrel_offset */ /* A relative 16 bit branch; the lower two bits must be zero. */ @@ -369,7 +316,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_REL14", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xfffc, /* dst_mask */ + 0x0000fffc, /* dst_mask */ true), /* pcrel_offset */ /* A relative 16 bit branch. Bit 10 should be set to indicate that @@ -386,7 +333,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_REL14_BRTAKEN", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xfffc, /* dst_mask */ + 0x0000fffc, /* dst_mask */ true), /* pcrel_offset */ /* A relative 16 bit branch. Bit 10 should be set to indicate that @@ -403,7 +350,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_REL14_BRNTAKEN",/* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xfffc, /* dst_mask */ + 0x0000fffc, /* dst_mask */ true), /* pcrel_offset */ /* Like R_PPC64_ADDR16, but referring to the GOT table entry for the @@ -477,12 +424,12 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { run has to have the data at some particular address. */ HOWTO (R_PPC64_COPY, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ + 0, /* this one is variable size */ + 0, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - ppc64_elf_unhandled_reloc, /* special_function */ + complain_overflow_dont, /* complain_on_overflow */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_COPY", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -502,7 +449,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_GLOB_DAT", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xffffffffffffffff, /* dst_mask */ + ONES (64), /* dst_mask */ false), /* pcrel_offset */ /* Created by the link editor. Marks a procedure linkage table @@ -535,7 +482,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_RELATIVE", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xffffffffffffffff, /* dst_mask */ + ONES (64), /* dst_mask */ false), /* pcrel_offset */ /* Like R_PPC64_ADDR32, but may be unaligned. */ @@ -575,7 +522,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { 32, /* bitsize */ true, /* pc_relative */ 0, /* bitpos */ - /* FIXME: Verify. Was complain_overflow_bitfield. */ + /* FIXME: Verify. Was complain_overflow_bitfield. */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_PPC64_REL32", /* name */ @@ -596,7 +543,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_PLT32", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0, /* dst_mask */ + 0xffffffff, /* dst_mask */ false), /* pcrel_offset */ /* 32-bit PC relative relocation to the symbol's procedure linkage table. @@ -612,7 +559,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_PLTREL32", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0, /* dst_mask */ + 0xffffffff, /* dst_mask */ true), /* pcrel_offset */ /* Like R_PPC64_ADDR16_LO, but referring to the PLT table entry for @@ -753,7 +700,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_ADDR64", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xffffffffffffffff, /* dst_mask */ + ONES (64), /* dst_mask */ false), /* pcrel_offset */ /* The bits 32-47 of an address. */ @@ -830,7 +777,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_UADDR64", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xffffffffffffffff, /* dst_mask */ + ONES (64), /* dst_mask */ false), /* pcrel_offset */ /* 64-bit relative relocation. */ @@ -845,10 +792,10 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_REL64", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xffffffffffffffff, /* dst_mask */ + ONES (64), /* dst_mask */ true), /* pcrel_offset */ - /* 64-bit relocation to the symbol's procedure linkage table. */ + /* 64-bit relocation to the symbol's procedure linkage table. */ HOWTO (R_PPC64_PLT64, /* type */ 0, /* rightshift */ 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ @@ -860,7 +807,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_PLT64", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0, /* dst_mask */ + ONES (64), /* dst_mask */ false), /* pcrel_offset */ /* 64-bit PC relative relocation to the symbol's procedure linkage @@ -877,7 +824,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_PLTREL64", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0, /* dst_mask */ + ONES (64), /* dst_mask */ true), /* pcrel_offset */ /* 16 bit TOC-relative relocation. */ @@ -964,7 +911,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { "R_PPC64_TOC", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0xffffffffffffffff, /* dst_mask */ + ONES (64), /* dst_mask */ false), /* pcrel_offset */ /* Like R_PPC64_GOT16, but also informs the link editor that the @@ -1411,8 +1358,8 @@ ppc64_elf_info_to_howto (abfd, cache_ptr, dst) { unsigned int type; + /* Initialize howto table if needed. */ if (!ppc64_elf_howto_table[R_PPC64_ADDR32]) - /* Initialize howto table if needed. */ ppc_howto_init (); type = ELF64_R_TYPE (dst->r_info); @@ -1438,7 +1385,7 @@ ppc64_elf_ha_reloc (abfd, reloc_entry, symbol, data, call the generic function. Any adjustment will be done at final link time. */ if (output_bfd != NULL) - return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message); /* Adjust the addend for sign extension of the low 16 bits. @@ -1469,7 +1416,7 @@ ppc64_elf_brtaken_reloc (abfd, reloc_entry, symbol, data, call the generic function. Any adjustment will be done at final link time. */ if (output_bfd != NULL) - return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message); octets = reloc_entry->address * bfd_octets_per_byte (abfd); @@ -1478,7 +1425,7 @@ ppc64_elf_brtaken_reloc (abfd, reloc_entry, symbol, data, r_type = (enum elf_ppc_reloc_type) reloc_entry->howto->type; if (r_type == R_PPC64_ADDR14_BRTAKEN || r_type == R_PPC64_REL14_BRTAKEN) - insn |= 0x01 << 21; /* 'y' or 't' bit, lowest bit of BO field. */ + insn |= 0x01 << 21; /* 'y' or 't' bit, lowest bit of BO field. */ if (is_power4) { @@ -1530,7 +1477,7 @@ ppc64_elf_sectoff_reloc (abfd, reloc_entry, symbol, data, call the generic function. Any adjustment will be done at final link time. */ if (output_bfd != NULL) - return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message); /* Subtract the symbol section base address. */ @@ -1553,7 +1500,7 @@ ppc64_elf_sectoff_ha_reloc (abfd, reloc_entry, symbol, data, call the generic function. Any adjustment will be done at final link time. */ if (output_bfd != NULL) - return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message); /* Subtract the symbol section base address. */ @@ -1581,7 +1528,7 @@ ppc64_elf_toc_reloc (abfd, reloc_entry, symbol, data, call the generic function. Any adjustment will be done at final link time. */ if (output_bfd != NULL) - return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message); TOCstart = _bfd_get_gp_value (input_section->output_section->owner); @@ -1610,7 +1557,7 @@ ppc64_elf_toc_ha_reloc (abfd, reloc_entry, symbol, data, call the generic function. Any adjustment will be done at final link time. */ if (output_bfd != NULL) - return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message); TOCstart = _bfd_get_gp_value (input_section->output_section->owner); @@ -1643,7 +1590,7 @@ ppc64_elf_toc64_reloc (abfd, reloc_entry, symbol, data, call the generic function. Any adjustment will be done at final link time. */ if (output_bfd != NULL) - return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message); TOCstart = _bfd_get_gp_value (input_section->output_section->owner); @@ -1670,7 +1617,7 @@ ppc64_elf_unhandled_reloc (abfd, reloc_entry, symbol, data, call the generic function. Any adjustment will be done at final link time. */ if (output_bfd != NULL) - return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message); if (error_message != NULL) @@ -1683,32 +1630,35 @@ ppc64_elf_unhandled_reloc (abfd, reloc_entry, symbol, data, return bfd_reloc_dangerous; } -/* Function to set whether a module needs the -mrelocatable bit set. */ +/* Fix bad default arch selected for a 64 bit input bfd when the + default is 32 bit. */ static boolean -ppc64_elf_set_private_flags (abfd, flags) +ppc64_elf_object_p (abfd) bfd *abfd; - flagword flags; { - BFD_ASSERT (!elf_flags_init (abfd) - || elf_elfheader (abfd)->e_flags == flags); + if (abfd->arch_info->the_default && abfd->arch_info->bits_per_word == 32) + { + Elf_Internal_Ehdr *i_ehdr = elf_elfheader (abfd); - elf_elfheader (abfd)->e_flags = flags; - elf_flags_init (abfd) = true; + if (i_ehdr->e_ident[EI_CLASS] == ELFCLASS64) + { + /* Relies on arch after 32 bit default being 64 bit default. */ + abfd->arch_info = abfd->arch_info->next; + BFD_ASSERT (abfd->arch_info->bits_per_word == 64); + } + } return true; } /* Merge backend specific data from an object file to the output object file when linking. */ + static boolean ppc64_elf_merge_private_bfd_data (ibfd, obfd) bfd *ibfd; bfd *obfd; { - flagword old_flags; - flagword new_flags; - boolean error; - /* Check if we have the same endianess. */ if (ibfd->xvec->byteorder != obfd->xvec->byteorder && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN) @@ -1726,106 +1676,6 @@ ppc64_elf_merge_private_bfd_data (ibfd, obfd) return false; } - if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour - || bfd_get_flavour (obfd) != bfd_target_elf_flavour) - return true; - - new_flags = elf_elfheader (ibfd)->e_flags; - old_flags = elf_elfheader (obfd)->e_flags; - if (!elf_flags_init (obfd)) - { - /* First call, no flags set. */ - elf_flags_init (obfd) = true; - elf_elfheader (obfd)->e_flags = new_flags; - } - - else if (new_flags == old_flags) - /* Compatible flags are ok. */ - ; - - else - { - /* Incompatible flags. Warn about -mrelocatable mismatch. - Allow -mrelocatable-lib to be linked with either. */ - error = false; - if ((new_flags & EF_PPC_RELOCATABLE) != 0 - && (old_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0) - { - error = true; - (*_bfd_error_handler) - (_("%s: compiled with -mrelocatable and linked with modules compiled normally"), - bfd_archive_filename (ibfd)); - } - else if ((new_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0 - && (old_flags & EF_PPC_RELOCATABLE) != 0) - { - error = true; - (*_bfd_error_handler) - (_("%s: compiled normally and linked with modules compiled with -mrelocatable"), - bfd_archive_filename (ibfd)); - } - - /* The output is -mrelocatable-lib iff both the input files are. */ - if (! (new_flags & EF_PPC_RELOCATABLE_LIB)) - elf_elfheader (obfd)->e_flags &= ~EF_PPC_RELOCATABLE_LIB; - - /* The output is -mrelocatable iff it can't be -mrelocatable-lib, - but each input file is either -mrelocatable or -mrelocatable-lib. */ - if (! (elf_elfheader (obfd)->e_flags & EF_PPC_RELOCATABLE_LIB) - && (new_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE)) - && (old_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE))) - elf_elfheader (obfd)->e_flags |= EF_PPC_RELOCATABLE; - - /* Do not warn about eabi vs. V.4 mismatch, just or in the bit - if any module uses it. */ - elf_elfheader (obfd)->e_flags |= (new_flags & EF_PPC_EMB); - - new_flags &= ~(EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB); - old_flags &= ~(EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB); - - /* Warn about any other mismatches. */ - if (new_flags != old_flags) - { - error = true; - (*_bfd_error_handler) - (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"), - bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags); - } - - if (error) - { - bfd_set_error (bfd_error_bad_value); - return false; - } - } - - return true; -} - -/* Handle a PowerPC specific section when reading an object file. This - is called when elfcode.h finds a section with an unknown type. */ - -static boolean -ppc64_elf_section_from_shdr (abfd, hdr, name) - bfd *abfd; - Elf64_Internal_Shdr *hdr; - char *name; -{ - asection *newsect; - flagword flags; - - if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) - return false; - - newsect = hdr->bfd_section; - flags = bfd_get_section_flags (abfd, newsect); - if (hdr->sh_flags & SHF_EXCLUDE) - flags |= SEC_EXCLUDE; - - if (hdr->sh_type == SHT_ORDERED) - flags |= SEC_SORT_ENTRIES; - - bfd_set_section_flags (abfd, newsect, flags); return true; } @@ -1921,25 +1771,102 @@ struct ppc_dyn_relocs selects between relative and absolute types. */ #define IS_ABSOLUTE_RELOC(RTYPE) \ - ((RTYPE) != R_PPC64_REL14 \ - && (RTYPE) != R_PPC64_REL14_BRNTAKEN \ - && (RTYPE) != R_PPC64_REL14_BRTAKEN \ - && (RTYPE) != R_PPC64_REL24 \ - && (RTYPE) != R_PPC64_REL32 \ - && (RTYPE) != R_PPC64_REL64) + ((RTYPE) != R_PPC64_REL32 \ + && (RTYPE) != R_PPC64_REL64 \ + && (RTYPE) != R_PPC64_ADDR30) + +/* Section name for stubs is the associated section name plus this + string. */ +#define STUB_SUFFIX ".stub" + +/* Linker stubs. + ppc_stub_long_branch: + Used when a 14 bit branch (or even a 24 bit branch) can't reach its + destination, but a 24 bit branch in a stub section will reach. + . b dest + + ppc_stub_plt_branch: + Similar to the above, but a 24 bit branch in the stub section won't + reach its destination. + . addis %r12,%r2,xxx@ha + . ld %r11,xxx@l(%r12) + . mtctr %r11 + . bctr + + ppc_stub_plt_call: + Used to call a function in a shared library. + . addis %r12,%r2,xxx@ha + . std %r2,40(%r1) + . ld %r11,xxx+0@l(%r12) + . ld %r2,xxx+8@l(%r12) + . mtctr %r11 + . ld %r11,xxx+16@l(%r12) + . bctr +*/ + +enum ppc_stub_type { + ppc_stub_none, + ppc_stub_long_branch, + ppc_stub_plt_branch, + ppc_stub_plt_call +}; + +struct ppc_stub_hash_entry { + + /* Base hash table entry structure. */ + struct bfd_hash_entry root; -/* ppc64 ELF linker hash entry. */ + /* The stub section. */ + asection *stub_sec; + + /* Offset within stub_sec of the beginning of this stub. */ + bfd_vma stub_offset; + + /* Given the symbol's value and its section we can determine its final + value when building the stubs (so the stub knows where to jump. */ + bfd_vma target_value; + asection *target_section; + + enum ppc_stub_type stub_type; + + /* The symbol table entry, if any, that this was derived from. */ + struct ppc_link_hash_entry *h; + + /* Where this stub is being called from, or, in the case of combined + stub sections, the first input section in the group. */ + asection *id_sec; +}; + +struct ppc_branch_hash_entry { + + /* Base hash table entry structure. */ + struct bfd_hash_entry root; + + /* Offset within .branch_lt. */ + unsigned int offset; + + /* Generation marker. */ + unsigned int iter; +}; struct ppc_link_hash_entry { struct elf_link_hash_entry elf; + /* A pointer to the most recently used stub hash entry against this + symbol. */ + struct ppc_stub_hash_entry *stub_cache; + /* Track dynamic relocs copied for this symbol. */ struct ppc_dyn_relocs *dyn_relocs; + /* Link between function code and descriptor symbols. */ + struct elf_link_hash_entry *oh; + /* Flag function code and descriptor symbols. */ unsigned int is_func:1; unsigned int is_func_descriptor:1; + unsigned int is_entry:1; }; /* ppc64 ELF linker hash table. */ @@ -1948,6 +1875,32 @@ struct ppc_link_hash_table { struct elf_link_hash_table elf; + /* The stub hash table. */ + struct bfd_hash_table stub_hash_table; + + /* Another hash table for plt_branch stubs. */ + struct bfd_hash_table branch_hash_table; + + /* Linker stub bfd. */ + bfd *stub_bfd; + + /* Linker call-backs. */ + asection * (*add_stub_section) PARAMS ((const char *, asection *)); + void (*layout_sections_again) PARAMS ((void)); + + /* Array to keep track of which stub sections have been created, and + information on stub grouping. */ + struct map_stub { + /* This is the section to which stubs in the group will be attached. */ + asection *link_sec; + /* The stub section. */ + asection *stub_sec; + } *stub_group; + + /* Assorted information used by ppc64_elf_size_stubs. */ + int top_index; + asection **input_list; + /* Short-cuts to get to dynamic linker sections. */ asection *sgot; asection *srelgot; @@ -1955,25 +1908,185 @@ struct ppc_link_hash_table asection *srelplt; asection *sdynbss; asection *srelbss; - asection *sstub; asection *sglink; asection *sfpr; + asection *sbrlt; + asection *srelbrlt; /* Set on error. */ - int plt_overflow; + unsigned int stub_error; + + /* Flag set when small branches are detected. Used to + select suitable defaults for the stub group size. */ + unsigned int has_14bit_branch; /* Set if we detect a reference undefined weak symbol. */ unsigned int have_undefweak; + /* Incremented every time we size stubs. */ + unsigned int stub_iteration; + /* Small local sym to section mapping cache. */ struct sym_sec_cache sym_sec; }; +static struct bfd_hash_entry *stub_hash_newfunc + PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); +static struct bfd_hash_entry *branch_hash_newfunc + PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); +static struct bfd_hash_entry *link_hash_newfunc + PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); +static struct bfd_link_hash_table *ppc64_elf_link_hash_table_create + PARAMS ((bfd *)); +static void ppc64_elf_link_hash_table_free + PARAMS ((struct bfd_link_hash_table *)); +static char *ppc_stub_name + PARAMS ((const asection *, const asection *, + const struct ppc_link_hash_entry *, const Elf_Internal_Rela *)); +static struct ppc_stub_hash_entry *ppc_get_stub_entry + PARAMS ((const asection *, const asection *, struct elf_link_hash_entry *, + const Elf_Internal_Rela *, struct ppc_link_hash_table *)); +static struct ppc_stub_hash_entry *ppc_add_stub + PARAMS ((const char *, asection *, struct ppc_link_hash_table *)); +static boolean create_linkage_sections + PARAMS ((bfd *, struct bfd_link_info *)); +static boolean create_got_section + PARAMS ((bfd *, struct bfd_link_info *)); +static boolean ppc64_elf_create_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); +static void ppc64_elf_copy_indirect_symbol + PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *, + struct elf_link_hash_entry *)); +static boolean ppc64_elf_check_relocs + PARAMS ((bfd *, struct bfd_link_info *, asection *, + const Elf_Internal_Rela *)); +static asection * ppc64_elf_gc_mark_hook + PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, + struct elf_link_hash_entry *, Elf_Internal_Sym *)); +static boolean ppc64_elf_gc_sweep_hook + PARAMS ((bfd *, struct bfd_link_info *, asection *, + const Elf_Internal_Rela *)); +static boolean func_desc_adjust + PARAMS ((struct elf_link_hash_entry *, PTR)); +static boolean ppc64_elf_func_desc_adjust + PARAMS ((bfd *, struct bfd_link_info *)); +static boolean ppc64_elf_adjust_dynamic_symbol + PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); +static void ppc64_elf_hide_symbol + PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean)); +static boolean edit_opd + PARAMS ((bfd *, struct bfd_link_info *)); +static boolean allocate_dynrelocs + PARAMS ((struct elf_link_hash_entry *, PTR)); +static boolean readonly_dynrelocs + PARAMS ((struct elf_link_hash_entry *, PTR)); +static enum elf_reloc_type_class ppc64_elf_reloc_type_class + PARAMS ((const Elf_Internal_Rela *)); +static boolean ppc64_elf_size_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); +static INLINE enum ppc_stub_type ppc_type_of_stub + PARAMS ((asection *, const Elf_Internal_Rela *, + struct ppc_link_hash_entry **, bfd_vma)); +static bfd_byte *build_plt_stub + PARAMS ((bfd *, bfd_byte *, int, int)); +static boolean ppc_build_one_stub + PARAMS ((struct bfd_hash_entry *, PTR)); +static boolean ppc_size_one_stub + PARAMS ((struct bfd_hash_entry *, PTR)); +static void group_sections + PARAMS ((struct ppc_link_hash_table *, bfd_size_type, boolean)); +static boolean ppc64_elf_relocate_section + PARAMS ((bfd *, struct bfd_link_info *info, bfd *, asection *, bfd_byte *, + Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms, + asection **)); +static boolean ppc64_elf_finish_dynamic_symbol + PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, + Elf_Internal_Sym *)); +static boolean ppc64_elf_finish_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); + /* Get the ppc64 ELF linker hash table from a link_info structure. */ #define ppc_hash_table(p) \ ((struct ppc_link_hash_table *) ((p)->hash)) +#define ppc_stub_hash_lookup(table, string, create, copy) \ + ((struct ppc_stub_hash_entry *) \ + bfd_hash_lookup ((table), (string), (create), (copy))) + +#define ppc_branch_hash_lookup(table, string, create, copy) \ + ((struct ppc_branch_hash_entry *) \ + bfd_hash_lookup ((table), (string), (create), (copy))) + +/* Create an entry in the stub hash table. */ + +static struct bfd_hash_entry * +stub_hash_newfunc (entry, table, string) + struct bfd_hash_entry *entry; + struct bfd_hash_table *table; + const char *string; +{ + /* Allocate the structure if it has not already been allocated by a + subclass. */ + if (entry == NULL) + { + entry = bfd_hash_allocate (table, sizeof (struct ppc_stub_hash_entry)); + if (entry == NULL) + return entry; + } + + /* Call the allocation method of the superclass. */ + entry = bfd_hash_newfunc (entry, table, string); + if (entry != NULL) + { + struct ppc_stub_hash_entry *eh; + + /* Initialize the local fields. */ + eh = (struct ppc_stub_hash_entry *) entry; + eh->stub_sec = NULL; + eh->stub_offset = 0; + eh->target_value = 0; + eh->target_section = NULL; + eh->stub_type = ppc_stub_none; + eh->h = NULL; + eh->id_sec = NULL; + } + + return entry; +} + +/* Create an entry in the branch hash table. */ + +static struct bfd_hash_entry * +branch_hash_newfunc (entry, table, string) + struct bfd_hash_entry *entry; + struct bfd_hash_table *table; + const char *string; +{ + /* Allocate the structure if it has not already been allocated by a + subclass. */ + if (entry == NULL) + { + entry = bfd_hash_allocate (table, sizeof (struct ppc_branch_hash_entry)); + if (entry == NULL) + return entry; + } + + /* Call the allocation method of the superclass. */ + entry = bfd_hash_newfunc (entry, table, string); + if (entry != NULL) + { + struct ppc_branch_hash_entry *eh; + + /* Initialize the local fields. */ + eh = (struct ppc_branch_hash_entry *) entry; + eh->offset = 0; + eh->iter = 0; + } + + return entry; +} + /* Create an entry in a ppc64 ELF linker hash table. */ static struct bfd_hash_entry * @@ -1997,9 +2110,12 @@ link_hash_newfunc (entry, table, string) { struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) entry; + eh->stub_cache = NULL; eh->dyn_relocs = NULL; + eh->oh = NULL; eh->is_func = 0; eh->is_func_descriptor = 0; + eh->is_entry = 0; } return entry; @@ -2014,32 +2130,209 @@ 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_alloc (abfd, amt); + htab = (struct ppc_link_hash_table *) bfd_malloc (amt); if (htab == NULL) return NULL; if (! _bfd_elf_link_hash_table_init (&htab->elf, abfd, link_hash_newfunc)) { - bfd_release (abfd, htab); + free (htab); return NULL; } + /* Init the stub hash table too. */ + if (!bfd_hash_table_init (&htab->stub_hash_table, stub_hash_newfunc)) + return NULL; + + /* And the branch hash table. */ + 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->sgot = NULL; htab->srelgot = NULL; htab->splt = NULL; htab->srelplt = NULL; htab->sdynbss = NULL; htab->srelbss = NULL; - htab->sstub = NULL; htab->sglink = NULL; htab->sfpr = NULL; - htab->plt_overflow = 0; + htab->sbrlt = NULL; + htab->srelbrlt = NULL; + htab->stub_error = 0; + htab->has_14bit_branch = 0; htab->have_undefweak = 0; + htab->stub_iteration = 0; htab->sym_sec.abfd = NULL; return &htab->elf.root; } +/* Free the derived linker hash table. */ + +static void +ppc64_elf_link_hash_table_free (hash) + struct bfd_link_hash_table *hash; +{ + struct ppc_link_hash_table *ret = (struct ppc_link_hash_table *) hash; + + bfd_hash_table_free (&ret->stub_hash_table); + bfd_hash_table_free (&ret->branch_hash_table); + _bfd_generic_link_hash_table_free (hash); +} + +/* Build a name for an entry in the stub hash table. */ + +static char * +ppc_stub_name (input_section, sym_sec, h, rel) + const asection *input_section; + const asection *sym_sec; + const struct ppc_link_hash_entry *h; + const Elf_Internal_Rela *rel; +{ + char *stub_name; + bfd_size_type len; + + /* rel->r_addend is actually 64 bit, but who uses more than +/- 2^31 + offsets from a sym as a branch target? In fact, we could + probably assume the addend is always zero. */ + BFD_ASSERT (((int) rel->r_addend & 0xffffffff) == rel->r_addend); + + if (h) + { + len = 8 + 1 + strlen (h->elf.root.root.string) + 1 + 8 + 1; + stub_name = bfd_malloc (len); + if (stub_name != NULL) + { + sprintf (stub_name, "%08x_%s+%x", + input_section->id & 0xffffffff, + h->elf.root.root.string, + (int) rel->r_addend & 0xffffffff); + } + } + else + { + len = 8 + 1 + 8 + 1 + 8 + 1 + 16 + 1; + stub_name = bfd_malloc (len); + if (stub_name != NULL) + { + sprintf (stub_name, "%08x_%x:%x+%x", + input_section->id & 0xffffffff, + sym_sec->id & 0xffffffff, + (int) ELF64_R_SYM (rel->r_info) & 0xffffffff, + (int) rel->r_addend & 0xffffffff); + } + } + return stub_name; +} + +/* Look up an entry in the stub hash. Stub entries are cached because + creating the stub name takes a bit of time. */ + +static struct ppc_stub_hash_entry * +ppc_get_stub_entry (input_section, sym_sec, hash, rel, htab) + const asection *input_section; + const asection *sym_sec; + struct elf_link_hash_entry *hash; + const Elf_Internal_Rela *rel; + struct ppc_link_hash_table *htab; +{ + struct ppc_stub_hash_entry *stub_entry; + struct ppc_link_hash_entry *h = (struct ppc_link_hash_entry *) hash; + const asection *id_sec; + + /* If this input section is part of a group of sections sharing one + stub section, then use the id of the first section in the group. + Stub names need to include a section id, as there may well be + more than one stub used to reach say, printf, and we need to + distinguish between them. */ + id_sec = htab->stub_group[input_section->id].link_sec; + + if (h != NULL && h->stub_cache != NULL + && h->stub_cache->h == h + && h->stub_cache->id_sec == id_sec) + { + stub_entry = h->stub_cache; + } + else + { + char *stub_name; + + stub_name = ppc_stub_name (id_sec, sym_sec, h, rel); + if (stub_name == NULL) + return NULL; + + stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, + stub_name, false, false); + if (h != NULL) + h->stub_cache = stub_entry; + + free (stub_name); + } + + return stub_entry; +} + +/* Add a new stub entry to the stub hash. Not all fields of the new + stub entry are initialised. */ + +static struct ppc_stub_hash_entry * +ppc_add_stub (stub_name, section, htab) + const char *stub_name; + asection *section; + struct ppc_link_hash_table *htab; +{ + asection *link_sec; + asection *stub_sec; + struct ppc_stub_hash_entry *stub_entry; + + link_sec = htab->stub_group[section->id].link_sec; + stub_sec = htab->stub_group[section->id].stub_sec; + if (stub_sec == NULL) + { + stub_sec = htab->stub_group[link_sec->id].stub_sec; + if (stub_sec == NULL) + { + size_t namelen; + bfd_size_type len; + char *s_name; + + namelen = strlen (link_sec->name); + len = namelen + sizeof (STUB_SUFFIX); + s_name = bfd_alloc (htab->stub_bfd, len); + if (s_name == NULL) + return NULL; + + memcpy (s_name, link_sec->name, namelen); + memcpy (s_name + namelen, STUB_SUFFIX, sizeof (STUB_SUFFIX)); + stub_sec = (*htab->add_stub_section) (s_name, link_sec); + if (stub_sec == NULL) + return NULL; + htab->stub_group[link_sec->id].stub_sec = stub_sec; + } + htab->stub_group[section->id].stub_sec = stub_sec; + } + + /* Enter this entry into the linker stub hash table. */ + stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, stub_name, + true, false); + if (stub_entry == NULL) + { + (*_bfd_error_handler) (_("%s: cannot create stub entry %s"), + bfd_archive_filename (section->owner), + stub_name); + return NULL; + } + + stub_entry->stub_sec = stub_sec; + stub_entry->stub_offset = 0; + stub_entry->id_sec = link_sec; + return stub_entry; +} + /* Create sections for linker generated code. */ static boolean @@ -2055,24 +2348,38 @@ create_linkage_sections (dynobj, info) /* Create .sfpr for code to save and restore fp regs. */ flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - htab->sfpr = bfd_make_section (dynobj, ".sfpr"); + htab->sfpr = bfd_make_section_anyway (dynobj, ".sfpr"); if (htab->sfpr == NULL || ! bfd_set_section_flags (dynobj, htab->sfpr, flags) || ! bfd_set_section_alignment (dynobj, htab->sfpr, 2)) return false; - /* Create .stub and .glink for global linkage functions. */ - htab->sstub = bfd_make_section (dynobj, ".stub"); - if (htab->sstub == NULL - || ! bfd_set_section_flags (dynobj, htab->sstub, flags) - || ! bfd_set_section_alignment (dynobj, htab->sstub, 2)) - return false; - htab->sglink = bfd_make_section (dynobj, ".glink"); + /* Create .glink for lazy dynamic linking support. */ + htab->sglink = bfd_make_section_anyway (dynobj, ".glink"); if (htab->sglink == NULL || ! bfd_set_section_flags (dynobj, htab->sglink, flags) || ! bfd_set_section_alignment (dynobj, htab->sglink, 2)) return false; + /* Create .branch_lt for plt_branch stubs. */ + flags = (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); + htab->sbrlt = bfd_make_section_anyway (dynobj, ".branch_lt"); + if (htab->sbrlt == NULL + || ! bfd_set_section_flags (dynobj, htab->sbrlt, flags) + || ! bfd_set_section_alignment (dynobj, htab->sbrlt, 3)) + return false; + + if (info->shared) + { + flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY + | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); + htab->srelbrlt = bfd_make_section_anyway (dynobj, ".rela.branch_lt"); + if (!htab->srelbrlt + || ! bfd_set_section_flags (dynobj, htab->srelbrlt, flags) + || ! bfd_set_section_alignment (dynobj, htab->srelbrlt, 3)) + return false; + } return true; } @@ -2137,7 +2444,8 @@ ppc64_elf_create_dynamic_sections (dynobj, info) /* Copy the extra info we tack onto an elf_link_hash_entry. */ static void -ppc64_elf_copy_indirect_symbol (dir, ind) +ppc64_elf_copy_indirect_symbol (bed, dir, ind) + struct elf_backend_data *bed; struct elf_link_hash_entry *dir, *ind; { struct ppc_link_hash_entry *edir, *eind; @@ -2181,8 +2489,31 @@ ppc64_elf_copy_indirect_symbol (dir, ind) edir->is_func |= eind->is_func; edir->is_func_descriptor |= eind->is_func_descriptor; + edir->is_entry |= eind->is_entry; - _bfd_elf_link_hash_copy_indirect (dir, ind); + _bfd_elf_link_hash_copy_indirect (bed, dir, ind); +} + +/* Set a flag, used by ppc64_elf_gc_mark_hook, on the entry symbol and + symbols undefined on the command-line. */ + +boolean +ppc64_elf_mark_entry_syms (info) + struct bfd_link_info *info; +{ + struct ppc_link_hash_table *htab; + struct bfd_sym_chain *sym; + + htab = ppc_hash_table (info); + for (sym = info->gc_sym_list; sym; sym = sym->next) + { + struct elf_link_hash_entry *h; + + h = elf_link_hash_lookup (&htab->elf, sym->name, false, false, false); + if (h != NULL) + ((struct ppc_link_hash_entry *) h)->is_entry = 1; + } + return true; } /* Look through the relocs for a section during the first phase, and @@ -2202,7 +2533,7 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs) const Elf_Internal_Rela *rel; const Elf_Internal_Rela *rel_end; asection *sreloc; - boolean is_opd; + asection **opd_sym_map; if (info->relocateable) return true; @@ -2212,12 +2543,34 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs) sym_hashes = elf_sym_hashes (abfd); sym_hashes_end = (sym_hashes - + symtab_hdr->sh_size / sizeof (Elf64_External_Sym)); - if (!elf_bad_symtab (abfd)) - sym_hashes_end -= symtab_hdr->sh_info; + + symtab_hdr->sh_size / sizeof (Elf64_External_Sym) + - symtab_hdr->sh_info); sreloc = NULL; - is_opd = strcmp (bfd_get_section_name (abfd, sec), ".opd") == 0; + opd_sym_map = NULL; + if (strcmp (bfd_get_section_name (abfd, sec), ".opd") == 0) + { + /* Garbage collection needs some extra help with .opd sections. + We don't want to necessarily keep everything referenced by + relocs in .opd, as that would keep all functions. Instead, + if we reference an .opd symbol (a function descriptor), we + want to keep the function code symbol's section. This is + easy for global symbols, but for local syms we need to keep + information about the associated function section. Later, if + edit_opd deletes entries, we'll use this array to adjust + local syms in .opd. */ + union opd_info { + asection *func_section; + long entry_adjust; + }; + bfd_size_type amt; + + amt = sec->_raw_size * sizeof (union opd_info) / 24; + opd_sym_map = (asection **) bfd_zalloc (abfd, amt); + if (opd_sym_map == NULL) + return false; + elf_section_data (sec)->tdata = opd_sym_map; + } if (htab->elf.dynobj == NULL) htab->elf.dynobj = abfd; @@ -2286,14 +2639,14 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs) case R_PPC64_PLT32: case R_PPC64_PLT64: /* This symbol requires a procedure linkage table entry. We - actually build the entry in adjust_dynamic_symbol, - because this might be a case of linking PIC code without - linking in any dynamic objects, in which case we don't - need to generate a procedure linkage table after all. */ + actually build the entry in adjust_dynamic_symbol, + because this might be a case of linking PIC code without + linking in any dynamic objects, in which case we don't + need to generate a procedure linkage table after all. */ if (h == NULL) { /* It does not make sense to have a procedure linkage - table entry for a local symbol. */ + table entry for a local symbol. */ bfd_set_error (bfd_error_bad_value); return false; } @@ -2334,6 +2687,12 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs) return false; break; + case R_PPC64_REL14: + case R_PPC64_REL14_BRTAKEN: + case R_PPC64_REL14_BRNTAKEN: + htab->has_14bit_branch = 1; + /* Fall through. */ + case R_PPC64_REL24: if (h != NULL && h->root.root.string[0] == '.' @@ -2348,7 +2707,7 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs) break; case R_PPC64_ADDR64: - if (is_opd + if (opd_sym_map != NULL && h != NULL && h->root.root.string[0] == '.' && h->root.root.string[1] != 0) @@ -2359,22 +2718,31 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs) false, false, false); if (fdh != NULL) { - /* Ensure the function descriptor symbol string is - part of the code symbol string. We aren't - changing the name here, just allowing some tricks - in ppc64_elf_hide_symbol. */ - fdh->root.root.string = h->root.root.string + 1; ((struct ppc_link_hash_entry *) fdh)->is_func_descriptor = 1; + ((struct ppc_link_hash_entry *) fdh)->oh = h; ((struct ppc_link_hash_entry *) h)->is_func = 1; + ((struct ppc_link_hash_entry *) h)->oh = fdh; } } + if (opd_sym_map != NULL + && h == NULL + && rel + 1 < rel_end + && ((enum elf_ppc_reloc_type) ELF64_R_TYPE ((rel + 1)->r_info) + == R_PPC64_TOC)) + { + asection *s; + + s = bfd_section_from_r_symndx (abfd, &htab->sym_sec, sec, + r_symndx); + if (s == NULL) + return false; + else if (s != sec) + opd_sym_map[rel->r_offset / 24] = s; + } /* Fall through. */ case R_PPC64_REL64: case R_PPC64_REL32: - case R_PPC64_REL14: - case R_PPC64_REL14_BRTAKEN: - case R_PPC64_REL14_BRNTAKEN: case R_PPC64_ADDR14: case R_PPC64_ADDR14_BRNTAKEN: case R_PPC64_ADDR14_BRTAKEN: @@ -2396,7 +2764,7 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs) case R_PPC64_UADDR64: case R_PPC64_TOC: /* Don't propagate .opd relocs. */ - if (NO_OPD_RELOCS && is_opd) + if (NO_OPD_RELOCS && opd_sym_map != NULL) break; /* If we are creating a shared library, and this is a reloc @@ -2537,16 +2905,19 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs) relocation. */ static asection * -ppc64_elf_gc_mark_hook (abfd, info, rel, h, sym) - bfd *abfd; +ppc64_elf_gc_mark_hook (sec, info, rel, h, sym) + asection *sec; struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; { + asection *rsec = NULL; + if (h != NULL) { enum elf_ppc_reloc_type r_type; + struct ppc_link_hash_entry *fdh; r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info); switch (r_type) @@ -2560,10 +2931,26 @@ ppc64_elf_gc_mark_hook (abfd, info, rel, h, sym) { case bfd_link_hash_defined: case bfd_link_hash_defweak: - return h->root.u.def.section; + fdh = (struct ppc_link_hash_entry *) h; + + /* Function descriptor syms cause the associated + function code sym section to be marked. */ + if (fdh->is_func_descriptor) + rsec = fdh->oh->root.u.def.section; + + /* Function entry syms return NULL if they are in .opd + and are not ._start (or others undefined on the ld + command line). Thus we avoid marking all function + sections, as all functions are referenced in .opd. */ + else if ((fdh->oh != NULL + && ((struct ppc_link_hash_entry *) fdh->oh)->is_entry) + || elf_section_data (sec)->tdata == NULL) + rsec = h->root.u.def.section; + break; case bfd_link_hash_common: - return h->root.u.c.p->section; + rsec = h->root.u.c.p->section; + break; default: break; @@ -2572,10 +2959,17 @@ ppc64_elf_gc_mark_hook (abfd, info, rel, h, sym) } else { - return bfd_section_from_elf_index (abfd, sym->st_shndx); + asection **opd_sym_section; + + rsec = bfd_section_from_elf_index (sec->owner, sym->st_shndx); + opd_sym_section = (asection **) elf_section_data (rsec)->tdata; + if (opd_sym_section != NULL) + rsec = opd_sym_section[sym->st_value / 24]; + else if (elf_section_data (sec)->tdata != NULL) + rsec = NULL; } - return NULL; + return rsec; } /* Update the .got, .plt. and dynamic reloc reference counts for the @@ -2642,6 +3036,9 @@ ppc64_elf_gc_sweep_hook (abfd, info, sec, relocs) } break; + case R_PPC64_REL14: + case R_PPC64_REL14_BRNTAKEN: + case R_PPC64_REL14_BRTAKEN: case R_PPC64_REL24: if (r_symndx >= symtab_hdr->sh_info) { @@ -2651,9 +3048,6 @@ ppc64_elf_gc_sweep_hook (abfd, info, sec, relocs) } break; - case R_PPC64_REL14: - case R_PPC64_REL14_BRNTAKEN: - case R_PPC64_REL14_BRTAKEN: case R_PPC64_REL32: case R_PPC64_REL64: if (r_symndx >= symtab_hdr->sh_info) @@ -2758,14 +3152,15 @@ func_desc_adjust (h, inf) && h->root.root.string[0] == '.' && h->root.root.string[1] != '\0') { - struct elf_link_hash_entry *fdh; + struct elf_link_hash_entry *fdh = ((struct ppc_link_hash_entry *) h)->oh; boolean force_local; /* Find the corresponding function descriptor symbol. Create it as undefined if necessary. */ - fdh = elf_link_hash_lookup (&htab->elf, h->root.root.string + 1, - false, false, true); + if (fdh == NULL) + fdh = elf_link_hash_lookup (&htab->elf, h->root.root.string + 1, + false, false, true); if (fdh == NULL && info->shared @@ -2814,7 +3209,8 @@ func_desc_adjust (h, inf) fdh->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; } ((struct ppc_link_hash_entry *) fdh)->is_func_descriptor = 1; - fdh->root.root.string = h->root.root.string + 1; + ((struct ppc_link_hash_entry *) fdh)->oh = h; + ((struct ppc_link_hash_entry *) h)->oh = fdh; } /* Now that the info is on the function descriptor, clear the @@ -2824,8 +3220,14 @@ func_desc_adjust (h, inf) been imported from another library. Function code syms that are really in the library we must leave global to prevent the linker dragging in a definition from a static library. */ - force_local = ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0 - && info->shared); + force_local = (info->shared + && ((h->elf_link_hash_flags + & ELF_LINK_HASH_DEF_REGULAR) == 0 + || fdh == NULL + || (fdh->elf_link_hash_flags + & ELF_LINK_HASH_DEF_REGULAR) == 0 + || (fdh->elf_link_hash_flags + & ELF_LINK_FORCED_LOCAL) != 0)); _bfd_elf_link_hash_hide_symbol (info, h, force_local); } @@ -2947,7 +3349,6 @@ ppc64_elf_func_desc_adjust (obfd, info) bfd_put_32 (htab->elf.dynobj, BLR, p); } - elf_link_hash_traverse (&htab->elf, func_desc_adjust, (PTR) info); return true; } @@ -3091,18 +3492,362 @@ ppc64_elf_hide_symbol (info, h, force_local) if (((struct ppc_link_hash_entry *) h)->is_func_descriptor) { - const char *name; - struct elf_link_hash_entry *fh; - struct ppc_link_hash_table *htab; + struct elf_link_hash_entry *fh = ((struct ppc_link_hash_entry *) h)->oh; - name = h->root.root.string - 1; - htab = ppc_hash_table (info); - fh = elf_link_hash_lookup (&htab->elf, name, false, false, false); + if (fh == NULL) + { + const char *p, *q; + struct ppc_link_hash_table *htab; + char save; + + /* We aren't supposed to use alloca in BFD because on + systems which do not have alloca the version in libiberty + calls xmalloc, which might cause the program to crash + when it runs out of memory. This function doesn't have a + return status, so there's no way to gracefully return an + error. So cheat. We know that string[-1] can be safely + dereferenced; It's either a string in an ELF string + table, or allocated in an objalloc structure. */ + + p = h->root.root.string - 1; + save = *p; + *(char *) p = '.'; + htab = ppc_hash_table (info); + fh = elf_link_hash_lookup (&htab->elf, p, false, false, false); + *(char *) p = save; + + /* Unfortunately, if it so happens that the string we were + looking for was allocated immediately before this string, + then we overwrote the string terminator. That's the only + reason the lookup should fail. */ + if (fh == NULL) + { + q = h->root.root.string + strlen (h->root.root.string); + while (q >= h->root.root.string && *q == *p) + --q, --p; + if (q < h->root.root.string && *p == '.') + fh = elf_link_hash_lookup (&htab->elf, p, false, false, false); + } + if (fh != NULL) + { + ((struct ppc_link_hash_entry *) h)->oh = fh; + ((struct ppc_link_hash_entry *) fh)->oh = h; + } + } if (fh != NULL) _bfd_elf_link_hash_hide_symbol (info, fh, force_local); } } +static boolean +edit_opd (obfd, info) + bfd *obfd; + struct bfd_link_info *info; +{ + bfd *ibfd; + unsigned int bfd_indx; + + for (bfd_indx = 0, ibfd = info->input_bfds; + ibfd != NULL; + ibfd = ibfd->link_next, bfd_indx++) + { + asection *sec; + Elf_Internal_Rela *relstart, *rel, *relend; + Elf_Internal_Shdr *symtab_hdr; + Elf_Internal_Sym *local_syms; + struct elf_link_hash_entry **sym_hashes; + bfd_vma offset; + long *adjust; + boolean need_edit; + + sec = bfd_get_section_by_name (ibfd, ".opd"); + if (sec == NULL) + continue; + + adjust = (long *) elf_section_data (sec)->tdata; + BFD_ASSERT (adjust != NULL); + memset (adjust, 0, (size_t) sec->_raw_size * sizeof (long) / 24); + + if (sec->output_section == bfd_abs_section_ptr) + continue; + + /* Look through the section relocs. */ + if ((sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0) + continue; + + local_syms = NULL; + symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; + sym_hashes = elf_sym_hashes (ibfd); + + /* Read the relocations. */ + relstart = _bfd_elf64_link_read_relocs (obfd, sec, (PTR) NULL, + (Elf_Internal_Rela *) NULL, + info->keep_memory); + if (relstart == NULL) + return false; + + /* First run through the relocs to check they are sane, and to + determine whether we need to edit this opd section. */ + need_edit = false; + offset = 0; + relend = relstart + sec->reloc_count; + for (rel = relstart; rel < relend; rel++) + { + enum elf_ppc_reloc_type r_type; + unsigned long r_symndx; + asection *sym_sec; + struct elf_link_hash_entry *h; + Elf_Internal_Sym *sym; + + /* .opd contains a regular array of 24 byte entries. We're + only interested in the reloc pointing to a function entry + point. */ + r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info); + if (r_type == R_PPC64_TOC) + continue; + + if (r_type != R_PPC64_ADDR64) + { + (*_bfd_error_handler) + (_("%s: unexpected reloc type %u in .opd section"), + bfd_archive_filename (ibfd), r_type); + need_edit = false; + break; + } + + if (rel + 1 >= relend) + continue; + r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE ((rel + 1)->r_info); + if (r_type != R_PPC64_TOC) + continue; + + if (rel->r_offset != offset) + { + /* If someone messes with .opd alignment then after a + "ld -r" we might have padding in the middle of .opd. + Also, there's nothing to prevent someone putting + something silly in .opd with the assembler. No .opd + optimization for them! */ + (*_bfd_error_handler) + (_("%s: .opd is not a regular array of opd entries"), + bfd_archive_filename (ibfd)); + need_edit = false; + break; + } + + r_symndx = ELF64_R_SYM (rel->r_info); + sym_sec = NULL; + h = NULL; + sym = NULL; + if (r_symndx >= symtab_hdr->sh_info) + { + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + if (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + sym_sec = h->root.u.def.section; + } + else + { + if (local_syms == NULL) + { + local_syms = (Elf_Internal_Sym *) symtab_hdr->contents; + if (local_syms == NULL) + local_syms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, + symtab_hdr->sh_info, 0, + NULL, NULL, NULL); + if (local_syms == NULL) + goto error_free_rel; + } + sym = local_syms + r_symndx; + if ((sym->st_shndx != SHN_UNDEF + && sym->st_shndx < SHN_LORESERVE) + || sym->st_shndx > SHN_HIRESERVE) + sym_sec = bfd_section_from_elf_index (ibfd, sym->st_shndx); + } + + if (sym_sec == NULL || sym_sec->owner == NULL) + { + (*_bfd_error_handler) + (_("%s: undefined sym `%s' in .opd section"), + bfd_archive_filename (ibfd), + h != NULL ? h->root.root.string : "<local symbol>"); + need_edit = false; + break; + } + + /* opd entries are always for functions defined in the + current input bfd. If the symbol isn't defined in the + input bfd, then we won't be using the function in this + bfd; It must be defined in a linkonce section in another + bfd, or is weak. It's also possible that we are + discarding the function due to a linker script /DISCARD/, + which we test for via the output_section. */ + if (sym_sec->owner != ibfd + || sym_sec->output_section == bfd_abs_section_ptr) + need_edit = true; + + offset += 24; + } + + if (need_edit) + { + Elf_Internal_Rela *write_rel; + bfd_byte *rptr, *wptr; + boolean skip; + + /* This seems a waste of time as input .opd sections are all + zeros as generated by gcc, but I suppose there's no reason + this will always be so. We might start putting something in + the third word of .opd entries. */ + if ((sec->flags & SEC_IN_MEMORY) == 0) + { + bfd_byte *loc = bfd_alloc (ibfd, sec->_raw_size); + if (loc == NULL + || !bfd_get_section_contents (ibfd, sec, loc, (bfd_vma) 0, + sec->_raw_size)) + { + if (local_syms != NULL + && symtab_hdr->contents != (unsigned char *) local_syms) + free (local_syms); + error_free_rel: + if (elf_section_data (sec)->relocs != relstart) + free (relstart); + return false; + } + sec->contents = loc; + sec->flags |= (SEC_IN_MEMORY | SEC_HAS_CONTENTS); + } + + elf_section_data (sec)->relocs = relstart; + + wptr = sec->contents; + rptr = sec->contents; + write_rel = relstart; + skip = false; + offset = 0; + for (rel = relstart; rel < relend; rel++) + { + if (rel->r_offset == offset) + { + unsigned long r_symndx; + asection *sym_sec; + struct elf_link_hash_entry *h; + Elf_Internal_Sym *sym; + + r_symndx = ELF64_R_SYM (rel->r_info); + sym_sec = NULL; + h = NULL; + sym = NULL; + if (r_symndx >= symtab_hdr->sh_info) + { + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + if (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + sym_sec = h->root.u.def.section; + } + else + { + sym = local_syms + r_symndx; + if ((sym->st_shndx != SHN_UNDEF + && sym->st_shndx < SHN_LORESERVE) + || sym->st_shndx > SHN_HIRESERVE) + sym_sec = bfd_section_from_elf_index (ibfd, + sym->st_shndx); + } + + skip = (sym_sec->owner != ibfd + || sym_sec->output_section == bfd_abs_section_ptr); + if (skip) + { + if (h != NULL && sym_sec->owner == ibfd) + { + /* Arrange for the function descriptor sym + to be dropped. */ + struct elf_link_hash_entry *fdh; + struct ppc_link_hash_entry *fh; + + fh = (struct ppc_link_hash_entry *) h; + BFD_ASSERT (fh->is_func); + fdh = fh->oh; + fdh->root.u.def.value = 0; + fdh->root.u.def.section = sym_sec; + } + } + else + { + /* We'll be keeping this opd entry. */ + + if (h != NULL) + { + /* Redefine the function descriptor symbol + to this location in the opd section. + We've checked above that opd relocs are + ordered. */ + struct elf_link_hash_entry *fdh; + struct ppc_link_hash_entry *fh; + + fh = (struct ppc_link_hash_entry *) h; + BFD_ASSERT (fh->is_func); + fdh = fh->oh; + fdh->root.u.def.value = wptr - sec->contents; + } + else + { + /* Local syms are a bit tricky. We could + tweak them as they can be cached, but + we'd need to look through the local syms + for the function descriptor sym which we + don't have at the moment. So keep an + array of adjustments. */ + adjust[(rel->r_offset + wptr - rptr) / 24] + = wptr - rptr; + } + + if (wptr != rptr) + memcpy (wptr, rptr, 24); + wptr += 24; + } + rptr += 24; + offset += 24; + } + + /* We need to adjust any reloc offsets to point to the + new opd entries. While we're at it, we may as well + remove redundant relocs. */ + if (!skip) + { + rel->r_offset += wptr - rptr; + if (write_rel != rel) + memcpy (write_rel, rel, sizeof (*rel)); + ++write_rel; + } + } + + sec->_cooked_size = wptr - sec->contents; + sec->reloc_count = write_rel - relstart; + } + else if (elf_section_data (sec)->relocs != relstart) + free (relstart); + + if (local_syms != NULL + && symtab_hdr->contents != (unsigned char *) local_syms) + { + if (!info->keep_memory) + free (local_syms); + else + symtab_hdr->contents = (unsigned char *) local_syms; + } + } + + return true; +} + /* This is the condition under which ppc64_elf_finish_dynamic_symbol will be called from elflink.h. If elflink.h doesn't call our finish_dynamic_symbol routine, we'll need to do something about @@ -3156,10 +3901,7 @@ allocate_dynrelocs (h, inf) /* Make room for this entry. */ s->_raw_size += PLT_ENTRY_SIZE; - /* Make room for the .stub and .glink code. */ - s = htab->sstub; - s->_raw_size += PLT_CALL_STUB_SIZE; - + /* Make room for the .glink code. */ s = htab->sglink; if (s->_raw_size == 0) s->_raw_size += GLINK_CALL_STUB_SIZE; @@ -3404,6 +4146,9 @@ ppc64_elf_size_dynamic_sections (output_bfd, info) } } + if (!edit_opd (output_bfd, info)) + return false; + /* Allocate global sym .plt and .got entries, and space for global sym dynamic relocs. */ elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info); @@ -3413,15 +4158,15 @@ ppc64_elf_size_dynamic_sections (output_bfd, info) relocs = false; for (s = dynobj->sections; s != NULL; s = s->next) { - bfd_vma size; - if ((s->flags & SEC_LINKER_CREATED) == 0) continue; - if (s == htab->splt - || s == htab->sgot - || s == htab->sstub - || s == htab->sglink) + if (s == htab->sbrlt || s == htab->srelbrlt) + /* These haven't been allocated yet; don't strip. */ + continue; + else if (s == htab->splt + || s == htab->sgot + || s == htab->sglink) { /* Strip this section if we don't need it; see the comment below. */ @@ -3462,18 +4207,16 @@ ppc64_elf_size_dynamic_sections (output_bfd, info) continue; } + /* .plt is in the bss section. We don't initialise it. */ + if ((s->flags & SEC_LOAD) == 0) + continue; + /* Allocate memory for the section contents. We use bfd_zalloc here in case unused entries are not reclaimed before the section's contents are written out. This should not happen, but this way if it does, we get a R_PPC64_NONE reloc instead of garbage. */ - size = s->_raw_size; - if (s == htab->sstub) - { - /* .stub may grow. Allocate enough for the maximum growth. */ - size += (size + 65536 + 65535) / 65536 * 4; - } - s->contents = (bfd_byte *) bfd_zalloc (dynobj, size); + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); if (s->contents == NULL) return false; } @@ -3494,7 +4237,7 @@ ppc64_elf_size_dynamic_sections (output_bfd, info) return false; } - if (htab->splt->_raw_size != 0) + if (htab->splt != NULL && htab->splt->_raw_size != 0) { if (!add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) @@ -3536,116 +4279,55 @@ ppc64_elf_size_dynamic_sections (output_bfd, info) return true; } -/* Called after we have determined section placement. If sections - move, we'll be called again. Provide a value for TOCstart. */ +/* Determine the type of stub needed, if any, for a call. */ -bfd_vma -ppc64_elf_toc (obfd) - bfd *obfd; +static INLINE enum ppc_stub_type +ppc_type_of_stub (input_sec, rel, hash, destination) + asection *input_sec; + const Elf_Internal_Rela *rel; + struct ppc_link_hash_entry **hash; + bfd_vma destination; { - asection *s; - bfd_vma TOCstart; + struct ppc_link_hash_entry *h = *hash; + bfd_vma location; + bfd_vma branch_offset; + bfd_vma max_branch_offset; + unsigned int r_type; - /* The TOC consists of sections .got, .toc, .tocbss, .plt in that - order. The TOC starts where the first of these sections starts. */ - s = bfd_get_section_by_name (obfd, ".got"); - if (s == NULL) - s = bfd_get_section_by_name (obfd, ".toc"); - if (s == NULL) - s = bfd_get_section_by_name (obfd, ".tocbss"); - if (s == NULL) - s = bfd_get_section_by_name (obfd, ".plt"); - if (s == NULL) + if (h != NULL) { - /* This may happen for - o references to TOC base (SYM@toc / TOC[tc0]) without a - .toc directive - o bad linker script - o --gc-sections and empty TOC sections - - FIXME: Warn user? */ + if (h->oh != NULL + && h->oh->plt.offset != (bfd_vma) -1 + && h->oh->dynindx != -1) + { + *hash = (struct ppc_link_hash_entry *) h->oh; + return ppc_stub_plt_call; + } - /* Look for a likely section. We probably won't even be - using TOCstart. */ - for (s = obfd->sections; s != NULL; s = s->next) - if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA | SEC_READONLY)) - == (SEC_ALLOC | SEC_SMALL_DATA)) - break; - if (s == NULL) - for (s = obfd->sections; s != NULL; s = s->next) - if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA)) - == (SEC_ALLOC | SEC_SMALL_DATA)) - break; - if (s == NULL) - for (s = obfd->sections; s != NULL; s = s->next) - if ((s->flags & (SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC) - break; - if (s == NULL) - for (s = obfd->sections; s != NULL; s = s->next) - if ((s->flags & SEC_ALLOC) == SEC_ALLOC) - break; + if (h->elf.root.type == bfd_link_hash_undefweak + || h->elf.root.type == bfd_link_hash_undefined) + return ppc_stub_none; } - TOCstart = 0; - if (s != NULL) - TOCstart = s->output_section->vma + s->output_offset; - - return TOCstart; -} - -/* PowerPC64 .plt entries are 24 bytes long, which doesn't divide - evenly into 64k. Sometimes with a large enough .plt, we'll need to - use offsets differing in the high 16 bits when accessing a .plt - entry from a .plt call stub. This function adjusts the size of - .stub to accommodate the extra stub instruction needed in such - cases. */ - -boolean -ppc64_elf_size_stubs (obfd, info, changed) - bfd *obfd; - struct bfd_link_info *info; - int *changed; -{ - struct ppc_link_hash_table *htab = ppc_hash_table (info); - bfd_vma plt_offset, next_64k; - long base, num, extra; - - /* .plt and .stub should be both present, or both absent. */ - if ((htab->splt == NULL || htab->splt->_raw_size == 0) - != (htab->sstub == NULL || htab->sstub->_raw_size == 0)) - abort (); + /* Determine where the call point is. */ + location = (input_sec->output_offset + + input_sec->output_section->vma + + rel->r_offset); - /* If no .plt, then nothing to do. */ - if (htab->splt == NULL || htab->splt->_raw_size == 0) - return true; + branch_offset = destination - location; + r_type = ELF64_R_TYPE (rel->r_info); - plt_offset = (htab->splt->output_section->vma - + htab->splt->output_offset - - elf_gp (obfd)); - next_64k = (plt_offset + 65535) & -65536; + /* Determine if a long branch stub is needed. */ + max_branch_offset = 1 << 25; + if (r_type != (unsigned int) R_PPC64_REL24) + max_branch_offset = 1 << 15; - /* If the .plt doesn't have any entries crossing a 64k boundary, - then there is no need for bigger stubs. */ - if (plt_offset + htab->splt->_raw_size <= next_64k) - return true; + if (branch_offset + max_branch_offset >= 2 * max_branch_offset) + /* We need a stub. Figure out whether a long_branch or plt_branch + is needed later. */ + return ppc_stub_long_branch; - /* OK, so we have at least one transition. Since .plt entries are - 24 bytes long, we'll strike it lucky every 3*64k, with the 64k - boundary between .plt entries. */ - base = next_64k / 65536; - num = (plt_offset + htab->splt->_raw_size - next_64k) / 65536; - extra = (base % 3 + num + 1) * 2 / 3; - - /* Allow one extra instruction for each EXTRA. The change in .stub - may change the location of .toc and .plt. .toc and .plt ought to - move as a group, but someone might be playing with eg. .plt - alignment, so don't allow .stub size to decrease. */ - if (htab->sstub->_cooked_size < htab->sstub->_raw_size + extra * 4) - { - htab->sstub->_cooked_size = htab->sstub->_raw_size + extra * 4; - *changed = true; - } - return true; + return ppc_stub_none; } /* Build a .plt call stub. */ @@ -3680,158 +4362,848 @@ build_plt_stub (obfd, p, offset, glink) return p; } -/* Build the stubs for one function call. */ - static boolean -build_one_stub (h, inf) - struct elf_link_hash_entry *h; - PTR inf; +ppc_build_one_stub (gen_entry, in_arg) + struct bfd_hash_entry *gen_entry; + PTR in_arg; { + struct ppc_stub_hash_entry *stub_entry; + struct ppc_branch_hash_entry *br_entry; struct bfd_link_info *info; struct ppc_link_hash_table *htab; + asection *stub_sec; + bfd *stub_bfd; + bfd_byte *loc; + bfd_byte *p; + unsigned int indx; + bfd_vma off; + int size; - if (h->root.type == bfd_link_hash_indirect - || h->root.type == bfd_link_hash_warning) - return true; + /* Massage our args to the form they really have. */ + stub_entry = (struct ppc_stub_hash_entry *) gen_entry; + info = (struct bfd_link_info *) in_arg; - info = (struct bfd_link_info *) inf; htab = ppc_hash_table (info); + stub_sec = stub_entry->stub_sec; - if (htab->elf.dynamic_sections_created - && h->plt.offset != (bfd_vma) -1 - && ((struct ppc_link_hash_entry *) h)->is_func_descriptor) + /* Make a note of the offset within the stubs for this entry. */ + stub_entry->stub_offset = stub_sec->_cooked_size; + loc = stub_sec->contents + stub_entry->stub_offset; + + stub_bfd = stub_sec->owner; + + switch (stub_entry->stub_type) { - struct elf_link_hash_entry *fh; - asection *s; - bfd_vma plt_r2; - bfd_byte *p; - unsigned int indx; + case ppc_stub_long_branch: + /* Branches are relative. This is where we are going to. */ + off = (stub_entry->target_value + + stub_entry->target_section->output_offset + + stub_entry->target_section->output_section->vma); - fh = elf_link_hash_lookup (&htab->elf, h->root.root.string - 1, - false, false, true); + /* And this is where we are coming from. */ + off -= (stub_entry->stub_offset + + stub_sec->output_offset + + stub_sec->output_section->vma); - if (fh == NULL) - abort (); + BFD_ASSERT (off + (1 << 25) < (bfd_vma) (1 << 26)); - BFD_ASSERT (((struct ppc_link_hash_entry *) fh)->is_func); + bfd_put_32 (stub_bfd, (bfd_vma) B_DOT | (off & 0x3fffffc), loc); + size = 4; + break; - /* Build the .plt call stub. */ - plt_r2 = (htab->splt->output_section->vma - + htab->splt->output_offset - + h->plt.offset - - elf_gp (htab->splt->output_section->owner) - - TOC_BASE_OFF); + case ppc_stub_plt_branch: + br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table, + stub_entry->root.string + 9, + false, false); + if (br_entry == NULL) + { + (*_bfd_error_handler) (_("can't find branch stub `%s'"), + stub_entry->root.string + 9); + htab->stub_error = true; + return false; + } + + off = (stub_entry->target_value + + stub_entry->target_section->output_offset + + stub_entry->target_section->output_section->vma); + + bfd_put_64 (htab->sbrlt->owner, off, + htab->sbrlt->contents + br_entry->offset); + + if (info->shared) + { + /* Create a reloc for the branch lookup table entry. */ + Elf_Internal_Rela rela; + Elf64_External_Rela *r; + + rela.r_offset = (br_entry->offset + + htab->sbrlt->output_offset + + htab->sbrlt->output_section->vma); + rela.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE); + rela.r_addend = off; + + r = (Elf64_External_Rela *) htab->srelbrlt->contents; + r += htab->srelbrlt->reloc_count++; + bfd_elf64_swap_reloca_out (htab->srelbrlt->owner, &rela, r); + } + + off = (br_entry->offset + + htab->sbrlt->output_offset + + htab->sbrlt->output_section->vma + - elf_gp (htab->sbrlt->output_section->owner) + - TOC_BASE_OFF); - if (plt_r2 + 0x80000000 > 0xffffffff - || (plt_r2 & 3) != 0) + if (off + 0x80000000 > 0xffffffff || (off & 7) != 0) { (*_bfd_error_handler) (_("linkage table error against `%s'"), - h->root.root.string); + stub_entry->root.string); bfd_set_error (bfd_error_bad_value); - htab->plt_overflow = true; + htab->stub_error = true; return false; } - s = htab->sstub; - /* Steal plt.offset to store the stub offset. */ - fh->plt.offset = s->_cooked_size; - p = s->contents + s->_cooked_size; - p = build_plt_stub (s->owner, p, (int) plt_r2, 0); - s->_cooked_size = p - s->contents; - - /* Build the .glink lazy link call stub. */ - s = htab->sglink; - p = s->contents + s->_cooked_size; - indx = s->reloc_count; - if (indx < 0x8000) + indx = off; + bfd_put_32 (stub_bfd, (bfd_vma) ADDIS_R12_R2 | PPC_HA (indx), loc); + bfd_put_32 (stub_bfd, (bfd_vma) LD_R11_0R12 | PPC_LO (indx), loc + 4); + bfd_put_32 (stub_bfd, (bfd_vma) MTCTR_R11, loc + 8); + bfd_put_32 (stub_bfd, (bfd_vma) BCTR, loc + 12); + size = 16; + break; + + case ppc_stub_plt_call: + /* Do the best we can for shared libraries built without + exporting ".foo" for each "foo". This can happen when symbol + versioning scripts strip all bar a subset of symbols. */ + if (stub_entry->h->oh->root.type != bfd_link_hash_defined + && stub_entry->h->oh->root.type != bfd_link_hash_defweak) { - bfd_put_32 (s->owner, LI_R0_0 | indx, p); - p += 4; + /* Point the symbol at the stub. There may be multiple stubs, + we don't really care; The main thing is to make this sym + defined somewhere. */ + stub_entry->h->oh->root.type = bfd_link_hash_defined; + stub_entry->h->oh->root.u.def.section = stub_entry->stub_sec; + stub_entry->h->oh->root.u.def.value = stub_entry->stub_offset; } - else + + /* Now build the stub. */ + off = stub_entry->h->elf.plt.offset; + if (off >= (bfd_vma) -2) + abort (); + + off &= ~ (bfd_vma) 1; + off += (htab->splt->output_offset + + htab->splt->output_section->vma + - elf_gp (htab->splt->output_section->owner) + - TOC_BASE_OFF); + + if (off + 0x80000000 > 0xffffffff || (off & 7) != 0) { - bfd_put_32 (s->owner, LIS_R0_0 | PPC_HI (indx), p); - p += 4; - bfd_put_32 (s->owner, ORI_R0_R0_0 | PPC_LO (indx), p); - p += 4; + (*_bfd_error_handler) + (_("linkage table error against `%s'"), + stub_entry->h->elf.root.root.string); + bfd_set_error (bfd_error_bad_value); + htab->stub_error = true; + return false; } - bfd_put_32 (s->owner, B_DOT | ((s->contents - p) & 0x3fffffc), p); - p += 4; - s->_cooked_size = p - s->contents; - s->reloc_count += 1; + + p = build_plt_stub (stub_bfd, loc, (int) off, 0); + size = p - loc; + break; + + default: + BFD_FAIL (); + return false; } + + stub_sec->_cooked_size += size; return true; } -boolean -ppc64_elf_build_stubs (obfd, info) - bfd *obfd; +/* As above, but don't actually build the stub. Just bump offset so + we know stub section sizes, and select plt_branch stubs where + long_branch stubs won't do. */ + +static boolean +ppc_size_one_stub (gen_entry, in_arg) + struct bfd_hash_entry *gen_entry; + PTR in_arg; +{ + struct ppc_stub_hash_entry *stub_entry; + struct ppc_link_hash_table *htab; + bfd_vma off; + int size; + + /* Massage our args to the form they really have. */ + stub_entry = (struct ppc_stub_hash_entry *) gen_entry; + htab = (struct ppc_link_hash_table *) in_arg; + + if (stub_entry->stub_type == ppc_stub_plt_call) + { + off = stub_entry->h->elf.plt.offset & ~(bfd_vma) 1; + off += (htab->splt->output_offset + + htab->splt->output_section->vma + - elf_gp (htab->splt->output_section->owner) + - TOC_BASE_OFF); + + size = 28; + if (PPC_HA ((int) off + 16) != PPC_HA ((int) off)) + size += 4; + } + else + { + /* ppc_stub_long_branch or ppc_stub_plt_branch. */ + stub_entry->stub_type = ppc_stub_long_branch; + size = 4; + + off = (stub_entry->target_value + + stub_entry->target_section->output_offset + + stub_entry->target_section->output_section->vma); + off -= (stub_entry->stub_sec->_raw_size + + stub_entry->stub_sec->output_offset + + stub_entry->stub_sec->output_section->vma); + + if (off + (1 << 25) >= (bfd_vma) (1 << 26)) + { + struct ppc_branch_hash_entry *br_entry; + + br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table, + stub_entry->root.string + 9, + true, false); + if (br_entry == NULL) + { + (*_bfd_error_handler) (_("can't build branch stub `%s'"), + stub_entry->root.string + 9); + htab->stub_error = true; + return false; + } + + if (br_entry->iter != htab->stub_iteration) + { + br_entry->iter = htab->stub_iteration; + br_entry->offset = htab->sbrlt->_raw_size; + htab->sbrlt->_raw_size += 8; + } + stub_entry->stub_type = ppc_stub_plt_branch; + size = 16; + } + } + + stub_entry->stub_sec->_raw_size += size; + return true; +} + +/* Set up various things so that we can make a list of input sections + for each output section included in the link. Returns -1 on error, + 0 when no stubs will be needed, and 1 on success. */ + +int +ppc64_elf_setup_section_lists (output_bfd, info) + bfd *output_bfd; struct bfd_link_info *info; { + bfd *input_bfd; + int top_id, top_index; + asection *section; + asection **input_list, **list; + bfd_size_type amt; struct ppc_link_hash_table *htab = ppc_hash_table (info); - bfd_vma old_stub_size; - bfd_vma plt_r2; - bfd_byte *p; - /* If no .plt stubs, then nothing to do. */ - if (htab->sstub == NULL || htab->sstub->_raw_size == 0) - return true; + if (htab->elf.root.creator->flavour != bfd_target_elf_flavour + || htab->sbrlt == NULL) + return 0; - old_stub_size = htab->sstub->_cooked_size; - htab->sstub->_cooked_size = 0; - - /* Build the .glink plt call stub. */ - plt_r2 = (htab->splt->output_section->vma - + htab->splt->output_offset - - elf_gp (obfd) - - TOC_BASE_OFF); - p = htab->sglink->contents; - p = build_plt_stub (htab->sglink->owner, p, (int) plt_r2, 1); - while (p - htab->sglink->contents < GLINK_CALL_STUB_SIZE) + /* Find the top input section id. */ + for (input_bfd = info->input_bfds, top_id = 0; + input_bfd != NULL; + input_bfd = input_bfd->link_next) { - bfd_put_32 (htab->sglink->owner, NOP, p); - p += 4; + for (section = input_bfd->sections; + section != NULL; + section = section->next) + { + if (top_id < section->id) + top_id = section->id; + } } - htab->sglink->_cooked_size = p - htab->sglink->contents; - /* Use reloc_count to count entries. */ - htab->sglink->reloc_count = 0; + amt = sizeof (struct map_stub) * (top_id + 1); + htab->stub_group = (struct map_stub *) bfd_zmalloc (amt); + if (htab->stub_group == NULL) + return -1; + + /* We can't use output_bfd->section_count here to find the top output + section index as some sections may have been removed, and + _bfd_strip_section_from_output doesn't renumber the indices. */ + for (section = output_bfd->sections, top_index = 0; + section != NULL; + section = section->next) + { + if (top_index < section->index) + top_index = section->index; + } - elf_link_hash_traverse (&htab->elf, build_one_stub, (PTR) info); - htab->sglink->reloc_count = 0; + htab->top_index = top_index; + amt = sizeof (asection *) * (top_index + 1); + input_list = (asection **) bfd_malloc (amt); + htab->input_list = input_list; + if (input_list == NULL) + return -1; + + /* For sections we aren't interested in, mark their entries with a + value we can check later. */ + list = input_list + top_index; + do + *list = bfd_abs_section_ptr; + while (list-- != input_list); + + for (section = output_bfd->sections; + section != NULL; + section = section->next) + { + if ((section->flags & SEC_CODE) != 0) + input_list[section->index] = NULL; + } - if (htab->plt_overflow) - return false; + return 1; +} - if (old_stub_size != htab->sstub->_cooked_size - || htab->sglink->_raw_size != htab->sglink->_cooked_size) +/* 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 +ppc64_elf_next_input_section (info, isec) + struct bfd_link_info *info; + asection *isec; +{ + struct ppc_link_hash_table *htab = ppc_hash_table (info); + + if (isec->output_section->index <= htab->top_index) { - (*_bfd_error_handler) - (_("stub section size doesn't match calculated size")); - bfd_set_error (bfd_error_bad_value); - return false; + asection **list = htab->input_list + isec->output_section->index; + if (*list != bfd_abs_section_ptr) + { + /* Steal the link_sec pointer for our list. */ +#define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec) + /* This happens to make the list in reverse order, + which is what we want. */ + PREV_SEC (isec) = *list; + *list = isec; + } } - return true; } -/* Set up any other section flags and such that may be necessary. */ +/* See whether we can group stub sections together. Grouping stub + sections may result in fewer stubs. More importantly, we need to + put all .init* and .fini* stubs at the beginning of the .init or + .fini output sections respectively, because glibc splits the + _init and _fini functions into multiple parts. Putting a stub in + the middle of a function is not a good idea. */ -static boolean -ppc64_elf_fake_sections (abfd, shdr, asect) - bfd *abfd ATTRIBUTE_UNUSED; - Elf64_Internal_Shdr *shdr; - asection *asect; +static void +group_sections (htab, stub_group_size, stubs_always_before_branch) + struct ppc_link_hash_table *htab; + bfd_size_type stub_group_size; + boolean stubs_always_before_branch; +{ + asection **list = htab->input_list + htab->top_index; + do + { + asection *tail = *list; + if (tail == bfd_abs_section_ptr) + continue; + while (tail != NULL) + { + asection *curr; + asection *prev; + bfd_size_type total; + + curr = tail; + if (tail->_cooked_size) + total = tail->_cooked_size; + else + total = tail->_raw_size; + while ((prev = PREV_SEC (curr)) != NULL + && ((total += curr->output_offset - prev->output_offset) + < stub_group_size)) + curr = prev; + + /* OK, the size from the start of CURR to the end is less + than stub_group_size and thus can be handled by one stub + section. (or the tail section is itself larger than + stub_group_size, in which case we may be toast.) We + should really be keeping track of the total size of stubs + added here, as stubs contribute to the final output + section size. That's a little tricky, and this way will + only break if stubs added make the total size more than + 2^25, ie. for the default stub_group_size, if stubs total + more than 2834432 bytes, or over 100000 plt call stubs. */ + do + { + prev = PREV_SEC (tail); + /* Set up this stub group. */ + htab->stub_group[tail->id].link_sec = curr; + } + while (tail != curr && (tail = prev) != NULL); + + /* But wait, there's more! Input sections up to stub_group_size + bytes before the stub section can be handled by it too. */ + if (!stubs_always_before_branch) + { + total = 0; + while (prev != NULL + && ((total += tail->output_offset - prev->output_offset) + < stub_group_size)) + { + tail = prev; + prev = PREV_SEC (tail); + htab->stub_group[tail->id].link_sec = curr; + } + } + tail = prev; + } + } + while (list-- != htab->input_list); + free (htab->input_list); +#undef PREV_SEC +} + +/* Determine and set the size of the stub section for a final link. + + The basic idea here is to examine all the relocations looking for + PC-relative calls to a target that is unreachable with a "bl" + instruction. */ + +boolean +ppc64_elf_size_stubs (output_bfd, stub_bfd, info, group_size, + add_stub_section, layout_sections_again) + bfd *output_bfd; + bfd *stub_bfd; + struct bfd_link_info *info; + bfd_signed_vma group_size; + asection * (*add_stub_section) PARAMS ((const char *, asection *)); + void (*layout_sections_again) PARAMS ((void)); { - if ((asect->flags & SEC_EXCLUDE) != 0) - shdr->sh_flags |= SHF_EXCLUDE; + bfd_size_type stub_group_size; + boolean stubs_always_before_branch; + struct ppc_link_hash_table *htab = ppc_hash_table (info); + + /* Stash our params away. */ + htab->stub_bfd = stub_bfd; + htab->add_stub_section = add_stub_section; + htab->layout_sections_again = layout_sections_again; + stubs_always_before_branch = group_size < 0; + if (group_size < 0) + stub_group_size = -group_size; + else + stub_group_size = group_size; + if (stub_group_size == 1) + { + /* Default values. */ + stub_group_size = 30720000; + if (htab->has_14bit_branch) + stub_group_size = 30000; + } + + group_sections (htab, stub_group_size, stubs_always_before_branch); + + while (1) + { + bfd *input_bfd; + unsigned int bfd_indx; + asection *stub_sec; + boolean stub_changed; + + htab->stub_iteration += 1; + stub_changed = false; + + for (input_bfd = info->input_bfds, bfd_indx = 0; + input_bfd != NULL; + input_bfd = input_bfd->link_next, bfd_indx++) + { + Elf_Internal_Shdr *symtab_hdr; + asection *section; + Elf_Internal_Sym *local_syms = NULL; + + /* We'll need the symbol table in a second. */ + symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; + if (symtab_hdr->sh_info == 0) + continue; + + /* Walk over each section attached to the input bfd. */ + for (section = input_bfd->sections; + section != NULL; + section = section->next) + { + Elf_Internal_Rela *internal_relocs, *irelaend, *irela; + + /* If there aren't any relocs, then there's nothing more + to do. */ + if ((section->flags & SEC_RELOC) == 0 + || section->reloc_count == 0) + continue; + + /* If this section is a link-once section that will be + discarded, then don't create any stubs. */ + if (section->output_section == NULL + || section->output_section->owner != output_bfd) + continue; + + /* Get the relocs. */ + internal_relocs + = _bfd_elf64_link_read_relocs (input_bfd, section, NULL, + (Elf_Internal_Rela *) NULL, + info->keep_memory); + if (internal_relocs == NULL) + goto error_ret_free_local; + + /* Now examine each relocation. */ + irela = internal_relocs; + irelaend = irela + section->reloc_count; + for (; irela < irelaend; irela++) + { + unsigned int r_type, r_indx; + enum ppc_stub_type stub_type; + struct ppc_stub_hash_entry *stub_entry; + asection *sym_sec; + bfd_vma sym_value; + bfd_vma destination; + struct ppc_link_hash_entry *hash; + char *stub_name; + const asection *id_sec; + + r_type = ELF64_R_TYPE (irela->r_info); + r_indx = ELF64_R_SYM (irela->r_info); + + if (r_type >= (unsigned int) R_PPC_max) + { + bfd_set_error (bfd_error_bad_value); + goto error_ret_free_internal; + } + + /* Only look for stubs on branch instructions. */ + if (r_type != (unsigned int) R_PPC64_REL24 + && r_type != (unsigned int) R_PPC64_REL14 + && r_type != (unsigned int) R_PPC64_REL14_BRTAKEN + && r_type != (unsigned int) R_PPC64_REL14_BRNTAKEN) + continue; + + /* Now determine the call target, its name, value, + section. */ + sym_sec = NULL; + sym_value = 0; + destination = 0; + hash = NULL; + if (r_indx < symtab_hdr->sh_info) + { + /* It's a local symbol. */ + Elf_Internal_Sym *sym; + Elf_Internal_Shdr *hdr; + + if (local_syms == NULL) + { + local_syms + = (Elf_Internal_Sym *) symtab_hdr->contents; + if (local_syms == NULL) + local_syms + = bfd_elf_get_elf_syms (input_bfd, symtab_hdr, + symtab_hdr->sh_info, 0, + NULL, NULL, NULL); + if (local_syms == NULL) + goto error_ret_free_internal; + } + sym = local_syms + r_indx; + hdr = elf_elfsections (input_bfd)[sym->st_shndx]; + sym_sec = hdr->bfd_section; + if (ELF_ST_TYPE (sym->st_info) != STT_SECTION) + sym_value = sym->st_value; + destination = (sym_value + irela->r_addend + + sym_sec->output_offset + + sym_sec->output_section->vma); + } + else + { + /* It's an external symbol. */ + int e_indx; + + e_indx = r_indx - symtab_hdr->sh_info; + hash = ((struct ppc_link_hash_entry *) + elf_sym_hashes (input_bfd)[e_indx]); + + while (hash->elf.root.type == bfd_link_hash_indirect + || hash->elf.root.type == bfd_link_hash_warning) + hash = ((struct ppc_link_hash_entry *) + hash->elf.root.u.i.link); + + if (hash->elf.root.type == bfd_link_hash_defined + || hash->elf.root.type == bfd_link_hash_defweak) + { + sym_sec = hash->elf.root.u.def.section; + sym_value = hash->elf.root.u.def.value; + if (sym_sec->output_section != NULL) + destination = (sym_value + irela->r_addend + + sym_sec->output_offset + + sym_sec->output_section->vma); + } + else if (hash->elf.root.type == bfd_link_hash_undefweak) + ; + else if (hash->elf.root.type == bfd_link_hash_undefined) + ; + else + { + bfd_set_error (bfd_error_bad_value); + goto error_ret_free_internal; + } + } + + /* Determine what (if any) linker stub is needed. */ + stub_type = ppc_type_of_stub (section, irela, &hash, + destination); + if (stub_type == ppc_stub_none) + continue; + + /* Support for grouping stub sections. */ + id_sec = htab->stub_group[section->id].link_sec; + + /* Get the name of this stub. */ + stub_name = ppc_stub_name (id_sec, sym_sec, hash, irela); + if (!stub_name) + goto error_ret_free_internal; + + stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, + stub_name, false, false); + if (stub_entry != NULL) + { + /* The proper stub has already been created. */ + free (stub_name); + continue; + } + + stub_entry = ppc_add_stub (stub_name, section, htab); + if (stub_entry == NULL) + { + free (stub_name); + error_ret_free_internal: + if (elf_section_data (section)->relocs == NULL) + free (internal_relocs); + error_ret_free_local: + if (local_syms != NULL + && (symtab_hdr->contents + != (unsigned char *) local_syms)) + free (local_syms); + return false; + } + + stub_entry->target_value = sym_value; + stub_entry->target_section = sym_sec; + stub_entry->stub_type = stub_type; + stub_entry->h = hash; + stub_changed = true; + } + + /* We're done with the internal relocs, free them. */ + if (elf_section_data (section)->relocs != internal_relocs) + free (internal_relocs); + } + + if (local_syms != NULL + && symtab_hdr->contents != (unsigned char *) local_syms) + { + if (!info->keep_memory) + free (local_syms); + else + symtab_hdr->contents = (unsigned char *) local_syms; + } + } + + if (!stub_changed) + break; + + /* OK, we've added some stubs. Find out the new size of the + stub sections. */ + for (stub_sec = htab->stub_bfd->sections; + stub_sec != NULL; + stub_sec = stub_sec->next) + { + stub_sec->_raw_size = 0; + stub_sec->_cooked_size = 0; + } + htab->sbrlt->_raw_size = 0; + htab->sbrlt->_cooked_size = 0; + + bfd_hash_traverse (&htab->stub_hash_table, ppc_size_one_stub, htab); + + /* Ask the linker to do its stuff. */ + (*htab->layout_sections_again) (); + } - if ((asect->flags & SEC_SORT_ENTRIES) != 0) - shdr->sh_type = SHT_ORDERED; + /* It would be nice to strip .branch_lt from the output if the + section is empty, but it's too late. If we strip sections here, + the dynamic symbol table is corrupted since the section symbol + for the stripped section isn't written. */ return true; } +/* Called after we have determined section placement. If sections + move, we'll be called again. Provide a value for TOCstart. */ + +bfd_vma +ppc64_elf_toc (obfd) + bfd *obfd; +{ + asection *s; + bfd_vma TOCstart; + + /* The TOC consists of sections .got, .toc, .tocbss, .plt in that + order. The TOC starts where the first of these sections starts. */ + s = bfd_get_section_by_name (obfd, ".got"); + if (s == NULL) + s = bfd_get_section_by_name (obfd, ".toc"); + if (s == NULL) + s = bfd_get_section_by_name (obfd, ".tocbss"); + if (s == NULL) + s = bfd_get_section_by_name (obfd, ".plt"); + if (s == NULL) + { + /* This may happen for + o references to TOC base (SYM@toc / TOC[tc0]) without a + .toc directive + o bad linker script + o --gc-sections and empty TOC sections + + FIXME: Warn user? */ + + /* Look for a likely section. We probably won't even be + using TOCstart. */ + for (s = obfd->sections; s != NULL; s = s->next) + if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA | SEC_READONLY)) + == (SEC_ALLOC | SEC_SMALL_DATA)) + break; + if (s == NULL) + for (s = obfd->sections; s != NULL; s = s->next) + if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA)) + == (SEC_ALLOC | SEC_SMALL_DATA)) + break; + if (s == NULL) + for (s = obfd->sections; s != NULL; s = s->next) + if ((s->flags & (SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC) + break; + if (s == NULL) + for (s = obfd->sections; s != NULL; s = s->next) + if ((s->flags & SEC_ALLOC) == SEC_ALLOC) + break; + } + + TOCstart = 0; + if (s != NULL) + TOCstart = s->output_section->vma + s->output_offset; + + return TOCstart; +} + +/* Build all the stubs associated with the current output file. + The stubs are kept in a hash table attached to the main linker + hash table. This function is called via gldelf64ppc_finish. */ + +boolean +ppc64_elf_build_stubs (info) + struct bfd_link_info *info; +{ + struct ppc_link_hash_table *htab = ppc_hash_table (info); + asection *stub_sec; + bfd_vma plt_r2; + bfd_byte *p; + + for (stub_sec = htab->stub_bfd->sections; + stub_sec != NULL; + stub_sec = stub_sec->next) + { + bfd_size_type size; + + /* Allocate memory to hold the linker stubs. */ + size = stub_sec->_raw_size; + if (size != 0) + { + stub_sec->contents = (bfd_byte *) bfd_zalloc (htab->stub_bfd, size); + if (stub_sec->contents == NULL) + return false; + } + stub_sec->_cooked_size = 0; + } + + if (htab->splt != NULL) + { + unsigned int indx; + + /* Build the .glink plt call stub. */ + plt_r2 = (htab->splt->output_offset + + htab->splt->output_section->vma + - elf_gp (htab->splt->output_section->owner) + - TOC_BASE_OFF); + p = htab->sglink->contents; + p = build_plt_stub (htab->sglink->owner, p, (int) plt_r2, 1); + while (p < htab->sglink->contents + GLINK_CALL_STUB_SIZE) + { + bfd_put_32 (htab->sglink->owner, NOP, p); + p += 4; + } + + /* Build the .glink lazy link call stubs. */ + indx = 0; + while (p < htab->sglink->contents + htab->sglink->_raw_size) + { + if (indx < 0x8000) + { + bfd_put_32 (htab->sglink->owner, LI_R0_0 | indx, p); + p += 4; + } + else + { + bfd_put_32 (htab->sglink->owner, LIS_R0_0 | PPC_HI (indx), p); + p += 4; + bfd_put_32 (htab->sglink->owner, ORI_R0_R0_0 | PPC_LO (indx), p); + p += 4; + } + bfd_put_32 (htab->sglink->owner, + B_DOT | ((htab->sglink->contents - p) & 0x3fffffc), p); + indx++; + p += 4; + } + htab->sglink->_cooked_size = p - htab->sglink->contents; + } + + if (htab->sbrlt->_raw_size != 0) + { + htab->sbrlt->contents = (bfd_byte *) bfd_zalloc (htab->sbrlt->owner, + htab->sbrlt->_raw_size); + if (htab->sbrlt->contents == NULL) + return false; + } + + /* Build the stubs as directed by the stub hash table. */ + bfd_hash_traverse (&htab->stub_hash_table, ppc_build_one_stub, info); + + for (stub_sec = htab->stub_bfd->sections; + stub_sec != NULL; + stub_sec = stub_sec->next) + { + if (stub_sec->_raw_size != stub_sec->_cooked_size) + break; + } + + if (stub_sec != NULL + || htab->sglink->_raw_size != htab->sglink->_cooked_size) + { + htab->stub_error = true; + (*_bfd_error_handler) (_("stubs don't match calculated size")); + } + + return !htab->stub_error; +} + /* The RELOCATE_SECTION function is called by the ELF backend linker to handle the relocations for a section. @@ -3897,7 +5269,7 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, TOCstart = elf_gp (output_bfd); symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); - is_opd = strcmp (bfd_get_section_name (abfd, input_section), ".opd") == 0; + is_opd = elf_section_data (input_section)->tdata != NULL; rel = relocs; relend = relocs + input_section->reloc_count; @@ -3910,11 +5282,15 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Sym *sym; asection *sec; struct elf_link_hash_entry *h; + struct elf_link_hash_entry *fdh; const char *sym_name; unsigned long r_symndx; bfd_vma relocation; boolean unresolved_reloc; + boolean warned; long insn; + struct ppc_stub_hash_entry *stub_entry; + bfd_vma max_br_offset; bfd_vma from; r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info); @@ -3927,6 +5303,7 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, h = (struct elf_link_hash_entry *) 0; sym_name = (const char *) 0; unresolved_reloc = false; + warned = false; if (r_type == R_PPC64_TOC) { @@ -3943,6 +5320,15 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); /* rel may have changed, update our copy of addend. */ addend = rel->r_addend; + + if (elf_section_data (sec) != NULL) + { + long *opd_sym_adjust; + + opd_sym_adjust = (long *) elf_section_data (sec)->tdata; + if (opd_sym_adjust != NULL && sym->st_value % 24 == 0) + relocation += opd_sym_adjust[sym->st_value / 24]; + } } else { @@ -3983,6 +5369,7 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, || info->no_undefined || ELF_ST_VISIBILITY (h->other))))) return false; + warned = true; } } @@ -3996,8 +5383,8 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, /* Branch taken prediction relocations. */ case R_PPC64_ADDR14_BRTAKEN: case R_PPC64_REL14_BRTAKEN: - insn = 0x01 << 21; /* 'y' or 't' bit, lowest bit of BO field. */ - /* Fall thru. */ + insn = 0x01 << 21; /* 'y' or 't' bit, lowest bit of BO field. */ + /* Fall thru. */ /* Branch not taken prediction relocations. */ case R_PPC64_ADDR14_BRNTAKEN: @@ -4036,8 +5423,10 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, to alter the TOC base. These are recognized by their need for a PLT entry. */ if (h != NULL - && h->plt.offset != (bfd_vma) -1 - && htab->sstub != NULL) + && (fdh = ((struct ppc_link_hash_entry *) h)->oh) != NULL + && fdh->plt.offset != (bfd_vma) -1 + && (stub_entry = ppc_get_stub_entry (input_section, sec, fdh, + rel, htab)) != NULL) { boolean can_plt_call = 0; @@ -4064,10 +5453,9 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, if (can_plt_call) { - /* plt.offset here is the offset into the stub section. */ - relocation = (htab->sstub->output_section->vma - + htab->sstub->output_offset - + h->plt.offset); + relocation = (stub_entry->stub_offset + + stub_entry->stub_sec->output_offset + + stub_entry->stub_sec->output_section->vma); addend = 0; unresolved_reloc = false; } @@ -4273,14 +5661,14 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, addend -= sec->output_section->vma; break; + case R_PPC64_REL14: + case R_PPC64_REL14_BRNTAKEN: + case R_PPC64_REL14_BRTAKEN: case R_PPC64_REL24: break; /* Relocations that may need to be propagated if this is a dynamic object. */ - case R_PPC64_REL14: - case R_PPC64_REL14_BRNTAKEN: - case R_PPC64_REL14_BRTAKEN: case R_PPC64_REL32: case R_PPC64_REL64: case R_PPC64_ADDR14: @@ -4378,6 +5766,20 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, relocate = true; if (r_type == R_PPC64_ADDR64 || r_type == R_PPC64_TOC) { + if (is_opd && h != NULL) + { + /* Lie about opd entries. This case occurs + when building shared libraries and we + reference a function in another shared + lib. The same thing happens for a weak + definition in an application that's + overridden by a strong definition in a + shared lib. (I believe this is a generic + bug in binutils handling of weak syms.) + In these cases we won't use the opd + entry in this lib. */ + unresolved_reloc = false; + } outrel.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE); } else @@ -4497,22 +5899,51 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, continue; } break; + + case R_PPC64_REL14: + case R_PPC64_REL14_BRNTAKEN: + case R_PPC64_REL14_BRTAKEN: + max_br_offset = 1 << 15; + goto branch_check; + + case R_PPC64_REL24: + max_br_offset = 1 << 25; + + branch_check: + /* If the branch is out of reach, then redirect the + call to the local stub for this function. */ + from = (offset + + input_section->output_offset + + input_section->output_section->vma); + if (relocation + addend - from + max_br_offset >= 2 * max_br_offset + && (stub_entry = ppc_get_stub_entry (input_section, sec, h, + rel, htab)) != NULL) + { + /* Munge up the value and addend so that we call the stub + rather than the procedure directly. */ + relocation = (stub_entry->stub_offset + + stub_entry->stub_sec->output_offset + + stub_entry->stub_sec->output_section->vma); + addend = 0; + } + break; } - /* FIXME: Why do we allow debugging sections to escape this error? - More importantly, why do we not emit dynamic relocs above in - debugging sections (which are ! SEC_ALLOC)? If we had - emitted the dynamic reloc, we could remove the fudge here. */ + /* Dynamic relocs are not propagated for SEC_DEBUGGING sections + because such sections are not SEC_ALLOC and thus ld.so will + not process them. */ if (unresolved_reloc - && !(info->shared - && (input_section->flags & SEC_DEBUGGING) != 0 + && !((input_section->flags & SEC_DEBUGGING) != 0 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) - (*_bfd_error_handler) - (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"), - bfd_archive_filename (input_bfd), - bfd_get_section_name (input_bfd, input_section), - (long) rel->r_offset, - h->root.root.string); + { + (*_bfd_error_handler) + (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"), + bfd_archive_filename (input_bfd), + bfd_get_section_name (input_bfd, input_section), + (long) rel->r_offset, + h->root.root.string); + ret = false; + } r = _bfd_final_link_relocate (ppc64_elf_howto_table[(int) r_type], input_bfd, @@ -4522,9 +5953,7 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, relocation, addend); - if (r == bfd_reloc_ok) - ; - else if (r == bfd_reloc_overflow) + if (r != bfd_reloc_ok) { const char *name; @@ -4555,13 +5984,25 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, name = bfd_section_name (input_bfd, sec); } - if (! ((*info->callbacks->reloc_overflow) - (info, name, ppc64_elf_howto_table[(int) r_type]->name, - (bfd_vma) 0, input_bfd, input_section, offset))) - return false; + if (r == bfd_reloc_overflow) + { + if (warned) + continue; + if (!((*info->callbacks->reloc_overflow) + (info, name, ppc64_elf_howto_table[(int) r_type]->name, + rel->r_addend, input_bfd, input_section, offset))) + return false; + } + else + { + (*_bfd_error_handler) + (_("%s(%s+0x%lx): reloc against `%s': error %d"), + bfd_archive_filename (input_bfd), + bfd_get_section_name (input_bfd, input_section), + (long) rel->r_offset, name, (int) r); + ret = false; + } } - else - ret = false; } return ret; @@ -4590,7 +6031,7 @@ ppc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym) Elf64_External_Rela *loc; /* This symbol has an entry in the procedure linkage table. Set - it up. */ + it up. */ if (htab->splt == NULL || htab->srelplt == NULL @@ -4617,7 +6058,7 @@ ppc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym) Elf64_External_Rela *loc; /* This symbol has an entry in the global offset table. Set it - up. */ + up. */ if (htab->sgot == NULL || htab->srelgot == NULL) abort (); @@ -4840,11 +6281,11 @@ ppc64_elf_finish_dynamic_sections (output_bfd, info) #define elf_backend_rela_normal 1 #define bfd_elf64_bfd_reloc_type_lookup ppc64_elf_reloc_type_lookup -#define bfd_elf64_bfd_set_private_flags ppc64_elf_set_private_flags #define bfd_elf64_bfd_merge_private_bfd_data ppc64_elf_merge_private_bfd_data #define bfd_elf64_bfd_link_hash_table_create ppc64_elf_link_hash_table_create +#define bfd_elf64_bfd_link_hash_table_free ppc64_elf_link_hash_table_free -#define elf_backend_section_from_shdr ppc64_elf_section_from_shdr +#define elf_backend_object_p ppc64_elf_object_p #define elf_backend_create_dynamic_sections ppc64_elf_create_dynamic_sections #define elf_backend_copy_indirect_symbol ppc64_elf_copy_indirect_symbol #define elf_backend_check_relocs ppc64_elf_check_relocs @@ -4854,7 +6295,6 @@ ppc64_elf_finish_dynamic_sections (output_bfd, info) #define elf_backend_hide_symbol ppc64_elf_hide_symbol #define elf_backend_always_size_sections ppc64_elf_func_desc_adjust #define elf_backend_size_dynamic_sections ppc64_elf_size_dynamic_sections -#define elf_backend_fake_sections ppc64_elf_fake_sections #define elf_backend_relocate_section ppc64_elf_relocate_section #define elf_backend_finish_dynamic_symbol ppc64_elf_finish_dynamic_symbol #define elf_backend_reloc_type_class ppc64_elf_reloc_type_class diff --git a/contrib/binutils/bfd/elf64-ppc.h b/contrib/binutils/bfd/elf64-ppc.h index beb637b..cabc388 100644 --- a/contrib/binutils/bfd/elf64-ppc.h +++ b/contrib/binutils/bfd/elf64-ppc.h @@ -17,6 +17,16 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -bfd_vma ppc64_elf_toc PARAMS ((bfd *)); -boolean ppc64_elf_size_stubs PARAMS ((bfd *, struct bfd_link_info *, int *)); -boolean ppc64_elf_build_stubs PARAMS ((bfd *, struct bfd_link_info *)); +boolean ppc64_elf_mark_entry_syms + PARAMS ((struct bfd_link_info *)); +bfd_vma ppc64_elf_toc + PARAMS ((bfd *)); +int ppc64_elf_setup_section_lists + PARAMS ((bfd *, struct bfd_link_info *)); +void ppc64_elf_next_input_section + PARAMS ((struct bfd_link_info *, asection *)); +boolean ppc64_elf_size_stubs + PARAMS ((bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma, + asection *(*) (const char *, asection *), void (*) (void))); +boolean ppc64_elf_build_stubs + PARAMS ((struct bfd_link_info *)); diff --git a/contrib/binutils/bfd/elf64-sparc.c b/contrib/binutils/bfd/elf64-sparc.c index d04a1d3..def93c4 100644 --- a/contrib/binutils/bfd/elf64-sparc.c +++ b/contrib/binutils/bfd/elf64-sparc.c @@ -72,6 +72,9 @@ static void sparc64_elf_symbol_processing static boolean sparc64_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *)); +static boolean sparc64_elf_fake_sections + PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *)); + static const char *sparc64_elf_print_symbol_all PARAMS ((bfd *, PTR, asymbol *)); static boolean sparc64_elf_relax_section @@ -659,14 +662,14 @@ sparc64_elf_bfd_link_hash_table_create (abfd) struct sparc64_elf_link_hash_table *ret; bfd_size_type amt = sizeof (struct sparc64_elf_link_hash_table); - ret = (struct sparc64_elf_link_hash_table *) bfd_zalloc (abfd, amt); + ret = (struct sparc64_elf_link_hash_table *) bfd_zmalloc (amt); if (ret == (struct sparc64_elf_link_hash_table *) NULL) return NULL; if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, _bfd_elf_link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return NULL; } @@ -711,7 +714,7 @@ init_insn_reloc (abfd, return bfd_reloc_ok; } - /* This works because partial_inplace == false. */ + /* This works because partial_inplace is false. */ if (output_bfd != NULL) return bfd_reloc_continue; @@ -1386,7 +1389,7 @@ sparc64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) return true; } else if (*namep && **namep - && info->hash->creator->flavour == bfd_target_elf_flavour) + && info->hash->creator == abfd->xvec) { int i; struct sparc64_elf_app_reg *p; @@ -2565,9 +2568,11 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, break; } + /* Dynamic relocs are not propagated for SEC_DEBUGGING sections + because such sections are not SEC_ALLOC and thus ld.so will + not process them. */ if (unresolved_reloc - && !(info->shared - && (input_section->flags & SEC_DEBUGGING) != 0 + && !((input_section->flags & SEC_DEBUGGING) != 0 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) (*_bfd_error_handler) (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"), @@ -2995,6 +3000,27 @@ sparc64_elf_merge_private_bfd_data (ibfd, obfd) } return true; } + +/* MARCO: Set the correct entry size for the .stab section. */ + +static boolean +sparc64_elf_fake_sections (abfd, hdr, sec) + bfd *abfd ATTRIBUTE_UNUSED; + Elf32_Internal_Shdr *hdr ATTRIBUTE_UNUSED; + asection *sec; +{ + const char *name; + + name = bfd_get_section_name (abfd, sec); + + if (strcmp (name, ".stab") == 0) + { + /* Even in the 64bit case the stab entries are only 12 bytes long. */ + elf_section_data (sec)->this_hdr.sh_entsize = 12; + } + + return true; +} /* Print a STT_REGISTER symbol to file FILE. */ @@ -3067,6 +3093,7 @@ const struct elf_size_info sparc64_elf_size_info = bfd_elf64_write_out_phdrs, bfd_elf64_write_shdrs_and_ehdr, sparc64_elf_write_relocs, + bfd_elf64_swap_symbol_in, bfd_elf64_swap_symbol_out, sparc64_elf_slurp_reloc_table, bfd_elf64_slurp_symbol_table, @@ -3131,6 +3158,8 @@ const struct elf_size_info sparc64_elf_size_info = sparc64_elf_output_arch_syms #define bfd_elf64_bfd_merge_private_bfd_data \ sparc64_elf_merge_private_bfd_data +#define elf_backend_fake_sections \ + sparc64_elf_fake_sections #define elf_backend_size_info \ sparc64_elf_size_info diff --git a/contrib/binutils/bfd/elf64-x86-64.c b/contrib/binutils/bfd/elf64-x86-64.c index b980344..a7303d0 100644 --- a/contrib/binutils/bfd/elf64-x86-64.c +++ b/contrib/binutils/bfd/elf64-x86-64.c @@ -125,6 +125,10 @@ static reloc_howto_type *elf64_x86_64_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type)); static void elf64_x86_64_info_to_howto PARAMS ((bfd *, arelent *, Elf64_Internal_Rela *)); +static boolean elf64_x86_64_grok_prstatus + PARAMS ((bfd *, Elf_Internal_Note *)); +static boolean elf64_x86_64_grok_psinfo + PARAMS ((bfd *, Elf_Internal_Note *)); static struct bfd_link_hash_table *elf64_x86_64_link_hash_table_create PARAMS ((bfd *)); static boolean elf64_x86_64_elf_object_p PARAMS ((bfd *abfd)); @@ -133,12 +137,13 @@ static boolean create_got_section static boolean elf64_x86_64_create_dynamic_sections PARAMS((bfd *, struct bfd_link_info *)); static void elf64_x86_64_copy_indirect_symbol - PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *)); + PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *, + struct elf_link_hash_entry *)); static boolean elf64_x86_64_check_relocs PARAMS ((bfd *, struct bfd_link_info *, asection *sec, const Elf_Internal_Rela *)); static asection *elf64_x86_64_gc_mark_hook - PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, + PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *)); static boolean elf64_x86_64_gc_sweep_hook @@ -208,6 +213,73 @@ elf64_x86_64_info_to_howto (abfd, cache_ptr, dst) BFD_ASSERT (r_type == cache_ptr->howto->type); } +/* Support for core dump NOTE sections. */ +static boolean +elf64_x86_64_grok_prstatus (abfd, note) + bfd *abfd; + Elf_Internal_Note *note; +{ + int offset; + size_t raw_size; + + switch (note->descsz) + { + default: + return false; + + case 336: /* sizeof(istruct elf_prstatus) on Linux/x86_64 */ + /* pr_cursig */ + elf_tdata (abfd)->core_signal + = bfd_get_16 (abfd, note->descdata + 12); + + /* pr_pid */ + elf_tdata (abfd)->core_pid + = bfd_get_32 (abfd, note->descdata + 32); + + /* pr_reg */ + offset = 112; + raw_size = 216; + + break; + } + + /* Make a ".reg/999" section. */ + return _bfd_elfcore_make_pseudosection (abfd, ".reg", + raw_size, note->descpos + offset); +} + +static boolean +elf64_x86_64_grok_psinfo (abfd, note) + bfd *abfd; + Elf_Internal_Note *note; +{ + switch (note->descsz) + { + default: + return false; + + case 136: /* sizeof(struct elf_prpsinfo) on Linux/x86_64 */ + elf_tdata (abfd)->core_program + = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16); + elf_tdata (abfd)->core_command + = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80); + } + + /* Note that for some reason, a spurious space is tacked + onto the end of the args in some (at least one anyway) + implementations, so strip it off if it exists. */ + + { + char *command = elf_tdata (abfd)->core_command; + int n = strlen (command); + + if (0 < n && command[n - 1] == ' ') + command[n - 1] = '\0'; + } + + return true; +} + /* Functions for the x86-64 ELF linker. */ /* The name of the dynamic interpreter. This is put in the .interp @@ -340,13 +412,13 @@ elf64_x86_64_link_hash_table_create (abfd) struct elf64_x86_64_link_hash_table *ret; bfd_size_type amt = sizeof (struct elf64_x86_64_link_hash_table); - ret = (struct elf64_x86_64_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct elf64_x86_64_link_hash_table *) bfd_malloc (amt); if (ret == NULL) return NULL; if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return NULL; } @@ -426,7 +498,8 @@ elf64_x86_64_create_dynamic_sections (dynobj, info) /* Copy the extra info we tack onto an elf_link_hash_entry. */ static void -elf64_x86_64_copy_indirect_symbol (dir, ind) +elf64_x86_64_copy_indirect_symbol (bed, dir, ind) + struct elf_backend_data *bed; struct elf_link_hash_entry *dir, *ind; { struct elf64_x86_64_link_hash_entry *edir, *eind; @@ -468,7 +541,7 @@ elf64_x86_64_copy_indirect_symbol (dir, ind) eind->dyn_relocs = NULL; } - _bfd_elf_link_hash_copy_indirect (dir, ind); + _bfd_elf_link_hash_copy_indirect (bed, dir, ind); } static boolean @@ -589,11 +662,28 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs) case R_X86_64_8: case R_X86_64_16: case R_X86_64_32: - case R_X86_64_64: case R_X86_64_32S: + /* Let's help debug shared library creation. These relocs + cannot be used in shared libs. Don't error out for + sections we don't care about, such as debug sections or + non-constant sections. */ + if (info->shared + && (sec->flags & SEC_ALLOC) != 0 + && (sec->flags & SEC_READONLY) != 0) + { + (*_bfd_error_handler) + (_("%s: relocation %s can not be used when making a shared object; recompile with -fPIC"), + bfd_archive_filename (abfd), + x86_64_elf_howto_table[ELF64_R_TYPE (rel->r_info)].name); + bfd_set_error (bfd_error_bad_value); + return false; + } + /* Fall through. */ + case R_X86_64_PC8: case R_X86_64_PC16: case R_X86_64_PC32: + case R_X86_64_64: if (h != NULL && !info->shared) { /* If this reloc is in a read-only section, we might @@ -768,8 +858,8 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs) relocation. */ static asection * -elf64_x86_64_gc_mark_hook (abfd, info, rel, h, sym) - bfd *abfd; +elf64_x86_64_gc_mark_hook (sec, info, rel, h, sym) + asection *sec; struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; @@ -799,9 +889,7 @@ elf64_x86_64_gc_mark_hook (abfd, info, rel, h, sym) } } else - { - return bfd_section_from_elf_index (abfd, sym->st_shndx); - } + return bfd_section_from_elf_index (sec->owner, sym->st_shndx); return NULL; } @@ -1016,7 +1104,7 @@ elf64_x86_64_adjust_dynamic_symbol (info, h) /* We must generate a R_X86_64_COPY reloc to tell the dynamic linker to copy the initial value out of the dynamic object and into the - runtime process image. */ + runtime process image. */ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { htab->srelbss->_raw_size += sizeof (Elf64_External_Rela); @@ -1790,9 +1878,44 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section, else { /* This symbol is local, or marked to become local. */ - relocate = true; - outrel.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE); - outrel.r_addend = relocation + rel->r_addend; + if (r_type == R_X86_64_64) + { + relocate = true; + outrel.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE); + outrel.r_addend = relocation + rel->r_addend; + } + else + { + long sindx; + + if (h == NULL) + sec = local_sections[r_symndx]; + else + { + BFD_ASSERT (h->root.type == bfd_link_hash_defined + || (h->root.type + == bfd_link_hash_defweak)); + sec = h->root.u.def.section; + } + if (sec != NULL && bfd_is_abs_section (sec)) + sindx = 0; + else if (sec == NULL || sec->owner == NULL) + { + bfd_set_error (bfd_error_bad_value); + return false; + } + else + { + asection *osec; + + osec = sec->output_section; + sindx = elf_section_data (osec)->dynindx; + BFD_ASSERT (sindx > 0); + } + + outrel.r_info = ELF64_R_INFO (sindx, r_type); + outrel.r_addend = relocation + rel->r_addend; + } } sreloc = elf_section_data (input_section)->sreloc; @@ -1817,14 +1940,11 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section, break; } - /* FIXME: Why do we allow debugging sections to escape this error? - More importantly, why do we not emit dynamic relocs for - R_386_32 above in debugging sections (which are ! SEC_ALLOC)? - If we had emitted the dynamic reloc, we could remove the - fudge here. */ + /* Dynamic relocs are not propagated for SEC_DEBUGGING sections + because such sections are not SEC_ALLOC and thus ld.so will + not process them. */ if (unresolved_reloc - && !(info->shared - && (input_section->flags & SEC_DEBUGGING) != 0 + && !((input_section->flags & SEC_DEBUGGING) != 0 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) (*_bfd_error_handler) (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"), @@ -2228,6 +2348,8 @@ elf64_x86_64_finish_dynamic_sections (output_bfd, info) #define elf_backend_finish_dynamic_symbol elf64_x86_64_finish_dynamic_symbol #define elf_backend_gc_mark_hook elf64_x86_64_gc_mark_hook #define elf_backend_gc_sweep_hook elf64_x86_64_gc_sweep_hook +#define elf_backend_grok_prstatus elf64_x86_64_grok_prstatus +#define elf_backend_grok_psinfo elf64_x86_64_grok_psinfo #define elf_backend_reloc_type_class elf64_x86_64_reloc_type_class #define elf_backend_relocate_section elf64_x86_64_relocate_section #define elf_backend_size_dynamic_sections elf64_x86_64_size_dynamic_sections diff --git a/contrib/binutils/bfd/elfarm-oabi.c b/contrib/binutils/bfd/elfarm-oabi.c index 25c4d89..c8e3fe6 100644 --- a/contrib/binutils/bfd/elfarm-oabi.c +++ b/contrib/binutils/bfd/elfarm-oabi.c @@ -1,5 +1,5 @@ /* 32-bit ELF support for ARM old abi option. - Copyright 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -18,6 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define OLD_ARM_ABI +#define bfd_elf32_arm_allocate_interworking_sections \ + bfd_elf32_arm_oabi_allocate_interworking_sections +#define bfd_elf32_arm_get_bfd_for_interworking \ + bfd_elf32_arm_oabi_get_bfd_for_interworking +#define bfd_elf32_arm_process_before_allocation \ + bfd_elf32_arm_oabi_process_before_allocation +#define bfd_elf32_arm_add_glue_sections_to_bfd \ + bfd_elf32_arm_oabi_add_glue_sections_to_bfd #include "elf/arm.h" #include "bfd.h" @@ -417,11 +425,4 @@ elf32_arm_reloc_type_lookup (abfd, code) return NULL; } -#define bfd_elf32_arm_allocate_interworking_sections \ - bfd_elf32_arm_oabi_allocate_interworking_sections -#define bfd_elf32_arm_get_bfd_for_interworking \ - bfd_elf32_arm_oabi_get_bfd_for_interworking -#define bfd_elf32_arm_process_before_allocation \ - bfd_elf32_arm_oabi_process_before_allocation - #include "elf32-arm.h" diff --git a/contrib/binutils/bfd/elfcode.h b/contrib/binutils/bfd/elfcode.h index 203323c..4f54cd3 100644 --- a/contrib/binutils/bfd/elfcode.h +++ b/contrib/binutils/bfd/elfcode.h @@ -1,6 +1,6 @@ /* ELF executable support for BFD. Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001 Free Software Foundation, Inc. + 2001, 2002 Free Software Foundation, Inc. Written by Fred Fish @ Cygnus Support, from information published in "UNIX System V Release 4, Programmers Guide: ANSI C and @@ -203,12 +203,14 @@ static char *elf_symbol_flags PARAMS ((flagword)); format. */ void -elf_swap_symbol_in (abfd, src, shndx, dst) +elf_swap_symbol_in (abfd, psrc, pshn, dst) bfd *abfd; - const Elf_External_Sym *src; - const Elf_External_Sym_Shndx *shndx; + const PTR psrc; + const PTR pshn; Elf_Internal_Sym *dst; { + const Elf_External_Sym *src = (const Elf_External_Sym *) psrc; + const Elf_External_Sym_Shndx *shndx = (const Elf_External_Sym_Shndx *) pshn; int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; dst->st_name = H_GET_32 (abfd, src->st_name); @@ -557,9 +559,9 @@ elf_object_p (abfd) section header table (FIXME: See comments re sections at top of this file). */ - if ((elf_file_p (&x_ehdr) == false) || - (x_ehdr.e_ident[EI_VERSION] != EV_CURRENT) || - (x_ehdr.e_ident[EI_CLASS] != ELFCLASS)) + if (! elf_file_p (&x_ehdr) + || x_ehdr.e_ident[EI_VERSION] != EV_CURRENT + || x_ehdr.e_ident[EI_CLASS] != ELFCLASS) goto got_wrong_format_error; /* Check that file's byte order matches xvec's */ @@ -622,6 +624,10 @@ elf_object_p (abfd) if (i_ehdrp->e_shentsize != sizeof (x_shdr) && i_ehdrp->e_shnum != 0) goto got_wrong_format_error; + /* Further sanity check. */ + if (i_ehdrp->e_shoff == 0 && i_ehdrp->e_shnum != 0) + goto got_wrong_format_error; + ebd = get_elf_backend_data (abfd); /* Check that the ELF e_machine field matches what this particular @@ -675,25 +681,28 @@ elf_object_p (abfd) /* Remember the entry point specified in the ELF file header. */ bfd_set_start_address (abfd, i_ehdrp->e_entry); - /* Seek to the section header table in the file. */ - if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0) - goto got_no_match; + if (i_ehdrp->e_shoff != 0) + { + /* Seek to the section header table in the file. */ + if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0) + goto got_no_match; - /* Read the first section header at index 0, and convert to internal - form. */ - if (bfd_bread ((PTR) & x_shdr, (bfd_size_type) sizeof x_shdr, abfd) - != sizeof (x_shdr)) - goto got_no_match; - elf_swap_shdr_in (abfd, &x_shdr, &i_shdr); + /* Read the first section header at index 0, and convert to internal + form. */ + if (bfd_bread ((PTR) & x_shdr, (bfd_size_type) sizeof x_shdr, abfd) + != sizeof (x_shdr)) + goto got_no_match; + elf_swap_shdr_in (abfd, &x_shdr, &i_shdr); - /* If the section count is zero, the actual count is in the first - section header. */ - if (i_ehdrp->e_shnum == SHN_UNDEF) - i_ehdrp->e_shnum = i_shdr.sh_size; + /* If the section count is zero, the actual count is in the first + section header. */ + if (i_ehdrp->e_shnum == SHN_UNDEF) + i_ehdrp->e_shnum = i_shdr.sh_size; - /* And similarly for the string table index. */ - if (i_ehdrp->e_shstrndx == SHN_XINDEX) - i_ehdrp->e_shstrndx = i_shdr.sh_link; + /* And similarly for the string table index. */ + if (i_ehdrp->e_shstrndx == SHN_XINDEX) + i_ehdrp->e_shstrndx = i_shdr.sh_link; + } /* Allocate space for a copy of the section header table in internal form. */ @@ -749,7 +758,7 @@ elf_object_p (abfd) } } - if (i_ehdrp->e_shstrndx) + if (i_ehdrp->e_shstrndx && i_ehdrp->e_shoff) { if (! bfd_section_from_shdr (abfd, i_ehdrp->e_shstrndx)) goto got_no_match; @@ -787,7 +796,7 @@ elf_object_p (abfd) bfd_section_from_shdr with it (since this particular strtab is used to find all of the ELF section names.) */ - if (i_ehdrp->e_shstrndx != 0) + if (i_ehdrp->e_shstrndx != 0 && i_ehdrp->e_shoff) { unsigned int num_sec; @@ -812,7 +821,7 @@ elf_object_p (abfd) information. */ if (ebd->elf_backend_object_p) { - if ((*ebd->elf_backend_object_p) (abfd) == false) + if (! (*ebd->elf_backend_object_p) (abfd)) goto got_wrong_format_error; } @@ -1124,10 +1133,12 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) unsigned long symcount; /* Number of external ELF symbols */ elf_symbol_type *sym; /* Pointer to current bfd symbol */ elf_symbol_type *symbase; /* Buffer for generated bfd symbols */ - Elf_Internal_Sym i_sym; - Elf_External_Sym *x_symp = NULL; - Elf_External_Sym_Shndx *x_shndx = NULL; - Elf_External_Versym *x_versymp = NULL; + Elf_Internal_Sym *isym; + Elf_Internal_Sym *isymend; + Elf_Internal_Sym *isymbuf = NULL; + Elf_External_Versym *xver; + Elf_External_Versym *xverbuf = NULL; + struct elf_backend_data *ebd; bfd_size_type amt; /* Read each raw ELF symbol, converting from external ELF form to @@ -1142,24 +1153,8 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) if (! dynamic) { - Elf_Internal_Shdr *shndx_hdr; - hdr = &elf_tdata (abfd)->symtab_hdr; - shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; verhdr = NULL; - - /* If we have a SHT_SYMTAB_SHNDX section for the symbol table, - read the raw contents. */ - if (elf_elfsections (abfd) != NULL - && elf_elfsections (abfd)[shndx_hdr->sh_link] == hdr) - { - amt = shndx_hdr->sh_size; - x_shndx = (Elf_External_Sym_Shndx *) bfd_malloc (amt); - if (x_shndx == NULL - || bfd_seek (abfd, shndx_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread ((PTR) x_shndx, amt, abfd) != amt) - goto error_return; - } } else { @@ -1178,39 +1173,24 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) } } - if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0) - goto error_return; - + ebd = get_elf_backend_data (abfd); symcount = hdr->sh_size / sizeof (Elf_External_Sym); - if (symcount == 0) sym = symbase = NULL; else { - unsigned long i; - - if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0) - goto error_return; + isymbuf = bfd_elf_get_elf_syms (abfd, hdr, symcount, 0, + NULL, NULL, NULL); + if (isymbuf == NULL) + return -1; amt = symcount; amt *= sizeof (elf_symbol_type); symbase = (elf_symbol_type *) bfd_zalloc (abfd, amt); if (symbase == (elf_symbol_type *) NULL) goto error_return; - sym = symbase; - - /* Temporarily allocate room for the raw ELF symbols. */ - amt = symcount; - amt *= sizeof (Elf_External_Sym); - x_symp = (Elf_External_Sym *) bfd_malloc (amt); - if (x_symp == NULL) - goto error_return; - - if (bfd_bread ((PTR) x_symp, amt, abfd) != amt) - goto error_return; /* Read the raw ELF version symbol information. */ - if (verhdr != NULL && verhdr->sh_size / sizeof (Elf_External_Versym) != symcount) { @@ -1230,41 +1210,40 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) if (bfd_seek (abfd, verhdr->sh_offset, SEEK_SET) != 0) goto error_return; - x_versymp = (Elf_External_Versym *) bfd_malloc (verhdr->sh_size); - if (x_versymp == NULL && verhdr->sh_size != 0) + xverbuf = (Elf_External_Versym *) bfd_malloc (verhdr->sh_size); + if (xverbuf == NULL && verhdr->sh_size != 0) goto error_return; - if (bfd_bread ((PTR) x_versymp, verhdr->sh_size, abfd) + if (bfd_bread ((PTR) xverbuf, verhdr->sh_size, abfd) != verhdr->sh_size) goto error_return; } /* Skip first symbol, which is a null dummy. */ - for (i = 1; i < symcount; i++) + xver = xverbuf; + if (xver != NULL) + ++xver; + isymend = isymbuf + symcount; + for (isym = isymbuf + 1, sym = symbase; isym < isymend; isym++, sym++) { - elf_swap_symbol_in (abfd, x_symp + i, - x_shndx + (x_shndx != NULL ? i : 0), &i_sym); - memcpy (&sym->internal_elf_sym, &i_sym, sizeof (Elf_Internal_Sym)); -#ifdef ELF_KEEP_EXTSYM - memcpy (&sym->native_elf_sym, x_symp + i, sizeof (Elf_External_Sym)); -#endif + memcpy (&sym->internal_elf_sym, isym, sizeof (Elf_Internal_Sym)); sym->symbol.the_bfd = abfd; sym->symbol.name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, - i_sym.st_name); + isym->st_name); - sym->symbol.value = i_sym.st_value; + sym->symbol.value = isym->st_value; - if (i_sym.st_shndx == SHN_UNDEF) + if (isym->st_shndx == SHN_UNDEF) { sym->symbol.section = bfd_und_section_ptr; } - else if (i_sym.st_shndx < SHN_LORESERVE - || i_sym.st_shndx > SHN_HIRESERVE) + else if (isym->st_shndx < SHN_LORESERVE + || isym->st_shndx > SHN_HIRESERVE) { sym->symbol.section = section_from_elf_index (abfd, - i_sym.st_shndx); + isym->st_shndx); if (sym->symbol.section == NULL) { /* This symbol is in a section for which we did not @@ -1273,18 +1252,18 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) sym->symbol.section = bfd_abs_section_ptr; } } - else if (i_sym.st_shndx == SHN_ABS) + else if (isym->st_shndx == SHN_ABS) { sym->symbol.section = bfd_abs_section_ptr; } - else if (i_sym.st_shndx == SHN_COMMON) + else if (isym->st_shndx == SHN_COMMON) { sym->symbol.section = bfd_com_section_ptr; /* Elf puts the alignment into the `value' field, and the size into the `size' field. BFD wants to see the size in the value field, and doesn't care (at the moment) about the alignment. */ - sym->symbol.value = i_sym.st_size; + sym->symbol.value = isym->st_size; } else sym->symbol.section = bfd_abs_section_ptr; @@ -1294,14 +1273,13 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0) sym->symbol.value -= sym->symbol.section->vma; - switch (ELF_ST_BIND (i_sym.st_info)) + switch (ELF_ST_BIND (isym->st_info)) { case STB_LOCAL: sym->symbol.flags |= BSF_LOCAL; break; case STB_GLOBAL: - if (i_sym.st_shndx != SHN_UNDEF - && i_sym.st_shndx != SHN_COMMON) + if (isym->st_shndx != SHN_UNDEF && isym->st_shndx != SHN_COMMON) sym->symbol.flags |= BSF_GLOBAL; break; case STB_WEAK: @@ -1309,7 +1287,7 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) break; } - switch (ELF_ST_TYPE (i_sym.st_info)) + switch (ELF_ST_TYPE (isym->st_info)) { case STT_SECTION: sym->symbol.flags |= BSF_SECTION_SYM | BSF_DEBUGGING; @@ -1328,31 +1306,24 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) if (dynamic) sym->symbol.flags |= BSF_DYNAMIC; - if (x_versymp != NULL) + if (xver != NULL) { Elf_Internal_Versym iversym; - _bfd_elf_swap_versym_in (abfd, x_versymp + i, &iversym); + _bfd_elf_swap_versym_in (abfd, xver, &iversym); sym->version = iversym.vs_vers; + xver++; } /* Do some backend-specific processing on this symbol. */ - { - struct elf_backend_data *ebd = get_elf_backend_data (abfd); - if (ebd->elf_backend_symbol_processing) - (*ebd->elf_backend_symbol_processing) (abfd, &sym->symbol); - } - - sym++; + if (ebd->elf_backend_symbol_processing) + (*ebd->elf_backend_symbol_processing) (abfd, &sym->symbol); } } /* Do some backend-specific processing on this symbol table. */ - { - struct elf_backend_data *ebd = get_elf_backend_data (abfd); - if (ebd->elf_backend_symbol_table_processing) - (*ebd->elf_backend_symbol_table_processing) (abfd, symbase, symcount); - } + if (ebd->elf_backend_symbol_table_processing) + (*ebd->elf_backend_symbol_table_processing) (abfd, symbase, symcount); /* We rely on the zalloc to clear out the final symbol entry. */ @@ -1372,21 +1343,17 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) *symptrs = 0; /* Final null pointer */ } - if (x_shndx != NULL) - free (x_shndx); - if (x_versymp != NULL) - free (x_versymp); - if (x_symp != NULL) - free (x_symp); + if (xverbuf != NULL) + free (xverbuf); + if (isymbuf != NULL && hdr->contents != (unsigned char *) isymbuf) + free (isymbuf); return symcount; error_return: - if (x_shndx != NULL) - free (x_shndx); - if (x_versymp != NULL) - free (x_versymp); - if (x_symp != NULL) - free (x_symp); + if (xverbuf != NULL) + free (xverbuf); + if (isymbuf != NULL && hdr->contents != (unsigned char *) isymbuf) + free (isymbuf); return -1; } @@ -1410,6 +1377,7 @@ elf_slurp_reloc_table_from_section (abfd, asect, rel_hdr, reloc_count, arelent *relent; unsigned int i; int entsize; + unsigned int symcount; allocated = (PTR) bfd_malloc (rel_hdr->sh_size); if (allocated == NULL) @@ -1426,6 +1394,11 @@ elf_slurp_reloc_table_from_section (abfd, asect, rel_hdr, reloc_count, BFD_ASSERT (entsize == sizeof (Elf_External_Rel) || entsize == sizeof (Elf_External_Rela)); + if (dynamic) + symcount = bfd_get_dynamic_symcount (abfd); + else + symcount = bfd_get_symcount (abfd); + for (i = 0, relent = relents; i < reloc_count; i++, relent++, native_relocs += entsize) @@ -1454,6 +1427,13 @@ elf_slurp_reloc_table_from_section (abfd, asect, rel_hdr, reloc_count, if (ELF_R_SYM (rela.r_info) == 0) relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; + else if (ELF_R_SYM (rela.r_info) > symcount) + { + (*_bfd_error_handler) + (_("%s(%s): relocation %d has invalid symbol index %ld"), + abfd->filename, asect->name, i, ELF_R_SYM (rela.r_info)); + relent->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr; + } else { asymbol **ps, *s; @@ -1695,6 +1675,7 @@ const struct elf_size_info NAME(_bfd_elf,size_info) = { elf_write_out_phdrs, elf_write_shdrs_and_ehdr, elf_write_relocs, + elf_swap_symbol_in, elf_swap_symbol_out, elf_slurp_reloc_table, elf_slurp_symbol_table, diff --git a/contrib/binutils/bfd/elfcore.h b/contrib/binutils/bfd/elfcore.h index c206af5..7db5f72 100644 --- a/contrib/binutils/bfd/elfcore.h +++ b/contrib/binutils/bfd/elfcore.h @@ -1,5 +1,5 @@ /* ELF core file support for BFD. - Copyright 1995, 1996, 1997, 1998, 2000, 2001 + Copyright 1995, 1996, 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -100,7 +100,7 @@ elf_core_file_p (abfd) } /* Check the magic number. */ - if (elf_file_p (&x_ehdr) == false) + if (! elf_file_p (&x_ehdr)) goto wrong; /* FIXME: Check EI_VERSION here ! */ @@ -244,7 +244,7 @@ elf_core_file_p (abfd) information. */ if (ebd->elf_backend_object_p) { - if ((*ebd->elf_backend_object_p) (abfd) == false) + if (! (*ebd->elf_backend_object_p) (abfd)) goto wrong; } diff --git a/contrib/binutils/bfd/elflink.c b/contrib/binutils/bfd/elflink.c index e74fae9..f8cc645 100644 --- a/contrib/binutils/bfd/elflink.c +++ b/contrib/binutils/bfd/elflink.c @@ -278,11 +278,13 @@ _bfd_elf_link_record_dynamic_symbol (info, h) } else { - alc = bfd_malloc ((bfd_size_type) (p - name + 1)); + size_t len = p - name + 1; + + alc = bfd_malloc ((bfd_size_type) len); if (alc == NULL) return false; - strncpy (alc, name, (size_t) (p - name)); - alc[p - name] = '\0'; + memcpy (alc, name, len - 1); + alc[len - 1] = '\0'; name = alc; copy = true; } @@ -300,6 +302,98 @@ _bfd_elf_link_record_dynamic_symbol (info, h) return true; } +/* Record a new local dynamic symbol. Returns 0 on failure, 1 on + success, and 2 on a failure caused by attempting to record a symbol + in a discarded section, eg. a discarded link-once section symbol. */ + +int +elf_link_record_local_dynamic_symbol (info, input_bfd, input_indx) + struct bfd_link_info *info; + bfd *input_bfd; + long input_indx; +{ + bfd_size_type amt; + struct elf_link_local_dynamic_entry *entry; + struct elf_link_hash_table *eht; + struct elf_strtab_hash *dynstr; + unsigned long dynstr_index; + char *name; + Elf_External_Sym_Shndx eshndx; + char esym[sizeof (Elf64_External_Sym)]; + + if (! is_elf_hash_table (info)) + return 0; + + /* See if the entry exists already. */ + for (entry = elf_hash_table (info)->dynlocal; entry ; entry = entry->next) + if (entry->input_bfd == input_bfd && entry->input_indx == input_indx) + return 1; + + amt = sizeof (*entry); + entry = (struct elf_link_local_dynamic_entry *) bfd_alloc (input_bfd, amt); + if (entry == NULL) + return 0; + + /* Go find the symbol, so that we can find it's name. */ + if (!bfd_elf_get_elf_syms (input_bfd, &elf_tdata (input_bfd)->symtab_hdr, + (size_t) 1, (size_t) input_indx, + &entry->isym, esym, &eshndx)) + { + bfd_release (input_bfd, entry); + return 0; + } + + if (entry->isym.st_shndx != SHN_UNDEF + && (entry->isym.st_shndx < SHN_LORESERVE + || entry->isym.st_shndx > SHN_HIRESERVE)) + { + asection *s; + + s = bfd_section_from_elf_index (input_bfd, entry->isym.st_shndx); + if (s == NULL || bfd_is_abs_section (s->output_section)) + { + /* We can still bfd_release here as nothing has done another + bfd_alloc. We can't do this later in this function. */ + bfd_release (input_bfd, entry); + return 2; + } + } + + name = (bfd_elf_string_from_elf_section + (input_bfd, elf_tdata (input_bfd)->symtab_hdr.sh_link, + entry->isym.st_name)); + + dynstr = elf_hash_table (info)->dynstr; + if (dynstr == NULL) + { + /* Create a strtab to hold the dynamic symbol names. */ + elf_hash_table (info)->dynstr = dynstr = _bfd_elf_strtab_init (); + if (dynstr == NULL) + return 0; + } + + dynstr_index = _bfd_elf_strtab_add (dynstr, name, false); + if (dynstr_index == (unsigned long) -1) + return 0; + entry->isym.st_name = dynstr_index; + + eht = elf_hash_table (info); + + entry->next = eht->dynlocal; + eht->dynlocal = entry; + entry->input_bfd = input_bfd; + entry->input_indx = input_indx; + eht->dynsymcount++; + + /* Whatever binding the symbol had before, it's now local. */ + entry->isym.st_info + = ELF_ST_INFO (STB_LOCAL, ELF_ST_TYPE (entry->isym.st_info)); + + /* The dynindx will be set at the end of size_dynamic_sections. */ + + return 1; +} + /* Return the dynindex of a local dynamic symbol. */ long @@ -355,7 +449,8 @@ _bfd_elf_link_renumber_dynsyms (output_bfd, info) { asection *p; for (p = output_bfd->sections; p ; p = p->next) - elf_section_data (p)->dynindx = ++dynsymcount; + if ((p->flags & SEC_EXCLUDE) == 0) + elf_section_data (p)->dynindx = ++dynsymcount; } if (elf_hash_table (info)->dynlocal) diff --git a/contrib/binutils/bfd/elflink.h b/contrib/binutils/bfd/elflink.h index bfe6374..25519b1 100644 --- a/contrib/binutils/bfd/elflink.h +++ b/contrib/binutils/bfd/elflink.h @@ -65,7 +65,7 @@ static boolean elf_link_read_relocs_from_section PARAMS ((bfd *, Elf_Internal_Shdr *, PTR, Elf_Internal_Rela *)); static size_t compute_bucket_count PARAMS ((struct bfd_link_info *)); -static void elf_link_output_relocs +static boolean elf_link_output_relocs PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *)); static boolean elf_link_size_reloc_section PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); @@ -149,18 +149,13 @@ elf_link_is_defined_archive_symbol (abfd, symdef) carsym * symdef; { Elf_Internal_Shdr * hdr; - Elf_Internal_Shdr * shndx_hdr; - Elf_External_Sym * esym; - Elf_External_Sym * esymend; - Elf_External_Sym * buf = NULL; - Elf_External_Sym_Shndx * shndx_buf = NULL; - Elf_External_Sym_Shndx * shndx; bfd_size_type symcount; bfd_size_type extsymcount; bfd_size_type extsymoff; - boolean result = false; - file_ptr pos; - bfd_size_type amt; + Elf_Internal_Sym *isymbuf; + Elf_Internal_Sym *isym; + Elf_Internal_Sym *isymend; + boolean result; abfd = _bfd_get_elt_at_filepos (abfd, symdef->file_offset); if (abfd == (bfd *) NULL) @@ -178,15 +173,9 @@ elf_link_is_defined_archive_symbol (abfd, symdef) /* Select the appropriate symbol table. */ if ((abfd->flags & DYNAMIC) == 0 || elf_dynsymtab (abfd) == 0) - { - hdr = &elf_tdata (abfd)->symtab_hdr; - shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; - } + hdr = &elf_tdata (abfd)->symtab_hdr; else - { - hdr = &elf_tdata (abfd)->dynsymtab_hdr; - shndx_hdr = NULL; - } + hdr = &elf_tdata (abfd)->dynsymtab_hdr; symcount = hdr->sh_size / sizeof (Elf_External_Sym); @@ -203,58 +192,34 @@ elf_link_is_defined_archive_symbol (abfd, symdef) extsymoff = hdr->sh_info; } - amt = extsymcount * sizeof (Elf_External_Sym); - buf = (Elf_External_Sym *) bfd_malloc (amt); - if (buf == NULL && extsymcount != 0) + if (extsymcount == 0) return false; - /* Read in the symbol table. - FIXME: This ought to be cached somewhere. */ - pos = hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym); - if (bfd_seek (abfd, pos, SEEK_SET) != 0 - || bfd_bread ((PTR) buf, amt, abfd) != amt) - goto error_exit; - - if (shndx_hdr != NULL && shndx_hdr->sh_size != 0) - { - amt = extsymcount * sizeof (Elf_External_Sym_Shndx); - shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (amt); - if (shndx_buf == NULL && extsymcount != 0) - goto error_exit; - - pos = shndx_hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym_Shndx); - if (bfd_seek (abfd, pos, SEEK_SET) != 0 - || bfd_bread ((PTR) shndx_buf, amt, abfd) != amt) - goto error_exit; - } + /* Read in the symbol table. */ + isymbuf = bfd_elf_get_elf_syms (abfd, hdr, extsymcount, extsymoff, + NULL, NULL, NULL); + if (isymbuf == NULL) + return false; /* Scan the symbol table looking for SYMDEF. */ - esymend = buf + extsymcount; - for (esym = buf, shndx = shndx_buf; - esym < esymend; - esym++, shndx = (shndx != NULL ? shndx + 1 : NULL)) + result = false; + for (isym = isymbuf, isymend = isymbuf + extsymcount; isym < isymend; isym++) { - Elf_Internal_Sym sym; - const char * name; - - elf_swap_symbol_in (abfd, esym, shndx, &sym); + const char *name; - name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, sym.st_name); + name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, + isym->st_name); if (name == (const char *) NULL) break; if (strcmp (name, symdef->name) == 0) { - result = is_global_data_symbol_definition (abfd, & sym); + result = is_global_data_symbol_definition (abfd, isym); break; } } - error_exit: - if (shndx_buf != NULL) - free (shndx_buf); - if (buf != NULL) - free (buf); + free (isymbuf); return result; } @@ -313,12 +278,10 @@ elf_link_add_archive_symbols (abfd, info) return true; amt = c; amt *= sizeof (boolean); - defined = (boolean *) bfd_malloc (amt); - included = (boolean *) bfd_malloc (amt); + defined = (boolean *) bfd_zmalloc (amt); + included = (boolean *) bfd_zmalloc (amt); if (defined == (boolean *) NULL || included == (boolean *) NULL) goto error_return; - memset (defined, 0, (size_t) amt); - memset (included, 0, (size_t) amt); symdefs = bfd_ardata (abfd)->symdefs; @@ -355,26 +318,40 @@ elf_link_add_archive_symbols (abfd, info) if (h == NULL) { char *p, *copy; + size_t len, first; /* If this is a default version (the name contains @@), - look up the symbol again without the version. The - effect is that references to the symbol without the - version will be matched by the default symbol in the - archive. */ + look up the symbol again with only one `@' as well + as without the version. The effect is that references + to the symbol with and without the version will be + matched by the default symbol in the archive. */ p = strchr (symdef->name, ELF_VER_CHR); if (p == NULL || p[1] != ELF_VER_CHR) continue; - copy = bfd_alloc (abfd, (bfd_size_type) (p - symdef->name + 1)); + /* First check with only one `@'. */ + len = strlen (symdef->name); + copy = bfd_alloc (abfd, (bfd_size_type) len); if (copy == NULL) goto error_return; - memcpy (copy, symdef->name, (size_t) (p - symdef->name)); - copy[p - symdef->name] = '\0'; + first = p - symdef->name + 1; + memcpy (copy, symdef->name, first); + memcpy (copy + first, symdef->name + first + 1, len - first); h = elf_link_hash_lookup (elf_hash_table (info), copy, false, false, false); + if (h == NULL) + { + /* We also need to check references to the symbol + without the version. */ + + copy[first - 1] = '\0'; + h = elf_link_hash_lookup (elf_hash_table (info), + copy, false, false, false); + } + bfd_release (abfd, copy); } @@ -922,19 +899,19 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, /* This function is called to create an indirect symbol from the default for the symbol with the default version if needed. The - symbol is described by H, NAME, SYM, SEC, VALUE, and OVERRIDE. We + symbol is described by H, NAME, SYM, PSEC, VALUE, and OVERRIDE. We set DYNSYM if the new indirect symbol is dynamic. DT_NEEDED indicates if it comes from a DT_NEEDED entry of a shared object. */ static boolean -elf_add_default_symbol (abfd, info, h, name, sym, sec, value, +elf_add_default_symbol (abfd, info, h, name, sym, psec, value, dynsym, override, dt_needed) bfd *abfd; struct bfd_link_info *info; struct elf_link_hash_entry *h; const char *name; Elf_Internal_Sym *sym; - asection **sec; + asection **psec; bfd_vma *value; boolean *dynsym; boolean override; @@ -948,6 +925,8 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value, boolean collect; boolean dynamic; char *p; + size_t len, shortlen; + asection *sec; /* If this symbol has a version, and it is the default version, we create an indirect symbol from the default name to the fully @@ -960,7 +939,7 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value, if (override) { /* We are overridden by an old defition. We need to check if we - need to crreate the indirect symbol from the default name. */ + need to create the indirect symbol from the default name. */ hi = elf_link_hash_lookup (elf_hash_table (info), name, true, false, false); BFD_ASSERT (hi != NULL); @@ -979,12 +958,12 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value, collect = bed->collect; dynamic = (abfd->flags & DYNAMIC) != 0; - shortname = bfd_hash_allocate (&info->hash->table, - (size_t) (p - name + 1)); + shortlen = p - name; + shortname = bfd_hash_allocate (&info->hash->table, shortlen + 1); if (shortname == NULL) return false; - strncpy (shortname, name, (size_t) (p - name)); - shortname [p - name] = '\0'; + memcpy (shortname, name, shortlen); + shortname[shortlen] = '\0'; /* We are going to create a new symbol. Merge it with any existing symbol with this name. For the purposes of the merge, act as @@ -992,7 +971,8 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value, actually going to define an indirect symbol. */ type_change_ok = false; size_change_ok = false; - if (! elf_merge_symbol (abfd, info, shortname, sym, sec, value, + sec = *psec; + if (! elf_merge_symbol (abfd, info, shortname, sym, &sec, value, &hi, &override, &type_change_ok, &size_change_ok, dt_needed)) return false; @@ -1064,7 +1044,7 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value, | ELF_LINK_HASH_DEF_REGULAR)) == 0); ht = (struct elf_link_hash_entry *) hi->root.u.i.link; - (*bed->elf_backend_copy_indirect_symbol) (ht, hi); + (*bed->elf_backend_copy_indirect_symbol) (bed, ht, hi); /* See if the new flags lead us to realize that the symbol must be dynamic. */ @@ -1089,16 +1069,18 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value, /* We also need to define an indirection from the nondefault version of the symbol. */ - shortname = bfd_hash_allocate (&info->hash->table, strlen (name)); + len = strlen (name); + shortname = bfd_hash_allocate (&info->hash->table, len); if (shortname == NULL) return false; - strncpy (shortname, name, (size_t) (p - name)); - strcpy (shortname + (p - name), p + 1); + memcpy (shortname, name, shortlen); + memcpy (shortname + shortlen, p + 1, len - shortlen); /* Once again, merge with any existing symbol. */ type_change_ok = false; size_change_ok = false; - if (! elf_merge_symbol (abfd, info, shortname, sym, sec, value, + sec = *psec; + if (! elf_merge_symbol (abfd, info, shortname, sym, &sec, value, &hi, &override, &type_change_ok, &size_change_ok, dt_needed)) return false; @@ -1106,10 +1088,13 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value, if (override) { /* Here SHORTNAME is a versioned name, so we don't expect to see - the type of override we do in the case above. */ - (*_bfd_error_handler) - (_("%s: warning: unexpected redefinition of `%s'"), - bfd_archive_filename (abfd), shortname); + the type of override we do in the case above unless it is + overridden by a versioned definiton. */ + if (hi->root.type != bfd_link_hash_defined + && hi->root.type != bfd_link_hash_defweak) + (*_bfd_error_handler) + (_("%s: warning: unexpected redefinition of indirect versioned symbol `%s'"), + bfd_archive_filename (abfd), shortname); } else { @@ -1131,7 +1116,7 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value, & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_DEF_REGULAR)) == 0); - (*bed->elf_backend_copy_indirect_symbol) (h, hi); + (*bed->elf_backend_copy_indirect_symbol) (bed, h, hi); /* See if the new flags lead us to realize that the symbol must be dynamic. */ @@ -1172,25 +1157,20 @@ elf_link_add_object_symbols (abfd, info) asection *, const Elf_Internal_Rela *)); boolean collect; Elf_Internal_Shdr *hdr; - Elf_Internal_Shdr *shndx_hdr; bfd_size_type symcount; bfd_size_type extsymcount; bfd_size_type extsymoff; - Elf_External_Sym *buf = NULL; - Elf_External_Sym_Shndx *shndx_buf = NULL; - Elf_External_Sym_Shndx *shndx; struct elf_link_hash_entry **sym_hash; boolean dynamic; Elf_External_Versym *extversym = NULL; Elf_External_Versym *ever; - Elf_External_Dyn *dynbuf = NULL; struct elf_link_hash_entry *weaks; - Elf_External_Sym *esym; - Elf_External_Sym *esymend; + Elf_Internal_Sym *isymbuf = NULL; + Elf_Internal_Sym *isym; + Elf_Internal_Sym *isymend; struct elf_backend_data *bed; boolean dt_needed; struct elf_link_hash_table * hash_table; - file_ptr pos; bfd_size_type amt; hash_table = elf_hash_table (info); @@ -1289,85 +1269,7 @@ elf_link_add_object_symbols (abfd, info) } } - /* If this is a dynamic object, we always link against the .dynsym - symbol table, not the .symtab symbol table. The dynamic linker - will only see the .dynsym symbol table, so there is no reason to - look at .symtab for a dynamic object. */ - - if (! dynamic || elf_dynsymtab (abfd) == 0) - { - hdr = &elf_tdata (abfd)->symtab_hdr; - shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; - } - else - { - hdr = &elf_tdata (abfd)->dynsymtab_hdr; - shndx_hdr = NULL; - } - - if (dynamic) - { - /* Read in any version definitions. */ - - if (! _bfd_elf_slurp_version_tables (abfd)) - goto error_return; - - /* Read in the symbol versions, but don't bother to convert them - to internal format. */ - if (elf_dynversym (abfd) != 0) - { - Elf_Internal_Shdr *versymhdr; - - versymhdr = &elf_tdata (abfd)->dynversym_hdr; - extversym = (Elf_External_Versym *) bfd_malloc (versymhdr->sh_size); - if (extversym == NULL) - goto error_return; - amt = versymhdr->sh_size; - if (bfd_seek (abfd, versymhdr->sh_offset, SEEK_SET) != 0 - || bfd_bread ((PTR) extversym, amt, abfd) != amt) - goto error_return; - } - } - - symcount = hdr->sh_size / sizeof (Elf_External_Sym); - - /* The sh_info field of the symtab header tells us where the - external symbols start. We don't care about the local symbols at - this point. */ - if (elf_bad_symtab (abfd)) - { - extsymcount = symcount; - extsymoff = 0; - } - else - { - extsymcount = symcount - hdr->sh_info; - extsymoff = hdr->sh_info; - } - - amt = extsymcount * sizeof (Elf_External_Sym); - buf = (Elf_External_Sym *) bfd_malloc (amt); - if (buf == NULL && extsymcount != 0) - goto error_return; - - if (shndx_hdr != NULL && shndx_hdr->sh_size != 0) - { - amt = extsymcount * sizeof (Elf_External_Sym_Shndx); - shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (amt); - if (shndx_buf == NULL && extsymcount != 0) - goto error_return; - } - - /* We store a pointer to the hash table entry for each external - symbol. */ - amt = extsymcount * sizeof (struct elf_link_hash_entry *); - sym_hash = (struct elf_link_hash_entry **) bfd_alloc (abfd, amt); - if (sym_hash == NULL) - goto error_return; - elf_sym_hashes (abfd) = sym_hash; - dt_needed = false; - if (! dynamic) { /* If we are creating a shared library, create all the dynamic @@ -1417,6 +1319,7 @@ elf_link_add_object_symbols (abfd, info) s = bfd_get_section_by_name (abfd, ".dynamic"); if (s != NULL) { + Elf_External_Dyn *dynbuf = NULL; Elf_External_Dyn *extdyn; Elf_External_Dyn *extdynend; int elfsec; @@ -1430,30 +1333,13 @@ elf_link_add_object_symbols (abfd, info) if (! bfd_get_section_contents (abfd, s, (PTR) dynbuf, (file_ptr) 0, s->_raw_size)) - goto error_return; + goto error_free_dyn; elfsec = _bfd_elf_section_from_bfd_section (abfd, s); if (elfsec == -1) - goto error_return; + goto error_free_dyn; shlink = elf_elfsections (abfd)[elfsec]->sh_link; - { - /* The shared libraries distributed with hpux11 have a bogus - sh_link field for the ".dynamic" section. This code detects - when SHLINK refers to a section that is not a string table - and tries to find the string table for the ".dynsym" section - instead. */ - Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[shlink]; - if (shdr->sh_type != SHT_STRTAB) - { - asection *ds = bfd_get_section_by_name (abfd, ".dynsym"); - int elfdsec = _bfd_elf_section_from_bfd_section (abfd, ds); - if (elfdsec == -1) - goto error_return; - shlink = elf_elfsections (abfd)[elfdsec]->sh_link; - } - } - extdyn = dynbuf; extdynend = extdyn + s->_raw_size / sizeof (Elf_External_Dyn); rpath = 0; @@ -1468,7 +1354,7 @@ elf_link_add_object_symbols (abfd, info) unsigned int tagv = dyn.d_un.d_val; name = bfd_elf_string_from_elf_section (abfd, shlink, tagv); if (name == NULL) - goto error_return; + goto error_free_dyn; } if (dyn.d_tag == DT_NEEDED) { @@ -1480,11 +1366,12 @@ elf_link_add_object_symbols (abfd, info) n = (struct bfd_link_needed_list *) bfd_alloc (abfd, amt); fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv); if (n == NULL || fnm == NULL) - goto error_return; - anm = bfd_alloc (abfd, (bfd_size_type) strlen (fnm) + 1); + goto error_free_dyn; + amt = strlen (fnm) + 1; + anm = bfd_alloc (abfd, amt); if (anm == NULL) - goto error_return; - strcpy (anm, fnm); + goto error_free_dyn; + memcpy (anm, fnm, (size_t) amt); n->name = anm; n->by = abfd; n->next = NULL; @@ -1511,11 +1398,12 @@ elf_link_add_object_symbols (abfd, info) n = (struct bfd_link_needed_list *) bfd_alloc (abfd, amt); fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv); if (n == NULL || fnm == NULL) - goto error_return; - anm = bfd_alloc (abfd, (bfd_size_type) strlen (fnm) + 1); + goto error_free_dyn; + amt = strlen (fnm) + 1; + anm = bfd_alloc (abfd, amt); if (anm == NULL) - goto error_return; - strcpy (anm, fnm); + goto error_free_dyn; + memcpy (anm, fnm, (size_t) amt); n->name = anm; n->by = abfd; n->next = NULL; @@ -1538,11 +1426,16 @@ elf_link_add_object_symbols (abfd, info) n = (struct bfd_link_needed_list *) bfd_alloc (abfd, amt); fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv); if (n == NULL || fnm == NULL) - goto error_return; - anm = bfd_alloc (abfd, (bfd_size_type) strlen (fnm) + 1); + goto error_free_dyn; + amt = strlen (fnm) + 1; + anm = bfd_alloc (abfd, amt); if (anm == NULL) - goto error_return; - strcpy (anm, fnm); + { + error_free_dyn: + free (dynbuf); + goto error_return; + } + memcpy (anm, fnm, (size_t) amt); n->name = anm; n->by = abfd; n->next = NULL; @@ -1556,7 +1449,6 @@ elf_link_add_object_symbols (abfd, info) } free (dynbuf); - dynbuf = NULL; } /* We do not want to include any of the sections in a dynamic @@ -1606,10 +1498,6 @@ elf_link_add_object_symbols (abfd, info) if (dyn.d_tag == DT_NEEDED && dyn.d_un.d_val == strindex) { - if (buf != NULL) - free (buf); - if (extversym != NULL) - free (extversym); _bfd_elf_strtab_delref (hash_table->dynstr, strindex); return true; } @@ -1627,31 +1515,79 @@ elf_link_add_object_symbols (abfd, info) elf_dt_name (abfd) = name; } - pos = hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym); - amt = extsymcount * sizeof (Elf_External_Sym); - if (bfd_seek (abfd, pos, SEEK_SET) != 0 - || bfd_bread ((PTR) buf, amt, abfd) != amt) - goto error_return; + /* If this is a dynamic object, we always link against the .dynsym + symbol table, not the .symtab symbol table. The dynamic linker + will only see the .dynsym symbol table, so there is no reason to + look at .symtab for a dynamic object. */ + + if (! dynamic || elf_dynsymtab (abfd) == 0) + hdr = &elf_tdata (abfd)->symtab_hdr; + else + hdr = &elf_tdata (abfd)->dynsymtab_hdr; - if (shndx_hdr != NULL && shndx_hdr->sh_size != 0) + symcount = hdr->sh_size / sizeof (Elf_External_Sym); + + /* The sh_info field of the symtab header tells us where the + external symbols start. We don't care about the local symbols at + this point. */ + if (elf_bad_symtab (abfd)) { - amt = extsymcount * sizeof (Elf_External_Sym_Shndx); - pos = shndx_hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym_Shndx); - if (bfd_seek (abfd, pos, SEEK_SET) != 0 - || bfd_bread ((PTR) shndx_buf, amt, abfd) != amt) + extsymcount = symcount; + extsymoff = 0; + } + else + { + extsymcount = symcount - hdr->sh_info; + extsymoff = hdr->sh_info; + } + + sym_hash = NULL; + if (extsymcount != 0) + { + isymbuf = bfd_elf_get_elf_syms (abfd, hdr, extsymcount, extsymoff, + NULL, NULL, NULL); + if (isymbuf == NULL) goto error_return; + + /* We store a pointer to the hash table entry for each external + symbol. */ + amt = extsymcount * sizeof (struct elf_link_hash_entry *); + sym_hash = (struct elf_link_hash_entry **) bfd_alloc (abfd, amt); + if (sym_hash == NULL) + goto error_free_sym; + elf_sym_hashes (abfd) = sym_hash; + } + + if (dynamic) + { + /* Read in any version definitions. */ + if (! _bfd_elf_slurp_version_tables (abfd)) + goto error_free_sym; + + /* Read in the symbol versions, but don't bother to convert them + to internal format. */ + if (elf_dynversym (abfd) != 0) + { + Elf_Internal_Shdr *versymhdr; + + versymhdr = &elf_tdata (abfd)->dynversym_hdr; + extversym = (Elf_External_Versym *) bfd_malloc (versymhdr->sh_size); + if (extversym == NULL) + goto error_free_sym; + amt = versymhdr->sh_size; + if (bfd_seek (abfd, versymhdr->sh_offset, SEEK_SET) != 0 + || bfd_bread ((PTR) extversym, amt, abfd) != amt) + goto error_free_vers; + } } weaks = NULL; ever = extversym != NULL ? extversym + extsymoff : NULL; - esymend = buf + extsymcount; - for (esym = buf, shndx = shndx_buf; - esym < esymend; - esym++, sym_hash++, ever = (ever != NULL ? ever + 1 : NULL), - shndx = (shndx != NULL ? shndx + 1 : NULL)) + for (isym = isymbuf, isymend = isymbuf + extsymcount; + isym < isymend; + isym++, sym_hash++, ever = (ever != NULL ? ever + 1 : NULL)) { - Elf_Internal_Sym sym; int bind; bfd_vma value; asection *sec; @@ -1666,14 +1602,12 @@ elf_link_add_object_symbols (abfd, info) override = false; - elf_swap_symbol_in (abfd, esym, shndx, &sym); - flags = BSF_NO_FLAGS; sec = NULL; - value = sym.st_value; + value = isym->st_value; *sym_hash = NULL; - bind = ELF_ST_BIND (sym.st_info); + bind = ELF_ST_BIND (isym->st_info); if (bind == STB_LOCAL) { /* This should be impossible, since ELF requires that all @@ -1684,8 +1618,8 @@ elf_link_add_object_symbols (abfd, info) } else if (bind == STB_GLOBAL) { - if (sym.st_shndx != SHN_UNDEF - && sym.st_shndx != SHN_COMMON) + if (isym->st_shndx != SHN_UNDEF + && isym->st_shndx != SHN_COMMON) flags = BSF_GLOBAL; } else if (bind == STB_WEAK) @@ -1695,39 +1629,57 @@ elf_link_add_object_symbols (abfd, info) /* Leave it up to the processor backend. */ } - if (sym.st_shndx == SHN_UNDEF) + if (isym->st_shndx == SHN_UNDEF) sec = bfd_und_section_ptr; - else if (sym.st_shndx < SHN_LORESERVE || sym.st_shndx > SHN_HIRESERVE) + else if (isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE) { - sec = section_from_elf_index (abfd, sym.st_shndx); + sec = section_from_elf_index (abfd, isym->st_shndx); if (sec == NULL) sec = bfd_abs_section_ptr; else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0) value -= sec->vma; } - else if (sym.st_shndx == SHN_ABS) + else if (isym->st_shndx == SHN_ABS) sec = bfd_abs_section_ptr; - else if (sym.st_shndx == SHN_COMMON) + else if (isym->st_shndx == SHN_COMMON) { sec = bfd_com_section_ptr; /* What ELF calls the size we call the value. What ELF calls the value we call the alignment. */ - value = sym.st_size; + value = isym->st_size; } else { /* Leave it up to the processor backend. */ } - name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, sym.st_name); + name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, + isym->st_name); if (name == (const char *) NULL) - goto error_return; + goto error_free_vers; - if (add_symbol_hook) + if (isym->st_shndx == SHN_COMMON + && ELF_ST_TYPE (isym->st_info) == STT_TLS) { - if (! (*add_symbol_hook) (abfd, info, &sym, &name, &flags, &sec, + asection *tcomm = bfd_get_section_by_name (abfd, ".tcommon"); + + if (tcomm == NULL) + { + tcomm = bfd_make_section (abfd, ".tcommon"); + if (tcomm == NULL + || !bfd_set_section_flags (abfd, tcomm, (SEC_ALLOC + | SEC_IS_COMMON + | SEC_LINKER_CREATED + | SEC_THREAD_LOCAL))) + goto error_free_vers; + } + sec = tcomm; + } + else if (add_symbol_hook) + { + if (! (*add_symbol_hook) (abfd, info, isym, &name, &flags, &sec, &value)) - goto error_return; + goto error_free_vers; /* The hook function sets the name to NULL if this symbol should be skipped for some reason. */ @@ -1739,7 +1691,7 @@ elf_link_add_object_symbols (abfd, info) if (sec == (asection *) NULL) { bfd_set_error (bfd_error_bad_value); - goto error_return; + goto error_free_vers; } if (bfd_is_und_section (sec) @@ -1770,11 +1722,10 @@ elf_link_add_object_symbols (abfd, info) || (vernum > 1 && ! bfd_is_abs_section (sec))) { const char *verstr; - unsigned int namelen; - bfd_size_type newlen; + size_t namelen, verlen, newlen; char *newname, *p; - if (sym.st_shndx != SHN_UNDEF) + if (isym->st_shndx != SHN_UNDEF) { if (vernum > elf_tdata (abfd)->dynverdef_hdr.sh_info) { @@ -1783,7 +1734,7 @@ elf_link_add_object_symbols (abfd, info) bfd_archive_filename (abfd), name, vernum, elf_tdata (abfd)->dynverdef_hdr.sh_info); bfd_set_error (bfd_error_bad_value); - goto error_return; + goto error_free_vers; } else if (vernum > 1) verstr = @@ -1823,37 +1774,39 @@ elf_link_add_object_symbols (abfd, info) (_("%s: %s: invalid needed version %d"), bfd_archive_filename (abfd), name, vernum); bfd_set_error (bfd_error_bad_value); - goto error_return; + goto error_free_vers; } } namelen = strlen (name); - newlen = namelen + strlen (verstr) + 2; - if ((iver.vs_vers & VERSYM_HIDDEN) == 0) + verlen = strlen (verstr); + newlen = namelen + verlen + 2; + if ((iver.vs_vers & VERSYM_HIDDEN) == 0 + && isym->st_shndx != SHN_UNDEF) ++newlen; - newname = (char *) bfd_alloc (abfd, newlen); + newname = (char *) bfd_alloc (abfd, (bfd_size_type) newlen); if (newname == NULL) - goto error_return; - strcpy (newname, name); + goto error_free_vers; + memcpy (newname, name, namelen); p = newname + namelen; *p++ = ELF_VER_CHR; /* If this is a defined non-hidden version symbol, we add another @ to the name. This indicates the default version of the symbol. */ if ((iver.vs_vers & VERSYM_HIDDEN) == 0 - && sym.st_shndx != SHN_UNDEF) + && isym->st_shndx != SHN_UNDEF) *p++ = ELF_VER_CHR; - strcpy (p, verstr); + memcpy (p, verstr, verlen + 1); name = newname; } } - if (! elf_merge_symbol (abfd, info, name, &sym, &sec, &value, + if (! elf_merge_symbol (abfd, info, name, isym, &sec, &value, sym_hash, &override, &type_change_ok, &size_change_ok, dt_needed)) - goto error_return; + goto error_free_vers; if (override) definition = false; @@ -1881,7 +1834,7 @@ elf_link_add_object_symbols (abfd, info) if (! (_bfd_generic_link_add_one_symbol (info, abfd, name, flags, sec, value, (const char *) NULL, false, collect, (struct bfd_link_hash_entry **) sym_hash))) - goto error_return; + goto error_free_vers; h = *sym_hash; while (h->root.type == bfd_link_hash_indirect @@ -1893,7 +1846,7 @@ elf_link_add_object_symbols (abfd, info) if (dynamic && definition && (flags & BSF_WEAK) != 0 - && ELF_ST_TYPE (sym.st_info) != STT_FUNC + && ELF_ST_TYPE (isym->st_info) != STT_FUNC && info->hash->creator->flavour == bfd_target_elf_flavour && h->weakdef == NULL) { @@ -1915,16 +1868,16 @@ elf_link_add_object_symbols (abfd, info) } /* Set the alignment of a common symbol. */ - if (sym.st_shndx == SHN_COMMON + if (isym->st_shndx == SHN_COMMON && h->root.type == bfd_link_hash_common) { unsigned int align; - align = bfd_log2 (sym.st_value); + align = bfd_log2 (isym->st_value); if (align > old_alignment /* Permit an alignment power of zero if an alignment of one is specified and no other alignments have been specified. */ - || (sym.st_value == 1 && old_alignment == 0)) + || (isym->st_value == 1 && old_alignment == 0)) h->root.u.c.p->alignment_power = align; } @@ -1935,16 +1888,16 @@ elf_link_add_object_symbols (abfd, info) int new_flag; /* Remember the symbol size and type. */ - if (sym.st_size != 0 + if (isym->st_size != 0 && (definition || h->size == 0)) { - if (h->size != 0 && h->size != sym.st_size && ! size_change_ok) + if (h->size != 0 && h->size != isym->st_size && ! size_change_ok) (*_bfd_error_handler) (_("Warning: size of symbol `%s' changed from %lu to %lu in %s"), - name, (unsigned long) h->size, (unsigned long) sym.st_size, - bfd_archive_filename (abfd)); + name, (unsigned long) h->size, + (unsigned long) isym->st_size, bfd_archive_filename (abfd)); - h->size = sym.st_size; + h->size = isym->st_size; } /* If this is a common symbol, then we always want H->SIZE @@ -1955,37 +1908,37 @@ elf_link_add_object_symbols (abfd, info) if (h->root.type == bfd_link_hash_common) h->size = h->root.u.c.size; - if (ELF_ST_TYPE (sym.st_info) != STT_NOTYPE + if (ELF_ST_TYPE (isym->st_info) != STT_NOTYPE && (definition || h->type == STT_NOTYPE)) { if (h->type != STT_NOTYPE - && h->type != ELF_ST_TYPE (sym.st_info) + && h->type != ELF_ST_TYPE (isym->st_info) && ! type_change_ok) (*_bfd_error_handler) (_("Warning: type of symbol `%s' changed from %d to %d in %s"), - name, h->type, ELF_ST_TYPE (sym.st_info), + name, h->type, ELF_ST_TYPE (isym->st_info), bfd_archive_filename (abfd)); - h->type = ELF_ST_TYPE (sym.st_info); + h->type = ELF_ST_TYPE (isym->st_info); } /* If st_other has a processor-specific meaning, specific code might be needed here. */ - if (sym.st_other != 0) + if (isym->st_other != 0) { /* Combine visibilities, using the most constraining one. */ unsigned char hvis = ELF_ST_VISIBILITY (h->other); - unsigned char symvis = ELF_ST_VISIBILITY (sym.st_other); + unsigned char symvis = ELF_ST_VISIBILITY (isym->st_other); if (symvis && (hvis > symvis || hvis == 0)) - h->other = sym.st_other; + h->other = isym->st_other; /* If neither has visibility, use the st_other of the definition. This is an arbitrary choice, since the other bits have no general meaning. */ if (!symvis && !hvis && (definition || h->other == 0)) - h->other = sym.st_other; + h->other = isym->st_other; } /* Set a flag in the hash table entry indicating the type of @@ -2029,21 +1982,21 @@ elf_link_add_object_symbols (abfd, info) /* Check to see if we need to add an indirect symbol for the default name. */ if (definition || h->root.type == bfd_link_hash_common) - if (! elf_add_default_symbol (abfd, info, h, name, &sym, + if (! elf_add_default_symbol (abfd, info, h, name, isym, &sec, &value, &dynsym, override, dt_needed)) - goto error_return; + goto error_free_vers; if (dynsym && h->dynindx == -1) { if (! _bfd_elf_link_record_dynamic_symbol (info, h)) - goto error_return; + goto error_free_vers; if (h->weakdef != NULL && ! new_weakdef && h->weakdef->dynindx == -1) { if (! _bfd_elf_link_record_dynamic_symbol (info, h->weakdef)) - goto error_return; + goto error_free_vers; } } else if (dynsym && h->dynindx != -1) @@ -2066,7 +2019,7 @@ elf_link_add_object_symbols (abfd, info) bfd_size_type strindex; if (! is_elf_hash_table (info)) - goto error_return; + goto error_free_vers; /* The symbol from a DT_NEEDED object is referenced from the regular object to create a dynamic executable. We @@ -2077,7 +2030,7 @@ elf_link_add_object_symbols (abfd, info) strindex = _bfd_elf_strtab_add (hash_table->dynstr, elf_dt_soname (abfd), false); if (strindex == (bfd_size_type) -1) - goto error_return; + goto error_free_vers; if (oldsize == _bfd_elf_strtab_size (hash_table->dynstr)) { @@ -2103,11 +2056,21 @@ elf_link_add_object_symbols (abfd, info) } if (! elf_add_dynamic_entry (info, (bfd_vma) DT_NEEDED, strindex)) - goto error_return; + goto error_free_vers; } } } + if (extversym != NULL) + { + free (extversym); + extversym = NULL; + } + + if (isymbuf != NULL) + free (isymbuf); + isymbuf = NULL; + /* Now set the weakdefs field correctly for all the weak defined symbols we found. The only way to do this is to search all the symbols. Since we only need the information for non functions in @@ -2175,24 +2138,11 @@ elf_link_add_object_symbols (abfd, info) if (! _bfd_elf_link_record_dynamic_symbol (info, hlook)) goto error_return; } - break; } } } - if (buf != NULL) - { - free (buf); - buf = NULL; - } - - if (extversym != NULL) - { - free (extversym); - extversym = NULL; - } - /* If this object is the same format as the output object, and it is not a shared library, then let the backend look through the relocs. @@ -2238,7 +2188,7 @@ elf_link_add_object_symbols (abfd, info) ok = (*check_relocs) (abfd, info, o, internal_relocs); - if (! info->keep_memory) + if (elf_section_data (o)->relocs != internal_relocs) free (internal_relocs); if (! ok) @@ -2258,7 +2208,9 @@ elf_link_add_object_symbols (abfd, info) asection *stab, *stabstr; stab = bfd_get_section_by_name (abfd, ".stab"); - if (stab != NULL && !(stab->flags & SEC_MERGE)) + if (stab != NULL + && (stab->flags & SEC_MERGE) == 0 + && !bfd_is_abs_section (stab->output_section)) { stabstr = bfd_get_section_by_name (abfd, ".stabstr"); @@ -2284,7 +2236,8 @@ elf_link_add_object_symbols (abfd, info) asection *s; for (s = abfd->sections; s != NULL; s = s->next) - if (s->flags & SEC_MERGE) + if ((s->flags & SEC_MERGE) != 0 + && !bfd_is_abs_section (s->output_section)) { struct bfd_elf_section_data *secdata; @@ -2298,15 +2251,29 @@ elf_link_add_object_symbols (abfd, info) } } + if (is_elf_hash_table (info)) + { + /* Add this bfd to the loaded list. */ + struct elf_link_loaded_list *n; + + n = ((struct elf_link_loaded_list *) + bfd_alloc (abfd, sizeof (struct elf_link_loaded_list))); + if (n == NULL) + goto error_return; + n->abfd = abfd; + n->next = hash_table->loaded; + hash_table->loaded = n; + } + return true; - error_return: - if (buf != NULL) - free (buf); - if (dynbuf != NULL) - free (dynbuf); + error_free_vers: if (extversym != NULL) free (extversym); + error_free_sym: + if (isymbuf != NULL) + free (isymbuf); + error_return: return false; } @@ -2487,92 +2454,6 @@ elf_add_dynamic_entry (info, tag, val) return true; } - -/* Record a new local dynamic symbol. */ - -boolean -elf_link_record_local_dynamic_symbol (info, input_bfd, input_indx) - struct bfd_link_info *info; - bfd *input_bfd; - long input_indx; -{ - struct elf_link_local_dynamic_entry *entry; - struct elf_link_hash_table *eht; - struct elf_strtab_hash *dynstr; - Elf_External_Sym esym; - Elf_External_Sym_Shndx eshndx; - Elf_External_Sym_Shndx *shndx; - unsigned long dynstr_index; - char *name; - file_ptr pos; - bfd_size_type amt; - - if (! is_elf_hash_table (info)) - return false; - - /* See if the entry exists already. */ - for (entry = elf_hash_table (info)->dynlocal; entry ; entry = entry->next) - if (entry->input_bfd == input_bfd && entry->input_indx == input_indx) - return true; - - entry = (struct elf_link_local_dynamic_entry *) - bfd_alloc (input_bfd, (bfd_size_type) sizeof (*entry)); - if (entry == NULL) - return false; - - /* Go find the symbol, so that we can find it's name. */ - amt = sizeof (Elf_External_Sym); - pos = elf_tdata (input_bfd)->symtab_hdr.sh_offset + input_indx * amt; - if (bfd_seek (input_bfd, pos, SEEK_SET) != 0 - || bfd_bread ((PTR) &esym, amt, input_bfd) != amt) - return false; - shndx = NULL; - if (elf_tdata (input_bfd)->symtab_shndx_hdr.sh_size != 0) - { - amt = sizeof (Elf_External_Sym_Shndx); - pos = elf_tdata (input_bfd)->symtab_shndx_hdr.sh_offset; - pos += input_indx * amt; - shndx = &eshndx; - if (bfd_seek (input_bfd, pos, SEEK_SET) != 0 - || bfd_bread ((PTR) shndx, amt, input_bfd) != amt) - return false; - } - elf_swap_symbol_in (input_bfd, &esym, shndx, &entry->isym); - - name = (bfd_elf_string_from_elf_section - (input_bfd, elf_tdata (input_bfd)->symtab_hdr.sh_link, - entry->isym.st_name)); - - dynstr = elf_hash_table (info)->dynstr; - if (dynstr == NULL) - { - /* Create a strtab to hold the dynamic symbol names. */ - elf_hash_table (info)->dynstr = dynstr = _bfd_elf_strtab_init (); - if (dynstr == NULL) - return false; - } - - dynstr_index = _bfd_elf_strtab_add (dynstr, name, false); - if (dynstr_index == (unsigned long) -1) - return false; - entry->isym.st_name = dynstr_index; - - eht = elf_hash_table (info); - - entry->next = eht->dynlocal; - eht->dynlocal = entry; - entry->input_bfd = input_bfd; - entry->input_indx = input_indx; - eht->dynsymcount++; - - /* Whatever binding the symbol had before, it's now local. */ - entry->isym.st_info - = ELF_ST_INFO (STB_LOCAL, ELF_ST_TYPE (entry->isym.st_info)); - - /* The dynindx will be set at the end of size_dynamic_sections. */ - - return true; -} /* Read and swap the relocs from the section indicated by SHDR. This may be either a REL or a RELA section. The relocations are @@ -2890,11 +2771,11 @@ compute_bucket_count (info) elf_link_hash_traverse (elf_hash_table (info), elf_collect_hash_codes, &hashcodesp); -/* We have a problem here. The following code to optimize the table - size requires an integer type with more the 32 bits. If - BFD_HOST_U_64_BIT is set we know about such a type. */ + /* We have a problem here. The following code to optimize the table + size requires an integer type with more the 32 bits. If + BFD_HOST_U_64_BIT is set we know about such a type. */ #ifdef BFD_HOST_U_64_BIT - if (info->optimize == true) + if (info->optimize) { unsigned long int nsyms = hashcodesp - hashcodes; size_t minsize; @@ -3035,7 +2916,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, return true; if (! is_elf_hash_table (info)) - return false; + return true; /* Any syms created from now on start with -1 in got.refcount/offset and plt.refcount/offset. */ @@ -3063,6 +2944,9 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, struct elf_info_failed eif; struct elf_link_hash_entry *h; asection *dynstr; + struct bfd_elf_version_tree *t; + struct bfd_elf_version_expr *d; + boolean all_defined; *sinterpptr = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (*sinterpptr != NULL || info->shared); @@ -3143,6 +3027,57 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, return false; } + /* Make all global versions with definiton. */ + for (t = verdefs; t != NULL; t = t->next) + for (d = t->globals; d != NULL; d = d->next) + if (!d->symver && strchr (d->pattern, '*') == NULL) + { + const char *verstr, *name; + size_t namelen, verlen, newlen; + char *newname, *p; + struct elf_link_hash_entry *newh; + + name = d->pattern; + namelen = strlen (name); + verstr = t->name; + verlen = strlen (verstr); + newlen = namelen + verlen + 3; + + newname = (char *) bfd_malloc ((bfd_size_type) newlen); + if (newname == NULL) + return false; + memcpy (newname, name, namelen); + + /* Check the hidden versioned definition. */ + p = newname + namelen; + *p++ = ELF_VER_CHR; + memcpy (p, verstr, verlen + 1); + newh = elf_link_hash_lookup (elf_hash_table (info), + newname, false, false, + false); + if (newh == NULL + || (newh->root.type != bfd_link_hash_defined + && newh->root.type != bfd_link_hash_defweak)) + { + /* Check the default versioned definition. */ + *p++ = ELF_VER_CHR; + memcpy (p, verstr, verlen + 1); + newh = elf_link_hash_lookup (elf_hash_table (info), + newname, false, false, + false); + } + free (newname); + + /* Mark this version if there is a definition and it is + not defined in a shared object. */ + if (newh != NULL + && ((newh->elf_link_hash_flags + & ELF_LINK_HASH_DEF_DYNAMIC) == 0) + && (newh->root.type == bfd_link_hash_defined + || newh->root.type == bfd_link_hash_defweak)) + d->symver = 1; + } + /* Attach all the symbols to their version information. */ asvinfo.output_bfd = output_bfd; asvinfo.info = info; @@ -3155,6 +3090,28 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, if (asvinfo.failed) return false; + if (!info->allow_undefined_version) + { + /* Check if all global versions have a definiton. */ + all_defined = true; + for (t = verdefs; t != NULL; t = t->next) + for (d = t->globals; d != NULL; d = d->next) + if (!d->symver && !d->script + && strchr (d->pattern, '*') == NULL) + { + (*_bfd_error_handler) + (_("%s: undefined version: %s"), + d->pattern, t->name); + all_defined = false; + } + + if (!all_defined) + { + bfd_set_error (bfd_error_bad_value); + return false; + } + } + /* Find all symbols which were defined in a dynamic object and make the backend pick a reasonable value for them. */ elf_link_hash_traverse (elf_hash_table (info), @@ -3210,7 +3167,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, { (*_bfd_error_handler) (_("%s: .preinit_array section is not allowed in DSO"), - bfd_archive_filename (sub)); + bfd_archive_filename (sub)); break; } @@ -3454,7 +3411,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, elf_tdata (output_bfd)->cverdefs = cdefs; } - if (info->new_dtags && info->flags) + if ((info->new_dtags && info->flags) || (info->flags & DF_STATIC_TLS)) { if (! elf_add_dynamic_entry (info, (bfd_vma) DT_FLAGS, info->flags)) return false; @@ -3645,10 +3602,9 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, BFD_ASSERT (s != NULL); hash_entry_size = elf_section_data (s)->this_hdr.sh_entsize; s->_raw_size = ((2 + bucketcount + dynsymcount) * hash_entry_size); - s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size); + s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size); if (s->contents == NULL) return false; - memset (s->contents, 0, (size_t) s->_raw_size); bfd_put (8 * hash_entry_size, output_bfd, (bfd_vma) bucketcount, s->contents); @@ -3947,7 +3903,7 @@ elf_fix_symbol_flags (h, eif) struct elf_backend_data *bed; bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj); - (*bed->elf_backend_copy_indirect_symbol) (weakdef, h); + (*bed->elf_backend_copy_indirect_symbol) (bed, weakdef, h); } } @@ -4067,7 +4023,7 @@ elf_adjust_dynamic_symbol (h, data) && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) == 0) (*_bfd_error_handler) (_("warning: type and size of dynamic symbol `%s' are not defined"), - h->root.root.string); + h->root.root.string); dynobj = elf_hash_table (eif->info)->dynobj; bed = get_elf_backend_data (dynobj); @@ -4127,7 +4083,7 @@ elf_export_symbol (h, data) if (!eif->verdefs) { -doit: + doit: if (! _bfd_elf_link_record_dynamic_symbol (eif->info, h)) { eif->failed = true; @@ -4294,7 +4250,7 @@ elf_link_assign_sym_version (h, data) alc = bfd_malloc ((bfd_size_type) len); if (alc == NULL) return false; - strncpy (alc, h->root.root.string, len - 1); + memcpy (alc, h->root.root.string, len - 1); alc[len - 1] = '\0'; if (alc[len - 2] == ELF_VER_CHR) alc[len - 2] = '\0'; @@ -4397,45 +4353,58 @@ elf_link_assign_sym_version (h, data) if (h->verinfo.vertree == NULL && sinfo->verdefs != NULL) { struct bfd_elf_version_tree *t; - struct bfd_elf_version_tree *deflt; + struct bfd_elf_version_tree *local_ver; struct bfd_elf_version_expr *d; /* See if can find what version this symbol is in. If the symbol is supposed to be local, then don't actually register it. */ - deflt = NULL; + local_ver = NULL; for (t = sinfo->verdefs; t != NULL; t = t->next) { if (t->globals != NULL) { + boolean matched; + + matched = false; for (d = t->globals; d != NULL; d = d->next) { if ((*d->match) (d, h->root.root.string)) { - h->verinfo.vertree = t; - break; + if (d->symver) + matched = true; + else + { + /* There is a version without definition. Make + the symbol the default definition for this + version. */ + h->verinfo.vertree = t; + local_ver = NULL; + d->script = 1; + break; + } } } if (d != NULL) break; + else if (matched) + /* There is no undefined version for this symbol. Hide the + default one. */ + (*bed->elf_backend_hide_symbol) (info, h, true); } if (t->locals != NULL) { for (d = t->locals; d != NULL; d = d->next) { + /* If the match is "*", keep looking for a more + explicit, perhaps even global, match. */ if (d->pattern[0] == '*' && d->pattern[1] == '\0') - deflt = t; + local_ver = t; else if ((*d->match) (d, h->root.root.string)) { - h->verinfo.vertree = t; - if (h->dynindx != -1 - && info->shared - && ! info->export_dynamic) - { - (*bed->elf_backend_hide_symbol) (info, h, true); - } + local_ver = t; break; } } @@ -4445,9 +4414,9 @@ elf_link_assign_sym_version (h, data) } } - if (deflt != NULL && h->verinfo.vertree == NULL) + if (local_ver != NULL) { - h->verinfo.vertree = deflt; + h->verinfo.vertree = local_ver; if (h->dynindx != -1 && info->shared && ! info->export_dynamic) @@ -4478,6 +4447,8 @@ struct elf_final_link_info asection *hash_sec; /* symbol version section (.gnu.version). */ asection *symver_sec; + /* first SHF_TLS section (if any). */ + asection *first_tls_sec; /* Buffer large enough to hold contents of any section. */ bfd_byte *contents; /* Buffer large enough to hold external relocs of any section. */ @@ -4517,6 +4488,8 @@ static boolean elf_link_output_extsym PARAMS ((struct elf_link_hash_entry *, PTR)); static boolean elf_link_sec_merge_syms PARAMS ((struct elf_link_hash_entry *, PTR)); +static boolean elf_link_check_versioned_symbol + PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); static boolean elf_link_input_bfd PARAMS ((struct elf_final_link_info *, bfd *)); static boolean elf_reloc_link_order @@ -4660,7 +4633,7 @@ elf_link_adjust_relocs (abfd, rel_hdr, count, rel_hash) for (j = 0; j < bed->s->int_rels_per_ext_rel; j++) irela[j].r_info = ELF_R_INFO ((*rel_hash)->indx, - ELF_R_TYPE (irela[j].r_info)); + ELF_R_TYPE (irela[j].r_info)); if (bed->s->swap_reloca_out) (*bed->s->swap_reloca_out) (abfd, irela, (bfd_byte *) erela); @@ -4673,10 +4646,12 @@ elf_link_adjust_relocs (abfd, rel_hdr, count, rel_hash) free (irela); } -struct elf_link_sort_rela { +struct elf_link_sort_rela +{ bfd_vma offset; enum elf_reloc_type_class type; - union { + union + { Elf_Internal_Rel rel; Elf_Internal_Rela rela; } u; @@ -4957,6 +4932,14 @@ elf_bfd_final_link (abfd, info) finfo.symbuf = NULL; finfo.symshndxbuf = NULL; finfo.symbuf_count = 0; + finfo.first_tls_sec = NULL; + for (o = abfd->sections; o != (asection *) NULL; o = o->next) + if ((o->flags & SEC_THREAD_LOCAL) != 0 + && (o->flags & SEC_LOAD) != 0) + { + finfo.first_tls_sec = o; + break; + } /* Count up the number of relocations we will output for each output section, so that we know the sizes of the reloc sections. We @@ -5004,7 +4987,7 @@ elf_bfd_final_link (abfd, info) o->reloc_count += (*bed->elf_backend_count_relocs) (sec, relocs); - if (!info->keep_memory) + if (elf_section_data (o)->relocs != relocs) free (relocs); } @@ -5321,6 +5304,40 @@ elf_bfd_final_link (abfd, info) goto error_return; } + if (finfo.first_tls_sec) + { + unsigned int align = 0; + bfd_vma base = finfo.first_tls_sec->vma, end = 0; + asection *sec; + + for (sec = finfo.first_tls_sec; + sec && (sec->flags & SEC_THREAD_LOCAL); + sec = sec->next) + { + bfd_vma size = sec->_raw_size; + + if (bfd_get_section_alignment (abfd, sec) > align) + align = bfd_get_section_alignment (abfd, sec); + if (sec->_raw_size == 0 && (sec->flags & SEC_HAS_CONTENTS) == 0) + { + struct bfd_link_order *o; + + size = 0; + for (o = sec->link_order_head; o != NULL; o = o->next) + if (size < o->offset + o->size) + size = o->offset + o->size; + } + end = sec->vma + size; + } + elf_hash_table (info)->tls_segment + = bfd_zalloc (abfd, sizeof (struct elf_link_tls_segment)); + if (elf_hash_table (info)->tls_segment == NULL) + goto error_return; + elf_hash_table (info)->tls_segment->start = base; + elf_hash_table (info)->tls_segment->size = end - base; + elf_hash_table (info)->tls_segment->align = align; + } + /* Since ELF permits relocations to be against local symbols, we must have the local symbols available when we do the relocations. Since we would rather only read the local symbols once, and we @@ -5447,8 +5464,8 @@ elf_bfd_final_link (abfd, info) sym = e->isym; if (e->isym.st_shndx != SHN_UNDEF - && (e->isym.st_shndx < SHN_LORESERVE - || e->isym.st_shndx > SHN_HIRESERVE)) + && (e->isym.st_shndx < SHN_LORESERVE + || e->isym.st_shndx > SHN_HIRESERVE)) { s = bfd_section_from_elf_index (e->input_bfd, e->isym.st_shndx); @@ -5631,7 +5648,13 @@ elf_bfd_final_link (abfd, info) name = ".fini_array"; get_size: o = bfd_get_section_by_name (abfd, name); - BFD_ASSERT (o != NULL); + if (o == NULL) + { + (*_bfd_error_handler) + (_("%s: could not find output section %s"), + bfd_get_filename (abfd), name); + goto error_return; + } if (o->_raw_size == 0) (*_bfd_error_handler) (_("warning: %s section has zero size"), name); @@ -5668,7 +5691,13 @@ elf_bfd_final_link (abfd, info) name = ".gnu.version"; get_vma: o = bfd_get_section_by_name (abfd, name); - BFD_ASSERT (o != NULL); + if (o == NULL) + { + (*_bfd_error_handler) + (_("%s: could not find output section %s"), + bfd_get_filename (abfd), name); + goto error_return; + } dyn.d_un.d_ptr = o->vma; elf_swap_dyn_out (dynobj, &dyn, dyncon); break; @@ -5747,6 +5776,15 @@ elf_bfd_final_link (abfd, info) } } + if (info->relocateable) + { + boolean failed = false; + + bfd_map_over_sections (abfd, bfd_elf_set_group_contents, &failed); + if (failed) + goto error_return; + } + /* If we have optimized stabs strings, output them. */ if (elf_hash_table (info)->stab_info != NULL) { @@ -5960,6 +5998,127 @@ elf_link_sec_merge_syms (h, data) return true; } +/* For DSOs loaded in via a DT_NEEDED entry, emulate ld.so in + allowing an unsatisfied unversioned symbol in the DSO to match a + versioned symbol that would normally require an explicit version. */ + +static boolean +elf_link_check_versioned_symbol (info, h) + struct bfd_link_info *info; + struct elf_link_hash_entry *h; +{ + bfd *undef_bfd = h->root.u.undef.abfd; + struct elf_link_loaded_list *loaded; + + if ((undef_bfd->flags & DYNAMIC) == 0 + || info->hash->creator->flavour != bfd_target_elf_flavour + || elf_dt_soname (h->root.u.undef.abfd) == NULL) + return false; + + for (loaded = elf_hash_table (info)->loaded; + loaded != NULL; + loaded = loaded->next) + { + bfd *input; + Elf_Internal_Shdr *hdr; + bfd_size_type symcount; + bfd_size_type extsymcount; + bfd_size_type extsymoff; + Elf_Internal_Shdr *versymhdr; + Elf_Internal_Sym *isym; + Elf_Internal_Sym *isymend; + Elf_Internal_Sym *isymbuf; + Elf_External_Versym *ever; + Elf_External_Versym *extversym; + + input = loaded->abfd; + + /* We check each DSO for a possible hidden versioned definition. */ + if (input == undef_bfd + || (input->flags & DYNAMIC) == 0 + || elf_dynversym (input) == 0) + continue; + + hdr = &elf_tdata (input)->dynsymtab_hdr; + + symcount = hdr->sh_size / sizeof (Elf_External_Sym); + if (elf_bad_symtab (input)) + { + extsymcount = symcount; + extsymoff = 0; + } + else + { + extsymcount = symcount - hdr->sh_info; + extsymoff = hdr->sh_info; + } + + if (extsymcount == 0) + continue; + + isymbuf = bfd_elf_get_elf_syms (input, hdr, extsymcount, extsymoff, + NULL, NULL, NULL); + if (isymbuf == NULL) + return false; + + /* Read in any version definitions. */ + versymhdr = &elf_tdata (input)->dynversym_hdr; + extversym = (Elf_External_Versym *) bfd_malloc (versymhdr->sh_size); + if (extversym == NULL) + goto error_ret; + + if (bfd_seek (input, versymhdr->sh_offset, SEEK_SET) != 0 + || (bfd_bread ((PTR) extversym, versymhdr->sh_size, input) + != versymhdr->sh_size)) + { + free (extversym); + error_ret: + free (isymbuf); + return false; + } + + ever = extversym + extsymoff; + isymend = isymbuf + extsymcount; + for (isym = isymbuf; isym < isymend; isym++, ever++) + { + const char *name; + Elf_Internal_Versym iver; + + if (ELF_ST_BIND (isym->st_info) == STB_LOCAL + || isym->st_shndx == SHN_UNDEF) + continue; + + name = bfd_elf_string_from_elf_section (input, + hdr->sh_link, + isym->st_name); + if (strcmp (name, h->root.root.string) != 0) + continue; + + _bfd_elf_swap_versym_in (input, ever, &iver); + + if ((iver.vs_vers & VERSYM_HIDDEN) == 0) + { + /* If we have a non-hidden versioned sym, then it should + have provided a definition for the undefined sym. */ + abort (); + } + + if ((iver.vs_vers & VERSYM_VERSION) == 2) + { + /* This is the oldest (default) sym. We can use it. */ + free (extversym); + free (isymbuf); + return true; + } + } + + free (extversym); + free (isymbuf); + } + + return false; +} + /* Add an external symbol to the symbol table. This is called from the hash table traversal routine. When generating a shared object, we go through the symbol table twice. The first time we output @@ -6009,7 +6168,8 @@ elf_link_output_extsym (h, data) && ! finfo->info->shared && h->root.type == bfd_link_hash_undefined && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0 - && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0) + && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0 + && ! elf_link_check_versioned_symbol (finfo->info, h)) { if (! ((*finfo->info->callbacks->undefined_symbol) (finfo->info, h->root.root.string, h->root.u.undef.abfd, @@ -6097,7 +6257,16 @@ elf_link_output_extsym (h, data) addresses. */ sym.st_value = h->root.u.def.value + input_sec->output_offset; if (! finfo->info->relocateable) - sym.st_value += input_sec->output_section->vma; + { + sym.st_value += input_sec->output_section->vma; + if (h->type == STT_TLS) + { + /* STT_TLS symbols are relative to PT_TLS segment + base. */ + BFD_ASSERT (finfo->first_tls_sec != NULL); + sym.st_value -= finfo->first_tls_sec->vma; + } + } } else { @@ -6173,8 +6342,8 @@ elf_link_output_extsym (h, data) sym.st_other ^= ELF_ST_VISIBILITY (sym.st_other); /* If this symbol should be put in the .dynsym section, then put it - there now. We have already know the symbol index. We also fill - in the entry in the .hash section. */ + there now. We already know the symbol index. We also fill in + the entry in the .hash section. */ if (h->dynindx != -1 && elf_hash_table (finfo->info)->dynamic_sections_created) { @@ -6233,7 +6402,7 @@ elf_link_output_extsym (h, data) /* If we're stripping it, then it was just a dynamic symbol, and there's nothing else to do. */ - if (strip) + if (strip || (input_sec->flags & SEC_EXCLUDE) != 0) return true; h->indx = bfd_get_symcount (finfo->output_bfd); @@ -6251,7 +6420,7 @@ elf_link_output_extsym (h, data) originated from the section given by INPUT_REL_HDR) to the OUTPUT_BFD. */ -static void +static boolean elf_link_output_relocs (output_bfd, input_section, input_rel_hdr, internal_relocs) bfd *output_bfd; @@ -6283,13 +6452,21 @@ elf_link_output_relocs (output_bfd, input_section, input_rel_hdr, output_rel_hdr = elf_section_data (output_section)->rel_hdr2; rel_countp = &elf_section_data (output_section)->rel_count2; } - - BFD_ASSERT (output_rel_hdr != NULL); + else + { + (*_bfd_error_handler) + (_("%s: relocation size mismatch in %s section %s"), + bfd_get_filename (output_bfd), + bfd_archive_filename (input_section->owner), + input_section->name); + bfd_set_error (bfd_error_wrong_object_format); + return false; + } bed = get_elf_backend_data (output_bfd); irela = internal_relocs; - irelaend = irela + NUM_SHDR_ENTRIES (input_rel_hdr) - * bed->s->int_rels_per_ext_rel; + irelaend = irela + (NUM_SHDR_ENTRIES (input_rel_hdr) + * bed->s->int_rels_per_ext_rel); if (input_rel_hdr->sh_entsize == sizeof (Elf_External_Rel)) { @@ -6341,6 +6518,8 @@ elf_link_output_relocs (output_bfd, input_section, input_rel_hdr, /* Bump the counter, so that we know where to add the next set of relocations. */ *rel_countp += NUM_SHDR_ENTRIES (input_rel_hdr); + + return true; } /* Link an input file into the linker output file. This function @@ -6359,15 +6538,11 @@ elf_link_input_bfd (finfo, input_bfd) Elf_Internal_Sym *, asection **)); bfd *output_bfd; Elf_Internal_Shdr *symtab_hdr; - Elf_Internal_Shdr *shndx_hdr; size_t locsymcount; size_t extsymoff; - Elf_External_Sym *external_syms; - Elf_External_Sym *esym; - Elf_External_Sym *esymend; - Elf_External_Sym_Shndx *shndx_buf; - Elf_External_Sym_Shndx *shndx; + Elf_Internal_Sym *isymbuf; Elf_Internal_Sym *isym; + Elf_Internal_Sym *isymend; long *pindex; asection **ppsection; asection *o; @@ -6402,44 +6577,29 @@ elf_link_input_bfd (finfo, input_bfd) } /* Read the local symbols. */ - if (symtab_hdr->contents != NULL) - external_syms = (Elf_External_Sym *) symtab_hdr->contents; - else if (locsymcount == 0) - external_syms = NULL; - else - { - bfd_size_type amt = locsymcount * sizeof (Elf_External_Sym); - external_syms = finfo->external_syms; - if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread (external_syms, amt, input_bfd) != amt) + isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents; + if (isymbuf == NULL && locsymcount != 0) + { + isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr, locsymcount, 0, + finfo->internal_syms, + finfo->external_syms, + finfo->locsym_shndx); + if (isymbuf == NULL) return false; } - shndx_hdr = &elf_tdata (input_bfd)->symtab_shndx_hdr; - shndx_buf = NULL; - if (shndx_hdr->sh_size != 0 && locsymcount != 0) - { - bfd_size_type amt = locsymcount * sizeof (Elf_External_Sym_Shndx); - shndx_buf = finfo->locsym_shndx; - if (bfd_seek (input_bfd, shndx_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread (shndx_buf, amt, input_bfd) != amt) - return false; - } - - /* Swap in the local symbols and write out the ones which we know - are going into the output file. */ - for (esym = external_syms, esymend = esym + locsymcount, - isym = finfo->internal_syms, pindex = finfo->indices, - ppsection = finfo->sections, shndx = shndx_buf; - esym < esymend; - esym++, isym++, pindex++, ppsection++, - shndx = (shndx != NULL ? shndx + 1 : NULL)) + /* Find local symbol sections and adjust values of symbols in + SEC_MERGE sections. Write out those local symbols we know are + going into the output file. */ + isymend = isymbuf + locsymcount; + for (isym = isymbuf, pindex = finfo->indices, ppsection = finfo->sections; + isym < isymend; + isym++, pindex++, ppsection++) { asection *isec; const char *name; Elf_Internal_Sym osym; - elf_swap_symbol_in (input_bfd, esym, shndx, isym); *pindex = -1; if (elf_bad_symtab (input_bfd)) @@ -6478,7 +6638,7 @@ elf_link_input_bfd (finfo, input_bfd) *ppsection = isec; /* Don't output the first, undefined, symbol. */ - if (esym == external_syms) + if (ppsection == finfo->sections) continue; if (ELF_ST_TYPE (isym->st_info) == STT_SECTION) @@ -6551,7 +6711,15 @@ elf_link_input_bfd (finfo, input_bfd) these requirements. */ osym.st_value += isec->output_offset; if (! finfo->info->relocateable) - osym.st_value += isec->output_section->vma; + { + osym.st_value += isec->output_section->vma; + if (ELF_ST_TYPE (osym.st_info) == STT_TLS) + { + /* STT_TLS symbols are relative to PT_TLS segment base. */ + BFD_ASSERT (finfo->first_tls_sec != NULL); + osym.st_value -= finfo->first_tls_sec->vma; + } + } if (! elf_link_output_sym (finfo, name, &osym, isec)) return false; @@ -6644,20 +6812,12 @@ elf_link_input_bfd (finfo, input_bfd) || h->root.type == bfd_link_hash_defweak) && elf_discarded_section (h->root.u.def.section)) { -#if BFD_VERSION_DATE < 20031005 if ((o->flags & SEC_DEBUGGING) != 0) { -#if BFD_VERSION_DATE > 20021005 - (*finfo->info->callbacks->warning) - (finfo->info, - _("warning: relocation against removed section; zeroing"), - NULL, input_bfd, o, rel->r_offset); -#endif BFD_ASSERT (r_symndx != 0); memset (rel, 0, sizeof (*rel)); } else -#endif { if (! ((*finfo->info->callbacks->undefined_symbol) (finfo->info, h->root.root.string, @@ -6673,23 +6833,15 @@ elf_link_input_bfd (finfo, input_bfd) if (sec != NULL && elf_discarded_section (sec)) { -#if BFD_VERSION_DATE < 20031005 if ((o->flags & SEC_DEBUGGING) != 0 || (sec->flags & SEC_LINK_ONCE) != 0) { -#if BFD_VERSION_DATE > 20021005 - (*finfo->info->callbacks->warning) - (finfo->info, - _("warning: relocation against removed section"), - NULL, input_bfd, o, rel->r_offset); -#endif BFD_ASSERT (r_symndx != 0); rel->r_info = ELF_R_INFO (0, ELF_R_TYPE (rel->r_info)); rel->r_addend = 0; } else -#endif { boolean ok; const char *msg @@ -6740,7 +6892,7 @@ elf_link_input_bfd (finfo, input_bfd) if (! (*relocate_section) (output_bfd, finfo->info, input_bfd, o, contents, internal_relocs, - finfo->internal_syms, + isymbuf, finfo->sections)) return false; @@ -6749,11 +6901,11 @@ elf_link_input_bfd (finfo, input_bfd) Elf_Internal_Rela *irela; Elf_Internal_Rela *irelaend; struct elf_link_hash_entry **rel_hash; - Elf_Internal_Shdr *input_rel_hdr; + Elf_Internal_Shdr *input_rel_hdr, *input_rel_hdr2; unsigned int next_erel; - void (*reloc_emitter) PARAMS ((bfd *, asection *, - Elf_Internal_Shdr *, - Elf_Internal_Rela *)); + boolean (*reloc_emitter) PARAMS ((bfd *, asection *, + Elf_Internal_Shdr *, + Elf_Internal_Rela *)); boolean rela_normal; input_rel_hdr = &elf_section_data (o)->rel_hdr; @@ -6772,6 +6924,7 @@ elf_link_input_bfd (finfo, input_bfd) { unsigned long r_symndx; asection *sec; + Elf_Internal_Sym sym; if (next_erel == bed->s->int_rels_per_ext_rel) { @@ -6824,9 +6977,9 @@ elf_link_input_bfd (finfo, input_bfd) /* This is a reloc against a local symbol. */ *rel_hash = NULL; - isym = finfo->internal_syms + r_symndx; + sym = isymbuf[r_symndx]; sec = finfo->sections[r_symndx]; - if (ELF_ST_TYPE (isym->st_info) == STT_SECTION) + if (ELF_ST_TYPE (sym.st_info) == STT_SECTION) { /* I suppose the backend ought to fill in the section of any STT_SECTION symbol against a @@ -6849,7 +7002,7 @@ elf_link_input_bfd (finfo, input_bfd) } /* Adjust the addend according to where the - section winds up in the output section. */ + section winds up in the output section. */ if (rela_normal) irela->r_addend += sec->output_offset; } @@ -6873,25 +7026,34 @@ elf_link_input_bfd (finfo, input_bfd) must output it now. */ shlink = symtab_hdr->sh_link; name = (bfd_elf_string_from_elf_section - (input_bfd, shlink, isym->st_name)); + (input_bfd, shlink, sym.st_name)); if (name == NULL) return false; osec = sec->output_section; - isym->st_shndx = + sym.st_shndx = _bfd_elf_section_from_bfd_section (output_bfd, osec); - if (isym->st_shndx == SHN_BAD) + if (sym.st_shndx == SHN_BAD) return false; - isym->st_value += sec->output_offset; + sym.st_value += sec->output_offset; if (! finfo->info->relocateable) - isym->st_value += osec->vma; + { + sym.st_value += osec->vma; + if (ELF_ST_TYPE (sym.st_info) == STT_TLS) + { + /* STT_TLS symbols are relative to PT_TLS + segment base. */ + BFD_ASSERT (finfo->first_tls_sec != NULL); + sym.st_value -= finfo->first_tls_sec->vma; + } + } finfo->indices[r_symndx] = bfd_get_symcount (output_bfd); - if (! elf_link_output_sym (finfo, name, isym, sec)) + if (! elf_link_output_sym (finfo, name, &sym, sec)) return false; } @@ -6910,17 +7072,20 @@ elf_link_input_bfd (finfo, input_bfd) else reloc_emitter = elf_link_output_relocs; - (*reloc_emitter) (output_bfd, o, input_rel_hdr, internal_relocs); + if (input_rel_hdr->sh_size != 0 + && ! (*reloc_emitter) (output_bfd, o, input_rel_hdr, + internal_relocs)) + return false; - input_rel_hdr = elf_section_data (o)->rel_hdr2; - if (input_rel_hdr) + input_rel_hdr2 = elf_section_data (o)->rel_hdr2; + if (input_rel_hdr2 && input_rel_hdr2->sh_size != 0) { internal_relocs += (NUM_SHDR_ENTRIES (input_rel_hdr) * bed->s->int_rels_per_ext_rel); - (*reloc_emitter) (output_bfd, o, input_rel_hdr, - internal_relocs); + if (! (*reloc_emitter) (output_bfd, o, input_rel_hdr2, + internal_relocs)) + return false; } - } } @@ -7437,28 +7602,27 @@ elf_finish_pointer_linker_section (output_bfd, input_bfd, info, lsect, h, /* Garbage collect unused sections. */ static boolean elf_gc_mark - PARAMS ((struct bfd_link_info *info, asection *sec, - asection * (*gc_mark_hook) - PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, - struct elf_link_hash_entry *, Elf_Internal_Sym *)))); + PARAMS ((struct bfd_link_info *, asection *, + asection * (*) (asection *, struct bfd_link_info *, + Elf_Internal_Rela *, struct elf_link_hash_entry *, + Elf_Internal_Sym *))); static boolean elf_gc_sweep - PARAMS ((struct bfd_link_info *info, - boolean (*gc_sweep_hook) - PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o, - const Elf_Internal_Rela *relocs)))); + PARAMS ((struct bfd_link_info *, + boolean (*) (bfd *, struct bfd_link_info *, asection *, + const Elf_Internal_Rela *))); static boolean elf_gc_sweep_symbol - PARAMS ((struct elf_link_hash_entry *h, PTR idxptr)); + PARAMS ((struct elf_link_hash_entry *, PTR)); static boolean elf_gc_allocate_got_offsets - PARAMS ((struct elf_link_hash_entry *h, PTR offarg)); + PARAMS ((struct elf_link_hash_entry *, PTR)); static boolean elf_gc_propagate_vtable_entries_used - PARAMS ((struct elf_link_hash_entry *h, PTR dummy)); + PARAMS ((struct elf_link_hash_entry *, PTR)); static boolean elf_gc_smash_unused_vtentry_relocs - PARAMS ((struct elf_link_hash_entry *h, PTR dummy)); + PARAMS ((struct elf_link_hash_entry *, PTR)); /* The mark phase of garbage collection. For a given section, mark it and any sections in this section's group, and all the sections @@ -7468,9 +7632,10 @@ static boolean elf_gc_mark (info, sec, gc_mark_hook) struct bfd_link_info *info; asection *sec; - asection * (*gc_mark_hook) - PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, - struct elf_link_hash_entry *, Elf_Internal_Sym *)); + asection * (*gc_mark_hook) PARAMS ((asection *, struct bfd_link_info *, + Elf_Internal_Rela *, + struct elf_link_hash_entry *, + Elf_Internal_Sym *)); { boolean ret; asection *group_sec; @@ -7489,17 +7654,12 @@ elf_gc_mark (info, sec, gc_mark_hook) { Elf_Internal_Rela *relstart, *rel, *relend; Elf_Internal_Shdr *symtab_hdr; - Elf_Internal_Shdr *shndx_hdr; struct elf_link_hash_entry **sym_hashes; size_t nlocsyms; size_t extsymoff; - Elf_External_Sym *locsyms, *freesyms = NULL; - Elf_External_Sym_Shndx *locsym_shndx; bfd *input_bfd = sec->owner; struct elf_backend_data *bed = get_elf_backend_data (input_bfd); - - /* GCFIXME: how to arrange so that relocs and symbols are not - reread continually? */ + Elf_Internal_Sym *isym = NULL; symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); @@ -7513,37 +7673,18 @@ elf_gc_mark (info, sec, gc_mark_hook) else extsymoff = nlocsyms = symtab_hdr->sh_info; - if (symtab_hdr->contents) - locsyms = (Elf_External_Sym *) symtab_hdr->contents; - else if (nlocsyms == 0) - locsyms = NULL; - else + isym = (Elf_Internal_Sym *) symtab_hdr->contents; + if (isym == NULL && nlocsyms != 0) { - bfd_size_type amt = nlocsyms * sizeof (Elf_External_Sym); - locsyms = freesyms = bfd_malloc (amt); - if (freesyms == NULL - || bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread (locsyms, amt, input_bfd) != amt) - { - ret = false; - goto out1; - } - } - - shndx_hdr = &elf_tdata (input_bfd)->symtab_shndx_hdr; - locsym_shndx = NULL; - if (shndx_hdr->sh_size != 0 && nlocsyms != 0) - { - bfd_size_type amt = nlocsyms * sizeof (Elf_External_Sym_Shndx); - locsym_shndx = (Elf_External_Sym_Shndx *) bfd_malloc (amt); - if (bfd_seek (input_bfd, shndx_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread (locsym_shndx, amt, input_bfd) != amt) + isym = bfd_elf_get_elf_syms (input_bfd, symtab_hdr, nlocsyms, 0, + NULL, NULL, NULL); + if (isym == NULL) return false; } /* Read the relocations. */ relstart = (NAME(_bfd_elf,link_read_relocs) - (sec->owner, sec, NULL, (Elf_Internal_Rela *) NULL, + (input_bfd, sec, NULL, (Elf_Internal_Rela *) NULL, info->keep_memory)); if (relstart == NULL) { @@ -7557,38 +7698,20 @@ elf_gc_mark (info, sec, gc_mark_hook) unsigned long r_symndx; asection *rsec; struct elf_link_hash_entry *h; - Elf_Internal_Sym s; r_symndx = ELF_R_SYM (rel->r_info); if (r_symndx == 0) continue; - if (elf_bad_symtab (sec->owner)) - { - elf_swap_symbol_in (input_bfd, - locsyms + r_symndx, - locsym_shndx + (locsym_shndx ? r_symndx : 0), - &s); - if (ELF_ST_BIND (s.st_info) == STB_LOCAL) - rsec = (*gc_mark_hook) (sec->owner, info, rel, NULL, &s); - else - { - h = sym_hashes[r_symndx - extsymoff]; - rsec = (*gc_mark_hook) (sec->owner, info, rel, h, NULL); - } - } - else if (r_symndx >= nlocsyms) + if (r_symndx >= nlocsyms + || ELF_ST_BIND (isym[r_symndx].st_info) != STB_LOCAL) { h = sym_hashes[r_symndx - extsymoff]; - rsec = (*gc_mark_hook) (sec->owner, info, rel, h, NULL); + rsec = (*gc_mark_hook) (sec, info, rel, h, NULL); } else { - elf_swap_symbol_in (input_bfd, - locsyms + r_symndx, - locsym_shndx + (locsym_shndx ? r_symndx : 0), - &s); - rsec = (*gc_mark_hook) (sec->owner, info, rel, NULL, &s); + rsec = (*gc_mark_hook) (sec, info, rel, NULL, &isym[r_symndx]); } if (rsec && !rsec->gc_mark) @@ -7604,11 +7727,16 @@ elf_gc_mark (info, sec, gc_mark_hook) } out2: - if (!info->keep_memory) + if (elf_section_data (sec)->relocs != relstart) free (relstart); out1: - if (freesyms) - free (freesyms); + if (isym != NULL && symtab_hdr->contents != (unsigned char *) isym) + { + if (! info->keep_memory) + free (isym); + else + symtab_hdr->contents = (unsigned char *) isym; + } } return ret; @@ -7619,9 +7747,8 @@ elf_gc_mark (info, sec, gc_mark_hook) static boolean elf_gc_sweep (info, gc_sweep_hook) struct bfd_link_info *info; - boolean (*gc_sweep_hook) - PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o, - const Elf_Internal_Rela *relocs)); + boolean (*gc_sweep_hook) PARAMS ((bfd *, struct bfd_link_info *, + asection *, const Elf_Internal_Rela *)); { bfd *sub; @@ -7665,7 +7792,7 @@ elf_gc_sweep (info, gc_sweep_hook) r = (*gc_sweep_hook) (o->owner, info, o, internal_relocs); - if (!info->keep_memory) + if (elf_section_data (o)->relocs != internal_relocs) free (internal_relocs); if (!r) @@ -7836,7 +7963,7 @@ elf_gc_sections (abfd, info) boolean ok = true; bfd *sub; asection * (*gc_mark_hook) - PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, + PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *h, Elf_Internal_Sym *)); if (!get_elf_backend_data (abfd)->can_gc_sections @@ -8163,7 +8290,6 @@ elf_reloc_symbol_deleted_p (offset, cookie) for (; rcookie->rel < rcookie->relend; rcookie->rel++) { unsigned long r_symndx = ELF_R_SYM (rcookie->rel->r_info); - Elf_Internal_Sym isym; if (! rcookie->bad_symtab) if (rcookie->rel->r_offset > offset) @@ -8171,21 +8297,8 @@ elf_reloc_symbol_deleted_p (offset, cookie) if (rcookie->rel->r_offset != offset) continue; - if (rcookie->locsyms && r_symndx < rcookie->locsymcount) - { - Elf_External_Sym *lsym; - Elf_External_Sym_Shndx *lshndx; - - lsym = (Elf_External_Sym *) rcookie->locsyms + r_symndx; - lshndx = (Elf_External_Sym_Shndx *) rcookie->locsym_shndx; - if (lshndx != NULL) - lshndx += r_symndx; - elf_swap_symbol_in (rcookie->abfd, lsym, lshndx, &isym); - } - if (r_symndx >= rcookie->locsymcount - || (rcookie->locsyms - && ELF_ST_BIND (isym.st_info) != STB_LOCAL)) + || ELF_ST_BIND (rcookie->locsyms[r_symndx].st_info) != STB_LOCAL) { struct elf_link_hash_entry *h; @@ -8202,17 +8315,19 @@ elf_reloc_symbol_deleted_p (offset, cookie) else return false; } - else if (rcookie->locsyms) + else { /* It's not a relocation against a global symbol, but it could be a relocation against a local symbol for a discarded section. */ asection *isec; + Elf_Internal_Sym *isym; /* Need to: get the symbol; get the section. */ - if (isym.st_shndx < SHN_LORESERVE || isym.st_shndx > SHN_HIRESERVE) + isym = &rcookie->locsyms[r_symndx]; + if (isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE) { - isec = section_from_elf_index (rcookie->abfd, isym.st_shndx); + isec = section_from_elf_index (rcookie->abfd, isym->st_shndx); if (isec != NULL && elf_discarded_section (isec)) return true; } @@ -8235,8 +8350,6 @@ elf_bfd_discard_info (output_bfd, info) struct elf_reloc_cookie cookie; asection *stab, *eh, *ehdr; Elf_Internal_Shdr *symtab_hdr; - Elf_Internal_Shdr *shndx_hdr; - Elf_External_Sym *freesyms; struct elf_backend_data *bed; bfd *abfd; boolean ret = false; @@ -8267,11 +8380,19 @@ elf_bfd_discard_info (output_bfd, info) if (ehdr) { eh = bfd_get_section_by_name (abfd, ".eh_frame"); - if (eh && eh->_raw_size == 0) + if (eh && (eh->_raw_size == 0 + || bfd_is_abs_section (eh->output_section))) eh = NULL; } - stab = strip ? NULL : bfd_get_section_by_name (abfd, ".stab"); + stab = NULL; + if (!strip) + { + stab = bfd_get_section_by_name (abfd, ".stab"); + if (stab && (stab->_raw_size == 0 + || bfd_is_abs_section (stab->output_section))) + stab = NULL; + } if ((! stab || elf_section_data(stab)->sec_info_type != ELF_INFO_TYPE_STABS) && ! eh @@ -8279,8 +8400,6 @@ elf_bfd_discard_info (output_bfd, info) continue; symtab_hdr = &elf_tdata (abfd)->symtab_hdr; - shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; - cookie.abfd = abfd; cookie.sym_hashes = elf_sym_hashes (abfd); cookie.bad_symtab = elf_bad_symtab (abfd); @@ -8296,48 +8415,20 @@ elf_bfd_discard_info (output_bfd, info) cookie.extsymoff = symtab_hdr->sh_info; } - freesyms = NULL; - if (symtab_hdr->contents) - cookie.locsyms = (void *) symtab_hdr->contents; - else if (cookie.locsymcount == 0) - cookie.locsyms = NULL; - else + cookie.locsyms = (Elf_Internal_Sym *) symtab_hdr->contents; + if (cookie.locsyms == NULL && cookie.locsymcount != 0) { - bfd_size_type amt = cookie.locsymcount * sizeof (Elf_External_Sym); - cookie.locsyms = bfd_malloc (amt); + cookie.locsyms = bfd_elf_get_elf_syms (abfd, symtab_hdr, + cookie.locsymcount, 0, + NULL, NULL, NULL); if (cookie.locsyms == NULL) return false; - freesyms = cookie.locsyms; - if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread (cookie.locsyms, amt, abfd) != amt) - { - error_ret_free_loc: - free (cookie.locsyms); - return false; - } - } - - cookie.locsym_shndx = NULL; - if (shndx_hdr->sh_size != 0 && cookie.locsymcount != 0) - { - bfd_size_type amt; - amt = cookie.locsymcount * sizeof (Elf_External_Sym_Shndx); - cookie.locsym_shndx = bfd_malloc (amt); - if (cookie.locsym_shndx == NULL) - goto error_ret_free_loc; - if (bfd_seek (abfd, shndx_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread (cookie.locsym_shndx, amt, abfd) != amt) - { - free (cookie.locsym_shndx); - goto error_ret_free_loc; - } } if (stab) { cookie.rels = (NAME(_bfd_elf,link_read_relocs) - (abfd, stab, (PTR) NULL, - (Elf_Internal_Rela *) NULL, + (abfd, stab, (PTR) NULL, (Elf_Internal_Rela *) NULL, info->keep_memory)); if (cookie.rels) { @@ -8349,7 +8440,7 @@ elf_bfd_discard_info (output_bfd, info) elf_reloc_symbol_deleted_p, &cookie)) ret = true; - if (! info->keep_memory) + if (elf_section_data (stab)->relocs != cookie.rels) free (cookie.rels); } } @@ -8372,8 +8463,13 @@ elf_bfd_discard_info (output_bfd, info) if (_bfd_elf_discard_section_eh_frame (abfd, info, eh, ehdr, elf_reloc_symbol_deleted_p, &cookie)) - ret = true; - if (! info->keep_memory) + { + /* Relocs have been edited. Ensure edited version is + used later in relocate_section. */ + elf_section_data (eh)->relocs = cookie.rels; + ret = true; + } + if (cookie.rels && elf_section_data (eh)->relocs != cookie.rels) free (cookie.rels); } @@ -8383,11 +8479,14 @@ elf_bfd_discard_info (output_bfd, info) ret = true; } - if (cookie.locsym_shndx != NULL) - free (cookie.locsym_shndx); - - if (freesyms != NULL) - free (freesyms); + if (cookie.locsyms != NULL + && symtab_hdr->contents != (unsigned char *) cookie.locsyms) + { + if (! info->keep_memory) + free (cookie.locsyms); + else + symtab_hdr->contents = (unsigned char *) cookie.locsyms; + } } if (ehdr && _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info, ehdr)) diff --git a/contrib/binutils/bfd/elfxx-ia64.c b/contrib/binutils/bfd/elfxx-ia64.c index f92ab6a..5302bf6 100644 --- a/contrib/binutils/bfd/elfxx-ia64.c +++ b/contrib/binutils/bfd/elfxx-ia64.c @@ -79,6 +79,9 @@ struct elfNN_ia64_dyn_sym_info bfd_vma pltoff_offset; bfd_vma plt_offset; bfd_vma plt2_offset; + bfd_vma tprel_offset; + bfd_vma dtpmod_offset; + bfd_vma dtprel_offset; /* The symbol table entry, if any, that this was derrived from. */ struct elf_link_hash_entry *h; @@ -97,6 +100,9 @@ struct elfNN_ia64_dyn_sym_info unsigned got_done : 1; unsigned fptr_done : 1; unsigned pltoff_done : 1; + unsigned tprel_done : 1; + unsigned dtpmod_done : 1; + unsigned dtprel_done : 1; /* True for the different kinds of linker data we want created. */ unsigned want_got : 1; @@ -105,6 +111,9 @@ struct elfNN_ia64_dyn_sym_info unsigned want_plt : 1; unsigned want_plt2 : 1; unsigned want_pltoff : 1; + unsigned want_tprel : 1; + unsigned want_dtpmod : 1; + unsigned want_dtprel : 1; }; struct elfNN_ia64_local_hash_entry @@ -165,7 +174,7 @@ static boolean elfNN_ia64_relax_section static boolean is_unwind_section_name PARAMS ((bfd *abfd, const char *)); static boolean elfNN_ia64_section_from_shdr - PARAMS ((bfd *, ElfNN_Internal_Shdr *, char *)); + PARAMS ((bfd *, ElfNN_Internal_Shdr *, const char *)); static boolean elfNN_ia64_section_flags PARAMS ((flagword *, ElfNN_Internal_Shdr *)); static boolean elfNN_ia64_fake_sections @@ -202,7 +211,8 @@ static struct bfd_hash_entry *elfNN_ia64_new_elf_hash_entry PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table, const char *string)); static void elfNN_ia64_hash_copy_indirect - PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *)); + PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *, + struct elf_link_hash_entry *)); static void elfNN_ia64_hash_hide_symbol PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean)); static struct bfd_link_hash_table *elfNN_ia64_hash_table_create @@ -285,6 +295,10 @@ static bfd_vma set_pltoff_entry PARAMS ((bfd *abfd, struct bfd_link_info *info, struct elfNN_ia64_dyn_sym_info *dyn_i, bfd_vma value, boolean)); +static bfd_vma elfNN_ia64_tprel_base + PARAMS ((struct bfd_link_info *info)); +static bfd_vma elfNN_ia64_dtprel_base + PARAMS ((struct bfd_link_info *info)); static int elfNN_ia64_unwind_entry_compare PARAMS ((const PTR, const PTR)); static boolean elfNN_ia64_final_link @@ -423,10 +437,25 @@ static reloc_howto_type ia64_howto_table[] = IA64_HOWTO (R_IA64_LTOFF22X, "LTOFF22X", 0, false, true), IA64_HOWTO (R_IA64_LDXMOV, "LDXMOV", 0, false, true), + IA64_HOWTO (R_IA64_TPREL14, "TPREL14", 0, false, false), IA64_HOWTO (R_IA64_TPREL22, "TPREL22", 0, false, false), + IA64_HOWTO (R_IA64_TPREL64I, "TPREL64I", 0, false, false), IA64_HOWTO (R_IA64_TPREL64MSB, "TPREL64MSB", 8, false, false), IA64_HOWTO (R_IA64_TPREL64LSB, "TPREL64LSB", 8, false, false), - IA64_HOWTO (R_IA64_LTOFF_TP22, "LTOFF_TP22", 0, false, false), + IA64_HOWTO (R_IA64_LTOFF_TPREL22, "LTOFF_TPREL22", 0, false, false), + + IA64_HOWTO (R_IA64_DTPMOD64MSB, "TPREL64MSB", 8, false, false), + IA64_HOWTO (R_IA64_DTPMOD64LSB, "TPREL64LSB", 8, false, false), + IA64_HOWTO (R_IA64_LTOFF_DTPMOD22, "LTOFF_DTPMOD22", 0, false, false), + + IA64_HOWTO (R_IA64_DTPREL14, "DTPREL14", 0, false, false), + IA64_HOWTO (R_IA64_DTPREL22, "DTPREL22", 0, false, false), + IA64_HOWTO (R_IA64_DTPREL64I, "DTPREL64I", 0, false, false), + IA64_HOWTO (R_IA64_DTPREL32MSB, "DTPREL32MSB", 4, false, false), + IA64_HOWTO (R_IA64_DTPREL32LSB, "DTPREL32LSB", 4, false, false), + IA64_HOWTO (R_IA64_DTPREL64MSB, "DTPREL64MSB", 8, false, false), + IA64_HOWTO (R_IA64_DTPREL64LSB, "DTPREL64LSB", 8, false, false), + IA64_HOWTO (R_IA64_LTOFF_DTPREL22, "LTOFF_DTPREL22", 0, false, false), }; static unsigned char elf_code_to_howto_index[R_IA64_MAX_RELOC_CODE + 1]; @@ -541,10 +570,25 @@ elfNN_ia64_reloc_type_lookup (abfd, bfd_code) case BFD_RELOC_IA64_LTOFF22X: rtype = R_IA64_LTOFF22X; break; case BFD_RELOC_IA64_LDXMOV: rtype = R_IA64_LDXMOV; break; + case BFD_RELOC_IA64_TPREL14: rtype = R_IA64_TPREL14; break; case BFD_RELOC_IA64_TPREL22: rtype = R_IA64_TPREL22; break; + case BFD_RELOC_IA64_TPREL64I: rtype = R_IA64_TPREL64I; break; case BFD_RELOC_IA64_TPREL64MSB: rtype = R_IA64_TPREL64MSB; break; case BFD_RELOC_IA64_TPREL64LSB: rtype = R_IA64_TPREL64LSB; break; - case BFD_RELOC_IA64_LTOFF_TP22: rtype = R_IA64_LTOFF_TP22; break; + case BFD_RELOC_IA64_LTOFF_TPREL22: rtype = R_IA64_LTOFF_TPREL22; break; + + case BFD_RELOC_IA64_DTPMOD64MSB: rtype = R_IA64_DTPMOD64MSB; break; + case BFD_RELOC_IA64_DTPMOD64LSB: rtype = R_IA64_DTPMOD64LSB; break; + case BFD_RELOC_IA64_LTOFF_DTPMOD22: rtype = R_IA64_LTOFF_DTPMOD22; break; + + case BFD_RELOC_IA64_DTPREL14: rtype = R_IA64_DTPREL14; break; + case BFD_RELOC_IA64_DTPREL22: rtype = R_IA64_DTPREL22; break; + case BFD_RELOC_IA64_DTPREL64I: rtype = R_IA64_DTPREL64I; break; + case BFD_RELOC_IA64_DTPREL32MSB: rtype = R_IA64_DTPREL32MSB; break; + case BFD_RELOC_IA64_DTPREL32LSB: rtype = R_IA64_DTPREL32LSB; break; + case BFD_RELOC_IA64_DTPREL64MSB: rtype = R_IA64_DTPREL64MSB; break; + case BFD_RELOC_IA64_DTPREL64LSB: rtype = R_IA64_DTPREL64LSB; break; + case BFD_RELOC_IA64_LTOFF_DTPREL22: rtype = R_IA64_LTOFF_DTPREL22; break; default: return 0; } @@ -648,15 +692,10 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) }; Elf_Internal_Shdr *symtab_hdr; - Elf_Internal_Shdr *shndx_hdr; Elf_Internal_Rela *internal_relocs; - Elf_Internal_Rela *free_relocs = NULL; Elf_Internal_Rela *irel, *irelend; bfd_byte *contents; - bfd_byte *free_contents = NULL; - ElfNN_External_Sym *extsyms; - ElfNN_External_Sym *free_extsyms = NULL; - Elf_External_Sym_Shndx *shndx_buf = NULL; + Elf_Internal_Sym *isymbuf = NULL; struct elfNN_ia64_link_hash_table *ia64_info; struct one_fixup *fixups = NULL; boolean changed_contents = false; @@ -683,10 +722,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL, link_info->keep_memory)); if (internal_relocs == NULL) - goto error_return; - - if (! link_info->keep_memory) - free_relocs = internal_relocs; + return false; ia64_info = elfNN_ia64_hash_table (link_info); irelend = internal_relocs + sec->reloc_count; @@ -698,8 +734,8 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) /* No branch-type relocations. */ if (irel == irelend) { - if (free_relocs != NULL) - free (free_relocs); + if (elf_section_data (sec)->relocs != internal_relocs) + free (internal_relocs); return true; } @@ -711,48 +747,15 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) contents = (bfd_byte *) bfd_malloc (sec->_raw_size); if (contents == NULL) goto error_return; - free_contents = contents; if (! bfd_get_section_contents (abfd, sec, contents, (file_ptr) 0, sec->_raw_size)) goto error_return; } - /* Read this BFD's local symbols. */ - if (symtab_hdr->contents != NULL) - extsyms = (ElfNN_External_Sym *) symtab_hdr->contents; - else - { - bfd_size_type amt; - - amt = symtab_hdr->sh_info * sizeof (ElfNN_External_Sym); - extsyms = (ElfNN_External_Sym *) bfd_malloc (amt); - if (extsyms == NULL) - goto error_return; - free_extsyms = extsyms; - if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread (extsyms, amt, abfd) != amt) - goto error_return; - } - - shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; - if (shndx_hdr->sh_size != 0) - { - bfd_size_type amt; - - amt = symtab_hdr->sh_info * sizeof (Elf_External_Sym_Shndx); - shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (amt); - if (shndx_buf == NULL) - goto error_return; - if (bfd_seek (abfd, shndx_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread (shndx_buf, amt, abfd) != amt) - goto error_return; - } - for (; irel < irelend; irel++) { bfd_vma symaddr, reladdr, trampoff, toff, roff; - Elf_Internal_Sym isym; asection *tsec; struct one_fixup *f; bfd_size_type amt; @@ -763,25 +766,34 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) /* Get the value of the symbol referred to by the reloc. */ if (ELFNN_R_SYM (irel->r_info) < symtab_hdr->sh_info) { - ElfNN_External_Sym *esym; - Elf_External_Sym_Shndx *shndx; - /* A local symbol. */ - esym = extsyms + ELFNN_R_SYM (irel->r_info); - shndx = shndx_buf + (shndx_buf ? ELFNN_R_SYM (irel->r_info) : 0); - bfd_elfNN_swap_symbol_in (abfd, esym, shndx, &isym); - if (isym.st_shndx == SHN_UNDEF) + Elf_Internal_Sym *isym; + + /* Read this BFD's local symbols. */ + if (isymbuf == NULL) + { + isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents; + if (isymbuf == NULL) + isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr, + symtab_hdr->sh_info, 0, + NULL, NULL, NULL); + if (isymbuf == 0) + goto error_return; + } + + isym = isymbuf + ELF64_R_SYM (irel->r_info); + if (isym->st_shndx == SHN_UNDEF) continue; /* We can't do anthing with undefined symbols. */ - else if (isym.st_shndx == SHN_ABS) + else if (isym->st_shndx == SHN_ABS) tsec = bfd_abs_section_ptr; - else if (isym.st_shndx == SHN_COMMON) + else if (isym->st_shndx == SHN_COMMON) tsec = bfd_com_section_ptr; - else if (isym.st_shndx == SHN_IA_64_ANSI_COMMON) + else if (isym->st_shndx == SHN_IA_64_ANSI_COMMON) tsec = bfd_com_section_ptr; else - tsec = bfd_section_from_elf_index (abfd, isym.st_shndx); + tsec = bfd_section_from_elf_index (abfd, isym->st_shndx); - toff = isym.st_value; + toff = isym->st_value; } else { @@ -929,50 +941,50 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) free (f); } - if (changed_relocs) - elf_section_data (sec)->relocs = internal_relocs; - else if (free_relocs != NULL) - free (free_relocs); - - if (changed_contents) - elf_section_data (sec)->this_hdr.contents = contents; - else if (free_contents != NULL) + if (isymbuf != NULL + && symtab_hdr->contents != (unsigned char *) isymbuf) { if (! link_info->keep_memory) - free (free_contents); + free (isymbuf); else { - /* Cache the section contents for elf_link_input_bfd. */ - elf_section_data (sec)->this_hdr.contents = contents; + /* Cache the symbols for elf_link_input_bfd. */ + symtab_hdr->contents = (unsigned char *) isymbuf; } } - if (shndx_buf != NULL) - free (shndx_buf); - - if (free_extsyms != NULL) + if (contents != NULL + && elf_section_data (sec)->this_hdr.contents != contents) { - if (! link_info->keep_memory) - free (free_extsyms); + if (!changed_contents && !link_info->keep_memory) + free (contents); else { - /* Cache the symbols for elf_link_input_bfd. */ - symtab_hdr->contents = (unsigned char *) extsyms; + /* Cache the section contents for elf_link_input_bfd. */ + elf_section_data (sec)->this_hdr.contents = contents; } } + if (elf_section_data (sec)->relocs != internal_relocs) + { + if (!changed_relocs) + free (internal_relocs); + else + elf_section_data (sec)->relocs = internal_relocs; + } + *again = changed_contents || changed_relocs; return true; error_return: - if (free_relocs != NULL) - free (free_relocs); - if (free_contents != NULL) - free (free_contents); - if (shndx_buf != NULL) - free (shndx_buf); - if (free_extsyms != NULL) - free (free_extsyms); + if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents) + free (isymbuf); + if (contents != NULL + && elf_section_data (sec)->this_hdr.contents != contents) + free (contents); + if (internal_relocs != NULL + && elf_section_data (sec)->relocs != internal_relocs) + free (internal_relocs); return false; } @@ -1004,7 +1016,7 @@ static boolean elfNN_ia64_section_from_shdr (abfd, hdr, name) bfd *abfd; ElfNN_Internal_Shdr *hdr; - char *name; + const char *name; { asection *newsect; @@ -1358,8 +1370,6 @@ elfNN_ia64_modify_segment_map (abfd) struct elf_segment_map *m, **pm; Elf_Internal_Shdr *hdr; asection *s; - boolean unwind_found; - asection *unwind_sec; /* If we need a PT_IA_64_ARCHEXT segment, it must come before all PT_LOAD segments. */ @@ -1404,20 +1414,16 @@ elfNN_ia64_modify_segment_map (abfd) for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) if (m->p_type == PT_IA_64_UNWIND) { + int i; + /* Look through all sections in the unwind segment for a match since there may be multiple sections to a segment. */ + for (i = m->count - 1; i >= 0; --i) + if (m->sections[i] == s) + break; - unwind_sec = m->sections[0]; - unwind_found = false; - while (unwind_sec != NULL && !unwind_found) - { - if (unwind_sec == s) - unwind_found = true; - else - unwind_sec = unwind_sec -> next; - } - if (unwind_found) + if (i >= 0) break; } @@ -1588,7 +1594,8 @@ elfNN_ia64_new_elf_hash_entry (entry, table, string) } static void -elfNN_ia64_hash_copy_indirect (xdir, xind) +elfNN_ia64_hash_copy_indirect (bed, xdir, xind) + struct elf_backend_data *bed ATTRIBUTE_UNUSED; struct elf_link_hash_entry *xdir, *xind; { struct elfNN_ia64_link_hash_entry *dir, *ind; @@ -2097,6 +2104,9 @@ elfNN_ia64_check_relocs (abfd, info, sec, relocs) NEED_FULL_PLT = 16, NEED_DYNREL = 32, NEED_LTOFF_FPTR = 64, + NEED_TPREL = 128, + NEED_DTPMOD = 256, + NEED_DTPREL = 512 }; struct elf_link_hash_entry *h = NULL; @@ -2134,11 +2144,42 @@ elfNN_ia64_check_relocs (abfd, info, sec, relocs) need_entry = 0; switch (ELFNN_R_TYPE (rel->r_info)) { - case R_IA64_TPREL22: case R_IA64_TPREL64MSB: case R_IA64_TPREL64LSB: - case R_IA64_LTOFF_TP22: - return false; + if (info->shared || maybe_dynamic) + need_entry = NEED_DYNREL; + dynrel_type = R_IA64_TPREL64LSB; + if (info->shared) + info->flags |= DF_STATIC_TLS; + break; + + case R_IA64_LTOFF_TPREL22: + need_entry = NEED_TPREL; + if (info->shared) + info->flags |= DF_STATIC_TLS; + break; + + case R_IA64_DTPREL64MSB: + case R_IA64_DTPREL64LSB: + if (info->shared || maybe_dynamic) + need_entry = NEED_DYNREL; + dynrel_type = R_IA64_DTPREL64LSB; + break; + + case R_IA64_LTOFF_DTPREL22: + need_entry = NEED_DTPREL; + break; + + case R_IA64_DTPMOD64MSB: + case R_IA64_DTPMOD64LSB: + if (info->shared || maybe_dynamic) + need_entry = NEED_DYNREL; + dynrel_type = R_IA64_DTPMOD64LSB; + break; + + case R_IA64_LTOFF_DTPMOD22: + need_entry = NEED_DTPMOD; + break; case R_IA64_LTOFF_FPTR22: case R_IA64_LTOFF_FPTR64I: @@ -2248,7 +2289,7 @@ elfNN_ia64_check_relocs (abfd, info, sec, relocs) dyn_i->h = h; /* Create what's needed. */ - if (need_entry & NEED_GOT) + if (need_entry & (NEED_GOT | NEED_TPREL | NEED_DTPMOD | NEED_DTPREL)) { if (!got) { @@ -2256,7 +2297,14 @@ elfNN_ia64_check_relocs (abfd, info, sec, relocs) if (!got) return false; } - dyn_i->want_got = 1; + if (need_entry & NEED_GOT) + dyn_i->want_got = 1; + if (need_entry & NEED_TPREL) + dyn_i->want_tprel = 1; + if (need_entry & NEED_DTPMOD) + dyn_i->want_dtpmod = 1; + if (need_entry & NEED_DTPREL) + dyn_i->want_dtprel = 1; } if (need_entry & NEED_FPTR) { @@ -2336,6 +2384,21 @@ allocate_global_data_got (dyn_i, data) dyn_i->got_offset = x->ofs; x->ofs += 8; } + if (dyn_i->want_tprel) + { + dyn_i->tprel_offset = x->ofs; + x->ofs += 8; + } + if (dyn_i->want_dtpmod) + { + dyn_i->dtpmod_offset = x->ofs; + x->ofs += 8; + } + if (dyn_i->want_dtprel) + { + dyn_i->dtprel_offset = x->ofs; + x->ofs += 8; + } return true; } @@ -2582,6 +2645,10 @@ allocate_dynrel_entries (dyn_i, data) if (!dynamic_symbol) count *= 2; break; + case R_IA64_TPREL64LSB: + case R_IA64_DTPREL64LSB: + case R_IA64_DTPMOD64LSB: + break; default: abort (); } @@ -2593,6 +2660,12 @@ allocate_dynrel_entries (dyn_i, data) if (((dynamic_symbol || shared) && dyn_i->want_got) || (dyn_i->want_ltoff_fptr && dyn_i->h && dyn_i->h->dynindx != -1)) ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); + if ((dynamic_symbol || shared) && dyn_i->want_tprel) + ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); + if ((dynamic_symbol || shared) && dyn_i->want_dtpmod) + ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); + if (dynamic_symbol && dyn_i->want_dtprel) + ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); if (dyn_i->want_pltoff) { @@ -2903,7 +2976,11 @@ elfNN_ia64_install_value (abfd, hit_addr, v, r_type) /* Instruction relocations. */ - case R_IA64_IMM14: opnd = IA64_OPND_IMM14; break; + case R_IA64_IMM14: + case R_IA64_TPREL14: + case R_IA64_DTPREL14: + opnd = IA64_OPND_IMM14; + break; case R_IA64_PCREL21F: opnd = IA64_OPND_TGT25; break; case R_IA64_PCREL21M: opnd = IA64_OPND_TGT25b; break; @@ -2920,6 +2997,11 @@ elfNN_ia64_install_value (abfd, hit_addr, v, r_type) case R_IA64_PLTOFF22: case R_IA64_PCREL22: case R_IA64_LTOFF_FPTR22: + case R_IA64_TPREL22: + case R_IA64_DTPREL22: + case R_IA64_LTOFF_TPREL22: + case R_IA64_LTOFF_DTPMOD22: + case R_IA64_LTOFF_DTPREL22: opnd = IA64_OPND_IMM22; break; @@ -2930,6 +3012,8 @@ elfNN_ia64_install_value (abfd, hit_addr, v, r_type) case R_IA64_PCREL64I: case R_IA64_FPTR64I: case R_IA64_LTOFF_FPTR64I: + case R_IA64_TPREL64I: + case R_IA64_DTPREL64I: opnd = IA64_OPND_IMMU64; break; @@ -2943,6 +3027,7 @@ elfNN_ia64_install_value (abfd, hit_addr, v, r_type) case R_IA64_SEGREL32MSB: case R_IA64_SECREL32MSB: case R_IA64_LTV32MSB: + case R_IA64_DTPREL32MSB: size = 4; bigendian = 1; break; @@ -2954,6 +3039,7 @@ elfNN_ia64_install_value (abfd, hit_addr, v, r_type) case R_IA64_SEGREL32LSB: case R_IA64_SECREL32LSB: case R_IA64_LTV32LSB: + case R_IA64_DTPREL32LSB: size = 4; bigendian = 0; break; @@ -2966,6 +3052,9 @@ elfNN_ia64_install_value (abfd, hit_addr, v, r_type) case R_IA64_SEGREL64MSB: case R_IA64_SECREL64MSB: case R_IA64_LTV64MSB: + case R_IA64_TPREL64MSB: + case R_IA64_DTPMOD64MSB: + case R_IA64_DTPREL64MSB: size = 8; bigendian = 1; break; @@ -2978,6 +3067,9 @@ elfNN_ia64_install_value (abfd, hit_addr, v, r_type) case R_IA64_SEGREL64LSB: case R_IA64_SECREL64LSB: case R_IA64_LTV64LSB: + case R_IA64_TPREL64LSB: + case R_IA64_DTPMOD64LSB: + case R_IA64_DTPREL64LSB: size = 8; bigendian = 0; break; @@ -3132,26 +3224,53 @@ set_got_entry (abfd, info, dyn_i, dynindx, addend, value, dyn_r_type) { struct elfNN_ia64_link_hash_table *ia64_info; asection *got_sec; + boolean done; + bfd_vma got_offset; ia64_info = elfNN_ia64_hash_table (info); got_sec = ia64_info->got_sec; - BFD_ASSERT ((dyn_i->got_offset & 7) == 0); - - if (! dyn_i->got_done) + switch (dyn_r_type) { + case R_IA64_TPREL64LSB: + done = dyn_i->tprel_done; + dyn_i->tprel_done = true; + got_offset = dyn_i->tprel_offset; + break; + case R_IA64_DTPMOD64LSB: + done = dyn_i->dtpmod_done; + dyn_i->dtpmod_done = true; + got_offset = dyn_i->dtpmod_offset; + break; + case R_IA64_DTPREL64LSB: + done = dyn_i->dtprel_done; + dyn_i->dtprel_done = true; + got_offset = dyn_i->dtprel_offset; + break; + default: + done = dyn_i->got_done; dyn_i->got_done = true; + got_offset = dyn_i->got_offset; + break; + } + + BFD_ASSERT ((got_offset & 7) == 0); + if (! done) + { /* Store the target address in the linkage table entry. */ - bfd_put_64 (abfd, value, got_sec->contents + dyn_i->got_offset); + bfd_put_64 (abfd, value, got_sec->contents + got_offset); /* Install a dynamic relocation if needed. */ - if (info->shared + if ((info->shared && dyn_r_type != R_IA64_DTPREL64LSB) || elfNN_ia64_dynamic_symbol_p (dyn_i->h, info) || elfNN_ia64_aix_vec (abfd->xvec) || (dynindx != -1 && dyn_r_type == R_IA64_FPTR64LSB)) { - if (dynindx == -1) + if (dynindx == -1 + && dyn_r_type != R_IA64_TPREL64LSB + && dyn_r_type != R_IA64_DTPMOD64LSB + && dyn_r_type != R_IA64_DTPREL64LSB) { dyn_r_type = R_IA64_REL64LSB; dynindx = 0; @@ -3171,6 +3290,15 @@ set_got_entry (abfd, info, dyn_i, dynindx, addend, value, dyn_r_type) case R_IA64_FPTR64LSB: dyn_r_type = R_IA64_FPTR64MSB; break; + case R_IA64_TPREL64LSB: + dyn_r_type = R_IA64_TPREL64MSB; + break; + case R_IA64_DTPMOD64LSB: + dyn_r_type = R_IA64_DTPMOD64MSB; + break; + case R_IA64_DTPREL64LSB: + dyn_r_type = R_IA64_DTPREL64MSB; + break; default: BFD_ASSERT (false); break; @@ -3179,7 +3307,7 @@ set_got_entry (abfd, info, dyn_i, dynindx, addend, value, dyn_r_type) elfNN_ia64_install_dyn_reloc (abfd, NULL, got_sec, ia64_info->rel_got_sec, - dyn_i->got_offset, dyn_r_type, + got_offset, dyn_r_type, dynindx, addend); } } @@ -3187,7 +3315,7 @@ set_got_entry (abfd, info, dyn_i, dynindx, addend, value, dyn_r_type) /* Return the address of the linkage table entry. */ value = (got_sec->output_section->vma + got_sec->output_offset - + dyn_i->got_offset); + + got_offset); return value; } @@ -3285,6 +3413,35 @@ set_pltoff_entry (abfd, info, dyn_i, value, is_plt) return value; } +/* Return the base VMA address which should be subtracted from real addresses + when resolving @tprel() relocation. + Main program TLS (whose template starts at PT_TLS p_vaddr) + is assigned offset round(16, PT_TLS p_align). */ + +static bfd_vma +elfNN_ia64_tprel_base (info) + struct bfd_link_info *info; +{ + struct elf_link_tls_segment *tls_segment + = elf_hash_table (info)->tls_segment; + + BFD_ASSERT (tls_segment != NULL); + return (tls_segment->start + - align_power ((bfd_vma) 16, tls_segment->align)); +} + +/* Return the base VMA address which should be subtracted from real addresses + when resolving @dtprel() relocation. + This is PT_TLS segment p_vaddr. */ + +static bfd_vma +elfNN_ia64_dtprel_base (info) + struct bfd_link_info *info; +{ + BFD_ASSERT (elf_hash_table (info)->tls_segment != NULL); + return elf_hash_table (info)->tls_segment->start; +} + /* Called through qsort to sort the .IA_64.unwind section during a non-relocatable link. Set elfNN_ia64_unwind_entry_compare_bfd to the output bfd so we can do proper endianness frobbing. */ @@ -4030,6 +4187,55 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, r_type); break; + case R_IA64_TPREL14: + case R_IA64_TPREL22: + case R_IA64_TPREL64I: + value -= elfNN_ia64_tprel_base (info); + r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); + break; + + case R_IA64_DTPREL14: + case R_IA64_DTPREL22: + case R_IA64_DTPREL64I: + value -= elfNN_ia64_dtprel_base (info); + r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); + break; + + case R_IA64_LTOFF_TPREL22: + case R_IA64_LTOFF_DTPMOD22: + case R_IA64_LTOFF_DTPREL22: + { + int got_r_type; + + switch (r_type) + { + default: + case R_IA64_LTOFF_TPREL22: + if (!dynamic_symbol_p && !info->shared) + value -= elfNN_ia64_tprel_base (info); + got_r_type = R_IA64_TPREL64LSB; + break; + case R_IA64_LTOFF_DTPMOD22: + if (!dynamic_symbol_p && !info->shared) + value = 1; + got_r_type = R_IA64_DTPMOD64LSB; + break; + case R_IA64_LTOFF_DTPREL22: + if (!dynamic_symbol_p) + value -= elfNN_ia64_dtprel_base (info); + got_r_type = R_IA64_DTPREL64LSB; + break; + } + dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false); + value = set_got_entry (input_bfd, info, dyn_i, + (h ? h->dynindx : -1), rel->r_addend, + value, got_r_type); + value -= gp_val; + r = elfNN_ia64_install_value (output_bfd, hit_addr, value, + r_type); + } + break; + default: r = bfd_reloc_notsupported; break; @@ -4592,6 +4798,9 @@ elfNN_hpux_backend_section_from_bfd_section (abfd, sec, retval) #undef elf_backend_section_from_bfd_section #define elf_backend_section_from_bfd_section elfNN_hpux_backend_section_from_bfd_section +#undef elf_backend_want_p_paddr_set_to_zero +#define elf_backend_want_p_paddr_set_to_zero 1 + #undef ELF_MAXPAGESIZE #define ELF_MAXPAGESIZE 0x1000 /* 1K */ @@ -4599,3 +4808,5 @@ elfNN_hpux_backend_section_from_bfd_section (abfd, sec, retval) #define elfNN_bed elfNN_ia64_hpux_bed #include "elfNN-target.h" + +#undef elf_backend_want_p_paddr_set_to_zero diff --git a/contrib/binutils/bfd/elfxx-target.h b/contrib/binutils/bfd/elfxx-target.h index e6b63d1..481ba71 100644 --- a/contrib/binutils/bfd/elfxx-target.h +++ b/contrib/binutils/bfd/elfxx-target.h @@ -44,7 +44,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef bfd_elfNN_get_reloc_upper_bound #define bfd_elfNN_get_reloc_upper_bound _bfd_elf_get_reloc_upper_bound #endif +#ifndef bfd_elfNN_get_symbol_info #define bfd_elfNN_get_symbol_info _bfd_elf_get_symbol_info +#endif #define bfd_elfNN_get_symtab _bfd_elf_get_symtab #define bfd_elfNN_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound #if 0 /* done in elf-bfd.h */ @@ -87,6 +89,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef elf_backend_want_dynbss #define elf_backend_want_dynbss 1 #endif +#ifndef elf_backend_want_p_paddr_set_to_zero +#define elf_backend_want_p_paddr_set_to_zero 0 +#endif #define bfd_elfNN_bfd_debug_info_start bfd_void #define bfd_elfNN_bfd_debug_info_end bfd_void @@ -126,6 +131,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ _bfd_elf_merge_sections #endif +#ifndef bfd_elfNN_bfd_discard_group +#define bfd_elfNN_bfd_discard_group bfd_elf_discard_group +#endif + #ifndef bfd_elfNN_bfd_make_debug_symbol #define bfd_elfNN_bfd_make_debug_symbol \ ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr) @@ -169,6 +178,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ _bfd_elf_canonicalize_dynamic_reloc #endif +#ifndef bfd_elfNN_bfd_link_hash_table_free +#define bfd_elfNN_bfd_link_hash_table_free _bfd_generic_link_hash_table_free +#endif + #ifdef elf_backend_relocate_section #ifndef bfd_elfNN_bfd_link_hash_table_create #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create @@ -190,6 +203,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define bfd_elfNN_bfd_final_link _bfd_generic_final_link #endif #endif /* ! defined (elf_backend_relocate_section) */ + +#ifndef bfd_elfNN_bfd_link_just_syms +#define bfd_elfNN_bfd_link_just_syms _bfd_elf_link_just_syms +#endif + #ifndef bfd_elfNN_bfd_link_split_section #define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section #endif @@ -367,6 +385,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef elf_backend_write_section #define elf_backend_write_section NULL #endif +#ifndef elf_backend_set_nonloadable_filepos +#define elf_backend_set_nonloadable_filepos NULL +#endif +#ifndef elf_backend_is_contained_by_filepos +#define elf_backend_is_contained_by_filepos NULL +#endif +#ifndef elf_backend_copy_private_bfd_data_p +#define elf_backend_copy_private_bfd_data_p NULL +#endif +#ifndef elf_backend_mips_irix_compat +#define elf_backend_mips_irix_compat NULL +#endif +#ifndef elf_backend_mips_rtype_to_howto +#define elf_backend_mips_rtype_to_howto NULL +#endif /* Previously, backends could only use SHT_REL or SHT_RELA relocation sections, but not both. They defined USE_REL to indicate SHT_REL @@ -462,6 +495,11 @@ static const struct elf_backend_data elfNN_bed = elf_backend_discard_info, elf_backend_ignore_discarded_relocs, elf_backend_write_section, + elf_backend_set_nonloadable_filepos, + elf_backend_is_contained_by_filepos, + elf_backend_copy_private_bfd_data_p, + elf_backend_mips_irix_compat, + elf_backend_mips_rtype_to_howto, elf_backend_ecoff_debug_swap, ELF_MACHINE_ALT1, ELF_MACHINE_ALT2, @@ -484,7 +522,8 @@ static const struct elf_backend_data elfNN_bed = elf_backend_can_gc_sections, elf_backend_can_refcount, elf_backend_want_got_sym, - elf_backend_want_dynbss + elf_backend_want_dynbss, + elf_backend_want_p_paddr_set_to_zero }; #endif diff --git a/contrib/binutils/bfd/format.c b/contrib/binutils/bfd/format.c index f60f0ca..1efa9e2 100644 --- a/contrib/binutils/bfd/format.c +++ b/contrib/binutils/bfd/format.c @@ -1,5 +1,5 @@ /* Generic BFD support for file formats. - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001 + Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Written by Cygnus Support. @@ -355,7 +355,7 @@ bfd_set_format (abfd, format) } if (abfd->format != bfd_unknown) - return (abfd->format == format) ? true : false; + return abfd->format == format; /* Presume the answer is yes. */ abfd->format = format; diff --git a/contrib/binutils/bfd/hash.c b/contrib/binutils/bfd/hash.c index 9766eaf..e7c77fe 100644 --- a/contrib/binutils/bfd/hash.c +++ b/contrib/binutils/bfd/hash.c @@ -1,5 +1,5 @@ /* hash.c -- hash table routines for BFD - Copyright 1993, 1994, 1995, 1997, 1999, 2001 + Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002 Free Software Foundation, Inc. Written by Steve Chamberlain <sac@cygnus.com> @@ -375,8 +375,8 @@ bfd_hash_lookup (table, string, create, copy) { hash += c + (c << 17); hash ^= hash >> 2; - ++len; } + len = (s - (const unsigned char *) string) - 1; hash += len + (len << 17); hash ^= hash >> 2; @@ -407,7 +407,7 @@ bfd_hash_lookup (table, string, create, copy) bfd_set_error (bfd_error_no_memory); return (struct bfd_hash_entry *) NULL; } - strcpy (new, string); + memcpy (new, string, len + 1); string = new; } hashp->string = string; diff --git a/contrib/binutils/bfd/i386linux.c b/contrib/binutils/bfd/i386linux.c index 755b456..c144822 100644 --- a/contrib/binutils/bfd/i386linux.c +++ b/contrib/binutils/bfd/i386linux.c @@ -597,10 +597,9 @@ bfd_i386linux_size_dynamic_sections (output_bfd, info) { s->_raw_size = linux_hash_table (info)->fixup_count + 1; s->_raw_size *= 8; - s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size); + s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size); if (s->contents == NULL) return false; - memset (s->contents, 0, (size_t) s->_raw_size); } return true; diff --git a/contrib/binutils/bfd/ieee.c b/contrib/binutils/bfd/ieee.c index df7cfd6..d1c5eb1 100644 --- a/contrib/binutils/bfd/ieee.c +++ b/contrib/binutils/bfd/ieee.c @@ -471,7 +471,7 @@ must_parse_int (ieee) common_header_type *ieee; { bfd_vma result; - BFD_ASSERT (parse_int (ieee, &result) == true); + BFD_ASSERT (parse_int (ieee, &result)); return result; } @@ -983,7 +983,7 @@ ieee_slurp_external_symbols (abfd) /* Fetch the default size if not resolved */ size = must_parse_int (&(ieee->h)); /* Fetch the defautlt value if available */ - if (parse_int (&(ieee->h), &value) == false) + if (! parse_int (&(ieee->h), &value)) { value = 0; } @@ -1058,7 +1058,7 @@ static boolean ieee_slurp_symbol_table (abfd) bfd *abfd; { - if (IEEE_DATA (abfd)->read_symbols == false) + if (! IEEE_DATA (abfd)->read_symbols) { if (! ieee_slurp_external_symbols (abfd)) return false; @@ -1112,7 +1112,7 @@ ieee_get_symtab (abfd, location) if (! ieee_slurp_symbol_table (abfd)) return -1; - if (ieee->symbol_table_full == false) + if (! ieee->symbol_table_full) { /* Arrgh - there are gaps in the table, run through and fill them */ /* up with pointers to a null place */ @@ -1414,7 +1414,7 @@ ieee_archive_p (abfd) abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, amt); if (!abfd->tdata.ieee_ar_data) - goto error_return; + goto error_ret_restore; ieee = IEEE_AR_DATA (abfd); /* Ignore the return value here. It doesn't matter if we don't read @@ -1530,13 +1530,13 @@ ieee_archive_p (abfd) return abfd->xvec; got_wrong_format_error: - bfd_release (abfd, ieee); - abfd->tdata.ieee_ar_data = save; bfd_set_error (bfd_error_wrong_format); - error_return: if (elts != NULL) free (elts); + bfd_release (abfd, ieee); + error_ret_restore: + abfd->tdata.ieee_ar_data = save; return NULL; } @@ -1663,11 +1663,11 @@ ieee_object_p (abfd) } next_byte (&(ieee->h)); - if (parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau) == false) + if (! parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau)) { goto fail; } - if (parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address) == false) + if (! parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address)) { goto fail; } @@ -1690,7 +1690,7 @@ ieee_object_p (abfd) } ieee->w.offset[part] = parse_i (&(ieee->h), &ok); - if (ok == false) + if (! ok) { goto fail; } @@ -1732,7 +1732,7 @@ ieee_object_p (abfd) got_wrong_format: bfd_set_error (bfd_error_wrong_format); fail: - (void) bfd_release (abfd, ieee); + bfd_release (abfd, ieee); abfd->tdata.ieee_data = save; return (const bfd_target *) NULL; } @@ -1895,7 +1895,7 @@ do_one (ieee, current_map, location_ptr, s, iterations) case 0: case 4: - if (pcrel == true) + if (pcrel) { #if KEEPMINUSPCININST bfd_put_32 (ieee->h.abfd, -current_map->pc, @@ -1917,7 +1917,7 @@ do_one (ieee, current_map, location_ptr, s, iterations) current_map->pc += 4; break; case 2: - if (pcrel == true) + if (pcrel) { #if KEEPMINUSPCININST bfd_put_16 (ieee->h.abfd, (bfd_vma) -current_map->pc, @@ -1941,7 +1941,7 @@ do_one (ieee, current_map, location_ptr, s, iterations) current_map->pc += 2; break; case 1: - if (pcrel == true) + if (pcrel) { #if KEEPMINUSPCININST bfd_put_8 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc); @@ -1969,7 +1969,7 @@ do_one (ieee, current_map, location_ptr, s, iterations) default: { bfd_vma this_size; - if (parse_int (&(ieee->h), &this_size) == true) + if (parse_int (&(ieee->h), &this_size)) { unsigned int i; for (i = 0; i < this_size; i++) @@ -2007,7 +2007,7 @@ ieee_slurp_section_data (abfd) ieee_per_section_type *current_map = (ieee_per_section_type *) NULL; asection *s; /* Seek to the start of the data area */ - if (ieee->read_data == true) + if (ieee->read_data) return true; ieee->read_data = true; ieee_seek (ieee, ieee->w.r.data_part); @@ -2398,10 +2398,9 @@ do_with_relocs (abfd, s) if ((PTR) stream == (PTR) NULL) { /* Outputting a section without data, fill it up */ - stream = (unsigned char *) (bfd_alloc (abfd, s->_raw_size)); + stream = (unsigned char *) bfd_zalloc (abfd, s->_raw_size); if (!stream) return false; - memset ((PTR) stream, 0, (size_t) s->_raw_size); } while (current_byte_index < s->_raw_size) { @@ -2626,7 +2625,7 @@ ieee_mkobject (abfd) output_buffer = 0; amt = sizeof (ieee_data_type); abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, amt); - return abfd->tdata.ieee_data ? true : false; + return abfd->tdata.ieee_data != NULL; } static void @@ -3943,7 +3942,7 @@ ieee_bfd_debug_info_accumulate (abfd, section) if (section->owner->xvec != abfd->xvec) return; /* Only bother once per bfd */ - if (ieee->done_debug == true) + if (ieee->done_debug) return; ieee->done_debug = true; @@ -4010,8 +4009,11 @@ ieee_bfd_debug_info_accumulate (abfd, section) #define ieee_bfd_relax_section bfd_generic_relax_section #define ieee_bfd_gc_sections bfd_generic_gc_sections #define ieee_bfd_merge_sections bfd_generic_merge_sections +#define ieee_bfd_discard_group bfd_generic_discard_group #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create +#define ieee_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols +#define ieee_bfd_link_just_syms _bfd_generic_link_just_syms #define ieee_bfd_final_link _bfd_generic_final_link #define ieee_bfd_link_split_section _bfd_generic_link_split_section @@ -4084,6 +4086,7 @@ const bfd_target ieee_vec = /* ieee_sizeof_headers, ieee_bfd_get_relocated_section_contents, ieee_bfd_relax_section, ieee_bfd_link_hash_table_create, + _bfd_generic_link_hash_table_free, ieee_bfd_link_add_symbols, ieee_bfd_final_link, ieee_bfd_link_split_section, ieee_bfd_gc_sections, ieee_bfd_merge_sections */ diff --git a/contrib/binutils/bfd/ihex.c b/contrib/binutils/bfd/ihex.c index 2e4494d..8188c01 100644 --- a/contrib/binutils/bfd/ihex.c +++ b/contrib/binutils/bfd/ihex.c @@ -3,21 +3,21 @@ Free Software Foundation, Inc. Written by Ian Lance Taylor of Cygnus Support <ian@cygnus.com>. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This is what Intel Hex files look like: @@ -147,12 +147,12 @@ static int ihex_sizeof_headers PARAMS ((bfd *, boolean)); #define CHUNK 16 -/* Macros for converting between hex and binary. */ +/* Macros for converting between hex and binary. */ -#define NIBBLE(x) (hex_value (x)) +#define NIBBLE(x) (hex_value (x)) #define HEX2(buffer) ((NIBBLE ((buffer)[0]) << 4) + NIBBLE ((buffer)[1])) #define HEX4(buffer) ((HEX2 (buffer) << 8) + HEX2 ((buffer) + 2)) -#define ISHEX(x) (hex_p (x)) +#define ISHEX(x) (hex_p (x)) /* When we write out an ihex value, the values can not be output as they are seen. Instead, we hold them in memory in this structure. */ @@ -193,19 +193,16 @@ static boolean ihex_mkobject (abfd) bfd *abfd; { - if (abfd->tdata.ihex_data == NULL) - { - struct ihex_data_struct *tdata; - bfd_size_type amt = sizeof (struct ihex_data_struct); + struct ihex_data_struct *tdata; + bfd_size_type amt = sizeof (struct ihex_data_struct); - tdata = (struct ihex_data_struct *) bfd_alloc (abfd, amt); - if (tdata == NULL) - return false; - abfd->tdata.ihex_data = tdata; - tdata->head = NULL; - tdata->tail = NULL; - } + tdata = (struct ihex_data_struct *) bfd_alloc (abfd, amt); + if (tdata == NULL) + return false; + abfd->tdata.ihex_data = tdata; + tdata->head = NULL; + tdata->tail = NULL; return true; } @@ -288,6 +285,7 @@ ihex_scan (abfd) lineno = 1; error = false; bufsize = 0; + while ((c = ihex_get_byte (abfd, &error)) != EOF) { if (c == '\r') @@ -314,11 +312,9 @@ ihex_scan (abfd) unsigned int chksum; /* This is a data record. */ - pos = bfd_tell (abfd) - 1; /* Read the header bytes. */ - if (bfd_bread (hdr, (bfd_size_type) 8, abfd) != 8) goto error_return; @@ -336,7 +332,6 @@ ihex_scan (abfd) type = HEX2 (hdr + 6); /* Read the data bytes. */ - chars = len * 2 + 2; if (chars >= bufsize) { @@ -515,6 +510,7 @@ static const bfd_target * ihex_object_p (abfd) bfd *abfd; { + PTR tdata_save; bfd_byte b[9]; unsigned int i; unsigned int type; @@ -553,10 +549,14 @@ ihex_object_p (abfd) } /* OK, it looks like it really is an Intel Hex file. */ - - if (! ihex_mkobject (abfd) - || ! ihex_scan (abfd)) - return NULL; + tdata_save = abfd->tdata.any; + if (! ihex_mkobject (abfd) || ! ihex_scan (abfd)) + { + if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL) + bfd_release (abfd, abfd->tdata.any); + abfd->tdata.any = tdata_save; + return NULL; + } return abfd->xvec; } @@ -980,8 +980,11 @@ ihex_sizeof_headers (abfd, exec) #define ihex_bfd_relax_section bfd_generic_relax_section #define ihex_bfd_gc_sections bfd_generic_gc_sections #define ihex_bfd_merge_sections bfd_generic_merge_sections +#define ihex_bfd_discard_group bfd_generic_discard_group #define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create +#define ihex_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols +#define ihex_bfd_link_just_syms _bfd_generic_link_just_syms #define ihex_bfd_final_link _bfd_generic_final_link #define ihex_bfd_link_split_section _bfd_generic_link_split_section diff --git a/contrib/binutils/bfd/libaout.h b/contrib/binutils/bfd/libaout.h index d7e5c71..a76b935 100644 --- a/contrib/binutils/bfd/libaout.h +++ b/contrib/binutils/bfd/libaout.h @@ -302,6 +302,7 @@ enum machine_type { M_ALPHA_NETBSD = 141, /* NetBSD/alpha binary */ M_ARM6_NETBSD = 143, /* NetBSD/arm32 binary */ M_SPARCLET_1 = 147, /* 0x93, reserved */ + M_VAX4K_NETBSD = 150, /* NetBSD/vax 4K pages binary */ M_MIPS1 = 151, /* MIPS R2000/R3000 binary */ M_MIPS2 = 152, /* MIPS R4000/R6000 binary */ M_SPARCLET_2 = 163, /* 0xa3, reserved */ diff --git a/contrib/binutils/bfd/libbfd-in.h b/contrib/binutils/bfd/libbfd-in.h index ed417ca..776dcd6 100644 --- a/contrib/binutils/bfd/libbfd-in.h +++ b/contrib/binutils/bfd/libbfd-in.h @@ -1,7 +1,7 @@ /* libbfd.h -- Declarations used by bfd library *implementation*. (This include file is not for users of the library.) Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001 + 2000, 2001, 2002 Free Software Foundation, Inc. Written by Cygnus Support. @@ -322,10 +322,18 @@ extern boolean _bfd_generic_set_section_contents ((boolean (*) \ PARAMS ((bfd *, struct bfd_link_info *))) \ bfd_false) +#define _bfd_nolink_bfd_discard_group \ + ((boolean (*) \ + PARAMS ((bfd *, struct sec *))) \ + bfd_false) #define _bfd_nolink_bfd_link_hash_table_create \ ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr) +#define _bfd_nolink_bfd_link_hash_table_free \ + ((void (*) PARAMS ((struct bfd_link_hash_table *))) bfd_void) #define _bfd_nolink_bfd_link_add_symbols \ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) +#define _bfd_nolink_bfd_link_just_syms \ + ((void (*) PARAMS ((asection *, struct bfd_link_info *))) bfd_void) #define _bfd_nolink_bfd_final_link \ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) #define _bfd_nolink_bfd_link_split_section \ @@ -389,6 +397,10 @@ extern boolean _bfd_link_hash_table_init extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create PARAMS ((bfd *)); +/* Generic link hash table destruction routine. */ +extern void _bfd_generic_link_hash_table_free + PARAMS ((struct bfd_link_hash_table *)); + /* Generic add symbol routine. */ extern boolean _bfd_generic_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *)); @@ -404,8 +416,6 @@ extern boolean _bfd_generic_link_add_archive_symbols PARAMS ((bfd *, struct bfd_link_info *, boolean (*checkfn) (bfd *, struct bfd_link_info *, boolean *))); - - /* Forward declaration to avoid prototype errors. */ typedef struct bfd_link_hash_entry _bfd_link_hash_entry; @@ -415,6 +425,10 @@ extern boolean _bfd_generic_link_add_one_symbol asection *, bfd_vma, const char *, boolean copy, boolean constructor, struct bfd_link_hash_entry **)); +/* Generic routine to mark section as supplying symbols only. */ +extern void _bfd_generic_link_just_syms + PARAMS ((asection *, struct bfd_link_info *)); + /* Generic link routine. */ extern boolean _bfd_generic_final_link PARAMS ((bfd *, struct bfd_link_info *)); @@ -579,5 +593,3 @@ extern boolean _bfd_sh_align_load_span boolean (*) (bfd *, asection *, PTR, bfd_byte *, bfd_vma), PTR, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, boolean *)); -/* And more follows */ - diff --git a/contrib/binutils/bfd/libbfd.c b/contrib/binutils/bfd/libbfd.c index a397d82..29170a0 100644 --- a/contrib/binutils/bfd/libbfd.c +++ b/contrib/binutils/bfd/libbfd.c @@ -1353,8 +1353,8 @@ _bfd_generic_get_section_contents_in_window (abfd, section, w, offset, count) return bfd_get_section_contents (abfd, section, w->data, offset, count); } if (offset + count > section->_raw_size - || (bfd_get_file_window (abfd, section->filepos + offset, count, w, true) - == false)) + || ! bfd_get_file_window (abfd, section->filepos + offset, count, w, + true)) return false; return true; #else diff --git a/contrib/binutils/bfd/libbfd.h b/contrib/binutils/bfd/libbfd.h index 55d192c..3480114 100644 --- a/contrib/binutils/bfd/libbfd.h +++ b/contrib/binutils/bfd/libbfd.h @@ -6,7 +6,7 @@ /* libbfd.h -- Declarations used by bfd library *implementation*. (This include file is not for users of the library.) Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001 + 2000, 2001, 2002 Free Software Foundation, Inc. Written by Cygnus Support. @@ -327,10 +327,18 @@ extern boolean _bfd_generic_set_section_contents ((boolean (*) \ PARAMS ((bfd *, struct bfd_link_info *))) \ bfd_false) +#define _bfd_nolink_bfd_discard_group \ + ((boolean (*) \ + PARAMS ((bfd *, struct sec *))) \ + bfd_false) #define _bfd_nolink_bfd_link_hash_table_create \ ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr) +#define _bfd_nolink_bfd_link_hash_table_free \ + ((void (*) PARAMS ((struct bfd_link_hash_table *))) bfd_void) #define _bfd_nolink_bfd_link_add_symbols \ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) +#define _bfd_nolink_bfd_link_just_syms \ + ((void (*) PARAMS ((asection *, struct bfd_link_info *))) bfd_void) #define _bfd_nolink_bfd_final_link \ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) #define _bfd_nolink_bfd_link_split_section \ @@ -394,6 +402,10 @@ extern boolean _bfd_link_hash_table_init extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create PARAMS ((bfd *)); +/* Generic link hash table destruction routine. */ +extern void _bfd_generic_link_hash_table_free + PARAMS ((struct bfd_link_hash_table *)); + /* Generic add symbol routine. */ extern boolean _bfd_generic_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *)); @@ -409,8 +421,6 @@ extern boolean _bfd_generic_link_add_archive_symbols PARAMS ((bfd *, struct bfd_link_info *, boolean (*checkfn) (bfd *, struct bfd_link_info *, boolean *))); - - /* Forward declaration to avoid prototype errors. */ typedef struct bfd_link_hash_entry _bfd_link_hash_entry; @@ -420,6 +430,10 @@ extern boolean _bfd_generic_link_add_one_symbol asection *, bfd_vma, const char *, boolean copy, boolean constructor, struct bfd_link_hash_entry **)); +/* Generic routine to mark section as supplying symbols only. */ +extern void _bfd_generic_link_just_syms + PARAMS ((asection *, struct bfd_link_info *)); + /* Generic link routine. */ extern boolean _bfd_generic_final_link PARAMS ((bfd *, struct bfd_link_info *)); @@ -584,14 +598,15 @@ extern boolean _bfd_sh_align_load_span boolean (*) (bfd *, asection *, PTR, bfd_byte *, bfd_vma), PTR, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, boolean *)); -/* And more follows */ - +/* Extracted from init.c. */ +/* Extracted from libbfd.c. */ boolean bfd_write_bigendian_4byte_int PARAMS ((bfd *, unsigned int)); unsigned int bfd_log2 PARAMS ((bfd_vma x)); +/* Extracted from cache.c. */ #define BFD_CACHE_MAX_OPEN 10 extern bfd *bfd_last_cache; @@ -611,6 +626,7 @@ bfd_open_file PARAMS ((bfd *abfd)); FILE * bfd_cache_lookup_worker PARAMS ((bfd *abfd)); +/* Extracted from reloc.c. */ #ifdef _BFD_MAKE_TABLE_bfd_reloc_code_real static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", @@ -722,6 +738,19 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_ALPHA_GPREL_HI16", "BFD_RELOC_ALPHA_GPREL_LO16", "BFD_RELOC_ALPHA_BRSGP", + "BFD_RELOC_ALPHA_TLSGD", + "BFD_RELOC_ALPHA_TLSLDM", + "BFD_RELOC_ALPHA_DTPMOD64", + "BFD_RELOC_ALPHA_GOTDTPREL16", + "BFD_RELOC_ALPHA_DTPREL64", + "BFD_RELOC_ALPHA_DTPREL_HI16", + "BFD_RELOC_ALPHA_DTPREL_LO16", + "BFD_RELOC_ALPHA_DTPREL16", + "BFD_RELOC_ALPHA_GOTTPREL16", + "BFD_RELOC_ALPHA_TPREL64", + "BFD_RELOC_ALPHA_TPREL_HI16", + "BFD_RELOC_ALPHA_TPREL_LO16", + "BFD_RELOC_ALPHA_TPREL16", "BFD_RELOC_MIPS_JMP", "BFD_RELOC_MIPS16_JMP", "BFD_RELOC_MIPS16_GPREL", @@ -752,6 +781,15 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_MIPS_REL16", "BFD_RELOC_MIPS_RELGOT", "BFD_RELOC_MIPS_JALR", + "BFD_RELOC_FRV_LABEL16", + "BFD_RELOC_FRV_LABEL24", + "BFD_RELOC_FRV_LO16", + "BFD_RELOC_FRV_HI16", + "BFD_RELOC_FRV_GPREL12", + "BFD_RELOC_FRV_GPRELU12", + "BFD_RELOC_FRV_GPREL32", + "BFD_RELOC_FRV_GPRELHI", + "BFD_RELOC_FRV_GPRELLO", "BFD_RELOC_386_GOT32", "BFD_RELOC_386_PLT32", @@ -761,6 +799,18 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_386_RELATIVE", "BFD_RELOC_386_GOTOFF", "BFD_RELOC_386_GOTPC", + "BFD_RELOC_386_TLS_TPOFF", + "BFD_RELOC_386_TLS_IE", + "BFD_RELOC_386_TLS_GOTIE", + "BFD_RELOC_386_TLS_LE", + "BFD_RELOC_386_TLS_GD", + "BFD_RELOC_386_TLS_LDM", + "BFD_RELOC_386_TLS_LDO_32", + "BFD_RELOC_386_TLS_IE_32", + "BFD_RELOC_386_TLS_LE_32", + "BFD_RELOC_386_TLS_DTPMOD32", + "BFD_RELOC_386_TLS_DTPOFF32", + "BFD_RELOC_386_TLS_TPOFF32", "BFD_RELOC_X86_64_GOT32", "BFD_RELOC_X86_64_PLT32", "BFD_RELOC_X86_64_COPY", @@ -967,6 +1017,9 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_D30V_21_PCREL_R", "BFD_RELOC_D30V_32", "BFD_RELOC_D30V_32_PCREL", + "BFD_RELOC_DLX_HI16_S", + "BFD_RELOC_DLX_LO16", + "BFD_RELOC_DLX_JMP26", "BFD_RELOC_M32R_24", "BFD_RELOC_M32R_10_PCREL", "BFD_RELOC_M32R_18_PCREL", @@ -1132,12 +1185,25 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_IA64_IPLTMSB", "BFD_RELOC_IA64_IPLTLSB", "BFD_RELOC_IA64_COPY", + "BFD_RELOC_IA64_LTOFF22X", + "BFD_RELOC_IA64_LDXMOV", + "BFD_RELOC_IA64_TPREL14", "BFD_RELOC_IA64_TPREL22", + "BFD_RELOC_IA64_TPREL64I", "BFD_RELOC_IA64_TPREL64MSB", "BFD_RELOC_IA64_TPREL64LSB", - "BFD_RELOC_IA64_LTOFF_TP22", - "BFD_RELOC_IA64_LTOFF22X", - "BFD_RELOC_IA64_LDXMOV", + "BFD_RELOC_IA64_LTOFF_TPREL22", + "BFD_RELOC_IA64_DTPMOD64MSB", + "BFD_RELOC_IA64_DTPMOD64LSB", + "BFD_RELOC_IA64_LTOFF_DTPMOD22", + "BFD_RELOC_IA64_DTPREL14", + "BFD_RELOC_IA64_DTPREL22", + "BFD_RELOC_IA64_DTPREL64I", + "BFD_RELOC_IA64_DTPREL32MSB", + "BFD_RELOC_IA64_DTPREL32LSB", + "BFD_RELOC_IA64_DTPREL64MSB", + "BFD_RELOC_IA64_DTPREL64LSB", + "BFD_RELOC_IA64_LTOFF_DTPREL22", "BFD_RELOC_M68HC11_HI8", "BFD_RELOC_M68HC11_LO8", "BFD_RELOC_M68HC11_3B", @@ -1199,6 +1265,9 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_XSTORMY16_REL_12", "BFD_RELOC_XSTORMY16_24", "BFD_RELOC_XSTORMY16_FPTR16", + "BFD_RELOC_VAX_GLOB_DAT", + "BFD_RELOC_VAX_JMP_SLOT", + "BFD_RELOC_VAX_RELATIVE", "@@overflow: BFD_RELOC_UNUSED@@", }; #endif @@ -1226,6 +1295,7 @@ bfd_generic_get_relocated_section_contents PARAMS ((bfd *abfd, boolean relocateable, asymbol **symbols)); +/* Extracted from archures.c. */ extern const bfd_arch_info_type bfd_default_arch_struct; boolean bfd_default_set_arch_mach PARAMS ((bfd *abfd, @@ -1239,6 +1309,7 @@ bfd_default_compatible PARAMS ((const bfd_arch_info_type *a, boolean bfd_default_scan PARAMS ((const struct bfd_arch_info *info, const char *string)); +/* Extracted from elf.c. */ struct elf_internal_shdr * bfd_elf_find_section PARAMS ((bfd *abfd, char *name)); diff --git a/contrib/binutils/bfd/libcoff-in.h b/contrib/binutils/bfd/libcoff-in.h index bbccbba..efc2fee 100644 --- a/contrib/binutils/bfd/libcoff-in.h +++ b/contrib/binutils/bfd/libcoff-in.h @@ -1,6 +1,6 @@ /* BFD COFF object file private structure. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001 + 2000, 2001, 2002 Free Software Foundation, Inc. Written by Cygnus Support. @@ -580,6 +580,8 @@ extern long _bfd_xcoff_canonicalize_dynamic_reloc PARAMS ((bfd *, arelent **, asymbol **)); extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create PARAMS ((bfd *)); +extern void _bfd_xcoff_bfd_link_hash_table_free + PARAMS ((struct bfd_link_hash_table *)); extern boolean _bfd_xcoff_bfd_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *)); extern boolean _bfd_xcoff_bfd_final_link @@ -596,5 +598,3 @@ extern boolean ppc_allocate_toc_section extern boolean ppc_process_before_allocation PARAMS ((bfd *, struct bfd_link_info *)); -/* And more taken from the source .. */ - diff --git a/contrib/binutils/bfd/libcoff.h b/contrib/binutils/bfd/libcoff.h index f26a692..88b0909 100644 --- a/contrib/binutils/bfd/libcoff.h +++ b/contrib/binutils/bfd/libcoff.h @@ -4,7 +4,7 @@ /* BFD COFF object file private structure. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001 + 2000, 2001, 2002 Free Software Foundation, Inc. Written by Cygnus Support. @@ -584,6 +584,8 @@ extern long _bfd_xcoff_canonicalize_dynamic_reloc PARAMS ((bfd *, arelent **, asymbol **)); extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create PARAMS ((bfd *)); +extern void _bfd_xcoff_bfd_link_hash_table_free + PARAMS ((struct bfd_link_hash_table *)); extern boolean _bfd_xcoff_bfd_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *)); extern boolean _bfd_xcoff_bfd_final_link @@ -600,8 +602,7 @@ extern boolean ppc_allocate_toc_section extern boolean ppc_process_before_allocation PARAMS ((bfd *, struct bfd_link_info *)); -/* And more taken from the source .. */ - +/* Extracted from coffcode.h. */ typedef struct coff_ptr_struct { /* Remembers the offset from the first symbol in the file for diff --git a/contrib/binutils/bfd/libecoff.h b/contrib/binutils/bfd/libecoff.h index 5f9e016..eb90a8c 100644 --- a/contrib/binutils/bfd/libecoff.h +++ b/contrib/binutils/bfd/libecoff.h @@ -1,5 +1,5 @@ /* BFD ECOFF object file private structure. - Copyright 1993, 1994, 1995, 1996, 1999, 2001 + Copyright 1993, 1994, 1995, 1996, 1999, 2001, 2002 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. @@ -330,8 +330,10 @@ extern int _bfd_ecoff_sizeof_headers PARAMS ((bfd *abfd, boolean reloc)); /* ecoff_bfd_relax_section defined by backend. */ extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create PARAMS ((bfd *)); +#define _bfd_ecoff_bfd_link_hash_table_free _bfd_generic_link_hash_table_free extern boolean _bfd_ecoff_bfd_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *)); +#define _bfd_ecoff_bfd_link_just_syms _bfd_generic_link_just_syms extern boolean _bfd_ecoff_bfd_final_link PARAMS ((bfd *, struct bfd_link_info *)); diff --git a/contrib/binutils/bfd/linker.c b/contrib/binutils/bfd/linker.c index 135f46d..242f8bd 100644 --- a/contrib/binutils/bfd/linker.c +++ b/contrib/binutils/bfd/linker.c @@ -1,5 +1,5 @@ /* linker.c -- BFD linker routines - Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support @@ -426,7 +426,7 @@ static void set_symbol_from_hash PARAMS ((asymbol *, struct bfd_link_hash_entry *)); static boolean generic_add_output_symbol PARAMS ((bfd *, size_t *psymalloc, asymbol *)); -static boolean default_fill_link_order +static boolean default_data_link_order PARAMS ((bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *)); static boolean default_indirect_link_order @@ -675,7 +675,7 @@ _bfd_generic_link_hash_table_create (abfd) struct generic_link_hash_table *ret; bfd_size_type amt = sizeof (struct generic_link_hash_table); - ret = (struct generic_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct generic_link_hash_table *) bfd_malloc (amt); if (ret == NULL) return (struct bfd_link_hash_table *) NULL; if (! _bfd_link_hash_table_init (&ret->root, abfd, @@ -687,6 +687,17 @@ _bfd_generic_link_hash_table_create (abfd) return &ret->root; } +void +_bfd_generic_link_hash_table_free (hash) + struct bfd_link_hash_table *hash; +{ + struct generic_link_hash_table *ret + = (struct generic_link_hash_table *) hash; + + bfd_hash_table_free (&ret->root.table); + free (ret); +} + /* Grab the symbols for an object file when doing a generic link. We store the symbols in the outsymbols field. We need to keep them around for the entire link to ensure that we only read them once. @@ -746,6 +757,19 @@ _bfd_generic_link_add_symbols_collect (abfd, info) return generic_link_add_symbols (abfd, info, true); } +/* Indicate that we are only retrieving symbol values from this + section. We want the symbols to act as though the values in the + file are absolute. */ + +void +_bfd_generic_link_just_syms (sec, info) + asection *sec; + struct bfd_link_info *info ATTRIBUTE_UNUSED; +{ + sec->output_section = bfd_abs_section_ptr; + sec->output_offset = sec->vma; +} + /* Add symbols from an object file to the global hash table. */ static boolean @@ -1650,8 +1674,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, abort (); if (! ((*info->callbacks->constructor) - (info, - c == 'I' ? true : false, + (info, c == 'I', h->root.string, abfd, section, value))) return false; } @@ -1789,37 +1812,38 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, /* Fall through. */ case MDEF: /* Handle a multiple definition. */ - { - asection *msec = NULL; - bfd_vma mval = 0; + if (!info->allow_multiple_definition) + { + asection *msec = NULL; + bfd_vma mval = 0; - switch (h->type) - { - case bfd_link_hash_defined: - msec = h->u.def.section; - mval = h->u.def.value; - break; - case bfd_link_hash_indirect: - msec = bfd_ind_section_ptr; - mval = 0; - break; - default: - abort (); - } + switch (h->type) + { + case bfd_link_hash_defined: + msec = h->u.def.section; + mval = h->u.def.value; + break; + case bfd_link_hash_indirect: + msec = bfd_ind_section_ptr; + mval = 0; + break; + default: + abort (); + } - /* Ignore a redefinition of an absolute symbol to the same - value; it's harmless. */ - if (h->type == bfd_link_hash_defined - && bfd_is_abs_section (msec) - && bfd_is_abs_section (section) - && value == mval) - break; + /* Ignore a redefinition of an absolute symbol to the + same value; it's harmless. */ + if (h->type == bfd_link_hash_defined + && bfd_is_abs_section (msec) + && bfd_is_abs_section (section) + && value == mval) + break; - if (! ((*info->callbacks->multiple_definition) - (info, h->root.string, msec->owner, msec, mval, abfd, - section, value))) - return false; - } + if (! ((*info->callbacks->multiple_definition) + (info, h->root.string, msec->owner, msec, mval, + abfd, section, value))) + return false; + } break; case CIND: @@ -1950,12 +1974,12 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, else { char *w; + size_t len = strlen (string) + 1; - w = bfd_hash_allocate (&info->hash->table, - strlen (string) + 1); + w = bfd_hash_allocate (&info->hash->table, len); if (w == NULL) return false; - strcpy (w, string); + memcpy (w, string, len); sub->u.i.warning = w; } @@ -2366,7 +2390,7 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc) Gross. .bss and similar sections won't have the linker_mark field set. */ if ((sym->section->flags & SEC_HAS_CONTENTS) != 0 - && sym->section->linker_mark == false) + && ! sym->section->linker_mark) output = false; if (output) @@ -2611,14 +2635,13 @@ bfd_new_link_order (abfd, section) asection *section; { bfd_size_type amt = sizeof (struct bfd_link_order); - struct bfd_link_order *new = (struct bfd_link_order *) bfd_alloc (abfd, amt); + struct bfd_link_order *new; + + new = (struct bfd_link_order *) bfd_zalloc (abfd, amt); if (!new) return NULL; new->type = bfd_undefined_link_order; - new->offset = 0; - new->size = 0; - new->next = (struct bfd_link_order *) NULL; if (section->link_order_tail != (struct bfd_link_order *) NULL) section->link_order_tail->next = new; @@ -2640,8 +2663,6 @@ _bfd_default_link_order (abfd, info, sec, link_order) asection *sec; struct bfd_link_order *link_order; { - file_ptr loc; - switch (link_order->type) { case bfd_undefined_link_order: @@ -2652,29 +2673,23 @@ _bfd_default_link_order (abfd, info, sec, link_order) case bfd_indirect_link_order: return default_indirect_link_order (abfd, info, sec, link_order, false); - case bfd_fill_link_order: - return default_fill_link_order (abfd, info, sec, link_order); case bfd_data_link_order: - loc = link_order->offset * bfd_octets_per_byte (abfd); - return bfd_set_section_contents (abfd, sec, - (PTR) link_order->u.data.contents, - loc, link_order->size); + return default_data_link_order (abfd, info, sec, link_order); } } -/* Default routine to handle a bfd_fill_link_order. */ +/* Default routine to handle a bfd_data_link_order. */ static boolean -default_fill_link_order (abfd, info, sec, link_order) +default_data_link_order (abfd, info, sec, link_order) bfd *abfd; struct bfd_link_info *info ATTRIBUTE_UNUSED; asection *sec; struct bfd_link_order *link_order; { bfd_size_type size; - unsigned char *space; - size_t i; - unsigned int fill; + size_t fill_size; + bfd_byte *fill; file_ptr loc; boolean result; @@ -2684,24 +2699,37 @@ default_fill_link_order (abfd, info, sec, link_order) if (size == 0) return true; - space = (unsigned char *) bfd_malloc (size); - if (space == NULL) - return false; - - fill = link_order->u.fill.value; - for (i = 0; i < size; i += 4) - space[i] = fill >> 24; - for (i = 1; i < size; i += 4) - space[i] = fill >> 16; - for (i = 2; i < size; i += 4) - space[i] = fill >> 8; - for (i = 3; i < size; i += 4) - space[i] = fill; + fill = link_order->u.data.contents; + fill_size = link_order->u.data.size; + if (fill_size != 0 && fill_size < size) + { + bfd_byte *p; + fill = (bfd_byte *) bfd_malloc (size); + if (fill == NULL) + return false; + p = fill; + if (fill_size == 1) + memset (p, (int) link_order->u.data.contents[0], (size_t) size); + else + { + do + { + memcpy (p, link_order->u.data.contents, fill_size); + p += fill_size; + size -= fill_size; + } + while (size >= fill_size); + if (size != 0) + memcpy (p, link_order->u.data.contents, (size_t) size); + size = link_order->size; + } + } loc = link_order->offset * bfd_octets_per_byte (abfd); - result = bfd_set_section_contents (abfd, sec, space, loc, size); + result = bfd_set_section_contents (abfd, sec, fill, loc, size); - free (space); + if (fill != link_order->u.data.contents) + free (fill); return result; } diff --git a/contrib/binutils/bfd/merge.c b/contrib/binutils/bfd/merge.c index e175efd..ce61207 100644 --- a/contrib/binutils/bfd/merge.c +++ b/contrib/binutils/bfd/merge.c @@ -1,22 +1,22 @@ /* SEC_MERGE support. - Copyright 2001 Free Software Foundation, Inc. + Copyright 2001, 2002 Free Software Foundation, Inc. Written by Jakub Jelinek <jakub@redhat.com>. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This file contains support for merging duplicate entities within sections, as used in ELF SHF_MERGE. */ @@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "sysdep.h" #include "libbfd.h" #include "hashtab.h" +#include "libiberty.h" struct sec_merge_sec_info; @@ -38,7 +39,8 @@ struct sec_merge_hash_entry /* Start of this string needs to be aligned to alignment octets (not 1 << align). */ unsigned int alignment; - union { + union + { /* Index within the merged section. */ bfd_size_type index; /* Entity size (if present in suffix hash tables). */ @@ -144,7 +146,7 @@ sec_merge_hash_newfunc (entry, table, string) ret->next = NULL; } - return (struct bfd_hash_entry *)ret; + return (struct bfd_hash_entry *) ret; } /* Look up an entry in a section merge hash table. */ @@ -381,14 +383,6 @@ _bfd_merge_section (abfd, psinfo, sec, psecinfo) return true; } - if (sec->output_section != NULL - && bfd_is_abs_section (sec->output_section)) - { - /* The section is being discarded from the link, so we should - just ignore it. */ - return true; - } - align = bfd_get_section_alignment (sec->owner, sec); if ((sec->entsize < (unsigned int)(1 << align) && ((sec->entsize & (sec->entsize - 1)) @@ -415,15 +409,14 @@ _bfd_merge_section (abfd, psinfo, sec, psecinfo) if (sinfo == NULL) { /* Initialize the information we need to keep track of. */ - sinfo = (struct sec_merge_info *) - bfd_alloc (abfd, (bfd_size_type) sizeof (struct sec_merge_info)); + amt = sizeof (struct sec_merge_info); + sinfo = (struct sec_merge_info *) bfd_alloc (abfd, amt); if (sinfo == NULL) goto error_return; sinfo->next = (struct sec_merge_info *) *psinfo; sinfo->chain = NULL; *psinfo = (PTR) sinfo; - sinfo->htab = - sec_merge_init (sec->entsize, (sec->flags & SEC_STRINGS)); + sinfo->htab = sec_merge_init (sec->entsize, (sec->flags & SEC_STRINGS)); if (sinfo->htab == NULL) goto error_return; } @@ -650,8 +643,10 @@ merge_strings (sinfo) qsort (array, (size_t) sinfo->htab->size, sizeof (struct sec_merge_hash_entry *), cmplengthentry); - last4tab = htab_create ((size_t) sinfo->htab->size * 4, NULL, last4_eq, NULL); - lasttab = htab_create ((size_t) sinfo->htab->size * 4, NULL, last_eq, NULL); + last4tab = htab_create_alloc ((size_t) sinfo->htab->size * 4, + NULL, last4_eq, NULL, calloc, free); + lasttab = htab_create_alloc ((size_t) sinfo->htab->size * 4, + NULL, last_eq, NULL, calloc, free); if (lasttab == NULL || last4tab == NULL) goto alloc_failure; @@ -839,10 +834,7 @@ _bfd_merge_sections (abfd, xsinfo, remove_hook) the hash table at all. */ for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next) if (secinfo->first == NULL) - { - secinfo->sec->_cooked_size = 0; - secinfo->sec->flags |= SEC_EXCLUDE; - } + secinfo->sec->_cooked_size = 0; } return true; @@ -908,7 +900,7 @@ _bfd_merged_section_offset (output_bfd, psec, psecinfo, offset, addend) if (sec->entsize == 1) { p = secinfo->contents + offset + addend - 1; - while (*p && p >= secinfo->contents) + while (p >= secinfo->contents && *p) --p; ++p; } diff --git a/contrib/binutils/bfd/opncls.c b/contrib/binutils/bfd/opncls.c index 200f6c7..cdf08df 100644 --- a/contrib/binutils/bfd/opncls.c +++ b/contrib/binutils/bfd/opncls.c @@ -5,21 +5,21 @@ Written by Cygnus Support. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -39,9 +39,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* fdopen is a loser -- we should use stdio exclusively. Unfortunately if we do that we can't use fcntl. */ -/* FIXME: This is no longer used. */ -long _bfd_chunksize = -1; - /* Return a new BFD. All BFD's are allocated through this routine. */ bfd * @@ -155,7 +152,6 @@ bfd_openr (filename, target) target_vec = bfd_find_target (target, nbfd); if (target_vec == NULL) { - bfd_set_error (bfd_error_invalid_target); _bfd_delete_bfd (nbfd); return NULL; } @@ -165,7 +161,7 @@ bfd_openr (filename, target) if (bfd_open_file (nbfd) == NULL) { - /* File didn't exist, or some such */ + /* File didn't exist, or some such. */ bfd_set_error (bfd_error_system_call); _bfd_delete_bfd (nbfd); return NULL; @@ -180,8 +176,7 @@ bfd_openr (filename, target) won't cause a storage leak. o - We open the file stream last, since we don't want to have to close it if anything goes wrong. Closing the stream means closing - the file descriptor too, even though we didn't open it. - */ + the file descriptor too, even though we didn't open it. */ /* FUNCTION bfd_fdopenr @@ -220,11 +215,12 @@ bfd_fdopenr (filename, target, fd) bfd_set_error (bfd_error_system_call); #if ! defined(HAVE_FCNTL) || ! defined(F_GETFL) - fdflags = O_RDWR; /* Assume full access */ + fdflags = O_RDWR; /* Assume full access. */ #else fdflags = fcntl (fd, F_GETFL, NULL); #endif - if (fdflags == -1) return NULL; + if (fdflags == -1) + return NULL; nbfd = _bfd_new_bfd (); if (nbfd == NULL) @@ -233,7 +229,6 @@ bfd_fdopenr (filename, target, fd) target_vec = bfd_find_target (target, nbfd); if (target_vec == NULL) { - bfd_set_error (bfd_error_invalid_target); _bfd_delete_bfd (nbfd); return NULL; } @@ -241,7 +236,7 @@ bfd_fdopenr (filename, target, fd) #ifndef HAVE_FDOPEN nbfd->iostream = (PTR) fopen (filename, FOPEN_RB); #else - /* (O_ACCMODE) parens are to avoid Ultrix header file bug */ + /* (O_ACCMODE) parens are to avoid Ultrix header file bug. */ switch (fdflags & (O_ACCMODE)) { case O_RDONLY: nbfd->iostream = (PTR) fdopen (fd, FOPEN_RB); break; @@ -257,14 +252,13 @@ bfd_fdopenr (filename, target, fd) return NULL; } - /* OK, put everything where it belongs */ - + /* OK, put everything where it belongs. */ nbfd->filename = filename; /* As a special case we allow a FD open for read/write to be written through, although doing so requires that we end the previous clause with a preposition. */ - /* (O_ACCMODE) parens are to avoid Ultrix header file bug */ + /* (O_ACCMODE) parens are to avoid Ultrix header file bug. */ switch (fdflags & (O_ACCMODE)) { case O_RDONLY: nbfd->direction = read_direction; break; @@ -313,7 +307,6 @@ bfd_openstreamr (filename, target, streamarg) target_vec = bfd_find_target (target, nbfd); if (target_vec == NULL) { - bfd_set_error (bfd_error_invalid_target); _bfd_delete_bfd (nbfd); return NULL; } @@ -331,10 +324,10 @@ bfd_openstreamr (filename, target, streamarg) return nbfd; } -/** bfd_openw -- open for writing. - Returns a pointer to a freshly-allocated BFD on success, or NULL. +/* bfd_openw -- open for writing. + Returns a pointer to a freshly-allocated BFD on success, or NULL. - See comment by bfd_fdopenr before you try to modify this function. */ + See comment by bfd_fdopenr before you try to modify this function. */ /* FUNCTION @@ -359,11 +352,8 @@ bfd_openw (filename, target) bfd *nbfd; const bfd_target *target_vec; - bfd_set_error (bfd_error_system_call); - /* nbfd has to point to head of malloc'ed block so that bfd_close may - reclaim it correctly. */ - + reclaim it correctly. */ nbfd = _bfd_new_bfd (); if (nbfd == NULL) return NULL; @@ -380,7 +370,8 @@ bfd_openw (filename, target) if (bfd_open_file (nbfd) == NULL) { - bfd_set_error (bfd_error_system_call); /* File not writeable, etc */ + /* File not writeable, etc. */ + bfd_set_error (bfd_error_system_call); _bfd_delete_bfd (nbfd); return NULL; } @@ -419,7 +410,7 @@ bfd_close (abfd) { boolean ret; - if (!bfd_read_p (abfd)) + if (bfd_write_p (abfd)) { if (! BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd))) return false; @@ -431,7 +422,7 @@ bfd_close (abfd) ret = bfd_cache_close (abfd); /* If the file was open for writing and is now executable, - make it so */ + make it so. */ if (ret && abfd->direction == write_direction && abfd->flags & EXEC_P) @@ -441,6 +432,7 @@ bfd_close (abfd) if (stat (abfd->filename, &buf) == 0) { unsigned int mask = umask (0); + umask (mask); chmod (abfd->filename, (0777 @@ -473,7 +465,6 @@ DESCRIPTION RETURNS <<true>> is returned if all is ok, otherwise <<false>>. - */ boolean @@ -485,7 +476,7 @@ bfd_close_all_done (abfd) ret = bfd_cache_close (abfd); /* If the file was open for writing and is now executable, - make it so */ + make it so. */ if (ret && abfd->direction == write_direction && abfd->flags & EXEC_P) @@ -495,6 +486,7 @@ bfd_close_all_done (abfd) if (stat (abfd->filename, &buf) == 0) { unsigned int mask = umask (0); + umask (mask); chmod (abfd->filename, (0777 @@ -519,7 +511,6 @@ DESCRIPTION <<bfd_openw>>, but without opening a file. The new BFD takes the target from the target used by @var{template}. The format is always set to <<bfd_object>>. - */ bfd * @@ -537,6 +528,7 @@ bfd_create (filename, templ) nbfd->xvec = templ->xvec; nbfd->direction = no_direction; bfd_set_format (nbfd, bfd_object); + return nbfd; } @@ -572,7 +564,7 @@ bfd_make_writable(abfd) bim = ((struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (struct bfd_in_memory))); abfd->iostream = (PTR) bim; - /* bfd_bwrite will grow these as needed */ + /* bfd_bwrite will grow these as needed. */ bim->size = 0; bim->buffer = 0; @@ -639,7 +631,7 @@ bfd_make_readable(abfd) abfd->tdata.any = 0; bfd_section_list_clear (abfd); - bfd_check_format(abfd, bfd_object); + bfd_check_format (abfd, bfd_object); return true; } diff --git a/contrib/binutils/bfd/pe-i386.c b/contrib/binutils/bfd/pe-i386.c index 7ced147..9c75f95 100644 --- a/contrib/binutils/bfd/pe-i386.c +++ b/contrib/binutils/bfd/pe-i386.c @@ -1,21 +1,21 @@ /* BFD back-end for Intel 386 PECOFF files. - Copyright 1995, 1996, 1999, 2001 Free Software Foundation, Inc. + Copyright 1995, 1996, 1999, 2001, 2002 Free Software Foundation, Inc. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -29,6 +29,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define COFF_LONG_FILENAMES #define COFF_SECTION_ALIGNMENT_ENTRIES \ +{ COFF_SECTION_NAME_EXACT_MATCH (".bss"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ +{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ +{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ { COFF_SECTION_NAME_PARTIAL_MATCH (".idata"), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \ { COFF_SECTION_NAME_EXACT_MATCH (".pdata"), \ diff --git a/contrib/binutils/bfd/peXXigen.c b/contrib/binutils/bfd/peXXigen.c index 04b7419..b643f3c 100644 --- a/contrib/binutils/bfd/peXXigen.c +++ b/contrib/binutils/bfd/peXXigen.c @@ -3,21 +3,21 @@ Free Software Foundation, Inc. Written by Cygnus Solutions. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Most of this hacked by Steve Chamberlain <sac@cygnus.com>. @@ -620,7 +620,7 @@ _bfd_XXi_swap_aouthdr_out (abfd, in, out) extra->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES; /* first null out all data directory entries .. */ - memset (extra->DataDirectory, sizeof (extra->DataDirectory), 0); + memset (extra->DataDirectory, 0, sizeof (extra->DataDirectory)); add_data_entry (abfd, extra, 0, ".edata", ib); @@ -1142,6 +1142,7 @@ pe_print_idata (abfd, vfile) adj = section->vma - extra->ImageBase; + /* Print all image import descriptors. */ for (i = 0; i < datasize; i += onaline) { bfd_vma hint_addr; @@ -1153,7 +1154,7 @@ pe_print_idata (abfd, vfile) bfd_size_type j; char *dll; - /* print (i + extra->DataDirectory[1].VirtualAddress) */ + /* Print (i + extra->DataDirectory[1].VirtualAddress). */ fprintf (file, " %08lx\t", (unsigned long) (i + adj + dataoff)); #if 0 if (i + 20 > datasize) @@ -1181,19 +1182,83 @@ pe_print_idata (abfd, vfile) if (hint_addr != 0) { - fprintf (file, _("\tvma: Hint/Ord Member-Name\n")); + bfd_byte *ft_data; + asection *ft_section; + bfd_vma ft_addr; + bfd_size_type ft_datasize; + int ft_idx; + int ft_allocated = 0; + + fprintf (file, _("\tvma: Hint/Ord Member-Name Bound-To\n")); idx = hint_addr - adj; + + ft_addr = first_thunk + extra->ImageBase; + ft_data = data; + ft_idx = first_thunk - adj; + ft_allocated = 0; + + if (first_thunk != hint_addr) + { + /* Find the section which contains the first thunk. */ + for (ft_section = abfd->sections; + ft_section != NULL; + ft_section = ft_section->next) + { + ft_datasize = bfd_section_size (abfd, ft_section); + if (ft_addr >= ft_section->vma + && ft_addr < ft_section->vma + ft_datasize) + break; + } + + if (ft_section == NULL) + { + fprintf (file, + _("\nThere is a first thunk, but the section containing it could not be found\n")); + continue; + } + + /* Now check to see if this section is the same as our current + section. If it is not then we will have to load its data in. */ + if (ft_section == section) + { + ft_data = data; + ft_idx = first_thunk - adj; + } + else + { + ft_idx = first_thunk - (ft_section->vma - extra->ImageBase); + ft_data = (bfd_byte *) bfd_malloc (datasize); + if (ft_data == NULL) + continue; + + /* Read datasize bfd_bytes starting at offset ft_idx. */ + if (! bfd_get_section_contents (abfd, ft_section, + (PTR) ft_data, + (bfd_vma) ft_idx, + datasize)) + { + free (ft_data); + continue; + } + + ft_idx = 0; + ft_allocated = 1; + } + } + /* Print HintName vector entries. */ for (j = 0; j < datasize; j += 4) { unsigned long member = bfd_get_32 (abfd, data + idx + j); + /* Print single IMAGE_IMPORT_BY_NAME vector. */ if (member == 0) break; + if (member & 0x80000000) - fprintf (file, "\t%04lx\t %4lu", member, - member & 0x7fffffff); + fprintf (file, "\t%04lx\t %4lu <none>", + member, member & 0x7fffffff); else { int ordinal; @@ -1206,69 +1271,18 @@ pe_print_idata (abfd, vfile) } /* If the time stamp is not zero, the import address - table holds actual addresses. */ + table holds actual addresses. */ if (time_stamp != 0 && first_thunk != 0 && first_thunk != hint_addr) fprintf (file, "\t%04lx", - (long) bfd_get_32 (abfd, data + first_thunk - adj + j)); + (long) bfd_get_32 (abfd, ft_data + ft_idx + j)); fprintf (file, "\n"); } - } - - if (hint_addr != first_thunk && time_stamp == 0) - { - int differ = 0; - int idx2; - - idx2 = first_thunk - adj; - - for (j = 0; j < datasize; j += 4) - { - int ordinal; - char *member_name; - bfd_vma hint_member = 0; - bfd_vma iat_member; - - if (hint_addr != 0) - hint_member = bfd_get_32 (abfd, data + idx + j); - iat_member = bfd_get_32 (abfd, data + idx2 + j); - - if (hint_addr == 0 && iat_member == 0) - break; - - if (hint_addr == 0 || hint_member != iat_member) - { - if (differ == 0) - { - fprintf (file, - _("\tThe Import Address Table (difference found)\n")); - fprintf (file, _("\tvma: Hint/Ord Member-Name\n")); - differ = 1; - } - - if (iat_member == 0) - fprintf (file, - _("\t>>> Ran out of IAT members!\n")); - else - { - ordinal = bfd_get_16 (abfd, data + iat_member - adj); - member_name = (char *) data + iat_member - adj + 2; - fprintf (file, "\t%04lx\t %4d %s\n", - (unsigned long) iat_member, - ordinal, - member_name); - } - } - - if (hint_addr != 0 && hint_member == 0) - break; - } - if (differ == 0) - fprintf (file, - _("\tThe Import Address Table is identical\n")); + if (ft_allocated) + free (ft_data); } fprintf (file, "\n"); diff --git a/contrib/binutils/bfd/po/SRC-POTFILES.in b/contrib/binutils/bfd/po/SRC-POTFILES.in index f3f1d26..e448599 100644 --- a/contrib/binutils/bfd/po/SRC-POTFILES.in +++ b/contrib/binutils/bfd/po/SRC-POTFILES.in @@ -1,4 +1,5 @@ aix386-core.c +aix5ppc-core.c aout-adobe.c aout-arm.c aout-cris.c @@ -64,7 +65,9 @@ cpu-avr.c cpu-cris.c cpu-d10v.c cpu-d30v.c +cpu-dlx.c cpu-fr30.c +cpu-frv.c cpu-h8300.c cpu-h8500.c cpu-hppa.c @@ -123,13 +126,16 @@ elf32-avr.c elf32-cris.c elf32-d10v.c elf32-d30v.c +elf32-dlx.c elf32-fr30.c +elf32-frv.c elf32-gen.c elf32-h8300.c elf32-hppa.c elf32-hppa.h elf32-i370.c elf32-i386.c +elf32-i386qnx.c elf32-i860.c elf32-i960.c elf32-m32r.c @@ -147,9 +153,12 @@ elf32-s390.c elf32-sh-lin.c elf32-sh-nbsd.c elf32-sh.c +elf32-sh64-com.c +elf32-sh64-nbsd.c elf32-sh64.c elf32-sparc.c elf32-v850.c +elf32-vax.c elf32-xstormy16.c elf32.c elf64-alpha.c @@ -160,6 +169,7 @@ elf64-mips.c elf64-mmix.c elf64-ppc.c elf64-s390.c +elf64-sh64-nbsd.c elf64-sh64.c elf64-sparc.c elf64-x86-64.c @@ -170,6 +180,7 @@ elfcode.h elfcore.h elflink.c elflink.h +elfxx-mips.c epoc-pe-arm.c epoc-pei-arm.c format.c @@ -266,6 +277,8 @@ syms.c targets.c tekhex.c trad-core.c +vax1knetbsd.c +vaxbsd.c vaxnetbsd.c versados.c version.h diff --git a/contrib/binutils/bfd/po/bfd.pot b/contrib/binutils/bfd/po/bfd.pot index 8471c0c..2b9a34a 100644 --- a/contrib/binutils/bfd/po/bfd.pot +++ b/contrib/binutils/bfd/po/bfd.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2002-02-08 03:22-0200\n" +"POT-Creation-Date: 2002-07-23 15:55-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: aout-adobe.c:196 +#: aout-adobe.c:197 #, c-format msgid "%s: Unknown section type in a.out.adobe file: %x\n" msgstr "" @@ -49,7 +49,7 @@ msgstr "" msgid "*unknown*" msgstr "" -#: aoutx.h:3735 +#: aoutx.h:3732 #, c-format msgid "%s: relocateable link from %s to %s not supported" msgstr "" @@ -179,7 +179,7 @@ msgstr "" msgid "Missing IHIHALF" msgstr "" -#: coff-a29k.c:212 coff-or32.c:228 +#: coff-a29k.c:212 coff-or32.c:229 msgid "Unrecognized reloc" msgstr "" @@ -191,7 +191,7 @@ msgstr "" msgid "missing IHIHALF reloc" msgstr "" -#: coff-alpha.c:881 coff-alpha.c:918 coff-alpha.c:1989 coff-mips.c:1433 +#: coff-alpha.c:881 coff-alpha.c:918 coff-alpha.c:1989 coff-mips.c:1432 msgid "GP relative relocation used when GP not defined" msgstr "" @@ -199,129 +199,129 @@ msgstr "" msgid "using multiple gp values" msgstr "" -#: coff-arm.c:1051 elf32-arm.h:285 +#: coff-arm.c:1066 elf32-arm.h:285 #, c-format msgid "%s: unable to find THUMB glue '%s' for `%s'" msgstr "" -#: coff-arm.c:1080 elf32-arm.h:320 +#: coff-arm.c:1096 elf32-arm.h:320 #, c-format msgid "%s: unable to find ARM glue '%s' for `%s'" msgstr "" -#: coff-arm.c:1375 coff-arm.c:1470 elf32-arm.h:886 elf32-arm.h:990 +#: coff-arm.c:1391 coff-arm.c:1486 elf32-arm.h:887 elf32-arm.h:991 #, c-format msgid "%s(%s): warning: interworking not enabled." msgstr "" -#: coff-arm.c:1379 elf32-arm.h:993 +#: coff-arm.c:1395 elf32-arm.h:994 #, c-format msgid " first occurrence: %s: arm call to thumb" msgstr "" -#: coff-arm.c:1474 elf32-arm.h:889 +#: coff-arm.c:1490 elf32-arm.h:890 #, c-format msgid " first occurrence: %s: thumb call to arm" msgstr "" -#: coff-arm.c:1477 +#: coff-arm.c:1493 msgid " consider relinking with --support-old-code enabled" msgstr "" -#: coff-arm.c:1767 coff-tic80.c:686 cofflink.c:3017 +#: coff-arm.c:1785 coff-tic80.c:686 cofflink.c:3031 #, c-format msgid "%s: bad reloc address 0x%lx in section `%s'" msgstr "" -#: coff-arm.c:2107 +#: coff-arm.c:2127 #, c-format msgid "%s: illegal symbol index in reloc: %d" msgstr "" -#: coff-arm.c:2235 +#: coff-arm.c:2255 #, c-format msgid "ERROR: %s is compiled for APCS-%d, whereas %s is compiled for APCS-%d" msgstr "" -#: coff-arm.c:2250 elf32-arm.h:2287 +#: coff-arm.c:2270 elf32-arm.h:2297 #, c-format msgid "" "ERROR: %s passes floats in float registers, whereas %s passes them in " "integer registers" msgstr "" -#: coff-arm.c:2253 elf32-arm.h:2292 +#: coff-arm.c:2273 elf32-arm.h:2302 #, c-format msgid "" "ERROR: %s passes floats in integer registers, whereas %s passes them in " "float registers" msgstr "" -#: coff-arm.c:2268 +#: coff-arm.c:2288 #, c-format msgid "" "ERROR: %s is compiled as position independent code, whereas target %s is " "absolute position" msgstr "" -#: coff-arm.c:2271 +#: coff-arm.c:2291 #, c-format msgid "" "ERROR: %s is compiled as absolute position code, whereas target %s is " "position independent" msgstr "" -#: coff-arm.c:2300 elf32-arm.h:2348 +#: coff-arm.c:2320 elf32-arm.h:2358 #, c-format msgid "Warning: %s supports interworking, whereas %s does not" msgstr "" -#: coff-arm.c:2303 elf32-arm.h:2355 +#: coff-arm.c:2323 elf32-arm.h:2365 #, c-format msgid "Warning: %s does not support interworking, whereas %s does" msgstr "" -#: coff-arm.c:2330 +#: coff-arm.c:2350 #, c-format msgid "private flags = %x:" msgstr "" -#: coff-arm.c:2338 elf32-arm.h:2408 +#: coff-arm.c:2358 elf32-arm.h:2418 msgid " [floats passed in float registers]" msgstr "" -#: coff-arm.c:2340 +#: coff-arm.c:2360 msgid " [floats passed in integer registers]" msgstr "" -#: coff-arm.c:2343 elf32-arm.h:2411 +#: coff-arm.c:2363 elf32-arm.h:2421 msgid " [position independent]" msgstr "" -#: coff-arm.c:2345 +#: coff-arm.c:2365 msgid " [absolute position]" msgstr "" -#: coff-arm.c:2349 +#: coff-arm.c:2369 msgid " [interworking flag not initialised]" msgstr "" -#: coff-arm.c:2351 +#: coff-arm.c:2371 msgid " [interworking supported]" msgstr "" -#: coff-arm.c:2353 +#: coff-arm.c:2373 msgid " [interworking not supported]" msgstr "" -#: coff-arm.c:2401 elf32-arm.h:2114 +#: coff-arm.c:2421 elf32-arm.h:2124 #, c-format msgid "" "Warning: Not setting interworking flag of %s since it has already been " "specified as non-interworking" msgstr "" -#: coff-arm.c:2405 elf32-arm.h:2118 +#: coff-arm.c:2425 elf32-arm.h:2128 #, c-format msgid "Warning: Clearing the interworking flag of %s due to outside request" msgstr "" @@ -330,35 +330,35 @@ msgstr "" msgid "uncertain calling convention for non-COFF symbol" msgstr "" -#: coff-m68k.c:481 coff-mips.c:2431 elf32-m68k.c:2212 elf32-mips.c:9967 +#: coff-m68k.c:481 coff-mips.c:2429 elf32-m68k.c:2157 elf32-mips.c:1844 msgid "unsupported reloc type" msgstr "" -#: coff-mips.c:875 elf32-mips.c:1997 elf64-mips.c:1739 +#: coff-mips.c:874 elf32-mips.c:1062 elf64-mips.c:1609 msgid "GP relative relocation when _gp not defined" msgstr "" #. No other sections should appear in -membedded-pic #. code. -#: coff-mips.c:2468 +#: coff-mips.c:2466 msgid "reloc against unsupported section" msgstr "" -#: coff-mips.c:2476 +#: coff-mips.c:2474 msgid "reloc not properly aligned" msgstr "" -#: coff-rs6000.c:2710 coff64-rs6000.c:1164 +#: coff-rs6000.c:2766 #, c-format msgid "%s: unsupported relocation type 0x%02x" msgstr "" -#: coff-rs6000.c:2756 coff64-rs6000.c:1210 +#: coff-rs6000.c:2859 #, c-format msgid "%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry" msgstr "" -#: coff-rs6000.c:3006 coff64-rs6000.c:2060 +#: coff-rs6000.c:3590 coff64-rs6000.c:2091 #, c-format msgid "%s: symbol `%s' has unrecognized smclas %d" msgstr "" @@ -368,7 +368,7 @@ msgstr "" msgid "Unrecognized reloc type 0x%x" msgstr "" -#: coff-tic54x.c:390 coffcode.h:4874 +#: coff-tic54x.c:390 coffcode.h:4974 #, c-format msgid "%s: warning: illegal symbol index %ld in relocs" msgstr "" @@ -378,37 +378,37 @@ msgstr "" msgid "ignoring reloc %s\n" msgstr "" -#: coffcode.h:1081 +#: coffcode.h:1086 #, c-format msgid "%s (%s): Section flag %s (0x%x) ignored" msgstr "" -#: coffcode.h:2137 +#: coffcode.h:2143 #, c-format msgid "Unrecognized TI COFF target id '0x%x'" msgstr "" -#: coffcode.h:4263 +#: coffcode.h:4365 #, c-format msgid "%s: warning: illegal symbol index %ld in line numbers" msgstr "" -#: coffcode.h:4277 +#: coffcode.h:4379 #, c-format msgid "%s: warning: duplicate line number information for `%s'" msgstr "" -#: coffcode.h:4636 +#: coffcode.h:4736 #, c-format msgid "%s: Unrecognized storage class %d for %s symbol `%s'" msgstr "" -#: coffcode.h:4767 +#: coffcode.h:4867 #, c-format msgid "warning: %s: local symbol `%s' has no section" msgstr "" -#: coffcode.h:4912 +#: coffcode.h:5012 #, c-format msgid "%s: illegal relocation type %d at address 0x%lx" msgstr "" @@ -418,186 +418,187 @@ msgstr "" msgid "%s: bad string table size %lu" msgstr "" -#: cofflink.c:536 elflink.h:1967 +#: cofflink.c:534 elflink.h:1912 #, c-format msgid "Warning: type of symbol `%s' changed from %d to %d in %s" msgstr "" -#: cofflink.c:2317 +#: cofflink.c:2321 #, c-format msgid "%s: relocs in section `%s', but it has no contents" msgstr "" -#: cofflink.c:2653 coffswap.h:889 +#: cofflink.c:2664 coffswap.h:877 #, c-format msgid "%s: %s: reloc overflow: 0x%lx > 0xffff" msgstr "" -#: cofflink.c:2662 coffswap.h:876 +#: cofflink.c:2673 coffswap.h:864 #, c-format msgid "%s: warning: %s: line number overflow: 0x%lx > 0xffff" msgstr "" -#: dwarf2.c:381 +#: dwarf2.c:382 msgid "Dwarf Error: Can't find .debug_str section." msgstr "" -#: dwarf2.c:398 +#: dwarf2.c:399 #, c-format msgid "" -"Dwarf Error: DW_FORM_strp offset (%u) greater than or equal to .debug_str " -"size (%u)." +"Dwarf Error: DW_FORM_strp offset (%lu) greater than or equal to .debug_str " +"size (%lu)." msgstr "" -#: dwarf2.c:542 +#: dwarf2.c:543 msgid "Dwarf Error: Can't find .debug_abbrev section." msgstr "" -#: dwarf2.c:559 +#: dwarf2.c:560 #, c-format msgid "" -"Dwarf Error: Abbrev offset (%u) greater than or equal to .debug_abbrev size " -"(%u)." +"Dwarf Error: Abbrev offset (%lu) greater than or equal to .debug_abbrev size " +"(%lu)." msgstr "" -#: dwarf2.c:756 +#: dwarf2.c:757 #, c-format -msgid "Dwarf Error: Invalid or unhandled FORM value: %d." +msgid "Dwarf Error: Invalid or unhandled FORM value: %u." msgstr "" -#: dwarf2.c:843 +#: dwarf2.c:852 msgid "Dwarf Error: mangled line number section (bad file number)." msgstr "" -#: dwarf2.c:929 +#: dwarf2.c:938 msgid "Dwarf Error: Can't find .debug_line section." msgstr "" -#: dwarf2.c:952 +#: dwarf2.c:961 #, c-format msgid "" -"Dwarf Error: Line offset (%u) greater than or equal to .debug_line size (%u)." +"Dwarf Error: Line offset (%lu) greater than or equal to .debug_line size (%" +"lu)." msgstr "" -#: dwarf2.c:1143 +#: dwarf2.c:1159 msgid "Dwarf Error: mangled line number section." msgstr "" -#: dwarf2.c:1318 dwarf2.c:1529 +#: dwarf2.c:1355 dwarf2.c:1566 #, c-format -msgid "Dwarf Error: Could not find abbrev number %d." +msgid "Dwarf Error: Could not find abbrev number %u." msgstr "" -#: dwarf2.c:1490 +#: dwarf2.c:1527 #, c-format msgid "" -"Dwarf Error: found dwarf version '%hu', this reader only handles version 2 " +"Dwarf Error: found dwarf version '%u', this reader only handles version 2 " "information." msgstr "" -#: dwarf2.c:1497 +#: dwarf2.c:1534 #, c-format msgid "" "Dwarf Error: found address size '%u', this reader can not handle sizes " "greater than '%u'." msgstr "" -#: dwarf2.c:1520 +#: dwarf2.c:1557 #, c-format -msgid "Dwarf Error: Bad abbrev number: %d." +msgid "Dwarf Error: Bad abbrev number: %u." msgstr "" -#: ecoff.c:1328 +#: ecoff.c:1318 #, c-format msgid "Unknown basic type %d" msgstr "" -#: ecoff.c:1597 +#: ecoff.c:1578 #, c-format msgid "" "\n" " End+1 symbol: %ld" msgstr "" -#: ecoff.c:1604 ecoff.c:1607 +#: ecoff.c:1585 ecoff.c:1588 #, c-format msgid "" "\n" " First symbol: %ld" msgstr "" -#: ecoff.c:1619 +#: ecoff.c:1600 #, c-format msgid "" "\n" " End+1 symbol: %-7ld Type: %s" msgstr "" -#: ecoff.c:1626 +#: ecoff.c:1607 #, c-format msgid "" "\n" " Local symbol: %ld" msgstr "" -#: ecoff.c:1634 +#: ecoff.c:1615 #, c-format msgid "" "\n" " struct; End+1 symbol: %ld" msgstr "" -#: ecoff.c:1639 +#: ecoff.c:1620 #, c-format msgid "" "\n" " union; End+1 symbol: %ld" msgstr "" -#: ecoff.c:1644 +#: ecoff.c:1625 #, c-format msgid "" "\n" " enum; End+1 symbol: %ld" msgstr "" -#: ecoff.c:1650 +#: ecoff.c:1631 #, c-format msgid "" "\n" " Type: %s" msgstr "" -#: elf-hppa.h:1366 elf-hppa.h:1399 elf32-ppc.c:3062 elf32-sh.c:4286 -#: elf64-sh64.c:1640 elf64-x86-64.c:1275 +#: elf-hppa.h:1476 elf-hppa.h:1509 elf32-ppc.c:3091 elf32-sh.c:4213 +#: elf64-sh64.c:1659 #, c-format msgid "" "%s: warning: unresolvable relocation against symbol `%s' from %s section" msgstr "" -#: elf-m10200.c:463 elf-m10300.c:673 elf32-arm.h:2074 elf32-avr.c:835 -#: elf32-cris.c:1406 elf32-d10v.c:482 elf32-fr30.c:653 elf32-h8300.c:547 -#: elf32-i860.c:1048 elf32-m32r.c:1280 elf32-openrisc.c:455 elf32-v850.c:1691 -#: elf32-xstormy16.c:976 elf64-mmix.c:1302 +#: elf-m10200.c:446 elf-m10300.c:656 elf32-arm.h:2084 elf32-avr.c:833 +#: elf32-cris.c:1403 elf32-d10v.c:481 elf32-fr30.c:635 elf32-frv.c:809 +#: elf32-h8300.c:548 elf32-i860.c:1031 elf32-m32r.c:1278 elf32-openrisc.c:439 +#: elf32-v850.c:1691 elf32-xstormy16.c:933 elf64-mmix.c:1302 msgid "internal error: out of range error" msgstr "" -#: elf-m10200.c:467 elf-m10300.c:677 elf32-arm.h:2078 elf32-avr.c:839 -#: elf32-cris.c:1410 elf32-d10v.c:486 elf32-fr30.c:657 elf32-h8300.c:551 -#: elf32-i860.c:1052 elf32-m32r.c:1284 elf32-mips.c:7600 elf32-openrisc.c:459 -#: elf32-v850.c:1695 elf32-xstormy16.c:980 elf64-mips.c:4464 elf64-mmix.c:1306 +#: elf-m10200.c:450 elf-m10300.c:660 elf32-arm.h:2088 elf32-avr.c:837 +#: elf32-cris.c:1407 elf32-d10v.c:485 elf32-fr30.c:639 elf32-frv.c:813 +#: elf32-h8300.c:552 elf32-i860.c:1035 elf32-m32r.c:1282 elf32-openrisc.c:443 +#: elf32-v850.c:1695 elf32-xstormy16.c:937 elf64-mmix.c:1306 elfxx-mips.c:5264 msgid "internal error: unsupported relocation error" msgstr "" -#: elf-m10200.c:471 elf-m10300.c:681 elf32-arm.h:2082 elf32-d10v.c:490 -#: elf32-h8300.c:555 elf32-m32r.c:1288 +#: elf-m10200.c:454 elf-m10300.c:664 elf32-arm.h:2092 elf32-d10v.c:489 +#: elf32-h8300.c:556 elf32-m32r.c:1286 msgid "internal error: dangerous error" msgstr "" -#: elf-m10200.c:475 elf-m10300.c:685 elf32-arm.h:2086 elf32-avr.c:847 -#: elf32-cris.c:1418 elf32-d10v.c:494 elf32-fr30.c:665 elf32-h8300.c:559 -#: elf32-i860.c:1060 elf32-m32r.c:1292 elf32-openrisc.c:467 elf32-v850.c:1715 -#: elf32-xstormy16.c:988 elf64-mmix.c:1314 +#: elf-m10200.c:458 elf-m10300.c:668 elf32-arm.h:2096 elf32-avr.c:845 +#: elf32-cris.c:1415 elf32-d10v.c:493 elf32-fr30.c:647 elf32-frv.c:821 +#: elf32-h8300.c:560 elf32-i860.c:1043 elf32-m32r.c:1290 elf32-openrisc.c:451 +#: elf32-v850.c:1715 elf32-xstormy16.c:945 elf64-mmix.c:1314 msgid "internal error: unknown error" msgstr "" @@ -606,221 +607,222 @@ msgstr "" msgid "%s: invalid string offset %u >= %lu for section `%s'" msgstr "" -#: elf.c:448 +#: elf.c:589 #, c-format msgid "%s: invalid SHT_GROUP entry" msgstr "" -#: elf.c:529 +#: elf.c:660 #, c-format msgid "%s: no group info for section %s" msgstr "" -#: elf.c:840 +#: elf.c:1023 msgid "" "\n" "Program Header:\n" msgstr "" -#: elf.c:889 +#: elf.c:1073 msgid "" "\n" "Dynamic Section:\n" msgstr "" -#: elf.c:1018 +#: elf.c:1202 msgid "" "\n" "Version definitions:\n" msgstr "" -#: elf.c:1041 +#: elf.c:1225 msgid "" "\n" "Version References:\n" msgstr "" -#: elf.c:1046 +#: elf.c:1230 #, c-format msgid " required from %s:\n" msgstr "" -#: elf.c:1682 +#: elf.c:1902 #, c-format msgid "%s: invalid link %lu for reloc section %s (index %u)" msgstr "" -#: elf.c:3296 +#: elf.c:3603 #, c-format msgid "%s: Not enough room for program headers (allocated %u, need %u)" msgstr "" -#: elf.c:3400 +#: elf.c:3708 #, c-format msgid "%s: Not enough room for program headers, try linking with -N" msgstr "" -#: elf.c:3525 +#: elf.c:3833 #, c-format msgid "" "Error: First section in segment (%s) starts at 0x%x whereas the segment " "starts at 0x%x" msgstr "" -#: elf.c:3811 +#: elf.c:4148 #, c-format msgid "%s: warning: allocated section `%s' not in segment" msgstr "" -#: elf.c:4142 +#: elf.c:4472 #, c-format msgid "%s: symbol `%s' required but not present" msgstr "" -#: elf.c:4395 +#: elf.c:4749 #, c-format -msgid "%s: warning: Empty loadable segment detected\n" +msgid "%s: warning: Empty loadable segment detected, is this intentional ?\n" msgstr "" -#: elf.c:5808 +#: elf.c:6193 #, c-format msgid "%s: unsupported relocation type %s" msgstr "" -#: elf32-arm.h:1224 +#: elf32-arm.h:1221 #, c-format msgid "%s: Warning: Arm BLX instruction targets Arm function '%s'." msgstr "" -#: elf32-arm.h:1420 +#: elf32-arm.h:1417 #, c-format msgid "%s: Warning: Thumb BLX instruction targets thumb function '%s'." msgstr "" -#: elf32-arm.h:1904 elf32-i386.c:1782 elf32-sh.c:4198 +#: elf32-arm.h:1914 elf32-sh.c:4125 #, c-format msgid "%s(%s+0x%lx): %s relocation against SEC_MERGE section" msgstr "" -#: elf32-arm.h:1998 +#: elf32-arm.h:2008 #, c-format msgid "" "%s: warning: unresolvable relocation %d against symbol `%s' from %s section" msgstr "" -#: elf32-arm.h:2166 +#: elf32-arm.h:2176 #, c-format msgid "" "Warning: Clearing the interworking flag of %s because non-interworking code " "in %s has been linked with it" msgstr "" -#: elf32-arm.h:2261 +#: elf32-arm.h:2271 #, c-format msgid "" "ERROR: %s is compiled for EABI version %d, whereas %s is compiled for " "version %d" msgstr "" -#: elf32-arm.h:2275 +#: elf32-arm.h:2285 #, c-format msgid "ERROR: %s is compiled for APCS-%d, whereas target %s uses APCS-%d" msgstr "" -#: elf32-arm.h:2303 +#: elf32-arm.h:2313 #, c-format msgid "ERROR: %s uses VFP instructions, whereas %s uses FPA instructions" msgstr "" -#: elf32-arm.h:2308 +#: elf32-arm.h:2318 #, c-format msgid "ERROR: %s uses FPA instructions, whereas %s uses VFP instructions" msgstr "" -#: elf32-arm.h:2328 +#: elf32-arm.h:2338 #, c-format msgid "ERROR: %s uses software FP, whereas %s uses hardware FP" msgstr "" -#: elf32-arm.h:2333 +#: elf32-arm.h:2343 #, c-format msgid "ERROR: %s uses hardware FP, whereas %s uses software FP" msgstr "" #. Ignore init flag - it may not be set, despite the flags field #. containing valid data. -#: elf32-arm.h:2386 elf32-cris.c:2991 elf32-m68k.c:410 elf32-mips.c:3255 +#: elf32-arm.h:2396 elf32-cris.c:2988 elf32-m68k.c:410 elf32-vax.c:543 +#: elfxx-mips.c:7756 #, c-format msgid "private flags = %lx:" msgstr "" -#: elf32-arm.h:2395 +#: elf32-arm.h:2405 msgid " [interworking enabled]" msgstr "" -#: elf32-arm.h:2403 +#: elf32-arm.h:2413 msgid " [VFP float format]" msgstr "" -#: elf32-arm.h:2405 +#: elf32-arm.h:2415 msgid " [FPA float format]" msgstr "" -#: elf32-arm.h:2414 +#: elf32-arm.h:2424 msgid " [new ABI]" msgstr "" -#: elf32-arm.h:2417 +#: elf32-arm.h:2427 msgid " [old ABI]" msgstr "" -#: elf32-arm.h:2420 +#: elf32-arm.h:2430 msgid " [software FP]" msgstr "" -#: elf32-arm.h:2428 +#: elf32-arm.h:2438 msgid " [Version1 EABI]" msgstr "" -#: elf32-arm.h:2431 elf32-arm.h:2442 +#: elf32-arm.h:2441 elf32-arm.h:2452 msgid " [sorted symbol table]" msgstr "" -#: elf32-arm.h:2433 elf32-arm.h:2444 +#: elf32-arm.h:2443 elf32-arm.h:2454 msgid " [unsorted symbol table]" msgstr "" -#: elf32-arm.h:2439 +#: elf32-arm.h:2449 msgid " [Version2 EABI]" msgstr "" -#: elf32-arm.h:2447 +#: elf32-arm.h:2457 msgid " [dynamic symbols use segment index]" msgstr "" -#: elf32-arm.h:2450 +#: elf32-arm.h:2460 msgid " [mapping symbols precede others]" msgstr "" -#: elf32-arm.h:2457 +#: elf32-arm.h:2467 msgid " <EABI version unrecognised>" msgstr "" -#: elf32-arm.h:2464 +#: elf32-arm.h:2474 msgid " [relocatable executable]" msgstr "" -#: elf32-arm.h:2467 +#: elf32-arm.h:2477 msgid " [has entry point]" msgstr "" -#: elf32-arm.h:2472 +#: elf32-arm.h:2482 msgid "<Unrecognised flag bits set>" msgstr "" -#: elf32-avr.c:843 elf32-cris.c:1414 elf32-fr30.c:661 elf32-i860.c:1056 -#: elf32-openrisc.c:463 elf32-v850.c:1699 elf32-xstormy16.c:984 -#: elf64-mmix.c:1310 +#: elf32-avr.c:841 elf32-cris.c:1411 elf32-fr30.c:643 elf32-frv.c:817 +#: elf32-i860.c:1039 elf32-openrisc.c:447 elf32-v850.c:1699 +#: elf32-xstormy16.c:941 elf64-mmix.c:1310 msgid "internal error: dangerous relocation" msgstr "" @@ -835,95 +837,118 @@ msgid "" "%s: No PLT nor GOT for relocation %s against symbol `%s' from %s section" msgstr "" -#: elf32-cris.c:1015 elf32-cris.c:1142 +#: elf32-cris.c:1015 elf32-cris.c:1141 msgid "[whose name is lost]" msgstr "" -#: elf32-cris.c:1131 +#: elf32-cris.c:1130 #, c-format msgid "" "%s: relocation %s with non-zero addend %d against local symbol from %s " "section" msgstr "" -#: elf32-cris.c:1138 +#: elf32-cris.c:1137 #, c-format msgid "" "%s: relocation %s with non-zero addend %d against symbol `%s' from %s section" msgstr "" -#: elf32-cris.c:1156 +#: elf32-cris.c:1155 #, c-format msgid "" "%s: relocation %s is not allowed for global symbol: `%s' from %s section" msgstr "" -#: elf32-cris.c:1171 +#: elf32-cris.c:1170 #, c-format msgid "%s: relocation %s in section %s with no GOT created" msgstr "" -#: elf32-cris.c:1289 +#: elf32-cris.c:1288 #, c-format msgid "%s: Internal inconsistency; no relocation section %s" msgstr "" -#: elf32-cris.c:2523 +#: elf32-cris.c:2514 #, c-format msgid "" "%s, section %s:\n" " relocation %s should not be used in a shared object; recompile with -fPIC" msgstr "" -#: elf32-cris.c:2994 +#: elf32-cris.c:2991 msgid " [symbols have a _ prefix]" msgstr "" -#: elf32-cris.c:3033 +#: elf32-cris.c:3030 #, c-format msgid "%s: uses _-prefixed symbols, but writing file with non-prefixed symbols" msgstr "" -#: elf32-cris.c:3034 +#: elf32-cris.c:3031 #, c-format msgid "%s: uses non-prefixed symbols, but writing file with _-prefixed symbols" msgstr "" +#: elf32-frv.c:1217 +#, c-format +msgid "" +"%s: compiled with %s and linked with modules that use non-pic relocations" +msgstr "" + +#: elf32-frv.c:1267 +#, c-format +msgid "%s: compiled with %s and linked with modules compiled with %s" +msgstr "" + +#: elf32-frv.c:1279 +#, c-format +msgid "" +"%s: uses different unknown e_flags (0x%lx) fields than previous modules (0x%" +"lx)" +msgstr "" + +#: elf32-frv.c:1315 +#, c-format +msgid "private flags = 0x%lx:" +msgstr "" + #: elf32-gen.c:82 elf64-gen.c:82 #, c-format msgid "%s: Relocations in generic ELF (EM: %d)" msgstr "" -#: elf32-hppa.c:646 +#: elf32-hppa.c:671 elf64-ppc.c:2323 #, c-format msgid "%s: cannot create stub entry %s" msgstr "" -#: elf32-hppa.c:937 elf32-hppa.c:3549 +#: elf32-hppa.c:956 elf32-hppa.c:3555 #, c-format msgid "%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections" msgstr "" -#: elf32-hppa.c:1312 +#: elf32-hppa.c:1338 elf64-x86-64.c:673 #, c-format msgid "" "%s: relocation %s can not be used when making a shared object; recompile " "with -fPIC" msgstr "" -#: elf32-hppa.c:1332 +#: elf32-hppa.c:1358 #, c-format msgid "" "%s: relocation %s should not be used when making a shared object; recompile " "with -fPIC" msgstr "" -#: elf32-hppa.c:1525 +#: elf32-hppa.c:1551 #, c-format msgid "Could not find relocation section for %s" msgstr "" -#: elf32-hppa.c:2871 +#: elf32-hppa.c:2855 #, c-format msgid "%s: duplicate export stub %s" msgstr "" @@ -933,69 +958,83 @@ msgstr "" msgid "%s(%s+0x%lx): fixing %s" msgstr "" -#: elf32-hppa.c:4073 +#: elf32-hppa.c:4080 #, c-format msgid "%s(%s+0x%lx): cannot handle %s for %s" msgstr "" -#: elf32-hppa.c:4412 +#: elf32-hppa.c:4393 msgid ".got section not immediately after .plt section" msgstr "" -#: elf32-i386.c:298 +#: elf32-i386.c:379 #, c-format msgid "%s: invalid relocation type %d" msgstr "" -#: elf32-i386.c:718 elf32-s390.c:637 elf64-s390.c:595 +#: elf32-i386.c:876 elf32-s390.c:649 elf64-s390.c:595 elf64-x86-64.c:591 #, c-format msgid "%s: bad symbol index: %d" msgstr "" -#: elf32-i386.c:863 elf32-s390.c:791 elf64-ppc.c:2198 elf64-s390.c:759 +#: elf32-i386.c:948 +#, c-format +msgid "%s: `%s' accessed both as normal and thread local symbol" +msgstr "" + +#: elf32-i386.c:1072 elf32-s390.c:808 elf64-ppc.c:2827 elf64-s390.c:759 +#: elf64-x86-64.c:761 #, c-format msgid "%s: bad relocation section name `%s'" msgstr "" -#: elf32-i386.c:2073 elf32-s390.c:1956 elf64-ppc.c:4128 elf64-s390.c:1959 +#: elf32-i386.c:1159 elf64-alpha.c:4768 +#, c-format +msgid "%s: TLS local exec code cannot be linked into shared objects" +msgstr "" + +#: elf32-i386.c:2747 elf32-s390.c:1981 elf32-sparc.c:1571 elf64-ppc.c:5918 +#: elf64-s390.c:1945 elf64-sparc.c:2578 elf64-x86-64.c:1948 #, c-format msgid "%s(%s+0x%lx): unresolvable relocation against symbol `%s'" msgstr "" -#: elf32-i386.c:2111 elf32-s390.c:1994 elf64-s390.c:1997 +#: elf32-i386.c:2784 elf32-s390.c:2019 elf64-ppc.c:5977 elf64-s390.c:1983 +#: elf64-x86-64.c:1986 #, c-format msgid "%s(%s+0x%lx): reloc against `%s': error %d" msgstr "" -#: elf32-m32r.c:923 +#: elf32-m32r.c:924 msgid "SDA relocation when _SDA_BASE_ not defined" msgstr "" -#: elf32-ia64.c:3537 elf32-m32r.c:1007 elf32-ppc.c:2930 elf64-ia64.c:3537 +#: elf32-ia64.c:3687 elf32-m32r.c:1013 elf32-ppc.c:2987 elf64-alpha.c:4185 +#: elf64-alpha.c:4313 elf64-ia64.c:3687 #, c-format msgid "%s: unknown relocation type %d" msgstr "" -#: elf32-m32r.c:1223 +#: elf32-m32r.c:1221 #, c-format msgid "%s: The target (%s) of an %s relocation is in the wrong section (%s)" msgstr "" -#: elf32-m32r.c:2000 +#: elf32-m32r.c:1947 #, c-format msgid "%s: Instruction set mismatch with previous modules" msgstr "" -#: elf32-m32r.c:2023 +#: elf32-m32r.c:1970 #, c-format msgid "private flags = %lx" msgstr "" -#: elf32-m32r.c:2028 +#: elf32-m32r.c:1975 msgid ": m32r instructions" msgstr "" -#: elf32-m32r.c:2029 +#: elf32-m32r.c:1976 msgid ": m32rx instructions" msgstr "" @@ -1003,301 +1042,180 @@ msgstr "" msgid " [cpu32]" msgstr "" -#: elf32-mcore.c:353 elf32-mcore.c:479 +#: elf32-m68k.c:416 +msgid " [m68000]" +msgstr "" + +#: elf32-mcore.c:354 elf32-mcore.c:457 #, c-format msgid "%s: Relocation %s (%d) is not currently supported.\n" msgstr "" -#: elf32-mcore.c:438 +#: elf32-mcore.c:442 #, c-format msgid "%s: Unknown relocation type %d\n" msgstr "" -#: elf32-mips.c:2156 elf64-mips.c:1972 +#: elf32-mips.c:1152 elf64-mips.c:1783 msgid "32bits gp relative relocation occurs for an external symbol" msgstr "" -#: elf32-mips.c:2305 +#: elf32-mips.c:1301 #, c-format msgid "Linking mips16 objects into %s format is not supported" msgstr "" -#: elf32-mips.c:3129 -#, c-format -msgid "%s: linking PIC files with non-PIC files" -msgstr "" - -#: elf32-mips.c:3139 -#, c-format -msgid "%s: linking abicalls files with non-abicalls files" -msgstr "" - -#: elf32-mips.c:3168 -#, c-format -msgid "%s: ISA mismatch (-mips%d) with previous modules (-mips%d)" -msgstr "" - -#: elf32-mips.c:3190 -#, c-format -msgid "%s: ISA mismatch (%d) with previous modules (%d)" -msgstr "" - -#: elf32-mips.c:3213 -#, c-format -msgid "%s: ABI mismatch: linking %s module with previous %s modules" -msgstr "" - -#: elf32-mips.c:3227 elf32-ppc.c:1470 elf64-ppc.c:1556 elf64-sparc.c:3027 -#, c-format -msgid "%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)" -msgstr "" - -#: elf32-mips.c:3258 -msgid " [abi=O32]" -msgstr "" - -#: elf32-mips.c:3260 -msgid " [abi=O64]" -msgstr "" - -#: elf32-mips.c:3262 -msgid " [abi=EABI32]" -msgstr "" - -#: elf32-mips.c:3264 -msgid " [abi=EABI64]" -msgstr "" - -#: elf32-mips.c:3266 -msgid " [abi unknown]" -msgstr "" - -#: elf32-mips.c:3268 -msgid " [abi=N32]" -msgstr "" - -#: elf32-mips.c:3270 -msgid " [abi=64]" -msgstr "" - -#: elf32-mips.c:3272 -msgid " [no abi set]" -msgstr "" - -#: elf32-mips.c:3275 -msgid " [mips1]" -msgstr "" - -#: elf32-mips.c:3277 -msgid " [mips2]" -msgstr "" - -#: elf32-mips.c:3279 -msgid " [mips3]" -msgstr "" - -#: elf32-mips.c:3281 -msgid " [mips4]" -msgstr "" - -#: elf32-mips.c:3283 -msgid " [mips5]" -msgstr "" - -#: elf32-mips.c:3285 -msgid " [mips32]" -msgstr "" - -#: elf32-mips.c:3287 -msgid " [mips64]" -msgstr "" - -#: elf32-mips.c:3289 -msgid " [unknown ISA]" -msgstr "" - -#: elf32-mips.c:3292 -msgid " [32bitmode]" -msgstr "" - -#: elf32-mips.c:3294 -msgid " [not 32bitmode]" -msgstr "" - -#: elf32-mips.c:4967 -msgid "static procedure (no name)" -msgstr "" - -#: elf32-mips.c:5585 elf64-mips.c:6694 -#, c-format -msgid "%s: illegal section name `%s'" -msgstr "" - -#: elf32-mips.c:6152 elf64-mips.c:3150 -msgid "not enough GOT space for local GOT entries" -msgstr "" - -#: elf32-mips.c:7263 elf64-mips.c:4203 -#, c-format -msgid "%s: %s+0x%lx: jump to stub routine which is not jal" -msgstr "" - -#: elf32-mips.c:8272 elf64-mips.c:5891 -#, c-format -msgid "%s: Malformed reloc detected for section %s" -msgstr "" - -#: elf32-mips.c:8350 elf64-mips.c:5969 -#, c-format -msgid "%s: CALL16 reloc at 0x%lx not against global symbol" -msgstr "" - -#: elf32-ppc.c:1436 elf64-ppc.c:1521 +#: elf32-ppc.c:1460 #, c-format msgid "" "%s: compiled with -mrelocatable and linked with modules compiled normally" msgstr "" -#: elf32-ppc.c:1444 elf64-ppc.c:1529 +#: elf32-ppc.c:1468 #, c-format msgid "" "%s: compiled normally and linked with modules compiled with -mrelocatable" msgstr "" -#: elf32-ppc.c:1568 +#: elf32-ppc.c:1494 elf64-sparc.c:2989 elfxx-mips.c:7713 +#, c-format +msgid "%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)" +msgstr "" + +#: elf32-ppc.c:1592 #, c-format msgid "%s: Unknown special linker type %d" msgstr "" -#: elf32-ppc.c:2218 elf32-ppc.c:2252 elf32-ppc.c:2287 +#: elf32-ppc.c:2273 elf32-ppc.c:2307 elf32-ppc.c:2342 #, c-format msgid "%s: relocation %s cannot be used when making a shared object" msgstr "" -#: elf32-ppc.c:3097 elf64-ppc.c:3720 +#: elf32-ppc.c:3126 elf64-ppc.c:5473 #, c-format msgid "%s: unknown relocation type %d for symbol %s" msgstr "" -#: elf32-ppc.c:3452 elf32-ppc.c:3473 elf32-ppc.c:3523 +#: elf32-ppc.c:3482 elf32-ppc.c:3503 elf32-ppc.c:3553 #, c-format msgid "" "%s: The target (%s) of a %s relocation is in the wrong output section (%s)" msgstr "" -#: elf32-ppc.c:3589 +#: elf32-ppc.c:3619 #, c-format msgid "%s: Relocation %s is not yet supported for symbol %s." msgstr "" -#: elf32-sh.c:1971 +#: elf32-sh.c:1964 #, c-format msgid "%s: 0x%lx: warning: bad R_SH_USES offset" msgstr "" -#: elf32-sh.c:1983 +#: elf32-sh.c:1976 #, c-format msgid "%s: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x" msgstr "" -#: elf32-sh.c:2000 +#: elf32-sh.c:1993 #, c-format msgid "%s: 0x%lx: warning: bad R_SH_USES load offset" msgstr "" -#: elf32-sh.c:2015 +#: elf32-sh.c:2008 #, c-format msgid "%s: 0x%lx: warning: could not find expected reloc" msgstr "" -#: elf32-sh.c:2072 +#: elf32-sh.c:2036 #, c-format msgid "%s: 0x%lx: warning: symbol in unexpected section" msgstr "" -#: elf32-sh.c:2193 +#: elf32-sh.c:2153 #, c-format msgid "%s: 0x%lx: warning: could not find expected COUNT reloc" msgstr "" -#: elf32-sh.c:2202 +#: elf32-sh.c:2162 #, c-format msgid "%s: 0x%lx: warning: bad count" msgstr "" -#: elf32-sh.c:2611 elf32-sh.c:3002 +#: elf32-sh.c:2550 elf32-sh.c:2926 #, c-format msgid "%s: 0x%lx: fatal: reloc overflow while relaxing" msgstr "" -#: elf32-sh.c:4146 elf64-sh64.c:1557 +#: elf32-sh.c:4073 elf64-sh64.c:1576 msgid "Unexpected STO_SH5_ISA32 on local symbol is not handled" msgstr "" -#: elf32-sh.c:4357 +#: elf32-sh.c:4284 #, c-format msgid "%s: 0x%lx: fatal: unaligned branch target for relax-support relocation" msgstr "" -#: elf32-sh64.c:211 elf64-sh64.c:2391 +#: elf32-sh64.c:203 elf64-sh64.c:2364 #, c-format msgid "%s: compiled as 32-bit object and %s is 64-bit" msgstr "" -#: elf32-sh64.c:214 elf64-sh64.c:2394 +#: elf32-sh64.c:206 elf64-sh64.c:2367 #, c-format msgid "%s: compiled as 64-bit object and %s is 32-bit" msgstr "" -#: elf32-sh64.c:216 elf64-sh64.c:2396 +#: elf32-sh64.c:208 elf64-sh64.c:2369 #, c-format msgid "%s: object size does not match that of target %s" msgstr "" -#: elf32-sh64.c:447 elf64-sh64.c:2973 +#: elf32-sh64.c:440 elf64-sh64.c:2941 #, c-format msgid "%s: encountered datalabel symbol in input" msgstr "" -#: elf32-sh64.c:530 +#: elf32-sh64.c:523 msgid "PTB mismatch: a SHmedia address (bit 0 == 1)" msgstr "" -#: elf32-sh64.c:533 +#: elf32-sh64.c:526 msgid "PTA mismatch: a SHcompact address (bit 0 == 0)" msgstr "" -#: elf32-sh64.c:551 +#: elf32-sh64.c:544 #, c-format msgid "%s: GAS error: unexpected PTB insn with R_SH_PT_16" msgstr "" -#: elf32-sh64.c:600 elf64-sh64.c:1684 +#: elf32-sh64.c:593 elf64-sh64.c:1703 #, c-format msgid "%s: error: unaligned relocation type %d at %08x reloc %08x\n" msgstr "" -#: elf32-sh64.c:684 +#: elf32-sh64.c:677 #, c-format msgid "%s: could not write out added .cranges entries" msgstr "" -#: elf32-sh64.c:745 +#: elf32-sh64.c:739 #, c-format msgid "%s: could not write out sorted .cranges entries" msgstr "" -#: elf32-sparc.c:1554 elf64-sparc.c:2280 +#: elf32-sparc.c:1535 elf64-sparc.c:2224 #, c-format msgid "%s: probably compiled without -fPIC?" msgstr "" -#: elf32-sparc.c:2007 +#: elf32-sparc.c:2002 #, c-format msgid "%s: compiled for a 64 bit system and target is 32 bit" msgstr "" -#: elf32-sparc.c:2021 +#: elf32-sparc.c:2016 #, c-format msgid "%s: linking little endian files with big endian files" msgstr "" @@ -1347,47 +1265,115 @@ msgstr "" msgid "could not locate special linker symbol __ctbp" msgstr "" -#: elf32-v850.c:1877 +#: elf32-v850.c:1875 #, c-format msgid "%s: Architecture mismatch with previous modules" msgstr "" -#: elf32-v850.c:1897 +#: elf32-v850.c:1895 #, c-format msgid "private flags = %lx: " msgstr "" -#: elf32-v850.c:1902 +#: elf32-v850.c:1900 msgid "v850 architecture" msgstr "" -#: elf32-v850.c:1903 +#: elf32-v850.c:1901 msgid "v850e architecture" msgstr "" -#: elf32-v850.c:1904 +#: elf32-v850.c:1902 msgid "v850ea architecture" msgstr "" -#: elf32-ia64.c:2247 elf32-xstormy16.c:414 elf64-ia64.c:2247 +#: elf32-vax.c:546 +msgid " [nonpic]" +msgstr "" + +#: elf32-vax.c:549 +msgid " [d-float]" +msgstr "" + +#: elf32-vax.c:552 +msgid " [g-float]" +msgstr "" + +#: elf32-vax.c:674 +#, c-format +msgid "" +"%s: warning: GOT addend of %ld to `%s' does not match previous GOT addend of " +"%ld" +msgstr "" + +#: elf32-vax.c:1679 +#, c-format +msgid "%s: warning: PLT addend of %d to `%s' from %s section ignored" +msgstr "" + +#: elf32-vax.c:1814 +#, c-format +msgid "%s: warning: %s relocation against symbol `%s' from %s section" +msgstr "" + +#: elf32-vax.c:1820 +#, c-format +msgid "%s: warning: %s relocation to 0x%x from %s section" +msgstr "" + +#: elf32-ia64.c:2280 elf32-xstormy16.c:414 elf64-ia64.c:2280 msgid "non-zero addend in @fptr reloc" msgstr "" -#: elf64-alpha.c:858 +#: elf64-alpha.c:1097 msgid "GPDISP relocation did not find ldah and lda instructions" msgstr "" -#: elf64-alpha.c:2934 +#: elf64-alpha.c:3675 #, c-format msgid "%s: .got subsegment exceeds 64K (size %d)" msgstr "" -#: elf64-alpha.c:3518 elf64-alpha.c:3530 +#: elf64-alpha.c:4498 elf64-alpha.c:4510 #, c-format msgid "%s: gp-relative relocation against dynamic symbol %s" msgstr "" -#: elf64-hppa.c:2070 +#: elf64-alpha.c:4536 elf64-alpha.c:4676 +#, c-format +msgid "%s: pc-relative relocation against dynamic symbol %s" +msgstr "" + +#: elf64-alpha.c:4564 +#, c-format +msgid "%s: change in gp: BRSGP %s" +msgstr "" + +#: elf64-alpha.c:4589 +msgid "<unknown>" +msgstr "" + +#: elf64-alpha.c:4594 +#, c-format +msgid "%s: !samegp reloc against symbol without .prologue: %s" +msgstr "" + +#: elf64-alpha.c:4639 +#, c-format +msgid "%s: unhandled dynamic relocation against %s" +msgstr "" + +#: elf64-alpha.c:4752 +#, c-format +msgid "%s: dtp-relative relocation against dynamic symbol %s" +msgstr "" + +#: elf64-alpha.c:4775 +#, c-format +msgid "%s: tp-relative relocation against dynamic symbol %s" +msgstr "" + +#: elf64-hppa.c:2080 #, c-format msgid "stub entry for %s cannot load .plt, dp offset = %ld" msgstr "" @@ -1433,159 +1419,344 @@ msgid "" "register is $%ld." msgstr "" -#: elf64-mmix.c:1967 +#: elf64-mmix.c:1965 #, c-format msgid "" "%s: Error: multiple definition of `%s'; start of %s is set in a earlier " "linked file\n" msgstr "" -#: elf64-mmix.c:2026 +#: elf64-mmix.c:2024 msgid "Register section has contents\n" msgstr "" -#: elf64-ppc.c:1484 libbfd.c:1436 +#: elf64-mmix.c:2186 +#, c-format +msgid "" +"Internal inconsistency: remaining %u != max %u.\n" +" Please report this bug." +msgstr "" + +#: elf64-ppc.c:1669 libbfd.c:1435 #, c-format msgid "%s: compiled for a big endian system and target is little endian" msgstr "" -#: elf64-ppc.c:1486 libbfd.c:1438 +#: elf64-ppc.c:1671 libbfd.c:1437 #, c-format msgid "%s: compiled for a little endian system and target is big endian" msgstr "" -#: elf64-ppc.c:3354 +#: elf64-ppc.c:3610 +#, c-format +msgid "%s: unexpected reloc type %u in .opd section" +msgstr "" + +#: elf64-ppc.c:3630 +#, c-format +msgid "%s: .opd is not a regular array of opd entries" +msgstr "" + +#: elf64-ppc.c:3672 +#, c-format +msgid "%s: undefined sym `%s' in .opd section" +msgstr "" + +#: elf64-ppc.c:4397 +#, c-format +msgid "can't find branch stub `%s'" +msgstr "" + +#: elf64-ppc.c:4436 elf64-ppc.c:4501 #, c-format msgid "linkage table error against `%s'" msgstr "" -#: elf64-ppc.c:3436 -msgid "stub section size doesn't match calculated size" +#: elf64-ppc.c:4573 +#, c-format +msgid "can't build branch stub `%s'" +msgstr "" + +#: elf64-ppc.c:5179 +msgid "stubs don't match calculated size" msgstr "" -#: elf64-ppc.c:4065 +#: elf64-ppc.c:5828 #, c-format msgid "%s: Relocation %s is not supported for symbol %s." msgstr "" -#: elf64-ppc.c:4109 +#: elf64-ppc.c:5872 #, c-format msgid "%s: error: relocation %s not a multiple of 4" msgstr "" -#: elf64-sparc.c:1277 +#: elf64-sparc.c:1280 #, c-format msgid "%s: check_relocs: unhandled reloc type %d" msgstr "" -#: elf64-sparc.c:1314 +#: elf64-sparc.c:1317 #, c-format msgid "%s: Only registers %%g[2367] can be declared using STT_REGISTER" msgstr "" -#: elf64-sparc.c:1334 +#: elf64-sparc.c:1337 #, c-format msgid "Register %%g%d used incompatibly: %s in %s, previously %s in %s" msgstr "" -#: elf64-sparc.c:1357 +#: elf64-sparc.c:1360 #, c-format msgid "Symbol `%s' has differing types: REGISTER in %s, previously %s in %s" msgstr "" -#: elf64-sparc.c:1404 +#: elf64-sparc.c:1406 #, c-format msgid "Symbol `%s' has differing types: %s in %s, previously REGISTER in %s" msgstr "" -#: elf64-sparc.c:3008 +#: elf64-sparc.c:2970 #, c-format msgid "%s: linking UltraSPARC specific with HAL specific code" msgstr "" -#: elfcode.h:1218 +#: elfcode.h:1198 #, c-format msgid "%s: version count (%ld) does not match symbol count (%ld)" msgstr "" -#: elflink.c:434 +#: elflink.c:440 #, c-format msgid "%s: Section %s is too large to add hole of %ld bytes" msgstr "" -#: elflink.h:1113 +#: elflink.h:1090 #, c-format msgid "%s: warning: unexpected redefinition of `%s'" msgstr "" -#: elflink.h:1784 +#: elflink.h:1727 #, c-format msgid "%s: %s: invalid version %u (max %d)" msgstr "" -#: elflink.h:1825 +#: elflink.h:1768 #, c-format msgid "%s: %s: invalid needed version %d" msgstr "" -#: elflink.h:1945 +#: elflink.h:1890 #, c-format msgid "Warning: size of symbol `%s' changed from %lu to %lu in %s" msgstr "" -#: elflink.h:4014 +#: elflink.h:3174 +#, c-format +msgid "%s: .preinit_array section is not allowed in DSO" +msgstr "" + +#: elflink.h:4030 #, c-format msgid "warning: type and size of dynamic symbol `%s' are not defined" msgstr "" -#: elflink.h:4320 +#: elflink.h:4345 #, c-format msgid "%s: undefined versioned symbol name %s" msgstr "" -#: elflink.h:4544 elflink.h:4552 elflink.h:6203 elflink.h:7280 +#: elflink.h:4611 elflink.h:4619 elflink.h:6508 elflink.h:7600 msgid "Error: out of memory" msgstr "" -#: elflink.h:4714 +#: elflink.h:4781 msgid "Not enough memory to sort relocations" msgstr "" -#: elflink.h:5980 +#: elflink.h:5682 elflink.h:5725 +#, c-format +msgid "%s: could not find output section %s" +msgstr "" + +#: elflink.h:5688 +#, c-format +msgid "warning: %s section has zero size" +msgstr "" + +#: elflink.h:6275 #, c-format msgid "%s: could not find output section %s for input section %s" msgstr "" -#: elflink.h:6553 +#: elflink.h:6486 +#, c-format +msgid "%s: relocation size mismatch in %s section %s" +msgstr "" + +#: elflink.h:6849 msgid "warning: relocation against removed section; zeroing" msgstr "" -#: elflink.h:6583 +#: elflink.h:6879 msgid "warning: relocation against removed section" msgstr "" -#: elflink.h:6596 +#: elflink.h:6892 #, c-format msgid "local symbols in discarded section %s" msgstr "" -#: i386linux.c:455 m68klinux.c:459 sparclinux.c:456 +#: elfxx-mips.c:734 +msgid "static procedure (no name)" +msgstr "" + +#: elfxx-mips.c:1601 +msgid "not enough GOT space for local GOT entries" +msgstr "" + +#: elfxx-mips.c:2750 +#, c-format +msgid "%s: %s+0x%lx: jump to stub routine which is not jal" +msgstr "" + +#: elfxx-mips.c:4270 +#, c-format +msgid "%s: Malformed reloc detected for section %s" +msgstr "" + +#: elfxx-mips.c:4348 +#, c-format +msgid "%s: CALL16 reloc at 0x%lx not against global symbol" +msgstr "" + +#: elfxx-mips.c:7301 +#, c-format +msgid "%s: illegal section name `%s'" +msgstr "" + +#: elfxx-mips.c:7615 +#, c-format +msgid "%s: linking PIC files with non-PIC files" +msgstr "" + +#: elfxx-mips.c:7625 +#, c-format +msgid "%s: linking abicalls files with non-abicalls files" +msgstr "" + +#: elfxx-mips.c:7654 +#, c-format +msgid "%s: ISA mismatch (-mips%d) with previous modules (-mips%d)" +msgstr "" + +#: elfxx-mips.c:7676 +#, c-format +msgid "%s: ISA mismatch (%d) with previous modules (%d)" +msgstr "" + +#: elfxx-mips.c:7699 +#, c-format +msgid "%s: ABI mismatch: linking %s module with previous %s modules" +msgstr "" + +#: elfxx-mips.c:7759 +msgid " [abi=O32]" +msgstr "" + +#: elfxx-mips.c:7761 +msgid " [abi=O64]" +msgstr "" + +#: elfxx-mips.c:7763 +msgid " [abi=EABI32]" +msgstr "" + +#: elfxx-mips.c:7765 +msgid " [abi=EABI64]" +msgstr "" + +#: elfxx-mips.c:7767 +msgid " [abi unknown]" +msgstr "" + +#: elfxx-mips.c:7769 +msgid " [abi=N32]" +msgstr "" + +#: elfxx-mips.c:7771 +msgid " [abi=64]" +msgstr "" + +#: elfxx-mips.c:7773 +msgid " [no abi set]" +msgstr "" + +#: elfxx-mips.c:7776 +msgid " [mips1]" +msgstr "" + +#: elfxx-mips.c:7778 +msgid " [mips2]" +msgstr "" + +#: elfxx-mips.c:7780 +msgid " [mips3]" +msgstr "" + +#: elfxx-mips.c:7782 +msgid " [mips4]" +msgstr "" + +#: elfxx-mips.c:7784 +msgid " [mips5]" +msgstr "" + +#: elfxx-mips.c:7786 +msgid " [mips32]" +msgstr "" + +#: elfxx-mips.c:7788 +msgid " [mips64]" +msgstr "" + +#: elfxx-mips.c:7790 +msgid " [unknown ISA]" +msgstr "" + +#: elfxx-mips.c:7793 +msgid " [mdmx]" +msgstr "" + +#: elfxx-mips.c:7796 +msgid " [mips16]" +msgstr "" + +#: elfxx-mips.c:7799 +msgid " [32bitmode]" +msgstr "" + +#: elfxx-mips.c:7801 +msgid " [not 32bitmode]" +msgstr "" + +#: i386linux.c:458 m68klinux.c:462 sparclinux.c:459 #, c-format msgid "Output file requires shared library `%s'\n" msgstr "" -#: i386linux.c:463 m68klinux.c:467 sparclinux.c:464 +#: i386linux.c:466 m68klinux.c:470 sparclinux.c:467 #, c-format msgid "Output file requires shared library `%s.so.%s'\n" msgstr "" -#: i386linux.c:653 i386linux.c:703 m68klinux.c:660 m68klinux.c:708 -#: sparclinux.c:655 sparclinux.c:705 +#: i386linux.c:655 i386linux.c:705 m68klinux.c:662 m68klinux.c:710 +#: sparclinux.c:657 sparclinux.c:707 #, c-format msgid "Symbol %s not defined for fixups\n" msgstr "" -#: i386linux.c:727 m68klinux.c:732 sparclinux.c:729 +#: i386linux.c:729 m68klinux.c:734 sparclinux.c:731 msgid "Warning: fixup count mismatch\n" msgstr "" @@ -1619,47 +1790,47 @@ msgstr "" msgid "%s:%d: unexpected character `%s' in Intel Hex file\n" msgstr "" -#: ihex.c:368 +#: ihex.c:366 #, c-format msgid "%s:%u: bad checksum in Intel Hex file (expected %u, found %u)" msgstr "" -#: ihex.c:422 +#: ihex.c:420 #, c-format msgid "%s:%u: bad extended address record length in Intel Hex file" msgstr "" -#: ihex.c:439 +#: ihex.c:437 #, c-format msgid "%s:%u: bad extended start address length in Intel Hex file" msgstr "" -#: ihex.c:456 +#: ihex.c:454 #, c-format msgid "%s:%u: bad extended linear address record length in Intel Hex file" msgstr "" -#: ihex.c:473 +#: ihex.c:471 #, c-format msgid "%s:%u: bad extended linear start address length in Intel Hex file" msgstr "" -#: ihex.c:490 +#: ihex.c:488 #, c-format msgid "%s:%u: unrecognized ihex type %u in Intel Hex file\n" msgstr "" -#: ihex.c:610 +#: ihex.c:607 #, c-format msgid "%s: internal error in ihex_read_section" msgstr "" -#: ihex.c:645 +#: ihex.c:642 #, c-format msgid "%s: bad section length in ihex_read_section" msgstr "" -#: ihex.c:863 +#: ihex.c:860 #, c-format msgid "%s: address 0x%s out of range for Intel Hex file" msgstr "" @@ -1673,174 +1844,174 @@ msgstr "" msgid "not mapping: env var not set\n" msgstr "" -#: libbfd.c:1467 +#: libbfd.c:1466 #, c-format msgid "Deprecated %s called at %s line %d in %s\n" msgstr "" -#: libbfd.c:1470 +#: libbfd.c:1469 #, c-format msgid "Deprecated %s called\n" msgstr "" -#: linker.c:1849 +#: linker.c:1873 #, c-format msgid "%s: indirect symbol `%s' to `%s' is a loop" msgstr "" -#: linker.c:2745 +#: linker.c:2776 #, c-format msgid "Attempt to do relocateable link with %s input and %s output" msgstr "" -#: merge.c:897 +#: merge.c:892 #, c-format msgid "%s: access beyond end of merged section (%ld + %ld)" msgstr "" -#: mmo.c:459 +#: mmo.c:460 #, c-format msgid "%s: No core to allocate section name %s\n" msgstr "" -#: mmo.c:535 +#: mmo.c:536 #, c-format msgid "%s: No core to allocate a symbol %d bytes long\n" msgstr "" -#: mmo.c:1188 +#: mmo.c:1245 #, c-format msgid "%s: invalid mmo file: initialization value for $255 is not `Main'\n" msgstr "" -#: mmo.c:1334 +#: mmo.c:1391 #, c-format msgid "" "%s: unsupported wide character sequence 0x%02X 0x%02X after symbol name " "starting with `%s'\n" msgstr "" -#: mmo.c:1569 +#: mmo.c:1633 #, c-format msgid "%s: invalid mmo file: unsupported lopcode `%d'\n" msgstr "" -#: mmo.c:1579 +#: mmo.c:1643 #, c-format msgid "%s: invalid mmo file: expected YZ = 1 got YZ = %d for lop_quote\n" msgstr "" -#: mmo.c:1615 +#: mmo.c:1679 #, c-format msgid "%s: invalid mmo file: expected z = 1 or z = 2, got z = %d for lop_loc\n" msgstr "" -#: mmo.c:1661 +#: mmo.c:1725 #, c-format msgid "" "%s: invalid mmo file: expected z = 1 or z = 2, got z = %d for lop_fixo\n" msgstr "" -#: mmo.c:1700 +#: mmo.c:1764 #, c-format msgid "%s: invalid mmo file: expected y = 0, got y = %d for lop_fixrx\n" msgstr "" -#: mmo.c:1709 +#: mmo.c:1773 #, c-format msgid "" "%s: invalid mmo file: expected z = 16 or z = 24, got z = %d for lop_fixrx\n" msgstr "" -#: mmo.c:1732 +#: mmo.c:1796 #, c-format msgid "" "%s: invalid mmo file: leading byte of operand word must be 0 or 1, got %d " "for lop_fixrx\n" msgstr "" -#: mmo.c:1755 +#: mmo.c:1819 #, c-format msgid "%s: cannot allocate file name for file number %d, %d bytes\n" msgstr "" -#: mmo.c:1775 +#: mmo.c:1839 #, c-format msgid "" "%s: invalid mmo file: file number %d `%s', was already entered as `%s'\n" msgstr "" -#: mmo.c:1788 +#: mmo.c:1852 #, c-format msgid "" "%s: invalid mmo file: file name for number %d was not specified before use\n" msgstr "" -#: mmo.c:1894 +#: mmo.c:1958 #, c-format msgid "" "%s: invalid mmo file: fields y and z of lop_stab non-zero, y: %d, z: %d\n" msgstr "" -#: mmo.c:1930 +#: mmo.c:1994 #, c-format msgid "%s: invalid mmo file: lop_end not last item in file\n" msgstr "" -#: mmo.c:1943 +#: mmo.c:2007 #, c-format msgid "" "%s: invalid mmo file: YZ of lop_end (%ld) not equal to the number of tetras " "to the preceding lop_stab (%ld)\n" msgstr "" -#: mmo.c:2608 +#: mmo.c:2670 #, c-format msgid "%s: invalid symbol table: duplicate symbol `%s'\n" msgstr "" -#: mmo.c:2896 +#: mmo.c:2921 #, c-format msgid "" "%s: Bad symbol definition: `Main' set to %s rather than the start address %" "s\n" msgstr "" -#: mmo.c:2930 +#: mmo.c:3011 #, c-format msgid "" "%s: warning: symbol table too large for mmo, larger than 65535 32-bit words: " "%d. Only `Main' will be emitted.\n" msgstr "" -#: mmo.c:2975 +#: mmo.c:3056 #, c-format msgid "%s: internal error, symbol table changed size from %d to %d words\n" msgstr "" -#: mmo.c:3030 +#: mmo.c:3111 #, c-format msgid "%s: internal error, internal register section %s had contents\n" msgstr "" -#: mmo.c:3082 +#: mmo.c:3163 #, c-format msgid "%s: no initialized registers; section length 0\n" msgstr "" -#: mmo.c:3088 +#: mmo.c:3169 #, c-format msgid "%s: too many initialized registers; section length %ld\n" msgstr "" -#: mmo.c:3093 +#: mmo.c:3174 #, c-format msgid "" "%s: invalid start address for initialized registers of length %ld: 0x%lx%" "08lx\n" msgstr "" -#: oasys.c:1036 +#: oasys.c:1029 #, c-format msgid "%s: can not represent section `%s' in oasys" msgstr "" @@ -1961,7 +2132,7 @@ msgstr "" msgid "Partition[%d] length = 0x%.8lx (%ld)\n" msgstr "" -#: som.c:5402 +#: som.c:5398 msgid "som_sizeof_headers unimplemented" msgstr "" @@ -1970,7 +2141,12 @@ msgstr "" msgid "%s:%d: Unexpected character `%s' in S-record file\n" msgstr "" -#: syms.c:998 +#: stabs.c:319 +#, c-format +msgid "%s(%s+0x%lx): Stabs entry has invalid string index." +msgstr "" + +#: syms.c:1044 msgid "Unsupported .stab relocation" msgstr "" @@ -1989,7 +2165,7 @@ msgstr "" msgid "Size mismatch section %s=%lx, %s=%lx" msgstr "" -#: vms-gsd.c:704 +#: vms-gsd.c:702 #, c-format msgid "unknown gsd/egsd subtype %d" msgstr "" @@ -2133,149 +2309,149 @@ msgstr "" msgid "Unhandled relocation %s" msgstr "" -#: xcofflink.c:1241 +#: xcofflink.c:1243 #, c-format msgid "%s: `%s' has line numbers but no enclosing section" msgstr "" -#: xcofflink.c:1294 +#: xcofflink.c:1296 #, c-format msgid "%s: class %d symbol `%s' has no aux entries" msgstr "" -#: xcofflink.c:1317 +#: xcofflink.c:1319 #, c-format msgid "%s: symbol `%s' has unrecognized csect type %d" msgstr "" -#: xcofflink.c:1329 +#: xcofflink.c:1331 #, c-format msgid "%s: bad XTY_ER symbol `%s': class %d scnum %d scnlen %d" msgstr "" -#: xcofflink.c:1365 +#: xcofflink.c:1367 #, c-format msgid "%s: XMC_TC0 symbol `%s' is class %d scnlen %d" msgstr "" -#: xcofflink.c:1517 +#: xcofflink.c:1519 #, c-format msgid "%s: csect `%s' not in enclosing section" msgstr "" -#: xcofflink.c:1624 +#: xcofflink.c:1626 #, c-format msgid "%s: misplaced XTY_LD `%s'" msgstr "" -#: xcofflink.c:1948 +#: xcofflink.c:1957 #, c-format msgid "%s: reloc %s:%d not in csect" msgstr "" -#: xcofflink.c:2083 +#: xcofflink.c:2092 #, c-format msgid "%s: XCOFF shared object when not producing XCOFF output" msgstr "" -#: xcofflink.c:2104 +#: xcofflink.c:2113 #, c-format msgid "%s: dynamic object with no .loader section" msgstr "" -#: xcofflink.c:2749 +#: xcofflink.c:2758 #, c-format msgid "%s: no such symbol" msgstr "" -#: xcofflink.c:2890 +#: xcofflink.c:2891 msgid "error: undefined symbol __rtinit" msgstr "" -#: xcofflink.c:3458 +#: xcofflink.c:3453 #, c-format msgid "warning: attempt to export undefined symbol `%s'" msgstr "" -#: xcofflink.c:4452 +#: xcofflink.c:4447 #, c-format msgid "TOC overflow: 0x%lx > 0x10000; try -mminimal-toc when compiling" msgstr "" -#: xcofflink.c:5292 xcofflink.c:5754 xcofflink.c:5816 xcofflink.c:6117 +#: xcofflink.c:5287 xcofflink.c:5756 xcofflink.c:5818 xcofflink.c:6119 #, c-format msgid "%s: loader reloc in unrecognized section `%s'" msgstr "" -#: xcofflink.c:5314 xcofflink.c:6128 +#: xcofflink.c:5309 xcofflink.c:6130 #, c-format msgid "%s: `%s' in loader reloc but not loader sym" msgstr "" -#: xcofflink.c:5329 +#: xcofflink.c:5324 #, c-format msgid "%s: loader reloc in read-only section %s" msgstr "" -#: elf32-ia64.c:2189 elf64-ia64.c:2189 +#: elf32-ia64.c:2222 elf64-ia64.c:2222 msgid "@pltoff reloc against local symbol" msgstr "" -#: elf32-ia64.c:3413 elf64-ia64.c:3413 +#: elf32-ia64.c:3562 elf64-ia64.c:3562 #, c-format msgid "%s: short data segment overflowed (0x%lx >= 0x400000)" msgstr "" -#: elf32-ia64.c:3424 elf64-ia64.c:3424 +#: elf32-ia64.c:3573 elf64-ia64.c:3573 #, c-format msgid "%s: __gp does not cover short data segment" msgstr "" -#: elf32-ia64.c:3728 elf64-ia64.c:3728 +#: elf32-ia64.c:3858 elf64-ia64.c:3858 #, c-format msgid "%s: linking non-pic code in a shared library" msgstr "" -#: elf32-ia64.c:3761 elf64-ia64.c:3761 +#: elf32-ia64.c:3891 elf64-ia64.c:3891 #, c-format msgid "%s: @gprel relocation against dynamic symbol %s" msgstr "" -#: elf32-ia64.c:3900 elf64-ia64.c:3900 +#: elf32-ia64.c:4030 elf64-ia64.c:4030 #, c-format msgid "%s: dynamic relocation against speculation fixup" msgstr "" -#: elf32-ia64.c:3908 elf64-ia64.c:3908 +#: elf32-ia64.c:4038 elf64-ia64.c:4038 #, c-format msgid "%s: speculation fixup against undefined weak symbol" msgstr "" -#: elf32-ia64.c:4092 elf64-ia64.c:4092 +#: elf32-ia64.c:4271 elf64-ia64.c:4271 msgid "unsupported reloc" msgstr "" -#: elf32-ia64.c:4372 elf64-ia64.c:4372 +#: elf32-ia64.c:4551 elf64-ia64.c:4551 #, c-format msgid "%s: linking trap-on-NULL-dereference with non-trapping files" msgstr "" -#: elf32-ia64.c:4381 elf64-ia64.c:4381 +#: elf32-ia64.c:4560 elf64-ia64.c:4560 #, c-format msgid "%s: linking big-endian files with little-endian files" msgstr "" -#: elf32-ia64.c:4390 elf64-ia64.c:4390 +#: elf32-ia64.c:4569 elf64-ia64.c:4569 #, c-format msgid "%s: linking 64-bit files with 32-bit files" msgstr "" -#: elf32-ia64.c:4399 elf64-ia64.c:4399 +#: elf32-ia64.c:4578 elf64-ia64.c:4578 #, c-format msgid "%s: linking constant-gp files with non-constant-gp files" msgstr "" -#: elf32-ia64.c:4409 elf64-ia64.c:4409 +#: elf32-ia64.c:4588 elf64-ia64.c:4588 #, c-format msgid "%s: linking auto-pic files with non-auto-pic files" msgstr "" @@ -2394,43 +2570,37 @@ msgid "" " Table Stamp Chain Name Thunk\n" msgstr "" -#: peigen.c:1180 pepigen.c:1180 +#: peigen.c:1181 pepigen.c:1181 #, c-format msgid "" "\n" "\tDLL Name: %s\n" msgstr "" -#: peigen.c:1184 peigen.c:1247 pepigen.c:1184 pepigen.c:1247 -msgid "\tvma: Hint/Ord Member-Name\n" -msgstr "" - -#: peigen.c:1246 pepigen.c:1246 -msgid "\tThe Import Address Table (difference found)\n" +#: peigen.c:1192 pepigen.c:1192 +msgid "\tvma: Hint/Ord Member-Name Bound-To\n" msgstr "" -#: peigen.c:1253 pepigen.c:1253 -msgid "\t>>> Ran out of IAT members!\n" -msgstr "" - -#: peigen.c:1271 pepigen.c:1271 -msgid "\tThe Import Address Table is identical\n" +#: peigen.c:1217 pepigen.c:1217 +msgid "" +"\n" +"There is a first thunk, but the section containing it could not be found\n" msgstr "" -#: peigen.c:1343 pepigen.c:1343 +#: peigen.c:1357 pepigen.c:1357 msgid "" "\n" "There is an export table, but the section containing it could not be found\n" msgstr "" -#: peigen.c:1348 pepigen.c:1348 +#: peigen.c:1362 pepigen.c:1362 #, c-format msgid "" "\n" "There is an export table in %s at 0x%lx\n" msgstr "" -#: peigen.c:1379 pepigen.c:1379 +#: peigen.c:1393 pepigen.c:1393 #, c-format msgid "" "\n" @@ -2438,129 +2608,129 @@ msgid "" "\n" msgstr "" -#: peigen.c:1383 pepigen.c:1383 +#: peigen.c:1397 pepigen.c:1397 #, c-format msgid "Export Flags \t\t\t%lx\n" msgstr "" -#: peigen.c:1386 pepigen.c:1386 +#: peigen.c:1400 pepigen.c:1400 #, c-format msgid "Time/Date stamp \t\t%lx\n" msgstr "" -#: peigen.c:1389 pepigen.c:1389 +#: peigen.c:1403 pepigen.c:1403 #, c-format msgid "Major/Minor \t\t\t%d/%d\n" msgstr "" -#: peigen.c:1392 pepigen.c:1392 +#: peigen.c:1406 pepigen.c:1406 msgid "Name \t\t\t\t" msgstr "" -#: peigen.c:1398 pepigen.c:1398 +#: peigen.c:1412 pepigen.c:1412 #, c-format msgid "Ordinal Base \t\t\t%ld\n" msgstr "" -#: peigen.c:1401 pepigen.c:1401 +#: peigen.c:1415 pepigen.c:1415 msgid "Number in:\n" msgstr "" -#: peigen.c:1404 pepigen.c:1404 +#: peigen.c:1418 pepigen.c:1418 #, c-format msgid "\tExport Address Table \t\t%08lx\n" msgstr "" -#: peigen.c:1408 pepigen.c:1408 +#: peigen.c:1422 pepigen.c:1422 #, c-format msgid "\t[Name Pointer/Ordinal] Table\t%08lx\n" msgstr "" -#: peigen.c:1411 pepigen.c:1411 +#: peigen.c:1425 pepigen.c:1425 msgid "Table Addresses\n" msgstr "" -#: peigen.c:1414 pepigen.c:1414 +#: peigen.c:1428 pepigen.c:1428 msgid "\tExport Address Table \t\t" msgstr "" -#: peigen.c:1419 pepigen.c:1419 +#: peigen.c:1433 pepigen.c:1433 msgid "\tName Pointer Table \t\t" msgstr "" -#: peigen.c:1424 pepigen.c:1424 +#: peigen.c:1438 pepigen.c:1438 msgid "\tOrdinal Table \t\t\t" msgstr "" -#: peigen.c:1439 pepigen.c:1439 +#: peigen.c:1453 pepigen.c:1453 #, c-format msgid "" "\n" "Export Address Table -- Ordinal Base %ld\n" msgstr "" -#: peigen.c:1458 pepigen.c:1458 +#: peigen.c:1472 pepigen.c:1472 msgid "Forwarder RVA" msgstr "" -#: peigen.c:1469 pepigen.c:1469 +#: peigen.c:1483 pepigen.c:1483 msgid "Export RVA" msgstr "" -#: peigen.c:1476 pepigen.c:1476 +#: peigen.c:1490 pepigen.c:1490 msgid "" "\n" "[Ordinal/Name Pointer] Table\n" msgstr "" -#: peigen.c:1531 pepigen.c:1531 +#: peigen.c:1545 pepigen.c:1545 #, c-format msgid "Warning, .pdata section size (%ld) is not a multiple of %d\n" msgstr "" -#: peigen.c:1535 pepigen.c:1535 +#: peigen.c:1549 pepigen.c:1549 msgid "" "\n" "The Function Table (interpreted .pdata section contents)\n" msgstr "" -#: peigen.c:1538 pepigen.c:1538 +#: peigen.c:1552 pepigen.c:1552 msgid " vma:\t\t\tBegin Address End Address Unwind Info\n" msgstr "" -#: peigen.c:1540 pepigen.c:1540 +#: peigen.c:1554 pepigen.c:1554 msgid "" " vma:\t\tBegin End EH EH PrologEnd Exception\n" " \t\tAddress Address Handler Data Address Mask\n" msgstr "" -#: peigen.c:1610 pepigen.c:1610 +#: peigen.c:1624 pepigen.c:1624 msgid " Register save millicode" msgstr "" -#: peigen.c:1613 pepigen.c:1613 +#: peigen.c:1627 pepigen.c:1627 msgid " Register restore millicode" msgstr "" -#: peigen.c:1616 pepigen.c:1616 +#: peigen.c:1630 pepigen.c:1630 msgid " Glue code sequence" msgstr "" -#: peigen.c:1668 pepigen.c:1668 +#: peigen.c:1682 pepigen.c:1682 msgid "" "\n" "\n" "PE File Base Relocations (interpreted .reloc section contents)\n" msgstr "" -#: peigen.c:1698 pepigen.c:1698 +#: peigen.c:1712 pepigen.c:1712 #, c-format msgid "" "\n" "Virtual Address: %08lx Chunk size %ld (0x%lx) Number of fixups %ld\n" msgstr "" -#: peigen.c:1711 pepigen.c:1711 +#: peigen.c:1725 pepigen.c:1725 #, c-format msgid "\treloc %4d offset %4x [%4lx] %s" msgstr "" @@ -2568,7 +2738,7 @@ msgstr "" #. The MS dumpbin program reportedly ands with 0xff0f before #. printing the characteristics field. Not sure why. No reason to #. emulate it here. -#: peigen.c:1751 pepigen.c:1751 +#: peigen.c:1765 pepigen.c:1765 #, c-format msgid "" "\n" diff --git a/contrib/binutils/bfd/ppcboot.c b/contrib/binutils/bfd/ppcboot.c index 9ac3f31..5b153bd 100644 --- a/contrib/binutils/bfd/ppcboot.c +++ b/contrib/binutils/bfd/ppcboot.c @@ -469,8 +469,11 @@ ppcboot_bfd_print_private_bfd_data (abfd, farg) #define ppcboot_bfd_relax_section bfd_generic_relax_section #define ppcboot_bfd_gc_sections bfd_generic_gc_sections #define ppcboot_bfd_merge_sections bfd_generic_merge_sections +#define ppcboot_bfd_discard_group bfd_generic_discard_group #define ppcboot_bfd_link_hash_table_create _bfd_generic_link_hash_table_create +#define ppcboot_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define ppcboot_bfd_link_add_symbols _bfd_generic_link_add_symbols +#define ppcboot_bfd_link_just_syms _bfd_generic_link_just_syms #define ppcboot_bfd_final_link _bfd_generic_final_link #define ppcboot_bfd_link_split_section _bfd_generic_link_split_section #define ppcboot_get_section_contents_in_window \ diff --git a/contrib/binutils/bfd/reloc.c b/contrib/binutils/bfd/reloc.c index c701fe0..59f7819 100644 --- a/contrib/binutils/bfd/reloc.c +++ b/contrib/binutils/bfd/reloc.c @@ -645,7 +645,7 @@ bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd, reloc_target_output_section = symbol->section->output_section; /* Convert input-section-relative symbol value to absolute. */ - if (output_bfd && howto->partial_inplace == false) + if (output_bfd && ! howto->partial_inplace) output_base = 0; else output_base = reloc_target_output_section->vma; @@ -658,7 +658,7 @@ bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd, /* Here the variable relocation holds the final address of the symbol we are relocating against, plus any addend. */ - if (howto->pc_relative == true) + if (howto->pc_relative) { /* This is a PC relative relocation. We want to set RELOCATION to the distance between the address of the symbol and the @@ -691,13 +691,13 @@ bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd, relocation -= input_section->output_section->vma + input_section->output_offset; - if (howto->pcrel_offset == true) + if (howto->pcrel_offset) relocation -= reloc_entry->address; } if (output_bfd != (bfd *) NULL) { - if (howto->partial_inplace == false) + if (! howto->partial_inplace) { /* This is a partial relocation, and we want to apply the relocation to the reloc entry rather than the raw data. Modify the reloc @@ -1037,7 +1037,7 @@ bfd_install_relocation (abfd, reloc_entry, data_start, data_start_offset, reloc_target_output_section = symbol->section->output_section; /* Convert input-section-relative symbol value to absolute. */ - if (howto->partial_inplace == false) + if (! howto->partial_inplace) output_base = 0; else output_base = reloc_target_output_section->vma; @@ -1050,7 +1050,7 @@ bfd_install_relocation (abfd, reloc_entry, data_start, data_start_offset, /* Here the variable relocation holds the final address of the symbol we are relocating against, plus any addend. */ - if (howto->pc_relative == true) + if (howto->pc_relative) { /* This is a PC relative relocation. We want to set RELOCATION to the distance between the address of the symbol and the @@ -1083,11 +1083,11 @@ bfd_install_relocation (abfd, reloc_entry, data_start, data_start_offset, relocation -= input_section->output_section->vma + input_section->output_offset; - if (howto->pcrel_offset == true && howto->partial_inplace == true) + if (howto->pcrel_offset && howto->partial_inplace) relocation -= reloc_entry->address; } - if (howto->partial_inplace == false) + if (! howto->partial_inplace) { /* This is a partial relocation, and we want to apply the relocation to the reloc entry rather than the raw data. Modify the reloc @@ -1963,6 +1963,35 @@ ENUMDOC STO_ALPHA_STD_GPLOAD. ENUM + BFD_RELOC_ALPHA_TLSGD +ENUMX + BFD_RELOC_ALPHA_TLSLDM +ENUMX + BFD_RELOC_ALPHA_DTPMOD64 +ENUMX + BFD_RELOC_ALPHA_GOTDTPREL16 +ENUMX + BFD_RELOC_ALPHA_DTPREL64 +ENUMX + BFD_RELOC_ALPHA_DTPREL_HI16 +ENUMX + BFD_RELOC_ALPHA_DTPREL_LO16 +ENUMX + BFD_RELOC_ALPHA_DTPREL16 +ENUMX + BFD_RELOC_ALPHA_GOTTPREL16 +ENUMX + BFD_RELOC_ALPHA_TPREL64 +ENUMX + BFD_RELOC_ALPHA_TPREL_HI16 +ENUMX + BFD_RELOC_ALPHA_TPREL_LO16 +ENUMX + BFD_RELOC_ALPHA_TPREL16 +ENUMDOC + Alpha thread-local storage relocations. + +ENUM BFD_RELOC_MIPS_JMP ENUMDOC Bits 27..2 of the relocation address shifted right 2 bits; @@ -2050,6 +2079,27 @@ ENUMX ENUMX BFD_RELOC_MIPS_JALR COMMENT +ENUM + BFD_RELOC_FRV_LABEL16 +ENUMX + BFD_RELOC_FRV_LABEL24 +ENUMX + BFD_RELOC_FRV_LO16 +ENUMX + BFD_RELOC_FRV_HI16 +ENUMX + BFD_RELOC_FRV_GPREL12 +ENUMX + BFD_RELOC_FRV_GPRELU12 +ENUMX + BFD_RELOC_FRV_GPREL32 +ENUMX + BFD_RELOC_FRV_GPRELHI +ENUMX + BFD_RELOC_FRV_GPRELLO +ENUMDOC + Fujitsu Frv Relocations. +COMMENT COMMENT ENUMDOC MIPS ELF relocations. @@ -2072,6 +2122,30 @@ ENUMX BFD_RELOC_386_GOTOFF ENUMX BFD_RELOC_386_GOTPC +ENUMX + BFD_RELOC_386_TLS_TPOFF +ENUMX + BFD_RELOC_386_TLS_IE +ENUMX + BFD_RELOC_386_TLS_GOTIE +ENUMX + BFD_RELOC_386_TLS_LE +ENUMX + BFD_RELOC_386_TLS_GD +ENUMX + BFD_RELOC_386_TLS_LDM +ENUMX + BFD_RELOC_386_TLS_LDO_32 +ENUMX + BFD_RELOC_386_TLS_IE_32 +ENUMX + BFD_RELOC_386_TLS_LE_32 +ENUMX + BFD_RELOC_386_TLS_DTPMOD32 +ENUMX + BFD_RELOC_386_TLS_DTPOFF32 +ENUMX + BFD_RELOC_386_TLS_TPOFF32 ENUMDOC i386/elf relocations @@ -2598,6 +2672,19 @@ ENUMDOC This is a 32-bit pc-relative reloc. ENUM + BFD_RELOC_DLX_HI16_S +ENUMDOC + DLX relocs +ENUM + BFD_RELOC_DLX_LO16 +ENUMDOC + DLX relocs +ENUM + BFD_RELOC_DLX_JMP26 +ENUMDOC + DLX relocs + +ENUM BFD_RELOC_M32R_24 ENUMDOC Mitsubishi M32R relocs. @@ -3185,17 +3272,43 @@ ENUMX ENUMX BFD_RELOC_IA64_COPY ENUMX + BFD_RELOC_IA64_LTOFF22X +ENUMX + BFD_RELOC_IA64_LDXMOV +ENUMX + BFD_RELOC_IA64_TPREL14 +ENUMX BFD_RELOC_IA64_TPREL22 ENUMX + BFD_RELOC_IA64_TPREL64I +ENUMX BFD_RELOC_IA64_TPREL64MSB ENUMX BFD_RELOC_IA64_TPREL64LSB ENUMX - BFD_RELOC_IA64_LTOFF_TP22 + BFD_RELOC_IA64_LTOFF_TPREL22 ENUMX - BFD_RELOC_IA64_LTOFF22X + BFD_RELOC_IA64_DTPMOD64MSB ENUMX - BFD_RELOC_IA64_LDXMOV + BFD_RELOC_IA64_DTPMOD64LSB +ENUMX + BFD_RELOC_IA64_LTOFF_DTPMOD22 +ENUMX + BFD_RELOC_IA64_DTPREL14 +ENUMX + BFD_RELOC_IA64_DTPREL22 +ENUMX + BFD_RELOC_IA64_DTPREL64I +ENUMX + BFD_RELOC_IA64_DTPREL32MSB +ENUMX + BFD_RELOC_IA64_DTPREL32LSB +ENUMX + BFD_RELOC_IA64_DTPREL64MSB +ENUMX + BFD_RELOC_IA64_DTPREL64LSB +ENUMX + BFD_RELOC_IA64_LTOFF_DTPREL22 ENUMDOC Intel IA64 Relocations. @@ -3363,6 +3476,15 @@ ENUMX ENUMDOC Sony Xstormy16 Relocations. +ENUM + BFD_RELOC_VAX_GLOB_DAT +ENUMX + BFD_RELOC_VAX_JMP_SLOT +ENUMX + BFD_RELOC_VAX_RELATIVE +ENUMDOC + Relocations used by VAX ELF. + ENDSENUM BFD_RELOC_UNUSED CODE_FRAGMENT diff --git a/contrib/binutils/bfd/reloc16.c b/contrib/binutils/bfd/reloc16.c index 1d69a7f..1db8daf 100644 --- a/contrib/binutils/bfd/reloc16.c +++ b/contrib/binutils/bfd/reloc16.c @@ -196,8 +196,7 @@ bfd_coff_reloc16_relax_section (abfd, input_section, link_info, again) The last element is used as an accumlator of shrinks. */ amt = reloc_count + 1; amt *= sizeof (unsigned); - shrinks = (unsigned *) bfd_malloc (amt); - memset (shrinks, 0, (size_t) amt); + shrinks = (unsigned *) bfd_zmalloc (amt); /* Loop until nothing changes in this section. */ do { diff --git a/contrib/binutils/bfd/rs6000-core.c b/contrib/binutils/bfd/rs6000-core.c index 6330153..a61f25c 100644 --- a/contrib/binutils/bfd/rs6000-core.c +++ b/contrib/binutils/bfd/rs6000-core.c @@ -11,21 +11,21 @@ Archive support from Damon A. Permezel. Contributed by IBM Corporation and Cygnus Support. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This port currently only handles reading object files, except when compiled on an RS/6000 host. -- no archive support, no core files. diff --git a/contrib/binutils/bfd/section.c b/contrib/binutils/bfd/section.c index 076a012..51b21c7 100644 --- a/contrib/binutils/bfd/section.c +++ b/contrib/binutils/bfd/section.c @@ -230,12 +230,6 @@ CODE_FRAGMENT . standard data. *} .#define SEC_CONSTRUCTOR 0x100 . -. {* The section is a constructor, and should be placed at the -. end of the text, data, or bss section(?). *} -.#define SEC_CONSTRUCTOR_TEXT 0x1100 -.#define SEC_CONSTRUCTOR_DATA 0x2100 -.#define SEC_CONSTRUCTOR_BSS 0x3100 -. . {* The section has contents - a data section could be . <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be . <<SEC_HAS_CONTENTS>> *} @@ -256,6 +250,9 @@ CODE_FRAGMENT . sections. *} .#define SEC_COFF_SHARED_LIBRARY 0x800 . +. {* The section contains thread local data. *} +.#define SEC_THREAD_LOCAL 0x1000 +. . {* The section has GOT references. This flag is only for the . linker, and is currently only used by the elf32-hppa back end. . It will be set if global offset table references were detected @@ -801,7 +798,7 @@ bfd_get_unique_section_name (abfd, templat, count) sname = bfd_malloc ((bfd_size_type) len + 8); if (sname == NULL) return NULL; - strcpy (sname, templat); + memcpy (sname, templat, len); num = 1; if (count != NULL) num = *count; @@ -1304,77 +1301,57 @@ SYNOPSIS DESCRIPTION Remove @var{section} from the output. If the output section - becomes empty, remove it from the output bfd. @var{info} may - be NULL; if it is not, it is used to decide whether the output - section is empty. + becomes empty, remove it from the output bfd. + + This function won't actually do anything except twiddle flags + if called too late in the linking process, when it's not safe + to remove sections. */ void _bfd_strip_section_from_output (info, s) struct bfd_link_info *info; asection *s; { - asection **spp, *os; - struct bfd_link_order *p, *pp; - boolean keep_os; + asection *os; + asection *is; + bfd *abfd; - /* Excise the input section from the link order. + s->flags |= SEC_EXCLUDE; - FIXME: For all calls that I can see to this function, the link - orders have not yet been set up. So why are we checking them? -- - Ian */ + /* If the section wasn't assigned to an output section, or the + section has been discarded by the linker script, there's nothing + more to do. */ os = s->output_section; - - /* Handle a section that wasn't output. */ - if (os == NULL) + if (os == NULL || os->owner == NULL) return; - for (p = os->link_order_head, pp = NULL; p != NULL; pp = p, p = p->next) - if (p->type == bfd_indirect_link_order - && p->u.indirect.section == s) - { - if (pp) - pp->next = p->next; - else - os->link_order_head = p->next; - if (!p->next) - os->link_order_tail = pp; - break; - } - - keep_os = os->link_order_head != NULL; - - if (! keep_os && info != NULL) - { - bfd *abfd; - for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next) - { - asection *is; - for (is = abfd->sections; is != NULL; is = is->next) - { - if (is != s && is->output_section == os - && (is->flags & SEC_EXCLUDE) == 0) - break; - } - if (is != NULL) - break; - } - if (abfd != NULL) - keep_os = true; - } + /* If the output section has other (non-excluded) input sections, we + can't remove it. */ + for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next) + for (is = abfd->sections; is != NULL; is = is->next) + if (is->output_section == os && (is->flags & SEC_EXCLUDE) == 0) + return; - /* If the output section is empty, remove it too. Careful about sections - that have been discarded in the link script -- they are mapped to - bfd_abs_section, which has no owner. */ - if (!keep_os && os->owner != NULL) - { - for (spp = &os->owner->sections; *spp; spp = &(*spp)->next) - if (*spp == os) - { - bfd_section_list_remove (os->owner, spp); - os->owner->section_count--; - break; - } - } + /* If the output section is empty, flag it for removal too. + See ldlang.c:strip_excluded_output_sections for the action. */ + os->flags |= SEC_EXCLUDE; +} - s->flags |= SEC_EXCLUDE; +/* +FUNCTION + bfd_generic_discard_group + +SYNOPSIS + boolean bfd_generic_discard_group (bfd *abfd, asection *group); + +DESCRIPTION + Remove all members of @var{group} from the output. +*/ + +boolean +bfd_generic_discard_group (abfd, group) + bfd *abfd ATTRIBUTE_UNUSED; + asection *group ATTRIBUTE_UNUSED; +{ + return true; } diff --git a/contrib/binutils/bfd/sparclinux.c b/contrib/binutils/bfd/sparclinux.c index a8b4792..e55a4ff 100644 --- a/contrib/binutils/bfd/sparclinux.c +++ b/contrib/binutils/bfd/sparclinux.c @@ -230,7 +230,7 @@ linux_link_hash_table_create (abfd) struct linux_link_hash_table *ret; bfd_size_type amt = sizeof (struct linux_link_hash_table); - ret = (struct linux_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct linux_link_hash_table *) bfd_malloc (amt); if (ret == (struct linux_link_hash_table *) NULL) return (struct bfd_link_hash_table *) NULL; if (! NAME(aout,link_hash_table_init) (&ret->root, abfd, @@ -599,10 +599,9 @@ bfd_sparclinux_size_dynamic_sections (output_bfd, info) { s->_raw_size = linux_hash_table (info)->fixup_count + 1; s->_raw_size *= 8; - s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size); + s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size); if (s->contents == NULL) return false; - memset (s->contents, 0, (size_t) s->_raw_size); } return true; diff --git a/contrib/binutils/bfd/srec.c b/contrib/binutils/bfd/srec.c index 41d9871..129b2ba 100644 --- a/contrib/binutils/bfd/srec.c +++ b/contrib/binutils/bfd/srec.c @@ -160,7 +160,7 @@ srec_init () { static boolean inited = false; - if (inited == false) + if (! inited) { inited = true; hex_init (); @@ -230,22 +230,23 @@ static boolean srec_mkobject (abfd) bfd *abfd; { + bfd_size_type amt; + tdata_type *tdata; + srec_init (); - if (abfd->tdata.srec_data == NULL) - { - bfd_size_type amt = sizeof (tdata_type); - tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, amt); - if (tdata == NULL) - return false; - abfd->tdata.srec_data = tdata; - tdata->type = 1; - tdata->head = NULL; - tdata->tail = NULL; - tdata->symbols = NULL; - tdata->symtail = NULL; - tdata->csymbols = NULL; - } + amt = sizeof (tdata_type); + tdata = (tdata_type *) bfd_alloc (abfd, amt); + if (tdata == NULL) + return false; + + abfd->tdata.srec_data = tdata; + tdata->type = 1; + tdata->head = NULL; + tdata->tail = NULL; + tdata->symbols = NULL; + tdata->symtail = NULL; + tdata->csymbols = NULL; return true; } @@ -640,6 +641,7 @@ static const bfd_target * srec_object_p (abfd) bfd *abfd; { + PTR tdata_save; bfd_byte b[4]; srec_init (); @@ -654,9 +656,14 @@ srec_object_p (abfd) return NULL; } - if (! srec_mkobject (abfd) - || ! srec_scan (abfd)) - return NULL; + tdata_save = abfd->tdata.any; + if (! srec_mkobject (abfd) || ! srec_scan (abfd)) + { + if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL) + bfd_release (abfd, abfd->tdata.any); + abfd->tdata.any = tdata_save; + return NULL; + } if (abfd->symcount > 0) abfd->flags |= HAS_SYMS; @@ -670,6 +677,7 @@ static const bfd_target * symbolsrec_object_p (abfd) bfd *abfd; { + PTR tdata_save; char b[2]; srec_init (); @@ -684,9 +692,14 @@ symbolsrec_object_p (abfd) return NULL; } - if (! srec_mkobject (abfd) - || ! srec_scan (abfd)) - return NULL; + tdata_save = abfd->tdata.any; + if (! srec_mkobject (abfd) || ! srec_scan (abfd)) + { + if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL) + bfd_release (abfd, abfd->tdata.any); + abfd->tdata.any = tdata_save; + return NULL; + } if (abfd->symcount > 0) abfd->flags |= HAS_SYMS; @@ -1270,8 +1283,11 @@ srec_print_symbol (abfd, afile, symbol, how) #define srec_bfd_relax_section bfd_generic_relax_section #define srec_bfd_gc_sections bfd_generic_gc_sections #define srec_bfd_merge_sections bfd_generic_merge_sections +#define srec_bfd_discard_group bfd_generic_discard_group #define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create +#define srec_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols +#define srec_bfd_link_just_syms _bfd_generic_link_just_syms #define srec_bfd_final_link _bfd_generic_final_link #define srec_bfd_link_split_section _bfd_generic_link_split_section diff --git a/contrib/binutils/bfd/stabs.c b/contrib/binutils/bfd/stabs.c index bba4a6d..e225d9c 100644 --- a/contrib/binutils/bfd/stabs.c +++ b/contrib/binutils/bfd/stabs.c @@ -284,6 +284,7 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo) sym < symend; sym += STABSIZE, ++pstridx) { + bfd_size_type symstroff; int type; const char *string; @@ -311,9 +312,18 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo) } /* Store the string in the hash table, and record the index. */ - string = ((char *) stabstrbuf - + stroff - + bfd_get_32 (abfd, sym + STRDXOFF)); + symstroff = stroff + bfd_get_32 (abfd, sym + STRDXOFF); + if (symstroff >= stabstrsec->_raw_size) + { + (*_bfd_error_handler) + (_("%s(%s+0x%lx): Stabs entry has invalid string index."), + bfd_archive_filename (abfd), + bfd_get_section_name (abfd, stabsec), + (long) (sym - stabbuf)); + bfd_set_error (bfd_error_bad_value); + goto error_return; + } + string = (char *) stabstrbuf + symstroff; *pstridx = _bfd_stringtab_add (sinfo->strings, string, true, true); /* An N_BINCL symbol indicates the start of the stabs entries diff --git a/contrib/binutils/bfd/sunos.c b/contrib/binutils/bfd/sunos.c index cb23fe1..5fec6f9 100644 --- a/contrib/binutils/bfd/sunos.c +++ b/contrib/binutils/bfd/sunos.c @@ -717,13 +717,13 @@ sunos_link_hash_table_create (abfd) struct sunos_link_hash_table *ret; bfd_size_type amt = sizeof (struct sunos_link_hash_table); - ret = (struct sunos_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct sunos_link_hash_table *) bfd_malloc (amt); if (ret == (struct sunos_link_hash_table *) NULL) return (struct bfd_link_hash_table *) NULL; if (! NAME(aout,link_hash_table_init) (&ret->root, abfd, sunos_link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return (struct bfd_link_hash_table *) NULL; } @@ -1434,10 +1434,9 @@ bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr, s = bfd_get_section_by_name (dynobj, ".hash"); BFD_ASSERT (s != NULL); hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE; - s->contents = (bfd_byte *) bfd_alloc (dynobj, hashalloc); + s->contents = (bfd_byte *) bfd_zalloc (dynobj, hashalloc); if (s->contents == NULL && dynsymcount > 0) return false; - memset (s->contents, 0, (size_t) hashalloc); for (i = 0; i < bucketcount; i++) PUT_WORD (output_bfd, (bfd_vma) -1, s->contents + i * HASH_ENTRY_SIZE); s->_raw_size = bucketcount * HASH_ENTRY_SIZE; diff --git a/contrib/binutils/bfd/syms.c b/contrib/binutils/bfd/syms.c index 01f7eee..8a8abf4 100644 --- a/contrib/binutils/bfd/syms.c +++ b/contrib/binutils/bfd/syms.c @@ -285,6 +285,9 @@ CODE_FRAGMENT . as well. *} .#define BSF_DEBUGGING_RELOC 0x20000 . +. {* This symbol is thread local. Used in ELF. *} +.#define BSF_THREAD_LOCAL 0x40000 +. . flagword flags; . . {* A pointer to the section to which this symbol is @@ -312,6 +315,7 @@ CODE_FRAGMENT #include "aout/stab_gnu.h" static char coff_section_type PARAMS ((const char *)); +static char decode_section_type PARAMS ((const struct sec *)); static int cmpindexentry PARAMS ((const PTR, const PTR)); /* @@ -586,6 +590,41 @@ coff_section_type (s) return '?'; } +/* Return the single-character symbol type corresponding to section + SECTION, or '?' for an unknown section. This uses section flags to + identify sections. + + FIXME These types are unhandled: c, i, e, p. If we handled these also, + we could perhaps obsolete coff_section_type. */ + +static char +decode_section_type (section) + const struct sec *section; +{ + if (section->flags & SEC_CODE) + return 't'; + if (section->flags & SEC_DATA) + { + if (section->flags & SEC_READONLY) + return 'r'; + else if (section->flags & SEC_SMALL_DATA) + return 'g'; + else + return 'd'; + } + if ((section->flags & SEC_HAS_CONTENTS) == 0) + { + if (section->flags & SEC_SMALL_DATA) + return 's'; + else + return 'b'; + } + if (section->flags & SEC_DEBUGGING) + return 'N'; + + return '?'; +} + /* FUNCTION bfd_decode_symclass @@ -636,7 +675,11 @@ bfd_decode_symclass (symbol) if (bfd_is_abs_section (symbol->section)) c = 'a'; else if (symbol->section) - c = coff_section_type (symbol->section->name); + { + c = coff_section_type (symbol->section->name); + if (c == '?') + c = decode_section_type (symbol->section); + } else return '?'; if (symbol->flags & BSF_GLOBAL) @@ -880,6 +923,7 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, char *file_name; char *directory_name; int saw_fun; + boolean saw_line, saw_func; *pfound = false; *pfilename = bfd_get_filename (abfd); @@ -1236,13 +1280,13 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, directory_name = indexentry->directory_name; str = indexentry->str; + saw_line = false; + saw_func = false; for (; stab < (indexentry+1)->stab; stab += STABSIZE) { - boolean done, saw_line, saw_func; + boolean done; bfd_vma val; - saw_line = false; - saw_func = false; done = false; switch (stab[TYPEOFF]) @@ -1309,14 +1353,16 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, || strncmp (info->filename, directory_name, dirlen) != 0 || strcmp (info->filename + dirlen, file_name) != 0) { + size_t len; + if (info->filename != NULL) free (info->filename); - info->filename = (char *) bfd_malloc ((bfd_size_type) dirlen - + strlen (file_name) + 1); + len = strlen (file_name) + 1; + info->filename = (char *) bfd_malloc ((bfd_size_type) dirlen + len); if (info->filename == NULL) return false; - strcpy (info->filename, directory_name); - strcpy (info->filename + dirlen, file_name); + memcpy (info->filename, directory_name, dirlen); + memcpy (info->filename + dirlen, file_name, len); } *pfilename = info->filename; diff --git a/contrib/binutils/bfd/targets.c b/contrib/binutils/bfd/targets.c index 78b4bbb..d41edf6 100644 --- a/contrib/binutils/bfd/targets.c +++ b/contrib/binutils/bfd/targets.c @@ -394,11 +394,14 @@ the tokens. .CONCAT2 (NAME,_bfd_get_relocated_section_contents), \ .CONCAT2 (NAME,_bfd_relax_section), \ .CONCAT2 (NAME,_bfd_link_hash_table_create), \ +.CONCAT2 (NAME,_bfd_link_hash_table_free), \ .CONCAT2 (NAME,_bfd_link_add_symbols), \ +.CONCAT2 (NAME,_bfd_link_just_syms), \ .CONCAT2 (NAME,_bfd_final_link), \ .CONCAT2 (NAME,_bfd_link_split_section), \ .CONCAT2 (NAME,_bfd_gc_sections), \ -.CONCAT2 (NAME,_bfd_merge_sections) +.CONCAT2 (NAME,_bfd_merge_sections), \ +.CONCAT2 (NAME,_bfd_discard_group) . int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean)); . bfd_byte *(*_bfd_get_relocated_section_contents) . PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, @@ -411,9 +414,15 @@ the tokens. . different information in this table. *} . struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *)); . +. {* Release the memory associated with the linker hash table. *} +. void (*_bfd_link_hash_table_free) PARAMS ((struct bfd_link_hash_table *)); +. . {* Add symbols from this object file into the hash table. *} . boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *)); . +. {* Indicate that we are only retrieving symbol values from this section. *} +. void (*_bfd_link_just_syms) PARAMS ((asection *, struct bfd_link_info *)); +. . {* Do a link based on the link_order structures attached to each . section of the BFD. *} . boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *)); @@ -427,6 +436,9 @@ the tokens. . {* Attempt to merge SEC_MERGE sections. *} . boolean (*_bfd_merge_sections) PARAMS ((bfd *, struct bfd_link_info *)); . +. {* Discard members of a group. *} +. boolean (*_bfd_discard_group) PARAMS ((bfd *, struct sec *)); +. . {* Routines to handle dynamic symbols and relocs. *} .#define BFD_JUMP_TABLE_DYNAMIC(NAME) \ .CONCAT2 (NAME,_get_dynamic_symtab_upper_bound), \ @@ -469,6 +481,7 @@ to find an alternative output format that is suitable. we can't intermix extern's and initializers. */ extern const bfd_target a29kcoff_big_vec; extern const bfd_target a_out_adobe_vec; +extern const bfd_target aix5coff64_vec; extern const bfd_target aout0_big_vec; extern const bfd_target aout_arm_big_vec; extern const bfd_target aout_arm_little_vec; @@ -499,12 +512,16 @@ extern const bfd_target bfd_elf32_bigmips_vec; extern const bfd_target bfd_elf32_cris_vec; extern const bfd_target bfd_elf32_d10v_vec; extern const bfd_target bfd_elf32_d30v_vec; +extern const bfd_target bfd_elf32_dlx_big_vec; extern const bfd_target bfd_elf32_fr30_vec; +extern const bfd_target bfd_elf32_frv_vec; extern const bfd_target bfd_elf32_h8300_vec; extern const bfd_target bfd_elf32_hppa_linux_vec; extern const bfd_target bfd_elf32_hppa_vec; extern const bfd_target bfd_elf32_i370_vec; +extern const bfd_target bfd_elf32_i386_freebsd_vec; extern const bfd_target bfd_elf32_i386_vec; +extern const bfd_target bfd_elf32_i386qnx_vec; extern const bfd_target bfd_elf32_i860_little_vec; extern const bfd_target bfd_elf32_i860_vec; extern const bfd_target bfd_elf32_i960_vec; @@ -531,6 +548,10 @@ extern const bfd_target bfd_elf32_pjl_vec; extern const bfd_target bfd_elf32_powerpc_vec; extern const bfd_target bfd_elf32_powerpcle_vec; extern const bfd_target bfd_elf32_s390_vec; +extern const bfd_target bfd_elf32_sh64_vec; +extern const bfd_target bfd_elf32_sh64l_vec; +extern const bfd_target bfd_elf32_sh64lnbsd_vec; +extern const bfd_target bfd_elf32_sh64nbsd_vec; extern const bfd_target bfd_elf32_sh_vec; extern const bfd_target bfd_elf32_shblin_vec; extern const bfd_target bfd_elf32_shl_vec; @@ -542,7 +563,9 @@ extern const bfd_target bfd_elf32_tradbigmips_vec; extern const bfd_target bfd_elf32_tradlittlemips_vec; extern const bfd_target bfd_elf32_us_cris_vec; extern const bfd_target bfd_elf32_v850_vec; +extern const bfd_target bfd_elf32_vax_vec; extern const bfd_target bfd_elf32_xstormy16_vec; +extern const bfd_target bfd_elf64_alpha_freebsd_vec; extern const bfd_target bfd_elf64_alpha_vec; extern const bfd_target bfd_elf64_big_generic_vec; extern const bfd_target bfd_elf64_bigmips_vec; @@ -559,6 +582,10 @@ extern const bfd_target bfd_elf64_mmix_vec; extern const bfd_target bfd_elf64_powerpc_vec; extern const bfd_target bfd_elf64_powerpcle_vec; extern const bfd_target bfd_elf64_s390_vec; +extern const bfd_target bfd_elf64_sh64_vec; +extern const bfd_target bfd_elf64_sh64l_vec; +extern const bfd_target bfd_elf64_sh64lnbsd_vec; +extern const bfd_target bfd_elf64_sh64nbsd_vec; extern const bfd_target bfd_elf64_sparc_vec; extern const bfd_target bfd_elf64_tradbigmips_vec; extern const bfd_target bfd_elf64_tradlittlemips_vec; @@ -654,7 +681,9 @@ extern const bfd_target tic54x_coff1_vec; extern const bfd_target tic54x_coff2_beh_vec; extern const bfd_target tic54x_coff2_vec; extern const bfd_target tic80coff_vec; +extern const bfd_target vaxbsd_vec; extern const bfd_target vaxnetbsd_vec; +extern const bfd_target vax1knetbsd_vec; extern const bfd_target versados_vec; extern const bfd_target vms_alpha_vec; extern const bfd_target vms_vax_vec; @@ -682,10 +711,6 @@ extern const bfd_target ptrace_core_vec; extern const bfd_target sco5_core_vec; extern const bfd_target trad_core_vec; -extern const bfd_target bfd_elf32_sh64_vec; -extern const bfd_target bfd_elf32_sh64l_vec; -extern const bfd_target bfd_elf64_sh64_vec; -extern const bfd_target bfd_elf64_sh64l_vec; static const bfd_target * const _bfd_target_vector[] = { #ifdef SELECT_VECS @@ -705,6 +730,9 @@ static const bfd_target * const _bfd_target_vector[] = { it wasn't omitted by mistake. */ &a29kcoff_big_vec, &a_out_adobe_vec, +#ifdef BFD64 + &aix5coff64_vec, +#endif &aout0_big_vec, #if 0 /* We have no way of distinguishing these from other a.out variants */ @@ -748,12 +776,16 @@ static const bfd_target * const _bfd_target_vector[] = { &bfd_elf32_cris_vec, &bfd_elf32_d10v_vec, &bfd_elf32_d30v_vec, + &bfd_elf32_dlx_big_vec, &bfd_elf32_fr30_vec, + &bfd_elf32_frv_vec, &bfd_elf32_h8300_vec, &bfd_elf32_hppa_linux_vec, &bfd_elf32_hppa_vec, &bfd_elf32_i370_vec, + &bfd_elf32_i386_freebsd_vec, &bfd_elf32_i386_vec, + &bfd_elf32_i386qnx_vec, &bfd_elf32_i860_little_vec, &bfd_elf32_i860_vec, &bfd_elf32_i960_vec, @@ -788,13 +820,21 @@ static const bfd_target * const _bfd_target_vector[] = { &bfd_elf32_shlin_vec, &bfd_elf32_shlnbsd_vec, &bfd_elf32_shnbsd_vec, +#ifdef BFD64 + &bfd_elf32_sh64_vec, + &bfd_elf32_sh64l_vec, + &bfd_elf32_sh64lnbsd_vec, + &bfd_elf32_sh64nbsd_vec, +#endif &bfd_elf32_sparc_vec, &bfd_elf32_tradbigmips_vec, &bfd_elf32_tradlittlemips_vec, &bfd_elf32_us_cris_vec, &bfd_elf32_v850_vec, + &bfd_elf32_vax_vec, &bfd_elf32_xstormy16_vec, #ifdef BFD64 + &bfd_elf64_alpha_freebsd_vec, &bfd_elf64_alpha_vec, &bfd_elf64_big_generic_vec, &bfd_elf64_bigmips_vec, @@ -811,6 +851,10 @@ static const bfd_target * const _bfd_target_vector[] = { &bfd_elf64_powerpc_vec, &bfd_elf64_powerpcle_vec, &bfd_elf64_s390_vec, + &bfd_elf64_sh64_vec, + &bfd_elf64_sh64l_vec, + &bfd_elf64_sh64lnbsd_vec, + &bfd_elf64_sh64nbsd_vec, #if 0 &bfd_elf64_sparc_vec, #endif @@ -954,7 +998,9 @@ static const bfd_target * const _bfd_target_vector[] = { &tic54x_coff2_beh_vec, &tic54x_coff2_vec, &tic80coff_vec, + &vaxbsd_vec, &vaxnetbsd_vec, + &vax1knetbsd_vec, &versados_vec, #ifdef BFD64 &vms_alpha_vec, diff --git a/contrib/binutils/bfd/tekhex.c b/contrib/binutils/bfd/tekhex.c index f5d5160..19dcb87 100644 --- a/contrib/binutils/bfd/tekhex.c +++ b/contrib/binutils/bfd/tekhex.c @@ -1,5 +1,5 @@ /* BFD backend for Extended Tektronix Hex Format objects. - Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 + Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>. @@ -242,7 +242,7 @@ tekhex_init () static boolean inited = false; int val; - if (inited == false) + if (! inited) { inited = true; hex_init (); @@ -354,17 +354,13 @@ find_chunk (abfd, vma) } if (!d) { - char *sname = bfd_alloc (abfd, (bfd_size_type) 12); - /* No chunk for this address, so make one up */ d = ((struct data_struct *) - bfd_alloc (abfd, (bfd_size_type) sizeof (struct data_struct))); + bfd_zalloc (abfd, (bfd_size_type) sizeof (struct data_struct))); - if (!sname || !d) + if (!d) return NULL; - memset (d->chunk_init, 0, CHUNK_MASK + 1); - memset (d->chunk_data, 0, CHUNK_MASK + 1); d->next = abfd->tdata.tekhex_data->data; d->vma = vma; abfd->tdata.tekhex_data->data = d; @@ -489,7 +485,7 @@ pass_over (abfd, func) /* To the front of the file */ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) abort (); - while (eof == false) + while (! eof) { char buffer[MAXCHUNK]; char *src = buffer; @@ -681,7 +677,7 @@ tekhex_set_section_contents (abfd, section, locationp, offset, bytes_to_do) bfd_size_type bytes_to_do; { - if (abfd->output_has_begun == false) + if (! abfd->output_has_begun) { /* The first time around, allocate enough sections to hold all the chunks */ asection *s = abfd->sections; @@ -1005,8 +1001,11 @@ tekhex_print_symbol (abfd, filep, symbol, how) #define tekhex_bfd_relax_section bfd_generic_relax_section #define tekhex_bfd_gc_sections bfd_generic_gc_sections #define tekhex_bfd_merge_sections bfd_generic_merge_sections +#define tekhex_bfd_discard_group bfd_generic_discard_group #define tekhex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create +#define tekhex_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols +#define tekhex_bfd_link_just_syms _bfd_generic_link_just_syms #define tekhex_bfd_final_link _bfd_generic_final_link #define tekhex_bfd_link_split_section _bfd_generic_link_split_section diff --git a/contrib/binutils/bfd/version.h b/contrib/binutils/bfd/version.h index 652aeb4..a440678 100644 --- a/contrib/binutils/bfd/version.h +++ b/contrib/binutils/bfd/version.h @@ -1 +1 @@ -#define BFD_VERSION_DATE 20020720 +#define BFD_VERSION_DATE 20021011 diff --git a/contrib/binutils/bfd/xcoff-target.h b/contrib/binutils/bfd/xcoff-target.h index 0787b8d..413511b 100644 --- a/contrib/binutils/bfd/xcoff-target.h +++ b/contrib/binutils/bfd/xcoff-target.h @@ -1,5 +1,5 @@ /* Common definitions for backends based on IBM RS/6000 "XCOFF64" files. - Copyright 2000, 2001 + Copyright 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Cygnus Support. @@ -98,6 +98,7 @@ extern int lynx_core_file_failing_signal PARAMS ((bfd *abfd)); #define _bfd_xcoff_bfd_relax_section coff_bfd_relax_section #define _bfd_xcoff_bfd_gc_sections coff_bfd_gc_sections #define _bfd_xcoff_bfd_merge_sections coff_bfd_merge_sections +#define _bfd_xcoff_bfd_discard_group bfd_generic_discard_group #define _bfd_xcoff_bfd_link_split_section coff_bfd_link_split_section /* XCOFF archives do not have anything which corresponds to an diff --git a/contrib/binutils/bfd/xcofflink.c b/contrib/binutils/bfd/xcofflink.c index 2e5ca5d..a869d7d 100644 --- a/contrib/binutils/bfd/xcofflink.c +++ b/contrib/binutils/bfd/xcofflink.c @@ -3,21 +3,21 @@ Free Software Foundation, Inc. Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -482,12 +482,12 @@ _bfd_xcoff_bfd_link_hash_table_create (abfd) struct xcoff_link_hash_table *ret; bfd_size_type amt = sizeof (struct xcoff_link_hash_table); - ret = (struct xcoff_link_hash_table *) bfd_alloc (abfd, amt); + ret = (struct xcoff_link_hash_table *) bfd_malloc (amt); if (ret == (struct xcoff_link_hash_table *) NULL) return (struct bfd_link_hash_table *) NULL; if (! _bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return (struct bfd_link_hash_table *) NULL; } @@ -513,6 +513,18 @@ _bfd_xcoff_bfd_link_hash_table_create (abfd) return &ret->root; } +/* Free a XCOFF link hash table. */ + +void +_bfd_xcoff_bfd_link_hash_table_free (hash) + struct bfd_link_hash_table *hash; +{ + struct xcoff_link_hash_table *ret = (struct xcoff_link_hash_table *) hash; + + _bfd_stringtab_free (ret->debug_strtab); + bfd_hash_table_free (&ret->root.table); + free (ret); +} /* Read internal relocs for an XCOFF csect. This is a wrapper around _bfd_coff_read_internal_relocs which tries to take advantage of any @@ -588,11 +600,11 @@ _bfd_xcoff_bfd_link_add_symbols (abfd, info) case bfd_archive: /* If the archive has a map, do the usual search. We then need - to check the archive for stripped dynamic objects, because - they will not appear in the archive map even though they - should, perhaps, be included. If the archive has no map, we - just consider each object file in turn, since that apparently - is what the AIX native linker does. */ + to check the archive for dynamic objects, because they may not + appear in the archive map even though they should, perhaps, be + included. If the archive has no map, we just consider each object + file in turn, since that apparently is what the AIX native linker + does. */ if (bfd_has_map (abfd)) { if (! (_bfd_generic_link_add_archive_symbols @@ -602,18 +614,18 @@ _bfd_xcoff_bfd_link_add_symbols (abfd, info) { bfd *member; - + member = bfd_openr_next_archived_file (abfd, (bfd *) NULL); while (member != NULL) { if (bfd_check_format (member, bfd_object) - && (! bfd_has_map (abfd) - || ((member->flags & DYNAMIC) != 0 - && (member->flags & HAS_SYMS) == 0))) + && (info->hash->creator == member->xvec) + && (! bfd_has_map (abfd) || (member->flags & DYNAMIC) != 0)) { boolean needed; - - if (! xcoff_link_check_archive_element (member, info, &needed)) + + if (! xcoff_link_check_archive_element (member, info, + &needed)) return false; if (needed) member->archive_pass = -1; @@ -1046,16 +1058,12 @@ xcoff_link_add_symbols (abfd, info) && ! info->static_link) { if (! xcoff_link_add_dynamic_symbols (abfd, info)) - { - return false; - } + return false; } /* create the loader, toc, gl, ds and debug sections, if needed */ if (false == xcoff_link_create_extra_sections(abfd, info)) - { - goto error_return; - } + goto error_return; if ((abfd->flags & DYNAMIC) != 0 && ! info->static_link) @@ -1078,21 +1086,19 @@ xcoff_link_add_symbols (abfd, info) /* We keep a list of the linker hash table entries that correspond to each external symbol. */ amt = symcount * sizeof (struct xcoff_link_hash_entry *); - sym_hash = (struct xcoff_link_hash_entry **) bfd_alloc (abfd, amt); + sym_hash = (struct xcoff_link_hash_entry **) bfd_zalloc (abfd, amt); if (sym_hash == NULL && symcount != 0) goto error_return; coff_data (abfd)->sym_hashes = (struct coff_link_hash_entry **) sym_hash; - memset (sym_hash, 0, (size_t) amt); /* Because of the weird stuff we are doing with XCOFF csects, we can not easily determine which section a symbol is in, so we store the information in the tdata for the input file. */ amt = symcount * sizeof (asection *); - csect_cache = (asection **) bfd_alloc (abfd, amt); + csect_cache = (asection **) bfd_zalloc (abfd, amt); if (csect_cache == NULL && symcount != 0) goto error_return; xcoff_data (abfd)->csects = csect_cache; - memset (csect_cache, 0, (size_t) amt); /* While splitting sections into csects, we need to assign the relocs correctly. The relocs and the csects must both be in @@ -1101,10 +1107,9 @@ xcoff_link_add_symbols (abfd, info) into reloc_info using the section target_index. */ amt = abfd->section_count + 1; amt *= sizeof (struct reloc_info_struct); - reloc_info = (struct reloc_info_struct *) bfd_malloc (amt); + reloc_info = (struct reloc_info_struct *) bfd_zmalloc (amt); if (reloc_info == NULL) goto error_return; - memset ((PTR) reloc_info, 0, (size_t) amt); /* Read in the relocs and line numbers for each section. */ linesz = bfd_coff_linesz (abfd); @@ -1121,11 +1126,9 @@ xcoff_link_add_symbols (abfd, info) false, (struct internal_reloc *) NULL); amt = o->reloc_count; amt *= sizeof (asection *); - reloc_info[o->target_index].csects = (asection **) bfd_malloc (amt); + reloc_info[o->target_index].csects = (asection **) bfd_zmalloc (amt); if (reloc_info[o->target_index].csects == NULL) goto error_return; - memset (reloc_info[o->target_index].csects, 0, (size_t) amt); - } if ((info->strip == strip_none || info->strip == strip_some) @@ -1146,7 +1149,6 @@ xcoff_link_add_symbols (abfd, info) } } - /* Don't let the linker relocation routines discard the symbols. */ obj_coff_keep_syms (abfd) = true; @@ -1771,12 +1773,19 @@ xcoff_link_add_symbols (abfd, info) if (info->hash->creator == abfd->xvec) { if (! bfd_is_und_section (section)) - *sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info), - name, true, copy, false); + { + *sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info), + name, true, copy, false); + } else - *sym_hash = ((struct xcoff_link_hash_entry *) - bfd_wrapped_link_hash_lookup (abfd, info, name, - true, copy, false)); + { + /* Make a copy of the symbol name to prevent problems with + merging symbols. */ + *sym_hash = ((struct xcoff_link_hash_entry *) + bfd_wrapped_link_hash_lookup (abfd, info, name, + true, true, + false)); + } if (*sym_hash == NULL) goto error_return; if (((*sym_hash)->root.type == bfd_link_hash_defined @@ -2806,7 +2815,7 @@ boolean bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, file_align, maxstack, maxdata, gc, modtype, textro, export_defineds, - special_sections) + special_sections, rtld) bfd *output_bfd; struct bfd_link_info *info; const char *libpath; @@ -2819,6 +2828,7 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, boolean textro; boolean export_defineds; asection **special_sections; + boolean rtld; { struct xcoff_link_hash_entry *hentry; asection *lsec; @@ -2837,7 +2847,6 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour) { - for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++) special_sections[i] = NULL; return true; @@ -2859,11 +2868,8 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, xcoff_hash_table (info)->file_align = file_align; xcoff_hash_table (info)->textro = textro; - if (entry == NULL) - { - hentry = NULL; - } - else + hentry = NULL; + if (entry != NULL) { hentry = xcoff_link_hash_lookup (xcoff_hash_table (info), entry, false, false, true); @@ -2872,65 +2878,56 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, } /* __rtinit */ - if (info->init_function || info->fini_function) { - struct xcoff_link_hash_entry *hrtinit; - struct internal_ldsym *ldsym; - - hrtinit = xcoff_link_hash_lookup (xcoff_hash_table (info), - "__rtinit", - false, false, true); - if (hrtinit != NULL) - { - xcoff_mark_symbol (info, hrtinit); - hrtinit->flags |= (XCOFF_DEF_REGULAR | XCOFF_RTINIT); - } - else - { - (*_bfd_error_handler) - (_("error: undefined symbol __rtinit")); - - return false; - } - - /* __rtinit initalized here - Some information, like the location of the .initfini seciton will - be filled in later. - - name or offset taken care of below with bfd_xcoff_put_ldsymbol_name. */ - amt = sizeof (struct internal_ldsym); - ldsym = (struct internal_ldsym *) bfd_malloc (amt); - - ldsym->l_value = 0; /* will be filled in later */ - ldsym->l_scnum = 2; /* data section */ - ldsym->l_smtype = XTY_SD; /* csect section definition */ - ldsym->l_smclas = 5; /* .rw */ - ldsym->l_ifile = 0; /* special system loader symbol */ - ldsym->l_parm = 0; /* NA */ - - /* Force __rtinit to be the first symbol in the loader symbol table - See xcoff_build_ldsyms - - The first 3 symbol table indices are reserved to indicate the data, - text and bss sections. */ - BFD_ASSERT (0 == ldinfo.ldsym_count); - - hrtinit->ldindx = 3; - ldinfo.ldsym_count = 1; - hrtinit->ldsym = ldsym; - - if (false == bfd_xcoff_put_ldsymbol_name (ldinfo.output_bfd, &ldinfo, - hrtinit->ldsym, - hrtinit->root.root.string)) - { + if (info->init_function || info->fini_function || rtld) + { + struct xcoff_link_hash_entry *hsym; + struct internal_ldsym *ldsym; + + hsym = xcoff_link_hash_lookup (xcoff_hash_table (info), + "__rtinit", false, false, true); + if (hsym == NULL) + { + (*_bfd_error_handler) + (_("error: undefined symbol __rtinit")); + return false; + } + + xcoff_mark_symbol (info, hsym); + hsym->flags |= (XCOFF_DEF_REGULAR | XCOFF_RTINIT); + + /* __rtinit initalized */ + amt = sizeof (struct internal_ldsym); + ldsym = (struct internal_ldsym *) bfd_malloc (amt); + + ldsym->l_value = 0; /* will be filled in later */ + ldsym->l_scnum = 2; /* data section */ + ldsym->l_smtype = XTY_SD; /* csect section definition */ + ldsym->l_smclas = 5; /* .rw */ + ldsym->l_ifile = 0; /* special system loader symbol */ + ldsym->l_parm = 0; /* NA */ + + /* Force __rtinit to be the first symbol in the loader symbol table + See xcoff_build_ldsyms + + The first 3 symbol table indices are reserved to indicate the data, + text and bss sections. */ + BFD_ASSERT (0 == ldinfo.ldsym_count); + + hsym->ldindx = 3; + ldinfo.ldsym_count = 1; + hsym->ldsym = ldsym; + + if (false == bfd_xcoff_put_ldsymbol_name (ldinfo.output_bfd, &ldinfo, + hsym->ldsym, + hsym->root.root.string)) return false; - } - - /* This symbol is written out by xcoff_write_global_symbol - Set stuff up so xcoff_write_global_symbol logic works. */ - hrtinit->flags |= XCOFF_DEF_REGULAR | XCOFF_MARK; - hrtinit->root.type = bfd_link_hash_defined; - hrtinit->root.u.def.value = 0; - } + + /* This symbol is written out by xcoff_write_global_symbol + Set stuff up so xcoff_write_global_symbol logic works. */ + hsym->flags |= XCOFF_DEF_REGULAR | XCOFF_MARK; + hsym->root.type = bfd_link_hash_defined; + hsym->root.u.def.value = 0; + } /* Garbage collect unused sections. */ if (info->relocateable @@ -3158,37 +3155,42 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, csectpp = xcoff_data (sub)->csects; - symesz = bfd_coff_symesz (sub); - esym = (bfd_byte *) obj_coff_external_syms (sub); - esymend = esym + symcount * symesz; - while (esym < esymend) + /* Dynamic object do not have csectpp's. */ + if (NULL != csectpp) { - struct internal_syment sym; + symesz = bfd_coff_symesz (sub); + esym = (bfd_byte *) obj_coff_external_syms (sub); + esymend = esym + symcount * symesz; - bfd_coff_swap_sym_in (sub, (PTR) esym, (PTR) &sym); + while (esym < esymend) + { + struct internal_syment sym; - *debug_index = (unsigned long) -1; + bfd_coff_swap_sym_in (sub, (PTR) esym, (PTR) &sym); - if (sym._n._n_n._n_zeroes == 0 - && *csectpp != NULL - && (! gc - || ((*csectpp)->flags & SEC_MARK) != 0 - || *csectpp == bfd_abs_section_ptr) - && bfd_coff_symname_in_debug (sub, &sym)) - { - char *name; - bfd_size_type indx; + *debug_index = (unsigned long) -1; - name = (char *) debug_contents + sym._n._n_n._n_offset; - indx = _bfd_stringtab_add (debug_strtab, name, true, true); - if (indx == (bfd_size_type) -1) - goto error_return; - *debug_index = indx; - } + if (sym._n._n_n._n_zeroes == 0 + && *csectpp != NULL + && (! gc + || ((*csectpp)->flags & SEC_MARK) != 0 + || *csectpp == bfd_abs_section_ptr) + && bfd_coff_symname_in_debug (sub, &sym)) + { + char *name; + bfd_size_type indx; - esym += (sym.n_numaux + 1) * symesz; - csectpp += sym.n_numaux + 1; - debug_index += sym.n_numaux + 1; + name = (char *) debug_contents + sym._n._n_n._n_offset; + indx = _bfd_stringtab_add (debug_strtab, name, true, true); + if (indx == (bfd_size_type) -1) + goto error_return; + *debug_index = indx; + } + + esym += (sym.n_numaux + 1) * symesz; + csectpp += sym.n_numaux + 1; + debug_index += sym.n_numaux + 1; + } } free (debug_contents); @@ -3220,10 +3222,11 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, } boolean -bfd_xcoff_link_generate_rtinit (abfd, init, fini) +bfd_xcoff_link_generate_rtinit (abfd, init, fini, rtld) bfd *abfd; const char *init; const char *fini; + boolean rtld; { struct bfd_in_memory *bim; @@ -3242,7 +3245,7 @@ bfd_xcoff_link_generate_rtinit (abfd, init, fini) abfd->direction = write_direction; abfd->where = 0; - if (false == bfd_xcoff_generate_rtinit (abfd, init, fini)) + if (false == bfd_xcoff_generate_rtinit (abfd, init, fini, rtld)) return false; /* need to reset to unknown or it will not be read back in correctly */ @@ -3267,14 +3270,9 @@ xcoff_build_ldsyms (h, p) if (h->root.type == bfd_link_hash_warning) h = (struct xcoff_link_hash_entry *) h->root.u.i.link; - /* __rtinit - Special handling of this symbol to make is the first symbol in - the loader symbol table. Make sure this pass through does not - undo it. */ + /* __rtinit, this symbol has special handling. */ if (h->flags & XCOFF_RTINIT) - { return true; - } /* If this is a final link, and the symbol was defined as a common symbol in a regular object file, and there was no definition in @@ -3389,17 +3387,11 @@ xcoff_build_ldsyms (h, p) xcoff32 uses 4 bytes in the toc. xcoff64 uses 8 bytes in the toc. */ if (bfd_xcoff_is_xcoff64 (ldinfo->output_bfd)) - { - byte_size = 8; - } + byte_size = 8; else if (bfd_xcoff_is_xcoff32 (ldinfo->output_bfd)) - { - byte_size = 4; - } + byte_size = 4; else - { - return false; - } + return false; hds->toc_section = xcoff_hash_table (ldinfo->info)->toc_section; hds->u.toc_offset = hds->toc_section->_raw_size; @@ -5895,7 +5887,10 @@ xcoff_write_global_symbol (h, inf) isym.n_value = (h->root.u.def.section->output_section->vma + h->root.u.def.section->output_offset + h->root.u.def.value); - isym.n_scnum = h->root.u.def.section->output_section->target_index; + if (bfd_is_abs_section (h->root.u.def.section->output_section)) + isym.n_scnum = N_ABS; + else + isym.n_scnum = h->root.u.def.section->output_section->target_index; isym.n_sclass = C_HIDEXT; aux.x_csect.x_smtyp = XTY_SD; |