From: Alan Modra Date: Sat, 27 Apr 2002 08:30:16 +0000 (+0000) Subject: * reloc.c: Move sh relocs to where they belong. X-Git-Tag: binutils-2_12_1~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3500b0b153c8dc9aa424eecfa8c092e4d95dd60a;p=thirdparty%2Fbinutils-gdb.git * reloc.c: Move sh relocs to where they belong. * libbfd.h, bfd-in2.h: Regenerate. Merge from mainline 2002-04-26 Alan Modra * 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 * elf32-hppa.c (hppa_type_of_stub): Correct and simplify condition under which a plt call stub is used. (final_link_relocate): Similarly. (allocate_plt_static): Clear h-plabel except when plt entry is exclusively used for a plabel. (allocate_dynrelocs): Use the above to simplify plt sizing. (struct elf32_hppa_link_hash_table): Add has_22bit_branch. (elf32_hppa_link_hash_table_create): Init. (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 * 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 * 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 * elf32-ppc.c (ppc_elf_add_symbol_hook): Check the hash table type. 2002-04-08 Randolph Chung * 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5e7b00ff41c..d579edc01ea 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,57 @@ +2002-04-27 Alan Modra + + * reloc.c: Move sh relocs to where they belong. + * libbfd.h, bfd-in2.h: Regenerate. + + Merge from mainline + 2002-04-26 Alan Modra + * 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 + * elf32-hppa.c (hppa_type_of_stub): Correct and simplify condition + under which a plt call stub is used. + (final_link_relocate): Similarly. + (allocate_plt_static): Clear h-plabel except when plt entry is + exclusively used for a plabel. + (allocate_dynrelocs): Use the above to simplify plt sizing. + (struct elf32_hppa_link_hash_table): Add has_22bit_branch. + (elf32_hppa_link_hash_table_create): Init. + (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 + * 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 + * 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 + * elf32-ppc.c (ppc_elf_add_symbol_hook): Check the hash table type. + + 2002-04-08 Randolph Chung + * 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-26 Richard Smith Jakub Jelinek diff --git a/bfd/ChangeLog-9495 b/bfd/ChangeLog-9495 index 4657d6683fd..a208f42991d 100644 --- a/bfd/ChangeLog-9495 +++ b/bfd/ChangeLog-9495 @@ -6887,7 +6887,7 @@ Tue May 24 16:17:18 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) * libelf.h (struct elf_obj_tdata): Add new field bad_symtab. (elf_bad_symtab): Define new accessor macro. (_bfd_elf_link_hash_newfunc): Declare. - (_bew_elf_link_hash_table_init): Declare. + (_bfd_elf_link_hash_table_init): Declare. * elfcode.h (elf_object_p): Call backend object_p hook after swapping in all the section headers. (map_program_segments): Correct typo: Internal for External. diff --git a/bfd/archures.c b/bfd/archures.c index 9a91424a6ef..40102e8b0f1 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -288,7 +288,9 @@ DESCRIPTION . const char *arch_name; . const char *printable_name; . unsigned int section_align_power; -. {* True if this is the default machine for the architecture. *} +. {* True if this is the default machine for the architecture. +. The default arch should be the first entry for an arch so that +. all the entries for that arch can be accessed via <>. *} . boolean the_default; . const struct bfd_arch_info * (*compatible) . PARAMS ((const struct bfd_arch_info *a, @@ -604,21 +606,9 @@ bfd_default_set_arch_mach (abfd, arch, mach) enum bfd_architecture arch; unsigned long mach; { - const bfd_arch_info_type * const *app, *ap; - - for (app = bfd_archures_list; *app != NULL; app++) - { - for (ap = *app; ap != NULL; ap = ap->next) - { - if (ap->arch == arch - && (ap->mach == mach - || (mach == 0 && ap->the_default))) - { - abfd->arch_info = ap; - return true; - } - } - } + abfd->arch_info = bfd_lookup_arch (arch, mach); + if (abfd->arch_info != NULL) + return true; abfd->arch_info = &bfd_default_arch_struct; bfd_set_error (bfd_error_bad_value); diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 93696aeec9f..a69b3750ae8 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1657,7 +1657,9 @@ typedef struct bfd_arch_info const char *arch_name; const char *printable_name; unsigned int section_align_power; - /* True if this is the default machine for the architecture. */ + /* True if this is the default machine for the architecture. + The default arch should be the first entry for an arch so that + all the entries for that arch can be accessed via <>. */ boolean the_default; const struct bfd_arch_info * (*compatible) PARAMS ((const struct bfd_arch_info *a, @@ -2194,55 +2196,6 @@ to compensate for the borrow when the low bits are added. */ BFD_RELOC_MIPS_REL16, BFD_RELOC_MIPS_RELGOT, BFD_RELOC_MIPS_JALR, - BFD_RELOC_SH_GOT_LOW16, - BFD_RELOC_SH_GOT_MEDLOW16, - BFD_RELOC_SH_GOT_MEDHI16, - BFD_RELOC_SH_GOT_HI16, - BFD_RELOC_SH_GOTPLT_LOW16, - BFD_RELOC_SH_GOTPLT_MEDLOW16, - BFD_RELOC_SH_GOTPLT_MEDHI16, - BFD_RELOC_SH_GOTPLT_HI16, - BFD_RELOC_SH_PLT_LOW16, - BFD_RELOC_SH_PLT_MEDLOW16, - BFD_RELOC_SH_PLT_MEDHI16, - BFD_RELOC_SH_PLT_HI16, - BFD_RELOC_SH_GOTOFF_LOW16, - BFD_RELOC_SH_GOTOFF_MEDLOW16, - BFD_RELOC_SH_GOTOFF_MEDHI16, - BFD_RELOC_SH_GOTOFF_HI16, - BFD_RELOC_SH_GOTPC_LOW16, - BFD_RELOC_SH_GOTPC_MEDLOW16, - BFD_RELOC_SH_GOTPC_MEDHI16, - BFD_RELOC_SH_GOTPC_HI16, - BFD_RELOC_SH_COPY64, - BFD_RELOC_SH_GLOB_DAT64, - BFD_RELOC_SH_JMP_SLOT64, - BFD_RELOC_SH_RELATIVE64, - BFD_RELOC_SH_GOT10BY4, - BFD_RELOC_SH_GOT10BY8, - BFD_RELOC_SH_GOTPLT10BY4, - BFD_RELOC_SH_GOTPLT10BY8, - BFD_RELOC_SH_GOTPLT32, - BFD_RELOC_SH_SHMEDIA_CODE, - BFD_RELOC_SH_IMMU5, - BFD_RELOC_SH_IMMS6, - BFD_RELOC_SH_IMMS6BY32, - BFD_RELOC_SH_IMMU6, - BFD_RELOC_SH_IMMS10, - BFD_RELOC_SH_IMMS10BY2, - BFD_RELOC_SH_IMMS10BY4, - BFD_RELOC_SH_IMMS10BY8, - BFD_RELOC_SH_IMMS16, - BFD_RELOC_SH_IMMU16, - BFD_RELOC_SH_IMM_LOW16, - BFD_RELOC_SH_IMM_LOW16_PCREL, - BFD_RELOC_SH_IMM_MEDLOW16, - BFD_RELOC_SH_IMM_MEDLOW16_PCREL, - BFD_RELOC_SH_IMM_MEDHI16, - BFD_RELOC_SH_IMM_MEDHI16_PCREL, - BFD_RELOC_SH_IMM_HI16, - BFD_RELOC_SH_IMM_HI16_PCREL, - BFD_RELOC_SH_PT_16, /* i386/elf relocations */ @@ -2423,6 +2376,55 @@ field in the instruction. */ BFD_RELOC_SH_JMP_SLOT, BFD_RELOC_SH_RELATIVE, BFD_RELOC_SH_GOTPC, + BFD_RELOC_SH_GOT_LOW16, + BFD_RELOC_SH_GOT_MEDLOW16, + BFD_RELOC_SH_GOT_MEDHI16, + BFD_RELOC_SH_GOT_HI16, + BFD_RELOC_SH_GOTPLT_LOW16, + BFD_RELOC_SH_GOTPLT_MEDLOW16, + BFD_RELOC_SH_GOTPLT_MEDHI16, + BFD_RELOC_SH_GOTPLT_HI16, + BFD_RELOC_SH_PLT_LOW16, + BFD_RELOC_SH_PLT_MEDLOW16, + BFD_RELOC_SH_PLT_MEDHI16, + BFD_RELOC_SH_PLT_HI16, + BFD_RELOC_SH_GOTOFF_LOW16, + BFD_RELOC_SH_GOTOFF_MEDLOW16, + BFD_RELOC_SH_GOTOFF_MEDHI16, + BFD_RELOC_SH_GOTOFF_HI16, + BFD_RELOC_SH_GOTPC_LOW16, + BFD_RELOC_SH_GOTPC_MEDLOW16, + BFD_RELOC_SH_GOTPC_MEDHI16, + BFD_RELOC_SH_GOTPC_HI16, + BFD_RELOC_SH_COPY64, + BFD_RELOC_SH_GLOB_DAT64, + BFD_RELOC_SH_JMP_SLOT64, + BFD_RELOC_SH_RELATIVE64, + BFD_RELOC_SH_GOT10BY4, + BFD_RELOC_SH_GOT10BY8, + BFD_RELOC_SH_GOTPLT10BY4, + BFD_RELOC_SH_GOTPLT10BY8, + BFD_RELOC_SH_GOTPLT32, + BFD_RELOC_SH_SHMEDIA_CODE, + BFD_RELOC_SH_IMMU5, + BFD_RELOC_SH_IMMS6, + BFD_RELOC_SH_IMMS6BY32, + BFD_RELOC_SH_IMMU6, + BFD_RELOC_SH_IMMS10, + BFD_RELOC_SH_IMMS10BY2, + BFD_RELOC_SH_IMMS10BY4, + BFD_RELOC_SH_IMMS10BY8, + BFD_RELOC_SH_IMMS16, + BFD_RELOC_SH_IMMU16, + BFD_RELOC_SH_IMM_LOW16, + BFD_RELOC_SH_IMM_LOW16_PCREL, + BFD_RELOC_SH_IMM_MEDLOW16, + BFD_RELOC_SH_IMM_MEDLOW16_PCREL, + BFD_RELOC_SH_IMM_MEDHI16, + BFD_RELOC_SH_IMM_MEDHI16_PCREL, + BFD_RELOC_SH_IMM_HI16, + BFD_RELOC_SH_IMM_HI16_PCREL, + BFD_RELOC_SH_PT_16, /* Thumb 23-, 12- and 9-bit pc-relative branches. The lowest bit must be zero and is not stored in the instruction. */ diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 72690d57397..5c6704f34ec 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -3014,6 +3014,7 @@ coff_compute_section_file_positions (abfd) else current->target_index = target_index++; } + abfd->section_tail = ¤t->next; free (section_list); } diff --git a/bfd/cpu-powerpc.c b/bfd/cpu-powerpc.c index d812618749d..d77b4260c1d 100644 --- a/bfd/cpu-powerpc.c +++ b/bfd/cpu-powerpc.c @@ -50,6 +50,65 @@ powerpc_compatible (a,b) const bfd_arch_info_type bfd_powerpc_archs[] = { +#if BFD_DEFAULT_TARGET_SIZE == 64 /* default arch must come first. */ + { + 64, /* 64 bits in a word */ + 64, /* 64 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_powerpc, + bfd_mach_ppc64, + "powerpc", + "powerpc:common64", + 3, + true, /* default for 64 bit target */ + powerpc_compatible, + bfd_default_scan, + &bfd_powerpc_archs[1] + }, + { + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_powerpc, + bfd_mach_ppc, /* for the POWER/PowerPC common architecture */ + "powerpc", + "powerpc:common", + 3, + false, + powerpc_compatible, + bfd_default_scan, + &bfd_powerpc_archs[2], + }, +#else + { + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_powerpc, + bfd_mach_ppc, /* for the POWER/PowerPC common architecture */ + "powerpc", + "powerpc:common", + 3, + true, /* default for 32 bit target */ + powerpc_compatible, + bfd_default_scan, + &bfd_powerpc_archs[1], + }, + { + 64, /* 64 bits in a word */ + 64, /* 64 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_powerpc, + bfd_mach_ppc64, + "powerpc", + "powerpc:common64", + 3, + false, + powerpc_compatible, + bfd_default_scan, + &bfd_powerpc_archs[2] + }, +#endif { 32, /* 32 bits in a word */ 32, /* 32 bits in an address */ @@ -62,7 +121,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[1] + &bfd_powerpc_archs[3] }, { 32, /* 32 bits in a word */ @@ -76,7 +135,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[2] + &bfd_powerpc_archs[4] }, { 32, /* 32 bits in a word */ @@ -90,7 +149,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[3] + &bfd_powerpc_archs[5] }, { 32, /* 32 bits in a word */ @@ -104,7 +163,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[4] + &bfd_powerpc_archs[6] }, { 32, /* 32 bits in a word */ @@ -118,7 +177,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[5] + &bfd_powerpc_archs[7] }, { 64, /* 64 bits in a word */ @@ -132,7 +191,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[6] + &bfd_powerpc_archs[8] }, { 64, /* 64 bits in a word */ @@ -146,7 +205,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[7] + &bfd_powerpc_archs[9] }, { 64, /* 64 bits in a word */ @@ -160,7 +219,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[8] + &bfd_powerpc_archs[10] }, { 64, /* 64 bits in a word */ @@ -174,7 +233,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[9] + &bfd_powerpc_archs[11] }, { 64, /* 64 bits in a word */ @@ -188,7 +247,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[10] + &bfd_powerpc_archs[12] }, { 32, /* 32 bits in a word */ @@ -202,7 +261,7 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[11] + &bfd_powerpc_archs[13] }, { 32, /* 32 bits in a word */ @@ -216,34 +275,6 @@ const bfd_arch_info_type bfd_powerpc_archs[] = false, /* not the default */ powerpc_compatible, bfd_default_scan, - &bfd_powerpc_archs[12] - }, - { - 64, /* 64 bits in a word */ - 64, /* 64 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_powerpc, - bfd_mach_ppc64, - "powerpc", - "powerpc:common64", - 3, - BFD_DEFAULT_TARGET_SIZE == 64, /* default for 64 bit target */ - powerpc_compatible, - bfd_default_scan, - &bfd_powerpc_archs[13] - }, - { - 32, /* 32 bits in a word */ - 32, /* 32 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_powerpc, - bfd_mach_ppc, /* for the POWER/PowerPC common architecture */ - "powerpc", - "powerpc:common", - 3, - BFD_DEFAULT_TARGET_SIZE != 64, /* default for 32 bit target */ - powerpc_compatible, - bfd_default_scan, 0 } }; diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h index 63d95c5016e..99a66f4e180 100644 --- a/bfd/elf-hppa.h +++ b/bfd/elf-hppa.h @@ -64,6 +64,12 @@ static boolean elf_hppa_fake_sections static void elf_hppa_final_write_processing PARAMS ((bfd *, boolean)); +static int hppa_unwind_entry_compare + PARAMS ((const PTR, const PTR)); + +static boolean elf_hppa_sort_unwind + PARAMS ((bfd *)); + #if ARCH_SIZE == 64 static boolean elf_hppa_add_symbol_hook PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, @@ -86,12 +92,12 @@ static boolean elf_hppa_final_link static boolean elf_hppa_relocate_section PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, - bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); + bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); static bfd_reloc_status_type elf_hppa_final_link_relocate PARAMS ((Elf_Internal_Rela *, bfd *, bfd *, asection *, - bfd_byte *, bfd_vma, struct bfd_link_info *, - asection *, struct elf_link_hash_entry *, + bfd_byte *, bfd_vma, struct bfd_link_info *, + asection *, struct elf_link_hash_entry *, struct elf64_hppa_dyn_hash_entry *)); static int elf_hppa_relocate_insn @@ -709,7 +715,7 @@ elf_hppa_reloc_final_type (abfd, base_type, format, field) be a section relative relocation. Dwarf2 (for example) uses 32bit section relative relocations. */ if (bfd_get_arch_info (abfd)->bits_per_address != 32) - final_type = R_PARISC_SECREL32; + final_type = R_PARISC_SECREL32; break; case e_psel: final_type = R_PARISC_PLABEL32; @@ -1037,6 +1043,64 @@ elf_hppa_final_write_processing (abfd, linker) | EF_PARISC_TRAPNIL); } +/* Comparison function for qsort to sort unwind section during a + final link. */ + +static int +hppa_unwind_entry_compare (a, b) + const PTR a; + const PTR b; +{ + const bfd_byte *ap, *bp; + unsigned long av, bv; + + ap = (const bfd_byte *) a; + av = (unsigned long) ap[0] << 24; + av |= (unsigned long) ap[1] << 16; + av |= (unsigned long) ap[2] << 8; + av |= (unsigned long) ap[3]; + + bp = (const bfd_byte *) b; + bv = (unsigned long) bp[0] << 24; + bv |= (unsigned long) bp[1] << 16; + bv |= (unsigned long) bp[2] << 8; + bv |= (unsigned long) bp[3]; + + return av < bv ? -1 : av > bv ? 1 : 0; +} + +static boolean elf_hppa_sort_unwind (abfd) + bfd *abfd; +{ + asection *s; + + /* Magic section names, but this is much safer than having + relocate_section remember where SEGREL32 relocs occurred. + Consider what happens if someone inept creates a linker script + that puts unwind information in .text. */ + s = bfd_get_section_by_name (abfd, ".PARISC.unwind"); + if (s != NULL) + { + bfd_size_type size; + char *contents; + + size = s->_raw_size; + contents = bfd_malloc (size); + if (contents == NULL) + return false; + + if (! bfd_get_section_contents (abfd, s, contents, (file_ptr) 0, size)) + return false; + + qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare); + + if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size)) + return false; + } + + return true; +} + #if ARCH_SIZE == 64 /* Hook called by the linker routine which adds symbols from an object file. HP's libraries define symbols with HP specific section @@ -1284,6 +1348,11 @@ elf_hppa_final_link (abfd, info) elf_hppa_remark_useless_dynamic_symbols, info); + /* If we're producing a final executable, sort the contents of the + unwind section. */ + if (retval) + retval = elf_hppa_sort_unwind (abfd); + return retval; } @@ -1416,7 +1485,7 @@ elf_hppa_relocate_section (output_bfd, info, input_bfd, input_section, relocation = 0; } /* Allow undefined symbols in shared libraries. */ - else if (info->shared && !info->no_undefined + else if (info->shared && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) { if (info->symbolic) @@ -2006,7 +2075,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, } /* We want the value of the OPD offset for this symbol, not - the symbol's actual address. */ + the symbol's actual address. */ value = (dyn_h->opd_offset + hppa_info->opd_sec->output_offset + hppa_info->opd_sec->output_section->vma); @@ -2047,7 +2116,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, bfd_put_32 (input_bfd, value, hit_data); else bfd_put_64 (input_bfd, value, hit_data); - return bfd_reloc_ok; + return bfd_reloc_ok; } /* Something we don't know how to handle. */ diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index a8d0a446099..ec65f92e6dd 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -71,14 +71,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ (single sub-space version) : addil LR'lt_ptr+ltoff,%dp ; get procedure entry point : ldw RR'lt_ptr+ltoff(%r1),%r21 - : bv %r0(%r21) + : bv %r0(%r21) : ldw RR'lt_ptr+ltoff+4(%r1),%r19 ; get new dlt value. Import stub to call shared library routine from shared library (single sub-space version) : addil LR'ltoff,%r19 ; get procedure entry point : ldw RR'ltoff(%r1),%r21 - : bv %r0(%r21) + : bv %r0(%r21) : ldw RR'ltoff+4(%r1),%r19 ; get new dlt value. Import stub to call shared library routine from normal object file @@ -203,9 +203,6 @@ struct elf32_hppa_link_hash_entry { #endif } *dyn_relocs; - /* Set during a static link if we detect a function is PIC. */ - unsigned int maybe_pic_call:1; - /* Set if the only reason we need a .plt entry is for a non-PIC to PIC function call. */ unsigned int pic_call:1; @@ -255,10 +252,11 @@ struct elf32_hppa_link_hash_table { /* Whether we support multiple sub-spaces for shared libs. */ unsigned int multi_subspace:1; - /* Flags set when PCREL12F and PCREL17F branches detected. Used to + /* Flags set when various size branches are detected. Used to select suitable defaults for the stub group size. */ unsigned int has_12bit_branch:1; unsigned int has_17bit_branch:1; + unsigned int has_22bit_branch:1; /* Set if we need a .plt stub to support lazy dynamic linking. */ unsigned int need_plt_stub:1; @@ -373,9 +371,6 @@ static boolean elf32_hppa_relocate_section PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); -static int hppa_unwind_entry_compare - PARAMS ((const PTR, const PTR)); - static boolean elf32_hppa_finish_dynamic_symbol PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, Elf_Internal_Sym *)); @@ -460,7 +455,6 @@ hppa_link_hash_newfunc (entry, table, string) eh = (struct elf32_hppa_link_hash_entry *) entry; eh->stub_cache = NULL; eh->dyn_relocs = NULL; - eh->maybe_pic_call = 0; eh->pic_call = 0; eh->plabel = 0; } @@ -508,6 +502,7 @@ elf32_hppa_link_hash_table_create (abfd) ret->multi_subspace = 0; ret->has_12bit_branch = 0; ret->has_17bit_branch = 0; + ret->has_22bit_branch = 0; ret->need_plt_stub = 0; ret->sym_sec.abfd = NULL; @@ -670,21 +665,12 @@ hppa_type_of_stub (input_sec, rel, hash, destination) unsigned int r_type; if (hash != NULL - && (((hash->elf.root.type == bfd_link_hash_defined - || hash->elf.root.type == bfd_link_hash_defweak) - && hash->elf.root.u.def.section->output_section == NULL) - || (hash->elf.root.type == bfd_link_hash_defweak - && hash->elf.dynindx != -1 - && hash->elf.plt.offset != (bfd_vma) -1) - || hash->elf.root.type == bfd_link_hash_undefweak - || hash->elf.root.type == bfd_link_hash_undefined - || (hash->maybe_pic_call && !(input_sec->flags & SEC_HAS_GOT_REF)))) + && hash->elf.plt.offset != (bfd_vma) -1 + && (hash->elf.dynindx != -1 || hash->pic_call) + && !hash->plabel) { - /* If output_section is NULL, then it's a symbol defined in a - shared library. We will need an import stub. Decide between - hppa_stub_import and hppa_stub_import_shared later. For - shared links we need stubs for undefined or weak syms too; - They will presumably be resolved by the dynamic linker. */ + /* We need an import stub. Decide between hppa_stub_import + and hppa_stub_import_shared later. */ return hppa_stub_import; } @@ -742,6 +728,7 @@ hppa_type_of_stub (input_sec, rel, hash, destination) #define BE_SR0_R21 0xe2a00000 /* be 0(%sr0,%r21) */ #define STW_RP 0x6bc23fd1 /* stw %rp,-24(%sr0,%sp) */ +#define BL22_RP 0xe800a002 /* b,l,n XXX,%rp */ #define BL_RP 0xe8400002 /* b,l,n XXX,%rp */ #define NOP 0x08000240 /* nop */ #define LDW_RP 0x4bc23fd1 /* ldw -24(%sr0,%sp),%rp */ @@ -931,7 +918,9 @@ hppa_build_one_stub (gen_entry, in_arg) + stub_sec->output_offset + stub_sec->output_section->vma); - if (sym_value - 8 + 0x40000 >= 0x80000) + if (sym_value - 8 + (1 << (17 + 1)) >= (1 << (17 + 2)) + && (!htab->has_22bit_branch + || sym_value - 8 + (1 << (22 + 1)) >= (1 << (22 + 2)))) { (*_bfd_error_handler) (_("%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections"), @@ -944,7 +933,10 @@ hppa_build_one_stub (gen_entry, in_arg) } val = hppa_field_adjust (sym_value, (bfd_signed_vma) -8, e_fsel) >> 2; - insn = hppa_rebuild_insn ((int) BL_RP, val, 17); + if (!htab->has_22bit_branch) + insn = hppa_rebuild_insn ((int) BL_RP, val, 17); + else + insn = hppa_rebuild_insn ((int) BL22_RP, val, 22); bfd_put_32 (stub_bfd, insn, loc); bfd_put_32 (stub_bfd, (bfd_vma) NOP, loc + 4); @@ -1263,12 +1255,16 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs) case R_PARISC_PCREL12F: htab->has_12bit_branch = 1; - /* Fall thru. */ + goto branch_common; + case R_PARISC_PCREL17C: case R_PARISC_PCREL17F: htab->has_17bit_branch = 1; - /* Fall thru. */ + goto branch_common; + case R_PARISC_PCREL22F: + htab->has_22bit_branch = 1; + branch_common: /* Function calls might need to go through the .plt, and might require long branch stubs. */ if (h == NULL) @@ -1322,7 +1318,7 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs) case R_PARISC_DIR14F: /* Used for load/store from absolute locn. */ case R_PARISC_DIR14R: case R_PARISC_DIR21L: /* As above, and for ext branches too. */ -#if 1 +#if 0 /* Help debug shared library creation. Any of the above relocs can be used in shared libs, but they may cause pages to become unshared. */ @@ -1838,19 +1834,10 @@ elf32_hppa_adjust_dynamic_symbol (info, h) unsigned int power_of_two; /* If this is a function, put it in the procedure linkage table. We - will fill in the contents of the procedure linkage table later, - when we know the address of the .got section. */ + will fill in the contents of the procedure linkage table later. */ if (h->type == STT_FUNC || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) { - if (!info->shared - && h->plt.refcount > 0 - && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0 - && (h->root.u.def.section->flags & SEC_HAS_GOT_REF) != 0) - { - ((struct elf32_hppa_link_hash_entry *) h)->maybe_pic_call = 1; - } - if (h->plt.refcount <= 0 || ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0 && h->root.type != bfd_link_hash_defweak @@ -1867,7 +1854,10 @@ elf32_hppa_adjust_dynamic_symbol (info, h) /* As a special sop to the hppa ABI, we keep a .plt entry for functions in sections containing PIC code. */ - if (((struct elf32_hppa_link_hash_entry *) h)->maybe_pic_call) + if (!info->shared + && h->plt.refcount > 0 + && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0 + && (h->root.u.def.section->flags & SEC_HAS_GOT_REF) != 0) ((struct elf32_hppa_link_hash_entry *) h)->pic_call = 1; else { @@ -1918,7 +1908,7 @@ elf32_hppa_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; @@ -1996,7 +1986,6 @@ mark_PIC_calls (h, inf) } h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; - ((struct elf32_hppa_link_hash_entry *) h)->maybe_pic_call = 1; ((struct elf32_hppa_link_hash_entry *) h)->pic_call = 1; return true; @@ -2026,6 +2015,7 @@ allocate_plt_static (h, inf) { /* Make an entry in the .plt section for non-pic code that is calling pic code. */ + ((struct elf32_hppa_link_hash_entry *) h)->plabel = 0; s = htab->splt; h->plt.offset = s->_raw_size; s->_raw_size += PLT_ENTRY_SIZE; @@ -2045,7 +2035,11 @@ allocate_plt_static (h, inf) if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h)) { - /* Allocate these later. */ + /* Allocate these later. From this point on, h->plabel + means that the plt entry is only used by a plabel. + We'll be using a normal plt entry for this symbol, so + clear the plabel indicator. */ + ((struct elf32_hppa_link_hash_entry *) h)->plabel = 0; } else if (((struct elf32_hppa_link_hash_entry *) h)->plabel) { @@ -2096,7 +2090,7 @@ allocate_dynrelocs (h, inf) if (htab->elf.dynamic_sections_created && h->plt.offset != (bfd_vma) -1 && !((struct elf32_hppa_link_hash_entry *) h)->pic_call - && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h)) + && !((struct elf32_hppa_link_hash_entry *) h)->plabel) { /* Make an entry in the .plt section. */ s = htab->splt; @@ -3267,37 +3261,13 @@ elf32_hppa_final_link (abfd, info) bfd *abfd; struct bfd_link_info *info; { - asection *s; - /* Invoke the regular ELF linker to do all the work. */ if (!bfd_elf32_bfd_final_link (abfd, info)) return false; /* If we're producing a final executable, sort the contents of the - unwind section. Magic section names, but this is much safer than - having elf32_hppa_relocate_section remember where SEGREL32 relocs - occurred. Consider what happens if someone inept creates a - linker script that puts unwind information in .text. */ - s = bfd_get_section_by_name (abfd, ".PARISC.unwind"); - if (s != NULL) - { - bfd_size_type size; - char *contents; - - size = s->_raw_size; - contents = bfd_malloc (size); - if (contents == NULL) - return false; - - if (! bfd_get_section_contents (abfd, s, contents, (file_ptr) 0, size)) - return false; - - qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare); - - if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size)) - return false; - } - return true; + unwind section. */ + return elf_hppa_sort_unwind (abfd); } /* Record the lowest address for the data and text segments. */ @@ -3370,19 +3340,14 @@ final_link_relocate (input_section, contents, rel, value, htab, sym_sec, h) case R_PARISC_PCREL12F: case R_PARISC_PCREL17F: case R_PARISC_PCREL22F: - /* If this is a call to a function defined in another dynamic - library, or if it is a call to a PIC function in the same - object, or if this is a shared link and it is a call to a - weak symbol which may or may not be in the same object, then - find the import stub in the stub hash. */ + /* If this call should go via the plt, find the import stub in + the stub hash. */ if (sym_sec == NULL || sym_sec->output_section == NULL || (h != NULL - && ((h->maybe_pic_call - && !(input_section->flags & SEC_HAS_GOT_REF)) - || (h->elf.root.type == bfd_link_hash_defweak - && h->elf.dynindx != -1 - && h->elf.plt.offset != (bfd_vma) -1)))) + && h->elf.plt.offset != (bfd_vma) -1 + && (h->elf.dynindx != -1 || h->pic_call) + && !h->plabel)) { stub_entry = hppa_get_stub_entry (input_section, sym_sec, h, rel, htab); @@ -3437,7 +3402,7 @@ final_link_relocate (input_section, contents, rel, value, htab, sym_sec, h) == (((int) OP_ADDIL << 26) | (27 << 21))) { insn &= ~ (0x1f << 21); -#if 1 /* debug them. */ +#if 0 /* debug them. */ (*_bfd_error_handler) (_("%s(%s+0x%lx): fixing %s"), bfd_archive_filename (input_bfd), @@ -4108,32 +4073,6 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section, return true; } -/* Comparison function for qsort to sort unwind section during a - final link. */ - -static int -hppa_unwind_entry_compare (a, b) - const PTR a; - const PTR b; -{ - const bfd_byte *ap, *bp; - unsigned long av, bv; - - ap = (const bfd_byte *) a; - av = (unsigned long) ap[0] << 24; - av |= (unsigned long) ap[1] << 16; - av |= (unsigned long) ap[2] << 8; - av |= (unsigned long) ap[3]; - - bp = (const bfd_byte *) b; - bv = (unsigned long) bp[0] << 24; - bv |= (unsigned long) bp[1] << 16; - bv |= (unsigned long) bp[2] << 8; - bv |= (unsigned long) bp[3]; - - return av < bv ? -1 : av > bv ? 1 : 0; -} - /* Finish up dynamic symbol handling. We set the contents of various dynamic sections here. */ diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 1ce1827acae..b3b62204893 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -838,7 +838,8 @@ m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) { if (! info->relocateable && (*namep)[0] == '_' && (*namep)[1] == 'S' - && strcmp (*namep, "_SDA_BASE_") == 0) + && strcmp (*namep, "_SDA_BASE_") == 0 + && info->hash->creator->flavour == bfd_target_elf_flavour) { /* This is simpler than using _bfd_elf_create_linker_section (our needs are simpler than ppc's needs). Also diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index be6cfabb195..9549d29367e 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -2542,7 +2542,8 @@ ppc_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) { if (sym->st_shndx == SHN_COMMON && !info->relocateable - && sym->st_size <= elf_gp_size (abfd)) + && sym->st_size <= elf_gp_size (abfd) + && info->hash->creator->flavour == bfd_target_elf_flavour) { /* Common symbols less than or equal to -G nn bytes are automatically put into .sdata. */ diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c index 5c85d36c2dd..5e7ccdd6822 100644 --- a/bfd/elf32-sh64.c +++ b/bfd/elf32-sh64.c @@ -389,7 +389,8 @@ sh64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) bfd_vma *valp; { /* We want to do this for relocatable as well as final linking. */ - if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL) + if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL + && info->hash->creator->flavour == bfd_target_elf_flavour) { struct elf_link_hash_entry *h; diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c index 3bda435c987..96146ed016e 100644 --- a/bfd/elf64-mmix.c +++ b/bfd/elf64-mmix.c @@ -1953,16 +1953,16 @@ mmix_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) strlen (MMIX_LOC_SECTION_START_SYMBOL_PREFIX)) == 0) { /* See if we have another one. */ - struct elf_link_hash_entry *h - = (struct elf_link_hash_entry *) bfd_link_hash_lookup (info->hash, - *namep, - false, - false, false); + struct bfd_link_hash_entry *h = bfd_link_hash_lookup (info->hash, + *namep, + false, + false, + false); - if (h != NULL && h->root.type != bfd_link_hash_undefined) + if (h != NULL && h->type != bfd_link_hash_undefined) { /* How do we get the asymbol (or really: the filename) from h? - h->root.u.def.section->owner is NULL. */ + h->u.def.section->owner is NULL. */ ((*_bfd_error_handler) (_("%s: Error: multiple definition of `%s'; start of %s is set in a earlier linked file\n"), bfd_get_filename (abfd), *namep, diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index dee4a44d97a..7b91b9df5e1 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -2929,7 +2929,8 @@ sh64_elf64_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) bfd_vma *valp; { /* We want to do this for relocatable as well as final linking. */ - if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL) + if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL + && info->hash->creator->flavour == bfd_target_elf_flavour) { struct elf_link_hash_entry *h; diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index 78d2a560f67..d04a1d3b580 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -1,5 +1,5 @@ /* SPARC-specific support for 64-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. @@ -1385,9 +1385,8 @@ sparc64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) *namep = NULL; return true; } - else if (! *namep || ! **namep) - return true; - else + else if (*namep && **namep + && info->hash->creator->flavour == bfd_target_elf_flavour) { int i; struct sparc64_elf_app_reg *p; diff --git a/bfd/elflink.h b/bfd/elflink.h index d43d8612d15..06035b31bee 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -5347,21 +5347,11 @@ elf_bfd_final_link (abfd, info) { for (p = o->link_order_head; p != NULL; p = p->next) { - Elf_Internal_Shdr *rhdr; - if (p->type == bfd_indirect_link_order - && (bfd_get_flavour (p->u.indirect.section->owner) + && (bfd_get_flavour ((sub = p->u.indirect.section->owner)) == bfd_target_elf_flavour) - && (((rhdr = &elf_section_data (p->u.indirect.section)->rel_hdr) - ->sh_entsize == 0) - || rhdr->sh_entsize == sizeof (Elf_External_Rel) - || rhdr->sh_entsize == sizeof (Elf_External_Rela)) - && (((rhdr = elf_section_data (p->u.indirect.section)->rel_hdr2) - == NULL) - || rhdr->sh_entsize == sizeof (Elf_External_Rel) - || rhdr->sh_entsize == sizeof (Elf_External_Rela))) + && elf_elfheader (sub)->e_ident[EI_CLASS] == bed->s->elfclass) { - sub = p->u.indirect.section->owner; if (! sub->output_has_begun) { if (! elf_link_input_bfd (&finfo, sub)) diff --git a/bfd/libbfd.h b/bfd/libbfd.h index e7ba1c58e4f..55d192cc048 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -752,55 +752,6 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_MIPS_REL16", "BFD_RELOC_MIPS_RELGOT", "BFD_RELOC_MIPS_JALR", - "BFD_RELOC_SH_GOT_LOW16", - "BFD_RELOC_SH_GOT_MEDLOW16", - "BFD_RELOC_SH_GOT_MEDHI16", - "BFD_RELOC_SH_GOT_HI16", - "BFD_RELOC_SH_GOTPLT_LOW16", - "BFD_RELOC_SH_GOTPLT_MEDLOW16", - "BFD_RELOC_SH_GOTPLT_MEDHI16", - "BFD_RELOC_SH_GOTPLT_HI16", - "BFD_RELOC_SH_PLT_LOW16", - "BFD_RELOC_SH_PLT_MEDLOW16", - "BFD_RELOC_SH_PLT_MEDHI16", - "BFD_RELOC_SH_PLT_HI16", - "BFD_RELOC_SH_GOTOFF_LOW16", - "BFD_RELOC_SH_GOTOFF_MEDLOW16", - "BFD_RELOC_SH_GOTOFF_MEDHI16", - "BFD_RELOC_SH_GOTOFF_HI16", - "BFD_RELOC_SH_GOTPC_LOW16", - "BFD_RELOC_SH_GOTPC_MEDLOW16", - "BFD_RELOC_SH_GOTPC_MEDHI16", - "BFD_RELOC_SH_GOTPC_HI16", - "BFD_RELOC_SH_COPY64", - "BFD_RELOC_SH_GLOB_DAT64", - "BFD_RELOC_SH_JMP_SLOT64", - "BFD_RELOC_SH_RELATIVE64", - "BFD_RELOC_SH_GOT10BY4", - "BFD_RELOC_SH_GOT10BY8", - "BFD_RELOC_SH_GOTPLT10BY4", - "BFD_RELOC_SH_GOTPLT10BY8", - "BFD_RELOC_SH_GOTPLT32", - "BFD_RELOC_SH_SHMEDIA_CODE", - "BFD_RELOC_SH_IMMU5", - "BFD_RELOC_SH_IMMS6", - "BFD_RELOC_SH_IMMS6BY32", - "BFD_RELOC_SH_IMMU6", - "BFD_RELOC_SH_IMMS10", - "BFD_RELOC_SH_IMMS10BY2", - "BFD_RELOC_SH_IMMS10BY4", - "BFD_RELOC_SH_IMMS10BY8", - "BFD_RELOC_SH_IMMS16", - "BFD_RELOC_SH_IMMU16", - "BFD_RELOC_SH_IMM_LOW16", - "BFD_RELOC_SH_IMM_LOW16_PCREL", - "BFD_RELOC_SH_IMM_MEDLOW16", - "BFD_RELOC_SH_IMM_MEDLOW16_PCREL", - "BFD_RELOC_SH_IMM_MEDHI16", - "BFD_RELOC_SH_IMM_MEDHI16_PCREL", - "BFD_RELOC_SH_IMM_HI16", - "BFD_RELOC_SH_IMM_HI16_PCREL", - "BFD_RELOC_SH_PT_16", "BFD_RELOC_386_GOT32", "BFD_RELOC_386_PLT32", @@ -947,6 +898,55 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_SH_JMP_SLOT", "BFD_RELOC_SH_RELATIVE", "BFD_RELOC_SH_GOTPC", + "BFD_RELOC_SH_GOT_LOW16", + "BFD_RELOC_SH_GOT_MEDLOW16", + "BFD_RELOC_SH_GOT_MEDHI16", + "BFD_RELOC_SH_GOT_HI16", + "BFD_RELOC_SH_GOTPLT_LOW16", + "BFD_RELOC_SH_GOTPLT_MEDLOW16", + "BFD_RELOC_SH_GOTPLT_MEDHI16", + "BFD_RELOC_SH_GOTPLT_HI16", + "BFD_RELOC_SH_PLT_LOW16", + "BFD_RELOC_SH_PLT_MEDLOW16", + "BFD_RELOC_SH_PLT_MEDHI16", + "BFD_RELOC_SH_PLT_HI16", + "BFD_RELOC_SH_GOTOFF_LOW16", + "BFD_RELOC_SH_GOTOFF_MEDLOW16", + "BFD_RELOC_SH_GOTOFF_MEDHI16", + "BFD_RELOC_SH_GOTOFF_HI16", + "BFD_RELOC_SH_GOTPC_LOW16", + "BFD_RELOC_SH_GOTPC_MEDLOW16", + "BFD_RELOC_SH_GOTPC_MEDHI16", + "BFD_RELOC_SH_GOTPC_HI16", + "BFD_RELOC_SH_COPY64", + "BFD_RELOC_SH_GLOB_DAT64", + "BFD_RELOC_SH_JMP_SLOT64", + "BFD_RELOC_SH_RELATIVE64", + "BFD_RELOC_SH_GOT10BY4", + "BFD_RELOC_SH_GOT10BY8", + "BFD_RELOC_SH_GOTPLT10BY4", + "BFD_RELOC_SH_GOTPLT10BY8", + "BFD_RELOC_SH_GOTPLT32", + "BFD_RELOC_SH_SHMEDIA_CODE", + "BFD_RELOC_SH_IMMU5", + "BFD_RELOC_SH_IMMS6", + "BFD_RELOC_SH_IMMS6BY32", + "BFD_RELOC_SH_IMMU6", + "BFD_RELOC_SH_IMMS10", + "BFD_RELOC_SH_IMMS10BY2", + "BFD_RELOC_SH_IMMS10BY4", + "BFD_RELOC_SH_IMMS10BY8", + "BFD_RELOC_SH_IMMS16", + "BFD_RELOC_SH_IMMU16", + "BFD_RELOC_SH_IMM_LOW16", + "BFD_RELOC_SH_IMM_LOW16_PCREL", + "BFD_RELOC_SH_IMM_MEDLOW16", + "BFD_RELOC_SH_IMM_MEDLOW16_PCREL", + "BFD_RELOC_SH_IMM_MEDHI16", + "BFD_RELOC_SH_IMM_MEDHI16_PCREL", + "BFD_RELOC_SH_IMM_HI16", + "BFD_RELOC_SH_IMM_HI16_PCREL", + "BFD_RELOC_SH_PT_16", "BFD_RELOC_THUMB_PCREL_BRANCH9", "BFD_RELOC_THUMB_PCREL_BRANCH12", "BFD_RELOC_THUMB_PCREL_BRANCH23", diff --git a/bfd/opncls.c b/bfd/opncls.c index 0b285d4b8ce..31af2bd0c35 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -1,6 +1,6 @@ /* opncls.c -- open and close a BFD. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, - 2001 + 2001, 2002 Free Software Foundation, Inc. Written by Cygnus Support. @@ -618,7 +618,6 @@ bfd_make_readable(abfd) abfd->arch_info = &bfd_default_arch_struct; abfd->where = 0; - abfd->sections = (asection *) NULL; abfd->format = bfd_unknown; abfd->my_archive = (bfd *) NULL; abfd->origin = 0; @@ -637,6 +636,7 @@ bfd_make_readable(abfd) abfd->outsymbols = 0; abfd->tdata.any = 0; + bfd_section_list_clear (abfd); bfd_check_format(abfd, bfd_object); return true; diff --git a/bfd/reloc.c b/bfd/reloc.c index 559a351dfd7..c701fe0d403 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -2051,106 +2051,6 @@ ENUMX BFD_RELOC_MIPS_JALR COMMENT COMMENT -ENUMX - BFD_RELOC_SH_GOT_LOW16 -ENUMX - BFD_RELOC_SH_GOT_MEDLOW16 -ENUMX - BFD_RELOC_SH_GOT_MEDHI16 -ENUMX - BFD_RELOC_SH_GOT_HI16 -ENUMX - BFD_RELOC_SH_GOTPLT_LOW16 -ENUMX - BFD_RELOC_SH_GOTPLT_MEDLOW16 -ENUMX - BFD_RELOC_SH_GOTPLT_MEDHI16 -ENUMX - BFD_RELOC_SH_GOTPLT_HI16 -ENUMX - BFD_RELOC_SH_PLT_LOW16 -ENUMX - BFD_RELOC_SH_PLT_MEDLOW16 -ENUMX - BFD_RELOC_SH_PLT_MEDHI16 -ENUMX - BFD_RELOC_SH_PLT_HI16 -ENUMX - BFD_RELOC_SH_GOTOFF_LOW16 -ENUMX - BFD_RELOC_SH_GOTOFF_MEDLOW16 -ENUMX - BFD_RELOC_SH_GOTOFF_MEDHI16 -ENUMX - BFD_RELOC_SH_GOTOFF_HI16 -ENUMX - BFD_RELOC_SH_GOTPC_LOW16 -ENUMX - BFD_RELOC_SH_GOTPC_MEDLOW16 -ENUMX - BFD_RELOC_SH_GOTPC_MEDHI16 -ENUMX - BFD_RELOC_SH_GOTPC_HI16 -ENUMX - BFD_RELOC_SH_COPY64 -ENUMX - BFD_RELOC_SH_GLOB_DAT64 -ENUMX - BFD_RELOC_SH_JMP_SLOT64 -ENUMX - BFD_RELOC_SH_RELATIVE64 -ENUMX - BFD_RELOC_SH_GOT10BY4 -ENUMX - BFD_RELOC_SH_GOT10BY8 -ENUMX - BFD_RELOC_SH_GOTPLT10BY4 -ENUMX - BFD_RELOC_SH_GOTPLT10BY8 -ENUMX - BFD_RELOC_SH_GOTPLT32 -COMMENT -ENUMX - BFD_RELOC_SH_SHMEDIA_CODE -ENUMX - BFD_RELOC_SH_IMMU5 -ENUMX - BFD_RELOC_SH_IMMS6 -ENUMX - BFD_RELOC_SH_IMMS6BY32 -ENUMX - BFD_RELOC_SH_IMMU6 -ENUMX - BFD_RELOC_SH_IMMS10 -ENUMX - BFD_RELOC_SH_IMMS10BY2 -ENUMX - BFD_RELOC_SH_IMMS10BY4 -ENUMX - BFD_RELOC_SH_IMMS10BY8 -ENUMX - BFD_RELOC_SH_IMMS16 -ENUMX - BFD_RELOC_SH_IMMU16 -ENUMX - BFD_RELOC_SH_IMM_LOW16 -ENUMX - BFD_RELOC_SH_IMM_LOW16_PCREL -ENUMX - BFD_RELOC_SH_IMM_MEDLOW16 -ENUMX - BFD_RELOC_SH_IMM_MEDLOW16_PCREL -ENUMX - BFD_RELOC_SH_IMM_MEDHI16 -ENUMX - BFD_RELOC_SH_IMM_MEDHI16_PCREL -ENUMX - BFD_RELOC_SH_IMM_HI16 -ENUMX - BFD_RELOC_SH_IMM_HI16_PCREL -ENUMX - BFD_RELOC_SH_PT_16 -COMMENT ENUMDOC MIPS ELF relocations. @@ -2487,6 +2387,104 @@ ENUMX BFD_RELOC_SH_RELATIVE ENUMX BFD_RELOC_SH_GOTPC +ENUMX + BFD_RELOC_SH_GOT_LOW16 +ENUMX + BFD_RELOC_SH_GOT_MEDLOW16 +ENUMX + BFD_RELOC_SH_GOT_MEDHI16 +ENUMX + BFD_RELOC_SH_GOT_HI16 +ENUMX + BFD_RELOC_SH_GOTPLT_LOW16 +ENUMX + BFD_RELOC_SH_GOTPLT_MEDLOW16 +ENUMX + BFD_RELOC_SH_GOTPLT_MEDHI16 +ENUMX + BFD_RELOC_SH_GOTPLT_HI16 +ENUMX + BFD_RELOC_SH_PLT_LOW16 +ENUMX + BFD_RELOC_SH_PLT_MEDLOW16 +ENUMX + BFD_RELOC_SH_PLT_MEDHI16 +ENUMX + BFD_RELOC_SH_PLT_HI16 +ENUMX + BFD_RELOC_SH_GOTOFF_LOW16 +ENUMX + BFD_RELOC_SH_GOTOFF_MEDLOW16 +ENUMX + BFD_RELOC_SH_GOTOFF_MEDHI16 +ENUMX + BFD_RELOC_SH_GOTOFF_HI16 +ENUMX + BFD_RELOC_SH_GOTPC_LOW16 +ENUMX + BFD_RELOC_SH_GOTPC_MEDLOW16 +ENUMX + BFD_RELOC_SH_GOTPC_MEDHI16 +ENUMX + BFD_RELOC_SH_GOTPC_HI16 +ENUMX + BFD_RELOC_SH_COPY64 +ENUMX + BFD_RELOC_SH_GLOB_DAT64 +ENUMX + BFD_RELOC_SH_JMP_SLOT64 +ENUMX + BFD_RELOC_SH_RELATIVE64 +ENUMX + BFD_RELOC_SH_GOT10BY4 +ENUMX + BFD_RELOC_SH_GOT10BY8 +ENUMX + BFD_RELOC_SH_GOTPLT10BY4 +ENUMX + BFD_RELOC_SH_GOTPLT10BY8 +ENUMX + BFD_RELOC_SH_GOTPLT32 +ENUMX + BFD_RELOC_SH_SHMEDIA_CODE +ENUMX + BFD_RELOC_SH_IMMU5 +ENUMX + BFD_RELOC_SH_IMMS6 +ENUMX + BFD_RELOC_SH_IMMS6BY32 +ENUMX + BFD_RELOC_SH_IMMU6 +ENUMX + BFD_RELOC_SH_IMMS10 +ENUMX + BFD_RELOC_SH_IMMS10BY2 +ENUMX + BFD_RELOC_SH_IMMS10BY4 +ENUMX + BFD_RELOC_SH_IMMS10BY8 +ENUMX + BFD_RELOC_SH_IMMS16 +ENUMX + BFD_RELOC_SH_IMMU16 +ENUMX + BFD_RELOC_SH_IMM_LOW16 +ENUMX + BFD_RELOC_SH_IMM_LOW16_PCREL +ENUMX + BFD_RELOC_SH_IMM_MEDLOW16 +ENUMX + BFD_RELOC_SH_IMM_MEDLOW16_PCREL +ENUMX + BFD_RELOC_SH_IMM_MEDHI16 +ENUMX + BFD_RELOC_SH_IMM_MEDHI16_PCREL +ENUMX + BFD_RELOC_SH_IMM_HI16 +ENUMX + BFD_RELOC_SH_IMM_HI16_PCREL +ENUMX + BFD_RELOC_SH_PT_16 ENUMDOC Hitachi SH relocs. Not all of these appear in object files. diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index a939b5cc3e3..2e5ca5dcfa1 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -2114,7 +2114,7 @@ xcoff_link_add_dynamic_symbols (abfd, info) /* Remove the sections from this object, so that they do not get included in the link. */ - abfd->sections = NULL; + bfd_section_list_clear (abfd); bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr);