aboutsummaryrefslogtreecommitdiff
path: root/gold
AgeCommit message (Collapse)Author
2017-08-01[GOLD] PowerPC recreate eh_frame for stubs on each relax passAlan Modra
There is a very small but non-zero probability that a stub group contains stubs on one relax pass, but does not on the next. In that case we would get an FDE covering a zero length address range. (Actually, it's even worse. Alignment padding for stubs can mean the address for the non-existent stubs is past the end of the original section to which stubs are attached, and due to the way do_plt_fde_location calculates the length we can get a negative length.) Fixing this properly requires removing the FDE. Also, I have been implementing the __tls_get_addr_opt support for gold, and that stub needs something other than the default FDE. The necessary FDE will depend on the offset to the __tls_get_addr_opt stub, which of course can change during relaxation. That means at the very least, rewriting the FDE on each pass, possibly changing the FDE size. I think that is better done by completely recreating PLT eh_frame FDEs. * ehframe.cc (Fde::operator==): New. (Cie::remove_fde, Eh_frame::remove_ehframe_for_plt): New. * ehframe.h (Fde::operator==): Declare. (Cie::remove_fde, Eh_frame::remove_ehframe_for_plt): Likewise. * layout.cc (Layout::remove_eh_frame_for_plt): New. * layout.h (Layout::remove_eh_frame_for_plt): Declare. * powerpc.cc (Target_powerpc::do_relax): Remove old eh_frame FDEs. (Stub_table::add_eh_frame): Delete eh_frame_added_ condition. Don't add eh_frame for empty stub section. (Stub_table::remove_eh_frame): New.
2017-07-31[GOLD] PowerPC --no-tls-optimizeAlan Modra
This adds a --no-tls-optimize option for people who want to keep __tls_get_addr calls in an executable rather than optimizing such code sequences to IE/LE. Also tidy some formatting errors, rename a variable to better reflect its use, and tweak two functions that create pairs of GOT entries to first check whether the GOT entry already exists before potentially inserting the header via reserve(2). Without the check it is possible to waste one GOT entry. * options.h (no_tls_optimize): New powerpc option. * powerpc.cc (Target_powerpc::abiversion, set_abiversion): Formatting. (Target_powerpc::stk_toc): Formatting, fix comment. (Target_powerpc::Track_tls::tls_get_addr_state): Rename from tls_get_addr. (Target_powerpc::optimize_tls_gd, optimize_tls_ld, optimize_tls_ie): Return TLSOPT_NONE when !tls_optimize. (Target_powerpc::add_global_pair_with_rel): Check for existing reloc before reserving. (Target_powerpc::add_local_tls_pair): Likewise.
2017-07-31PR 21847, PowerPC64 --plt-localentry againAlan Modra
This makes ld warn about --plt-localentry if a version of glibc without the necessary ld.so checks is detected, and revises the documentation. bfd/ * elf64-ppc.c (ppc64_elf_tls_setup): Warn on --plt-localentry without ld.so checks. gold/ * powerpc.cc (Target_powerpc::scan_relocs): Warn on --plt-localentry without ld.so checks. ld/ * ld.texinfo (plt-localentry): Revise.
2017-07-29PR 21847, Don't default PowerPC64 to --plt-localentryAlan Modra
The big comment in ppc64_elf_tls_setup says why. I've also added some code to the bfd linker that catches the -lpthread -lc symbol differences and disable generation of optimized call stubs even when --plt-localentry is activated. Gold doesn't yet have that. PR 21847 bfd/ * elf64-ppc.c (struct ppc_link_hash_entry): Add non_zero_localentry. (ppc64_elf_merge_symbol): Set non_zero_localentry. (is_elfv2_localentry0): Test non_zero_localentry. (ppc64_elf_tls_setup): Default to --no-plt-localentry. gold/ * powerpc.cc (Target_powerpc::scan_relocs): Default to --no-plt-localentry. ld/ * ld.texinfo (plt-localentry): Document.
2017-07-28gold: Add put_ch_reserved to 64-bit Chdr_writeH.J. Lu
The 64-bit ELF compression header has a reserved field. It should be cleared to avoid random bits in it. elfcpp/ PR gold/21857 * elfcpp.h (Chdr_write): Add put_ch_reserved. (Chdr_write<64, true>::put_ch_reserved): New. (Chdr_write<64, false>::put_ch_reserved): Likewise. gold/ PR gold/21857 * compressed_output.cc (Output_compressed_section::set_final_data_size): Call put_ch_reserved to clear the reserved field for 64-bit ELF.
2017-07-26Gold: Fix mips.cc for GCC 4.2H.J. Lu
GCC 4.2 fails to compile "(uint64_t) 0x800080008000" with error: integer constant is too large for ‘long’ type This patch adds "llu" suffix to 0x800080008000 for GCC 4.2. * mips.cc (Mips_relocate_functions): Add "llu" suffix to 0x800080008000.
2017-07-23Correct eh_frame info for __glink_PLTresolveAlan Modra
My PPC64_OPT_LOCALENTRY patch of June 1, git commit f378ab099d, and the later gold change, git commit 7ee7ff7015, added an insn in __glink_PLTresolve which needs a corresponding adjustment in the eh_frame info for asynchronous exceptions to unwind correctly. It would have been OK for both ABIs to use +5 for the advance before restore of LR, since we can put the DW_CFA_restore_extended on any insn after the actual restore and before the r12/r0 copy is clobbered, but it's slightly better to delay as much as possible. There are then more addresses where fewer CFA program insns are executed. bfd/ * elf64-ppc.c (ppc64_elf_size_stubs): Correct advance to restore of LR. gold/ * powerpc.cc (glink_eh_frame_fde_64v2): Correct advance to restore of LR. (glink_eh_frame_fde_64v1): Advance to restore of LR at latest possible insn.
2017-07-18Fix spelling typos.Yuri Chornovian
2017-07-12Add missing gold/ChangeLog entry.Cary Coutant
2017-07-12Update PO filesAlan Modra
bfd/ * po/es.po: Update from translationproject.org/latest/bfd/. * po/fi.po: Likewise. * po/fr.po: Likewise. * po/id.po: Likewise. * po/ja.po: Likewise. * po/ro.po: Likewise. * po/ru.po: Likewise. * po/sr.po: Likewise. * po/sv.po: Likewise. * po/tr.po: Likewise. * po/uk.po: Likewise. * po/vi.po: Likewise. * po/zh_CN.po: Likewise. * po/hr.po: New file from translationproject.org. * configure.ac (ALL_LINGUAS): Add hr. Sort. * configure: Regenerate. binutils/ * po/bg.po: Update from translationproject.org/latest/binutils/. * po/ca.po: Likewise. * po/da.po: Likewise. * po/es.po: Likewise. * po/fi.po: Likewise. * po/fr.po: Likewise. * po/hr.po: Likewise. * po/id.po: Likewise. * po/it.po: Likewise. * po/ja.po: Likewise. * po/ro.po: Likewise. * po/ru.po: Likewise. * po/sk.po: Likewise. * po/sr.po: Likewise. * po/sv.po: Likewise. * po/tr.po: Likewise. * po/uk.po: Likewise. * po/vi.po: Likewise. * po/zh_CN.po: Likewise. * po/zh_TW.po: Likewise. gas/ * po/es.po: Update from translationproject.org/latest/gas/. * po/fi.po: Likewise. * po/fr.po: Likewise. * po/id.po: Likewise. * po/ja.po: Likewise. * po/ru.po: Likewise. * po/sv.po: Likewise. * po/tr.po: Likewise. * po/uk.po: Likewise. * po/zh_CN.po: Likewise. gold/ * po/es.po: Update from translationproject.org/latest/gold/. * po/fi.po: Likewise. * po/fr.po: Likewise. * po/id.po: Likewise. * po/it.po: Likewise. * po/vi.po: Likewise. * po/zh_CN.po: Likewise. * po/ja.po: New file from translationproject.org. * po/sv.po: Likewise. * po/uk.po: Likewise. gprof/ * po/bg.po: Update from translationproject.org/latest/gprof/. * po/da.po: Likewise. * po/de.po: Likewise. * po/eo.po: Likewise. * po/es.po: Likewise. * po/fi.po: Likewise. * po/fr.po: Likewise. * po/ga.po: Likewise. * po/hu.po: Likewise. * po/id.po: Likewise. * po/it.po: Likewise. * po/ja.po: Likewise. * po/ms.po: Likewise. * po/nl.po: Likewise. * po/pt_BR.po: Likewise. * po/ro.po: Likewise. * po/ru.po: Likewise. * po/sr.po: Likewise. * po/sv.po: Likewise. * po/tr.po: Likewise. * po/uk.po: Likewise. * po/vi.po: Likewise. ld/ * po/bg.po: Update from translationproject.org/latest/ld/. * po/da.po: Likewise. * po/es.po: Likewise. * po/fi.po: Likewise. * po/fr.po: Likewise. * po/id.po: Likewise. * po/it.po: Likewise. * po/ja.po: Likewise. * po/tr.po: Likewise. * po/uk.po: Likewise. * po/vi.po: Likewise. * po/zh_CN.po: Likewise. * po/zh_TW.po: Likewise. * po/de.po: New file from translationproject.org. * po/ru.po: Likewise. * configure.ac (ALL_LINGUAS): Add de, ru. Sort. * configure: Regenerate. opcodes/ * po/da.po: Update from translationproject.org/latest/opcodes/. * po/de.po: Likewise. * po/es.po: Likewise. * po/fi.po: Likewise. * po/fr.po: Likewise. * po/id.po: Likewise. * po/it.po: Likewise. * po/nl.po: Likewise. * po/pt_BR.po: Likewise. * po/ro.po: Likewise. * po/sv.po: Likewise. * po/tr.po: Likewise. * po/uk.po: Likewise. * po/vi.po: Likewise. * po/zh_CN.po: Likewise.
2017-07-11Fixing for PR gold/21491 - Errata workaround can produce broken images.Han Shen
The problem is caused by the fact that gold is relocating the stubs for an entire output section when it processes the relocations for a particular input section that happened to be designated as the stub table "owner". The Relocate_task for that input section may or may not run before the Relocate_task for another input section that contains the code that needs the erratum fix, but doesn't "own" the stub table. If it runs before (or might even race with) that other task, it ends up with a copy of the unrelocated original instruction. In other words - when calling fix_errata() from do_relocate_sections(), gold is going through the list of errata stubs that are associated only with that object. This routine updates the stored original instruction and replaces it in the output view with a branch to the stub. Later, as gold is going through the object file's input sections, it then checks for stub tables "owned" by each input section, and writes out all the stubs from that stub table, regardless of what object file each stub is associated with. Fixed by relocating the erratum stub only after the corresponding errata spot is fixed. That is to have fix_errata() call Stub_table::relocate_erratum_stub() for each stub. gold/ChangeLog 2017-07-06 Han Shen <shenhan@google.com> PR gold/21491 * aarch64.cc (Erratum_stub::invalidate_erratum_stub): New method. (Erratum_stub::is_invalidated_erratum_stub): New method. (Stub_table::relocate_reloc_stub): Renamed from "relocate_stub". (Stub_table::relocate_reloc_stubs): Renamed from "relocate_stubs". (Stub_table::relocate_erratum_stub): New method. (AArch64_relobj::fix_errata_and_relocate_erratum_stubs): Renamed from "fix_errata". (Target_aarch64::relocate_reloc_stub): Renamed from "relocate_stub".
2017-06-23[GOLD] PowerPC64 localentry:0 plt call optimizationAlan Modra
elfcpp/ * elfcpp.h (DT_PPC64_OPT): Define. * powerpc.h (PPC64_OPT_TLS, PPC64_OPT_MULTI_TOC, PPC64_OPT_LOCALENTRY): Define. gold/ * options.h (General_options): Add plt_localentry. * powerpc.cc (Target_powerpc::st_other): New function. (Target_powerpc::plt_localentry0_, plt_localentry0_init_, has_localentry0_): New vars. (Target_powerpc::plt_localentry0, set_has_localentry0, is_elfv2_localentry0): New functions. (Target_powerpc::Branch_info::mark_pltcall): Don't set tocsave or return true for localentry:0 calls. (Stub_table::Plt_stub_ent::localentry0_): New var. (Stub_table::add_plt_call_entry): Set localentry0_ and has_localentry0_. Don't set r2save_ for localentry:0 calls. (Output_data_glink::do_write): Save r2 in __glink_PLTresolve for elfv2. (Target_powerpc::scan_relocs): Default plt_localentry0_. (Target_powerpc::do_finalize_sections): Set DT_PPC64_OPT. (Target_powerpc::Relocate::relocate): Don't require nop following calls for localentry:0 plt calls, and don't change nop.
2017-06-23[GOLD] PowerPC64 tocsaveAlan Modra
This adds support to gold for the tocsave relocs already supported by ld.bfd. R_PPC64_TOCSAVE relocs are part of a scheme to move r2 saves to the prologue of a function rather than in each plt call stub. We don't want a compiler to always emit the r2 save, as this would be wasted if the calls turned out to be local. See the tocsave*.s in ld/testsuite/ld-powerpc/. * powerpc.cc (Target_powerpc::tocsave_loc_): New var. (Target_powerpc::mark_pltcall, add_tocsave, tocsave_loc): New functions. (Target_powerpc::Branch_info::tocsave_): New var. (Target_powerpc::Branch_info::mark_pltcall): New function. (Target_powerpc::Branch_info::make_stub): Pass tocsave_ to add_plt_call_entry. (Stub_table::Plt_stub_ent): Make public. Add r2save_. (Stub_table::add_plt_call_entry): Add bool tocsave_ param. Set r2save_. (Stub_table::find_plt_call_entry): Return Plt_stub_ent*. Adjust use throughout. (Stub_table::do_write): Conditionally output r2 save in plt stubs. (Target_powerpc::Scan::local): Handle R_PPC64_TOCSAVE. (Target_powerpc::Scan::global): Likewise. (Target_powerpc::Relocate::relocate): Skip r2 save in plt call stub with tocsave reloc. Replace header tocsave nop with r2 save. * symtab.h (struct Symbol_location_hash): Make public.
2017-06-21[GOLD] PowerPC move plt indx_ out of unordered map keyAlan Modra
I was lazy when adding indx_ to Plt_stub_ent. The field isn't part of the key, so ought to be part of the mapped type. Make it so. * powerpc.cc (Plt_stub_key): Rename from Plt_stub_ent. Remove indx_. (Plt_stub_key_hash): Rename from Plt_stub_ent_hash. (struct Plt_stub_ent): New. (Plt_stub_entries): Map from Plt_stub_key to Plt_stub_ent. Adjust use throughout file.
2017-06-202017-06-20 Eric Christopher <echristo@gmail.com>Eric Christopher
* aarch64.cc (scan_reloc_for_stub): Use plt_address_for_global to calculate the symbol value. (scan_reloc_section_for_stubs): Allow stubs to be created for section symbols. (maybe_apply_stub): Handle creating stubs for weak symbols to match the code in scan_reloc_for_stub.
2017-06-20[GOLD] Avoid duplicate PLT stub symbols on ppc32James Clarke
If two objects are compiled with -fPIC or -fPIE and call the same function, two different PLT entries are created, one for each object, but the same stub symbol name is used for both. * powerpc.cc (Stub_table::define_stub_syms): Always include object's uniq_ value.
2017-06-152017-06-15 Eric Christopher <echristo@gmail.com>Eric Christopher
* aarch64.cc: Fix a few typos and grammar-os.
2017-06-15[GOLD] Don't install branch-to-stub for TLS relaxed ERRATUM 843419 sequences ↵Jiong Wang
on AArch64 TLS relaxation may change erratum 843419 sequences that those offending ADRP instructions actually transformed into other instructions in which case there is erratum 843419 risk anymore that we should avoid installing unnecessary branch-to-stub. gold/ * aarch64.cc (Insn_utilities::is_mrs_tpidr_el0): New method. (AArch64_relobj<size, big_endian>::try_fix_erratum_843419_optimized): Return ture for some TLS relaxed sequences.
2017-06-072017-06-07 Eric Christopher <echristo@gmail.com>Eric Christopher
* aarch64.cc (maybe_apply_stub): Add debug logging for looking up stubs to undefined symbols and early return rather than fail to look them up. (scan_reloc_for_stub): Add debug logging for no stub creation for undefined symbols.
2017-05-23PR21503, Gold doesn't create linker stub symbols on ppc64Alan Modra
PR 21503 * options.h: Add --emit-stub-syms option. * powerpc.cc (object_id): New. (Powerpc_relobj): Add uniq_ and accessor. Sort variables for better packing. (Powerpc_dynobj): Sort variables for better packing. (Target_powerpc::define_local): New function. (Target_powerpc::group_sections): Pass stub table size to Stub_table constructor. (Target_powerpc::do_relax): Define stub and glink symbols. (Stub_table): Add uniq_ variable, and id param to constructor. (Stub_table::Plt_stub_ent): Add indx_ variable. (Stub_table::Branch_stub_entries): Move typedef earlier. (Stub_table::branch_stub_size): Replace "to" parameter with a Branch_stub_entries iterator. (Stub_table::add_long_branch_entry): Adjust to suit. (Stub_table::add_plt_call_entry): Set indx_. (Stub_table::define_stub_syms): New function.
2017-05-152017-05-15 Eric Christopher <echristo@gmail.com>Eric Christopher
* layout.cc (Layout::segment_precedes): Add a case for testing pointer equality when determining which segment precedes another.
2017-05-13Fix assertion failure relaxing TLS for position-independent executables.James Clarke
gold/ PR gold/21444 * gold.cc (Target_sparc::Relocate::relocate_tls): Local variables are final for position-independent executables. This has to be consistent with Target_sparc::Scan::local otherwise they will disagree as to whether local-exec is used.
2017-05-12Fix misplacement of a relaxed section on AArch64.Igor Kudrin
gold/ChangeLog PR gold/21430 * aarch64.cc (AArch64_relobj::convert_input_section_to_relaxed_section): Set the section offset to -1ULL. (Target_aarch64::relocate_section): Adjust the view in case of a relaxed input section. * testsuite/Makefile.am (pr21430): New test. * testsuite/Makefile.in: Regenerate * testsuite/pr21430.s: New test source file. * testsuite/pr21430.sh: New test script.
2017-04-27[GOLD] testsuite/plugin_section_order.c fixAlan Modra
* testsuite/plugin_section_order.c (onload): Add missing break.
2017-03-15Mips: Fix TLS LDM GOT entry.Vladimir Radosavljevic
gold/ * mips.cc (Mips_got_entry::hash()): Shift addend to reduce possibility of collisions. (Mips_got_entry::equals): Fix case for GOT_TLS_LDM entries.
2017-03-15Mips: Omit empty objects for merging processor-specific data.Vladimir Radosavljevic
gold/ * mips.cc (Mips_relobj::merge_processor_specific_data_): New data member. (Mips_relobj::merge_processor_specific_data): New method. (Mips_relobj::do_read_symbols): Set merge_processor_specific_data_ to false, only if the input file is a binary or if object has no contents except the section name string table and an empty symbol table with the undefined symbol. (Target_mips::do_finalize_sections): Refactor. Skip empty object files for merging processor-specific data.
2017-03-15Mips: Add support for resolving multiple consecutive relocations.Vladimir Radosavljevic
gold/ * mips.cc (Target_mips::Relocate::calculated_value_): New data member. (Target_mips::Relocate::calculate_only_): Likewise. (Target_mips::Relocate::relocate): Handle multiple consecutive relocations with the same offset.
2017-03-15Remove redundant checks for relocatable link (MIPS).Vladimir Radosavljevic
gold/ * mips.cc (Target_mips::Relocate::relocate): Remove redundant checks for relocatable link. (Mips_relocate_functions::reljalr): Likewise.
2017-03-15Add support for .MIPS.options section.Vladimir Radosavljevic
gold/ * mips.cc (class Mips_output_section_options): New class. (Target_mips::do_make_output_section): New method.
2017-03-15Improve relocation overflow errors on MIPS.Vladimir Radosavljevic
gold/ * mips.cc (Mips_relocate_functions::rel26): Don't print relocation overflow error message. (Target_mips::relocate_special_relocatable): Improve relocation overflow error message. (Target_mips::Relocate::relocate): Likewise.
2017-03-15Correct the definition of _gp and _GLOBAL_OFFSET_TABLE_ symbols for MIPS.Vladimir Radosavljevic
gold/ * mips.cc (symbol_refs_local): Return false if a symbol is from a dynamic object. (Target_mips::got_section): Make _GLOBAL_OFFSET_TABLE_ STV_HIDDEN. (Target_mips::set_gp): Refactor. Make _gp STT_NOTYPE and STB_LOCAL. (Target_mips::do_finalize_sections): Set _gp after all the checks for creating .got are done. (Target_mips::Scan::global): Remove unused code.
2017-02-22PowerPC ld segfault on script discarding dynamic sectionsAlan Modra
bfd/ * elf64-ppc.c (ppc64_elf_finish_dynamic_sections): Don't segfault on .got or .plt output section being discarded by script. * elf32-ppc.c (ppc_elf_finish_dynamic_sections): Likewise. Move vxworks splt temp. gold/ * powerpc.cc (Target_powerpc::make_iplt_section): Check that output_section exists before attempting add_output_section_data. (Target_powerpc::make_brlt_section): Likewise.
2017-02-15Don't give an internal error for unsupported relocations.Vladimir Radosavljevic
gold/ * mips.cc (Target_mips::Scan::get_reference_flags): Remove gold_unreachable from default case.
2017-02-15Add support for R_MIPS_HIGHER/HIGHEST, R_MICROMIPS_HIGHER/HIGHEST relocations.Vladimir Radosavljevic
2017-02-15 Vladimir Radosavljevic <Vladimir.Radosavljevic@imgtec.com> PR gold/21111 * mips.cc (Mips_relocate_functions::relhigher): New method. (Mips_relocate_functions::relhighest): Likewise. (mips_get_size_for_reloc): Add support for relocs: R_MIPS_HIGHER and R_MIPS_HIGHEST. (Target_mips::Scan::local): Add support for relocs: R_MIPS_HIGHER, R_MIPS_HIGHEST, R_MICROMIPS_HIGHER and R_MICROMIPS_HIGHEST. (Target_mips::Scan::global): Likewise. (Target_mips::Scan::get_reference_flags): Likewise. (Target_mips::Relocate::relocate): Call static methods for resolving HIGHER and HIGHEST relocations.
2017-02-15Improved support for --icf=safe when used with -pie.Rahul Chaudhry
gold/ * x86_64.cc (Target_x86_64::do_can_check_for_function_pointers): Return true even when building pie binaries. (Target_x86_64::possible_function_pointer_reloc): Check opcode for R_X86_64_PC32 relocations. (Target_x86_64::local_reloc_may_be_function_pointer): Pass extra arguments to local_reloc_may_be_function_pointer. (Target_x86_64::global_reloc_may_be_function_pointer): Likewise. * gc.h (gc_process_relocs): Add check for STT_FUNC. * testsuite/Makefile.am (icf_safe_pie_test): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/icf_safe_pie_test.sh: New shell script.
2017-02-03[GOLD] PowerPC64 TOC indirect to TOC relative segfaultAlan Modra
* powerpc.cc (Powerpc_relobj::make_toc_relative): Don't crash when no .toc section exists.
2017-01-31Don't allow mov-to-lea optimization for __ehdr_start.Cary Coutant
gold/ PR gold/21090 * x86_64.cc (Target_x86_64::can_convert_mov_to_lea): Add check for predefined symbol. (Target_x86_64::Relocate::relocate): Fix formatting.
2017-01-23Add -e to test scripts where necessary.Rahul Chaudhry
gold/ * testsuite/icf_safe_so_test.sh: Use "set -e". * testsuite/icf_safe_test.sh: Likewise. * testsuite/icf_test.sh: Likewise.
2017-01-23Make the sh_info field of .rel.plt point to .plt (MIPS).Vladimir Radosavljevic
gold/ * mips.cc (Mips_output_data_plt::rel_plt): Remove const from return type. (Target_mips::make_plt_entry): Make the sh_info field of .rel.plt point to .plt.
2017-01-23Fix MIPS GOT when global symbols are forced to local visibility.Vladimir Radosavljevic
gold/ PR gold/21054 * mips.cc (Mips_got_info::record_global_got_symbol): Don't add symbol to the dynamic symbol table if it is forced to local visibility. (Target_mips::do_finalize_sections): Don't add __RLD_MAP symbol to the dynamic symbol table if it is forced to local visibility.
2017-01-20Fix problem in aarch64 gold sources uncovered by Coverty - using sizeof on a ↵Nick Clifton
pointer instead of an array. * aarch64.cc (Stub_template_repertoire): Change ST_E_835769_INSNS from a pointer to an array.
2017-01-13Gold: Fix build with GCC 4.2H.J. Lu
PR gold/21040 * powerpc.cc (Powerpc_relobj<size, big_endian>::make_toc_relative): Cast 0x80008000 to uint64_t.
2017-01-12Fix incorrect byte counts.Cary Coutant
gold/ * object.cc (Sized_relobj_file): Fix byte counts for calls to memmem.
2017-01-11Fix more compile errors with GCC 4.2.Cary Coutant
gold/ PR gold/21040 * x86_64.cc (Output_data_plt_x86_64_bnd::do_fill_first_plt_entry): Remove unnecessary 'typename' keyword. (Output_data_plt_x86_64_bnd::do_fill_plt_entry): Likewise. (Output_data_plt_x86_64_bnd::fill_aplt_entry): Likewise. (Output_data_plt_x86_64_bnd::do_fill_tlsdesc_entry): Likewise. (Output_data_plt_x86_64_bnd::do_write): Likewise.
2017-01-11Fix compile errors with GCC 4.2.Cary Coutant
gold/ PR gold/21040 * x86_64.cc (Output_data_plt_x86_64_bnd::do_fill_first_plt_entry): Remove unnecessary 'typename' keyword. (Output_data_plt_x86_64_bnd::do_fill_plt_entry): Likewise. (Output_data_plt_x86_64_bnd::do_fill_tlsdesc_entry): Likewise. (Output_data_plt_x86_64_bnd::fill_aplt_entry): Likewise. * testsuite/copy_test_relro_1.cc (p, b, c, q): Add separate extern declarations.
2017-01-11Fix test cases to work for i386.Cary Coutant
gold/ PR gold/21039 * testsuite/script_test_13.sh: Adjust patterns to work for i386. * testsuite/script_test_15a.sh: Likewise. * testsuite/script_test_15b.sh: Likewise. * testsuite/script_test_15c.sh: Likewise.
2017-01-11[GOLD] PowerPC64 TOC indirect to TOC relative code editingAlan Modra
Doesn't yet trim off the unused TOC entries. * powerpc.cc (class Powerpc_copy_relocs): New. (Powerpc_copy_relocs::emit): New function. (Powerpc_relobj::relatoc_, toc_, no_toc_opt_): New variables. (Powerpc_relobj::toc_shndx, set_no_toc_opt, no_toc_opt): New inlines. (Powerpc_relobj::do_relocate_sections): New function. (Powerpc_relobj::make_toc_relative): Likewise. (Powerpc_relobj::do_find_special_sections): Stash away .rela.toc and .toc too. (ok_lo_toc_insn): Move earlier, and handle more insns. (Target_powerpc::Scan::local): If optimizing toc accesses, set no_toc_opt for entries we can't edit. Check insn validity. Emit "toc optimization is not supported" warning, downgraded from error. (Target_powerpc::Scan::global): Likewise. (Target_powerpc::Relocate::relocate): Edit TOC indirect code to TOC relative. Don't emit "toc optimization is not supported" error here.
2017-01-10Refactor Sized_relobj_file::do_relocate_sections.Cary Coutant
gold/ * aarch64.cc (AArch64_relobj::do_relocate_sections): Call Sized_relobj_file::relocate_section_range(). * arm.cc (Arm_relobj::do_relocate_sections): Likewise. * object.h (Sized_relobj_file::relocate_section_range): New method. * reloc.cc (Sized_relobj_file::do_relocate_sections): Move implementation... (Sized_relobj_file::relocate_section_range): ...to new method.
2017-01-10[GOLD] Fix tests for powerpc64Alan Modra
PowerPC64 defines .TOC. rather than _GLOBAL_OFFSET_TABLE_, and what's more, doesn't define it at all unless referenced. For ELFv1 ABI the symbol isn't normally referenced, so modify the test to accept .TOC. as a variant of _GLOBAL_OFFSET_TABLE_ and 0 or 1 occurrences. copy_test_relro as written doesn't need copy relocs on PowerPC64. PowerPC64 is always PIC. So, modify copy_test_relro to test that the existing vars are in fact read-only directly by deliberately causing a sigsegv, and add another couple of vars that do cause copy relocs even when PIC. * testsuite/ver_test_8.sh: Accept .TOC. in lieu of _GLOBAL_OFFSET_TABLE_. Allow zero count. * testsuite/copy_test_relro_1.cc (c, q): New vars. * testsuite/copy_test_relro.cc: Rewrite to test read-only status of variables directly. Reference new vars in read-only data.
2017-01-10[GOLD] Add --secure-plt option for ppc32Alan Modra
Added just to accept, and ignore. gcc since 2015-10-21, when configured with --enable-secureplt passes this option to the linker. As powerpc gold cannot link --bss-plt code successfully, gold needs to accept the option or the gcc specs file needs to be changed. The patch also make gold detect --bss-plt code and error out rather than producing a binary that crashes. * options.h: Add --secure-plt option. * powerpc.cc (Target_powerpc::Scan::local): Detect and error on -fPIC -mbss-plt code. (Target_powerpc::Scan::global): Likewise.