Commit Graph

104 Commits

Author SHA1 Message Date
Alan Modra 9055360d4a Fixes to powerpc64 gold ELFv2 support
* powerpc.cc (Target_powerpc::glink_section): Provide non-const
	accessor.
	(Target_powerpc::Branch_info::make_stub): Make global entry stubs.
	Only call ppc64_local_entry_offset for 64-bit.  Restrict
	symval_for_branch lookup to ELFv1.
	(Stub_table::add_plt_call_entry): Use unsigned int off.
	(Output_data_glink::Address, invalid_address): New.
	(Output_data_glink::add_eh_frame): Move out of line.  Add
	support for ELFv2.
	(Output_data_glink::add_global_entry, find_global_entry,
	global_entry_address): New functions.
	(Output_data_glink::global_entry_stubs_, end_branch_table_,
	ge_size): New variables.
	(Output_data_glink::set_final_data_size): Add global entry
	stub sizing.
	(Output_data_glink::do_write): Write global entry stubs.
	(Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Add target
	parameter.  Return true for ELFv2.  Adjust callers.
	(Target_powerpc::Scan::local, global): Restrict opd lookup to
	ELFv1.  Similarly for ifunc and dynamic relocation processing
	specific to ELFv1.  Recognize that symbols are defined on
	their plt entries for ELFv2.
	(Target_powerpc::symval_for_branch): Assert if called for
	ELFv2 or ppc32.
	(Target_powerpc::Relocate::relocate): Use global entry plt
	stub for symbol value if such exists on ELFv2.
	(Target_powerpc::Relocate::relocate): Don't call
	symval_for_branch when ELFv2.  Do adjust for local entry
	offset when ELFv2.
	(Target_powerpc::do_dynsym_value): Set symbols to global entry
	plt stub for ELFv2.
	(Target_powerpc::do_plt_address_for_global): Similarly.
2013-11-15 10:36:34 +10:30
Alan Modra 88b8e63904 Remove powerpc.cc copy of use_plt_offset
This adds an extra flag for needs_dynamic_reloc() in order to remove
the copy of this function and use_plt_offset() in powerpc.cc, and
tweaks the powerpc get_reference_flags() to return the flag as
appropriate.  ELFv2 does not want ELFv1 behaviour here.

	* symtab.h (Symbol::Reference_flags): Add FUNC_DESC_ABI.
	(Symbol::needs_dynamic_reloc): Test new flag.
	* powerpc.cc (needs_dynamic_reloc, use_plt_offset): Delete.
	(Target_powerpc::Scan::get_reference_flags): Add target param.
	Return FUNC_DESC_ABI for 64-bit ELFv1.
	(Target_powerpc::Branch_info::make_stub): Adjust get_reference_flags
	call.
	(Target_powerpc::Scan::global): Use Symbol::needs_dynamic_reloc.
	(Target_powerpc::Relocate::relocate): Use Symbol::use_plt_offset.
2013-11-04 16:00:13 +10:30
Alan Modra b4f7960d53 PowerPC64 ELFv2 support for gold.
elfcpp/
	* powerpc.h (EF_PPC64_ABI): New enum constant.
	(STO_PPC64_LOCAL_BIT, STO_PPC64_LOCAL_MASK): Likewise.
	(ppc64_decode_local_entry): New function.
	(ppc64_encode_local_entry): Likewise.
gold/
	* powerpc.cc (Powerpc_relobj::abiversion, set_abiversion,
	ppc64_local_entry_offset, ppc64_local_entry_offset,
	do_read_symbols): New functions.
	(Powerpc_relobj::e_flags_, st_other_): New vars.
	(Powerpc_relobj::Powerpc_relobj): Call set_abiversion.
	(Powerpc_dynobj::abiversion, set_abiversion): New functions.
	(Powerpc_relobj::e_flags_): New var.
	(Target_powerpc::first_plt_entry_offset, plt_entry_size): Inline
	and adjust for ELFv2.
	(Target_powerpc::abiversion, set_abiversion, stk_toc): New functions.
	(Powerpc_relobj::do_find_special_sections): Check no .opd in ELFv2.
	(Powerpc_dynobj::do_find_special_sections): Likewise.
	(Target_powerpc::do_define_standard_symbols): Define ".TOC.".
	(Target_powerpc::Branch_info::make_stub): Adjust stub destination
	to ELFv2 local entry.
	(Target_powerpc::do_relax): No thread safe barriers needed for
	ELFv2.
	(Output_data_plt_powerpc::initial_plt_entry_size_,
	plt_entry_size): Delete.  Replace all uses with
	first_plt_entry_offset() and plt_entry_size().
	(Output_data_plt_powerpc::Output_data_plt_powerpc): Remove
	reserved_size parm.  Update callers.
	(Output_data_plt_powerpc::entry_count): Update.
	(Output_data_plt_powerpc::first_plt_entry_offset): Make private
	and use Target_powerpc::first_plt_entry_offset().
	(Output_data_plt_powerpc::get_plt_entry_size): Similarly and
	rename to plt_entry_size.
	(Output_data_plt_powerpc::add_ifunc_entry,
	add_local_ifunc_entry): Adjust reloc for ELFv2.
	(glink_eh_frame_fde_64): Rename to glink_eh_frame_fde_64v1.
	(glink_eh_frame_fde_64v2): New.
	(Stub_table::plt_call_size): Support ELFv2 sizing.
	(Output_data_glink::add_eh_frame): Use the new FDE.
	(Output_data_glink::set_final_data_size): Adjust for ELFv2 glink.
	(Stub_table::do_write): Write ELFv2 stubs and glink.
	(Target_powerpc::Relocate::relocate): Replaces nop after call
	with ld 2,24(1) and adjust local offset destination for ELFv2.
2013-10-30 13:45:05 +10:30
Alan Modra f9c6b9078c Report overflow on PowerPC64 @h and @ha relocations.
This changes the behaviour of @h and @ha on PowerPC64 to report errors
on 32-bit overflow.  The motivation for this change is that on
PowerPC64, most uses of @h and @ha modifiers and their corresponding
relocations are to build up 32-bit offsets.  We'd like to know when
such offsets overflow.  Only rarely do people use @h or @ha with the
high 32-bit modifiers to build a 64-bit constant.  Those uses will now
need to use two new modifiers, @high and @higha, if the constant isn't
known at assembly time.  For now, we won't report overflow at assembly
time..

This also fixes an error when applying some of the HIGHER and HIGHEST
relocations.

include/elf/
	* ppc64.h (R_PPC64_ADDR16_HIGH, R_PPC64_ADDR16_HIGHA,
	R_PPC64_TPREL16_HIGH, R_PPC64_TPREL16_HIGHA,
	R_PPC64_DTPREL16_HIGH, R_PPC64_DTPREL16_HIGHA): New.
	(IS_PPC64_TLS_RELOC): Match new tls relocs.
bfd/
	* reloc.c (BFD_RELOC_PPC64_ADDR16_HIGH, BFD_RELOC_PPC64_ADDR16_HIGHA,
	BFD_RELOC_PPC64_TPREL16_HIGH, BFD_RELOC_PPC64_TPREL16_HIGHA,
	BFD_RELOC_PPC64_DTPREL16_HIGH, BFD_RELOC_PPC64_DTPREL16_HIGHA): New.
	* elf64-ppc.c (ppc64_elf_howto_raw): Add entries for new relocs.
	Make all _HA and _HI relocs report signed overflow.
	(ppc64_elf_reloc_type_lookup): Handle new relocs.
	(must_be_dyn_reloc, ppc64_elf_check_relocs): Likewise.
	(dec_dynrel_count, ppc64_elf_relocate_section): Likewise.
	(ppc64_elf_relocate_section): Don't apply 0x8000 adjust to
	R_PPC64_TPREL16_HIGHER, R_PPC64_TPREL16_HIGHEST,
	R_PPC64_DTPREL16_HIGHER, and R_PPC64_DTPREL16_HIGHEST.
	* libbfd.h: Regenerate.
	* bfd-in2.h: Regenerate.
gas/
	* config/tc-ppc.c (SEX16): Don't mask.
	(REPORT_OVERFLOW_HI): Define as zero.
	(ppc_elf_suffix): Support @high, @higha, @dtprel@high, @dtprel@higha,
	@tprel@high, and @tprel@higha modifiers.
	(md_assemble): Ignore X_unsigned when applying 16-bit insn fields.
	Add (disabled) code to check @h and @ha reloc overflow for powerpc64.
	Handle new relocs.
	(md_apply_fix): Similarly.
elfcpp/
	* powerpc.h (R_PPC64_ADDR16_HIGH, R_PPC64_ADDR16_HIGHA,
	R_PPC64_TPREL16_HIGH, R_PPC64_TPREL16_HIGHA,
	R_PPC64_DTPREL16_HIGH, R_PPC64_DTPREL16_HIGHA): Define.
gold/
	* powerpc.cc (Target_powerpc::Scan::check_non_pic): Handle new relocs.
	(Target_powerpc::Scan::global, local): Likewise.
	(Target_powerpc::Relocate::relocate): Likewise.  Check for overflow
	on all ppc64 @h and @ha relocs.
2013-10-30 13:33:15 +10:30
Alan Modra e84fe78fbc * output.h (Output_data_got::add_constant): Tidy.
(Output_data_got::add_constant_pair): New function.
	* powerpc.cc (Output_data_got_powerpc): Override all Output_data_got
	methods used so as to first call reserve_ent().
2013-10-14 02:53:01 +00:00
Roland McGrath 44dcb735e4 gold/
* powerpc.cc (Output_data_got_powerpc): Remove unused methods
	add_got_entry and add_got_entry_pair.
2013-10-11 23:06:08 +00:00
Roland McGrath 43819297ce gold/
* i386.cc (Target_i386): Remove unused member dynbss_.
	* arm.cc (Target_arm): Likewise.
	* powerpc.cc (Target_powerpc): Likewise.
	* sparc.cc (Target_sparc): Likewise.
	* tilegx.cc (Target_tilegx): Likewise.
	* x86_64.cc (Target_x86_64): Likewise.
	* dwarf_reader.h (Dwarf_info_reader): Remove unused members
	type_signature_, type_offset_.
	* plugin.h (Plugin_hook): Remove unused member layout_.
	* readsyms.h (Add_symbols): Remove unused members dirpath_, dirindex_,
	mapfile_.
	(Read_member): Remove unused members input_objects_, symtab_,
	mapfile_, layout_.
	(Check_library): Remove unused member symtab_.
	* archive.h (Lib_group): Remove unused member lib_.
	* archive.cc (Lib_group::Lib_group): Update initializer.
	* incremental.h	(Incremental_binary): Remove unused member target_.
	(Incremental_script_entry): Removed unused member script_.
	* layout.h (Write_symbols_task): Remove unused member input_objects_.
	* icf.h (Icf): Remove unused member num_tracked_relocs.
2013-10-11 21:11:49 +00:00
Cary Coutant c6905c28a5 gold/
* object.cc (Sized_relobj::do_output_section_address): New function.
	(Sized_relobj): Instantiate explicitly.
	* object.h (Object::output_section_address): New function.
	(Object::do_output_section_address): New function.
	(Sized_relobj::do_output_section_address): New function.
	* powerpc.cc (Target_powerpc::symval_for_branch): Use it.
2013-07-31 18:47:50 +00:00
Cary Coutant a67858e046 gold/
* parameters.cc (Parameters::entry): Return target-specific entry
    	symbol name.
    	* target.h (Target::entry_symbol_name): New function.
    	(Target_info::entry_symbol_name): New data member.

    	* arm.cc (Target_arm::arm_info): Add entry_symbol_name.
    	(Target_arm_nacl::arm_nacl_info): Likewise.
    	* i386.cc (Target_i386::i386_info): Likewise.
    	(Target_i386_nacl::i386_nacl_info): Likewise.
    	* powerpc.cc (Target_powerpc::powerpc_info): Likewise.
    	* sparc.cc (Target_sparc::sparc_info): Likewise.
    	* tilegx.cc (Target_tilegx::tilegx_info): Likewise.
    	* x86_64.cc: (Target_x86_64::x86_64_info) Likewise.
    	(Target_x86_64_nacl::x86_64_nacl_info) Likewise.
    	* testsuite/testfile.cc (Target_test::test_target_info): Likewise.
2013-07-30 21:26:53 +00:00
Cary Coutant 4d5effb90d gold/
* powerpc.cc (Target_powerpc::write_branch_lookup_table): Use
	correct BRLT entry size.
2013-07-11 21:30:56 +00:00
Alan Modra ba8ca3e739 bfd/
* elf64-ppc.c (struct ppc_stub_hash_entry): Delete "addend".
	(ppc64_elf_size_stubs): Don't set "addend".
	(ppc64_elf_relocate_section): Don't allow calls via
	toc-adjusting stubs without a following nop even in an
	executable, except for self-calls and both libc_start_main
	and .libc_start_main.
gold/
	* powerpc.cc (Target_powerpc::Relocate::relocate): Update self-call
	comment.
2013-07-03 02:22:35 +00:00
Cary Coutant 06f30c9d10 PR gold/15662
* powerpc.cc (Output_data_brlt_powerpc::reset_brlt_sizes): New
	function.
	(Output_data_brlt_powerpc::finalize_brlt_sizes): New function.
	(Target_powerpc::do_relax): Call the above.
2013-06-27 23:20:35 +00:00
Alan Modra a2d7bf59d6 * powerpc.cc (Target_powerpc::symval_for_branch): Don't assert
on garbage collected .opd section.

	* powerpc.cc (Target_powerpc::do_gc_add_reference): Test dst_shndx
	is non-zero.
	(Target_powerpc::do_gc_mark_symbols): Likewise for sym->shndx().
	(Target_powerpc::do_function_location): Likewise for loc->shndx.
2013-06-27 03:11:22 +00:00
Ian Lance Taylor 0e8048633e * target-reloc.h (relocate_section): If the reloc offset is out of
range, pass VIEW as NULL to relocate.relocate.
	* arm.cc (Target_arm:Relocate::relocate): Check for a NULL view.
	* i386.cc (Target_i386::Relocate::relocate): Likewise.
	* powerpc.cc (Target_powerpc::Relocate::relocate): Likewise.
	* sparc.cc (Target_sparc::Relocate::relocate): Likewise.
	* tilegx.cc (Target_tilegx::Relocate::relocate): Likewise.
	* x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.
2013-04-27 00:53:16 +00:00
Alan Modra 0cfdc76718 * powerpc.cc (Stub_control::can_add_to_stub_group): Don't set
owner when sections are not adjacent and exceed group size.
	(Target_powerpc::group_sections): Handle corner case.
	(Target_powerpc::Branch_info::make_stub): Handle case where
	stub table doesn't exist due to branches in non-exec sections.
	(Target_powerpc::Relocate::relocate): Likewise.
2013-04-13 10:12:30 +00:00
Alan Modra 6830ee24c7 PR gold/15354
* powerpc.cc (Target_powerpc::make_brlt_section): Name section
	.branch_lt to match bfd ld.  Adjust comments throughout file.
2013-04-11 01:28:27 +00:00
Alan Modra b3ccdeb53f * powerpc.cc (Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Make
static and public.  Add report_err param.  Return false for data refs.
	(Target_powerpc::rela_dyn_section): New overloaded function.
	(Target_powerpc::plt_, iplt_): Elucidate.
	(Output_data_plt_powerpc::entry_count): Handle current_data_size()==0.
	(Output_data_plt_powerpc::do_write): Don't write .iplt.
	(Output_data_plt_powerpc::plt_entry_count): Don't add .iplt entries.
	(Target_powerpc::Scan::local, global): Adjust reloc_needs_plt_for_ifunc
	calls.  Put ifunc dynamic relocs in irela_dyn_section.  Only
	push_branch and make_plt_entry for ifunc syms when
	reloc_needs_plt_for_ifunc.
	(Target_powerpc::Relocate::relocate): Don't use plt entry value
	for ifunc unless reloc_needs_plt_for_ifunc.
2013-03-15 08:40:49 +00:00
Alan Modra 4d9aa15515 * powerpc.cc (is_branch_reloc): Forward declare.
(Target_powerpc::do_can_check_for_function_pointers): New predicate.
	(Target_powerpc::Scan::local_reloc_may_be_function_pointer): Return
	false for 64-bit, true for 32-bit non-branch relocs.
	(Target_powerpc::Scan::global_reloc_may_be_function_pointer): Likewise.
	* testsuite/Makefile.am (icf_test): Use linker map file instead of
	nm output.
	(icf_safe_test): Generate linker map file as well as nm output.
	(icf_safe_so_test): Likewise.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/icf_test.sh: Parse linker map file to determine
	section folding.
	* testsuite/icf_safe_test.sh: Likewise.  Expect folding for PowerPC.
	* testsuite/icf_safe_so_test.sh: Likewise.
	(X86_32_or_ARM_specific_safe_fold): Merge into..
	(arch_specific_safe_fold): ..this.
	(X86_64_specific_safe_fold): Delete unused function.
2013-03-12 22:46:19 +00:00
Alan Modra dc3714f31f * gold.cc (queue_middle_tasks): Move detect_odr_violations..
* layout.cc (Layout_task_runner::run): ..to here.
	* symtab.h (struct Symbol_location): Extract from..
	(class Symbol_table): ..here.
	* symtab.cc (Symbol_table::linenos_from_loc): Invoke function_location.
	* target.h (class Target): Add function_location and
	do_function_location functions.
	(class Sized_target): Add do_function_location.
	* object.h (class Sized_relobj_file): Move find_shdr..
	(class Object): ..to here.
	* object.cc: Likewise.  Update to suit.  Instantiate.
	(Sized_relobj_file::find_eh_frame): Update find_shdr call.
	* powerpc.cc (class Powerpc_dynobj): New.
	(Target_powerpc::do_function_location): New function.
	(Powerpc_relobj::do_find_special_sections): Update find_shdr call.
	(Powerpc_dynobj::do_read_symbols): New function.
	(Target_powerpc::do_make_elf_object): Make a Powerpc_dynobj.
2013-03-10 23:08:18 +00:00
Alan Modra 6c77229c00 * powerpc.cc (class Powerpc_relobj): Move some member functions.
(Target_powerpc::symval_for_branch):  Add symtab param.  Update
	all callers.  Handle folded sections.
	(Target_powerpc::do_gc_add_reference): Don't cast dynamic object
	to Powerpc_relobj.
	(Global_symbol_visitor_opd::operator()): Likewise.
2013-03-06 12:28:47 +00:00
Alan Modra 9d5781f8a2 * target.h (Target::plt_fde_location, do_plt_fde_location): Declare.
* target.cc (Target::do_plt_fde_location): New function.
	* ehframe.h (class FDE): Add post_map field to u_.from_linker,
	accessor function, and constructor param.
	(struct Post_fde, Post_fdes): Declare.
	(Cie::write): Add post_fdes param.
	* ehframe.cc (Fde::write): Use plt_fde_location.
	(struct Post_fde): Define.
	(Cie::write): Stash FDEs added post merge mapping.
	(Eh_frame::add_ehframe_for_plt): Assert no new CIEs after mapping.
	Adjust Fde constructor call.  Bump final_data_size_ for post map FDEs.
	(Eh_frame::do_sized_write): Arrange to write post map FDES after
	other FDEs.
	* powerpc.cc (Target_powerpc::do_plt_fde_location): New function.
	(Target_powerpc::has_glink): New function.
	(Target_powerpc::do_relax): Add eh_frame info for stubs.
	(struct Eh_cie, eh_frame_cie, glink_eh_frame_fde_64,
	glink_eh_frame_fde_32, default_fde): New data.
	(Stub_table::eh_frame_added_): New var.
	(Stub_table::find_long_branch_entry, stub_address, stub_offset):
	Make const.
	(Stub_table::add_eh_frame): New function.
	(Output_data_glink::add_eh_frame): New function.
	(Target_powerpc::make_glink_section): Call add_eh_frame.
2013-02-27 23:11:56 +00:00
Alan Modra 91c2b899a6 * powerpc.cc (Stub_table::plt_off): New function, extracted from..
(Stub_table::do_write): ..here, two places.
	(Stub_table::plt_call_size): Use it here too.
2013-02-15 12:59:15 +00:00
Alan Modra ec5b818745 * powerpc.cc (Stub_table::find_plt_call_entry): Make types
used in declaration and definition consistent.
	(Target_powerpc::symval_for_branch): Ditto.
2013-01-17 23:29:14 +00:00
Alan Modra e245874365 bfd/
* elf64-ppc.c (ppc64_elf_size_stubs): Default shared libs to
	plt-thread-safe.
gold/
	* powerpc.cc (Target_powerpc::do_relax): Default shared libs to
	plt-thread-safe.
ld/testsuite/
	* ld-powerpc/tlsso.d: Adjust for plt-thread-safe stubs.
	* ld-powerpc/tlsso.g: Likewise.
	* ld-powerpc/tlsso.r: Likewise.
	* ld-powerpc/tlstocso.d: Likewise.
	* ld-powerpc/tlstocso.g: Likewise.
2013-01-15 06:13:26 +00:00
Alan Modra e3deeb9c3a * powerpc.cc (class Track_tls): New.
(class Relocate, class Scan): Inherit Track_tls.
	(Target_powerpc::Scan::local, global): Track tls optimization
	and avoid creating plt entry for __tls_get_addr if all uses
	are optimized away.
	(Target_powerpc::Relocate::relocate): Update to use Track_tls.
2012-12-12 08:09:41 +00:00
Alan Modra d8f5a2749d * options.h (General_options): Add --toc-sort/--no-toc-sort.
Replace no_toc_optimize with toc_optimize.
	* output.h (Output_section::input_sections): Provide non-const variant.
	* powerpc.cc (Powerpc_relobj::has_small_toc_reloc_,
	set_has_small_toc_reloc, has_small_toc_reloc): New variable and
	accessors.
	(Target_powerpc::Scan::local, global): Call set_has_small_toc_reloc.
	(class Sort_toc_sections): New.
	(Target_powerpc::do_finalize_sections): Sort toc sections.
	(Target_powerpc::Relocate::relocate): Update toc_optimize test.
2012-12-12 03:41:40 +00:00
Alan Modra edc27beb58 * powerpc.cc (Target_selector_powerpc::Target_selector_powerpc):
Set EM_PPC64 or EM_PPC here.
	(Target_selector_powerpc::do_recognize): Delete.
2012-12-10 11:45:18 +00:00
Alan Modra 906b9150c7 * powerpc.cc (Powerpc_relobj::Powerpc_relobj): Init has14_ and
stub_table_.
	(Target_powerpc::Branch_info::make_stub): Don't omit addend.
2012-12-10 11:30:57 +00:00
Alan Modra decdd3bc36 * powerpc.cc (Stub_table::do_write): Delete redundant Address
typedef and invalid_address constant.
	(Output_data_glink, Stub_table, Target_powerpc): Explicitly
	instantiate constants.
2012-12-07 04:23:36 +00:00
Alan Modra aba6bc71dd * options.h (General_options): Add no_toc_optimize.
* powerpc.cc (ok_lo_toc_insn): New function.
	(Target_powerpc::Relocate::relocate): Optimize toc access sequences.
2012-12-07 00:03:18 +00:00
Alan Modra 9e69ed506a * options.h (General_options): Add plt_align, plt_static_chain,
plt_thread_safe.  Update stub_group_size help text.
	* powerpc.cc (Target_powerpc::plt_thread_safe): New access function
	for new plt_thread_safe_ var.
	(use_plt_offset): Correct comments.
	(Target_powerpc::do_relax): Look for thread creation symbols to
	determine default plt_thread_safe value.  Clear plt call stubs
	as well as branch stubs each iteration.
	(add_2_2_11, add_12_12_11, bnectr_p4, cmpldi_2_0, xor_11_11_11): New
	insn constants.
	(l, hi, ha, write_insn): Move earlier.
	(Stub_table): Delete prev_size, add last_plt_size and last_branch_size.
	(Stub_table::clear_stubs): Rename from clear_long_branch_stubs, clear
	plt stubs too.
	(Stub_table::update_size): Adjust.
	(Stub_table::prev_size, set_prev_size): Delete.
	(Stub_table::stub_align): Let --plt-align affect result.
	(Stub_table::plt_call_size): Calculate sizes for various stubs.
	(Stub_table::branch_stub_size): Use last_plt_size in address calc.
	(Stub_table::add_plt_call_stub): Pass iterator to plt_call_size.
	(Stub_table::do_write): Support more stub variants.
2012-12-06 03:13:17 +00:00
Alan Modra f43ba157ad * powerpc.cc (Powerpc_relobj::do_scan_relocs): Delete.
(Target_powerpc::do_define_standard_symbols): New function.
2012-12-04 03:13:31 +00:00
Alan Modra ec661b9dca * layout.h (Layout::get_executable_sections): Declare.
* layout.cc (Layout::get_executable_sections): New function.
	* arm.cc (Target_arm::group_sections): Use it.
	(Arm_output_section::group_sections): Delete now redundant test.
	* output.cc (Output_reloc::Output_reloc): Add is_relative.
	param to handle relative relocs.
	* output.h (Output_reloc::Output_reloc <absolute reloc>): Likewise.
	(Output_data_reloc::add_absolute): Adjust.
	(Output_data_reloc::add_relative): New function.
	(Output_data::reset_data_size): New function.
	(Output_relaxed_input_section::set_relobj, set_shndx): New functions.
	(Output_section::set_addralign): New function.
	(Output_section::checkpoint_set_addralign): New function.
	(Output_section::clear_section_offsets_need_adjustment): New function.
	(Output_section::input_sections): Make public.
	* powerpc.cc (class Output_data_brlt_powerpc): New.
	(class Stub_table, class Stub_control): New.
	(Powerpc_relobj::has14_, set_has_14bit_branch, has_14bit_branch,
	stub_table_, set_stub_table, stub_table): New vectors and accessor
	functions.
	(Target_powerpc::do_may_relax, do_relax, push_branch,
	new_stub_table, stub_tables, brlt_section, group_sections,
	add_branch_lookup_table, find_branch_lookup_table,
	write_branch_lookup_table, make_brlt_section): New functions.
	(Target_powerpc::struct Sort_sections, class Branch_info): New.
	(Target_powerpc::brlt_section_, stub_tables_, branch_lookup_table_,
	branch_info_): New vars.
	(Target_powerpc::make_plt_entry, make_local_ifunc_plt_entry): Don't
	make call stubs here.
	(Output_data_glink): Remove all call stub handling from this class.
	(Target_powerpc::Scan::local, global): Save interesting branch
	relocs and relocs for ifunc.  Adjust calls to plt entry functions.
	(Target_powerpc::do_finalize_sections): Only make reg save/restore
	functions on final link.
	(Target_powerpc::Relocate::relocate): Adjust lookup of call stubs.
	Handle long branch destinations too.
	(Target_powerpc::do_dynsym_value, do_plt_address_for_global,
	do_plt_address_for_local): Adjust lookup of plt call stubs.
2012-12-03 05:30:59 +00:00
Alan Modra 627b30b77e * powerpc.c (Target_powerpc::Scan::global): Don't emit relative
relocs against protected symbols when building 32-bit shared libs.
2012-11-30 05:01:20 +00:00
Alan Modra 40b469d719 * powerpc.cc (Target_powerpc::make_plt_section): Add symtab
param.  Call got_section() to make .got.  Update all callers
	and their callers and so on.
2012-11-30 04:50:00 +00:00
Alan Modra bb66a627d0 * powerpc.cc (Powerpc_relobj::do_scan_relocs): Make STB_LOCAL
_GLOBAL_OFFSET_TABLE_ rather than STB_WEAK.
	(Output_data_got_powerpc::make_header): Update _GLOBAL_OFFSET_TABLE_
	value if it already exists.
2012-11-30 04:47:08 +00:00
Alan Modra 26a4e9cbc4 * powerpc.cc (Powerpc_relobj): Delete "Offset" typedef.
(struct Opd_ent): Use "Address" rather than "Offset".
	(Output_data_got_powerpc::got_base_offset): Return Valtype.
	(Target_powerpc::got_section): Make public.
	(Target_powerpc::scan_relocs): Move code setting symbols..
	(Powerpc_relobj::do_scan_relocs): ..to here, new function.
	Create _SDA_BASE_ only when referenced.
2012-11-05 03:29:58 +00:00
Roland McGrath 62fe925ad4 gold/
* target.h (Sized_target::relocate_relocs): Use Elf_Off
	for offset_in_output_section parameter.
	(Sized_target::relocate_special_relocatable): Likewise.
	* arm.cc (Target_arm::relocate_relocs): Likewise.
	(Target_arm::relocate_special_relocatable): Likewise.
	* i386.cc (Target_i386::relocate_relocs): Likewise.
	* powerpc.cc (Target_powerpc::relocate_relocs): Likewise.
	* sparc.cc (Target_sparc::relocate_relocs): Likewise.
	* target-reloc.h (relocate_relocs): Likewise.
	* testsuite/testfile.cc (Target_test): Likewise.
	* tilegx.cc (Target_tilegx::relocate_relocs): Likewise.
	* x86_64.cc (Target_x86_64::relocate_relocs): Likewise.
2012-11-01 23:27:00 +00:00
Alan Modra 168a472611 * target-reloc.h (class Default_comdat_behavior): New, package up..
(get_comdat_behaviour): ..this.
	(relocate_section): Add Relocate_comdat_behavior template arg,
	adjust code to suit.
	* arm.cc (Target_arm::relocate_section): Adjust to suit.
	(Target_arm::scan_reloc_section): Likewise.
	* i386.cc (Target_i386::relocate_section): Likewise.
	* sparc.cc (Target_sparc::relocate_section): Likewise.
	* tilegx.cc (Target_tilegx::relocate_section): Likewise.
	* x86_64.cc (Target_x86_64::relocate_section): Likewise.
	* powerpc.cc (class Relocate_comdat_behavior): New.
	(Target_powerpc::relocate_section): Don't zap opd relocs.  Supply
	gold::relocate_section with new template arg.
2012-10-18 04:18:18 +00:00
Alan Modra acc276d812 * powerpc.cc (Target_powerpc::Scan::local, global): Always emit
dynamic relocs for GOT_TPREL got entries, without symbol if
	resolving locally.
	(Target_powerpc::do_gc_add_reference): Don't add for dynamic objects.
	(Target_powerpc::scan_relocs): Define _GLOBAL_OFFSET_TABLE_ early.
	(Target_powerpc::Relocate:relocate): REL32 reloc may be unaligned.
2012-10-17 14:33:41 +00:00
Alan Modra f3a0ed298a * powerpc.cc (Target_powerpc::define_save_restore_funcs): New func.
(Target_powerpc::do_finalize_sections): Call it.
	(Output_data_save_res): New class and supporting functions.
	(Target_powerpc::symval_for_branch): Only look up .opd entry for
	normal symbols defined in object files.
2012-10-16 00:23:00 +00:00
Alan Modra c6de8ed456 * powerpc.cc (Powerpc_relobj::add_gc_mark, process_gc_mark): New.
(struct Opd_ent): Make "discard" a bit field.  Add "gc_mark".
	(Target_powerpc::do_gc_mark_symbol): Delay marking function code
	section if scan_opd_relocs not yet called.
	(Target_powerpc::gc_process_relocs): Call process_gc_mark.
2012-10-12 09:44:11 +00:00
Alan Modra 03e25981b6 * powerpc.cc (Output_data_plt_powerpc::add_entry, add_ifunc_entry,
add_local_ifunc_entry): Revert last change.
	(Target_powerpc::make_plt_entry, make_local_ifunc_plt_entry): Likewise.
2012-10-12 09:39:19 +00:00
Alan Modra c9824451ad * powerpc.cc (Target_powerpc::do_plt_address_for_local,
do_plt_address_for_global): New functions.
	(Output_data_got_powerpc::do_write): Don't segfault when linking
	statically.
	(Output_data_plt_powerpc::add_entry, add_ifunc_entry,
	add_local_ifunc_entry): Return true on adding entry..
	(Target_powerpc::make_plt_entry): ..use to avoid unnecessary
	glink->add_entry call.  Remove unused symtab param.  Adjust calls.
	(Target_powerpc::make_local_ifunc_plt_entry): Likewise.
	(Target_powerpc::make_iplt_section): Remove symtab param.  Don't
	set up symbols here.
	(Target_powerpc::do_finalize_sections): Instead set up __rela_iplt
	syms here.  Do so even when no .iplt.  Don't segfault when linking
	statically.
	(Output_data_glink::add_entry, find_entry): Rearrange params.  Add
	new variants without reloc param.
	(Glink_sym_ent::Glink_sym_ent): Likewise.
	(Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Accept any
	reloc when refs will resolve to plt call stub.
	(Target_powerpc::Scan::local): Correct ifunc handling.  Allow
	R_PPC_PLTREL24 to resolve locally.
	(Target_powerpc::Scan::global): Correct ifunc handling.
	(Target_powerpc::Relocate::relocate): Correct local sym glink
	lookup.  Don't destroy "value" when we have a plt call stub,
	and when checking plt call validity.
	(Target_powerpc::do_dynsym_value): Simplify.
2012-10-05 08:18:07 +00:00
Alan Modra e5d5f5ed43 * powerpc.cc (Target_powerpc::iplt_): New output section.
(Target_powerpc::iplt_section, make_iplt_section,
	reloc_needs_plt_for_ifunc, make_local_ifunc_plt_entry): New functions.
	(Target_powerpc::make_plt_entry): Handle ifunc syms.
	Target_powerpc::plt_entry_count): Count iplt entries too.
	(Output_data_plt_powerpc::Output_data_plt_powerpc): Don't create
	reloc section in constructor.  New params.
	(Target_powerpc::make_plt_section): Create reloc section here instead.
	(Output_data_plt_powerpc::add_ifunc_entry, add_local_ifunc_entry): New
	functions.
	(Output_data_plt_powerpc::initial_plt_entry_size_, name_): New vars.
	(Output_data_glink::add_entry, find_entry): New functions to
	deal with local syms.
	(Glink_sym_ent): Add support for local syms.
	(Output_data_glink::do_write): Handle ifunc plt entries.
	(Target_powerpc::Scan::get_reference_flags): Handle more relocs.
	(Target_powerpc::Scan::local, global): Handle ifunc syms.
	(Target_powerpc::Relocate::relocate): Likewise.
	(Target_powerpc::do_dynsym_value): Use glink stub, not plt entry.
2012-09-29 10:29:05 +00:00
Alan Modra ec4dbad32d * object.h (Sized_relobj_file::adjust_local_symbol,
do_adjust_local_symbol): New functions.
	* object.cc (Sized_relobj_file::do_count_local_symbols): Use the above.
	* powerpc.cc (Powerpc_relobj::do_adjust_local_symbol): New function.
	(Powerpc_relobj::scan_opd_relocs): Warn on unexpected opd relocs
	and irregular opd entry spacing.
	(Powerpc_relobj::do_read_relocs): Add opd size checks.
	(Global_symbol_visitor_opd): New functor.
	(Target_powerpc::do_finalize_sections): Omit global symbols defined
	on deleted opd entries.
2012-09-25 00:59:25 +00:00
Alan Modra bfdfa4cd8d * target-reloc.h (scan_relocs): Call scan.local for relocs
against symbols in discarded sections.  Pass is_discarded
	param.
	* arm.cc, * i386.cc, * sparc.cc, * x86_64.cc (Target_*::Scan::local):
	Add is_discarded param.
	* powerpc (Target_powerpc::Scan::local): Likewise.  Use
	is_discarded to flag opd entry as discarded.  Don't emit dyn
	relocs on such entries.
	(Target_powerpc::Scan::global): Similarly detect and handle
	such opd entries.
	(Powerpc_relobj): Replace opd_ent_shndx_ and opd_ent_off_ with
	opd_ent_.  Update all uses.
	(Powerpc_relobj::get_opd_discard, set_opd_discard): New functions.
	(Target_powerpc::relocate_section): Zero out discarded opd
	entry relocs.
2012-09-12 22:43:54 +00:00
Alan Modra bd73a62d77 * output.h (Output_data_got::add_global_tls, add_local_tls,
add_local_tls_pair): New functions.
	(Output_data_got::add_local_pair_with_rel): Remove second
	reloc param.  Expand comment.
	(Output_data_got::Got_entry): Rename use_plt_offset_ to
	use_plt_or_tls_offset_, similarly for constructor param.
	(Output_data_got::Got_entry::write): Add got_index param.
	* output.cc (Output_data_got::add_global_tls, add_local_tls,
	add_local_tls_pair): New functions.
	(Output_data_got::Got_entry::write): Handle tls symbols
	with use_plt_or_tls_offset_ set specially.
	(Output_data_got::add_local_pair_with_rel): Only one reloc.
	(Output_data_got::do_write): Replace iterator with index, pass
	index to entry write function.
	* target.h (Target::tls_offset_for_local, tls_offset_for_global,
	do_tls_offset_for_local, do_tls_offset_for_global): New functions.
	* arm.cc (Target_arm::Scan::local): Update add_local_pair_with_rel
	call.
	* i386.cc (Target_i386::Scan::local): Likewise.
	* sparc.cc (Target_sparc::Scan::local): Likewise.
	* x86_64.cc (Target_x86_64::Scan::local): Likewise.
	* powerpc.cc (Target_powerpc::do_tls_offset_for_local,
	do_tls_offset_for_global): New functions.
	(Target_powerpc::Scan::local): Correct TLS relocations and got
	entry values.
	(Target_powerpc::Scan::global): Don't emit unnecessary
	dynamic relocations on TLS GOT entries.
2012-09-10 23:05:54 +00:00
Alan Modra e81fea4d17 * target.h (Target::gc_mark_symbol, do_gc_mark_symbol): New functions.
(Sized_target::gc_add_reference, do_gc_add_reference): New functions.
	* gc.h (gc_process_relocs): Call target gc_add_reference.
	* gold.cc (queue_middle_tasks): Use gc_mark_symbol on start sym.
	* symtab.cc (Symbol_table::gc_mark_undef_symbols): Use gc_mark_symbol.
	(Symbol_table::gc_mark_symbol): Call target gc_mark_symbol. Remove
	unnecessary cast.
	* powerpc.cc (Powerpc_relobj::get_opd_ent): Rearrange parameters
	to cater for when we don't need code offset.  Update use.
	(Powerpc_relobj::access_from_map_, opd_valid_): New vars.
	(Powerpc_relobj::access_from_map, add_reference, opd_valid,
	set_opd_valid): New functions.
	(Target_powerpc::do_gc_add_reference): New function.
	(Target_powerpc::gc_process_relocs): Call gc()->add_reference on
	stashed refs.
	(Target_powerpc::do_gc_mark_symbol): New function.
2012-09-09 03:43:51 +00:00
Alan Modra f4baf0d43d * powerpc.cc (Powerpc_relocate_functions): Upcase enum values,
update all uses and lose "enum" when using type.
2012-09-05 11:27:14 +00:00