summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/binutils/bfd')
-rw-r--r--contrib/binutils/bfd/ChangeLog308
-rw-r--r--contrib/binutils/bfd/ChangeLog-94952
-rw-r--r--contrib/binutils/bfd/archures.c22
-rw-r--r--contrib/binutils/bfd/bfd-in2.h102
-rw-r--r--contrib/binutils/bfd/coff-arm.c29
-rw-r--r--contrib/binutils/bfd/coffcode.h1
-rw-r--r--contrib/binutils/bfd/config.in3
-rwxr-xr-xcontrib/binutils/bfd/configure158
-rw-r--r--contrib/binutils/bfd/configure.in10
-rw-r--r--contrib/binutils/bfd/cpu-powerpc.c109
-rw-r--r--contrib/binutils/bfd/cpu-s390.c56
-rw-r--r--contrib/binutils/bfd/doc/archures.texi8
-rw-r--r--contrib/binutils/bfd/doc/libbfd.texi2
-rw-r--r--contrib/binutils/bfd/doc/reloc.texi98
-rw-r--r--contrib/binutils/bfd/dwarf2.c34
-rw-r--r--contrib/binutils/bfd/elf-bfd.h5
-rw-r--r--contrib/binutils/bfd/elf-eh-frame.c32
-rw-r--r--contrib/binutils/bfd/elf.c7
-rw-r--r--contrib/binutils/bfd/elf32-arm.h16
-rw-r--r--contrib/binutils/bfd/elf32-mips.c24
-rw-r--r--contrib/binutils/bfd/elf32-ppc.c98
-rw-r--r--contrib/binutils/bfd/elf32-s390.c2476
-rw-r--r--contrib/binutils/bfd/elf64-alpha.c10
-rw-r--r--contrib/binutils/bfd/elf64-ppc.c691
-rw-r--r--contrib/binutils/bfd/elf64-ppc.h2
-rw-r--r--contrib/binutils/bfd/elf64-s390.c2392
-rw-r--r--contrib/binutils/bfd/elf64-sparc.c7
-rw-r--r--contrib/binutils/bfd/elf64-x86-64.c1796
-rw-r--r--contrib/binutils/bfd/elfarm-nabi.c4
-rw-r--r--contrib/binutils/bfd/elflink.h38
-rw-r--r--contrib/binutils/bfd/elfxx-ia64.c24
-rw-r--r--contrib/binutils/bfd/elfxx-target.h5
-rw-r--r--contrib/binutils/bfd/ihex.c4
-rw-r--r--contrib/binutils/bfd/libbfd.h98
-rw-r--r--contrib/binutils/bfd/opncls.c6
-rw-r--r--contrib/binutils/bfd/reloc.c198
-rw-r--r--contrib/binutils/bfd/rs6000-core.c2
-rw-r--r--contrib/binutils/bfd/syms.c3
-rw-r--r--contrib/binutils/bfd/version.h2
-rw-r--r--contrib/binutils/bfd/xcofflink.c2
40 files changed, 7379 insertions, 1505 deletions
diff --git a/contrib/binutils/bfd/ChangeLog b/contrib/binutils/bfd/ChangeLog
index f58ffce..987bd68 100644
--- a/contrib/binutils/bfd/ChangeLog
+++ b/contrib/binutils/bfd/ChangeLog
@@ -1,3 +1,311 @@
+2002-05-14 Daniel Jacobowitz <drow@mvista.com>
+
+ * configure.in: Set is_release=y for 2.12.1 release.
+ * configure: Likewise.
+
+2002-05-13 David Edelsohn <edelsohn@gnu.org>
+
+ * configure.in: 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>
+
+ Merge from mainline (to elf32-mips.c):
+ 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-11 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+ Daniel Jacobowitz <drow@mvista.com>
+
+ * coff-sh.c (sh_reloc_map): Map to R_SH_IMM32 for non-PE. Don't
+ map BFD_RELOC_RVA.
+
+2002-05-09 Alan Modra <amodra@bigpond.net.au>
+
+ * elf64-ppc.c (RA_REGISTER_MASK, RA_REGISTER_SHIFT): Delete.
+
+ 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.
+ (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>
+ * elf-bfd.h (struct elf_backend_data): Add rela_normal.
+ * elfxx-target.h (elf_backend_rela_normal): Define.
+ (elfNN_bed): Init rela_normal.
+ * elflink.h (elf_link_input_bfd <emit_relocs>): Handle adjustment
+ for section symbols here if rela_normal. Simplify abs section test.
+ * elf-m10200.c (mn10200_elf_relocate_section): If relocatable,
+ return immediately. Remove code handling relocatable linking.
+ * elf-m10300.c (mn10300_elf_relocate_section): Likewise.
+ * elf32-fr30.c (fr30_elf_relocate_section): Likewise.
+ * elf32-i370.c (i370_elf_relocate_section): Likewise.
+ * elf32-i860.c (elf32_i860_relocate_section): Likewise.
+ * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+ * elf32-mcore.c (mcore_elf_relocate_section): Likewise.
+ * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise.
+ * elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+ * elf32-s390.c (elf_s390_relocate_section): Likewise.
+ * elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise.
+ * elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
+ * elf64-s390.c (elf_s390_relocate_section): Likewise.
+ * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
+ * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise.
+ * elf32-arm.h (elf32_arm_relocate_section): Likewise #ifndef USE_REL.
+ * elf32-m32r.c (m32r_elf_relocate_section): Likewise.
+ * elf-m10200.c (elf_backend_rela_normal): Define.
+ * elf-m10300.c (elf_backend_rela_normal): Define.
+ * elf32-fr30.c (elf_backend_rela_normal): Define.
+ * elf32-i370.c (elf_backend_rela_normal): Define.
+ * elf32-i860.c (elf_backend_rela_normal): Define.
+ * elf32-m68k.c (elf_backend_rela_normal): Define.
+ * elf32-mcore.c (elf_backend_rela_normal): Define.
+ * elf32-openrisc.c (elf_backend_rela_normal): Define.
+ * elf32-ppc.c (elf_backend_rela_normal): Define.
+ * elf32-s390.c (elf_backend_rela_normal): Define.
+ * elf32-xstormy16.c (elf_backend_rela_normal): Define.
+ * elf64-ppc.c (elf_backend_rela_normal): Define.
+ * elf64-s390.c (elf_backend_rela_normal): Define.
+ * elf64-x86-64.c (elf_backend_rela_normal): Define.
+ * elfxx-ia64.c (elf_backend_rela_normal): Define.
+ * 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>
+ * 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>
+ * 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.
+ Change "abbrev_offset" to bfd_vma.
+ (read_indirect_string): Use correct conversion chars in error
+ message format string, cast bfd_vma's to unsigned long.
+ (read_abbrevs): Likewise.
+ (read_attribute_value): Likewise.
+ (decode_line_info): Likewise.
+ (scan_unit_for_functions): Likewise.
+ (parse_comp_unit): Likewise.
+
+ 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>
+ * elf64-ppc.c (ppc64_elf_howto_raw <R_PPC64_SECTOFF>): Change to a
+ 16 bit reloc.
+ <R_PPC64_SECTOFF_DS>: Likewise.
+ (ppc64_elf_reloc_type_lookup): Map from BFD_RELOC_16_BASEREL to
+ SECTOFF reloc.
+ * 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.
+ (ppc64_elf_sectoff_reloc): New function.
+ (ppc64_elf_sectoff_ha_reloc): New function.
+ (ppc64_elf_toc_reloc): New function.
+ (ppc64_elf_toc_ha_reloc): New function.
+ (ppc64_elf_toc64_reloc): New function.
+ (ppc64_elf_unhandled_reloc): New function.
+ (ppc64_elf_howto_raw): Use the above.
+ <R_PPC64_RELATIVE>: Mark pc_relative, pcrel_offset.
+ <R_PPC64_SECTOFF>: Not pc_relative or pcrel_offset. Fix dst_mask.
+ <R_PPC64_SECTOFF_DS>: Likewise.
+ (IS_ABSOLUTE_RELOC): Update.
+ (struct ppc_link_hash_table): Add have_undefweak.
+ (ppc64_elf_link_hash_table_create): Init.
+ (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_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.
+
+ 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>
+ * 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
+ call branches. Correct undefined weak destination.
+ (ppc64_elf_func_desc_adjust): Always create at least one blr in
+ .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.
+
+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-02 Richard Henderson <rth@redhat.com>
+
+ * elf64-alpha.c (elf64_alpha_relocate_section): Force relative relocs
+ vs SHN_UNDEF to zero.
+
+2002-04-27 Alan Modra <amodra@bigpond.net.au>
+
+ 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-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.
+
+ * reloc.c: Move sh relocs to where they belong.
+ * libbfd.h, bfd-in2.h: Regenerate.
+
+ 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.
+ (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 <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-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-26 Richard Smith <richard@ex-parrot.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ * elf-eh-frame.c (struct eh_cie_fde): Add per_encoding_relative.
+ (_bfd_elf_discard_section_eh_frame): Set it for CIEs with pcrel
+ encoded personality.
+ (_bfd_elf_write_section_eh_frame): Adjust pcrel encoded personality
+ for CIE/FDE removal.
+
+2002-04-26 Jakub Jelinek <jakub@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.
+
+2002-04-18 Nick Clifton <nickc@cambridge.redhat.com>
+
+ * coff-arm.c (coff_thumb_pcrel_12, coff_thumb_pcrel_9,
+ 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
+ for ARM_WINCE builds.
+
+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>
* elf32-cris.c (cris_elf_howto_table) <R_CRIS_16_PCREL,
diff --git a/contrib/binutils/bfd/ChangeLog-9495 b/contrib/binutils/bfd/ChangeLog-9495
index 4657d66..a208f42 100644
--- a/contrib/binutils/bfd/ChangeLog-9495
+++ b/contrib/binutils/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/contrib/binutils/bfd/archures.c b/contrib/binutils/bfd/archures.c
index 9a91424..40102e8 100644
--- a/contrib/binutils/bfd/archures.c
+++ b/contrib/binutils/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 <<next>>. *}
. 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/contrib/binutils/bfd/bfd-in2.h b/contrib/binutils/bfd/bfd-in2.h
index 93696ae..a69b375 100644
--- a/contrib/binutils/bfd/bfd-in2.h
+++ b/contrib/binutils/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 <<next>>. */
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/contrib/binutils/bfd/coff-arm.c b/contrib/binutils/bfd/coff-arm.c
index 798cd49..c92cbe6 100644
--- a/contrib/binutils/bfd/coff-arm.c
+++ b/contrib/binutils/bfd/coff-arm.c
@@ -87,12 +87,16 @@ static bfd_reloc_status_type aoutarm_fix_pcrel_26_done
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_reloc_status_type aoutarm_fix_pcrel_26
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+#ifndef ARM_WINCE
static bfd_reloc_status_type coff_thumb_pcrel_23
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_reloc_status_type coff_thumb_pcrel_12
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_reloc_status_type coff_thumb_pcrel_9
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static insn32 insert_thumb_branch
+ PARAMS ((insn32, int));
+#endif
+static bfd_reloc_status_type coff_thumb_pcrel_12
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_reloc_status_type coff_arm_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static boolean coff_arm_adjust_symndx
@@ -109,8 +113,6 @@ static const struct reloc_howto_struct * coff_arm_reloc_type_lookup
PARAMS ((bfd *, bfd_reloc_code_real_type));
static struct bfd_link_hash_table * coff_arm_link_hash_table_create
PARAMS ((bfd *));
-static insn32 insert_thumb_branch
- PARAMS ((insn32, int));
static struct coff_link_hash_entry * find_thumb_glue
PARAMS ((struct bfd_link_info *, const char *, bfd *));
static struct coff_link_hash_entry * find_arm_glue
@@ -118,9 +120,11 @@ static struct coff_link_hash_entry * find_arm_glue
#ifndef COFF_IMAGE_WITH_PE
static void record_arm_to_thumb_glue
PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *));
+#ifndef ARM_WINCE
static void record_thumb_to_arm_glue
PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *));
#endif
+#endif
static boolean coff_arm_merge_private_bfd_data
PARAMS ((bfd *, bfd *));
static boolean coff_arm_print_private_bfd_data
@@ -801,6 +805,7 @@ coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section,
return flag;
}
+#ifndef ARM_WINCE
static bfd_reloc_status_type
coff_thumb_pcrel_23 (abfd, reloc_entry, symbol, data, input_section,
output_bfd, error_message)
@@ -818,7 +823,7 @@ coff_thumb_pcrel_23 (abfd, reloc_entry, symbol, data, input_section,
}
static bfd_reloc_status_type
-coff_thumb_pcrel_12 (abfd, reloc_entry, symbol, data, input_section,
+coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section,
output_bfd, error_message)
bfd *abfd;
arelent *reloc_entry;
@@ -830,11 +835,12 @@ coff_thumb_pcrel_12 (abfd, reloc_entry, symbol, data, input_section,
{
return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message,
- b12);
+ b9);
}
+#endif /* not ARM_WINCE */
static bfd_reloc_status_type
-coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section,
+coff_thumb_pcrel_12 (abfd, reloc_entry, symbol, data, input_section,
output_bfd, error_message)
bfd *abfd;
arelent *reloc_entry;
@@ -846,7 +852,7 @@ coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section,
{
return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message,
- b9);
+ b12);
}
static const struct reloc_howto_struct *
@@ -900,10 +906,12 @@ coff_arm_reloc_type_lookup (abfd, code)
#define BADMAG(x) ARMBADMAG(x)
#define ARM 1 /* Customize coffcode.h */
+#ifndef ARM_WINCE
/* Make sure that the 'r_offset' field is copied properly
so that identical binaries will compare the same. */
#define SWAP_IN_RELOC_OFFSET H_GET_32
#define SWAP_OUT_RELOC_OFFSET H_PUT_32
+#endif
/* Extend the coff_link_hash_table structure with a few ARM specific fields.
This allows us to store global data here without actually creating any
@@ -975,6 +983,7 @@ arm_emit_base_file_entry (info, output_bfd, input_section, reloc_offset)
}
+#ifndef ARM_WINCE
/* The thumb form of a long branch is a bit finicky, because the offset
encoding is split over two fields, each in it's own instruction. They
can occur in any order. So given a thumb form of long branch, and an
@@ -1031,6 +1040,7 @@ insert_thumb_branch (br_insn, rel_off)
return br_insn;
}
+
static struct coff_link_hash_entry *
find_thumb_glue (info, name, input_bfd)
@@ -1060,6 +1070,7 @@ find_thumb_glue (info, name, input_bfd)
return myh;
}
+#endif /* not ARM_WINCE */
static struct coff_link_hash_entry *
find_arm_glue (info, name, input_bfd)
@@ -1914,6 +1925,7 @@ record_arm_to_thumb_glue (info, h)
return;
}
+#ifndef ARM_WINCE
static void
record_thumb_to_arm_glue (info, h)
struct bfd_link_info * info;
@@ -1987,6 +1999,7 @@ record_thumb_to_arm_glue (info, h)
return;
}
+#endif /* not ARM_WINCE */
/* 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/
diff --git a/contrib/binutils/bfd/coffcode.h b/contrib/binutils/bfd/coffcode.h
index 72690d5..5c6704f 100644
--- a/contrib/binutils/bfd/coffcode.h
+++ b/contrib/binutils/bfd/coffcode.h
@@ -3014,6 +3014,7 @@ coff_compute_section_file_positions (abfd)
else
current->target_index = target_index++;
}
+ abfd->section_tail = &current->next;
free (section_list);
}
diff --git a/contrib/binutils/bfd/config.in b/contrib/binutils/bfd/config.in
index e0b0c20..222096e 100644
--- a/contrib/binutils/bfd/config.in
+++ b/contrib/binutils/bfd/config.in
@@ -214,6 +214,9 @@
/* Define if getenv is not declared in system header files. */
#undef NEED_DECLARATION_GETENV
+/* Define if struct core_dumpx has member c_impl */
+#undef HAVE_ST_C_IMPL
+
/* Define if <sys/procfs.h> has prstatus_t. */
#undef HAVE_PRSTATUS_T
diff --git a/contrib/binutils/bfd/configure b/contrib/binutils/bfd/configure
index 9bbf34d..94c88ab 100755
--- a/contrib/binutils/bfd/configure
+++ b/contrib/binutils/bfd/configure
@@ -1199,7 +1199,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/'`
@@ -5173,6 +5173,32 @@ if test "${target}" = "${host}"; then
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
+ cat > conftest.$ac_ext <<EOF
+#line 5182 "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
+ rm -rf conftest*
+ cat >> confdefs.h <<\EOF
+#define HAVE_ST_C_IMPL 1
+EOF
+
+ echo "$ac_t""yes" 1>&6
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
;;
rs6000-*-aix4*) COREFILE=rs6000-core.lo ;;
rs6000-*-*) COREFILE=rs6000-core.lo ;;
@@ -5226,17 +5252,17 @@ if test "${target}" = "${host}"; then
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5230: checking for $ac_hdr" >&5
+echo "configure:5256: 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 5235 "configure"
+#line 5261 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5240: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5266: \"$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*
@@ -5264,12 +5290,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:5268: checking for prstatus_t in sys/procfs.h" >&5
+echo "configure:5294: 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 5273 "configure"
+#line 5299 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5278,7 +5304,7 @@ int main() {
prstatus_t avar
; return 0; }
EOF
-if { (eval echo configure:5282: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5308: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bfd_cv_have_sys_procfs_type_prstatus_t=yes
else
@@ -5300,12 +5326,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:5304: checking for prstatus32_t in sys/procfs.h" >&5
+echo "configure:5330: 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 5309 "configure"
+#line 5335 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5314,7 +5340,7 @@ int main() {
prstatus32_t avar
; return 0; }
EOF
-if { (eval echo configure:5318: \"$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_prstatus32_t=yes
else
@@ -5336,12 +5362,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:5340: checking for prstatus_t.pr_who in sys/procfs.h" >&5
+echo "configure:5366: 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 5345 "configure"
+#line 5371 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5350,7 +5376,7 @@ int main() {
prstatus_t avar; void* aref = (void*) &avar.pr_who
; return 0; }
EOF
-if { (eval echo configure:5354: \"$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_member_prstatus_t_pr_who=yes
else
@@ -5372,12 +5398,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:5376: checking for prstatus32_t.pr_who in sys/procfs.h" >&5
+echo "configure:5402: 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 5381 "configure"
+#line 5407 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5386,7 +5412,7 @@ int main() {
prstatus32_t avar; void* aref = (void*) &avar.pr_who
; return 0; }
EOF
-if { (eval echo configure:5390: \"$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_prstatus32_t_pr_who=yes
else
@@ -5408,12 +5434,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:5412: checking for pstatus_t in sys/procfs.h" >&5
+echo "configure:5438: 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 5417 "configure"
+#line 5443 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5422,7 +5448,7 @@ int main() {
pstatus_t avar
; return 0; }
EOF
-if { (eval echo configure:5426: \"$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_pstatus_t=yes
else
@@ -5444,12 +5470,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:5448: checking for pxstatus_t in sys/procfs.h" >&5
+echo "configure:5474: 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 5453 "configure"
+#line 5479 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5458,7 +5484,7 @@ int main() {
pxstatus_t avar
; return 0; }
EOF
-if { (eval echo configure:5462: \"$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_pxstatus_t=yes
else
@@ -5480,12 +5506,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:5484: checking for pstatus32_t in sys/procfs.h" >&5
+echo "configure:5510: 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 5489 "configure"
+#line 5515 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5494,7 +5520,7 @@ int main() {
pstatus32_t avar
; return 0; }
EOF
-if { (eval echo configure:5498: \"$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_pstatus32_t=yes
else
@@ -5516,12 +5542,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:5520: checking for prpsinfo_t in sys/procfs.h" >&5
+echo "configure:5546: 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 5525 "configure"
+#line 5551 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5530,7 +5556,7 @@ int main() {
prpsinfo_t avar
; return 0; }
EOF
-if { (eval echo configure:5534: \"$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_prpsinfo_t=yes
else
@@ -5552,12 +5578,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:5556: checking for prpsinfo32_t in sys/procfs.h" >&5
+echo "configure:5582: 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 5561 "configure"
+#line 5587 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5566,7 +5592,7 @@ int main() {
prpsinfo32_t avar
; return 0; }
EOF
-if { (eval echo configure:5570: \"$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_prpsinfo32_t=yes
else
@@ -5588,12 +5614,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:5592: checking for psinfo_t in sys/procfs.h" >&5
+echo "configure:5618: 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 5597 "configure"
+#line 5623 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5602,7 +5628,7 @@ int main() {
psinfo_t avar
; return 0; }
EOF
-if { (eval echo configure:5606: \"$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_psinfo_t=yes
else
@@ -5624,12 +5650,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:5628: checking for psinfo32_t in sys/procfs.h" >&5
+echo "configure:5654: 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 5633 "configure"
+#line 5659 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5638,7 +5664,7 @@ int main() {
psinfo32_t avar
; return 0; }
EOF
-if { (eval echo configure:5642: \"$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_psinfo32_t=yes
else
@@ -5660,12 +5686,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:5664: checking for lwpstatus_t in sys/procfs.h" >&5
+echo "configure:5690: 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 5669 "configure"
+#line 5695 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5674,7 +5700,7 @@ int main() {
lwpstatus_t avar
; return 0; }
EOF
-if { (eval echo configure:5678: \"$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_lwpstatus_t=yes
else
@@ -5696,12 +5722,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:5700: checking for lwpxstatus_t in sys/procfs.h" >&5
+echo "configure:5726: 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 5705 "configure"
+#line 5731 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5710,7 +5736,7 @@ int main() {
lwpxstatus_t avar
; return 0; }
EOF
-if { (eval echo configure:5714: \"$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_lwpxstatus_t=yes
else
@@ -5732,12 +5758,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:5736: checking for lwpstatus_t.pr_context in sys/procfs.h" >&5
+echo "configure:5762: 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 5741 "configure"
+#line 5767 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5746,7 +5772,7 @@ int main() {
lwpstatus_t avar; void* aref = (void*) &avar.pr_context
; return 0; }
EOF
-if { (eval echo configure:5750: \"$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_member_lwpstatus_t_pr_context=yes
else
@@ -5768,12 +5794,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:5772: checking for lwpstatus_t.pr_reg in sys/procfs.h" >&5
+echo "configure:5798: 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 5777 "configure"
+#line 5803 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5782,7 +5808,7 @@ int main() {
lwpstatus_t avar; void* aref = (void*) &avar.pr_reg
; return 0; }
EOF
-if { (eval echo configure:5786: \"$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_reg=yes
else
@@ -5804,12 +5830,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:5808: checking for win32_pstatus_t in sys/procfs.h" >&5
+echo "configure:5834: 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 5813 "configure"
+#line 5839 "configure"
#include "confdefs.h"
#define _SYSCALL32
@@ -5818,7 +5844,7 @@ int main() {
win32_pstatus_t avar
; return 0; }
EOF
-if { (eval echo configure:5822: \"$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_win32_pstatus_t=yes
else
@@ -6235,10 +6261,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:6239: checking for gcc version with buggy 64-bit support" >&5
+echo "configure:6265: 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 6242 "configure"
+#line 6268 "configure"
#include "confdefs.h"
:__GNUC__:__GNUC_MINOR__:__i386__:
EOF
@@ -6283,17 +6309,17 @@ for ac_hdr in stdlib.h unistd.h sys/stat.h sys/types.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6287: checking for $ac_hdr" >&5
+echo "configure:6313: 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 6292 "configure"
+#line 6318 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6297: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6323: \"$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*
@@ -6322,12 +6348,12 @@ done
for ac_func in getpagesize
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6326: checking for $ac_func" >&5
+echo "configure:6352: 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 6331 "configure"
+#line 6357 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -6350,7 +6376,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:6354: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6380: \"$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
@@ -6375,7 +6401,7 @@ fi
done
echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:6379: checking for working mmap" >&5
+echo "configure:6405: 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
@@ -6383,7 +6409,7 @@ else
ac_cv_func_mmap_fixed_mapped=no
else
cat > conftest.$ac_ext <<EOF
-#line 6387 "configure"
+#line 6413 "configure"
#include "confdefs.h"
/* Thanks to Mike Haertel and Jim Avera for this test.
@@ -6536,7 +6562,7 @@ main()
}
EOF
-if { (eval echo configure:6540: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6566: \"$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
@@ -6561,12 +6587,12 @@ fi
for ac_func in madvise mprotect
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6565: checking for $ac_func" >&5
+echo "configure:6591: 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 6570 "configure"
+#line 6596 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -6589,7 +6615,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:6593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6619: \"$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
diff --git a/contrib/binutils/bfd/configure.in b/contrib/binutils/bfd/configure.in
index 999847a..defa540 100644
--- a/contrib/binutils/bfd/configure.in
+++ b/contrib/binutils/bfd/configure.in
@@ -9,7 +9,7 @@ AC_ISC_POSIX
AM_INIT_AUTOMAKE(bfd, 2.12.1)
# 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/'`
@@ -327,6 +327,14 @@ changequote(,)dnl
changequote([,])dnl
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
+ AC_MSG_CHECKING([for c_impl in struct core_dumpx])
+ AC_TRY_COMPILE([#include <core.h>],
+ [struct core_dumpx c; c.c_impl = 0;],
+ [AC_DEFINE(HAVE_ST_C_IMPL, 1,
+ [Define if struct core_dumpx has member c_impl])
+ AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
;;
rs6000-*-aix4*) COREFILE=rs6000-core.lo ;;
rs6000-*-*) COREFILE=rs6000-core.lo ;;
diff --git a/contrib/binutils/bfd/cpu-powerpc.c b/contrib/binutils/bfd/cpu-powerpc.c
index d812618..d77b426 100644
--- a/contrib/binutils/bfd/cpu-powerpc.c
+++ b/contrib/binutils/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/contrib/binutils/bfd/cpu-s390.c b/contrib/binutils/bfd/cpu-s390.c
new file mode 100644
index 0000000..ac0d45e
--- /dev/null
+++ b/contrib/binutils/bfd/cpu-s390.c
@@ -0,0 +1,56 @@
+/* BFD support for the s390 processor.
+ Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
+ Contributed by Carl B. Pedersen and Martin Schwidefsky.
+
+ 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 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. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_s390_64_arch =
+{
+ 64, /* bits in a word */
+ 64, /* bits in an address */
+ 8, /* bits in a byte */
+ bfd_arch_s390,
+ bfd_mach_s390_64,
+ "s390",
+ "s390:64-bit",
+ 3, /* section alignment power */
+ true, /* the default */
+ bfd_default_compatible,
+ bfd_default_scan,
+ NULL
+};
+
+const bfd_arch_info_type bfd_s390_arch =
+{
+ 32, /* bits in a word */
+ 32, /* bits in an address */
+ 8, /* bits in a byte */
+ bfd_arch_s390,
+ bfd_mach_s390_31,
+ "s390",
+ "s390:31-bit",
+ 3, /* section alignment power */
+ true, /* the default */
+ bfd_default_compatible,
+ bfd_default_scan,
+ &bfd_s390_64_arch
+};
diff --git a/contrib/binutils/bfd/doc/archures.texi b/contrib/binutils/bfd/doc/archures.texi
index dcdaff9..eb4d180 100644
--- a/contrib/binutils/bfd/doc/archures.texi
+++ b/contrib/binutils/bfd/doc/archures.texi
@@ -225,8 +225,8 @@ enum bfd_architecture
#define bfd_mach_avr5 5
bfd_arch_cris, /* Axis CRIS */
bfd_arch_s390, /* IBM s390 */
-#define bfd_mach_s390_esa 0
-#define bfd_mach_s390_esame 1
+#define bfd_mach_s390_31 0
+#define bfd_mach_s390_64 1
bfd_arch_openrisc, /* OpenRISC */
bfd_arch_mmix, /* Donald Knuth's educational processor. */
bfd_arch_xstormy16,
@@ -253,7 +253,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 @code{next}. */
boolean the_default;
const struct bfd_arch_info * (*compatible)
PARAMS ((const struct bfd_arch_info *a,
diff --git a/contrib/binutils/bfd/doc/libbfd.texi b/contrib/binutils/bfd/doc/libbfd.texi
index 0c20a07..b28650f 100644
--- a/contrib/binutils/bfd/doc/libbfd.texi
+++ b/contrib/binutils/bfd/doc/libbfd.texi
@@ -10,7 +10,7 @@ completeness.
@subsubsection @code{bfd_write_bigendian_4byte_int}
@strong{Synopsis}
@example
-void bfd_write_bigendian_4byte_int (bfd *, unsigned int);
+boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
@end example
@strong{Description}@*
Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big
diff --git a/contrib/binutils/bfd/doc/reloc.texi b/contrib/binutils/bfd/doc/reloc.texi
index 2b449d3..2f462fd 100644
--- a/contrib/binutils/bfd/doc/reloc.texi
+++ b/contrib/binutils/bfd/doc/reloc.texi
@@ -768,55 +768,6 @@ Relocation against a MIPS literal section.
@deffnx {} BFD_RELOC_MIPS_REL16
@deffnx {} BFD_RELOC_MIPS_RELGOT
@deffnx {} BFD_RELOC_MIPS_JALR
-@deffnx {} BFD_RELOC_SH_GOT_LOW16
-@deffnx {} BFD_RELOC_SH_GOT_MEDLOW16
-@deffnx {} BFD_RELOC_SH_GOT_MEDHI16
-@deffnx {} BFD_RELOC_SH_GOT_HI16
-@deffnx {} BFD_RELOC_SH_GOTPLT_LOW16
-@deffnx {} BFD_RELOC_SH_GOTPLT_MEDLOW16
-@deffnx {} BFD_RELOC_SH_GOTPLT_MEDHI16
-@deffnx {} BFD_RELOC_SH_GOTPLT_HI16
-@deffnx {} BFD_RELOC_SH_PLT_LOW16
-@deffnx {} BFD_RELOC_SH_PLT_MEDLOW16
-@deffnx {} BFD_RELOC_SH_PLT_MEDHI16
-@deffnx {} BFD_RELOC_SH_PLT_HI16
-@deffnx {} BFD_RELOC_SH_GOTOFF_LOW16
-@deffnx {} BFD_RELOC_SH_GOTOFF_MEDLOW16
-@deffnx {} BFD_RELOC_SH_GOTOFF_MEDHI16
-@deffnx {} BFD_RELOC_SH_GOTOFF_HI16
-@deffnx {} BFD_RELOC_SH_GOTPC_LOW16
-@deffnx {} BFD_RELOC_SH_GOTPC_MEDLOW16
-@deffnx {} BFD_RELOC_SH_GOTPC_MEDHI16
-@deffnx {} BFD_RELOC_SH_GOTPC_HI16
-@deffnx {} BFD_RELOC_SH_COPY64
-@deffnx {} BFD_RELOC_SH_GLOB_DAT64
-@deffnx {} BFD_RELOC_SH_JMP_SLOT64
-@deffnx {} BFD_RELOC_SH_RELATIVE64
-@deffnx {} BFD_RELOC_SH_GOT10BY4
-@deffnx {} BFD_RELOC_SH_GOT10BY8
-@deffnx {} BFD_RELOC_SH_GOTPLT10BY4
-@deffnx {} BFD_RELOC_SH_GOTPLT10BY8
-@deffnx {} BFD_RELOC_SH_GOTPLT32
-@deffnx {} BFD_RELOC_SH_SHMEDIA_CODE
-@deffnx {} BFD_RELOC_SH_IMMU5
-@deffnx {} BFD_RELOC_SH_IMMS6
-@deffnx {} BFD_RELOC_SH_IMMS6BY32
-@deffnx {} BFD_RELOC_SH_IMMU6
-@deffnx {} BFD_RELOC_SH_IMMS10
-@deffnx {} BFD_RELOC_SH_IMMS10BY2
-@deffnx {} BFD_RELOC_SH_IMMS10BY4
-@deffnx {} BFD_RELOC_SH_IMMS10BY8
-@deffnx {} BFD_RELOC_SH_IMMS16
-@deffnx {} BFD_RELOC_SH_IMMU16
-@deffnx {} BFD_RELOC_SH_IMM_LOW16
-@deffnx {} BFD_RELOC_SH_IMM_LOW16_PCREL
-@deffnx {} BFD_RELOC_SH_IMM_MEDLOW16
-@deffnx {} BFD_RELOC_SH_IMM_MEDLOW16_PCREL
-@deffnx {} BFD_RELOC_SH_IMM_MEDHI16
-@deffnx {} BFD_RELOC_SH_IMM_MEDHI16_PCREL
-@deffnx {} BFD_RELOC_SH_IMM_HI16
-@deffnx {} BFD_RELOC_SH_IMM_HI16_PCREL
-@deffnx {} BFD_RELOC_SH_PT_16
MIPS ELF relocations.
@end deffn
@deffn {} BFD_RELOC_386_GOT32
@@ -996,6 +947,55 @@ These relocs are only used within the ARM assembler. They are not
@deffnx {} BFD_RELOC_SH_JMP_SLOT
@deffnx {} BFD_RELOC_SH_RELATIVE
@deffnx {} BFD_RELOC_SH_GOTPC
+@deffnx {} BFD_RELOC_SH_GOT_LOW16
+@deffnx {} BFD_RELOC_SH_GOT_MEDLOW16
+@deffnx {} BFD_RELOC_SH_GOT_MEDHI16
+@deffnx {} BFD_RELOC_SH_GOT_HI16
+@deffnx {} BFD_RELOC_SH_GOTPLT_LOW16
+@deffnx {} BFD_RELOC_SH_GOTPLT_MEDLOW16
+@deffnx {} BFD_RELOC_SH_GOTPLT_MEDHI16
+@deffnx {} BFD_RELOC_SH_GOTPLT_HI16
+@deffnx {} BFD_RELOC_SH_PLT_LOW16
+@deffnx {} BFD_RELOC_SH_PLT_MEDLOW16
+@deffnx {} BFD_RELOC_SH_PLT_MEDHI16
+@deffnx {} BFD_RELOC_SH_PLT_HI16
+@deffnx {} BFD_RELOC_SH_GOTOFF_LOW16
+@deffnx {} BFD_RELOC_SH_GOTOFF_MEDLOW16
+@deffnx {} BFD_RELOC_SH_GOTOFF_MEDHI16
+@deffnx {} BFD_RELOC_SH_GOTOFF_HI16
+@deffnx {} BFD_RELOC_SH_GOTPC_LOW16
+@deffnx {} BFD_RELOC_SH_GOTPC_MEDLOW16
+@deffnx {} BFD_RELOC_SH_GOTPC_MEDHI16
+@deffnx {} BFD_RELOC_SH_GOTPC_HI16
+@deffnx {} BFD_RELOC_SH_COPY64
+@deffnx {} BFD_RELOC_SH_GLOB_DAT64
+@deffnx {} BFD_RELOC_SH_JMP_SLOT64
+@deffnx {} BFD_RELOC_SH_RELATIVE64
+@deffnx {} BFD_RELOC_SH_GOT10BY4
+@deffnx {} BFD_RELOC_SH_GOT10BY8
+@deffnx {} BFD_RELOC_SH_GOTPLT10BY4
+@deffnx {} BFD_RELOC_SH_GOTPLT10BY8
+@deffnx {} BFD_RELOC_SH_GOTPLT32
+@deffnx {} BFD_RELOC_SH_SHMEDIA_CODE
+@deffnx {} BFD_RELOC_SH_IMMU5
+@deffnx {} BFD_RELOC_SH_IMMS6
+@deffnx {} BFD_RELOC_SH_IMMS6BY32
+@deffnx {} BFD_RELOC_SH_IMMU6
+@deffnx {} BFD_RELOC_SH_IMMS10
+@deffnx {} BFD_RELOC_SH_IMMS10BY2
+@deffnx {} BFD_RELOC_SH_IMMS10BY4
+@deffnx {} BFD_RELOC_SH_IMMS10BY8
+@deffnx {} BFD_RELOC_SH_IMMS16
+@deffnx {} BFD_RELOC_SH_IMMU16
+@deffnx {} BFD_RELOC_SH_IMM_LOW16
+@deffnx {} BFD_RELOC_SH_IMM_LOW16_PCREL
+@deffnx {} BFD_RELOC_SH_IMM_MEDLOW16
+@deffnx {} BFD_RELOC_SH_IMM_MEDLOW16_PCREL
+@deffnx {} BFD_RELOC_SH_IMM_MEDHI16
+@deffnx {} BFD_RELOC_SH_IMM_MEDHI16_PCREL
+@deffnx {} BFD_RELOC_SH_IMM_HI16
+@deffnx {} BFD_RELOC_SH_IMM_HI16_PCREL
+@deffnx {} BFD_RELOC_SH_PT_16
Hitachi SH relocs. Not all of these appear in object files.
@end deffn
@deffn {} BFD_RELOC_THUMB_PCREL_BRANCH9
diff --git a/contrib/binutils/bfd/dwarf2.c b/contrib/binutils/bfd/dwarf2.c
index f129e0b..e3b8e27 100644
--- a/contrib/binutils/bfd/dwarf2.c
+++ b/contrib/binutils/bfd/dwarf2.c
@@ -42,7 +42,7 @@ struct line_head
{
bfd_vma total_length;
unsigned short version;
- unsigned int prologue_length;
+ bfd_vma prologue_length;
unsigned char minimum_instruction_length;
unsigned char default_is_stmt;
int line_base;
@@ -225,7 +225,7 @@ static bfd_vma read_address PARAMS ((struct comp_unit *, char *));
static struct abbrev_info *lookup_abbrev
PARAMS ((unsigned int, struct abbrev_info **));
static struct abbrev_info **read_abbrevs
- PARAMS ((bfd *, unsigned int, struct dwarf2_debug *));
+ PARAMS ((bfd *, bfd_vma, struct dwarf2_debug *));
static char *read_attribute
PARAMS ((struct attribute *, struct attr_abbrev *,
struct comp_unit *, char *));
@@ -396,8 +396,8 @@ read_indirect_string (unit, buf, bytes_read_ptr)
if (offset >= stash->dwarf_str_size)
{
- (*_bfd_error_handler) (_("Dwarf Error: DW_FORM_strp offset (%u) greater than or equal to .debug_str size (%u)."),
- offset, stash->dwarf_str_size);
+ (*_bfd_error_handler) (_("Dwarf Error: DW_FORM_strp offset (%lu) greater than or equal to .debug_str size (%lu)."),
+ (unsigned long) offset, stash->dwarf_str_size);
bfd_set_error (bfd_error_bad_value);
return NULL;
}
@@ -523,7 +523,7 @@ lookup_abbrev (number,abbrevs)
static struct abbrev_info**
read_abbrevs (abfd, offset, stash)
bfd * abfd;
- unsigned int offset;
+ bfd_vma offset;
struct dwarf2_debug *stash;
{
struct abbrev_info **abbrevs;
@@ -557,8 +557,8 @@ read_abbrevs (abfd, offset, stash)
if (offset >= stash->dwarf_abbrev_size)
{
- (*_bfd_error_handler) (_("Dwarf Error: Abbrev offset (%u) greater than or equal to .debug_abbrev size (%u)."),
- offset, stash->dwarf_abbrev_size);
+ (*_bfd_error_handler) (_("Dwarf Error: Abbrev offset (%lu) greater than or equal to .debug_abbrev size (%lu)."),
+ (unsigned long) offset, stash->dwarf_abbrev_size);
bfd_set_error (bfd_error_bad_value);
return 0;
}
@@ -754,7 +754,7 @@ read_attribute_value (attr, form, unit, info_ptr)
info_ptr = read_attribute_value (attr, form, unit, info_ptr);
break;
default:
- (*_bfd_error_handler) (_("Dwarf Error: Invalid or unhandled FORM value: %d."),
+ (*_bfd_error_handler) (_("Dwarf Error: Invalid or unhandled FORM value: %u."),
form);
bfd_set_error (bfd_error_bad_value);
}
@@ -958,7 +958,7 @@ decode_line_info (unit, stash)
below. */
if (unit->line_offset >= stash->dwarf_line_size)
{
- (*_bfd_error_handler) (_("Dwarf Error: Line offset (%u) greater than or equal to .debug_line size (%u)."),
+ (*_bfd_error_handler) (_("Dwarf Error: Line offset (%lu) greater than or equal to .debug_line size (%lu)."),
unit->line_offset, stash->dwarf_line_size);
bfd_set_error (bfd_error_bad_value);
return 0;
@@ -1345,7 +1345,7 @@ scan_unit_for_functions (unit)
abbrev = lookup_abbrev (abbrev_number,unit->abbrevs);
if (! abbrev)
{
- (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %d."),
+ (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."),
abbrev_number);
bfd_set_error (bfd_error_bad_value);
return false;
@@ -1486,9 +1486,9 @@ parse_comp_unit (abfd, stash, unit_length, offset_size)
unsigned int offset_size;
{
struct comp_unit* unit;
- unsigned short version;
- unsigned int abbrev_offset = 0;
- unsigned char addr_size;
+ unsigned int version;
+ bfd_vma abbrev_offset = 0;
+ unsigned int addr_size;
struct abbrev_info** abbrevs;
unsigned int abbrev_number, bytes_read, i;
struct abbrev_info *abbrev;
@@ -1517,7 +1517,7 @@ parse_comp_unit (abfd, stash, unit_length, offset_size)
if (version != 2)
{
- (*_bfd_error_handler) (_("Dwarf Error: found dwarf version '%hu', this reader only handles version 2 information."), version);
+ (*_bfd_error_handler) (_("Dwarf Error: found dwarf version '%u', this reader only handles version 2 information."), version);
bfd_set_error (bfd_error_bad_value);
return 0;
}
@@ -1526,7 +1526,7 @@ parse_comp_unit (abfd, stash, unit_length, offset_size)
{
(*_bfd_error_handler) (_("Dwarf Error: found address size '%u', this reader can not handle sizes greater than '%u'."),
addr_size,
- sizeof (bfd_vma));
+ (unsigned int) sizeof (bfd_vma));
bfd_set_error (bfd_error_bad_value);
return 0;
}
@@ -1547,7 +1547,7 @@ parse_comp_unit (abfd, stash, unit_length, offset_size)
info_ptr += bytes_read;
if (! abbrev_number)
{
- (*_bfd_error_handler) (_("Dwarf Error: Bad abbrev number: %d."),
+ (*_bfd_error_handler) (_("Dwarf Error: Bad abbrev number: %u."),
abbrev_number);
bfd_set_error (bfd_error_bad_value);
return 0;
@@ -1556,7 +1556,7 @@ parse_comp_unit (abfd, stash, unit_length, offset_size)
abbrev = lookup_abbrev (abbrev_number, abbrevs);
if (! abbrev)
{
- (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %d."),
+ (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."),
abbrev_number);
bfd_set_error (bfd_error_bad_value);
return 0;
diff --git a/contrib/binutils/bfd/elf-bfd.h b/contrib/binutils/bfd/elf-bfd.h
index 4439daa..d10fda9 100644
--- a/contrib/binutils/bfd/elf-bfd.h
+++ b/contrib/binutils/bfd/elf-bfd.h
@@ -788,6 +788,11 @@ struct elf_backend_data
section. */
unsigned default_use_rela_p : 1;
+ /* Set if RELA relocations for a relocatable link can be handled by
+ generic code. Backends that set this flag need do nothing in the
+ backend relocate_section routine for relocatable linking. */
+ unsigned rela_normal : 1;
+
/* True if addresses "naturally" sign extend. This is used when
swapping in from Elf32 when BFD64. */
unsigned sign_extend_vma : 1;
diff --git a/contrib/binutils/bfd/elf-eh-frame.c b/contrib/binutils/bfd/elf-eh-frame.c
index 20cbfb2..6a23edb 100644
--- a/contrib/binutils/bfd/elf-eh-frame.c
+++ b/contrib/binutils/bfd/elf-eh-frame.c
@@ -64,6 +64,7 @@ struct eh_cie_fde
unsigned char removed : 1;
unsigned char make_relative : 1;
unsigned char make_lsda_relative : 1;
+ unsigned char per_encoding_relative : 1;
};
struct eh_frame_sec_info
@@ -469,6 +470,8 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
= cie.make_relative;
sec_info->entry[last_cie_ndx].make_lsda_relative
= cie.make_lsda_relative;
+ sec_info->entry[last_cie_ndx].per_encoding_relative
+ = (cie.per_encoding & 0x70) == DW_EH_PE_pcrel;
}
}
@@ -633,8 +636,9 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
else
{
if (info->shared
- && (cie.fde_encoding & 0xf0) == DW_EH_PE_absptr
- && cie.make_relative == 0)
+ && (((cie.fde_encoding & 0xf0) == DW_EH_PE_absptr
+ && cie.make_relative == 0)
+ || (cie.fde_encoding & 0xf0) == DW_EH_PE_aligned))
{
/* If shared library uses absolute pointers
which we cannot turn into PC relative,
@@ -689,6 +693,7 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
{
sec_info->entry[i].make_relative = make_relative;
sec_info->entry[i].make_lsda_relative = make_lsda_relative;
+ sec_info->entry[i].per_encoding_relative = 0;
}
}
else if (sec_info->entry[i].cie && sec_info->entry[i].sec == sec)
@@ -947,7 +952,8 @@ _bfd_elf_write_section_eh_frame (abfd, sec, ehdrsec, contents)
/* CIE */
cie_offset = sec_info->entry[i].new_offset;
if (sec_info->entry[i].make_relative
- || sec_info->entry[i].make_lsda_relative)
+ || sec_info->entry[i].make_lsda_relative
+ || sec_info->entry[i].per_encoding_relative)
{
unsigned char *aug;
unsigned int action;
@@ -956,7 +962,8 @@ _bfd_elf_write_section_eh_frame (abfd, sec, ehdrsec, contents)
/* Need to find 'R' or 'L' augmentation's argument and modify
DW_EH_PE_* value. */
action = (sec_info->entry[i].make_relative ? 1 : 0)
- | (sec_info->entry[i].make_lsda_relative ? 2 : 0);
+ | (sec_info->entry[i].make_lsda_relative ? 2 : 0)
+ | (sec_info->entry[i].per_encoding_relative ? 4 : 0);
buf = contents + sec_info->entry[i].offset;
/* Skip length, id and version. */
buf += 9;
@@ -988,10 +995,22 @@ _bfd_elf_write_section_eh_frame (abfd, sec, ehdrsec, contents)
per_width = get_DW_EH_PE_width (per_encoding,
ptr_size);
BFD_ASSERT (per_width != 0);
+ BFD_ASSERT (((per_encoding & 0x70) == DW_EH_PE_pcrel)
+ == sec_info->entry[i].per_encoding_relative);
if ((per_encoding & 0xf0) == DW_EH_PE_aligned)
buf = (contents
+ ((buf - contents + per_width - 1)
& ~((bfd_size_type) per_width - 1)));
+ if (action & 4)
+ {
+ bfd_vma value;
+
+ value = read_value (abfd, buf, per_width);
+ value += (sec_info->entry[i].offset
+ - sec_info->entry[i].new_offset);
+ write_value (abfd, buf, value, per_width);
+ action &= ~4;
+ }
buf += per_width;
break;
case 'R':
@@ -1008,7 +1027,7 @@ _bfd_elf_write_section_eh_frame (abfd, sec, ehdrsec, contents)
}
}
}
- else
+ else if (sec_info->entry[i].size > 4)
{
/* FDE */
bfd_vma value = 0, address;
@@ -1081,6 +1100,9 @@ _bfd_elf_write_section_eh_frame (abfd, sec, ehdrsec, contents)
}
}
}
+ else
+ /* Terminating FDE must be at the end of .eh_frame section only. */
+ BFD_ASSERT (i == sec_info->count - 1);
BFD_ASSERT (p == contents + sec_info->entry[i].new_offset);
memmove (p, contents + sec_info->entry[i].offset,
diff --git a/contrib/binutils/bfd/elf.c b/contrib/binutils/bfd/elf.c
index 67d9add..b78eb5f 100644
--- a/contrib/binutils/bfd/elf.c
+++ b/contrib/binutils/bfd/elf.c
@@ -3881,7 +3881,6 @@ prep_headers (abfd)
Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
Elf_Internal_Phdr *i_phdrp = 0; /* Program header table, internal form */
Elf_Internal_Shdr **i_shdrp; /* Section header table, internal form */
- int count;
struct elf_strtab_hash *shstrtab;
struct elf_backend_data *bed = get_elf_backend_data (abfd);
@@ -3904,12 +3903,6 @@ prep_headers (abfd)
bfd_big_endian (abfd) ? ELFDATA2MSB : ELFDATA2LSB;
i_ehdrp->e_ident[EI_VERSION] = bed->s->ev_current;
- i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_NONE;
- i_ehdrp->e_ident[EI_ABIVERSION] = 0;
-
- for (count = EI_PAD; count < EI_NIDENT; count++)
- i_ehdrp->e_ident[count] = 0;
-
if ((abfd->flags & DYNAMIC) != 0)
i_ehdrp->e_type = ET_DYN;
else if ((abfd->flags & EXEC_P) != 0)
diff --git a/contrib/binutils/bfd/elf32-arm.h b/contrib/binutils/bfd/elf32-arm.h
index d420e5b..7d02127 100644
--- a/contrib/binutils/bfd/elf32-arm.h
+++ b/contrib/binutils/bfd/elf32-arm.h
@@ -1390,7 +1390,7 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd,
boolean overflow = false;
bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data);
bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2);
- bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
+ bfd_signed_vma reloc_signed_max = ((1 << (howto->bitsize - 1)) - 1) >> howto->rightshift;
bfd_signed_vma reloc_signed_min = ~ reloc_signed_max;
bfd_vma check;
bfd_signed_vma signed_check;
@@ -1830,6 +1830,11 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Rela * relend;
const char * name;
+#ifndef USE_REL
+ if (info->relocateable)
+ return true;
+#endif
+
symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
@@ -1862,6 +1867,7 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
#endif
howto = bfd_reloc.howto;
+#ifdef USE_REL
if (info->relocateable)
{
/* This is a relocateable link. We don't have to change
@@ -1874,19 +1880,16 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
{
sec = local_sections[r_symndx];
-#ifdef USE_REL
arm_add_to_rel (input_bfd, contents + rel->r_offset,
howto,
(bfd_signed_vma) (sec->output_offset
+ sym->st_value));
-#else
- rel->r_addend += (sec->output_offset + sym->st_value);
-#endif
}
}
continue;
}
+#endif
/* This is a final link. */
h = NULL;
@@ -3637,6 +3640,9 @@ elf32_arm_reloc_type_class (rela)
#define elf_backend_plt_readonly 1
#define elf_backend_want_got_plt 1
#define elf_backend_want_plt_sym 0
+#ifndef USE_REL
+#define elf_backend_rela_normal 1
+#endif
#define elf_backend_got_header_size 12
#define elf_backend_plt_header_size PLT_ENTRY_SIZE
diff --git a/contrib/binutils/bfd/elf32-mips.c b/contrib/binutils/bfd/elf32-mips.c
index e7b4701..ddfe4a0 100644
--- a/contrib/binutils/bfd/elf32-mips.c
+++ b/contrib/binutils/bfd/elf32-mips.c
@@ -105,6 +105,9 @@ struct mips_elf_link_hash_entry
/* This is like the call_stub field, but it is used if the function
being called returns a floating point value. */
asection *call_fp_stub;
+
+ /* Are we forced local? .*/
+ boolean forced_local;
};
static bfd_reloc_status_type mips32_64bit_reloc
@@ -4528,6 +4531,7 @@ mips_elf_link_hash_newfunc (entry, table, string)
ret->need_fn_stub = false;
ret->call_stub = NULL;
ret->call_fp_stub = NULL;
+ ret->forced_local = false;
}
return (struct bfd_hash_entry *) ret;
@@ -4543,7 +4547,12 @@ _bfd_mips_elf_hide_symbol (info, entry, force_local)
asection *got;
struct mips_got_info *g;
struct mips_elf_link_hash_entry *h;
+
h = (struct mips_elf_link_hash_entry *) entry;
+ if (h->forced_local)
+ return;
+ h->forced_local = true;
+
dynobj = elf_hash_table (info)->dynobj;
got = bfd_get_section_by_name (dynobj, ".got");
g = (struct mips_got_info *) elf_section_data (got)->tdata;
@@ -6047,9 +6056,18 @@ mips_elf_record_global_got_symbol (h, info, g)
{
/* A global symbol in the GOT must also be in the dynamic symbol
table. */
- if (h->dynindx == -1
- && !bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
+ if (h->dynindx == -1)
+ {
+ switch (ELF_ST_VISIBILITY (h->other))
+ {
+ case STV_INTERNAL:
+ case STV_HIDDEN:
+ _bfd_mips_elf_hide_symbol (info, h, true);
+ break;
+ }
+ if (!bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
/* If we've already marked this entry as needing GOT space, we don't
need to do it again. */
diff --git a/contrib/binutils/bfd/elf32-ppc.c b/contrib/binutils/bfd/elf32-ppc.c
index be6cfab..31d9e0c 100644
--- a/contrib/binutils/bfd/elf32-ppc.c
+++ b/contrib/binutils/bfd/elf32-ppc.c
@@ -1,5 +1,5 @@
/* PowerPC-specific support for 32-bit ELF
- 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.
@@ -49,6 +49,8 @@ static boolean ppc_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
static int ppc_elf_additional_program_headers PARAMS ((bfd *));
static boolean ppc_elf_modify_segment_map PARAMS ((bfd *));
+static asection *ppc_elf_create_got
+ PARAMS ((bfd *, struct bfd_link_info *));
static boolean ppc_elf_create_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
@@ -679,20 +681,20 @@ static reloc_howto_type ppc_elf_howto_raw[] = {
0xffff, /* dst_mask */
false), /* pcrel_offset */
- /* 32-bit section relative relocation. */
+ /* 16-bit section relative relocation. */
HOWTO (R_PPC_SECTOFF, /* type */
0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_PPC_SECTOFF", /* name */
false, /* partial_inplace */
0, /* src_mask */
- 0, /* dst_mask */
- true), /* pcrel_offset */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
/* 16-bit lower half section relative relocation. */
HOWTO (R_PPC_SECTOFF_LO, /* type */
@@ -1295,7 +1297,7 @@ ppc_elf_reloc_type_lookup (abfd, code)
case BFD_RELOC_HI16_PLTOFF: ppc_reloc = R_PPC_PLT16_HI; break;
case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC_PLT16_HA; break;
case BFD_RELOC_GPREL16: ppc_reloc = R_PPC_SDAREL16; break;
- case BFD_RELOC_32_BASEREL: ppc_reloc = R_PPC_SECTOFF; break;
+ case BFD_RELOC_16_BASEREL: ppc_reloc = R_PPC_SECTOFF; break;
case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC_SECTOFF_LO; break;
case BFD_RELOC_HI16_BASEREL: ppc_reloc = R_PPC_SECTOFF_HI; break;
case BFD_RELOC_HI16_S_BASEREL: ppc_reloc = R_PPC_SECTOFF_HA; break;
@@ -1632,6 +1634,30 @@ ppc_elf_modify_segment_map (abfd)
return true;
}
+/* The powerpc .got has a blrl instruction in it. Mark it executable. */
+
+static asection *
+ppc_elf_create_got (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ register asection *s;
+ flagword flags;
+
+ if (!_bfd_elf_create_got_section (abfd, info))
+ return NULL;
+
+ s = bfd_get_section_by_name (abfd, ".got");
+ if (s == NULL)
+ abort ();
+
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED);
+ if (!bfd_set_section_flags (abfd, s, flags))
+ return NULL;
+ return s;
+}
+
/* We have to create .dynsbss and .rela.sbss here so that they get mapped
to output sections (just like _bfd_elf_create_dynamic_sections has
to create .dynbss and .rela.bss). */
@@ -1644,6 +1670,9 @@ ppc_elf_create_dynamic_sections (abfd, info)
register asection *s;
flagword flags;
+ if (!ppc_elf_create_got (abfd, info))
+ return false;
+
if (!_bfd_elf_create_dynamic_sections (abfd, info))
return false;
@@ -1663,7 +1692,13 @@ ppc_elf_create_dynamic_sections (abfd, info)
|| ! bfd_set_section_alignment (abfd, s, 2))
return false;
}
- return true;
+
+ s = bfd_get_section_by_name (abfd, ".plt");
+ if (s == NULL)
+ abort ();
+
+ flags = SEC_ALLOC | SEC_CODE | SEC_IN_MEMORY | SEC_LINKER_CREATED;
+ return bfd_set_section_flags (abfd, s, flags);
}
/* Adjust a symbol defined by a dynamic object and referenced by a
@@ -2119,10 +2154,9 @@ ppc_elf_check_relocs (abfd, info, sec, relocs)
{
if (dynobj == NULL)
elf_hash_table (info)->dynobj = dynobj = abfd;
- if (! _bfd_elf_create_got_section (dynobj, info))
+ sgot = ppc_elf_create_got (dynobj, info);
+ if (sgot == NULL)
return false;
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
}
}
@@ -2139,10 +2173,9 @@ ppc_elf_check_relocs (abfd, info, sec, relocs)
{
if (dynobj == NULL)
elf_hash_table (info)->dynobj = dynobj = abfd;
- if (! _bfd_elf_create_got_section (dynobj, info))
+ sgot = ppc_elf_create_got (dynobj, info);
+ if (sgot == NULL)
return false;
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
}
if (srelgot == NULL
@@ -2542,7 +2575,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. */
@@ -2895,6 +2929,9 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
(info->relocateable) ? " (relocatable)" : "");
#endif
+ if (info->relocateable)
+ return true;
+
if (!ppc_elf_howto_table[R_PPC_ADDR32])
/* Initialize howto table if needed. */
ppc_elf_howto_init ();
@@ -2939,34 +2976,6 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
howto = ppc_elf_howto_table[(int) r_type];
r_symndx = ELF32_R_SYM (rel->r_info);
- if (info->relocateable)
- {
- /* 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. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if ((unsigned) ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- addend = rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
-#ifdef DEBUG
- fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
- howto->name,
- (int) r_type,
- r_symndx,
- (long) offset,
- (long) addend);
-#endif
- continue;
- }
-
- /* This is a final link. */
if (r_symndx < symtab_hdr->sh_info)
{
sym = local_syms + r_symndx;
@@ -3780,6 +3789,7 @@ ppc_elf_grok_psinfo (abfd, note)
#define elf_backend_can_refcount 1
#define elf_backend_got_header_size 12
#define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE
+#define elf_backend_rela_normal 1
#define bfd_elf32_bfd_merge_private_bfd_data ppc_elf_merge_private_bfd_data
#define bfd_elf32_bfd_relax_section ppc_elf_relax_section
diff --git a/contrib/binutils/bfd/elf32-s390.c b/contrib/binutils/bfd/elf32-s390.c
new file mode 100644
index 0000000..ed5f3f0
--- /dev/null
+++ b/contrib/binutils/bfd/elf32-s390.c
@@ -0,0 +1,2476 @@
+/* IBM S/390-specific support for 32-bit ELF
+ Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
+ Contributed by Carl B. Pedersen and Martin Schwidefsky.
+
+ 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 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. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+static reloc_howto_type *elf_s390_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static void elf_s390_info_to_howto
+ PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
+static boolean elf_s390_is_local_label_name
+ PARAMS ((bfd *, 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 *elf_s390_link_hash_table_create
+ PARAMS ((bfd *));
+static boolean create_got_section
+ PARAMS((bfd *, struct bfd_link_info *));
+static boolean elf_s390_create_dynamic_sections
+ PARAMS((bfd *, struct bfd_link_info *));
+static void elf_s390_copy_indirect_symbol
+ PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
+static boolean elf_s390_check_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
+static asection *elf_s390_gc_mark_hook
+ PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
+ struct elf_link_hash_entry *, Elf_Internal_Sym *));
+static boolean elf_s390_gc_sweep_hook
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
+static boolean elf_s390_adjust_dynamic_symbol
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+static boolean allocate_dynrelocs
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean readonly_dynrelocs
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean elf_s390_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf_s390_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+static boolean elf_s390_finish_dynamic_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
+ Elf_Internal_Sym *));
+static enum elf_reloc_type_class elf_s390_reloc_type_class
+ PARAMS ((const Elf_Internal_Rela *));
+static boolean elf_s390_finish_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf_s390_object_p PARAMS ((bfd *));
+static boolean elf_s390_grok_prstatus PARAMS ((bfd *, Elf_Internal_Note *));
+
+#define USE_RELA 1 /* We want RELA relocations, not REL. */
+
+#include "elf/s390.h"
+
+/* The relocation "howto" table. */
+
+static reloc_howto_type elf_howto_table[] =
+{
+ HOWTO (R_390_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_390_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO(R_390_8, 0, 0, 8, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_8", false, 0,0x000000ff, false),
+ HOWTO(R_390_12, 0, 1, 12, false, 0, complain_overflow_dont, bfd_elf_generic_reloc, "R_390_12", false, 0,0x00000fff, false),
+ HOWTO(R_390_16, 0, 1, 16, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_16", false, 0,0x0000ffff, false),
+ HOWTO(R_390_32, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_32", false, 0,0xffffffff, false),
+ HOWTO(R_390_PC32, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC32", false, 0,0xffffffff, true),
+ HOWTO(R_390_GOT12, 0, 1, 12, false, 0, complain_overflow_dont, bfd_elf_generic_reloc, "R_390_GOT12", false, 0,0x00000fff, false),
+ HOWTO(R_390_GOT32, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOT32", false, 0,0xffffffff, false),
+ HOWTO(R_390_PLT32, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PLT32", false, 0,0xffffffff, true),
+ HOWTO(R_390_COPY, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_COPY", false, 0,0xffffffff, false),
+ HOWTO(R_390_GLOB_DAT, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GLOB_DAT",false, 0,0xffffffff, false),
+ HOWTO(R_390_JMP_SLOT, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_JMP_SLOT",false, 0,0xffffffff, false),
+ HOWTO(R_390_RELATIVE, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_RELATIVE",false, 0,0xffffffff, false),
+ HOWTO(R_390_GOTOFF, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTOFF", false, 0,0xffffffff, false),
+ HOWTO(R_390_GOTPC, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTPC", false, 0,0xffffffff, true),
+ HOWTO(R_390_GOT16, 0, 1, 16, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOT16", false, 0,0x0000ffff, false),
+ HOWTO(R_390_PC16, 0, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC16", false, 0,0x0000ffff, true),
+ HOWTO(R_390_PC16DBL, 1, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC16DBL", false, 0,0x0000ffff, true),
+ HOWTO(R_390_PLT16DBL, 1, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PLT16DBL", false, 0,0x0000ffff, true),
+ HOWTO(R_390_PC32DBL, 1, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC32DBL", false, 0,0xffffffff, true),
+ HOWTO(R_390_PLT32DBL, 1, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PLT32DBL", false, 0,0xffffffff, true),
+ HOWTO(R_390_GOTPCDBL, 1, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTPCDBL", false, 0,0xffffffff, true),
+ HOWTO(R_390_GOTENT, 1, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTENT", false, 0,0xffffffff, true),
+};
+
+/* GNU extension to record C++ vtable hierarchy. */
+static reloc_howto_type elf32_s390_vtinherit_howto =
+ HOWTO (R_390_GNU_VTINHERIT, 0,2,0,false,0,complain_overflow_dont, NULL, "R_390_GNU_VTINHERIT", false,0, 0, false);
+static reloc_howto_type elf32_s390_vtentry_howto =
+ HOWTO (R_390_GNU_VTENTRY, 0,2,0,false,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_390_GNU_VTENTRY", false,0,0, false);
+
+static reloc_howto_type *
+elf_s390_reloc_type_lookup (abfd, code)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ case BFD_RELOC_NONE:
+ return &elf_howto_table[(int) R_390_NONE];
+ case BFD_RELOC_8:
+ return &elf_howto_table[(int) R_390_8];
+ case BFD_RELOC_390_12:
+ return &elf_howto_table[(int) R_390_12];
+ case BFD_RELOC_16:
+ return &elf_howto_table[(int) R_390_16];
+ case BFD_RELOC_32:
+ return &elf_howto_table[(int) R_390_32];
+ case BFD_RELOC_CTOR:
+ return &elf_howto_table[(int) R_390_32];
+ case BFD_RELOC_32_PCREL:
+ return &elf_howto_table[(int) R_390_PC32];
+ case BFD_RELOC_390_GOT12:
+ return &elf_howto_table[(int) R_390_GOT12];
+ case BFD_RELOC_32_GOT_PCREL:
+ return &elf_howto_table[(int) R_390_GOT32];
+ case BFD_RELOC_390_PLT32:
+ return &elf_howto_table[(int) R_390_PLT32];
+ case BFD_RELOC_390_COPY:
+ return &elf_howto_table[(int) R_390_COPY];
+ case BFD_RELOC_390_GLOB_DAT:
+ return &elf_howto_table[(int) R_390_GLOB_DAT];
+ case BFD_RELOC_390_JMP_SLOT:
+ return &elf_howto_table[(int) R_390_JMP_SLOT];
+ case BFD_RELOC_390_RELATIVE:
+ return &elf_howto_table[(int) R_390_RELATIVE];
+ case BFD_RELOC_32_GOTOFF:
+ return &elf_howto_table[(int) R_390_GOTOFF];
+ case BFD_RELOC_390_GOTPC:
+ return &elf_howto_table[(int) R_390_GOTPC];
+ case BFD_RELOC_390_GOT16:
+ return &elf_howto_table[(int) R_390_GOT16];
+ case BFD_RELOC_16_PCREL:
+ return &elf_howto_table[(int) R_390_PC16];
+ case BFD_RELOC_390_PC16DBL:
+ return &elf_howto_table[(int) R_390_PC16DBL];
+ case BFD_RELOC_390_PLT16DBL:
+ return &elf_howto_table[(int) R_390_PLT16DBL];
+ case BFD_RELOC_390_PC32DBL:
+ return &elf_howto_table[(int) R_390_PC32DBL];
+ case BFD_RELOC_390_PLT32DBL:
+ return &elf_howto_table[(int) R_390_PLT32DBL];
+ case BFD_RELOC_390_GOTPCDBL:
+ return &elf_howto_table[(int) R_390_GOTPCDBL];
+ case BFD_RELOC_390_GOTENT:
+ return &elf_howto_table[(int) R_390_GOTENT];
+ case BFD_RELOC_VTABLE_INHERIT:
+ return &elf32_s390_vtinherit_howto;
+ case BFD_RELOC_VTABLE_ENTRY:
+ return &elf32_s390_vtentry_howto;
+ default:
+ break;
+ }
+ return 0;
+}
+
+/* We need to use ELF32_R_TYPE so we have our own copy of this function,
+ and elf32-s390.c has its own copy. */
+
+static void
+elf_s390_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ arelent *cache_ptr;
+ Elf_Internal_Rela *dst;
+{
+ switch (ELF32_R_TYPE(dst->r_info))
+ {
+ case R_390_GNU_VTINHERIT:
+ cache_ptr->howto = &elf32_s390_vtinherit_howto;
+ break;
+
+ case R_390_GNU_VTENTRY:
+ cache_ptr->howto = &elf32_s390_vtentry_howto;
+ break;
+
+ default:
+ BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_390_max);
+ cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
+ }
+}
+
+static boolean
+elf_s390_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ if (name[0] == '.' && (name[1] == 'X' || name[1] == 'L'))
+ return true;
+
+ return _bfd_elf_is_local_label_name (abfd, name);
+}
+
+/* Functions for the 390 ELF linker. */
+
+/* The name of the dynamic interpreter. This is put in the .interp
+ section. */
+
+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
+
+/* The size in bytes of the first entry in the procedure linkage table. */
+#define PLT_FIRST_ENTRY_SIZE 32
+/* The size in bytes of an entry in the procedure linkage table. */
+#define PLT_ENTRY_SIZE 32
+
+#define GOT_ENTRY_SIZE 4
+
+/* The first three entries in a procedure linkage table are reserved,
+ and the initial contents are unimportant (we zero them out).
+ Subsequent entries look like this. See the SVR4 ABI 386
+ supplement to see how this works. */
+
+/* For the s390, simple addr offset can only be 0 - 4096.
+ To use the full 2 GB address space, several instructions
+ are needed to load an address in a register and execute
+ a branch( or just saving the address)
+
+ Furthermore, only r 0 and 1 are free to use!!! */
+
+/* The first 3 words in the GOT are then reserved.
+ Word 0 is the address of the dynamic table.
+ Word 1 is a pointer to a structure describing the object
+ Word 2 is used to point to the loader entry address.
+
+ The code for position independand PLT entries looks like this:
+
+ r12 holds addr of the current GOT at entry to the PLT
+
+ The GOT holds the address in the PLT to be executed.
+ The loader then gets:
+ 24(15) = Pointer to the structure describing the object.
+ 28(15) = Offset in symbol table
+
+ The loader must then find the module where the function is
+ and insert the address in the GOT.
+
+ Note: 390 can only address +- 64 K relative.
+ We check if offset > 65536, then make a relative branch -64xxx
+ back to a previous defined branch
+
+PLT1: BASR 1,0 # 2 bytes
+ L 1,22(1) # 4 bytes Load offset in GOT in r 1
+ L 1,(1,12) # 4 bytes Load address from GOT in r1
+ BCR 15,1 # 2 bytes Jump to address
+RET1: BASR 1,0 # 2 bytes Return from GOT 1st time
+ L 1,14(1) # 4 bytes Load offset in symol table in r1
+ BRC 15,-x # 4 bytes Jump to start of PLT
+ .word 0 # 2 bytes filler
+ .long ? # 4 bytes offset in GOT
+ .long ? # 4 bytes offset into symbol table
+
+ This was the general case. There are two additional, optimizes PLT
+ definitions. One for GOT offsets < 4096 and one for GOT offsets < 32768.
+ First the one for GOT offsets < 4096:
+
+PLT1: L 1,<offset>(12) # 4 bytes Load address from GOT in R1
+ BCR 15,1 # 2 bytes Jump to address
+ .word 0,0,0 # 6 bytes filler
+RET1: BASR 1,0 # 2 bytes Return from GOT 1st time
+ L 1,14(1) # 4 bytes Load offset in symbol table in r1
+ BRC 15,-x # 4 bytes Jump to start of PLT
+ .word 0,0,0 # 6 bytes filler
+ .long ? # 4 bytes offset into symbol table
+
+ Second the one for GOT offsets < 32768:
+
+PLT1: LHI 1,<offset> # 4 bytes Load offset in GOT to r1
+ L 1,(1,12) # 4 bytes Load address from GOT to r1
+ BCR 15,1 # 2 bytes Jump to address
+ .word 0 # 2 bytes filler
+RET1: BASR 1,0 # 2 bytes Return from GOT 1st time
+ L 1,14(1) # 4 bytes Load offset in symbol table in r1
+ BRC 15,-x # 4 bytes Jump to start of PLT
+ .word 0,0,0 # 6 bytes filler
+ .long ? # 4 bytes offset into symbol table
+
+Total = 32 bytes per PLT entry
+
+ The code for static build PLT entries looks like this:
+
+PLT1: BASR 1,0 # 2 bytes
+ L 1,22(1) # 4 bytes Load address of GOT entry
+ L 1,0(0,1) # 4 bytes Load address from GOT in r1
+ BCR 15,1 # 2 bytes Jump to address
+RET1: BASR 1,0 # 2 bytes Return from GOT 1st time
+ L 1,14(1) # 4 bytes Load offset in symbol table in r1
+ BRC 15,-x # 4 bytes Jump to start of PLT
+ .word 0 # 2 bytes filler
+ .long ? # 4 bytes address of GOT entry
+ .long ? # 4 bytes offset into symbol table */
+
+#define PLT_PIC_ENTRY_WORD0 0x0d105810
+#define PLT_PIC_ENTRY_WORD1 0x10165811
+#define PLT_PIC_ENTRY_WORD2 0xc00007f1
+#define PLT_PIC_ENTRY_WORD3 0x0d105810
+#define PLT_PIC_ENTRY_WORD4 0x100ea7f4
+
+#define PLT_PIC12_ENTRY_WORD0 0x5810c000
+#define PLT_PIC12_ENTRY_WORD1 0x07f10000
+#define PLT_PIC12_ENTRY_WORD2 0x00000000
+#define PLT_PIC12_ENTRY_WORD3 0x0d105810
+#define PLT_PIC12_ENTRY_WORD4 0x100ea7f4
+
+#define PLT_PIC16_ENTRY_WORD0 0xa7180000
+#define PLT_PIC16_ENTRY_WORD1 0x5811c000
+#define PLT_PIC16_ENTRY_WORD2 0x07f10000
+#define PLT_PIC16_ENTRY_WORD3 0x0d105810
+#define PLT_PIC16_ENTRY_WORD4 0x100ea7f4
+
+#define PLT_ENTRY_WORD0 0x0d105810
+#define PLT_ENTRY_WORD1 0x10165810
+#define PLT_ENTRY_WORD2 0x100007f1
+#define PLT_ENTRY_WORD3 0x0d105810
+#define PLT_ENTRY_WORD4 0x100ea7f4
+
+/* The first PLT entry pushes the offset into the symbol table
+ from R1 onto the stack at 8(15) and the loader object info
+ at 12(15), loads the loader address in R1 and jumps to it. */
+
+/* The first entry in the PLT for PIC code:
+
+PLT0:
+ ST 1,28(15) # R1 has offset into symbol table
+ L 1,4(12) # Get loader ino(object struct address)
+ ST 1,24(15) # Store address
+ L 1,8(12) # Entry address of loader in R1
+ BR 1 # Jump to loader
+
+ The first entry in the PLT for static code:
+
+PLT0:
+ ST 1,28(15) # R1 has offset into symbol table
+ BASR 1,0
+ L 1,18(0,1) # Get address of GOT
+ MVC 24(4,15),4(1) # Move loader ino to stack
+ L 1,8(1) # Get address of loader
+ BR 1 # Jump to loader
+ .word 0 # filler
+ .long got # address of GOT */
+
+#define PLT_PIC_FIRST_ENTRY_WORD0 0x5010f01c
+#define PLT_PIC_FIRST_ENTRY_WORD1 0x5810c004
+#define PLT_PIC_FIRST_ENTRY_WORD2 0x5010f018
+#define PLT_PIC_FIRST_ENTRY_WORD3 0x5810c008
+#define PLT_PIC_FIRST_ENTRY_WORD4 0x07f10000
+
+#define PLT_FIRST_ENTRY_WORD0 0x5010f01c
+#define PLT_FIRST_ENTRY_WORD1 0x0d105810
+#define PLT_FIRST_ENTRY_WORD2 0x1012D203
+#define PLT_FIRST_ENTRY_WORD3 0xf0181004
+#define PLT_FIRST_ENTRY_WORD4 0x58101008
+#define PLT_FIRST_ENTRY_WORD5 0x07f10000
+
+/* The s390 linker needs to keep track of the number of relocs that it
+ decides to copy as dynamic relocs in check_relocs for each symbol.
+ This is so that it can later discard them if they are found to be
+ unnecessary. We store the information in a field extending the
+ regular ELF linker hash table. */
+
+struct elf_s390_dyn_relocs
+{
+ struct elf_s390_dyn_relocs *next;
+
+ /* The input section of the reloc. */
+ asection *sec;
+
+ /* Total number of relocs copied for the input section. */
+ bfd_size_type count;
+
+ /* Number of pc-relative relocs copied for the input section. */
+ bfd_size_type pc_count;
+};
+
+/* s390 ELF linker hash entry. */
+
+struct elf_s390_link_hash_entry
+{
+ struct elf_link_hash_entry elf;
+
+ /* Track dynamic relocs copied for this symbol. */
+ struct elf_s390_dyn_relocs *dyn_relocs;
+};
+
+/* s390 ELF linker hash table. */
+
+struct elf_s390_link_hash_table
+{
+ struct elf_link_hash_table elf;
+
+ /* Short-cuts to get to dynamic linker sections. */
+ asection *sgot;
+ asection *sgotplt;
+ asection *srelgot;
+ asection *splt;
+ asection *srelplt;
+ asection *sdynbss;
+ asection *srelbss;
+
+ /* Small local sym to section mapping cache. */
+ struct sym_sec_cache sym_sec;
+};
+
+/* Get the s390 ELF linker hash table from a link_info structure. */
+
+#define elf_s390_hash_table(p) \
+ ((struct elf_s390_link_hash_table *) ((p)->hash))
+
+/* Create an entry in an s390 ELF linker hash table. */
+
+static struct bfd_hash_entry *
+link_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 elf_s390_link_hash_entry));
+ if (entry == NULL)
+ return entry;
+ }
+
+ /* Call the allocation method of the superclass. */
+ entry = _bfd_elf_link_hash_newfunc (entry, table, string);
+ if (entry != NULL)
+ {
+ struct elf_s390_link_hash_entry *eh;
+
+ eh = (struct elf_s390_link_hash_entry *) entry;
+ eh->dyn_relocs = NULL;
+ }
+
+ return entry;
+}
+
+/* Create an s390 ELF linker hash table. */
+
+static struct bfd_link_hash_table *
+elf_s390_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct elf_s390_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf_s390_link_hash_table);
+
+ ret = (struct elf_s390_link_hash_table *) bfd_alloc (abfd, amt);
+ if (ret == NULL)
+ return NULL;
+
+ if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+
+ ret->sgot = NULL;
+ ret->sgotplt = NULL;
+ ret->srelgot = NULL;
+ ret->splt = NULL;
+ ret->srelplt = NULL;
+ ret->sdynbss = NULL;
+ ret->srelbss = NULL;
+ ret->sym_sec.abfd = NULL;
+
+ return &ret->elf.root;
+}
+
+/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
+ shortcuts to them in our hash table. */
+
+static boolean
+create_got_section (dynobj, info)
+ bfd *dynobj;
+ struct bfd_link_info *info;
+{
+ struct elf_s390_link_hash_table *htab;
+
+ if (! _bfd_elf_create_got_section (dynobj, info))
+ return false;
+
+ htab = elf_s390_hash_table (info);
+ htab->sgot = bfd_get_section_by_name (dynobj, ".got");
+ htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+ if (!htab->sgot || !htab->sgotplt)
+ abort ();
+
+ htab->srelgot = bfd_make_section (dynobj, ".rela.got");
+ if (htab->srelgot == NULL
+ || ! bfd_set_section_flags (dynobj, htab->srelgot,
+ (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
+ return false;
+ return true;
+}
+
+/* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
+ .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
+ hash table. */
+
+static boolean
+elf_s390_create_dynamic_sections (dynobj, info)
+ bfd *dynobj;
+ struct bfd_link_info *info;
+{
+ struct elf_s390_link_hash_table *htab;
+
+ htab = elf_s390_hash_table (info);
+ if (!htab->sgot && !create_got_section (dynobj, info))
+ return false;
+
+ if (!_bfd_elf_create_dynamic_sections (dynobj, info))
+ return false;
+
+ htab->splt = bfd_get_section_by_name (dynobj, ".plt");
+ htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
+ htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+ if (!info->shared)
+ htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+
+ if (!htab->splt || !htab->srelplt || !htab->sdynbss
+ || (!info->shared && !htab->srelbss))
+ abort ();
+
+ return true;
+}
+
+/* Copy the extra info we tack onto an elf_link_hash_entry. */
+
+static void
+elf_s390_copy_indirect_symbol (dir, ind)
+ struct elf_link_hash_entry *dir, *ind;
+{
+ struct elf_s390_link_hash_entry *edir, *eind;
+
+ edir = (struct elf_s390_link_hash_entry *) dir;
+ eind = (struct elf_s390_link_hash_entry *) ind;
+
+ if (eind->dyn_relocs != NULL)
+ {
+ if (edir->dyn_relocs != NULL)
+ {
+ struct elf_s390_dyn_relocs **pp;
+ struct elf_s390_dyn_relocs *p;
+
+ if (ind->root.type == bfd_link_hash_indirect)
+ abort ();
+
+ /* Add reloc counts against the weak sym to the strong sym
+ list. Merge any entries against the same section. */
+ for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
+ {
+ struct elf_s390_dyn_relocs *q;
+
+ for (q = edir->dyn_relocs; q != NULL; q = q->next)
+ if (q->sec == p->sec)
+ {
+ q->pc_count += p->pc_count;
+ q->count += p->count;
+ *pp = p->next;
+ break;
+ }
+ if (q == NULL)
+ pp = &p->next;
+ }
+ *pp = edir->dyn_relocs;
+ }
+
+ edir->dyn_relocs = eind->dyn_relocs;
+ eind->dyn_relocs = NULL;
+ }
+
+ _bfd_elf_link_hash_copy_indirect (dir, ind);
+}
+
+/* Look through the relocs for a section during the first phase, and
+ allocate space in the global offset table or procedure linkage
+ table. */
+
+static boolean
+elf_s390_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ struct elf_s390_link_hash_table *htab;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+ asection *sreloc;
+
+ if (info->relocateable)
+ return true;
+
+ htab = elf_s390_hash_table (info);
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+
+ sreloc = NULL;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+
+ if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
+ {
+ (*_bfd_error_handler) (_("%s: bad symbol index: %d"),
+ bfd_archive_filename (abfd),
+ r_symndx);
+ return false;
+ }
+
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_390_GOT12:
+ case R_390_GOT16:
+ case R_390_GOT32:
+ case R_390_GOTENT:
+ /* 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;
+
+ 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_390_GOTOFF:
+ case R_390_GOTPC:
+ case R_390_GOTPCDBL:
+ if (htab->sgot == NULL)
+ {
+ if (htab->elf.dynobj == NULL)
+ htab->elf.dynobj = abfd;
+ if (!create_got_section (htab->elf.dynobj, info))
+ return false;
+ }
+ break;
+
+ case R_390_PLT16DBL:
+ case R_390_PLT32DBL:
+ case R_390_PLT32:
+ /* 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 which is
+ never referenced by a dynamic object, in which case we
+ don't need to generate a procedure linkage table entry
+ after all. */
+
+ /* If this is a local symbol, we resolve it directly without
+ creating a procedure linkage table entry. */
+ if (h == NULL)
+ continue;
+
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+ h->plt.refcount += 1;
+ break;
+
+ case R_390_8:
+ case R_390_16:
+ case R_390_32:
+ case R_390_PC16:
+ case R_390_PC16DBL:
+ case R_390_PC32DBL:
+ case R_390_PC32:
+ if (h != NULL && !info->shared)
+ {
+ /* If this reloc is in a read-only section, we might
+ need a copy reloc. We can't check reliably at this
+ stage whether the section is read-only, as input
+ sections have not yet been mapped to output sections.
+ Tentatively set the flag for now, and correct in
+ adjust_dynamic_symbol. */
+ h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
+
+ /* We may need a .plt entry if the function this reloc
+ refers to is in a shared lib. */
+ h->plt.refcount += 1;
+ }
+
+ /* If we are creating a shared library, and this is a reloc
+ against a global symbol, or a non PC relative reloc
+ against a local symbol, then we need to copy the reloc
+ into the shared library. However, if we are linking with
+ -Bsymbolic, we do not need to copy a reloc against a
+ global symbol which is defined in an object we are
+ including in the link (i.e., DEF_REGULAR is set). At
+ this point we have not seen all the input files, so it is
+ possible that DEF_REGULAR is not set now but will be set
+ later (it is never cleared). In case of a weak definition,
+ DEF_REGULAR may be cleared later by a strong definition in
+ a shared library. We account for that possibility below by
+ storing information in the relocs_copied field of the hash
+ table entry. A similar situation occurs when creating
+ shared libraries and symbol visibility changes render the
+ symbol local.
+
+ If on the other hand, we are creating an executable, we
+ may need to keep relocations for symbols satisfied by a
+ dynamic library if we manage to avoid copy relocs for the
+ symbol. */
+ if ((info->shared
+ && (sec->flags & SEC_ALLOC) != 0
+ && ((ELF32_R_TYPE (rel->r_info) != R_390_PC16
+ && ELF32_R_TYPE (rel->r_info) != R_390_PC16DBL
+ && ELF32_R_TYPE (rel->r_info) != R_390_PC32DBL
+ && ELF32_R_TYPE (rel->r_info) != R_390_PC32)
+ || (h != NULL
+ && (! info->symbolic
+ || h->root.type == bfd_link_hash_defweak
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+ || (!info->shared
+ && (sec->flags & SEC_ALLOC) != 0
+ && h != NULL
+ && (h->root.type == bfd_link_hash_defweak
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)))
+ {
+ struct elf_s390_dyn_relocs *p;
+ struct elf_s390_dyn_relocs **head;
+
+ /* We must copy these reloc types into the output file.
+ Create a reloc section in dynobj and make room for
+ this reloc. */
+ if (sreloc == NULL)
+ {
+ const char *name;
+ bfd *dynobj;
+
+ name = (bfd_elf_string_from_elf_section
+ (abfd,
+ elf_elfheader (abfd)->e_shstrndx,
+ elf_section_data (sec)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ if (strncmp (name, ".rela", 5) != 0
+ || strcmp (bfd_get_section_name (abfd, sec),
+ name + 5) != 0)
+ {
+ (*_bfd_error_handler)
+ (_("%s: bad relocation section name `%s\'"),
+ bfd_archive_filename (abfd), name);
+ }
+
+ if (htab->elf.dynobj == NULL)
+ htab->elf.dynobj = abfd;
+
+ dynobj = htab->elf.dynobj;
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ if (sreloc == NULL)
+ {
+ flagword flags;
+
+ sreloc = bfd_make_section (dynobj, name);
+ flags = (SEC_HAS_CONTENTS | SEC_READONLY
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+ if ((sec->flags & SEC_ALLOC) != 0)
+ flags |= SEC_ALLOC | SEC_LOAD;
+ if (sreloc == NULL
+ || ! bfd_set_section_flags (dynobj, sreloc, flags)
+ || ! bfd_set_section_alignment (dynobj, sreloc, 2))
+ return false;
+ }
+ elf_section_data (sec)->sreloc = sreloc;
+ }
+
+ /* If this is a global symbol, we count the number of
+ relocations we need for this symbol. */
+ if (h != NULL)
+ {
+ head = &((struct elf_s390_link_hash_entry *) h)->dyn_relocs;
+ }
+ else
+ {
+ /* Track dynamic relocs needed for local syms too.
+ We really need local syms available to do this
+ easily. Oh well. */
+
+ asection *s;
+ s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
+ sec, r_symndx);
+ if (s == NULL)
+ return false;
+
+ head = ((struct elf_s390_dyn_relocs **)
+ &elf_section_data (s)->local_dynrel);
+ }
+
+ p = *head;
+ if (p == NULL || p->sec != sec)
+ {
+ bfd_size_type amt = sizeof *p;
+ p = ((struct elf_s390_dyn_relocs *)
+ bfd_alloc (htab->elf.dynobj, amt));
+ if (p == NULL)
+ return false;
+ p->next = *head;
+ *head = p;
+ p->sec = sec;
+ p->count = 0;
+ p->pc_count = 0;
+ }
+
+ p->count += 1;
+ if (ELF32_R_TYPE (rel->r_info) == R_390_PC16
+ || ELF32_R_TYPE (rel->r_info) == R_390_PC16DBL
+ || ELF32_R_TYPE (rel->r_info) == R_390_PC32DBL
+ || ELF32_R_TYPE (rel->r_info) == R_390_PC32)
+ p->pc_count += 1;
+ }
+ break;
+
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_390_GNU_VTINHERIT:
+ if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_390_GNU_VTENTRY:
+ if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return false;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return true;
+}
+
+/* Return the section that should be marked against GC for a given
+ relocation. */
+
+static asection *
+elf_s390_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ 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))
+ {
+ case R_390_GNU_VTINHERIT:
+ case R_390_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+
+ default:
+ break;
+ }
+ }
+ }
+ else
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+
+ return NULL;
+}
+
+/* Update the got entry reference counts for the section being removed. */
+
+static boolean
+elf_s390_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_signed_vma *local_got_refcounts;
+ const Elf_Internal_Rela *rel, *relend;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ elf_section_data (sec)->local_dynrel = NULL;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ local_got_refcounts = elf_local_got_refcounts (abfd);
+
+ relend = relocs + sec->reloc_count;
+ for (rel = relocs; rel < relend; rel++)
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_390_GOT12:
+ case R_390_GOT16:
+ case R_390_GOT32:
+ case R_390_GOTOFF:
+ case R_390_GOTPC:
+ case R_390_GOTPCDBL:
+ case R_390_GOTENT:
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ if (h->got.refcount > 0)
+ h->got.refcount -= 1;
+ }
+ else if (local_got_refcounts != NULL)
+ {
+ if (local_got_refcounts[r_symndx] > 0)
+ local_got_refcounts[r_symndx] -= 1;
+ }
+ break;
+
+ case R_390_8:
+ case R_390_12:
+ case R_390_16:
+ case R_390_32:
+ case R_390_PC16:
+ case R_390_PC16DBL:
+ case R_390_PC32DBL:
+ case R_390_PC32:
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ struct elf_s390_link_hash_entry *eh;
+ struct elf_s390_dyn_relocs **pp;
+ struct elf_s390_dyn_relocs *p;
+
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ if (!info->shared && h->plt.refcount > 0)
+ h->plt.refcount -= 1;
+
+ eh = (struct elf_s390_link_hash_entry *) h;
+
+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
+ if (p->sec == sec)
+ {
+ if (ELF32_R_TYPE (rel->r_info) == R_390_PC16
+ || ELF32_R_TYPE (rel->r_info) == R_390_PC16DBL
+ || ELF32_R_TYPE (rel->r_info) == R_390_PC32DBL
+ || ELF32_R_TYPE (rel->r_info) == R_390_PC32)
+ p->pc_count -= 1;
+ p->count -= 1;
+ if (p->count == 0)
+ *pp = p->next;
+ break;
+ }
+ }
+ break;
+
+ case R_390_PLT16DBL:
+ case R_390_PLT32DBL:
+ case R_390_PLT32:
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ if (h->plt.refcount > 0)
+ h->plt.refcount -= 1;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+ regular object. The current definition is in some section of the
+ dynamic object, but we're not including those sections. We have to
+ change the definition to something the rest of the link can
+ understand. */
+
+static boolean
+elf_s390_adjust_dynamic_symbol (info, h)
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+{
+ struct elf_s390_link_hash_table *htab;
+ struct elf_s390_link_hash_entry * eh;
+ struct elf_s390_dyn_relocs *p;
+ asection *s;
+ 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
+ (although we could actually do it here). */
+ if (h->type == STT_FUNC
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+ {
+ if (h->plt.refcount <= 0
+ || (! 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->root.type != bfd_link_hash_undefweak
+ && h->root.type != bfd_link_hash_undefined))
+ {
+ /* 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, or if all references were garbage collected. In
+ such a case, we don't actually need to build a procedure
+ linkage table, and we can just do a PC32 reloc instead. */
+ h->plt.offset = (bfd_vma) -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ }
+
+ return true;
+ }
+ else
+ /* It's possible that we incorrectly decided a .plt reloc was
+ needed for an R_390_PC32 reloc to a non-function sym in
+ check_relocs. We can't decide accurately between function and
+ non-function syms in check-relocs; Objects loaded later in
+ the link may change h->type. So fix it now. */
+ h->plt.offset = (bfd_vma) -1;
+
+ /* If this is a weak symbol, and there is a real definition, the
+ processor independent code will have arranged for us to see the
+ real definition first, and we can just use the same value. */
+ if (h->weakdef != NULL)
+ {
+ BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+ || h->weakdef->root.type == bfd_link_hash_defweak);
+ h->root.u.def.section = h->weakdef->root.u.def.section;
+ h->root.u.def.value = h->weakdef->root.u.def.value;
+ return true;
+ }
+
+ /* This is a reference to a symbol defined by a dynamic object which
+ is not a function. */
+
+ /* If we are creating a shared library, we must presume that the
+ only references to the symbol are via the global offset table.
+ For such cases we need not do anything here; the relocations will
+ be handled correctly by relocate_section. */
+ if (info->shared)
+ return true;
+
+ /* If there are no references to this symbol that do not use the
+ GOT, we don't need to generate a copy reloc. */
+ if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
+ return true;
+
+ /* If -z nocopyreloc was given, we won't generate them either. */
+ if (info->nocopyreloc)
+ {
+ h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
+ return true;
+ }
+
+ eh = (struct elf_s390_link_hash_entry *) h;
+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ {
+ s = p->sec->output_section;
+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
+ break;
+ }
+
+ /* 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. */
+ if (p == NULL)
+ {
+ h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
+ return true;
+ }
+
+ /* We must allocate the symbol in our .dynbss section, which will
+ become part of the .bss section of the executable. There will be
+ an entry for this symbol in the .dynsym section. The dynamic
+ object will contain position independent code, so all references
+ from the dynamic object to this symbol will go through the global
+ offset table. The dynamic linker will use the .dynsym entry to
+ determine the address it must put in the global offset table, so
+ both the dynamic object and the regular object will refer to the
+ same memory location for the variable. */
+
+ htab = elf_s390_hash_table (info);
+
+ /* We must generate a R_390_COPY reloc to tell the dynamic linker to
+ copy the initial value out of the dynamic object and into the
+ runtime process image. */
+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+ {
+ htab->srelbss->_raw_size += sizeof (Elf32_External_Rela);
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+ }
+
+ /* We need to figure out the alignment required for this symbol. I
+ have no idea how ELF linkers handle this. */
+ power_of_two = bfd_log2 (h->size);
+ if (power_of_two > 3)
+ power_of_two = 3;
+
+ /* Apply the required alignment. */
+ s = htab->sdynbss;
+ s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two));
+ if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s))
+ {
+ if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two))
+ return false;
+ }
+
+ /* Define the symbol as being at this point in the section. */
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+
+ /* Increment the section size to make room for the symbol. */
+ s->_raw_size += h->size;
+
+ return true;
+}
+
+/* This is the condition under which elf_s390_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
+ initializing any .plt and .got entries in elf_s390_relocate_section. */
+#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
+ ((DYN) \
+ && ((INFO)->shared \
+ || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
+ && ((H)->dynindx != -1 \
+ || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
+
+/* Allocate space in .plt, .got and associated reloc sections for
+ dynamic relocs. */
+
+static boolean
+allocate_dynrelocs (h, inf)
+ struct elf_link_hash_entry *h;
+ PTR inf;
+{
+ struct bfd_link_info *info;
+ struct elf_s390_link_hash_table *htab;
+ struct elf_s390_link_hash_entry *eh;
+ struct elf_s390_dyn_relocs *p;
+
+ if (h->root.type == bfd_link_hash_indirect)
+ return true;
+
+ if (h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ info = (struct bfd_link_info *) inf;
+ htab = elf_s390_hash_table (info);
+
+ if (htab->elf.dynamic_sections_created
+ && h->plt.refcount > 0)
+ {
+ /* Make sure this symbol is output as a dynamic symbol.
+ Undefined weak syms won't yet be marked as dynamic. */
+ if (h->dynindx == -1
+ && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
+ {
+ asection *s = htab->splt;
+
+ /* If this is the first .plt entry, make room for the special
+ first entry. */
+ if (s->_raw_size == 0)
+ s->_raw_size += PLT_FIRST_ENTRY_SIZE;
+
+ h->plt.offset = s->_raw_size;
+
+ /* If this symbol is not defined in a regular file, and we are
+ not generating a shared library, then set the symbol to this
+ location in the .plt. This is required to make function
+ pointers compare as equal between the normal executable and
+ the shared library. */
+ if (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = h->plt.offset;
+ }
+
+ /* Make room for this entry. */
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .got.plt section, which
+ will be placed in the .got section by the linker script. */
+ htab->sgotplt->_raw_size += GOT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .rela.plt section. */
+ htab->srelplt->_raw_size += sizeof (Elf32_External_Rela);
+ }
+ else
+ {
+ h->plt.offset = (bfd_vma) -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ }
+ }
+ else
+ {
+ h->plt.offset = (bfd_vma) -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ }
+
+ if (h->got.refcount > 0)
+ {
+ asection *s;
+ boolean dyn;
+
+ /* Make sure this symbol is output as a dynamic symbol.
+ Undefined weak syms won't yet be marked as dynamic. */
+ if (h->dynindx == -1
+ && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ s = htab->sgot;
+ h->got.offset = s->_raw_size;
+ s->_raw_size += GOT_ENTRY_SIZE;
+ dyn = htab->elf.dynamic_sections_created;
+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h))
+ htab->srelgot->_raw_size += sizeof (Elf32_External_Rela);
+ }
+ else
+ h->got.offset = (bfd_vma) -1;
+
+ eh = (struct elf_s390_link_hash_entry *) h;
+ if (eh->dyn_relocs == NULL)
+ return true;
+
+ /* In the shared -Bsymbolic case, discard space allocated for
+ dynamic pc-relative relocs against symbols which turn out to be
+ defined in regular objects. For the normal shared case, discard
+ space for pc-relative relocs that have become local due to symbol
+ visibility changes. */
+
+ if (info->shared)
+ {
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
+ && ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
+ || info->symbolic))
+ {
+ struct elf_s390_dyn_relocs **pp;
+
+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+ {
+ p->count -= p->pc_count;
+ p->pc_count = 0;
+ if (p->count == 0)
+ *pp = p->next;
+ else
+ pp = &p->next;
+ }
+ }
+ }
+ else
+ {
+ /* For the non-shared case, discard space for relocs against
+ symbols which turn out to need copy relocs or are not
+ dynamic. */
+
+ if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
+ && (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ || (htab->elf.dynamic_sections_created
+ && (h->root.type == bfd_link_hash_undefweak
+ || h->root.type == bfd_link_hash_undefined))))
+ {
+ /* Make sure this symbol is output as a dynamic symbol.
+ Undefined weak syms won't yet be marked as dynamic. */
+ if (h->dynindx == -1
+ && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+ {
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ /* If that succeeded, we know we'll be keeping all the
+ relocs. */
+ if (h->dynindx != -1)
+ goto keep;
+ }
+
+ eh->dyn_relocs = NULL;
+
+ keep: ;
+ }
+
+ /* Finally, allocate space. */
+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ {
+ asection *sreloc = elf_section_data (p->sec)->sreloc;
+ sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela);
+ }
+
+ return true;
+}
+
+/* Find any dynamic relocs that apply to read-only sections. */
+
+static boolean
+readonly_dynrelocs (h, inf)
+ struct elf_link_hash_entry *h;
+ PTR inf;
+{
+ struct elf_s390_link_hash_entry *eh;
+ struct elf_s390_dyn_relocs *p;
+
+ if (h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ eh = (struct elf_s390_link_hash_entry *) h;
+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ {
+ asection *s = p->sec->output_section;
+
+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
+ {
+ struct bfd_link_info *info = (struct bfd_link_info *) inf;
+
+ info->flags |= DF_TEXTREL;
+
+ /* Not an error, just cut short the traversal. */
+ return false;
+ }
+ }
+ return true;
+}
+
+/* Set the sizes of the dynamic sections. */
+
+static boolean
+elf_s390_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd ATTRIBUTE_UNUSED;
+ struct bfd_link_info *info;
+{
+ struct elf_s390_link_hash_table *htab;
+ bfd *dynobj;
+ asection *s;
+ boolean relocs;
+ bfd *ibfd;
+
+ htab = elf_s390_hash_table (info);
+ dynobj = htab->elf.dynobj;
+ if (dynobj == NULL)
+ abort ();
+
+ if (htab->elf.dynamic_sections_created)
+ {
+ /* Set the contents of the .interp section to the interpreter. */
+ if (! info->shared)
+ {
+ s = bfd_get_section_by_name (dynobj, ".interp");
+ if (s == NULL)
+ abort ();
+ s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+ }
+ }
+
+ /* Set up .got offsets for local syms, and space for local dynamic
+ relocs. */
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ {
+ bfd_signed_vma *local_got;
+ bfd_signed_vma *end_local_got;
+ bfd_size_type locsymcount;
+ Elf_Internal_Shdr *symtab_hdr;
+ asection *srela;
+
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ continue;
+
+ for (s = ibfd->sections; s != NULL; s = s->next)
+ {
+ struct elf_s390_dyn_relocs *p;
+
+ for (p = *((struct elf_s390_dyn_relocs **)
+ &elf_section_data (s)->local_dynrel);
+ p != NULL;
+ p = p->next)
+ {
+ if (!bfd_is_abs_section (p->sec)
+ && bfd_is_abs_section (p->sec->output_section))
+ {
+ /* Input section has been discarded, either because
+ it is a copy of a linkonce section or due to
+ linker script /DISCARD/, so we'll be discarding
+ the relocs too. */
+ }
+ else if (p->count != 0)
+ {
+ srela = elf_section_data (p->sec)->sreloc;
+ srela->_raw_size += p->count * sizeof (Elf32_External_Rela);
+ if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+ info->flags |= DF_TEXTREL;
+ }
+ }
+ }
+
+ local_got = elf_local_got_refcounts (ibfd);
+ if (!local_got)
+ continue;
+
+ symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ locsymcount = symtab_hdr->sh_info;
+ end_local_got = local_got + locsymcount;
+ s = htab->sgot;
+ srela = htab->srelgot;
+ for (; local_got < end_local_got; ++local_got)
+ {
+ if (*local_got > 0)
+ {
+ *local_got = s->_raw_size;
+ s->_raw_size += GOT_ENTRY_SIZE;
+ if (info->shared)
+ srela->_raw_size += sizeof (Elf32_External_Rela);
+ }
+ else
+ *local_got = (bfd_vma) -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);
+
+ /* We now have determined the sizes of the various dynamic sections.
+ Allocate memory for them. */
+ relocs = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ if (s == htab->splt
+ || s == htab->sgot
+ || s == htab->sgotplt)
+ {
+ /* Strip this section if we don't need it; see the
+ comment below. */
+ }
+ else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
+ {
+ if (s->_raw_size != 0 && s != htab->srelplt)
+ relocs = true;
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ s->reloc_count = 0;
+ }
+ else
+ {
+ /* It's not one of our sections, so don't allocate space. */
+ continue;
+ }
+
+ if (s->_raw_size == 0)
+ {
+ /* If we don't need this section, strip it from the
+ output file. This is to handle .rela.bss and
+ .rela.plt. We must create it in
+ create_dynamic_sections, because it must be created
+ before the linker maps input sections to output
+ sections. The linker does that before
+ adjust_dynamic_symbol is called, and it is that
+ function which decides whether anything needs to go
+ into these sections. */
+
+ _bfd_strip_section_from_output (info, s);
+ 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_390_NONE reloc instead
+ of garbage. */
+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
+ if (s->contents == NULL)
+ return false;
+ }
+
+ if (htab->elf.dynamic_sections_created)
+ {
+ /* Add some entries to the .dynamic section. We fill in the
+ values later, in elf_s390_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+ if (! info->shared)
+ {
+ if (!add_dynamic_entry (DT_DEBUG, 0))
+ return false;
+ }
+
+ if (htab->splt->_raw_size != 0)
+ {
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
+ return false;
+ }
+
+ if (relocs)
+ {
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
+ return false;
+
+ /* If any dynamic relocs apply to a read-only section,
+ then we need a DT_TEXTREL entry. */
+ if ((info->flags & DF_TEXTREL) == 0)
+ elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
+ (PTR) info);
+
+ if ((info->flags & DF_TEXTREL) != 0)
+ {
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
+ return false;
+ }
+ }
+ }
+#undef add_dynamic_entry
+
+ return true;
+}
+
+/* Relocate a 390 ELF section. */
+
+static boolean
+elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ struct elf_s390_link_hash_table *htab;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_vma *local_got_offsets;
+ Elf_Internal_Rela *rel;
+ Elf_Internal_Rela *relend;
+
+ if (info->relocateable)
+ return true;
+
+ htab = elf_s390_hash_table (info);
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+ local_got_offsets = elf_local_got_offsets (input_bfd);
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ bfd_vma off;
+ bfd_vma relocation;
+ boolean unresolved_reloc;
+ bfd_reloc_status_type r;
+
+ r_type = ELF32_R_TYPE (rel->r_info);
+ if (r_type == (int) R_390_GNU_VTINHERIT
+ || r_type == (int) R_390_GNU_VTENTRY)
+ continue;
+ if (r_type < 0 || r_type >= (int) R_390_max)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ howto = elf_howto_table + r_type;
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ unresolved_reloc = false;
+ 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);
+ }
+ else
+ {
+ 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)
+ {
+ sec = h->root.u.def.section;
+ if (sec->output_section == NULL)
+ {
+ /* Set a flag that will be cleared later if we find a
+ relocation value for this symbol. output_section
+ is typically NULL for symbols satisfied by a shared
+ library. */
+ unresolved_reloc = true;
+ relocation = 0;
+ }
+ else
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else if (info->shared
+ && (!info->symbolic || info->allow_shlib_undefined)
+ && !info->no_undefined
+ && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
+ relocation = 0;
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset,
+ (!info->shared || info->no_undefined
+ || ELF_ST_VISIBILITY (h->other)))))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ switch (r_type)
+ {
+ case R_390_GOT12:
+ case R_390_GOT16:
+ case R_390_GOT32:
+ case R_390_GOTENT:
+ /* Relocation is to the entry for this symbol in the global
+ offset table. */
+ if (htab->sgot == NULL)
+ abort ();
+
+ if (h != NULL)
+ {
+ boolean dyn;
+
+ off = h->got.offset;
+ dyn = htab->elf.dynamic_sections_created;
+ if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
+ || (info->shared
+ && (info->symbolic
+ || h->dynindx == -1
+ || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+ {
+ /* This is actually a static link, or it is a
+ -Bsymbolic link and the symbol is defined
+ locally, or the symbol was forced to be local
+ because of a version file. We must initialize
+ this entry in the global offset table. Since the
+ offset must always be a multiple of 2, we use the
+ least significant bit to record whether we have
+ initialized it already.
+
+ When doing a dynamic link, we create a .rel.got
+ relocation entry to initialize the value. This
+ is done in the finish_dynamic_symbol routine. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, relocation,
+ htab->sgot->contents + off);
+ h->got.offset |= 1;
+ }
+ }
+ else
+ unresolved_reloc = false;
+ }
+ else
+ {
+ if (local_got_offsets == NULL)
+ abort ();
+
+ off = local_got_offsets[r_symndx];
+
+ /* The offset must always be a multiple of 4. We use
+ the least significant bit to record whether we have
+ already generated the necessary reloc. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_32 (output_bfd, relocation,
+ htab->sgot->contents + off);
+
+ if (info->shared)
+ {
+ asection *srelgot;
+ Elf_Internal_Rela outrel;
+ Elf32_External_Rela *loc;
+
+ srelgot = htab->srelgot;
+ if (srelgot == NULL)
+ abort ();
+
+ outrel.r_offset = (htab->sgot->output_section->vma
+ + htab->sgot->output_offset
+ + off);
+ outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
+ outrel.r_addend = relocation;
+ loc = (Elf32_External_Rela *) srelgot->contents;
+ loc += srelgot->reloc_count++;
+ bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+ }
+
+ local_got_offsets[r_symndx] |= 1;
+ }
+ }
+
+ if (off >= (bfd_vma) -2)
+ abort ();
+
+ relocation = htab->sgot->output_offset + off;
+
+ /*
+ * For @GOTENT the relocation is against the offset between
+ * the instruction and the symbols entry in the GOT and not
+ * between the start of the GOT and the symbols entry. We
+ * add the vma of the GOT to get the correct value.
+ */
+ if (r_type == R_390_GOTENT)
+ relocation += htab->sgot->output_section->vma;
+
+ break;
+
+ case R_390_GOTOFF:
+ /* Relocation is relative to the start of the global offset
+ table. */
+
+ /* Note that sgot->output_offset is not involved in this
+ calculation. We always want the start of .got. If we
+ defined _GLOBAL_OFFSET_TABLE in a different way, as is
+ permitted by the ABI, we might have to change this
+ calculation. */
+ relocation -= htab->sgot->output_section->vma;
+ break;
+
+ case R_390_GOTPC:
+ case R_390_GOTPCDBL:
+ /* Use global offset table as symbol value. */
+ relocation = htab->sgot->output_section->vma;
+ unresolved_reloc = false;
+ break;
+
+ case R_390_PLT16DBL:
+ case R_390_PLT32DBL:
+ case R_390_PLT32:
+ /* Relocation is to the entry for this symbol in the
+ procedure linkage table. */
+
+ /* Resolve a PLT32 reloc against a local symbol directly,
+ without using the procedure linkage table. */
+ if (h == NULL)
+ break;
+
+ if (h->plt.offset == (bfd_vma) -1
+ || htab->splt == NULL)
+ {
+ /* We didn't make a PLT entry for this symbol. This
+ happens when statically linking PIC code, or when
+ using -Bsymbolic. */
+ break;
+ }
+
+ relocation = (htab->splt->output_section->vma
+ + htab->splt->output_offset
+ + h->plt.offset);
+ unresolved_reloc = false;
+ break;
+
+ case R_390_8:
+ case R_390_16:
+ case R_390_32:
+ case R_390_PC16:
+ case R_390_PC16DBL:
+ case R_390_PC32DBL:
+ case R_390_PC32:
+ /* r_symndx will be zero only for relocs against symbols
+ from removed linkonce sections, or sections discarded by
+ a linker script. */
+ if (r_symndx == 0
+ || (input_section->flags & SEC_ALLOC) == 0)
+ break;
+
+ if ((info->shared
+ && ((r_type != R_390_PC16
+ && r_type != R_390_PC16DBL
+ && r_type != R_390_PC32DBL
+ && r_type != R_390_PC32)
+ || (h != NULL
+ && h->dynindx != -1
+ && (! info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+ || (!info->shared
+ && h != NULL
+ && h->dynindx != -1
+ && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
+ && (((h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ || h->root.type == bfd_link_hash_undefweak
+ || h->root.type == bfd_link_hash_undefined)))
+ {
+ Elf_Internal_Rela outrel;
+ boolean skip, relocate;
+ asection *sreloc;
+ Elf32_External_Rela *loc;
+
+ /* When generating a shared object, these relocations
+ are copied into the output file to be resolved at run
+ time. */
+
+ skip = false;
+ relocate = false;
+
+ outrel.r_offset =
+ _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset);
+ if (outrel.r_offset == (bfd_vma) -1)
+ skip = true;
+ else if (outrel.r_offset == (bfd_vma) -2)
+ skip = true, relocate = true;
+ outrel.r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+
+ if (skip)
+ memset (&outrel, 0, sizeof outrel);
+ else if (h != NULL
+ && h->dynindx != -1
+ && (r_type == R_390_PC16
+ || r_type == R_390_PC16DBL
+ || r_type == R_390_PC32DBL
+ || r_type == R_390_PC32
+ || !info->shared
+ || !info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))
+ {
+ outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
+ outrel.r_addend = rel->r_addend;
+ }
+ else
+ {
+ /* This symbol is local, or marked to become local. */
+ relocate = true;
+ outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
+ outrel.r_addend = relocation + rel->r_addend;
+ }
+
+ sreloc = elf_section_data (input_section)->sreloc;
+ if (sreloc == NULL)
+ abort ();
+
+ loc = (Elf32_External_Rela *) sreloc->contents;
+ loc += sreloc->reloc_count++;
+ bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+
+ /* If this reloc is against an external symbol, we do
+ not want to fiddle with the addend. Otherwise, we
+ need to include the symbol value so that it becomes
+ an addend for the dynamic reloc. */
+ if (! relocate)
+ continue;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (unresolved_reloc
+ && !(info->shared
+ && (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);
+
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, rel->r_addend);
+
+ if (r != bfd_reloc_ok)
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name);
+ if (name == NULL)
+ return false;
+ if (*name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+
+ if (r == bfd_reloc_overflow)
+ {
+
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_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);
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Finish up dynamic symbol handling. We set the contents of various
+ dynamic sections here. */
+
+static boolean
+elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ struct elf_s390_link_hash_table *htab;
+
+ htab = elf_s390_hash_table (info);
+
+ if (h->plt.offset != (bfd_vma) -1)
+ {
+ bfd_vma plt_index;
+ bfd_vma got_offset;
+ Elf_Internal_Rela rela;
+ Elf32_External_Rela *loc;
+ bfd_vma relative_offset;
+
+ /* This symbol has an entry in the procedure linkage table. Set
+ it up. */
+
+ if (h->dynindx == -1
+ || htab->splt == NULL
+ || htab->sgotplt == NULL
+ || htab->srelplt == NULL)
+ abort ();
+
+ /* Calc. index no.
+ Current offset - size first entry / entry size. */
+ plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) / PLT_ENTRY_SIZE;
+
+ /* Offset in GOT is PLT index plus GOT headers(3) times 4,
+ addr & GOT addr. */
+ got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
+
+ /* S390 uses halfwords for relative branch calc! */
+ relative_offset = - ((PLT_FIRST_ENTRY_SIZE +
+ (PLT_ENTRY_SIZE * plt_index) + 18) / 2);
+ /* If offset is > 32768, branch to a previous branch
+ 390 can only handle +-64 K jumps. */
+ if ( -32768 > (int) relative_offset )
+ relative_offset =
+ -(unsigned) (((65536 / PLT_ENTRY_SIZE - 1) * PLT_ENTRY_SIZE) / 2);
+
+ /* Fill in the entry in the procedure linkage table. */
+ if (!info->shared)
+ {
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD0,
+ htab->splt->contents + h->plt.offset);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD1,
+ htab->splt->contents + h->plt.offset + 4);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD2,
+ htab->splt->contents + h->plt.offset + 8);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD3,
+ htab->splt->contents + h->plt.offset + 12);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD4,
+ htab->splt->contents + h->plt.offset + 16);
+ bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+ htab->splt->contents + h->plt.offset + 20);
+ bfd_put_32 (output_bfd,
+ (htab->sgotplt->output_section->vma
+ + htab->sgotplt->output_offset
+ + got_offset),
+ htab->splt->contents + h->plt.offset + 24);
+ }
+ else if (got_offset < 4096)
+ {
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD0 + got_offset,
+ htab->splt->contents + h->plt.offset);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD1,
+ htab->splt->contents + h->plt.offset + 4);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD2,
+ htab->splt->contents + h->plt.offset + 8);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD3,
+ htab->splt->contents + h->plt.offset + 12);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD4,
+ htab->splt->contents + h->plt.offset + 16);
+ bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+ htab->splt->contents + h->plt.offset + 20);
+ bfd_put_32 (output_bfd, (bfd_vma) 0,
+ htab->splt->contents + h->plt.offset + 24);
+ }
+ else if (got_offset < 32768)
+ {
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD0 + got_offset,
+ htab->splt->contents + h->plt.offset);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD1,
+ htab->splt->contents + h->plt.offset + 4);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD2,
+ htab->splt->contents + h->plt.offset + 8);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD3,
+ htab->splt->contents + h->plt.offset + 12);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD4,
+ htab->splt->contents + h->plt.offset + 16);
+ bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+ htab->splt->contents + h->plt.offset + 20);
+ bfd_put_32 (output_bfd, (bfd_vma) 0,
+ htab->splt->contents + h->plt.offset + 24);
+ }
+ else
+ {
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD0,
+ htab->splt->contents + h->plt.offset);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD1,
+ htab->splt->contents + h->plt.offset + 4);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD2,
+ htab->splt->contents + h->plt.offset + 8);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD3,
+ htab->splt->contents + h->plt.offset + 12);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD4,
+ htab->splt->contents + h->plt.offset + 16);
+ bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+ htab->splt->contents + h->plt.offset + 20);
+ bfd_put_32 (output_bfd, got_offset,
+ htab->splt->contents + h->plt.offset + 24);
+ }
+ /* Insert offset into reloc. table here. */
+ bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela),
+ htab->splt->contents + h->plt.offset + 28);
+
+ /* Fill in the entry in the global offset table.
+ Points to instruction after GOT offset. */
+ bfd_put_32 (output_bfd,
+ (htab->splt->output_section->vma
+ + htab->splt->output_offset
+ + h->plt.offset
+ + 12),
+ htab->sgotplt->contents + got_offset);
+
+ /* Fill in the entry in the .rela.plt section. */
+ rela.r_offset = (htab->sgotplt->output_section->vma
+ + htab->sgotplt->output_offset
+ + got_offset);
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_390_JMP_SLOT);
+ rela.r_addend = 0;
+ loc = (Elf32_External_Rela *) htab->srelplt->contents + plt_index;
+ bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ /* Mark the symbol as undefined, rather than as defined in
+ 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. */
+ sym->st_shndx = SHN_UNDEF;
+ }
+ }
+
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ Elf_Internal_Rela rela;
+ Elf32_External_Rela *loc;
+
+ /* This symbol has an entry in the global offset table. Set it
+ up. */
+
+ if (htab->sgot == NULL || htab->srelgot == NULL)
+ abort ();
+
+ rela.r_offset = (htab->sgot->output_section->vma
+ + htab->sgot->output_offset
+ + (h->got.offset &~ (bfd_vma) 1));
+
+ /* If this is a static link, or it is a -Bsymbolic link and the
+ symbol is defined locally or was forced to be local because
+ of a version file, we just want to emit a RELATIVE reloc.
+ The entry in the global offset table will already have been
+ initialized in the relocate_section function. */
+ if (info->shared
+ && (info->symbolic
+ || h->dynindx == -1
+ || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+ {
+ BFD_ASSERT((h->got.offset & 1) != 0);
+ rela.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
+ rela.r_addend = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ }
+ else
+ {
+ BFD_ASSERT((h->got.offset & 1) == 0);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgot->contents + h->got.offset);
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_390_GLOB_DAT);
+ rela.r_addend = 0;
+ }
+
+ loc = (Elf32_External_Rela *) htab->srelgot->contents;
+ loc += htab->srelgot->reloc_count++;
+ bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
+ }
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
+ {
+ Elf_Internal_Rela rela;
+ Elf32_External_Rela *loc;
+
+ /* This symbols needs a copy reloc. Set it up. */
+
+ if (h->dynindx == -1
+ || (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
+ || htab->srelbss == NULL)
+ abort ();
+
+ rela.r_offset = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ rela.r_info = ELF32_R_INFO (h->dynindx, R_390_COPY);
+ rela.r_addend = 0;
+ loc = (Elf32_External_Rela *) htab->srelbss->contents;
+ loc += htab->srelbss->reloc_count++;
+ bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
+ }
+
+ /* Mark some specially defined symbols as absolute. */
+ if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+ || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
+ || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
+ sym->st_shndx = SHN_ABS;
+
+ return true;
+}
+
+/* Used to decide how to sort relocs in an optimal manner for the
+ dynamic linker, before writing them out. */
+
+static enum elf_reloc_type_class
+elf_s390_reloc_type_class (rela)
+ const Elf_Internal_Rela *rela;
+{
+ switch ((int) ELF32_R_TYPE (rela->r_info))
+ {
+ case R_390_RELATIVE:
+ return reloc_class_relative;
+ case R_390_JMP_SLOT:
+ return reloc_class_plt;
+ case R_390_COPY:
+ return reloc_class_copy;
+ default:
+ return reloc_class_normal;
+ }
+}
+
+/* Finish up the dynamic sections. */
+
+static boolean
+elf_s390_finish_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ struct elf_s390_link_hash_table *htab;
+ bfd *dynobj;
+ asection *sdyn;
+
+ htab = elf_s390_hash_table (info);
+ dynobj = htab->elf.dynobj;
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ if (htab->elf.dynamic_sections_created)
+ {
+ Elf32_External_Dyn *dyncon, *dynconend;
+
+ if (sdyn == NULL || htab->sgot == NULL)
+ abort ();
+
+ dyncon = (Elf32_External_Dyn *) sdyn->contents;
+ dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+ asection *s;
+
+ bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
+
+ switch (dyn.d_tag)
+ {
+ default:
+ continue;
+
+ case DT_PLTGOT:
+ dyn.d_un.d_ptr = htab->sgot->output_section->vma;
+ break;
+
+ case DT_JMPREL:
+ dyn.d_un.d_ptr = htab->srelplt->output_section->vma;
+ break;
+
+ case DT_PLTRELSZ:
+ s = htab->srelplt->output_section;
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val = s->_cooked_size;
+ else
+ dyn.d_un.d_val = s->_raw_size;
+ break;
+ }
+
+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+ }
+
+ /* Fill in the special first entry in the procedure linkage table. */
+ if (htab->splt && htab->splt->_raw_size > 0)
+ {
+ memset (htab->splt->contents, 0, PLT_FIRST_ENTRY_SIZE);
+ if (info->shared)
+ {
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD0,
+ htab->splt->contents );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD1,
+ htab->splt->contents +4 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD2,
+ htab->splt->contents +8 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD3,
+ htab->splt->contents +12 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD4,
+ htab->splt->contents +16 );
+ }
+ else
+ {
+ bfd_put_32 (output_bfd, (bfd_vma)PLT_FIRST_ENTRY_WORD0,
+ htab->splt->contents );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD1,
+ htab->splt->contents +4 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD2,
+ htab->splt->contents +8 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD3,
+ htab->splt->contents +12 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD4,
+ htab->splt->contents +16 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD5,
+ htab->splt->contents +20 );
+ bfd_put_32 (output_bfd,
+ htab->sgotplt->output_section->vma
+ + htab->sgotplt->output_offset,
+ htab->splt->contents + 24);
+ }
+ elf_section_data (htab->splt->output_section)
+ ->this_hdr.sh_entsize = 4;
+ }
+
+ }
+
+ if (htab->sgotplt)
+ {
+ /* Fill in the first three entries in the global offset table. */
+ if (htab->sgotplt->_raw_size > 0)
+ {
+ bfd_put_32 (output_bfd,
+ (sdyn == NULL ? (bfd_vma) 0
+ : sdyn->output_section->vma + sdyn->output_offset),
+ htab->sgotplt->contents);
+ /* One entry for shared object struct ptr. */
+ bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 4);
+ /* One entry for _dl_runtime_resolve. */
+ bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 8);
+ }
+
+ elf_section_data (htab->sgotplt->output_section)
+ ->this_hdr.sh_entsize = 4;
+ }
+ return true;
+}
+
+static boolean
+elf_s390_object_p (abfd)
+ bfd *abfd;
+{
+ return bfd_default_set_arch_mach (abfd, bfd_arch_s390, bfd_mach_s390_31);
+}
+
+static boolean
+elf_s390_grok_prstatus (abfd, note)
+ bfd * abfd;
+ Elf_Internal_Note * note;
+{
+ int offset;
+ unsigned int raw_size;
+
+ switch (note->descsz)
+ {
+ default:
+ return false;
+
+ case 224: /* S/390 Linux. */
+ /* 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 + 24);
+
+ /* pr_reg */
+ offset = 72;
+ raw_size = 144;
+ break;
+ }
+
+ /* Make a ".reg/999" section. */
+ return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+ raw_size, note->descpos + offset);
+}
+
+#define TARGET_BIG_SYM bfd_elf32_s390_vec
+#define TARGET_BIG_NAME "elf32-s390"
+#define ELF_ARCH bfd_arch_s390
+#define ELF_MACHINE_CODE EM_S390
+#define ELF_MACHINE_ALT1 EM_S390_OLD
+#define ELF_MAXPAGESIZE 0x1000
+
+#define elf_backend_can_gc_sections 1
+#define elf_backend_can_refcount 1
+#define elf_backend_want_got_plt 1
+#define elf_backend_plt_readonly 1
+#define elf_backend_want_plt_sym 0
+#define elf_backend_got_header_size 12
+#define elf_backend_plt_header_size PLT_ENTRY_SIZE
+#define elf_backend_rela_normal 1
+
+#define elf_info_to_howto elf_s390_info_to_howto
+
+#define bfd_elf32_bfd_is_local_label_name elf_s390_is_local_label_name
+#define bfd_elf32_bfd_link_hash_table_create elf_s390_link_hash_table_create
+#define bfd_elf32_bfd_reloc_type_lookup elf_s390_reloc_type_lookup
+
+#define elf_backend_adjust_dynamic_symbol elf_s390_adjust_dynamic_symbol
+#define elf_backend_check_relocs elf_s390_check_relocs
+#define elf_backend_copy_indirect_symbol elf_s390_copy_indirect_symbol
+#define elf_backend_create_dynamic_sections elf_s390_create_dynamic_sections
+#define elf_backend_finish_dynamic_sections elf_s390_finish_dynamic_sections
+#define elf_backend_finish_dynamic_symbol elf_s390_finish_dynamic_symbol
+#define elf_backend_gc_mark_hook elf_s390_gc_mark_hook
+#define elf_backend_gc_sweep_hook elf_s390_gc_sweep_hook
+#define elf_backend_reloc_type_class elf_s390_reloc_type_class
+#define elf_backend_relocate_section elf_s390_relocate_section
+#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
+#define elf_backend_reloc_type_class elf_s390_reloc_type_class
+#define elf_backend_grok_prstatus elf_s390_grok_prstatus
+
+#define elf_backend_object_p elf_s390_object_p
+
+#include "elf32-target.h"
diff --git a/contrib/binutils/bfd/elf64-alpha.c b/contrib/binutils/bfd/elf64-alpha.c
index 550de53..faf9944 100644
--- a/contrib/binutils/bfd/elf64-alpha.c
+++ b/contrib/binutils/bfd/elf64-alpha.c
@@ -3695,6 +3695,16 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
}
goto default_reloc;
+ case R_ALPHA_SREL32:
+ case R_ALPHA_SREL64:
+ /* ??? .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. */
+ if (r_symndx == 0)
+ howto = (elf64_alpha_howto_table
+ + (r_type - R_ALPHA_SREL32 + R_ALPHA_REFLONG));
+ goto default_reloc;
+
default:
default_reloc:
r = _bfd_final_link_relocate (howto, input_bfd, input_section,
diff --git a/contrib/binutils/bfd/elf64-ppc.c b/contrib/binutils/bfd/elf64-ppc.c
index 6adc202..d25c25f 100644
--- a/contrib/binutils/bfd/elf64-ppc.c
+++ b/contrib/binutils/bfd/elf64-ppc.c
@@ -39,7 +39,21 @@ static reloc_howto_type *ppc64_elf_reloc_type_lookup
PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
static void ppc64_elf_info_to_howto
PARAMS ((bfd *abfd, arelent *cache_ptr, Elf64_Internal_Rela *dst));
-static bfd_reloc_status_type ppc64_elf_addr16_ha_reloc
+static bfd_reloc_status_type ppc64_elf_ha_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_brtaken_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_sectoff_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_sectoff_ha_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_toc_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_toc_ha_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+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));
@@ -101,12 +115,6 @@ static boolean ppc64_elf_finish_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
-/* Mask to set RA in memory instructions. */
-#define RA_REGISTER_MASK 0x001f0000
-
-/* Value to shift register by to insert RA. */
-#define RA_REGISTER_SHIFT 16
-
/* The name of the dynamic interpreter. This is put in the .interp
section. */
#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
@@ -146,6 +154,10 @@ static boolean ppc64_elf_finish_dynamic_sections
/* Pad with this. */
#define NOP 0x60000000
+/* Some other nops. */
+#define CROR_151515 0x4def7b82
+#define CROR_313131 0x4ffffb82
+
/* .glink entries for the first 32k functions are two instructions. */
#define LI_R0_0 0x38000000 /* li %r0,0 */
#define B_DOT 0x48000000 /* b . */
@@ -273,7 +285,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- ppc64_elf_addr16_ha_reloc, /* special_function */
+ ppc64_elf_ha_reloc, /* special_function */
"R_PPC64_ADDR16_HA", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -306,7 +318,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_brtaken_reloc, /* special_function */
"R_PPC64_ADDR14_BRTAKEN",/* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -323,7 +335,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_brtaken_reloc, /* special_function */
"R_PPC64_ADDR14_BRNTAKEN",/* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -370,7 +382,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
true, /* pc_relative */
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_brtaken_reloc, /* special_function */
"R_PPC64_REL14_BRTAKEN", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -387,7 +399,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
true, /* pc_relative */
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_brtaken_reloc, /* special_function */
"R_PPC64_REL14_BRNTAKEN",/* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -403,7 +415,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_GOT16", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -419,7 +431,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_GOT16_LO", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -435,7 +447,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont,/* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_GOT16_HI", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -451,7 +463,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont,/* complain_on_overflow */
- ppc64_elf_addr16_ha_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_GOT16_HA", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -470,7 +482,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_COPY", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -486,7 +498,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_GLOB_DAT", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -502,7 +514,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_JMP_SLOT", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -580,7 +592,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLT32", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -612,7 +624,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLT16_LO", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -628,7 +640,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLT16_HI", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -644,31 +656,29 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- ppc64_elf_addr16_ha_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLT16_HA", /* name */
false, /* partial_inplace */
0, /* src_mask */
0xffff, /* dst_mask */
false), /* pcrel_offset */
- /* 32-bit section relative relocation. */
- /* FIXME: Verify R_PPC64_SECTOFF. Seems strange with size=2 and
- dst_mask=0. */
+ /* 16-bit section relative relocation. */
HOWTO (R_PPC64_SECTOFF, /* type */
0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_sectoff_reloc, /* special_function */
"R_PPC64_SECTOFF", /* name */
false, /* partial_inplace */
0, /* src_mask */
- 0, /* dst_mask */
- true), /* pcrel_offset */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
- /* 16-bit lower half section relative relocation. */
+ /* Like R_PPC64_SECTOFF, but no overflow warning. */
HOWTO (R_PPC64_SECTOFF_LO, /* type */
0, /* rightshift */
1, /* size (0 = byte, 1 = short, 2 = long) */
@@ -676,7 +686,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_sectoff_reloc, /* special_function */
"R_PPC64_SECTOFF_LO", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -691,7 +701,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_sectoff_reloc, /* special_function */
"R_PPC64_SECTOFF_HI", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -706,7 +716,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- ppc64_elf_addr16_ha_reloc, /* special_function */
+ ppc64_elf_sectoff_ha_reloc, /* special_function */
"R_PPC64_SECTOFF_HA", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -714,8 +724,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false), /* pcrel_offset */
/* Like R_PPC64_REL24 without touching the two least significant
- bits. */
- /* FIXME: Verify R_PPC64_ADDR30. */
+ bits. Should have been named R_PPC64_REL30! */
HOWTO (R_PPC64_ADDR30, /* type */
2, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
@@ -771,7 +780,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- ppc64_elf_addr16_ha_reloc, /* special_function */
+ ppc64_elf_ha_reloc, /* special_function */
"R_PPC64_ADDR16_HIGHERA", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -802,7 +811,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- ppc64_elf_addr16_ha_reloc, /* special_function */
+ ppc64_elf_ha_reloc, /* special_function */
"R_PPC64_ADDR16_HIGHESTA", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -847,7 +856,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLT64", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -864,7 +873,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
true, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLTREL64", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -881,7 +890,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_toc_reloc, /* special_function */
"R_PPC64_TOC16", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -898,7 +907,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_toc_reloc, /* special_function */
"R_PPC64_TOC16_LO", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -915,7 +924,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_toc_reloc, /* special_function */
"R_PPC64_TOC16_HI", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -934,7 +943,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- ppc64_elf_addr16_ha_reloc, /* special_function */
+ ppc64_elf_toc_ha_reloc, /* special_function */
"R_PPC64_TOC16_HA", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -951,7 +960,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_toc64_reloc, /* special_function */
"R_PPC64_TOC", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -974,7 +983,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLTGOT16", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -990,7 +999,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLTGOT16_LO", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -1006,7 +1015,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLTGOT16_HI", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -1024,7 +1033,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont,/* complain_on_overflow */
- ppc64_elf_addr16_ha_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLTGOT16_HA", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -1069,7 +1078,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_GOT16_DS", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -1084,7 +1093,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_GOT16_LO_DS", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -1099,7 +1108,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLT16_LO_DS", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -1107,21 +1116,19 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false), /* pcrel_offset */
/* Like R_PPC64_SECTOFF, but for instructions with a DS field. */
- /* FIXME: Verify R_PPC64_SECTOFF. Seems strange with size=2 and
- dst_mask=0. */
HOWTO (R_PPC64_SECTOFF_DS, /* type */
0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_sectoff_reloc, /* special_function */
"R_PPC64_SECTOFF_DS", /* name */
false, /* partial_inplace */
0, /* src_mask */
- 0, /* dst_mask */
- true), /* pcrel_offset */
+ 0xfffc, /* dst_mask */
+ false), /* pcrel_offset */
/* Like R_PPC64_SECTOFF_LO, but for instructions with a DS field. */
HOWTO (R_PPC64_SECTOFF_LO_DS, /* type */
@@ -1131,7 +1138,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_sectoff_reloc, /* special_function */
"R_PPC64_SECTOFF_LO_DS",/* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -1146,7 +1153,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_toc_reloc, /* special_function */
"R_PPC64_TOC16_DS", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -1161,7 +1168,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_toc_reloc, /* special_function */
"R_PPC64_TOC16_LO_DS", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -1177,7 +1184,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLTGOT16_DS", /* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -1193,7 +1200,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
+ ppc64_elf_unhandled_reloc, /* special_function */
"R_PPC64_PLTGOT16_LO_DS",/* name */
false, /* partial_inplace */
0, /* src_mask */
@@ -1319,7 +1326,7 @@ ppc64_elf_reloc_type_lookup (abfd, code)
break;
case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC64_PLT16_HA;
break;
- case BFD_RELOC_32_BASEREL: ppc_reloc = R_PPC64_SECTOFF;
+ case BFD_RELOC_16_BASEREL: ppc_reloc = R_PPC64_SECTOFF;
break;
case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC64_SECTOFF_LO;
break;
@@ -1417,41 +1424,265 @@ ppc64_elf_info_to_howto (abfd, cache_ptr, dst)
/* Handle the R_PPC_ADDR16_HA and similar relocs. */
static bfd_reloc_status_type
-ppc64_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd ATTRIBUTE_UNUSED;
+ppc64_elf_ha_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* If this is a relocatable link (output_bfd test tells us), just
+ 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,
+ input_section, output_bfd, error_message);
+
+ /* Adjust the addend for sign extension of the low 16 bits.
+ We won't actually be using the low 16 bits, so trashing them
+ doesn't matter. */
+ reloc_entry->addend += 0x8000;
+ return bfd_reloc_continue;
+}
+
+static bfd_reloc_status_type
+ppc64_elf_brtaken_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
arelent *reloc_entry;
asymbol *symbol;
- PTR data ATTRIBUTE_UNUSED;
+ PTR data;
asection *input_section;
bfd *output_bfd;
- char **error_message ATTRIBUTE_UNUSED;
+ char **error_message;
{
- bfd_vma relocation;
+ long insn;
+ enum elf_ppc_reloc_type r_type;
+ bfd_size_type octets;
+ /* Disabled until we sort out how ld should choose 'y' vs 'at'. */
+ boolean is_power4 = false;
+ /* If this is a relocatable link (output_bfd test tells us), just
+ 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,
+ input_section, output_bfd, error_message);
+
+ octets = reloc_entry->address * bfd_octets_per_byte (abfd);
+ insn = bfd_get_32 (abfd, (bfd_byte *) data + octets);
+ insn &= ~(0x01 << 21);
+ 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. */
+
+ if (is_power4)
+ {
+ /* Set 'a' bit. This is 0b00010 in BO field for branch
+ on CR(BI) insns (BO == 001at or 011at), and 0b01000
+ for branch on CTR insns (BO == 1a00t or 1a01t). */
+ if ((insn & (0x14 << 21)) == (0x04 << 21))
+ insn |= 0x02 << 21;
+ else if ((insn & (0x14 << 21)) == (0x10 << 21))
+ insn |= 0x08 << 21;
+ else
+ return bfd_reloc_continue;
+ }
+ else
{
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
+ bfd_vma target = 0;
+ bfd_vma from;
+
+ if (!bfd_is_com_section (symbol->section))
+ target = symbol->value;
+ target += symbol->section->output_section->vma;
+ target += symbol->section->output_offset;
+ target += reloc_entry->addend;
+
+ from = (reloc_entry->address
+ + input_section->output_offset
+ + input_section->output_section->vma);
+
+ /* Invert 'y' bit if not the default. */
+ if ((bfd_signed_vma) (target - from) < 0)
+ insn ^= 0x01 << 21;
}
+ bfd_put_32 (abfd, (bfd_vma) insn, (bfd_byte *) data + octets);
+ return bfd_reloc_continue;
+}
+
+static bfd_reloc_status_type
+ppc64_elf_sectoff_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* If this is a relocatable link (output_bfd test tells us), just
+ 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,
+ input_section, output_bfd, error_message);
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
+ /* Subtract the symbol section base address. */
+ reloc_entry->addend -= symbol->section->output_section->vma;
+ return bfd_reloc_continue;
+}
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
+static bfd_reloc_status_type
+ppc64_elf_sectoff_ha_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* If this is a relocatable link (output_bfd test tells us), just
+ 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,
+ input_section, output_bfd, error_message);
+
+ /* Subtract the symbol section base address. */
+ reloc_entry->addend -= symbol->section->output_section->vma;
+
+ /* Adjust the addend for sign extension of the low 16 bits. */
+ reloc_entry->addend += 0x8000;
+ return bfd_reloc_continue;
+}
+
+static bfd_reloc_status_type
+ppc64_elf_toc_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma TOCstart;
+
+ /* If this is a relocatable link (output_bfd test tells us), just
+ 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,
+ input_section, output_bfd, error_message);
+
+ TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
+ if (TOCstart == 0)
+ TOCstart = ppc64_elf_toc (input_section->output_section->owner);
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += reloc_entry->addend;
+ /* Subtract the TOC base address. */
+ reloc_entry->addend -= TOCstart + TOC_BASE_OFF;
+ return bfd_reloc_continue;
+}
+
+static bfd_reloc_status_type
+ppc64_elf_toc_ha_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma TOCstart;
+
+ /* If this is a relocatable link (output_bfd test tells us), just
+ 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,
+ input_section, output_bfd, error_message);
+
+ TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
+ if (TOCstart == 0)
+ TOCstart = ppc64_elf_toc (input_section->output_section->owner);
- reloc_entry->addend += (relocation & 0x8000) << 1;
+ /* Subtract the TOC base address. */
+ reloc_entry->addend -= TOCstart + TOC_BASE_OFF;
+ /* Adjust the addend for sign extension of the low 16 bits. */
+ reloc_entry->addend += 0x8000;
return bfd_reloc_continue;
}
+static bfd_reloc_status_type
+ppc64_elf_toc64_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma TOCstart;
+ bfd_size_type octets;
+
+ /* If this is a relocatable link (output_bfd test tells us), just
+ 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,
+ input_section, output_bfd, error_message);
+
+ TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
+ if (TOCstart == 0)
+ TOCstart = ppc64_elf_toc (input_section->output_section->owner);
+
+ octets = reloc_entry->address * bfd_octets_per_byte (abfd);
+ bfd_put_64 (abfd, TOCstart + TOC_BASE_OFF, (bfd_byte *) data + octets);
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+ppc64_elf_unhandled_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* If this is a relocatable link (output_bfd test tells us), just
+ 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,
+ input_section, output_bfd, error_message);
+
+ if (error_message != NULL)
+ {
+ static char buf[60];
+ sprintf (buf, "generic linker can't handle %s",
+ reloc_entry->howto->name);
+ *error_message = buf;
+ }
+ return bfd_reloc_dangerous;
+}
+
/* Function to set whether a module needs the -mrelocatable bit set. */
static boolean
@@ -1731,6 +1962,9 @@ struct ppc_link_hash_table
/* Set on error. */
int plt_overflow;
+ /* Set if we detect a reference undefined weak symbol. */
+ unsigned int have_undefweak;
+
/* Small local sym to section mapping cache. */
struct sym_sec_cache sym_sec;
};
@@ -1800,6 +2034,7 @@ ppc64_elf_link_hash_table_create (abfd)
htab->sglink = NULL;
htab->sfpr = NULL;
htab->plt_overflow = 0;
+ htab->have_undefweak = 0;
htab->sym_sec.abfd = NULL;
return &htab->elf.root;
@@ -2515,6 +2750,10 @@ func_desc_adjust (h, inf)
if (!((struct ppc_link_hash_entry *) h)->is_func)
return true;
+ if (h->root.type == bfd_link_hash_undefweak
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR))
+ htab->have_undefweak = true;
+
if (h->plt.refcount > 0
&& h->root.root.string[0] == '.'
&& h->root.root.string[1] != '\0')
@@ -2610,6 +2849,7 @@ ppc64_elf_func_desc_adjust (obfd, info)
unsigned int lowest_restf = MAX_SAVE_FPR + 2;
unsigned int i;
struct elf_link_hash_entry *h;
+ bfd_byte *p;
char sym[10];
htab = ppc_hash_table (info);
@@ -2660,41 +2900,52 @@ ppc64_elf_func_desc_adjust (obfd, info)
}
}
+ elf_link_hash_traverse (&htab->elf, func_desc_adjust, (PTR) info);
+
htab->sfpr->_raw_size = ((MAX_SAVE_FPR + 2 - lowest_savef) * 4
+ (MAX_SAVE_FPR + 2 - lowest_restf) * 4);
if (htab->sfpr->_raw_size == 0)
{
- _bfd_strip_section_from_output (info, htab->sfpr);
- }
- else
- {
- bfd_byte *p = (bfd_byte *) bfd_alloc (htab->elf.dynobj,
- htab->sfpr->_raw_size);
- if (p == NULL)
- return false;
- htab->sfpr->contents = p;
-
- for (i = lowest_savef; i <= MAX_SAVE_FPR; i++)
+ if (!htab->have_undefweak)
{
- unsigned int fpr = i << 21;
- unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8;
- bfd_put_32 (htab->elf.dynobj, STFD_FR0_0R1 + fpr + stackoff, p);
- p += 4;
+ _bfd_strip_section_from_output (info, htab->sfpr);
+ return true;
}
+
+ htab->sfpr->_raw_size = 4;
+ }
+
+ p = (bfd_byte *) bfd_alloc (htab->elf.dynobj, htab->sfpr->_raw_size);
+ if (p == NULL)
+ return false;
+ htab->sfpr->contents = p;
+
+ for (i = lowest_savef; i <= MAX_SAVE_FPR; i++)
+ {
+ unsigned int fpr = i << 21;
+ unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8;
+ bfd_put_32 (htab->elf.dynobj, STFD_FR0_0R1 + fpr + stackoff, p);
+ p += 4;
+ }
+ if (lowest_savef <= MAX_SAVE_FPR)
+ {
bfd_put_32 (htab->elf.dynobj, BLR, p);
p += 4;
+ }
- for (i = lowest_restf; i <= MAX_SAVE_FPR; i++)
- {
- unsigned int fpr = i << 21;
- unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8;
- bfd_put_32 (htab->elf.dynobj, LFD_FR0_0R1 + fpr + stackoff, p);
- p += 4;
- }
- bfd_put_32 (htab->elf.dynobj, BLR, p);
+ for (i = lowest_restf; i <= MAX_SAVE_FPR; i++)
+ {
+ unsigned int fpr = i << 21;
+ unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8;
+ bfd_put_32 (htab->elf.dynobj, LFD_FR0_0R1 + fpr + stackoff, p);
p += 4;
}
+ if (lowest_restf <= MAX_SAVE_FPR
+ || htab->sfpr->_raw_size == 4)
+ {
+ bfd_put_32 (htab->elf.dynobj, BLR, p);
+ }
elf_link_hash_traverse (&htab->elf, func_desc_adjust, (PTR) info);
return true;
@@ -3285,69 +3536,61 @@ ppc64_elf_size_dynamic_sections (output_bfd, info)
return true;
}
-/* Called after we have seen all the input files/sections, but before
- final symbol resolution and section placement has been determined.
+/* Called after we have determined section placement. If sections
+ move, we'll be called again. Provide a value for TOCstart. */
- We use this hook to provide a value for TOCstart, which we store in
- the output bfd elf_gp. */
-
-boolean
-ppc64_elf_set_toc (obfd, info)
+bfd_vma
+ppc64_elf_toc (obfd)
bfd *obfd;
- struct bfd_link_info *info;
{
- if (!info->relocateable)
- {
- asection *s;
- bfd_vma TOCstart;
+ 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");
+ /* 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)
- s = bfd_get_section_by_name (obfd, ".tocbss");
+ 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)
- s = bfd_get_section_by_name (obfd, ".plt");
+ for (s = obfd->sections; s != NULL; s = s->next)
+ if ((s->flags & (SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC)
+ break;
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;
- }
+ 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;
+ TOCstart = 0;
+ if (s != NULL)
+ TOCstart = s->output_section->vma + s->output_offset;
- elf_gp (obfd) = TOCstart;
- }
- return true;
+ return TOCstart;
}
/* PowerPC64 .plt entries are 24 bytes long, which doesn't divide
@@ -3642,6 +3885,9 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
/* Disabled until we sort out how ld should choose 'y' vs 'at'. */
boolean is_power4 = false;
+ if (info->relocateable)
+ return true;
+
/* Initialize howto table if needed. */
if (!ppc64_elf_howto_table[R_PPC64_ADDR32])
ppc_howto_init ();
@@ -3668,32 +3914,11 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
unsigned long r_symndx;
bfd_vma relocation;
boolean unresolved_reloc;
- boolean has_nop;
long insn;
+ bfd_vma from;
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
r_symndx = ELF64_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* 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 ((unsigned) ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
- continue;
- }
-
- /* This is a final link. */
-
offset = rel->r_offset;
addend = rel->r_addend;
r = bfd_reloc_other;
@@ -3716,6 +3941,7 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
sym_name = "<local symbol>";
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+ /* rel may have changed, update our copy of addend. */
addend = rel->r_addend;
}
else
@@ -3791,8 +4017,12 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
}
else
{
+ from = (offset
+ + input_section->output_offset
+ + input_section->output_section->vma);
+
/* Invert 'y' bit if not the default. */
- if ((bfd_signed_vma) (relocation - offset) < 0)
+ if ((bfd_signed_vma) (relocation + addend - from) < 0)
insn ^= 0x01 << 21;
}
@@ -3800,57 +4030,71 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
break;
case R_PPC64_REL24:
- case R_PPC64_ADDR24:
- /* An ADDR24 or REL24 branching to a linkage function may be
- followed by a nop that we have to replace with a ld in
- order to restore the TOC base pointer. Only calls to
- shared objects need to alter the TOC base. These are
- recognized by their need for a PLT entry. */
- has_nop = 0;
+ /* A REL24 branching to a linkage function is followed by a
+ nop. We replace the nop with a ld in order to restore
+ the TOC base pointer. Only calls to shared objects need
+ 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)
{
- /* plt.offset here is the offset into the stub section. */
- relocation = (htab->sstub->output_section->vma
- + htab->sstub->output_offset
- + h->plt.offset);
- unresolved_reloc = false;
-
- /* Make sure that there really is an instruction after
- the branch that we can decode. */
+ boolean can_plt_call = 0;
+
if (offset + 8 <= input_section->_cooked_size)
{
- bfd_byte *pnext;
-
- pnext = contents + offset + 4;
- insn = bfd_get_32 (input_bfd, pnext);
-
- if (insn == 0x60000000 /* nop (ori r0,r0,0) */
- || insn == 0x4def7b82 /* cror 15,15,15 */
- || insn == 0x4ffffb82) /* cror 31,31,31 */
+ insn = bfd_get_32 (input_bfd, contents + offset + 4);
+ if (insn == NOP
+ || insn == CROR_151515 || insn == CROR_313131)
{
- bfd_put_32 (input_bfd,
- (bfd_vma) 0xe8410028, /* ld r2,40(r1) */
- pnext);
- has_nop = 1;
+ bfd_put_32 (input_bfd, (bfd_vma) LD_R2_40R1,
+ contents + offset + 4);
+ can_plt_call = 1;
}
}
+
+ if (!can_plt_call)
+ {
+ /* If this is a plain branch rather than a branch
+ and link, don't require a nop. */
+ insn = bfd_get_32 (input_bfd, contents + offset);
+ if ((insn & 1) == 0)
+ can_plt_call = 1;
+ }
+
+ 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);
+ addend = 0;
+ unresolved_reloc = false;
+ }
}
if (h != NULL
&& h->root.type == bfd_link_hash_undefweak
- && r_type == R_PPC64_REL24
- && addend == 0
- && relocation == 0)
+ && relocation == 0
+ && addend == 0)
{
- /* Tweak calls to undefined weak functions to behave as
- if the "called" function immediately returns. We can
- thus call to a weak function without first checking
- whether the function is defined. */
- relocation = 4;
- if (has_nop)
- relocation = 8;
+ /* Tweak calls to undefined weak functions to point at a
+ blr. We can thus call a weak function without first
+ checking whether the function is defined. We have a
+ blr at the end of .sfpr. */
+ BFD_ASSERT (htab->sfpr->_raw_size != 0);
+ relocation = (htab->sfpr->_raw_size - 4
+ + htab->sfpr->output_offset
+ + htab->sfpr->output_section->vma);
+ from = (offset
+ + input_section->output_offset
+ + input_section->output_section->vma);
+
+ /* But let's not be silly about it. If the blr isn't in
+ reach, just go to the next instruction. */
+ if (relocation - from + (1 << 25) >= (1 << 26)
+ || htab->sfpr->_raw_size == 0)
+ relocation = from + 4;
}
break;
}
@@ -4593,6 +4837,7 @@ ppc64_elf_finish_dynamic_sections (output_bfd, info)
#define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE
#define elf_backend_can_gc_sections 1
#define elf_backend_can_refcount 1
+#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
diff --git a/contrib/binutils/bfd/elf64-ppc.h b/contrib/binutils/bfd/elf64-ppc.h
index b261a58..beb637b 100644
--- a/contrib/binutils/bfd/elf64-ppc.h
+++ b/contrib/binutils/bfd/elf64-ppc.h
@@ -17,6 +17,6 @@ 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. */
-boolean ppc64_elf_set_toc PARAMS ((bfd *, struct bfd_link_info *));
+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 *));
diff --git a/contrib/binutils/bfd/elf64-s390.c b/contrib/binutils/bfd/elf64-s390.c
new file mode 100644
index 0000000..40f4908
--- /dev/null
+++ b/contrib/binutils/bfd/elf64-s390.c
@@ -0,0 +1,2392 @@
+/* IBM S/390-specific support for 64-bit ELF
+ Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
+ Contributed Martin Schwidefsky (schwidefsky@de.ibm.com).
+
+ 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 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. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+
+static reloc_howto_type *elf_s390_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+static void elf_s390_info_to_howto
+ PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
+static boolean elf_s390_is_local_label_name
+ PARAMS ((bfd *, 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 *elf_s390_link_hash_table_create
+ PARAMS ((bfd *));
+static boolean create_got_section
+ PARAMS((bfd *, struct bfd_link_info *));
+static boolean elf_s390_create_dynamic_sections
+ PARAMS((bfd *, struct bfd_link_info *));
+static void elf_s390_copy_indirect_symbol
+ PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
+static boolean elf_s390_check_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
+static asection *elf_s390_gc_mark_hook
+ PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
+ struct elf_link_hash_entry *, Elf_Internal_Sym *));
+static boolean elf_s390_gc_sweep_hook
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
+static boolean elf_s390_adjust_dynamic_symbol
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+static boolean allocate_dynrelocs
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean readonly_dynrelocs
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean elf_s390_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf_s390_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+static boolean elf_s390_finish_dynamic_symbol
+ PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
+ Elf_Internal_Sym *));
+static enum elf_reloc_type_class elf_s390_reloc_type_class
+ PARAMS ((const Elf_Internal_Rela *));
+static boolean elf_s390_finish_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+static boolean elf_s390_object_p PARAMS ((bfd *));
+
+#define USE_RELA 1 /* We want RELA relocations, not REL. */
+
+#include "elf/s390.h"
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
+ from smaller values. Start with zero, widen, *then* decrement. */
+#define MINUS_ONE (((bfd_vma)0) - 1)
+
+/* The relocation "howto" table. */
+static reloc_howto_type elf_howto_table[] =
+{
+ HOWTO (R_390_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_390_NONE", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO(R_390_8, 0, 0, 8, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_8", false, 0,0x000000ff, false),
+ HOWTO(R_390_12, 0, 1, 12, false, 0, complain_overflow_dont, bfd_elf_generic_reloc, "R_390_12", false, 0,0x00000fff, false),
+ HOWTO(R_390_16, 0, 1, 16, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_16", false, 0,0x0000ffff, false),
+ HOWTO(R_390_32, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_32", false, 0,0xffffffff, false),
+ HOWTO(R_390_PC32, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC32", false, 0,0xffffffff, true),
+ HOWTO(R_390_GOT12, 0, 1, 12, false, 0, complain_overflow_dont, bfd_elf_generic_reloc, "R_390_GOT12", false, 0,0x00000fff, false),
+ HOWTO(R_390_GOT32, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOT32", false, 0,0xffffffff, false),
+ HOWTO(R_390_PLT32, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PLT32", false, 0,0xffffffff, true),
+ HOWTO(R_390_COPY, 0, 4, 64, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_COPY", false, 0,MINUS_ONE, false),
+ HOWTO(R_390_GLOB_DAT, 0, 4, 64, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GLOB_DAT",false, 0,MINUS_ONE, false),
+ HOWTO(R_390_JMP_SLOT, 0, 4, 64, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_JMP_SLOT",false, 0,MINUS_ONE, false),
+ HOWTO(R_390_RELATIVE, 0, 4, 64, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_RELATIVE",false, 0,MINUS_ONE, false),
+ HOWTO(R_390_GOTOFF, 0, 4, 64, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTOFF", false, 0,MINUS_ONE, false),
+ HOWTO(R_390_GOTPC, 0, 4, 64, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTPC", false, 0,MINUS_ONE, true),
+ HOWTO(R_390_GOT16, 0, 1, 16, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOT16", false, 0,0x0000ffff, false),
+ HOWTO(R_390_PC16, 0, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC16", false, 0,0x0000ffff, true),
+ HOWTO(R_390_PC16DBL, 1, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC16DBL", false, 0,0x0000ffff, true),
+ HOWTO(R_390_PLT16DBL, 1, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PLT16DBL", false, 0,0x0000ffff, true),
+ HOWTO(R_390_PC32DBL, 1, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC32DBL", false, 0,0xffffffff, true),
+ HOWTO(R_390_PLT32DBL, 1, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PLT32DBL", false, 0,0xffffffff, true),
+ HOWTO(R_390_GOTPCDBL, 1, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTPCDBL", false, 0,MINUS_ONE, true),
+ HOWTO(R_390_64, 0, 4, 64, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_64", false, 0,MINUS_ONE, false),
+ HOWTO(R_390_PC64, 0, 4, 64, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC64", false, 0,MINUS_ONE, true),
+ HOWTO(R_390_GOT64, 0, 4, 64, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOT64", false, 0,MINUS_ONE, false),
+ HOWTO(R_390_PLT64, 0, 4, 64, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PLT64", false, 0,MINUS_ONE, true),
+ HOWTO(R_390_GOTENT, 1, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTENT", false, 0,MINUS_ONE, true),
+};
+
+/* GNU extension to record C++ vtable hierarchy. */
+static reloc_howto_type elf64_s390_vtinherit_howto =
+ HOWTO (R_390_GNU_VTINHERIT, 0,4,0,false,0,complain_overflow_dont, NULL, "R_390_GNU_VTINHERIT", false,0, 0, false);
+static reloc_howto_type elf64_s390_vtentry_howto =
+ HOWTO (R_390_GNU_VTENTRY, 0,4,0,false,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_390_GNU_VTENTRY", false,0,0, false);
+
+static reloc_howto_type *
+elf_s390_reloc_type_lookup (abfd, code)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ bfd_reloc_code_real_type code;
+{
+ switch (code)
+ {
+ case BFD_RELOC_NONE:
+ return &elf_howto_table[(int) R_390_NONE];
+ case BFD_RELOC_8:
+ return &elf_howto_table[(int) R_390_8];
+ case BFD_RELOC_390_12:
+ return &elf_howto_table[(int) R_390_12];
+ case BFD_RELOC_16:
+ return &elf_howto_table[(int) R_390_16];
+ case BFD_RELOC_32:
+ return &elf_howto_table[(int) R_390_32];
+ case BFD_RELOC_CTOR:
+ return &elf_howto_table[(int) R_390_32];
+ case BFD_RELOC_32_PCREL:
+ return &elf_howto_table[(int) R_390_PC32];
+ case BFD_RELOC_390_GOT12:
+ return &elf_howto_table[(int) R_390_GOT12];
+ case BFD_RELOC_32_GOT_PCREL:
+ return &elf_howto_table[(int) R_390_GOT32];
+ case BFD_RELOC_390_PLT32:
+ return &elf_howto_table[(int) R_390_PLT32];
+ case BFD_RELOC_390_COPY:
+ return &elf_howto_table[(int) R_390_COPY];
+ case BFD_RELOC_390_GLOB_DAT:
+ return &elf_howto_table[(int) R_390_GLOB_DAT];
+ case BFD_RELOC_390_JMP_SLOT:
+ return &elf_howto_table[(int) R_390_JMP_SLOT];
+ case BFD_RELOC_390_RELATIVE:
+ return &elf_howto_table[(int) R_390_RELATIVE];
+ case BFD_RELOC_32_GOTOFF:
+ return &elf_howto_table[(int) R_390_GOTOFF];
+ case BFD_RELOC_390_GOTPC:
+ return &elf_howto_table[(int) R_390_GOTPC];
+ case BFD_RELOC_390_GOT16:
+ return &elf_howto_table[(int) R_390_GOT16];
+ case BFD_RELOC_16_PCREL:
+ return &elf_howto_table[(int) R_390_PC16];
+ case BFD_RELOC_390_PC16DBL:
+ return &elf_howto_table[(int) R_390_PC16DBL];
+ case BFD_RELOC_390_PLT16DBL:
+ return &elf_howto_table[(int) R_390_PLT16DBL];
+ case BFD_RELOC_VTABLE_INHERIT:
+ return &elf64_s390_vtinherit_howto;
+ case BFD_RELOC_VTABLE_ENTRY:
+ return &elf64_s390_vtentry_howto;
+ case BFD_RELOC_390_PC32DBL:
+ return &elf_howto_table[(int) R_390_PC32DBL];
+ case BFD_RELOC_390_PLT32DBL:
+ return &elf_howto_table[(int) R_390_PLT32DBL];
+ case BFD_RELOC_390_GOTPCDBL:
+ return &elf_howto_table[(int) R_390_GOTPCDBL];
+ case BFD_RELOC_64:
+ return &elf_howto_table[(int) R_390_64];
+ case BFD_RELOC_64_PCREL:
+ return &elf_howto_table[(int) R_390_PC64];
+ case BFD_RELOC_390_GOT64:
+ return &elf_howto_table[(int) R_390_GOT64];
+ case BFD_RELOC_390_PLT64:
+ return &elf_howto_table[(int) R_390_PLT64];
+ case BFD_RELOC_390_GOTENT:
+ return &elf_howto_table[(int) R_390_GOTENT];
+ default:
+ break;
+ }
+ return 0;
+}
+
+/* We need to use ELF64_R_TYPE so we have our own copy of this function,
+ and elf64-s390.c has its own copy. */
+
+static void
+elf_s390_info_to_howto (abfd, cache_ptr, dst)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ arelent *cache_ptr;
+ Elf_Internal_Rela *dst;
+{
+ switch (ELF64_R_TYPE(dst->r_info))
+ {
+ case R_390_GNU_VTINHERIT:
+ cache_ptr->howto = &elf64_s390_vtinherit_howto;
+ break;
+
+ case R_390_GNU_VTENTRY:
+ cache_ptr->howto = &elf64_s390_vtentry_howto;
+ break;
+
+ default:
+ BFD_ASSERT (ELF64_R_TYPE(dst->r_info) < (unsigned int) R_390_max);
+ cache_ptr->howto = &elf_howto_table[ELF64_R_TYPE(dst->r_info)];
+ }
+}
+
+static boolean
+elf_s390_is_local_label_name (abfd, name)
+ bfd *abfd;
+ const char *name;
+{
+ if (name[0] == '.' && (name[1] == 'X' || name[1] == 'L'))
+ return true;
+
+ return _bfd_elf_is_local_label_name (abfd, name);
+}
+
+/* Functions for the 390 ELF linker. */
+
+/* The name of the dynamic interpreter. This is put in the .interp
+ section. */
+
+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
+
+/* The size in bytes of the first entry in the procedure linkage table. */
+#define PLT_FIRST_ENTRY_SIZE 32
+/* The size in bytes of an entry in the procedure linkage table. */
+#define PLT_ENTRY_SIZE 32
+
+#define GOT_ENTRY_SIZE 8
+
+/* The first three entries in a procedure linkage table are reserved,
+ and the initial contents are unimportant (we zero them out).
+ Subsequent entries look like this. See the SVR4 ABI 386
+ supplement to see how this works. */
+
+/* For the s390, simple addr offset can only be 0 - 4096.
+ To use the full 16777216 TB address space, several instructions
+ are needed to load an address in a register and execute
+ a branch( or just saving the address)
+
+ Furthermore, only r 0 and 1 are free to use!!! */
+
+/* The first 3 words in the GOT are then reserved.
+ Word 0 is the address of the dynamic table.
+ Word 1 is a pointer to a structure describing the object
+ Word 2 is used to point to the loader entry address.
+
+ The code for PLT entries looks like this:
+
+ The GOT holds the address in the PLT to be executed.
+ The loader then gets:
+ 24(15) = Pointer to the structure describing the object.
+ 28(15) = Offset in symbol table
+ The loader must then find the module where the function is
+ and insert the address in the GOT.
+
+ PLT1: LARL 1,<fn>@GOTENT # 6 bytes Load address of GOT entry in r1
+ LG 1,0(1) # 6 bytes Load address from GOT in r1
+ BCR 15,1 # 2 bytes Jump to address
+ RET1: BASR 1,0 # 2 bytes Return from GOT 1st time
+ LGF 1,12(1) # 6 bytes Load offset in symbl table in r1
+ BRCL 15,-x # 6 bytes Jump to start of PLT
+ .long ? # 4 bytes offset into symbol table
+
+ Total = 32 bytes per PLT entry
+ Fixup at offset 2: relative address to GOT entry
+ Fixup at offset 22: relative branch to PLT0
+ Fixup at offset 28: 32 bit offset into symbol table
+
+ A 32 bit offset into the symbol table is enough. It allows for symbol
+ tables up to a size of 2 gigabyte. A single dynamic object (the main
+ program, any shared library) is limited to 4GB in size and I want to see
+ the program that manages to have a symbol table of more than 2 GB with a
+ total size of at max 4 GB. */
+
+#define PLT_ENTRY_WORD0 (bfd_vma) 0xc0100000
+#define PLT_ENTRY_WORD1 (bfd_vma) 0x0000e310
+#define PLT_ENTRY_WORD2 (bfd_vma) 0x10000004
+#define PLT_ENTRY_WORD3 (bfd_vma) 0x07f10d10
+#define PLT_ENTRY_WORD4 (bfd_vma) 0xe310100c
+#define PLT_ENTRY_WORD5 (bfd_vma) 0x0014c0f4
+#define PLT_ENTRY_WORD6 (bfd_vma) 0x00000000
+#define PLT_ENTRY_WORD7 (bfd_vma) 0x00000000
+
+/* The first PLT entry pushes the offset into the symbol table
+ from R1 onto the stack at 8(15) and the loader object info
+ at 12(15), loads the loader address in R1 and jumps to it. */
+
+/* The first entry in the PLT:
+
+ PLT0:
+ STG 1,56(15) # r1 contains the offset into the symbol table
+ LARL 1,_GLOBAL_OFFSET_TABLE # load address of global offset table
+ MVC 48(8,15),8(1) # move loader ino (object struct address) to stack
+ LG 1,16(1) # get entry address of loader
+ BCR 15,1 # jump to loader
+
+ Fixup at offset 8: relative address to start of GOT. */
+
+#define PLT_FIRST_ENTRY_WORD0 (bfd_vma) 0xe310f038
+#define PLT_FIRST_ENTRY_WORD1 (bfd_vma) 0x0024c010
+#define PLT_FIRST_ENTRY_WORD2 (bfd_vma) 0x00000000
+#define PLT_FIRST_ENTRY_WORD3 (bfd_vma) 0xd207f030
+#define PLT_FIRST_ENTRY_WORD4 (bfd_vma) 0x1008e310
+#define PLT_FIRST_ENTRY_WORD5 (bfd_vma) 0x10100004
+#define PLT_FIRST_ENTRY_WORD6 (bfd_vma) 0x07f10700
+#define PLT_FIRST_ENTRY_WORD7 (bfd_vma) 0x07000700
+
+/* The s390 linker needs to keep track of the number of relocs that it
+ decides to copy as dynamic relocs in check_relocs for each symbol.
+ This is so that it can later discard them if they are found to be
+ unnecessary. We store the information in a field extending the
+ regular ELF linker hash table. */
+
+struct elf_s390_dyn_relocs
+{
+ struct elf_s390_dyn_relocs *next;
+
+ /* The input section of the reloc. */
+ asection *sec;
+
+ /* Total number of relocs copied for the input section. */
+ bfd_size_type count;
+
+ /* Number of pc-relative relocs copied for the input section. */
+ bfd_size_type pc_count;
+};
+
+/* s390 ELF linker hash entry. */
+
+struct elf_s390_link_hash_entry
+{
+ struct elf_link_hash_entry elf;
+
+ /* Track dynamic relocs copied for this symbol. */
+ struct elf_s390_dyn_relocs *dyn_relocs;
+};
+
+/* s390 ELF linker hash table. */
+
+struct elf_s390_link_hash_table
+{
+ struct elf_link_hash_table elf;
+
+ /* Short-cuts to get to dynamic linker sections. */
+ asection *sgot;
+ asection *sgotplt;
+ asection *srelgot;
+ asection *splt;
+ asection *srelplt;
+ asection *sdynbss;
+ asection *srelbss;
+
+ /* Small local sym to section mapping cache. */
+ struct sym_sec_cache sym_sec;
+};
+
+/* Get the s390 ELF linker hash table from a link_info structure. */
+
+#define elf_s390_hash_table(p) \
+ ((struct elf_s390_link_hash_table *) ((p)->hash))
+
+/* Create an entry in an s390 ELF linker hash table. */
+
+static struct bfd_hash_entry *
+link_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 elf_s390_link_hash_entry));
+ if (entry == NULL)
+ return entry;
+ }
+
+ /* Call the allocation method of the superclass. */
+ entry = _bfd_elf_link_hash_newfunc (entry, table, string);
+ if (entry != NULL)
+ {
+ struct elf_s390_link_hash_entry *eh;
+
+ eh = (struct elf_s390_link_hash_entry *) entry;
+ eh->dyn_relocs = NULL;
+ }
+
+ return entry;
+}
+
+/* Create an s390 ELF linker hash table. */
+
+static struct bfd_link_hash_table *
+elf_s390_link_hash_table_create (abfd)
+ bfd *abfd;
+{
+ struct elf_s390_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf_s390_link_hash_table);
+
+ ret = (struct elf_s390_link_hash_table *) bfd_alloc (abfd, amt);
+ if (ret == NULL)
+ return NULL;
+
+ if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
+ {
+ bfd_release (abfd, ret);
+ return NULL;
+ }
+
+ ret->sgot = NULL;
+ ret->sgotplt = NULL;
+ ret->srelgot = NULL;
+ ret->splt = NULL;
+ ret->srelplt = NULL;
+ ret->sdynbss = NULL;
+ ret->srelbss = NULL;
+ ret->sym_sec.abfd = NULL;
+
+ return &ret->elf.root;
+}
+
+/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
+ shortcuts to them in our hash table. */
+
+static boolean
+create_got_section (dynobj, info)
+ bfd *dynobj;
+ struct bfd_link_info *info;
+{
+ struct elf_s390_link_hash_table *htab;
+
+ if (! _bfd_elf_create_got_section (dynobj, info))
+ return false;
+
+ htab = elf_s390_hash_table (info);
+ htab->sgot = bfd_get_section_by_name (dynobj, ".got");
+ htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+ if (!htab->sgot || !htab->sgotplt)
+ abort ();
+
+ htab->srelgot = bfd_make_section (dynobj, ".rela.got");
+ if (htab->srelgot == NULL
+ || ! bfd_set_section_flags (dynobj, htab->srelgot,
+ (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
+ return false;
+ return true;
+}
+
+/* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
+ .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
+ hash table. */
+
+static boolean
+elf_s390_create_dynamic_sections (dynobj, info)
+ bfd *dynobj;
+ struct bfd_link_info *info;
+{
+ struct elf_s390_link_hash_table *htab;
+
+ htab = elf_s390_hash_table (info);
+ if (!htab->sgot && !create_got_section (dynobj, info))
+ return false;
+
+ if (!_bfd_elf_create_dynamic_sections (dynobj, info))
+ return false;
+
+ htab->splt = bfd_get_section_by_name (dynobj, ".plt");
+ htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
+ htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+ if (!info->shared)
+ htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+
+ if (!htab->splt || !htab->srelplt || !htab->sdynbss
+ || (!info->shared && !htab->srelbss))
+ abort ();
+
+ return true;
+}
+
+/* Copy the extra info we tack onto an elf_link_hash_entry. */
+
+static void
+elf_s390_copy_indirect_symbol (dir, ind)
+ struct elf_link_hash_entry *dir, *ind;
+{
+ struct elf_s390_link_hash_entry *edir, *eind;
+
+ edir = (struct elf_s390_link_hash_entry *) dir;
+ eind = (struct elf_s390_link_hash_entry *) ind;
+
+ if (eind->dyn_relocs != NULL)
+ {
+ if (edir->dyn_relocs != NULL)
+ {
+ struct elf_s390_dyn_relocs **pp;
+ struct elf_s390_dyn_relocs *p;
+
+ if (ind->root.type == bfd_link_hash_indirect)
+ abort ();
+
+ /* Add reloc counts against the weak sym to the strong sym
+ list. Merge any entries against the same section. */
+ for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
+ {
+ struct elf_s390_dyn_relocs *q;
+
+ for (q = edir->dyn_relocs; q != NULL; q = q->next)
+ if (q->sec == p->sec)
+ {
+ q->pc_count += p->pc_count;
+ q->count += p->count;
+ *pp = p->next;
+ break;
+ }
+ if (q == NULL)
+ pp = &p->next;
+ }
+ *pp = edir->dyn_relocs;
+ }
+
+ edir->dyn_relocs = eind->dyn_relocs;
+ eind->dyn_relocs = NULL;
+ }
+
+ _bfd_elf_link_hash_copy_indirect (dir, ind);
+}
+
+/* Look through the relocs for a section during the first phase, and
+ allocate space in the global offset table or procedure linkage
+ table. */
+
+static boolean
+elf_s390_check_relocs (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ struct elf_s390_link_hash_table *htab;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+ asection *sreloc;
+
+ if (info->relocateable)
+ return true;
+
+ htab = elf_s390_hash_table (info);
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+
+ sreloc = NULL;
+
+ rel_end = relocs + sec->reloc_count;
+ for (rel = relocs; rel < rel_end; rel++)
+ {
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ r_symndx = ELF64_R_SYM (rel->r_info);
+
+ if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
+ {
+ (*_bfd_error_handler) (_("%s: bad symbol index: %d"),
+ bfd_archive_filename (abfd),
+ r_symndx);
+ return false;
+ }
+
+ if (r_symndx < symtab_hdr->sh_info)
+ h = NULL;
+ else
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ switch (ELF64_R_TYPE (rel->r_info))
+ {
+ case R_390_GOT12:
+ case R_390_GOT16:
+ case R_390_GOT32:
+ case R_390_GOT64:
+ case R_390_GOTENT:
+ /* 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;
+
+ 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_390_GOTOFF:
+ case R_390_GOTPC:
+ case R_390_GOTPCDBL:
+ if (htab->sgot == NULL)
+ {
+ if (htab->elf.dynobj == NULL)
+ htab->elf.dynobj = abfd;
+ if (!create_got_section (htab->elf.dynobj, info))
+ return false;
+ }
+ break;
+
+ case R_390_PLT16DBL:
+ case R_390_PLT32:
+ case R_390_PLT32DBL:
+ case R_390_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 which is
+ never referenced by a dynamic object, in which case we
+ don't need to generate a procedure linkage table entry
+ after all. */
+
+ /* If this is a local symbol, we resolve it directly without
+ creating a procedure linkage table entry. */
+ if (h == NULL)
+ continue;
+
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+ h->plt.refcount += 1;
+ break;
+
+ case R_390_8:
+ case R_390_16:
+ case R_390_32:
+ case R_390_64:
+ case R_390_PC16:
+ case R_390_PC16DBL:
+ case R_390_PC32:
+ case R_390_PC32DBL:
+ case R_390_PC64:
+ if (h != NULL && !info->shared)
+ {
+ /* If this reloc is in a read-only section, we might
+ need a copy reloc. We can't check reliably at this
+ stage whether the section is read-only, as input
+ sections have not yet been mapped to output sections.
+ Tentatively set the flag for now, and correct in
+ adjust_dynamic_symbol. */
+ h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
+
+ /* We may need a .plt entry if the function this reloc
+ refers to is in a shared lib. */
+ h->plt.refcount += 1;
+ }
+
+ /* If we are creating a shared library, and this is a reloc
+ against a global symbol, or a non PC relative reloc
+ against a local symbol, then we need to copy the reloc
+ into the shared library. However, if we are linking with
+ -Bsymbolic, we do not need to copy a reloc against a
+ global symbol which is defined in an object we are
+ including in the link (i.e., DEF_REGULAR is set). At
+ this point we have not seen all the input files, so it is
+ possible that DEF_REGULAR is not set now but will be set
+ later (it is never cleared). In case of a weak definition,
+ DEF_REGULAR may be cleared later by a strong definition in
+ a shared library. We account for that possibility below by
+ storing information in the relocs_copied field of the hash
+ table entry. A similar situation occurs when creating
+ shared libraries and symbol visibility changes render the
+ symbol local.
+
+ If on the other hand, we are creating an executable, we
+ may need to keep relocations for symbols satisfied by a
+ dynamic library if we manage to avoid copy relocs for the
+ symbol. */
+ if ((info->shared
+ && (sec->flags & SEC_ALLOC) != 0
+ && ((ELF64_R_TYPE (rel->r_info) != R_390_PC16
+ && ELF64_R_TYPE (rel->r_info) != R_390_PC16DBL
+ && ELF64_R_TYPE (rel->r_info) != R_390_PC32
+ && ELF64_R_TYPE (rel->r_info) != R_390_PC32DBL
+ && ELF64_R_TYPE (rel->r_info) != R_390_PC64)
+ || (h != NULL
+ && (! info->symbolic
+ || h->root.type == bfd_link_hash_defweak
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+ || (!info->shared
+ && (sec->flags & SEC_ALLOC) != 0
+ && h != NULL
+ && (h->root.type == bfd_link_hash_defweak
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)))
+ {
+ struct elf_s390_dyn_relocs *p;
+ struct elf_s390_dyn_relocs **head;
+
+ /* We must copy these reloc types into the output file.
+ Create a reloc section in dynobj and make room for
+ this reloc. */
+ if (sreloc == NULL)
+ {
+ const char *name;
+ bfd *dynobj;
+
+ name = (bfd_elf_string_from_elf_section
+ (abfd,
+ elf_elfheader (abfd)->e_shstrndx,
+ elf_section_data (sec)->rel_hdr.sh_name));
+ if (name == NULL)
+ return false;
+
+ if (strncmp (name, ".rela", 5) != 0
+ || strcmp (bfd_get_section_name (abfd, sec),
+ name + 5) != 0)
+ {
+ (*_bfd_error_handler)
+ (_("%s: bad relocation section name `%s\'"),
+ bfd_archive_filename (abfd), name);
+ }
+
+ if (htab->elf.dynobj == NULL)
+ htab->elf.dynobj = abfd;
+
+ dynobj = htab->elf.dynobj;
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ if (sreloc == NULL)
+ {
+ flagword flags;
+
+ sreloc = bfd_make_section (dynobj, name);
+ flags = (SEC_HAS_CONTENTS | SEC_READONLY
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+ if ((sec->flags & SEC_ALLOC) != 0)
+ flags |= SEC_ALLOC | SEC_LOAD;
+ if (sreloc == NULL
+ || ! bfd_set_section_flags (dynobj, sreloc, flags)
+ || ! bfd_set_section_alignment (dynobj, sreloc, 2))
+ return false;
+ }
+ elf_section_data (sec)->sreloc = sreloc;
+ }
+
+ /* If this is a global symbol, we count the number of
+ relocations we need for this symbol. */
+ if (h != NULL)
+ {
+ head = &((struct elf_s390_link_hash_entry *) h)->dyn_relocs;
+ }
+ else
+ {
+ /* Track dynamic relocs needed for local syms too.
+ We really need local syms available to do this
+ easily. Oh well. */
+
+ asection *s;
+ s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
+ sec, r_symndx);
+ if (s == NULL)
+ return false;
+
+ head = ((struct elf_s390_dyn_relocs **)
+ &elf_section_data (s)->local_dynrel);
+ }
+
+ p = *head;
+ if (p == NULL || p->sec != sec)
+ {
+ bfd_size_type amt = sizeof *p;
+ p = ((struct elf_s390_dyn_relocs *)
+ bfd_alloc (htab->elf.dynobj, amt));
+ if (p == NULL)
+ return false;
+ p->next = *head;
+ *head = p;
+ p->sec = sec;
+ p->count = 0;
+ p->pc_count = 0;
+ }
+
+ p->count += 1;
+ if (ELF64_R_TYPE (rel->r_info) == R_390_PC16
+ || ELF64_R_TYPE (rel->r_info) == R_390_PC16DBL
+ || ELF64_R_TYPE (rel->r_info) == R_390_PC32
+ || ELF64_R_TYPE (rel->r_info) == R_390_PC32DBL
+ || ELF64_R_TYPE (rel->r_info) == R_390_PC64)
+ p->pc_count += 1;
+ }
+ break;
+
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_390_GNU_VTINHERIT:
+ if (!_bfd_elf64_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return false;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_390_GNU_VTENTRY:
+ if (!_bfd_elf64_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return false;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return true;
+}
+
+/* Return the section that should be marked against GC for a given
+ relocation. */
+
+static asection *
+elf_s390_gc_mark_hook (abfd, info, rel, h, sym)
+ bfd *abfd;
+ 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 (ELF64_R_TYPE (rel->r_info))
+ {
+ case R_390_GNU_VTINHERIT:
+ case R_390_GNU_VTENTRY:
+ break;
+
+ default:
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ return h->root.u.def.section;
+
+ case bfd_link_hash_common:
+ return h->root.u.c.p->section;
+
+ default:
+ break;
+ }
+ }
+ }
+ else
+ {
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
+
+ return NULL;
+}
+
+/* Update the got entry reference counts for the section being removed. */
+
+static boolean
+elf_s390_gc_sweep_hook (abfd, info, sec, relocs)
+ bfd *abfd;
+ struct bfd_link_info *info;
+ asection *sec;
+ const Elf_Internal_Rela *relocs;
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_signed_vma *local_got_refcounts;
+ const Elf_Internal_Rela *rel, *relend;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ elf_section_data (sec)->local_dynrel = NULL;
+
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ local_got_refcounts = elf_local_got_refcounts (abfd);
+
+ relend = relocs + sec->reloc_count;
+ for (rel = relocs; rel < relend; rel++)
+ switch (ELF64_R_TYPE (rel->r_info))
+ {
+ case R_390_GOT12:
+ case R_390_GOT16:
+ case R_390_GOT32:
+ case R_390_GOT64:
+ case R_390_GOTOFF:
+ case R_390_GOTPC:
+ case R_390_GOTPCDBL:
+ case R_390_GOTENT:
+ r_symndx = ELF64_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ if (h->got.refcount > 0)
+ h->got.refcount -= 1;
+ }
+ else if (local_got_refcounts != NULL)
+ {
+ if (local_got_refcounts[r_symndx] > 0)
+ local_got_refcounts[r_symndx] -= 1;
+ }
+ break;
+
+ case R_390_8:
+ case R_390_12:
+ case R_390_16:
+ case R_390_32:
+ case R_390_64:
+ case R_390_PC16:
+ case R_390_PC16DBL:
+ case R_390_PC32:
+ case R_390_PC32DBL:
+ case R_390_PC64:
+ r_symndx = ELF64_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ struct elf_s390_link_hash_entry *eh;
+ struct elf_s390_dyn_relocs **pp;
+ struct elf_s390_dyn_relocs *p;
+
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ if (!info->shared && h->plt.refcount > 0)
+ h->plt.refcount -= 1;
+
+ eh = (struct elf_s390_link_hash_entry *) h;
+
+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
+ if (p->sec == sec)
+ {
+ if (ELF64_R_TYPE (rel->r_info) == R_390_PC16
+ || ELF64_R_TYPE (rel->r_info) == R_390_PC16DBL
+ || ELF64_R_TYPE (rel->r_info) == R_390_PC32)
+ p->pc_count -= 1;
+ p->count -= 1;
+ if (p->count == 0)
+ *pp = p->next;
+ break;
+ }
+ }
+ break;
+
+ case R_390_PLT16DBL:
+ case R_390_PLT32:
+ case R_390_PLT32DBL:
+ case R_390_PLT64:
+ r_symndx = ELF64_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ if (h->plt.refcount > 0)
+ h->plt.refcount -= 1;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+ regular object. The current definition is in some section of the
+ dynamic object, but we're not including those sections. We have to
+ change the definition to something the rest of the link can
+ understand. */
+
+static boolean
+elf_s390_adjust_dynamic_symbol (info, h)
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+{
+ struct elf_s390_link_hash_table *htab;
+ struct elf_s390_link_hash_entry * eh;
+ struct elf_s390_dyn_relocs *p;
+ asection *s;
+ 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
+ (although we could actually do it here). */
+ if (h->type == STT_FUNC
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+ {
+ if (h->plt.refcount <= 0
+ || (! 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->root.type != bfd_link_hash_undefweak
+ && h->root.type != bfd_link_hash_undefined))
+ {
+ /* 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, or if all references were garbage collected. In
+ such a case, we don't actually need to build a procedure
+ linkage table, and we can just do a PC32 reloc instead. */
+ h->plt.offset = (bfd_vma) -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ }
+
+ return true;
+ }
+ else
+ /* It's possible that we incorrectly decided a .plt reloc was
+ needed for an R_390_PC32 reloc to a non-function sym in
+ check_relocs. We can't decide accurately between function and
+ non-function syms in check-relocs; Objects loaded later in
+ the link may change h->type. So fix it now. */
+ h->plt.offset = (bfd_vma) -1;
+
+ /* If this is a weak symbol, and there is a real definition, the
+ processor independent code will have arranged for us to see the
+ real definition first, and we can just use the same value. */
+ if (h->weakdef != NULL)
+ {
+ BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+ || h->weakdef->root.type == bfd_link_hash_defweak);
+ h->root.u.def.section = h->weakdef->root.u.def.section;
+ h->root.u.def.value = h->weakdef->root.u.def.value;
+ return true;
+ }
+
+ /* This is a reference to a symbol defined by a dynamic object which
+ is not a function. */
+
+ /* If we are creating a shared library, we must presume that the
+ only references to the symbol are via the global offset table.
+ For such cases we need not do anything here; the relocations will
+ be handled correctly by relocate_section. */
+ if (info->shared)
+ return true;
+
+ /* If there are no references to this symbol that do not use the
+ GOT, we don't need to generate a copy reloc. */
+ if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
+ return true;
+
+ /* If -z nocopyreloc was given, we won't generate them either. */
+ if (info->nocopyreloc)
+ {
+ h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
+ return true;
+ }
+
+ eh = (struct elf_s390_link_hash_entry *) h;
+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ {
+ s = p->sec->output_section;
+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
+ break;
+ }
+
+ /* 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. */
+ if (p == NULL)
+ {
+ h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
+ return true;
+ }
+
+ /* We must allocate the symbol in our .dynbss section, which will
+ become part of the .bss section of the executable. There will be
+ an entry for this symbol in the .dynsym section. The dynamic
+ object will contain position independent code, so all references
+ from the dynamic object to this symbol will go through the global
+ offset table. The dynamic linker will use the .dynsym entry to
+ determine the address it must put in the global offset table, so
+ both the dynamic object and the regular object will refer to the
+ same memory location for the variable. */
+
+ htab = elf_s390_hash_table (info);
+
+ /* We must generate a R_390_COPY reloc to tell the dynamic linker to
+ copy the initial value out of the dynamic object and into the
+ runtime process image. */
+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+ {
+ htab->srelbss->_raw_size += sizeof (Elf64_External_Rela);
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+ }
+
+ /* We need to figure out the alignment required for this symbol. I
+ have no idea how ELF linkers handle this. */
+ power_of_two = bfd_log2 (h->size);
+ if (power_of_two > 3)
+ power_of_two = 3;
+
+ /* Apply the required alignment. */
+ s = htab->sdynbss;
+ s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two));
+ if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s))
+ {
+ if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two))
+ return false;
+ }
+
+ /* Define the symbol as being at this point in the section. */
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+
+ /* Increment the section size to make room for the symbol. */
+ s->_raw_size += h->size;
+
+ return true;
+}
+
+/* This is the condition under which elf_s390_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
+ initializing any .plt and .got entries in elf_s390_relocate_section. */
+#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
+ ((DYN) \
+ && ((INFO)->shared \
+ || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
+ && ((H)->dynindx != -1 \
+ || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
+
+/* Allocate space in .plt, .got and associated reloc sections for
+ dynamic relocs. */
+
+static boolean
+allocate_dynrelocs (h, inf)
+ struct elf_link_hash_entry *h;
+ PTR inf;
+{
+ struct bfd_link_info *info;
+ struct elf_s390_link_hash_table *htab;
+ struct elf_s390_link_hash_entry *eh;
+ struct elf_s390_dyn_relocs *p;
+
+ if (h->root.type == bfd_link_hash_indirect)
+ return true;
+
+ if (h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ info = (struct bfd_link_info *) inf;
+ htab = elf_s390_hash_table (info);
+
+ if (htab->elf.dynamic_sections_created
+ && h->plt.refcount > 0)
+ {
+ /* Make sure this symbol is output as a dynamic symbol.
+ Undefined weak syms won't yet be marked as dynamic. */
+ if (h->dynindx == -1
+ && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+ {
+ if (! bfd_elf64_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
+ {
+ asection *s = htab->splt;
+
+ /* If this is the first .plt entry, make room for the special
+ first entry. */
+ if (s->_raw_size == 0)
+ s->_raw_size += PLT_FIRST_ENTRY_SIZE;
+
+ h->plt.offset = s->_raw_size;
+
+ /* If this symbol is not defined in a regular file, and we are
+ not generating a shared library, then set the symbol to this
+ location in the .plt. This is required to make function
+ pointers compare as equal between the normal executable and
+ the shared library. */
+ if (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = h->plt.offset;
+ }
+
+ /* Make room for this entry. */
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .got.plt section, which
+ will be placed in the .got section by the linker script. */
+ htab->sgotplt->_raw_size += GOT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .rela.plt section. */
+ htab->srelplt->_raw_size += sizeof (Elf64_External_Rela);
+ }
+ else
+ {
+ h->plt.offset = (bfd_vma) -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ }
+ }
+ else
+ {
+ h->plt.offset = (bfd_vma) -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ }
+
+ if (h->got.refcount > 0)
+ {
+ asection *s;
+ boolean dyn;
+
+ /* Make sure this symbol is output as a dynamic symbol.
+ Undefined weak syms won't yet be marked as dynamic. */
+ if (h->dynindx == -1
+ && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+ {
+ if (! bfd_elf64_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ s = htab->sgot;
+ h->got.offset = s->_raw_size;
+ s->_raw_size += GOT_ENTRY_SIZE;
+ dyn = htab->elf.dynamic_sections_created;
+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h))
+ htab->srelgot->_raw_size += sizeof (Elf64_External_Rela);
+ }
+ else
+ h->got.offset = (bfd_vma) -1;
+
+ eh = (struct elf_s390_link_hash_entry *) h;
+ if (eh->dyn_relocs == NULL)
+ return true;
+
+ /* In the shared -Bsymbolic case, discard space allocated for
+ dynamic pc-relative relocs against symbols which turn out to be
+ defined in regular objects. For the normal shared case, discard
+ space for pc-relative relocs that have become local due to symbol
+ visibility changes. */
+
+ if (info->shared)
+ {
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
+ && ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
+ || info->symbolic))
+ {
+ struct elf_s390_dyn_relocs **pp;
+
+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+ {
+ p->count -= p->pc_count;
+ p->pc_count = 0;
+ if (p->count == 0)
+ *pp = p->next;
+ else
+ pp = &p->next;
+ }
+ }
+ }
+ else
+ {
+ /* For the non-shared case, discard space for relocs against
+ symbols which turn out to need copy relocs or are not
+ dynamic. */
+
+ if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
+ && (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ || (htab->elf.dynamic_sections_created
+ && (h->root.type == bfd_link_hash_undefweak
+ || h->root.type == bfd_link_hash_undefined))))
+ {
+ /* Make sure this symbol is output as a dynamic symbol.
+ Undefined weak syms won't yet be marked as dynamic. */
+ if (h->dynindx == -1
+ && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+ {
+ if (! bfd_elf64_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ /* If that succeeded, we know we'll be keeping all the
+ relocs. */
+ if (h->dynindx != -1)
+ goto keep;
+ }
+
+ eh->dyn_relocs = NULL;
+
+ keep: ;
+ }
+
+ /* Finally, allocate space. */
+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ {
+ asection *sreloc = elf_section_data (p->sec)->sreloc;
+ sreloc->_raw_size += p->count * sizeof (Elf64_External_Rela);
+ }
+
+ return true;
+}
+
+/* Find any dynamic relocs that apply to read-only sections. */
+
+static boolean
+readonly_dynrelocs (h, inf)
+ struct elf_link_hash_entry *h;
+ PTR inf;
+{
+ struct elf_s390_link_hash_entry *eh;
+ struct elf_s390_dyn_relocs *p;
+
+ if (h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ eh = (struct elf_s390_link_hash_entry *) h;
+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ {
+ asection *s = p->sec->output_section;
+
+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
+ {
+ struct bfd_link_info *info = (struct bfd_link_info *) inf;
+
+ info->flags |= DF_TEXTREL;
+
+ /* Not an error, just cut short the traversal. */
+ return false;
+ }
+ }
+ return true;
+}
+
+/* Set the sizes of the dynamic sections. */
+
+static boolean
+elf_s390_size_dynamic_sections (output_bfd, info)
+ bfd *output_bfd ATTRIBUTE_UNUSED;
+ struct bfd_link_info *info;
+{
+ struct elf_s390_link_hash_table *htab;
+ bfd *dynobj;
+ asection *s;
+ boolean relocs;
+ bfd *ibfd;
+
+ htab = elf_s390_hash_table (info);
+ dynobj = htab->elf.dynobj;
+ if (dynobj == NULL)
+ abort ();
+
+ if (htab->elf.dynamic_sections_created)
+ {
+ /* Set the contents of the .interp section to the interpreter. */
+ if (! info->shared)
+ {
+ s = bfd_get_section_by_name (dynobj, ".interp");
+ if (s == NULL)
+ abort ();
+ s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+ }
+ }
+
+ /* Set up .got offsets for local syms, and space for local dynamic
+ relocs. */
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ {
+ bfd_signed_vma *local_got;
+ bfd_signed_vma *end_local_got;
+ bfd_size_type locsymcount;
+ Elf_Internal_Shdr *symtab_hdr;
+ asection *srela;
+
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ continue;
+
+ for (s = ibfd->sections; s != NULL; s = s->next)
+ {
+ struct elf_s390_dyn_relocs *p;
+
+ for (p = *((struct elf_s390_dyn_relocs **)
+ &elf_section_data (s)->local_dynrel);
+ p != NULL;
+ p = p->next)
+ {
+ if (!bfd_is_abs_section (p->sec)
+ && bfd_is_abs_section (p->sec->output_section))
+ {
+ /* Input section has been discarded, either because
+ it is a copy of a linkonce section or due to
+ linker script /DISCARD/, so we'll be discarding
+ the relocs too. */
+ }
+ else if (p->count != 0)
+ {
+ srela = elf_section_data (p->sec)->sreloc;
+ srela->_raw_size += p->count * sizeof (Elf64_External_Rela);
+ if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+ info->flags |= DF_TEXTREL;
+ }
+ }
+ }
+
+ local_got = elf_local_got_refcounts (ibfd);
+ if (!local_got)
+ continue;
+
+ symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ locsymcount = symtab_hdr->sh_info;
+ end_local_got = local_got + locsymcount;
+ s = htab->sgot;
+ srela = htab->srelgot;
+ for (; local_got < end_local_got; ++local_got)
+ {
+ if (*local_got > 0)
+ {
+ *local_got = s->_raw_size;
+ s->_raw_size += GOT_ENTRY_SIZE;
+ if (info->shared)
+ srela->_raw_size += sizeof (Elf64_External_Rela);
+ }
+ else
+ *local_got = (bfd_vma) -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);
+
+ /* We now have determined the sizes of the various dynamic sections.
+ Allocate memory for them. */
+ relocs = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ if (s == htab->splt
+ || s == htab->sgot
+ || s == htab->sgotplt)
+ {
+ /* Strip this section if we don't need it; see the
+ comment below. */
+ }
+ else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
+ {
+ if (s->_raw_size != 0 && s != htab->srelplt)
+ relocs = true;
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ s->reloc_count = 0;
+ }
+ else
+ {
+ /* It's not one of our sections, so don't allocate space. */
+ continue;
+ }
+
+ if (s->_raw_size == 0)
+ {
+ /* If we don't need this section, strip it from the
+ output file. This is to handle .rela.bss and
+ .rela.plt. We must create it in
+ create_dynamic_sections, because it must be created
+ before the linker maps input sections to output
+ sections. The linker does that before
+ adjust_dynamic_symbol is called, and it is that
+ function which decides whether anything needs to go
+ into these sections. */
+
+ _bfd_strip_section_from_output (info, s);
+ 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_390_NONE reloc instead
+ of garbage. */
+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
+ if (s->contents == NULL)
+ return false;
+ }
+
+ if (htab->elf.dynamic_sections_created)
+ {
+ /* Add some entries to the .dynamic section. We fill in the
+ values later, in elf_s390_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+ if (! info->shared)
+ {
+ if (!add_dynamic_entry (DT_DEBUG, 0))
+ return false;
+ }
+
+ if (htab->splt->_raw_size != 0)
+ {
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
+ return false;
+ }
+
+ if (relocs)
+ {
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
+ return false;
+
+ /* If any dynamic relocs apply to a read-only section,
+ then we need a DT_TEXTREL entry. */
+ if ((info->flags & DF_TEXTREL) == 0)
+ elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
+ (PTR) info);
+
+ if ((info->flags & DF_TEXTREL) != 0)
+ {
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
+ return false;
+ }
+ }
+ }
+#undef add_dynamic_entry
+
+ return true;
+}
+
+/* Relocate a 390 ELF section. */
+
+static boolean
+elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ Elf_Internal_Rela *relocs;
+ Elf_Internal_Sym *local_syms;
+ asection **local_sections;
+{
+ struct elf_s390_link_hash_table *htab;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ bfd_vma *local_got_offsets;
+ Elf_Internal_Rela *rel;
+ Elf_Internal_Rela *relend;
+
+ if (info->relocateable)
+ return true;
+
+ htab = elf_s390_hash_table (info);
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (input_bfd);
+ local_got_offsets = elf_local_got_offsets (input_bfd);
+
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ bfd_vma off;
+ bfd_vma relocation;
+ boolean unresolved_reloc;
+ bfd_reloc_status_type r;
+
+ r_type = ELF64_R_TYPE (rel->r_info);
+ if (r_type == (int) R_390_GNU_VTINHERIT
+ || r_type == (int) R_390_GNU_VTENTRY)
+ continue;
+ if (r_type < 0 || r_type >= (int) R_390_max)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ howto = elf_howto_table + r_type;
+ r_symndx = ELF64_R_SYM (rel->r_info);
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+ unresolved_reloc = false;
+ 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);
+ }
+ else
+ {
+ 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)
+ {
+ sec = h->root.u.def.section;
+ if (sec->output_section == NULL)
+ {
+ /* Set a flag that will be cleared later if we find a
+ relocation value for this symbol. output_section
+ is typically NULL for symbols satisfied by a shared
+ library. */
+ unresolved_reloc = true;
+ relocation = 0;
+ }
+ else
+ relocation = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if (h->root.type == bfd_link_hash_undefweak)
+ relocation = 0;
+ else if (info->shared
+ && (!info->symbolic || info->allow_shlib_undefined)
+ && !info->no_undefined
+ && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
+ relocation = 0;
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset,
+ (!info->shared || info->no_undefined
+ || ELF_ST_VISIBILITY (h->other)))))
+ return false;
+ relocation = 0;
+ }
+ }
+
+ switch (r_type)
+ {
+ case R_390_GOT12:
+ case R_390_GOT16:
+ case R_390_GOT32:
+ case R_390_GOT64:
+ case R_390_GOTENT:
+ /* Relocation is to the entry for this symbol in the global
+ offset table. */
+ if (htab->sgot == NULL)
+ abort ();
+
+ if (h != NULL)
+ {
+ boolean dyn;
+
+ off = h->got.offset;
+ dyn = htab->elf.dynamic_sections_created;
+ if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
+ || (info->shared
+ && (info->symbolic
+ || h->dynindx == -1
+ || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+ {
+ /* This is actually a static link, or it is a
+ -Bsymbolic link and the symbol is defined
+ locally, or the symbol was forced to be local
+ because of a version file. We must initialize
+ this entry in the global offset table. Since the
+ offset must always be a multiple of 2, we use the
+ least significant bit to record whether we have
+ initialized it already.
+
+ When doing a dynamic link, we create a .rel.got
+ relocation entry to initialize the value. This
+ is done in the finish_dynamic_symbol routine. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_64 (output_bfd, relocation,
+ htab->sgot->contents + off);
+ h->got.offset |= 1;
+ }
+ }
+ else
+ unresolved_reloc = false;
+ }
+ else
+ {
+ if (local_got_offsets == NULL)
+ abort ();
+
+ off = local_got_offsets[r_symndx];
+
+ /* The offset must always be a multiple of 8. We use
+ the least significant bit to record whether we have
+ already generated the necessary reloc. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ bfd_put_64 (output_bfd, relocation,
+ htab->sgot->contents + off);
+
+ if (info->shared)
+ {
+ asection *srelgot;
+ Elf_Internal_Rela outrel;
+ Elf64_External_Rela *loc;
+
+ srelgot = htab->srelgot;
+ if (srelgot == NULL)
+ abort ();
+
+ outrel.r_offset = (htab->sgot->output_section->vma
+ + htab->sgot->output_offset
+ + off);
+ outrel.r_info = ELF64_R_INFO (0, R_390_RELATIVE);
+ outrel.r_addend = relocation;
+ loc = (Elf64_External_Rela *) srelgot->contents;
+ loc += srelgot->reloc_count++;
+ bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
+ }
+
+ local_got_offsets[r_symndx] |= 1;
+ }
+ }
+
+ if (off >= (bfd_vma) -2)
+ abort ();
+
+ relocation = htab->sgot->output_offset + off;
+
+ /*
+ * For @GOTENT the relocation is against the offset between
+ * the instruction and the symbols entry in the GOT and not
+ * between the start of the GOT and the symbols entry. We
+ * add the vma of the GOT to get the correct value.
+ */
+ if (r_type == R_390_GOTENT)
+ relocation += htab->sgot->output_section->vma;
+
+ break;
+
+ case R_390_GOTOFF:
+ /* Relocation is relative to the start of the global offset
+ table. */
+
+ /* Note that sgot->output_offset is not involved in this
+ calculation. We always want the start of .got. If we
+ defined _GLOBAL_OFFSET_TABLE in a different way, as is
+ permitted by the ABI, we might have to change this
+ calculation. */
+ relocation -= htab->sgot->output_section->vma;
+
+ break;
+
+ case R_390_GOTPC:
+ case R_390_GOTPCDBL:
+ /* Use global offset table as symbol value. */
+ relocation = htab->sgot->output_section->vma;
+ unresolved_reloc = false;
+ break;
+
+ case R_390_PLT16DBL:
+ case R_390_PLT32:
+ case R_390_PLT32DBL:
+ case R_390_PLT64:
+ /* Relocation is to the entry for this symbol in the
+ procedure linkage table. */
+
+ /* Resolve a PLT32 reloc against a local symbol directly,
+ without using the procedure linkage table. */
+ if (h == NULL)
+ break;
+
+ if (h->plt.offset == (bfd_vma) -1
+ || htab->splt == NULL)
+ {
+ /* We didn't make a PLT entry for this symbol. This
+ happens when statically linking PIC code, or when
+ using -Bsymbolic. */
+ break;
+ }
+
+ relocation = (htab->splt->output_section->vma
+ + htab->splt->output_offset
+ + h->plt.offset);
+ unresolved_reloc = false;
+ break;
+
+ case R_390_8:
+ case R_390_16:
+ case R_390_32:
+ case R_390_64:
+ case R_390_PC16:
+ case R_390_PC16DBL:
+ case R_390_PC32:
+ case R_390_PC32DBL:
+ case R_390_PC64:
+ /* r_symndx will be zero only for relocs against symbols
+ from removed linkonce sections, or sections discarded by
+ a linker script. */
+ if (r_symndx == 0
+ || (input_section->flags & SEC_ALLOC) == 0)
+ break;
+
+ if ((info->shared
+ && ((r_type != R_390_PC16
+ && r_type != R_390_PC16DBL
+ && r_type != R_390_PC32
+ && r_type != R_390_PC32DBL
+ && r_type != R_390_PC64)
+ || (h != NULL
+ && h->dynindx != -1
+ && (! info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+ || (!info->shared
+ && h != NULL
+ && h->dynindx != -1
+ && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
+ && (((h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ || h->root.type == bfd_link_hash_undefweak
+ || h->root.type == bfd_link_hash_undefined)))
+ {
+ Elf_Internal_Rela outrel;
+ boolean skip, relocate;
+ asection *sreloc;
+ Elf64_External_Rela *loc;
+
+ /* When generating a shared object, these relocations
+ are copied into the output file to be resolved at run
+ time. */
+
+ skip = false;
+ relocate = false;
+
+ outrel.r_offset =
+ _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset);
+ if (outrel.r_offset == (bfd_vma) -1)
+ skip = true;
+ else if (outrel.r_offset == (bfd_vma) -2)
+ skip = true, relocate = true;
+
+ outrel.r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+
+ if (skip)
+ memset (&outrel, 0, sizeof outrel);
+ else if (h != NULL
+ && h->dynindx != -1
+ && (r_type == R_390_PC16
+ || r_type == R_390_PC16DBL
+ || r_type == R_390_PC32
+ || r_type == R_390_PC32DBL
+ || r_type == R_390_PC64
+ || !info->shared
+ || !info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))
+ {
+ outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
+ outrel.r_addend = rel->r_addend;
+ }
+ else
+ {
+ /* This symbol is local, or marked to become local. */
+ relocate = true;
+ outrel.r_info = ELF64_R_INFO (0, R_390_RELATIVE);
+ outrel.r_addend = relocation + rel->r_addend;
+ }
+
+ sreloc = elf_section_data (input_section)->sreloc;
+ if (sreloc == NULL)
+ abort ();
+
+ loc = (Elf64_External_Rela *) sreloc->contents;
+ loc += sreloc->reloc_count++;
+ bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
+
+ /* If this reloc is against an external symbol, we do
+ not want to fiddle with the addend. Otherwise, we
+ need to include the symbol value so that it becomes
+ an addend for the dynamic reloc. */
+ if (! relocate)
+ continue;
+ }
+
+ break;
+
+ default:
+ break;
+ }
+
+ if (unresolved_reloc
+ && !(info->shared
+ && (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);
+
+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+ contents, rel->r_offset,
+ relocation, rel->r_addend);
+
+ if (r != bfd_reloc_ok)
+ {
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
+ {
+ name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name);
+ if (name == NULL)
+ return false;
+ if (*name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+
+ if (r == bfd_reloc_overflow)
+ {
+
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_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);
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* Finish up dynamic symbol handling. We set the contents of various
+ dynamic sections here. */
+
+static boolean
+elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+{
+ struct elf_s390_link_hash_table *htab;
+
+ htab = elf_s390_hash_table (info);
+
+ if (h->plt.offset != (bfd_vma) -1)
+ {
+ bfd_vma plt_index;
+ bfd_vma got_offset;
+ Elf_Internal_Rela rela;
+ Elf64_External_Rela *loc;
+
+ /* This symbol has an entry in the procedure linkage table. Set
+ it up. */
+
+ if (h->dynindx == -1
+ || htab->splt == NULL
+ || htab->sgotplt == NULL
+ || htab->srelplt == NULL)
+ abort ();
+
+ /* Calc. index no.
+ Current offset - size first entry / entry size. */
+ plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) / PLT_ENTRY_SIZE;
+
+ /* Offset in GOT is PLT index plus GOT headers(3) times 8,
+ addr & GOT addr. */
+ got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
+
+ /* Fill in the blueprint of a PLT. */
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD0,
+ htab->splt->contents + h->plt.offset);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD1,
+ htab->splt->contents + h->plt.offset + 4);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD2,
+ htab->splt->contents + h->plt.offset + 8);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD3,
+ htab->splt->contents + h->plt.offset + 12);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD4,
+ htab->splt->contents + h->plt.offset + 16);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD5,
+ htab->splt->contents + h->plt.offset + 20);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD6,
+ htab->splt->contents + h->plt.offset + 24);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD7,
+ htab->splt->contents + h->plt.offset + 28);
+ /* Fixup the relative address to the GOT entry */
+ bfd_put_32 (output_bfd,
+ (htab->sgotplt->output_section->vma +
+ htab->sgotplt->output_offset + got_offset
+ - (htab->splt->output_section->vma + h->plt.offset))/2,
+ htab->splt->contents + h->plt.offset + 2);
+ /* Fixup the relative branch to PLT 0 */
+ bfd_put_32 (output_bfd, - (PLT_FIRST_ENTRY_SIZE +
+ (PLT_ENTRY_SIZE * plt_index) + 22)/2,
+ htab->splt->contents + h->plt.offset + 24);
+ /* Fixup offset into symbol table */
+ bfd_put_32 (output_bfd, plt_index * sizeof (Elf64_External_Rela),
+ htab->splt->contents + h->plt.offset + 28);
+
+ /* Fill in the entry in the global offset table.
+ Points to instruction after GOT offset. */
+ bfd_put_64 (output_bfd,
+ (htab->splt->output_section->vma
+ + htab->splt->output_offset
+ + h->plt.offset
+ + 14),
+ htab->sgotplt->contents + got_offset);
+
+ /* Fill in the entry in the .rela.plt section. */
+ rela.r_offset = (htab->sgotplt->output_section->vma
+ + htab->sgotplt->output_offset
+ + got_offset);
+ rela.r_info = ELF64_R_INFO (h->dynindx, R_390_JMP_SLOT);
+ rela.r_addend = 0;
+ loc = (Elf64_External_Rela *) htab->srelplt->contents + plt_index;
+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ /* Mark the symbol as undefined, rather than as defined in
+ 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. */
+ sym->st_shndx = SHN_UNDEF;
+ }
+ }
+
+ if (h->got.offset != (bfd_vma) -1)
+ {
+ Elf_Internal_Rela rela;
+ Elf64_External_Rela *loc;
+
+ /* This symbol has an entry in the global offset table. Set it
+ up. */
+
+ if (htab->sgot == NULL || htab->srelgot == NULL)
+ abort ();
+
+ rela.r_offset = (htab->sgot->output_section->vma
+ + htab->sgot->output_offset
+ + (h->got.offset &~ (bfd_vma) 1));
+
+ /* If this is a static link, or it is a -Bsymbolic link and the
+ symbol is defined locally or was forced to be local because
+ of a version file, we just want to emit a RELATIVE reloc.
+ The entry in the global offset table will already have been
+ initialized in the relocate_section function. */
+ if (info->shared
+ && (info->symbolic
+ || h->dynindx == -1
+ || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+ {
+ BFD_ASSERT((h->got.offset & 1) != 0);
+ rela.r_info = ELF64_R_INFO (0, R_390_RELATIVE);
+ rela.r_addend = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ }
+ else
+ {
+ BFD_ASSERT((h->got.offset & 1) == 0);
+ bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgot->contents + h->got.offset);
+ rela.r_info = ELF64_R_INFO (h->dynindx, R_390_GLOB_DAT);
+ rela.r_addend = 0;
+ }
+
+ loc = (Elf64_External_Rela *) htab->srelgot->contents;
+ loc += htab->srelgot->reloc_count++;
+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
+ }
+
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
+ {
+ Elf_Internal_Rela rela;
+ Elf64_External_Rela *loc;
+
+ /* This symbols needs a copy reloc. Set it up. */
+
+ if (h->dynindx == -1
+ || (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
+ || htab->srelbss == NULL)
+ abort ();
+
+ rela.r_offset = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ rela.r_info = ELF64_R_INFO (h->dynindx, R_390_COPY);
+ rela.r_addend = 0;
+ loc = (Elf64_External_Rela *) htab->srelbss->contents;
+ loc += htab->srelbss->reloc_count++;
+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
+ }
+
+ /* Mark some specially defined symbols as absolute. */
+ if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+ || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
+ || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
+ sym->st_shndx = SHN_ABS;
+
+ return true;
+}
+
+/* Used to decide how to sort relocs in an optimal manner for the
+ dynamic linker, before writing them out. */
+
+static enum elf_reloc_type_class
+elf_s390_reloc_type_class (rela)
+ const Elf_Internal_Rela *rela;
+{
+ switch ((int) ELF64_R_TYPE (rela->r_info))
+ {
+ case R_390_RELATIVE:
+ return reloc_class_relative;
+ case R_390_JMP_SLOT:
+ return reloc_class_plt;
+ case R_390_COPY:
+ return reloc_class_copy;
+ default:
+ return reloc_class_normal;
+ }
+}
+
+/* Finish up the dynamic sections. */
+
+static boolean
+elf_s390_finish_dynamic_sections (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ struct elf_s390_link_hash_table *htab;
+ bfd *dynobj;
+ asection *sdyn;
+
+ htab = elf_s390_hash_table (info);
+ dynobj = htab->elf.dynobj;
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ if (htab->elf.dynamic_sections_created)
+ {
+ Elf64_External_Dyn *dyncon, *dynconend;
+
+ if (sdyn == NULL || htab->sgot == NULL)
+ abort ();
+
+ dyncon = (Elf64_External_Dyn *) sdyn->contents;
+ dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+ for (; dyncon < dynconend; dyncon++)
+ {
+ Elf_Internal_Dyn dyn;
+ asection *s;
+
+ bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
+
+ switch (dyn.d_tag)
+ {
+ default:
+ continue;
+
+ case DT_PLTGOT:
+ dyn.d_un.d_ptr = htab->sgot->output_section->vma;
+ break;
+
+ case DT_JMPREL:
+ dyn.d_un.d_ptr = htab->srelplt->output_section->vma;
+ break;
+
+ case DT_PLTRELSZ:
+ s = htab->srelplt->output_section;
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val = s->_cooked_size;
+ else
+ dyn.d_un.d_val = s->_raw_size;
+ break;
+
+ case DT_RELASZ:
+ /* The procedure linkage table relocs (DT_JMPREL) should
+ not be included in the overall relocs (DT_RELA).
+ Therefore, we override the DT_RELASZ entry here to
+ make it not include the JMPREL relocs. Since the
+ linker script arranges for .rela.plt to follow all
+ other relocation sections, we don't have to worry
+ about changing the DT_RELA entry. */
+ s = htab->srelplt->output_section;
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val -= s->_cooked_size;
+ else
+ dyn.d_un.d_val -= s->_raw_size;
+ break;
+ }
+
+ bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
+ }
+
+ /* Fill in the special first entry in the procedure linkage table. */
+ if (htab->splt && htab->splt->_raw_size > 0)
+ {
+ /* fill in blueprint for plt 0 entry */
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD0,
+ htab->splt->contents );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD1,
+ htab->splt->contents +4 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD3,
+ htab->splt->contents +12 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD4,
+ htab->splt->contents +16 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD5,
+ htab->splt->contents +20 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD6,
+ htab->splt->contents + 24);
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD7,
+ htab->splt->contents + 28 );
+ /* Fixup relative address to start of GOT */
+ bfd_put_32 (output_bfd,
+ (htab->sgotplt->output_section->vma +
+ htab->sgotplt->output_offset
+ - htab->splt->output_section->vma - 6)/2,
+ htab->splt->contents + 8);
+ }
+ elf_section_data (htab->splt->output_section)
+ ->this_hdr.sh_entsize = PLT_ENTRY_SIZE;
+ }
+
+ if (htab->sgotplt)
+ {
+ /* Fill in the first three entries in the global offset table. */
+ if (htab->sgotplt->_raw_size > 0)
+ {
+ bfd_put_64 (output_bfd,
+ (sdyn == NULL ? (bfd_vma) 0
+ : sdyn->output_section->vma + sdyn->output_offset),
+ htab->sgotplt->contents);
+ /* One entry for shared object struct ptr. */
+ bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 8);
+ /* One entry for _dl_runtime_resolve. */
+ bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 12);
+ }
+
+ elf_section_data (htab->sgot->output_section)
+ ->this_hdr.sh_entsize = 8;
+ }
+ return true;
+}
+
+static boolean
+elf_s390_object_p (abfd)
+ bfd *abfd;
+{
+ return bfd_default_set_arch_mach (abfd, bfd_arch_s390, bfd_mach_s390_64);
+}
+
+/*
+ * Why was the hash table entry size definition changed from
+ * ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
+ * this is the only reason for the s390_elf64_size_info structure.
+ */
+
+const struct elf_size_info s390_elf64_size_info =
+{
+ sizeof (Elf64_External_Ehdr),
+ sizeof (Elf64_External_Phdr),
+ sizeof (Elf64_External_Shdr),
+ sizeof (Elf64_External_Rel),
+ sizeof (Elf64_External_Rela),
+ sizeof (Elf64_External_Sym),
+ sizeof (Elf64_External_Dyn),
+ sizeof (Elf_External_Note),
+ 8, /* hash-table entry size */
+ 1, /* internal relocations per external relocations */
+ 64, /* arch_size */
+ 8, /* file_align */
+ ELFCLASS64, EV_CURRENT,
+ bfd_elf64_write_out_phdrs,
+ bfd_elf64_write_shdrs_and_ehdr,
+ bfd_elf64_write_relocs,
+ bfd_elf64_swap_symbol_out,
+ bfd_elf64_slurp_reloc_table,
+ bfd_elf64_slurp_symbol_table,
+ bfd_elf64_swap_dyn_in,
+ bfd_elf64_swap_dyn_out,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+#define TARGET_BIG_SYM bfd_elf64_s390_vec
+#define TARGET_BIG_NAME "elf64-s390"
+#define ELF_ARCH bfd_arch_s390
+#define ELF_MACHINE_CODE EM_S390
+#define ELF_MACHINE_ALT1 EM_S390_OLD
+#define ELF_MAXPAGESIZE 0x1000
+
+#define elf_backend_size_info s390_elf64_size_info
+
+#define elf_backend_can_gc_sections 1
+#define elf_backend_can_refcount 1
+#define elf_backend_want_got_plt 1
+#define elf_backend_plt_readonly 1
+#define elf_backend_want_plt_sym 0
+#define elf_backend_got_header_size 24
+#define elf_backend_plt_header_size PLT_ENTRY_SIZE
+#define elf_backend_rela_normal 1
+
+#define elf_info_to_howto elf_s390_info_to_howto
+
+#define bfd_elf64_bfd_is_local_label_name elf_s390_is_local_label_name
+#define bfd_elf64_bfd_link_hash_table_create elf_s390_link_hash_table_create
+#define bfd_elf64_bfd_reloc_type_lookup elf_s390_reloc_type_lookup
+
+#define elf_backend_adjust_dynamic_symbol elf_s390_adjust_dynamic_symbol
+#define elf_backend_check_relocs elf_s390_check_relocs
+#define elf_backend_copy_indirect_symbol elf_s390_copy_indirect_symbol
+#define elf_backend_create_dynamic_sections elf_s390_create_dynamic_sections
+#define elf_backend_finish_dynamic_sections elf_s390_finish_dynamic_sections
+#define elf_backend_finish_dynamic_symbol elf_s390_finish_dynamic_symbol
+#define elf_backend_gc_mark_hook elf_s390_gc_mark_hook
+#define elf_backend_gc_sweep_hook elf_s390_gc_sweep_hook
+#define elf_backend_reloc_type_class elf_s390_reloc_type_class
+#define elf_backend_relocate_section elf_s390_relocate_section
+#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
+#define elf_backend_reloc_type_class elf_s390_reloc_type_class
+
+#define elf_backend_object_p elf_s390_object_p
+
+#include "elf64-target.h"
diff --git a/contrib/binutils/bfd/elf64-sparc.c b/contrib/binutils/bfd/elf64-sparc.c
index 78d2a56..d04a1d3 100644
--- a/contrib/binutils/bfd/elf64-sparc.c
+++ b/contrib/binutils/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/contrib/binutils/bfd/elf64-x86-64.c b/contrib/binutils/bfd/elf64-x86-64.c
index 61d2c6e..b980344 100644
--- a/contrib/binutils/bfd/elf64-x86-64.c
+++ b/contrib/binutils/bfd/elf64-x86-64.c
@@ -1,5 +1,5 @@
/* X86-64 specific support for 64-bit ELF
- Copyright 2000, 2001 Free Software Foundation, Inc.
+ Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Jan Hubicka <jh@suse.cz>.
This file is part of BFD, the Binary File Descriptor library.
@@ -20,13 +20,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
+#include "bfdlink.h"
#include "libbfd.h"
#include "elf-bfd.h"
#include "elf/x86-64.h"
/* We use only the RELA entries. */
-#define USE_RELA
+#define USE_RELA 1
/* In case we're on a 32-bit machine, construct a 64-bit "-1" value. */
#define MINUS_ONE (~ (bfd_vma) 0)
@@ -127,6 +128,12 @@ static void elf64_x86_64_info_to_howto
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));
+static boolean create_got_section
+ PARAMS((bfd *, struct bfd_link_info *));
+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 *));
static boolean elf64_x86_64_check_relocs
PARAMS ((bfd *, struct bfd_link_info *, asection *sec,
const Elf_Internal_Rela *));
@@ -138,11 +145,15 @@ static boolean elf64_x86_64_gc_sweep_hook
PARAMS ((bfd *, struct bfd_link_info *, asection *,
const Elf_Internal_Rela *));
-static struct bfd_hash_entry *elf64_x86_64_link_hash_newfunc
+static struct bfd_hash_entry *link_hash_newfunc
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
static boolean elf64_x86_64_adjust_dynamic_symbol
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+static boolean allocate_dynrelocs
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean readonly_dynrelocs
+ PARAMS ((struct elf_link_hash_entry *, PTR));
static boolean elf64_x86_64_size_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
static boolean elf64_x86_64_relocate_section
@@ -235,53 +246,54 @@ static const bfd_byte elf64_x86_64_plt_entry[PLT_ENTRY_SIZE] =
};
/* The x86-64 linker needs to keep track of the number of relocs that
- it decides to copy in check_relocs for each symbol. This is so
- that it can discard PC relative relocs if it doesn't need them when
- linking with -Bsymbolic. We store the information in a field
- extending the regular ELF linker hash table. */
+ it decides to copy as dynamic relocs in check_relocs for each symbol.
+ This is so that it can later discard them if they are found to be
+ unnecessary. We store the information in a field extending the
+ regular ELF linker hash table. */
-/* This structure keeps track of the number of PC relative relocs we
- have copied for a given symbol. */
-
-struct elf64_x86_64_pcrel_relocs_copied
+struct elf64_x86_64_dyn_relocs
{
/* Next section. */
- struct elf64_x86_64_pcrel_relocs_copied *next;
- /* A section in dynobj. */
- asection *section;
- /* Number of relocs copied in this section. */
+ struct elf64_x86_64_dyn_relocs *next;
+
+ /* The input section of the reloc. */
+ asection *sec;
+
+ /* Total number of relocs copied for the input section. */
bfd_size_type count;
+
+ /* Number of pc-relative relocs copied for the input section. */
+ bfd_size_type pc_count;
};
/* x86-64 ELF linker hash entry. */
struct elf64_x86_64_link_hash_entry
{
- struct elf_link_hash_entry root;
+ struct elf_link_hash_entry elf;
- /* Number of PC relative relocs copied for this symbol. */
- struct elf64_x86_64_pcrel_relocs_copied *pcrel_relocs_copied;
+ /* Track dynamic relocs copied for this symbol. */
+ struct elf64_x86_64_dyn_relocs *dyn_relocs;
};
-/* x86-64 ELF linker hash table. */
+/* x86-64 ELF linker hash table. */
struct elf64_x86_64_link_hash_table
{
- struct elf_link_hash_table root;
-};
-
-/* Declare this now that the above structures are defined. */
+ struct elf_link_hash_table elf;
-static boolean elf64_x86_64_discard_copies
- PARAMS ((struct elf64_x86_64_link_hash_entry *, PTR));
-
-/* Traverse an x86-64 ELF linker hash table. */
+ /* Short-cuts to get to dynamic linker sections. */
+ asection *sgot;
+ asection *sgotplt;
+ asection *srelgot;
+ asection *splt;
+ asection *srelplt;
+ asection *sdynbss;
+ asection *srelbss;
-#define elf64_x86_64_link_hash_traverse(table, func, info) \
- (elf_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
- (info)))
+ /* Small local sym to section mapping cache. */
+ struct sym_sec_cache sym_sec;
+};
/* Get the x86-64 ELF linker hash table from a link_info structure. */
@@ -291,33 +303,32 @@ static boolean elf64_x86_64_discard_copies
/* Create an entry in an x86-64 ELF linker hash table. */
static struct bfd_hash_entry *
-elf64_x86_64_link_hash_newfunc (entry, table, string)
+link_hash_newfunc (entry, table, string)
struct bfd_hash_entry *entry;
struct bfd_hash_table *table;
const char *string;
{
- struct elf64_x86_64_link_hash_entry *ret =
- (struct elf64_x86_64_link_hash_entry *) entry;
-
/* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct elf64_x86_64_link_hash_entry *) NULL)
- ret = ((struct elf64_x86_64_link_hash_entry *)
- bfd_hash_allocate (table,
- sizeof (struct elf64_x86_64_link_hash_entry)));
- if (ret == (struct elf64_x86_64_link_hash_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
+ subclass. */
+ if (entry == NULL)
+ {
+ entry = bfd_hash_allocate (table,
+ sizeof (struct elf64_x86_64_link_hash_entry));
+ if (entry == NULL)
+ return entry;
+ }
/* Call the allocation method of the superclass. */
- ret = ((struct elf64_x86_64_link_hash_entry *)
- _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret != (struct elf64_x86_64_link_hash_entry *) NULL)
+ entry = _bfd_elf_link_hash_newfunc (entry, table, string);
+ if (entry != NULL)
{
- ret->pcrel_relocs_copied = NULL;
+ struct elf64_x86_64_link_hash_entry *eh;
+
+ eh = (struct elf64_x86_64_link_hash_entry *) entry;
+ eh->dyn_relocs = NULL;
}
- return (struct bfd_hash_entry *) ret;
+ return entry;
}
/* Create an X86-64 ELF linker hash table. */
@@ -329,18 +340,135 @@ 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));
- if (ret == (struct elf64_x86_64_link_hash_table *) NULL)
+ ret = (struct elf64_x86_64_link_hash_table *) bfd_alloc (abfd, amt);
+ if (ret == NULL)
return NULL;
- if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
- elf64_x86_64_link_hash_newfunc))
+ if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
{
bfd_release (abfd, ret);
return NULL;
}
- return &ret->root.root;
+ ret->sgot = NULL;
+ ret->sgotplt = NULL;
+ ret->srelgot = NULL;
+ ret->splt = NULL;
+ ret->srelplt = NULL;
+ ret->sdynbss = NULL;
+ ret->srelbss = NULL;
+ ret->sym_sec.abfd = NULL;
+
+ return &ret->elf.root;
+}
+
+/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
+ shortcuts to them in our hash table. */
+
+static boolean
+create_got_section (dynobj, info)
+ bfd *dynobj;
+ struct bfd_link_info *info;
+{
+ struct elf64_x86_64_link_hash_table *htab;
+
+ if (! _bfd_elf_create_got_section (dynobj, info))
+ return false;
+
+ htab = elf64_x86_64_hash_table (info);
+ htab->sgot = bfd_get_section_by_name (dynobj, ".got");
+ htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+ if (!htab->sgot || !htab->sgotplt)
+ abort ();
+
+ htab->srelgot = bfd_make_section (dynobj, ".rela.got");
+ if (htab->srelgot == NULL
+ || ! bfd_set_section_flags (dynobj, htab->srelgot,
+ (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, htab->srelgot, 3))
+ return false;
+ return true;
+}
+
+/* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
+ .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
+ hash table. */
+
+static boolean
+elf64_x86_64_create_dynamic_sections (dynobj, info)
+ bfd *dynobj;
+ struct bfd_link_info *info;
+{
+ struct elf64_x86_64_link_hash_table *htab;
+
+ htab = elf64_x86_64_hash_table (info);
+ if (!htab->sgot && !create_got_section (dynobj, info))
+ return false;
+
+ if (!_bfd_elf_create_dynamic_sections (dynobj, info))
+ return false;
+
+ htab->splt = bfd_get_section_by_name (dynobj, ".plt");
+ htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
+ htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+ if (!info->shared)
+ htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+
+ if (!htab->splt || !htab->srelplt || !htab->sdynbss
+ || (!info->shared && !htab->srelbss))
+ abort ();
+
+ return true;
+}
+
+/* Copy the extra info we tack onto an elf_link_hash_entry. */
+
+static void
+elf64_x86_64_copy_indirect_symbol (dir, ind)
+ struct elf_link_hash_entry *dir, *ind;
+{
+ struct elf64_x86_64_link_hash_entry *edir, *eind;
+
+ edir = (struct elf64_x86_64_link_hash_entry *) dir;
+ eind = (struct elf64_x86_64_link_hash_entry *) ind;
+
+ if (eind->dyn_relocs != NULL)
+ {
+ if (edir->dyn_relocs != NULL)
+ {
+ struct elf64_x86_64_dyn_relocs **pp;
+ struct elf64_x86_64_dyn_relocs *p;
+
+ if (ind->root.type == bfd_link_hash_indirect)
+ abort ();
+
+ /* Add reloc counts against the weak sym to the strong sym
+ list. Merge any entries against the same section. */
+ for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
+ {
+ struct elf64_x86_64_dyn_relocs *q;
+
+ for (q = edir->dyn_relocs; q != NULL; q = q->next)
+ if (q->sec == p->sec)
+ {
+ q->pc_count += p->pc_count;
+ q->count += p->count;
+ *pp = p->next;
+ break;
+ }
+ if (q == NULL)
+ pp = &p->next;
+ }
+ *pp = edir->dyn_relocs;
+ }
+
+ edir->dyn_relocs = eind->dyn_relocs;
+ eind->dyn_relocs = NULL;
+ }
+
+ _bfd_elf_link_hash_copy_indirect (dir, ind);
}
static boolean
@@ -353,8 +481,8 @@ elf64_x86_64_elf_object_p (abfd)
}
/* Look through the relocs for a section during the first phase, and
- allocate space in the global offset table or procedure linkage
- table. */
+ calculate needed space in the global offset table, procedure
+ linkage table, and dynamic reloc sections. */
static boolean
elf64_x86_64_check_relocs (abfd, info, sec, relocs)
@@ -363,25 +491,22 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
asection *sec;
const Elf_Internal_Rela *relocs;
{
- bfd *dynobj;
+ struct elf64_x86_64_link_hash_table *htab;
Elf_Internal_Shdr *symtab_hdr;
struct elf_link_hash_entry **sym_hashes;
- bfd_signed_vma *local_got_refcounts;
const Elf_Internal_Rela *rel;
const Elf_Internal_Rela *rel_end;
- asection *sgot;
- asection *srelgot;
asection *sreloc;
if (info->relocateable)
return true;
- dynobj = elf_hash_table (info)->dynobj;
+ htab = elf64_x86_64_hash_table (info);
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (abfd);
- local_got_refcounts = elf_local_got_refcounts (abfd);
- sgot = srelgot = sreloc = NULL;
+ sreloc = NULL;
+
rel_end = relocs + sec->reloc_count;
for (rel = relocs; rel < rel_end; rel++)
{
@@ -389,75 +514,35 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
struct elf_link_hash_entry *h;
r_symndx = ELF64_R_SYM (rel->r_info);
+
+ if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
+ {
+ (*_bfd_error_handler) (_("%s: bad symbol index: %d"),
+ bfd_archive_filename (abfd),
+ r_symndx);
+ return false;
+ }
+
if (r_symndx < symtab_hdr->sh_info)
h = NULL;
else
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
- /* Some relocs require a global offset table. */
- if (dynobj == NULL)
- {
- switch (ELF64_R_TYPE (rel->r_info))
- {
- case R_X86_64_GOT32:
- case R_X86_64_GOTPCREL:
- elf_hash_table (info)->dynobj = dynobj = abfd;
- if (! _bfd_elf_create_got_section (dynobj, info))
- return false;
- break;
- }
- }
-
switch (ELF64_R_TYPE (rel->r_info))
{
- case R_X86_64_GOTPCREL:
case R_X86_64_GOT32:
+ case R_X86_64_GOTPCREL:
/* This symbol requires a global offset table entry. */
-
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
-
- if (srelgot == NULL && (h != NULL || info->shared))
- {
- srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
- if (srelgot == NULL)
- {
- srelgot = bfd_make_section (dynobj, ".rela.got");
- if (srelgot == NULL
- || ! bfd_set_section_flags (dynobj, srelgot,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_LINKER_CREATED
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, srelgot, 3))
- return false;
- }
- }
-
if (h != NULL)
{
- if (h->got.refcount == 0)
- {
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (! bfd_elf64_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- sgot->_raw_size += GOT_ENTRY_SIZE;
- srelgot->_raw_size += sizeof (Elf64_External_Rela);
- }
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;
@@ -470,19 +555,18 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
return false;
elf_local_got_refcounts (abfd) = local_got_refcounts;
}
- if (local_got_refcounts[r_symndx] == 0)
- {
- sgot->_raw_size += GOT_ENTRY_SIZE;
- if (info->shared)
- {
- /* If we are generating a shared object, we need to
- output a R_X86_64_RELATIVE reloc so that the dynamic
- linker can adjust this GOT entry. */
- srelgot->_raw_size += sizeof (Elf64_External_Rela);
- }
- }
local_got_refcounts[r_symndx] += 1;
}
+ /* Fall through */
+
+ //case R_X86_64_GOTPCREL:
+ if (htab->sgot == NULL)
+ {
+ if (htab->elf.dynobj == NULL)
+ htab->elf.dynobj = abfd;
+ if (!create_got_section (htab->elf.dynobj, info))
+ return false;
+ }
break;
case R_X86_64_PLT32:
@@ -507,9 +591,23 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
case R_X86_64_32:
case R_X86_64_64:
case R_X86_64_32S:
+ case R_X86_64_PC8:
+ case R_X86_64_PC16:
case R_X86_64_PC32:
- if (h != NULL)
- h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
+ if (h != NULL && !info->shared)
+ {
+ /* If this reloc is in a read-only section, we might
+ need a copy reloc. We can't check reliably at this
+ stage whether the section is read-only, as input
+ sections have not yet been mapped to output sections.
+ Tentatively set the flag for now, and correct in
+ adjust_dynamic_symbol. */
+ h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
+
+ /* We may need a .plt entry if the function this reloc
+ refers to is in a shared lib. */
+ h->plt.refcount += 1;
+ }
/* If we are creating a shared library, and this is a reloc
against a global symbol, or a non PC relative reloc
@@ -520,27 +618,45 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
including in the link (i.e., DEF_REGULAR is set). At
this point we have not seen all the input files, so it is
possible that DEF_REGULAR is not set now but will be set
- later (it is never cleared). We account for that
- possibility below by storing information in the
- pcrel_relocs_copied field of the hash table entry.
- A similar situation occurs when creating shared libraries
- and symbol visibility changes render the symbol local. */
- if (info->shared
- && (sec->flags & SEC_ALLOC) != 0
- && (((ELF64_R_TYPE (rel->r_info) != R_X86_64_PC8)
- && (ELF64_R_TYPE (rel->r_info) != R_X86_64_PC16)
- && (ELF64_R_TYPE (rel->r_info) != R_X86_64_PC32))
- || (h != NULL
- && (! info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+ later (it is never cleared). In case of a weak definition,
+ DEF_REGULAR may be cleared later by a strong definition in
+ a shared library. We account for that possibility below by
+ storing information in the relocs_copied field of the hash
+ table entry. A similar situation occurs when creating
+ shared libraries and symbol visibility changes render the
+ symbol local.
+
+ If on the other hand, we are creating an executable, we
+ may need to keep relocations for symbols satisfied by a
+ dynamic library if we manage to avoid copy relocs for the
+ symbol. */
+ if ((info->shared
+ && (sec->flags & SEC_ALLOC) != 0
+ && (((ELF64_R_TYPE (rel->r_info) != R_X86_64_PC8)
+ && (ELF64_R_TYPE (rel->r_info) != R_X86_64_PC16)
+ && (ELF64_R_TYPE (rel->r_info) != R_X86_64_PC32))
+ || (h != NULL
+ && (! info->symbolic
+ || h->root.type == bfd_link_hash_defweak
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+ || (!info->shared
+ && (sec->flags & SEC_ALLOC) != 0
+ && h != NULL
+ && (h->root.type == bfd_link_hash_defweak
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)))
{
- /* When creating a shared object, we must copy these
- reloc types into the output file. We create a reloc
- section in dynobj and make room for this reloc. */
+ struct elf64_x86_64_dyn_relocs *p;
+ struct elf64_x86_64_dyn_relocs **head;
+
+ /* We must copy these reloc types into the output file.
+ Create a reloc section in dynobj and make room for
+ this reloc. */
if (sreloc == NULL)
{
const char *name;
+ bfd *dynobj;
name = (bfd_elf_string_from_elf_section
(abfd,
@@ -549,9 +665,19 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
if (name == NULL)
return false;
- BFD_ASSERT (strncmp (name, ".rela", 5) == 0
- && strcmp (bfd_get_section_name (abfd, sec),
- name + 5) == 0);
+ if (strncmp (name, ".rela", 5) != 0
+ || strcmp (bfd_get_section_name (abfd, sec),
+ name + 5) != 0)
+ {
+ (*_bfd_error_handler)
+ (_("%s: bad relocation section name `%s\'"),
+ bfd_archive_filename (abfd), name);
+ }
+
+ if (htab->elf.dynobj == NULL)
+ htab->elf.dynobj = abfd;
+
+ dynobj = htab->elf.dynobj;
sreloc = bfd_get_section_by_name (dynobj, name);
if (sreloc == NULL)
@@ -568,46 +694,51 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
|| ! bfd_set_section_alignment (dynobj, sreloc, 3))
return false;
}
- if (sec->flags & SEC_READONLY)
- info->flags |= DF_TEXTREL;
+ elf_section_data (sec)->sreloc = sreloc;
}
- sreloc->_raw_size += sizeof (Elf64_External_Rela);
-
- /* If this is a global symbol, we count the number of PC
- relative relocations we have entered for this symbol,
- so that we can discard them later as necessary. Note
- that this function is only called if we are using an
- elf64_x86_64 linker hash table, which means that h is
- really a pointer to an elf64_x86_64_link_hash_entry. */
- if (h != NULL
- && ((ELF64_R_TYPE (rel->r_info) == R_X86_64_PC8)
- || (ELF64_R_TYPE (rel->r_info) == R_X86_64_PC16)
- || (ELF64_R_TYPE (rel->r_info) == R_X86_64_PC32)))
+ /* If this is a global symbol, we count the number of
+ relocations we need for this symbol. */
+ if (h != NULL)
{
- struct elf64_x86_64_link_hash_entry *eh;
- struct elf64_x86_64_pcrel_relocs_copied *p;
-
- eh = (struct elf64_x86_64_link_hash_entry *) h;
+ head = &((struct elf64_x86_64_link_hash_entry *) h)->dyn_relocs;
+ }
+ else
+ {
+ /* Track dynamic relocs needed for local syms too.
+ We really need local syms available to do this
+ easily. Oh well. */
+
+ asection *s;
+ s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
+ sec, r_symndx);
+ if (s == NULL)
+ return false;
- for (p = eh->pcrel_relocs_copied; p != NULL; p = p->next)
- if (p->section == sreloc)
- break;
+ head = ((struct elf64_x86_64_dyn_relocs **)
+ &elf_section_data (s)->local_dynrel);
+ }
+ p = *head;
+ if (p == NULL || p->sec != sec)
+ {
+ bfd_size_type amt = sizeof *p;
+ p = ((struct elf64_x86_64_dyn_relocs *)
+ bfd_alloc (htab->elf.dynobj, amt));
if (p == NULL)
- {
- p = ((struct elf64_x86_64_pcrel_relocs_copied *)
- bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
- if (p == NULL)
- return false;
- p->next = eh->pcrel_relocs_copied;
- eh->pcrel_relocs_copied = p;
- p->section = sreloc;
- p->count = 0;
- }
-
- ++p->count;
+ return false;
+ p->next = *head;
+ *head = p;
+ p->sec = sec;
+ p->count = 0;
+ p->pc_count = 0;
}
+
+ p->count += 1;
+ if (ELF64_R_TYPE (rel->r_info) == R_X86_64_PC8
+ || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC16
+ || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC32)
+ p->pc_count += 1;
}
break;
@@ -624,6 +755,9 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
if (!_bfd_elf64_gc_record_vtentry (abfd, sec, h, rel->r_addend))
return false;
break;
+
+ default:
+ break;
}
}
@@ -637,7 +771,7 @@ static asection *
elf64_x86_64_gc_mark_hook (abfd, info, rel, h, sym)
bfd *abfd;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
- Elf_Internal_Rela *rel ATTRIBUTE_UNUSED;
+ Elf_Internal_Rela *rel;
struct elf_link_hash_entry *h;
Elf_Internal_Sym *sym;
{
@@ -677,7 +811,7 @@ elf64_x86_64_gc_mark_hook (abfd, info, rel, h, sym)
static boolean
elf64_x86_64_gc_sweep_hook (abfd, info, sec, relocs)
bfd *abfd;
- struct bfd_link_info *info ATTRIBUTE_UNUSED;
+ struct bfd_link_info *info;
asection *sec;
const Elf_Internal_Rela *relocs;
{
@@ -687,21 +821,13 @@ elf64_x86_64_gc_sweep_hook (abfd, info, sec, relocs)
const Elf_Internal_Rela *rel, *relend;
unsigned long r_symndx;
struct elf_link_hash_entry *h;
- bfd *dynobj;
- asection *sgot;
- asection *srelgot;
+
+ elf_section_data (sec)->local_dynrel = NULL;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (abfd);
local_got_refcounts = elf_local_got_refcounts (abfd);
- dynobj = elf_hash_table (info)->dynobj;
- if (dynobj == NULL)
- return true;
-
- sgot = bfd_get_section_by_name (dynobj, ".got");
- srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-
relend = relocs + sec->reloc_count;
for (rel = relocs; rel < relend; rel++)
switch (ELF64_R_TYPE (rel->r_info))
@@ -713,30 +839,53 @@ elf64_x86_64_gc_sweep_hook (abfd, info, sec, relocs)
{
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
if (h->got.refcount > 0)
- {
- h->got.refcount -= 1;
- if (h->got.refcount == 0)
- {
- sgot->_raw_size -= GOT_ENTRY_SIZE;
- srelgot->_raw_size -= sizeof (Elf64_External_Rela);
- }
- }
+ h->got.refcount -= 1;
}
else if (local_got_refcounts != NULL)
{
if (local_got_refcounts[r_symndx] > 0)
- {
- local_got_refcounts[r_symndx] -= 1;
- if (local_got_refcounts[r_symndx] == 0)
- {
- sgot->_raw_size -= GOT_ENTRY_SIZE;
- if (info->shared)
- srelgot->_raw_size -= sizeof (Elf64_External_Rela);
- }
- }
+ local_got_refcounts[r_symndx] -= 1;
}
break;
+ 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:
+ case R_X86_64_PC8:
+ case R_X86_64_PC16:
+ case R_X86_64_PC32:
+ r_symndx = ELF64_R_SYM (rel->r_info);
+ if (r_symndx >= symtab_hdr->sh_info)
+ {
+ struct elf64_x86_64_link_hash_entry *eh;
+ struct elf64_x86_64_dyn_relocs **pp;
+ struct elf64_x86_64_dyn_relocs *p;
+
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ if (!info->shared && h->plt.refcount > 0)
+ h->plt.refcount -= 1;
+
+ eh = (struct elf64_x86_64_link_hash_entry *) h;
+
+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
+ if (p->sec == sec)
+ {
+ if (ELF64_R_TYPE (rel->r_info) == R_X86_64_PC8
+ || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC16
+ || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC32)
+ p->pc_count -= 1;
+ p->count -= 1;
+ if (p->count == 0)
+ *pp = p->next;
+ break;
+ }
+ }
+ break;
+
+
case R_X86_64_PLT32:
r_symndx = ELF64_R_SYM (rel->r_info);
if (r_symndx >= symtab_hdr->sh_info)
@@ -765,33 +914,24 @@ elf64_x86_64_adjust_dynamic_symbol (info, h)
struct bfd_link_info *info;
struct elf_link_hash_entry *h;
{
- bfd *dynobj;
+ struct elf64_x86_64_link_hash_table *htab;
+ struct elf64_x86_64_link_hash_entry * eh;
+ struct elf64_x86_64_dyn_relocs *p;
asection *s;
unsigned int power_of_two;
- dynobj = elf_hash_table (info)->dynobj;
-
- /* Make sure we know what is going on here. */
- BFD_ASSERT (dynobj != NULL
- && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
- || h->weakdef != NULL
- || ((h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_REF_REGULAR) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)));
-
/* 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. */
if (h->type == STT_FUNC
|| (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
{
- 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)
- || (info->shared && h->plt.refcount <= 0))
+ if (h->plt.refcount <= 0
+ || (! 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->root.type != bfd_link_hash_undefweak
+ && h->root.type != bfd_link_hash_undefined))
{
/* This case can occur if we saw a PLT32 reloc in an input
file, but the symbol was never referred to by a dynamic
@@ -800,55 +940,16 @@ elf64_x86_64_adjust_dynamic_symbol (info, h)
linkage table, and we can just do a PC32 reloc instead. */
h->plt.offset = (bfd_vma) -1;
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
- return true;
- }
-
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (! bfd_elf64_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- s = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (s != NULL);
-
- /* If this is the first .plt entry, make room for the special
- first entry. */
- if (s->_raw_size == 0)
- s->_raw_size = PLT_ENTRY_SIZE;
-
- /* If this symbol is not defined in a regular file, and we are
- not generating a shared library, then set the symbol to this
- location in the .plt. This is required to make function
- pointers compare as equal between the normal executable and
- the shared library. */
- if (! info->shared
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
- {
- h->root.u.def.section = s;
- h->root.u.def.value = s->_raw_size;
}
- h->plt.offset = s->_raw_size;
-
- /* Make room for this entry. */
- s->_raw_size += PLT_ENTRY_SIZE;
-
- /* We also need to make an entry in the .got.plt section, which
- will be placed in the .got section by the linker script. */
- s = bfd_get_section_by_name (dynobj, ".got.plt");
- BFD_ASSERT (s != NULL);
- s->_raw_size += GOT_ENTRY_SIZE;
-
- /* We also need to make an entry in the .rela.plt section. */
- s = bfd_get_section_by_name (dynobj, ".rela.plt");
- BFD_ASSERT (s != NULL);
- s->_raw_size += sizeof (Elf64_External_Rela);
-
return true;
}
else
+ /* It's possible that we incorrectly decided a .plt reloc was
+ needed for an R_X86_64_PC32 reloc to a non-function sym in
+ check_relocs. We can't decide accurately between function and
+ non-function syms in check-relocs; Objects loaded later in
+ the link may change h->type. So fix it now. */
h->plt.offset = (bfd_vma) -1;
/* If this is a weak symbol, and there is a real definition, the
@@ -878,6 +979,29 @@ elf64_x86_64_adjust_dynamic_symbol (info, h)
if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
return true;
+ /* If -z nocopyreloc was given, we won't generate them either. */
+ if (info->nocopyreloc)
+ {
+ h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
+ return true;
+ }
+
+ eh = (struct elf64_x86_64_link_hash_entry *) h;
+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ {
+ s = p->sec->output_section;
+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
+ break;
+ }
+
+ /* 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. */
+ if (p == NULL)
+ {
+ h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
+ return true;
+ }
+
/* We must allocate the symbol in our .dynbss section, which will
become part of the .bss section of the executable. There will be
an entry for this symbol in the .dynsym section. The dynamic
@@ -888,20 +1012,14 @@ elf64_x86_64_adjust_dynamic_symbol (info, h)
both the dynamic object and the regular object will refer to the
same memory location for the variable. */
- s = bfd_get_section_by_name (dynobj, ".dynbss");
- BFD_ASSERT (s != NULL);
+ htab = elf64_x86_64_hash_table (info);
/* 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. We need to remember the offset into the
- .rela.bss section we are going to use. */
+ runtime process image. */
if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
{
- asection *srel;
-
- srel = bfd_get_section_by_name (dynobj, ".rela.bss");
- BFD_ASSERT (srel != NULL);
- srel->_raw_size += sizeof (Elf64_External_Rela);
+ htab->srelbss->_raw_size += sizeof (Elf64_External_Rela);
h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
}
@@ -915,10 +1033,11 @@ elf64_x86_64_adjust_dynamic_symbol (info, h)
power_of_two = 4;
/* Apply the required alignment. */
+ s = htab->sdynbss;
s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two));
- if (power_of_two > bfd_get_section_alignment (dynobj, s))
+ if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s))
{
- if (! bfd_set_section_alignment (dynobj, s, power_of_two))
+ if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two))
return false;
}
@@ -932,6 +1051,223 @@ elf64_x86_64_adjust_dynamic_symbol (info, h)
return true;
}
+/* This is the condition under which elf64_x86_64_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
+ initializing any .plt and .got entries in elf64_x86_64_relocate_section. */
+#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
+ ((DYN) \
+ && ((INFO)->shared \
+ || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
+ && ((H)->dynindx != -1 \
+ || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
+
+/* Allocate space in .plt, .got and associated reloc sections for
+ dynamic relocs. */
+
+static boolean
+allocate_dynrelocs (h, inf)
+ struct elf_link_hash_entry *h;
+ PTR inf;
+{
+ struct bfd_link_info *info;
+ struct elf64_x86_64_link_hash_table *htab;
+ struct elf64_x86_64_link_hash_entry *eh;
+ struct elf64_x86_64_dyn_relocs *p;
+
+ if (h->root.type == bfd_link_hash_indirect)
+ return true;
+
+ if (h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ info = (struct bfd_link_info *) inf;
+ htab = elf64_x86_64_hash_table (info);
+
+ if (htab->elf.dynamic_sections_created
+ && h->plt.refcount > 0)
+ {
+ /* Make sure this symbol is output as a dynamic symbol.
+ Undefined weak syms won't yet be marked as dynamic. */
+ if (h->dynindx == -1
+ && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+ {
+ if (! bfd_elf64_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
+ {
+ asection *s = htab->splt;
+
+ /* If this is the first .plt entry, make room for the special
+ first entry. */
+ if (s->_raw_size == 0)
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ h->plt.offset = s->_raw_size;
+
+ /* If this symbol is not defined in a regular file, and we are
+ not generating a shared library, then set the symbol to this
+ location in the .plt. This is required to make function
+ pointers compare as equal between the normal executable and
+ the shared library. */
+ if (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = h->plt.offset;
+ }
+
+ /* Make room for this entry. */
+ s->_raw_size += PLT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .got.plt section, which
+ will be placed in the .got section by the linker script. */
+ htab->sgotplt->_raw_size += GOT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .rela.plt section. */
+ htab->srelplt->_raw_size += sizeof (Elf64_External_Rela);
+ }
+ else
+ {
+ h->plt.offset = (bfd_vma) -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ }
+ }
+ else
+ {
+ h->plt.offset = (bfd_vma) -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ }
+
+ if (h->got.refcount > 0)
+ {
+ asection *s;
+ boolean dyn;
+
+ /* Make sure this symbol is output as a dynamic symbol.
+ Undefined weak syms won't yet be marked as dynamic. */
+ if (h->dynindx == -1
+ && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+ {
+ if (! bfd_elf64_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ s = htab->sgot;
+ h->got.offset = s->_raw_size;
+ s->_raw_size += GOT_ENTRY_SIZE;
+ dyn = htab->elf.dynamic_sections_created;
+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h))
+ htab->srelgot->_raw_size += sizeof (Elf64_External_Rela);
+ }
+ else
+ h->got.offset = (bfd_vma) -1;
+
+ eh = (struct elf64_x86_64_link_hash_entry *) h;
+ if (eh->dyn_relocs == NULL)
+ return true;
+
+ /* In the shared -Bsymbolic case, discard space allocated for
+ dynamic pc-relative relocs against symbols which turn out to be
+ defined in regular objects. For the normal shared case, discard
+ space for pc-relative relocs that have become local due to symbol
+ visibility changes. */
+
+ if (info->shared)
+ {
+ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
+ && ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
+ || info->symbolic))
+ {
+ struct elf64_x86_64_dyn_relocs **pp;
+
+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+ {
+ p->count -= p->pc_count;
+ p->pc_count = 0;
+ if (p->count == 0)
+ *pp = p->next;
+ else
+ pp = &p->next;
+ }
+ }
+ }
+ else
+ {
+ /* For the non-shared case, discard space for relocs against
+ symbols which turn out to need copy relocs or are not
+ dynamic. */
+
+ if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
+ && (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ || (htab->elf.dynamic_sections_created
+ && (h->root.type == bfd_link_hash_undefweak
+ || h->root.type == bfd_link_hash_undefined))))
+ {
+ /* Make sure this symbol is output as a dynamic symbol.
+ Undefined weak syms won't yet be marked as dynamic. */
+ if (h->dynindx == -1
+ && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+ {
+ if (! bfd_elf64_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ /* If that succeeded, we know we'll be keeping all the
+ relocs. */
+ if (h->dynindx != -1)
+ goto keep;
+ }
+
+ eh->dyn_relocs = NULL;
+
+ keep: ;
+ }
+
+ /* Finally, allocate space. */
+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ {
+ asection *sreloc = elf_section_data (p->sec)->sreloc;
+ sreloc->_raw_size += p->count * sizeof (Elf64_External_Rela);
+ }
+
+ return true;
+}
+
+/* Find any dynamic relocs that apply to read-only sections. */
+
+static boolean
+readonly_dynrelocs (h, inf)
+ struct elf_link_hash_entry *h;
+ PTR inf;
+{
+ struct elf64_x86_64_link_hash_entry *eh;
+ struct elf64_x86_64_dyn_relocs *p;
+
+ if (h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ eh = (struct elf64_x86_64_link_hash_entry *) h;
+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ {
+ asection *s = p->sec->output_section;
+
+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
+ {
+ struct bfd_link_info *info = (struct bfd_link_info *) inf;
+
+ info->flags |= DF_TEXTREL;
+
+ /* Not an error, just cut short the traversal. */
+ return false;
+ }
+ }
+ return true;
+}
+
/* Set the sizes of the dynamic sections. */
static boolean
@@ -939,110 +1275,140 @@ elf64_x86_64_size_dynamic_sections (output_bfd, info)
bfd *output_bfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info;
{
+ struct elf64_x86_64_link_hash_table *htab;
bfd *dynobj;
asection *s;
- boolean plt;
boolean relocs;
+ bfd *ibfd;
- dynobj = elf_hash_table (info)->dynobj;
- BFD_ASSERT (dynobj != NULL);
+ htab = elf64_x86_64_hash_table (info);
+ dynobj = htab->elf.dynobj;
+ if (dynobj == NULL)
+ abort ();
- if (elf_hash_table (info)->dynamic_sections_created)
+ if (htab->elf.dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
if (! info->shared)
{
s = bfd_get_section_by_name (dynobj, ".interp");
- BFD_ASSERT (s != NULL);
+ if (s == NULL)
+ abort ();
s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
}
}
- else
- {
- /* We may have created entries in the .rela.got section.
- However, if we are not creating the dynamic sections, we will
- not actually use these entries. Reset the size of .rela.got,
- which will cause it to get stripped from the output file
- below. */
- s = bfd_get_section_by_name (dynobj, ".rela.got");
- if (s != NULL)
- s->_raw_size = 0;
- }
- /* If this is a -Bsymbolic shared link, then we need to discard all
- PC relative relocs against symbols defined in a regular object.
- We allocated space for them in the check_relocs routine, but we
- will not fill them in in the relocate_section routine. */
- if (info->shared)
- elf64_x86_64_link_hash_traverse (elf64_x86_64_hash_table (info),
- elf64_x86_64_discard_copies,
- (PTR) info);
-
- /* The check_relocs and adjust_dynamic_symbol entry points have
- determined the sizes of the various dynamic sections. Allocate
- memory for them. */
- plt = relocs = false;
- for (s = dynobj->sections; s != NULL; s = s->next)
+ /* Set up .got offsets for local syms, and space for local dynamic
+ relocs. */
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
{
- const char *name;
- boolean strip;
+ bfd_signed_vma *local_got;
+ bfd_signed_vma *end_local_got;
+ bfd_size_type locsymcount;
+ Elf_Internal_Shdr *symtab_hdr;
+ asection *srel;
- if ((s->flags & SEC_LINKER_CREATED) == 0)
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
continue;
- /* It's OK to base decisions on the section name, because none
- of the dynobj section names depend upon the input files. */
- name = bfd_get_section_name (dynobj, s);
-
- strip = false;
- if (strcmp (name, ".plt") == 0)
+ for (s = ibfd->sections; s != NULL; s = s->next)
{
- if (s->_raw_size == 0)
- {
- /* Strip this section if we don't need it; see the
- comment below. */
- strip = true;
- }
- else
+ struct elf64_x86_64_dyn_relocs *p;
+
+ for (p = *((struct elf64_x86_64_dyn_relocs **)
+ &elf_section_data (s)->local_dynrel);
+ p != NULL;
+ p = p->next)
{
- /* Remember whether there is a PLT. */
- plt = true;
+ if (!bfd_is_abs_section (p->sec)
+ && bfd_is_abs_section (p->sec->output_section))
+ {
+ /* Input section has been discarded, either because
+ it is a copy of a linkonce section or due to
+ linker script /DISCARD/, so we'll be discarding
+ the relocs too. */
+ }
+ else if (p->count != 0)
+ {
+ srel = elf_section_data (p->sec)->sreloc;
+ srel->_raw_size += p->count * sizeof (Elf64_External_Rela);
+ if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+ info->flags |= DF_TEXTREL;
+
+ }
}
}
- else if (strncmp (name, ".rela", 5) == 0)
+
+ local_got = elf_local_got_refcounts (ibfd);
+ if (!local_got)
+ continue;
+
+ symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ locsymcount = symtab_hdr->sh_info;
+ end_local_got = local_got + locsymcount;
+ s = htab->sgot;
+ srel = htab->srelgot;
+ for (; local_got < end_local_got; ++local_got)
{
- if (s->_raw_size == 0)
+ if (*local_got > 0)
{
- /* If we don't need this section, strip it from the
- output file. This is mostly to handle .rela.bss and
- .rela.plt. We must create both sections in
- create_dynamic_sections, because they must be created
- before the linker maps input sections to output
- sections. The linker does that before
- adjust_dynamic_symbol is called, and it is that
- function which decides whether anything needs to go
- into these sections. */
- strip = true;
+ *local_got = s->_raw_size;
+ s->_raw_size += GOT_ENTRY_SIZE;
+ if (info->shared)
+ srel->_raw_size += sizeof (Elf64_External_Rela);
}
else
- {
- if (strcmp (name, ".rela.plt") != 0)
- relocs = true;
+ *local_got = (bfd_vma) -1;
+ }
+ }
- /* We use the reloc_count field as a counter if we need
- to copy relocs into the output file. */
- s->reloc_count = 0;
- }
+ /* Allocate global sym .plt and .got entries, and space for global
+ sym dynamic relocs. */
+ elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
+
+ /* We now have determined the sizes of the various dynamic sections.
+ Allocate memory for them. */
+ relocs = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ if (s == htab->splt
+ || s == htab->sgot
+ || s == htab->sgotplt)
+ {
+ /* Strip this section if we don't need it; see the
+ comment below. */
}
- else if (strncmp (name, ".got", 4) != 0)
+ else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
+ {
+ if (s->_raw_size != 0 && s != htab->srelplt)
+ relocs = true;
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ s->reloc_count = 0;
+ }
+ else
{
/* It's not one of our sections, so don't allocate space. */
continue;
}
- if (strip)
+ if (s->_raw_size == 0)
{
+ /* If we don't need this section, strip it from the
+ output file. This is mostly to handle .rela.bss and
+ .rela.plt. We must create both sections in
+ create_dynamic_sections, because they must be created
+ before the linker maps input sections to output
+ sections. The linker does that before
+ adjust_dynamic_symbol is called, and it is that
+ function which decides whether anything needs to go
+ into these sections. */
+
_bfd_strip_section_from_output (info, s);
continue;
}
@@ -1053,11 +1419,11 @@ elf64_x86_64_size_dynamic_sections (output_bfd, info)
but this way if it does, we get a R_X86_64_NONE reloc instead
of garbage. */
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
- if (s->contents == NULL && s->_raw_size != 0)
+ if (s->contents == NULL)
return false;
}
- if (elf_hash_table (info)->dynamic_sections_created)
+ if (htab->elf.dynamic_sections_created)
{
/* Add some entries to the .dynamic section. We fill in the
values later, in elf64_x86_64_finish_dynamic_sections, but we
@@ -1073,7 +1439,7 @@ elf64_x86_64_size_dynamic_sections (output_bfd, info)
return false;
}
- if (plt)
+ if (htab->splt->_raw_size != 0)
{
if (!add_dynamic_entry (DT_PLTGOT, 0)
|| !add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -1088,12 +1454,18 @@ elf64_x86_64_size_dynamic_sections (output_bfd, info)
|| !add_dynamic_entry (DT_RELASZ, 0)
|| !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
return false;
- }
- if ((info->flags & DF_TEXTREL) != 0)
- {
- if (!add_dynamic_entry (DT_TEXTREL, 0))
- return false;
+ /* If any dynamic relocs apply to a read-only section,
+ then we need a DT_TEXTREL entry. */
+ if ((info->flags & DF_TEXTREL) == 0)
+ elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
+ (PTR) info);
+
+ if ((info->flags & DF_TEXTREL) != 0)
+ {
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
+ return false;
+ }
}
}
#undef add_dynamic_entry
@@ -1101,40 +1473,6 @@ elf64_x86_64_size_dynamic_sections (output_bfd, info)
return true;
}
-/* This function is called via elf64_x86_64_link_hash_traverse if we are
- creating a shared object. In the -Bsymbolic case, it discards the
- space allocated to copy PC relative relocs against symbols which
- are defined in regular objects. For the normal non-symbolic case,
- we also discard space for relocs that have become local due to
- symbol visibility changes. We allocated space for them in the
- check_relocs routine, but we won't fill them in in the
- relocate_section routine. */
-
-static boolean
-elf64_x86_64_discard_copies (h, inf)
- struct elf64_x86_64_link_hash_entry *h;
- PTR inf;
-{
- struct elf64_x86_64_pcrel_relocs_copied *s;
- struct bfd_link_info *info = (struct bfd_link_info *) inf;
-
- if (h->root.root.type == bfd_link_hash_warning)
- h = (struct elf64_x86_64_link_hash_entry *) h->root.root.u.i.link;
-
- /* If a symbol has been forced local or we have found a regular
- definition for the symbolic link case, then we won't be needing
- any relocs. */
- if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
- && ((h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
- || info->symbolic))
- {
- for (s = h->pcrel_relocs_copied; s != NULL; s = s->next)
- s->section->_raw_size -= s->count * sizeof (Elf64_External_Rela);
- }
-
- return true;
-}
-
/* Relocate an x86_64 ELF section. */
static boolean
@@ -1149,31 +1487,24 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Sym *local_syms;
asection **local_sections;
{
- bfd *dynobj;
+ struct elf64_x86_64_link_hash_table *htab;
Elf_Internal_Shdr *symtab_hdr;
struct elf_link_hash_entry **sym_hashes;
bfd_vma *local_got_offsets;
- asection *sgot;
- asection *splt;
- asection *sreloc;
- Elf_Internal_Rela *rela;
+ Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
- dynobj = elf_hash_table (info)->dynobj;
+ if (info->relocateable)
+ return true;
+
+ htab = elf64_x86_64_hash_table (info);
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
local_got_offsets = elf_local_got_offsets (input_bfd);
- sreloc = splt = sgot = NULL;
- if (dynobj != NULL)
- {
- splt = bfd_get_section_by_name (dynobj, ".plt");
- sgot = bfd_get_section_by_name (dynobj, ".got");
- }
-
- rela = relocs;
+ rel = relocs;
relend = relocs + input_section->reloc_count;
- for (; rela < relend; rela++)
+ for (; rel < relend; rel++)
{
int r_type;
reloc_howto_type *howto;
@@ -1181,52 +1512,34 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
struct elf_link_hash_entry *h;
Elf_Internal_Sym *sym;
asection *sec;
+ bfd_vma off;
bfd_vma relocation;
+ boolean unresolved_reloc;
bfd_reloc_status_type r;
- unsigned int indx;
- r_type = ELF64_R_TYPE (rela->r_info);
+ r_type = ELF64_R_TYPE (rel->r_info);
if (r_type == (int) R_X86_64_GNU_VTINHERIT
|| r_type == (int) R_X86_64_GNU_VTENTRY)
continue;
- if ((indx = (unsigned) r_type) >= R_X86_64_max)
+ if (r_type < 0 || r_type >= R_X86_64_max)
{
bfd_set_error (bfd_error_bad_value);
return false;
}
- howto = x86_64_elf_howto_table + indx;
-
- r_symndx = ELF64_R_SYM (rela->r_info);
-
- if (info->relocateable)
- {
- /* 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. */
- 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];
- rela->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
- /* This is a final link. */
+ howto = x86_64_elf_howto_table + r_type;
+ r_symndx = ELF64_R_SYM (rel->r_info);
h = NULL;
sym = NULL;
sec = NULL;
+ unresolved_reloc = false;
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, rela);
+
+ relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
}
else
{
@@ -1234,50 +1547,18 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
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)
{
sec = h->root.u.def.section;
- if ((r_type == R_X86_64_PLT32
- && splt != NULL
- && h->plt.offset != (bfd_vma) -1)
- || ((r_type == R_X86_64_GOT32 || r_type == R_X86_64_GOTPCREL)
- && elf_hash_table (info)->dynamic_sections_created
- && (!info->shared
- || (! info->symbolic && h->dynindx != -1)
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0))
- || (info->shared
- && ((! info->symbolic && h->dynindx != -1)
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)
- && (r_type == R_X86_64_8
- || r_type == R_X86_64_16
- || r_type == R_X86_64_32
- || r_type == R_X86_64_64
- || r_type == R_X86_64_PC8
- || r_type == R_X86_64_PC16
- || r_type == R_X86_64_PC32)
- && ((input_section->flags & SEC_ALLOC) != 0
- /* DWARF will emit R_X86_64_32 relocations in its
- sections against symbols defined externally
- in shared libraries. We can't do anything
- with them here. */
- || ((input_section->flags & SEC_DEBUGGING) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_DYNAMIC) != 0))))
- {
- /* In these cases, we don't need the relocation
- value. We check specially because in some
- obscure cases sec->output_section will be NULL. */
- relocation = 0;
- }
- else if (sec->output_section == NULL)
+ if (sec->output_section == NULL)
{
- (*_bfd_error_handler)
- (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
- bfd_archive_filename (input_bfd), h->root.root.string,
- bfd_get_section_name (input_bfd, input_section));
+ /* Set a flag that will be cleared later if we find a
+ relocation value for this symbol. output_section
+ is typically NULL for symbols satisfied by a shared
+ library. */
+ unresolved_reloc = true;
relocation = 0;
}
else
@@ -1296,14 +1577,13 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
{
if (! ((*info->callbacks->undefined_symbol)
(info, h->root.root.string, input_bfd,
- input_section, rela->r_offset,
+ input_section, rel->r_offset,
(!info->shared || info->no_undefined
|| ELF_ST_VISIBILITY (h->other)))))
return false;
relocation = 0;
}
}
-
/* When generating a shared object, the relocations handled here are
copied into the output file to be resolved at run time. */
switch (r_type)
@@ -1313,16 +1593,21 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
offset table. */
case R_X86_64_GOTPCREL:
/* Use global offset table as symbol value. */
- BFD_ASSERT (sgot != NULL);
+ if (htab->sgot == NULL)
+ abort ();
if (h != NULL)
{
- bfd_vma off = h->got.offset;
- BFD_ASSERT (off != (bfd_vma) -1);
+ boolean dyn;
+
+ off = h->got.offset;
+ dyn = htab->elf.dynamic_sections_created;
- if (! elf_hash_table (info)->dynamic_sections_created
+ if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
|| (info->shared
- && (info->symbolic || h->dynindx == -1)
+ && (info->symbolic
+ || h->dynindx == -1
+ || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
{
/* This is actually a static link, or it is a -Bsymbolic
@@ -1341,21 +1626,17 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
else
{
bfd_put_64 (output_bfd, relocation,
- sgot->contents + off);
+ htab->sgot->contents + off);
h->got.offset |= 1;
}
}
- if (r_type == R_X86_64_GOTPCREL)
- relocation = sgot->output_section->vma + sgot->output_offset + off;
else
- relocation = sgot->output_offset + off;
+ unresolved_reloc = false;
}
else
{
- bfd_vma off;
-
- BFD_ASSERT (local_got_offsets != NULL
- && local_got_offsets[r_symndx] != (bfd_vma) -1);
+ if (local_got_offsets == NULL)
+ abort ();
off = local_got_offsets[r_symndx];
@@ -1366,39 +1647,42 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
off &= ~1;
else
{
- bfd_put_64 (output_bfd, relocation, sgot->contents + off);
+ bfd_put_64 (output_bfd, relocation,
+ htab->sgot->contents + off);
if (info->shared)
{
asection *srelgot;
Elf_Internal_Rela outrel;
+ Elf64_External_Rela *loc;
/* We need to generate a R_X86_64_RELATIVE reloc
for the dynamic linker. */
- srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
- BFD_ASSERT (srelgot != NULL);
+ srelgot = htab->srelgot;
+ if (srelgot == NULL)
+ abort ();
- outrel.r_offset = (sgot->output_section->vma
- + sgot->output_offset
+ outrel.r_offset = (htab->sgot->output_section->vma
+ + htab->sgot->output_offset
+ off);
outrel.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE);
outrel.r_addend = relocation;
- bfd_elf64_swap_reloca_out (output_bfd, &outrel,
- (((Elf64_External_Rela *)
- srelgot->contents)
- + srelgot->reloc_count));
- ++srelgot->reloc_count;
+ loc = (Elf64_External_Rela *) srelgot->contents;
+ loc += srelgot->reloc_count++;
+ bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
}
local_got_offsets[r_symndx] |= 1;
}
-
- if (r_type == R_X86_64_GOTPCREL)
- relocation = sgot->output_section->vma + sgot->output_offset + off;
- else
- relocation = sgot->output_offset + off;
}
+ if (off >= (bfd_vma) -2)
+ abort ();
+
+ relocation = htab->sgot->output_offset + off;
+ if (r_type == R_X86_64_GOTPCREL)
+ relocation += htab->sgot->output_section->vma;
+
break;
case R_X86_64_PLT32:
@@ -1410,7 +1694,8 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
if (h == NULL)
break;
- if (h->plt.offset == (bfd_vma) -1 || splt == NULL)
+ if (h->plt.offset == (bfd_vma) -1
+ || htab->splt == NULL)
{
/* We didn't make a PLT entry for this symbol. This
happens when statically linking PIC code, or when
@@ -1418,62 +1703,64 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
break;
}
- relocation = (splt->output_section->vma
- + splt->output_offset
+ relocation = (htab->splt->output_section->vma
+ + htab->splt->output_offset
+ h->plt.offset);
+ unresolved_reloc = false;
break;
case R_X86_64_PC8:
case R_X86_64_PC16:
case R_X86_64_PC32:
- if (h == NULL || h->dynindx == -1
- || (info->symbolic
- && h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
- break;
- /* Fall through. */
case R_X86_64_8:
case R_X86_64_16:
case R_X86_64_32:
case R_X86_64_64:
/* FIXME: The ABI says the linker should make sure the value is
the same when it's zeroextended to 64 bit. */
- if (info->shared
- && r_symndx != 0
- && (input_section->flags & SEC_ALLOC) != 0)
+
+ /* r_symndx will be zero only for relocs against symbols
+ from removed linkonce sections, or sections discarded by
+ a linker script. */
+ if (r_symndx == 0
+ || (input_section->flags & SEC_ALLOC) == 0)
+ break;
+
+ if ((info->shared
+ && ((r_type != R_X86_64_PC8
+ && r_type != R_X86_64_PC16
+ && r_type != R_X86_64_PC32)
+ || (h != NULL
+ && h->dynindx != -1
+ && (! info->symbolic
+ || (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+ || (!info->shared
+ && h != NULL
+ && h->dynindx != -1
+ && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
+ && (((h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)
+ || h->root.type == bfd_link_hash_undefweak
+ || h->root.type == bfd_link_hash_undefined)))
{
Elf_Internal_Rela outrel;
boolean skip, relocate;
+ asection *sreloc;
+ Elf64_External_Rela *loc;
/* When generating a shared object, these relocations
are copied into the output file to be resolved at run
time. */
- if (sreloc == NULL)
- {
- 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));
- if (name == NULL)
- return false;
-
- BFD_ASSERT (strncmp (name, ".rela", 5) == 0
- && strcmp (bfd_get_section_name (input_bfd,
- input_section),
- name + 5) == 0);
-
- sreloc = bfd_get_section_by_name (dynobj, name);
- BFD_ASSERT (sreloc != NULL);
- }
-
skip = false;
relocate = false;
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
- rela->r_offset);
+ rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
else if (outrel.r_offset == (bfd_vma) -2)
@@ -1484,65 +1771,37 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
if (skip)
memset (&outrel, 0, sizeof outrel);
+
/* h->dynindx may be -1 if this symbol was marked to
become local. */
else if (h != NULL
- && ((! info->symbolic && h->dynindx != -1)
+ && h->dynindx != -1
+ && (r_type == R_X86_64_PC8
+ || r_type == R_X86_64_PC16
+ || r_type == R_X86_64_PC32
+ || !info->shared
+ || !info->symbolic
|| (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0))
{
- BFD_ASSERT (h->dynindx != -1);
outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
- outrel.r_addend = relocation + rela->r_addend;
+ outrel.r_addend = rel->r_addend;
}
else
{
- if (r_type == R_X86_64_64)
- {
- relocate = true;
- outrel.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE);
- outrel.r_addend = relocation + rela->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 + rela->r_addend;
- }
-
+ /* 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;
}
- bfd_elf64_swap_reloca_out (output_bfd, &outrel,
- (((Elf64_External_Rela *)
- sreloc->contents)
- + sreloc->reloc_count));
- ++sreloc->reloc_count;
+ sreloc = elf_section_data (input_section)->sreloc;
+ if (sreloc == NULL)
+ abort ();
+
+ loc = (Elf64_External_Rela *) sreloc->contents;
+ loc += sreloc->reloc_count++;
+ bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
/* If this reloc is against an external symbol, we do
not want to fiddle with the addend. Otherwise, we
@@ -1558,39 +1817,59 @@ 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. */
+ if (unresolved_reloc
+ && !(info->shared
+ && (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);
+
r = _bfd_final_link_relocate (howto, input_bfd, input_section,
- contents, rela->r_offset,
- relocation, rela->r_addend);
+ contents, rel->r_offset,
+ relocation, rel->r_addend);
if (r != bfd_reloc_ok)
{
- switch (r)
+ const char *name;
+
+ if (h != NULL)
+ name = h->root.root.string;
+ else
{
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (h != NULL)
- name = h->root.root.string;
- else
- {
- name = bfd_elf_string_from_elf_section (input_bfd,
- symtab_hdr->sh_link,
- sym->st_name);
- if (name == NULL)
- return false;
- if (*name == '\0')
- name = bfd_section_name (input_bfd, sec);
- }
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto->name, (bfd_vma) 0,
- input_bfd, input_section, rela->r_offset)))
- return false;
- }
- break;
+ name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name);
+ if (name == NULL)
+ return false;
+ if (*name == '\0')
+ name = bfd_section_name (input_bfd, sec);
+ }
+
+ if (r == bfd_reloc_overflow)
+ {
+
+ if (! ((*info->callbacks->reloc_overflow)
+ (info, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_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);
+ return false;
}
}
}
@@ -1608,28 +1887,25 @@ elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym)
struct elf_link_hash_entry *h;
Elf_Internal_Sym *sym;
{
- bfd *dynobj;
+ struct elf64_x86_64_link_hash_table *htab;
- dynobj = elf_hash_table (info)->dynobj;
+ htab = elf64_x86_64_hash_table (info);
if (h->plt.offset != (bfd_vma) -1)
{
- asection *splt;
- asection *sgot;
- asection *srela;
bfd_vma plt_index;
bfd_vma got_offset;
Elf_Internal_Rela rela;
+ Elf64_External_Rela *loc;
/* This symbol has an entry in the procedure linkage table. Set
it up. */
- BFD_ASSERT (h->dynindx != -1);
-
- splt = bfd_get_section_by_name (dynobj, ".plt");
- sgot = bfd_get_section_by_name (dynobj, ".got.plt");
- srela = bfd_get_section_by_name (dynobj, ".rela.plt");
- BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
+ if (h->dynindx == -1
+ || htab->splt == NULL
+ || htab->sgotplt == NULL
+ || htab->srelplt == NULL)
+ abort ();
/* Get the index in the procedure linkage table which
corresponds to this symbol. This is the index of this symbol
@@ -1643,7 +1919,7 @@ elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym)
got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
/* Fill in the entry in the procedure linkage table. */
- memcpy (splt->contents + h->plt.offset, elf64_x86_64_plt_entry,
+ memcpy (htab->splt->contents + h->plt.offset, elf64_x86_64_plt_entry,
PLT_ENTRY_SIZE);
/* Insert the relocation positions of the plt section. The magic
@@ -1652,67 +1928,61 @@ elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym)
/* Put offset for jmp *name@GOTPCREL(%rip), since the
instruction uses 6 bytes, subtract this value. */
bfd_put_32 (output_bfd,
- (sgot->output_section->vma
- + sgot->output_offset
+ (htab->sgotplt->output_section->vma
+ + htab->sgotplt->output_offset
+ got_offset
- - splt->output_section->vma
- - splt->output_offset
+ - htab->splt->output_section->vma
+ - htab->splt->output_offset
- h->plt.offset
- 6),
- splt->contents + h->plt.offset + 2);
+ htab->splt->contents + h->plt.offset + 2);
/* Put relocation index. */
bfd_put_32 (output_bfd, plt_index,
- splt->contents + h->plt.offset + 7);
+ htab->splt->contents + h->plt.offset + 7);
/* Put offset for jmp .PLT0. */
bfd_put_32 (output_bfd, - (h->plt.offset + PLT_ENTRY_SIZE),
- splt->contents + h->plt.offset + 12);
+ htab->splt->contents + h->plt.offset + 12);
/* Fill in the entry in the global offset table, initially this
points to the pushq instruction in the PLT which is at offset 6. */
- bfd_put_64 (output_bfd, (splt->output_section->vma + splt->output_offset
+ bfd_put_64 (output_bfd, (htab->splt->output_section->vma
+ + htab->splt->output_offset
+ h->plt.offset + 6),
- sgot->contents + got_offset);
+ htab->sgotplt->contents + got_offset);
/* Fill in the entry in the .rela.plt section. */
- rela.r_offset = (sgot->output_section->vma
- + sgot->output_offset
+ rela.r_offset = (htab->sgotplt->output_section->vma
+ + htab->sgotplt->output_offset
+ got_offset);
rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_JUMP_SLOT);
rela.r_addend = 0;
- bfd_elf64_swap_reloca_out (output_bfd, &rela,
- ((Elf64_External_Rela *) srela->contents
- + plt_index));
+ loc = (Elf64_External_Rela *) htab->srelplt->contents + plt_index;
+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
{
/* Mark the symbol as undefined, rather than as defined in
- the .plt section. Leave the value alone. */
+ 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. */
sym->st_shndx = SHN_UNDEF;
- /* If the symbol is weak, we do need to clear the value.
- Otherwise, the PLT entry would provide a definition for
- the symbol even if the symbol wasn't defined anywhere,
- and so the symbol would never be NULL. */
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR_NONWEAK)
- == 0)
- sym->st_value = 0;
}
}
if (h->got.offset != (bfd_vma) -1)
{
- asection *sgot;
- asection *srela;
Elf_Internal_Rela rela;
+ Elf64_External_Rela *loc;
/* This symbol has an entry in the global offset table. Set it
up. */
- sgot = bfd_get_section_by_name (dynobj, ".got");
- srela = bfd_get_section_by_name (dynobj, ".rela.got");
- BFD_ASSERT (sgot != NULL && srela != NULL);
+ if (htab->sgot == NULL || htab->srelgot == NULL)
+ abort ();
- rela.r_offset = (sgot->output_section->vma
- + sgot->output_offset
+ rela.r_offset = (htab->sgot->output_section->vma
+ + htab->sgot->output_offset
+ (h->got.offset &~ (bfd_vma) 1));
/* If this is a static link, or it is a -Bsymbolic link and the
@@ -1720,10 +1990,11 @@ elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym)
of a version file, we just want to emit a RELATIVE reloc.
The entry in the global offset table will already have been
initialized in the relocate_section function. */
- if (! elf_hash_table (info)->dynamic_sections_created
- || (info->shared
- && (info->symbolic || h->dynindx == -1)
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+ if (info->shared
+ && (info->symbolic
+ || h->dynindx == -1
+ || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
{
BFD_ASSERT((h->got.offset & 1) != 0);
rela.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE);
@@ -1734,41 +2005,38 @@ elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym)
else
{
BFD_ASSERT((h->got.offset & 1) == 0);
- bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
+ bfd_put_64 (output_bfd, (bfd_vma) 0,
+ htab->sgot->contents + h->got.offset);
rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_GLOB_DAT);
rela.r_addend = 0;
}
- bfd_elf64_swap_reloca_out (output_bfd, &rela,
- ((Elf64_External_Rela *) srela->contents
- + srela->reloc_count));
- ++srela->reloc_count;
+ loc = (Elf64_External_Rela *) htab->srelgot->contents;
+ loc += htab->srelgot->reloc_count++;
+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
}
if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
{
- asection *s;
Elf_Internal_Rela rela;
+ Elf64_External_Rela *loc;
/* This symbol needs a copy reloc. Set it up. */
- BFD_ASSERT (h->dynindx != -1
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak));
-
- s = bfd_get_section_by_name (h->root.u.def.section->owner,
- ".rela.bss");
- BFD_ASSERT (s != NULL);
+ if (h->dynindx == -1
+ || (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
+ || htab->srelbss == NULL)
+ abort ();
rela.r_offset = (h->root.u.def.value
+ h->root.u.def.section->output_section->vma
+ h->root.u.def.section->output_offset);
rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_COPY);
rela.r_addend = 0;
- bfd_elf64_swap_reloca_out (output_bfd, &rela,
- ((Elf64_External_Rela *) s->contents
- + s->reloc_count));
- ++s->reloc_count;
+ loc = (Elf64_External_Rela *) htab->srelbss->contents;
+ loc += htab->srelbss->reloc_count++;
+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
}
/* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
@@ -1779,6 +2047,26 @@ elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym)
return true;
}
+/* Used to decide how to sort relocs in an optimal manner for the
+ dynamic linker, before writing them out. */
+
+static enum elf_reloc_type_class
+elf64_x86_64_reloc_type_class (rela)
+ const Elf_Internal_Rela *rela;
+{
+ switch ((int) ELF64_R_TYPE (rela->r_info))
+ {
+ case R_X86_64_RELATIVE:
+ return reloc_class_relative;
+ case R_X86_64_JUMP_SLOT:
+ return reloc_class_plt;
+ case R_X86_64_COPY:
+ return reloc_class_copy;
+ default:
+ return reloc_class_normal;
+ }
+}
+
/* Finish up the dynamic sections. */
static boolean
@@ -1786,29 +2074,26 @@ elf64_x86_64_finish_dynamic_sections (output_bfd, info)
bfd *output_bfd;
struct bfd_link_info *info;
{
+ struct elf64_x86_64_link_hash_table *htab;
bfd *dynobj;
asection *sdyn;
- asection *sgot;
-
- dynobj = elf_hash_table (info)->dynobj;
- sgot = bfd_get_section_by_name (dynobj, ".got.plt");
- BFD_ASSERT (sgot != NULL);
+ htab = elf64_x86_64_hash_table (info);
+ dynobj = htab->elf.dynobj;
sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
- if (elf_hash_table (info)->dynamic_sections_created)
+ if (htab->elf.dynamic_sections_created)
{
- asection *splt;
Elf64_External_Dyn *dyncon, *dynconend;
- BFD_ASSERT (sdyn != NULL);
+ if (sdyn == NULL || htab->sgot == NULL)
+ abort ();
dyncon = (Elf64_External_Dyn *) sdyn->contents;
dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
for (; dyncon < dynconend; dyncon++)
{
Elf_Internal_Dyn dyn;
- const char *name;
asection *s;
bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
@@ -1819,115 +2104,100 @@ elf64_x86_64_finish_dynamic_sections (output_bfd, info)
continue;
case DT_PLTGOT:
- name = ".got";
- goto get_vma;
+ dyn.d_un.d_ptr = htab->sgot->output_section->vma;
+ break;
case DT_JMPREL:
- name = ".rela.plt";
+ dyn.d_un.d_ptr = htab->srelplt->output_section->vma;
+ break;
- get_vma:
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
+ case DT_PLTRELSZ:
+ s = htab->srelplt->output_section;
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val = s->_cooked_size;
+ else
+ dyn.d_un.d_val = s->_raw_size;
break;
case DT_RELASZ:
- /* FIXME: This comment and code is from elf64-alpha.c: */
- /* My interpretation of the TIS v1.1 ELF document indicates
- that RELASZ should not include JMPREL. This is not what
- the rest of the BFD does. It is, however, what the
- glibc ld.so wants. Do this fixup here until we found
- out who is right. */
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
- if (s)
+ /* The procedure linkage table relocs (DT_JMPREL) should
+ not be included in the overall relocs (DT_RELA).
+ Therefore, we override the DT_RELASZ entry here to
+ make it not include the JMPREL relocs. Since the
+ linker script arranges for .rela.plt to follow all
+ other relocation sections, we don't have to worry
+ about changing the DT_RELA entry. */
+ if (htab->srelplt != NULL)
{
- /* Subtract JMPREL size from RELASZ. */
- dyn.d_un.d_val -=
- (s->_cooked_size ? s->_cooked_size : s->_raw_size);
+ s = htab->srelplt->output_section;
+ if (s->_cooked_size != 0)
+ dyn.d_un.d_val -= s->_cooked_size;
+ else
+ dyn.d_un.d_val -= s->_raw_size;
}
break;
-
- case DT_PLTRELSZ:
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_val =
- (s->_cooked_size != 0 ? s->_cooked_size : s->_raw_size);
- break;
}
+
bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
}
- /* Initialize the contents of the .plt section. */
- splt = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (splt != NULL);
- if (splt->_raw_size > 0)
+ /* Fill in the special first entry in the procedure linkage table. */
+ if (htab->splt && htab->splt->_raw_size > 0)
{
/* Fill in the first entry in the procedure linkage table. */
- memcpy (splt->contents, elf64_x86_64_plt0_entry, PLT_ENTRY_SIZE);
+ memcpy (htab->splt->contents, elf64_x86_64_plt0_entry,
+ PLT_ENTRY_SIZE);
/* Add offset for pushq GOT+8(%rip), since the instruction
uses 6 bytes subtract this value. */
bfd_put_32 (output_bfd,
- (sgot->output_section->vma
- + sgot->output_offset
+ (htab->sgotplt->output_section->vma
+ + htab->sgotplt->output_offset
+ 8
- - splt->output_section->vma
- - splt->output_offset
+ - htab->splt->output_section->vma
+ - htab->splt->output_offset
- 6),
- splt->contents + 2);
+ htab->splt->contents + 2);
/* Add offset for jmp *GOT+16(%rip). The 12 is the offset to
the end of the instruction. */
bfd_put_32 (output_bfd,
- (sgot->output_section->vma
- + sgot->output_offset
+ (htab->sgotplt->output_section->vma
+ + htab->sgotplt->output_offset
+ 16
- - splt->output_section->vma
- - splt->output_offset
+ - htab->splt->output_section->vma
+ - htab->splt->output_offset
- 12),
- splt->contents + 8);
+ htab->splt->contents + 8);
+ elf_section_data (htab->splt->output_section)->this_hdr.sh_entsize =
+ PLT_ENTRY_SIZE;
}
-
- elf_section_data (splt->output_section)->this_hdr.sh_entsize =
- PLT_ENTRY_SIZE;
}
- /* Set the first entry in the global offset table to the address of
- the dynamic section. */
- if (sgot->_raw_size > 0)
+ if (htab->sgotplt)
{
- if (sdyn == NULL)
- bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents);
- else
- bfd_put_64 (output_bfd,
- sdyn->output_section->vma + sdyn->output_offset,
- sgot->contents);
- /* Write GOT[1] and GOT[2], needed for the dynamic linker. */
- bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents + GOT_ENTRY_SIZE);
- bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents + GOT_ENTRY_SIZE*2);
- }
+ /* Fill in the first three entries in the global offset table. */
+ if (htab->sgotplt->_raw_size > 0)
+ {
+ /* Set the first entry in the global offset table to the address of
+ the dynamic section. */
+ if (sdyn == NULL)
+ bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents);
+ else
+ bfd_put_64 (output_bfd,
+ sdyn->output_section->vma + sdyn->output_offset,
+ htab->sgotplt->contents);
+ /* Write GOT[1] and GOT[2], needed for the dynamic linker. */
+ bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + GOT_ENTRY_SIZE);
+ bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + GOT_ENTRY_SIZE*2);
+ }
- elf_section_data (sgot->output_section)->this_hdr.sh_entsize =
- GOT_ENTRY_SIZE;
+ elf_section_data (htab->sgotplt->output_section)->this_hdr.sh_entsize =
+ GOT_ENTRY_SIZE;
+ }
return true;
}
-static enum elf_reloc_type_class
-elf64_x86_64_reloc_type_class (rela)
- const Elf_Internal_Rela *rela;
-{
- switch ((int) ELF64_R_TYPE (rela->r_info))
- {
- case R_X86_64_RELATIVE:
- return reloc_class_relative;
- case R_X86_64_JUMP_SLOT:
- return reloc_class_plt;
- case R_X86_64_COPY:
- return reloc_class_copy;
- default:
- return reloc_class_normal;
- }
-}
#define TARGET_LITTLE_SYM bfd_elf64_x86_64_vec
#define TARGET_LITTLE_NAME "elf64-x86-64"
@@ -1942,25 +2212,25 @@ elf64_x86_64_reloc_type_class (rela)
#define elf_backend_want_plt_sym 0
#define elf_backend_got_header_size (GOT_ENTRY_SIZE*3)
#define elf_backend_plt_header_size PLT_ENTRY_SIZE
+#define elf_backend_rela_normal 1
#define elf_info_to_howto elf64_x86_64_info_to_howto
-#define bfd_elf64_bfd_final_link _bfd_elf64_gc_common_final_link
#define bfd_elf64_bfd_link_hash_table_create \
elf64_x86_64_link_hash_table_create
#define bfd_elf64_bfd_reloc_type_lookup elf64_x86_64_reloc_type_lookup
#define elf_backend_adjust_dynamic_symbol elf64_x86_64_adjust_dynamic_symbol
#define elf_backend_check_relocs elf64_x86_64_check_relocs
-#define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
-#define elf_backend_finish_dynamic_sections \
- elf64_x86_64_finish_dynamic_sections
+#define elf_backend_copy_indirect_symbol elf64_x86_64_copy_indirect_symbol
+#define elf_backend_create_dynamic_sections elf64_x86_64_create_dynamic_sections
+#define elf_backend_finish_dynamic_sections elf64_x86_64_finish_dynamic_sections
#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_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
#define elf_backend_object_p elf64_x86_64_elf_object_p
-#define elf_backend_reloc_type_class elf64_x86_64_reloc_type_class
#include "elf64-target.h"
diff --git a/contrib/binutils/bfd/elfarm-nabi.c b/contrib/binutils/bfd/elfarm-nabi.c
index 7ced680..2d791de 100644
--- a/contrib/binutils/bfd/elfarm-nabi.c
+++ b/contrib/binutils/bfd/elfarm-nabi.c
@@ -138,8 +138,8 @@ static reloc_howto_type elf32_arm_howto_table[] =
bfd_elf_generic_reloc, /* special_function */
"R_ARM_ABS16", /* name */
false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
false), /* pcrel_offset */
/* 12 bit absolute */
diff --git a/contrib/binutils/bfd/elflink.h b/contrib/binutils/bfd/elflink.h
index d43d861..bfe6374 100644
--- a/contrib/binutils/bfd/elflink.h
+++ b/contrib/binutils/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))
@@ -6764,6 +6754,12 @@ elf_link_input_bfd (finfo, input_bfd)
void (*reloc_emitter) PARAMS ((bfd *, asection *,
Elf_Internal_Shdr *,
Elf_Internal_Rela *));
+ boolean rela_normal;
+
+ input_rel_hdr = &elf_section_data (o)->rel_hdr;
+ rela_normal = (bed->rela_normal
+ && (input_rel_hdr->sh_entsize
+ == sizeof (Elf_External_Rela)));
/* Adjust the reloc addresses and symbol indices. */
@@ -6786,7 +6782,7 @@ elf_link_input_bfd (finfo, input_bfd)
irela->r_offset += o->output_offset;
/* Relocs in an executable have to be virtual addresses. */
- if (finfo->info->emitrelocations)
+ if (!finfo->info->relocateable)
irela->r_offset += o->output_section->vma;
r_symndx = ELF_R_SYM (irela->r_info);
@@ -6837,10 +6833,9 @@ elf_link_input_bfd (finfo, input_bfd)
processor specific section. If we have
discarded a section, the output_section will
be the absolute section. */
- if (sec != NULL
- && (bfd_is_abs_section (sec)
- || (sec->output_section != NULL
- && bfd_is_abs_section (sec->output_section))))
+ if (bfd_is_abs_section (sec)
+ || (sec != NULL
+ && bfd_is_abs_section (sec->output_section)))
r_symndx = 0;
else if (sec == NULL || sec->owner == NULL)
{
@@ -6852,6 +6847,11 @@ elf_link_input_bfd (finfo, input_bfd)
r_symndx = sec->output_section->target_index;
BFD_ASSERT (r_symndx != 0);
}
+
+ /* Adjust the addend according to where the
+ section winds up in the output section. */
+ if (rela_normal)
+ irela->r_addend += sec->output_offset;
}
else
{
@@ -6910,7 +6910,6 @@ elf_link_input_bfd (finfo, input_bfd)
else
reloc_emitter = elf_link_output_relocs;
- input_rel_hdr = &elf_section_data (o)->rel_hdr;
(*reloc_emitter) (output_bfd, o, input_rel_hdr, internal_relocs);
input_rel_hdr = elf_section_data (o)->rel_hdr2;
@@ -6918,7 +6917,8 @@ elf_link_input_bfd (finfo, input_bfd)
{
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);
+ (*reloc_emitter) (output_bfd, o, input_rel_hdr,
+ internal_relocs);
}
}
diff --git a/contrib/binutils/bfd/elfxx-ia64.c b/contrib/binutils/bfd/elfxx-ia64.c
index aadb963..f92ab6a 100644
--- a/contrib/binutils/bfd/elfxx-ia64.c
+++ b/contrib/binutils/bfd/elfxx-ia64.c
@@ -3502,6 +3502,7 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section,
elf_section_data(input_section->output_section)
->this_hdr.sh_flags |= flags;
+ return true;
}
gp_val = _bfd_get_gp_value (output_bfd);
@@ -3534,29 +3535,9 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section,
ret_val = false;
continue;
}
+
howto = lookup_howto (r_type);
r_symndx = ELFNN_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* 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. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sym_sec = local_sections[r_symndx];
- rel->r_addend += sym_sec->output_offset;
- }
- }
- continue;
- }
-
- /* This is a final link. */
-
h = NULL;
sym = NULL;
sym_sec = NULL;
@@ -4561,6 +4542,7 @@ elfNN_hpux_backend_section_from_bfd_section (abfd, sec, retval)
#define elf_backend_copy_indirect_symbol elfNN_ia64_hash_copy_indirect
#define elf_backend_hide_symbol elfNN_ia64_hash_hide_symbol
#define elf_backend_reloc_type_class elfNN_ia64_reloc_type_class
+#define elf_backend_rela_normal 1
#include "elfNN-target.h"
diff --git a/contrib/binutils/bfd/elfxx-target.h b/contrib/binutils/bfd/elfxx-target.h
index 25ddd0e..e6b63d1 100644
--- a/contrib/binutils/bfd/elfxx-target.h
+++ b/contrib/binutils/bfd/elfxx-target.h
@@ -390,6 +390,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define elf_backend_default_use_rela_p !USE_REL
#endif
+#ifndef elf_backend_rela_normal
+#define elf_backend_rela_normal 0
+#endif
+
#ifndef ELF_MACHINE_ALT1
#define ELF_MACHINE_ALT1 0
#endif
@@ -470,6 +474,7 @@ static const struct elf_backend_data elfNN_bed =
elf_backend_may_use_rel_p,
elf_backend_may_use_rela_p,
elf_backend_default_use_rela_p,
+ elf_backend_rela_normal,
elf_backend_sign_extend_vma,
elf_backend_want_got_plt,
elf_backend_plt_readonly,
diff --git a/contrib/binutils/bfd/ihex.c b/contrib/binutils/bfd/ihex.c
index 613eaf3..2e4494d 100644
--- a/contrib/binutils/bfd/ihex.c
+++ b/contrib/binutils/bfd/ihex.c
@@ -875,8 +875,8 @@ ihex_write_object_contents (abfd)
rec_addr = where - (extbase + segbase);
/* Output records shouldn't cross 64K boundaries. */
- if (rec_addr + now > 0xfffff)
- now = 0xffff - rec_addr;
+ if (rec_addr + now > 0xffff)
+ now = 0x10000 - rec_addr;
if (! ihex_write_record (abfd, now, rec_addr, 0, p))
return false;
diff --git a/contrib/binutils/bfd/libbfd.h b/contrib/binutils/bfd/libbfd.h
index e7ba1c5..55d192c 100644
--- a/contrib/binutils/bfd/libbfd.h
+++ b/contrib/binutils/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/contrib/binutils/bfd/opncls.c b/contrib/binutils/bfd/opncls.c
index 0b285d4..200f6c7 100644
--- a/contrib/binutils/bfd/opncls.c
+++ b/contrib/binutils/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.
@@ -96,6 +96,8 @@ _bfd_new_bfd_contained_in (obfd)
bfd *nbfd;
nbfd = _bfd_new_bfd ();
+ if (nbfd == NULL)
+ return NULL;
nbfd->xvec = obfd->xvec;
nbfd->my_archive = obfd;
nbfd->direction = read_direction;
@@ -618,7 +620,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 +638,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/contrib/binutils/bfd/reloc.c b/contrib/binutils/bfd/reloc.c
index 559a351..c701fe0 100644
--- a/contrib/binutils/bfd/reloc.c
+++ b/contrib/binutils/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/contrib/binutils/bfd/rs6000-core.c b/contrib/binutils/bfd/rs6000-core.c
index 19ff4a4..6330153 100644
--- a/contrib/binutils/bfd/rs6000-core.c
+++ b/contrib/binutils/bfd/rs6000-core.c
@@ -182,7 +182,7 @@ typedef union {
/* Return the c_impl field from struct core_dumpx C. */
-#ifdef AIX_CORE_DUMPX_CORE
+#if defined (HAVE_ST_C_IMPL) || defined (AIX_5_CORE)
# define CNEW_IMPL(c) (c).c_impl
#else
# define CNEW_IMPL(c) 0
diff --git a/contrib/binutils/bfd/syms.c b/contrib/binutils/bfd/syms.c
index 4309c0d..01f7eee 100644
--- a/contrib/binutils/bfd/syms.c
+++ b/contrib/binutils/bfd/syms.c
@@ -1297,7 +1297,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
*pfound = true;
- if (IS_ABSOLUTE_PATH(file_name) || directory_name == NULL)
+ if (file_name == NULL || IS_ABSOLUTE_PATH (file_name)
+ || directory_name == NULL)
*pfilename = file_name;
else
{
diff --git a/contrib/binutils/bfd/version.h b/contrib/binutils/bfd/version.h
index 6af6920..600c673 100644
--- a/contrib/binutils/bfd/version.h
+++ b/contrib/binutils/bfd/version.h
@@ -1 +1 @@
-#define BFD_VERSION_DATE 20020412
+#define BFD_VERSION_DATE 20020622
diff --git a/contrib/binutils/bfd/xcofflink.c b/contrib/binutils/bfd/xcofflink.c
index a939b5c..2e5ca5d 100644
--- a/contrib/binutils/bfd/xcofflink.c
+++ b/contrib/binutils/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);
OpenPOWER on IntegriCloud