aboutsummaryrefslogtreecommitdiff
path: root/gold
AgeCommit message (Collapse)AuthorFilesLines
2018-02-15Fix symbol resolution with linker plugins for defsym symbols.Sriraman Tallam10-13/+261
2018-02-07 Sriraman Tallam <tmsriram@google.com> * expression.cc (Symbol_expression::set_expr_sym_in_real_elf): New method. (Unary_expression::set_expr_sym_in_real_elf): New method. (Binary_expression::set_expr_sym_in_real_elf): New method. (Trinary_expression::set_expr_sym_in_real_elf): New method. * plugin.cc (get_symbol_resolution_info): Fix symbol resolution if defined or used in defsyms. * plugin.h (Plugin_manager::is_defsym_def): New method. (Plugin_manager::Plugin_manager): Initialize defsym_defines_set_. (Plugin_manager::defsym_defines_set_): New member. (Plugin_manager::Defsym_defines_set): New typedef. * script.cc (Script_options::set_defsym_uses_in_real_elf): New method. (Script_options::find_defsym_defs): New method. * script.h (Expression::set_expr_sym_in_real_elf): New method. (Symbol_assignment::is_defsym): New method. (Symbol_assignment::value): New method. (Script_options::find_defsym_defs): New method. (Script_options::set_defsym_uses_in_real_elf): New method. * testsuite/Makefile.am (plugin_test_defsym): New test. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c: Check for new symbol resolution. * testsuite/plugin_test_defsym.sh: New script. * testsuite/plugin_test_defsym.c: New test source.
2018-02-07Revert "PowerPC PLT speculative execution barriers"Alan Modra3-54/+19
This reverts most of commit 1be5d8d3bb. Left in place are addition of --no-plt-align to some ppc32 ld tests and the ld.texinfo --no-plt-thread-safe fix.
2018-02-02Add support for DWARF-4 line number tables.Cary Coutant3-1/+20
Reads the maximum_operations_per_instruction field, added in DWARF-4 to the line number program header. gold/ * PR gold/22776 * dwarf_reader.cc (Sized_dwarf_line_info::read_header_prolog): Add support for DWARF-4 line number tables. * dwarf_reader.h (Sized_dwarf_line_info::max_ops_per_insn): New field.
2018-01-18PowerPC PLT stub alignment fixesAlan Modra2-7/+20
Asking for ppc32 plt call stubs to be aligned at 32 byte boundaries didn't quite work. For ld.bfd they were spaced 32 bytes apart, but only started on a 16 byte boundary. ld.gold also didn't get it right. Finding that bug made me check over the ppc64 plt stub alignment, where I found that negative values for alignment (meaning align to minimize boundary crossing) were not accepted. Since no one has complained about that, I guess I could have removed the feature from ld.bfd documentation, but I've opted instead to correct the code. I've also added an optional alignment paramenter for ppc32 --plt-align, for some consistency with gold and ppc64 ld.bfd. bfd/ * elf32-ppc.c (ppc_elf_create_glink): Correct alignment of .glink. * elf64-ppc.c (ppc64_elf_size_stubs): Handle negative plt_stub_align. (ppc64_elf_build_stubs): Likewise. gold/ * powerpc.cc (param_plt_align): New function supplying default --plt-align values. Use it.. (Stub_table::plt_call_align): ..here, and.. (Output_data_glink::global_entry_align): ..here. (Stub_table::stub_align): Correct 32-bit minimum alignment. ld/ * emultempl/ppc32elf.em: Support optional --plt-align arg. * emultempl/ppc64elf.em: Support negative --plt-align arg.
2018-01-17PowerPC PLT speculative execution barriersAlan Modra3-13/+64
Spectre variant 2 mitigation for PowerPC and PowerPC64. bfd/ * elf32-ppc.c (GLINK_ENTRY_SIZE): Handle speculation barrier. (CRSETEQ, BEQCTRM): Define. (is_nonpic_glink_stub): Don't check bctr. (ppc_elf_link_hash_table_create): Init new ppc_elf_params field. (ppc_elf_relax_section): Size speculation barrier. (output_bctr): New function. (write_glink_stub): Use output_bctr. (ppc_elf_relocate_section): Use output_bctr for long branch stub. (ppc_elf_finish_dynamic_symbol): Likewise. (ppc_elf_finish_dynamic_sections): Use output_bctr. * elf32-ppc.h (struct ppc_elf_params): Add speculate_indirect_jumps. * elf64-ppc.c (CRSETEQ, BEQCTRM, BEQCTRLM): Define. (GLINK_PLTRESOLVE_SIZE): Size speculation barrier. (size_global_entry_stubs): Handle speculation barrier sizing. (plt_stub_size): Likewise. (output_bctr): New function. (build_plt_stub, build_tls_get_addr_stub): Output speculation barrier. (ppc_build_one_stub): Likewise for ppc_stub_plt_branch. (ppc_size_one_stub): Size speculation barrier in ppc_stub_plt_branch. (build_global_entry_stubs): Output speculation barrier. (ppc64_elf_build_stubs): Likewise in __glink_PLTresolve stub. * elf64-ppc.h (struct ppc64_elf_params): Add speculate_indirect_jumps. gold/ * options.h (speculate_indirect_jumps): New option. * powerpc.cc (beqctrm, beqctrlm, crseteq): New insn constants. (output_bctr): New function. (Stub_table::plt_call_size): Add space for speculation barrier. (Stub_table::branch_stub_size): Likewise. (Output_data_glink::pltresolve_size): Likewise. (Stub_table::do_write): Output speculation barriers. ld/ * emultempl/ppc32elf.em (params): Init new field. (OPTION_SPECULATE_INDIRECT_JUMPS): Define. (OPTION_NO_SPECULATE_INDIRECT_JUMPS): Define. (PARSE_AND_LIST_LONGOPTS): Handle new options. (PARSE_AND_LIST_ARGS_CASES): Likewise. (PARSE_AND_LIST_OPTIONS): Likewise. * emultempl/ppc64elf.em (params): Init new field. (OPTION_SPECULATE_INDIRECT_JUMPS): Define. (OPTION_NO_SPECULATE_INDIRECT_JUMPS): Define. (PARSE_AND_LIST_LONGOPTS): Handle --speculate-indirect-jumps. (PARSE_AND_LIST_OPTIONS): Likewise. (PARSE_AND_LIST_ARGS_CASES): Likewise. * ld.texinfo (--no-plt-thread-safe): Correct itemx. (--speculate-indirect-jumps): Document. * testsuite/ld-powerpc/elfv2exe.d, * testsuite/ld-powerpc/elfv2so.d, * testsuite/ld-powerpc/relbrlt.d, * testsuite/ld-powerpc/powerpc.exp: Disable plt alignment and speculation barriers on various tests.
2018-01-17PowerPC PLT stub tidyAlan Modra3-94/+149
This is in preparation for the next patch adding Spectre variant 2 mitigation for PowerPC and PowerPC64. Besides tidying code involved in stub output (to reduce the number of places where bctr is output), the patch adds some user visible features: 1) PowerPC64 ELFv2 global entry stubs now are aligned under the control of --plt-align, with a default alignment of 32 bytes. 2) PowerPC64 __glink_PLTresolve is no longer padded out with nops. 3) PowerPC32 PLT stubs are aligned under the control of --plt-align, with the default alignment being 16 bytes as before. 4) The PowerPC32 branch/nop table emitted before __glink_PLTresolve is now smaller in many cases. It was sized incorrectly when the __tls_get_addr_opt stub was used, and unnecessarily included space for local ifuncs. bfd/ * elf32-ppc.c (GLINK_ENTRY_SIZE): Add parameters, handle __tls_get_addr_opt, and alignment sizing. (TLS_GET_ADDR_GLINK_SIZE): Delete. (is_nonpic_glink_stub): Don't use GLINK_ENTRY_SIZE. (ppc_elf_get_synthetic_symtab): Recognize stubs spaced at 4, 6, or 8 insns. (ppc_elf_link_hash_table_create): Init new ppc_elf_params field. (allocate_dynrelocs): Use new GLINK_ENTRY_SIZE. (ppc_elf_size_dynamic_sections): Likewise. Size branch table by PLT reloc count. (write_glink_stub): Handle __tls_get_addr_opt stub. Pad out to size given by GLINK_ENTRY_SIZE. (ppc_elf_relocate_section): Adjust write_glink_stub call. (ppc_elf_finish_dynamic_symbol): Likewise. (ppc_elf_finish_dynamic_sections): Write PLTresolve without using insn array since so many need rewriting. * elf32-ppc.h (struct ppc_elf_params): Add plt_stub_align. * elf64-ppc.c (GLINK_PLTRESOLVE_SIZE): Rename from GLINK_CALL_STUB_SIZE. Add htab param and evaluate to size without nops. Adjust all uses. (ppc64_elf_get_synthetic_symtab): Don't use GLINK_CALL_STUB_SIZE in glink_vma calculation. (struct ppc_link_hash_table): Add global_entry section pointer. (create_linkage_sections): Create separate section for global entry stubs. (PPC_LO, PPC_HI, PPC_HA): Move earlier. (size_global_entry_stubs): Handle sizing for aligned stubs. (ppc64_elf_size_dynamic_sections): Handle global_entry alloc, and don't stash end of glink branch table in rawsize. (ppc_build_one_stub): Rewrite stub size calculations. (build_global_entry_stubs): Use new section. (ppc64_elf_build_stubs): Don't pad __glink_PLTresolve with nops. Build lazy link stubs out to end of section. Build global entry stubs in new section. gold/ * options.h (plt_align): Support for PowerPC32 too. * powerpc.cc (Stub_table::stub_align): Heed --plt-align for 32-bit. (Stub_table::plt_call_size, branch_stub_size): Tidy. (Stub_table::plt_call_align): Implement using stub_align. (Output_data_glink::global_entry_align): New function. (Output_data_glink::global_entry_off): New function. (Output_data_glink::global_entry_address): Use global_entry_off. (Output_data_glink::pltresolve_size): New function, replacing pltresolve_size_ constant. Update all uses. (Output_data_glink::add_global_entry): Align offset. (Output_data_glink::set_final_data_size): Use global_entry_align. (Stub_table::do_write): Don't pad __glink_PLTrelsolve with nops. Tidy stub output. Use global_entry_off. ld/ * emultempl/ppc32elf.em (params): Init new field. (enum ppc32_opt): New enum to define OPTION_* values. Add OPTION_PLT_ALIGN and OPTION_NO_PLT_ALIGN. (PARSE_AND_LIST_LONGOPTS): Handle new options. (PARSE_AND_LIST_ARGS_CASES): Likewise. (PARSE_AND_LIST_OPTIONS): Likewise. Break up help output. * emultempl/ppc64elf.em (ppc_add_stub_section): Init alignment correctly for negative --plt-stub-align. * testsuite/ld-powerpc/elfv2exe.d, * testsuite/ld-powerpc/elfv2so.d, * testsuite/ld-powerpc/relbrlt.d, * testsuite/ld-powerpc/relbrlt.s, * testsuite/ld-powerpc/tlsexe.d, * testsuite/ld-powerpc/tlsexe.r, * testsuite/ld-powerpc/tlsexe32.d, * testsuite/ld-powerpc/tlsexe32.g, * testsuite/ld-powerpc/tlsexe32.r, * testsuite/ld-powerpc/tlsexetoc.d, * testsuite/ld-powerpc/tlsexetoc.r, * testsuite/ld-powerpc/tlsopt5_32.d, * testsuite/ld-powerpc/tlsso.d, * testsuite/ld-powerpc/tlstocso.d: Update for changed stub order.
2018-01-15Fix -fuse-ld option to accept string argument.Cary Coutant2-1/+6
PR 22042 complained that garbage text was being printed in the help for the -fuse-ld option; this was caused by passing an empty string to the gettext() function, which sometimes returns garbage when passed an empty string. The quick fix was to replace "" with NULL as the helparg, but that changed the parsing of the option, as gold uses the helparg to determine whether an option takes an argument. This patch adds a non-empty helparg string to fix both problems. gold/ PR gold/22694 * options.h (-fuse-ld): Add correct helparg.
2018-01-15Update Ukranian translations for bfd, binutils, gas, gold, ld and opcodesNick Clifton2-1006/+1695
2018-01-13Update pot filesNick Clifton2-910/+1587
2018-01-13Add note about 2.30 branch creation to changelogsNick Clifton1-0/+4
2018-01-12Update gold version number to 1.15.Cary Coutant3-2/+20
gold/ * NEWS: Add new features in 1.15. * version.cc (version_string): Bump to 1.15.
2018-01-12Apply:Eric Christopher2-1/+10
2018-01-12 Sterling Augustine <saugustine@google.com> * cref.cc (Cref_inputs::Cref_table_compare::operator): Add conditionals and calls to is_forwarder.
2018-01-03Update year range in copyright notice of binutils filesAlan Modra211-212/+216
2018-01-03ChangeLog rotationAlan Modra2-836/+850
2017-12-15[GOLD] PR22602, handle __tls_get_addr forwarders properlyAlan Modra2-4/+11
We never need to resolve_forwards() a symbol found by hash table lookup such as target->tls_get_addr_opt() but we do potentially need to do so for random symbols seen on relocs. So these calls were in the wrong order, resulting in missing stubs and an assertion failure. PR 22602 * powerpc.cc (Target_powerpc::Branch_info::mark_pltcall): Resolve forwards before replacing __tls_get_addr. (Target_powerpc::Branch_info::make_stub): Likewise.
2017-12-11Add plugin API for processing plugin-added input filesStephen Crane7-21/+309
Gold plugins may wish to further process an input file added by a plugin. For example, the plugin may need to assign a unique segment for sections in a plugin-generated input file. This patch adds a plugin callback that the linker will call when reading symbols from a new input file added after the all_symbols_read event (i.e. an input file added by a plugin). 2017-12-11 Stephen Crane <sjc@immunant.com> * plugin-api.h: Add new plugin hook to allow processing of input files added by a plugin. (ld_plugin_new_input_handler): New function hook type. (ld_plugin_register_new_input): New interface. (LDPT_REGISTER_NEW_INPUT_HOOK): New enum val. (tv_register_new_input): New member. * plugin.cc (Plugin::load): Include hooks for register_new_input in transfer vector. (Plugin::new_input): New function. (register_new_input): New function. (Plugin_manager::claim_file): Call Plugin::new_input if in replacement phase. * plugin.h (Plugin::set_new_input_handler): New function. * testsuite/plugin_new_section_layout.c: New plugin to test new_input plugin API. * testsuite/plugin_final_layout.sh: Add new input test. * testsuite/Makefile.am (plugin_layout_new_file): New test case. * testsuite/Makefile.in: Regenerate.
2017-12-02Handle case where posix_fallocate is not supported for a filesystem.Cary Coutant2-3/+23
2017-12-02 Vladimir Kondratyev <vladimir@kondratyev.su> Cary Coutant <ccoutant@gmail.com> gold/ PR gold/22540 * output.cc (gold_fallocate): Trivial return for len == 0. Add fallback options when posix_fallocate and fallocate return not-supported errors.
2017-12-01Disallow --incremental with -pie and force -no-pie for incremental tests.Cary Coutant6-53/+84
This is a partial fix for the gold testsuite failures documented in PR 21090. The use of -fpie triggers some mov-to-lea optimizations that are not compatible with incremental linking, so those optimizations need to be disabled. We also diagnose the attempt to use -pie with incremental linking, and force -no-pie for the incremental tests in case the build has been configured to have GCC pass -pie all the time. We still have a problem where compiling with -fpie results in some GOT entries even when linking with -no-pie. This combination still causes test failures because we are not updating the GOT entries in an incremental update link. gold/ PR gold/21090 * incremental.cc (Sized_relobj_incr::do_relocate): Fix comment. * options.cc (General_options::finalize): Disallow -pie with incremental linking. * x86_64.cc (Target_x86_64::Scan::local): Don't do mov-to-lea or callq-to-direct optimizations for incremental links. (Target_x86_64::Scan::global): Likewise. (Target_x86_64::Relocate::relocate): Likewise. * testsuite/Makefile.am (incremental_test): Force -no-pie. (incremental_test_2): Likewise. (incremental_test_3): Likewise. (incremental_test_4): Likewise. (incremental_test_5): Likewise. (incremental_test_6): Likewise. (incremental_copy_test): Likewise. (incremental_common_test_1): Likewise. (incremental_comdat_test_1): Likewise. * testsuite/Makefile.in: Regenerate.
2017-12-01Workaround GCC 7 bug with debug line numbers causing debug_msg.sh failure.Cary Coutant3-3/+17
gold/ PR gold/21841 * testsuite/debug_msg.sh: Adjust expected line numbers. * testsuite/odr_violation2.cc (DummyFunction): New function.
2017-12-01Fix incremental linking failure with GCC 7+.Cary Coutant5-4/+21
With the new compiler, we're running out of patch space for the .eh_frame section. To workaround that issue, we compile the before and after versions both with no unwind tables. gold/ PR gold/22309 * testsuite/Makefile.am (two_file_test_1_v1_ndebug.o): Compile with no EH information. (two_file_test_1_ndebug.o): Likewise. * testsuite/Makefile.in: Regenerate. * testsuite/two_file_test_1.cc: Touch to force recompilation with new flags. * testsuite/two_file_test_1_v1.cc: Likewise.
2017-12-01Fix localized help string output for -fuse-ld.Cary Coutant2-1/+6
gold/ PR gold/22042 * options.h (-fuse-ld): Use NULL instead of empty string.
2017-12-01Fix internal error from command line with unbalanced --start-lib/--end-lib.Benjamin Peterson6-11/+81
The problem is that while the command line isn't trivially empty, it contains no input files. As gold tries to configure the number of threads to use based on the number of input files, this causes the assertion failure above. Fix this problem by making the logic in gold.cc more robust and also adding a better error message about --start-lib to options.cc. gold/ PR gold/22406 * gold.cc (queue_initial_tasks) Check for number of real input files. * options.cc (Command_line::process) Check for unterminated --start-lib options. * testsuite/Makefile.am: Add new test script. * testsuite/Makefile.in: Regenerate. * testsuite/check_empty_command_lines.sh: New test script.
2017-12-01Fix problem where undef can fail to trigger archive rescan.Stephen Crane2-7/+14
If a shared library contains an undefined symbol and LTO adds a new reference to that same undefined symbol, the reference in the new object added by the plugin would not trigger a rescan of the archive containing the symbol. 2017-11-17 Stephen Crane <sjc@immunant.com> gold/ PR gold/22448 * symtab.cc (Symbol_table::add_from_object): Only rescan for undefined symbols in regular, not dynamic, objects.
2017-11-30Fix internal error in fix_errata on aarch64.Peter Smith2-0/+32
The addresses of erratum stubs can be changed by relaxation passes, and need to be updated. gold/ PR gold/20765 * aarch64.cc (Aarch64_relobj::update_erratum_address): New method. (AArch64_relobj::scan_errata): Update addresses in stub table after relaxation pass.
2017-11-30Fix problem where erratum stubs are not always applied.Cary Coutant2-3/+11
I checked over the results of applying --fix-cortex-a53-843419 to a very large program (gitit) with two stub tables and thousands of erratum fixes. I noticed that all the erratum_stubs were being created but about 1/3 of them were being skipped over by fix_errata_and_relocate_erratum_stubs(). By skipped over I mean no branch relocation or adrp -> adr transformation was applied to the erratum address, leaving the erratum_stub unreachable, and with a branch with a 0 immediate. The root cause of the skipped over erratum_stubs is Erratum_stub::invalidate_erratum_stub() that is used to set relobj_ to NULL when an erratum_stub has been processed. Unfortunately relobj_ is used in operator<() so altering relobj makes the results from erratum_stubs_.lower_bound() as used in find_erratum_stubs_for_input_section() unreliable. 2017-11-30 Peter Smith <peter.smith@linaro.org> Cary Coutant <ccoutant@gmail.com> gold/ PR gold/20765 * aarch64.cc (Erratum_stub::invalidate_erratum_stub): Use erratum_insn_ instead of relobj_ to invalidate the stub. (Erratum_stub::is_invalidated_erratum_stub): Likewise.
2017-11-30Fix segfault in relocate_erratum_stub on aarch64.Peter Smith2-1/+7
The fix for PR21868 (an internal error when --fix-cortex-a53-843419 is applied) has a small mistake in it. When the stub_owner section needs an erratum fix an incorrect address for the stubs for the section is given to relocate_erratum_stub. If we are lucky we will get a segfault; if we aren't, an incorrect patch or data corruption is possible. The error is visible in PR21868, but the side-effects aren't fatal. gold/ PR gold/22233 * aarch64.cc (AArch64_relobj::fix_errata_and_relocate_erratum_stubs): Fix calculation of stub address.
2017-11-29Support --localedir, --datarootdir and --datadirStefan Stroe2-4/+10
bfd/ * po/Make-in (datadir): Define as @datadir@. (localedir): Define as @localedir@. (gnulocaledir, gettextsrcdir): Use @datarootdir@. binutils/ * po/Make-in (datadir): Define as @datadir@. (localedir): Define as @localedir@. (gnulocaledir, gettextsrcdir): Use @datarootdir@. gas/ * po/Make-in (datadir): Define as @datadir@. (localedir): Define as @localedir@. (gnulocaledir, gettextsrcdir): Use @datarootdir@. gold/ * po/Make-in (datadir): Define as @datadir@. (localedir): Define as @localedir@. (gnulocaledir, gettextsrcdir): Use @datarootdir@. gprof/ * po/Make-in (datadir): Define as @datadir@. (localedir): Define as @localedir@. (gnulocaledir, gettextsrcdir): Use @datarootdir@. ld/ * po/Make-in (datadir): Define as @datadir@. (localedir): Define as @localedir@. (gnulocaledir, gettextsrcdir): Use @datarootdir@. opcodes/ * po/Make-in (datadir): Define as @datadir@. (localedir): Define as @localedir@. (gnulocaledir, gettextsrcdir): Use @datarootdir@.
2017-11-28Allow multiply-defined absolute symbols when they have the same value.Cary Coutant2-5/+20
gold/ * resolve.cc (Symbol_table::resolve): Allow multiply-defined absolute symbols when they have the same value.
2017-11-28Allow multiple .eh_frame sections per object file.Cary Coutant3-16/+19
LLVM is experimenting with placing .eh_frame sections in the COMDAT group with the function's text. This triggers an internal error in gold because we don't expect to see but one .eh_frame section in an object, and we use a single data member in class Sized_relobj_file to keep track of that section. This patch removes that data member, and instead checks the output section and the input section offset to identify an optimized .eh_frame section. gold/ * object.h (class Sized_relobj_file): Remove discarded_eh_frame_shndx_. * object.cc (Sized_relobj_file::Sized_relobj_file): Likewise. (Sized_relobj_file::layout_eh_frame_section): Likewise. (Sized_relobj_file::do_count_local_symbols): Check for optimized .eh_frame section by other means. (Sized_relobj_file::compute_final_local_value_internal): Likewise.
2017-11-28gold: Add a newline at end of pr22266_a.cH.J. Lu2-1/+5
This patch fixes the build with GCC 4.2: gold/testsuite/pr22266_a.c:13:2: error: no newline at end of file * testsuite/pr22266_a.c: Add a newline at end of file.
2017-11-27Fix symbol values and relocation addends for relocatable links.Cary Coutant8-28/+92
The fix for PR 19291 broke some other cases where -r is used with scripts, as reported in PR 22266. The original fix for PR 22266 ended up breaking many cases for REL targets, where the addends are stored in the section data, and are not being adjusted properly. The problem was basically that in a relocatable output file (ET_REL), symbol values are supposed to be relative to the start address of their section. Usually in a relocatable file, all sections start at 0, so the failure to get this right is often irrelevant, but with a linker script, we occasionally see an output section whose starting address is not 0, and gold would occasionally write a symbol with its relocated value instead of its section-relative value. This patch reverts the recent fix for PR 22266 as well as my original fix for PR 19291. The original fix moved the symbol value adjustment to write_local_symbols, but neglected to undo a few places where the adjustment was also being applied, resulting in an occasional double adjustment. The more recent fix removed those other adjustments, but then failed to re-account for the adjustment when rewriting the relocations on REL targets. With the old attempts reverted, we now apply the symbol value adjustment to the one case that had been missed (non-section symbols in merge sections). But now we also need to account for the adjustment when rewriting the addends for RELA relocations. gold/ PR gold/19291 PR gold/22266 * object.cc (Sized_relobj_file::compute_final_local_value_internal): Revert changes from 2017-11-08 patch. Adjust symbol value in relocatable links for non-section symbols. (Sized_relobj_file::compute_final_local_value): Revert changes from 2017-11-08 patch. (Sized_relobj_file::do_finalize_local_symbols): Likewise. (Sized_relobj_file::write_local_symbols): Revert changes from 2015-11-25 patch. * object.h (Sized_relobj_file::compute_final_local_value_internal): Revert changes from 2017-11-08 patch. * powerpc.cc (Target_powerpc::relocate_relocs): Adjust addend for relocatable links. * target-reloc.h (relocate_relocs): Adjust addend for relocatable links. * testsuite/pr22266_a.c (hello): New function. * testsuite/pr22266_main.c (main): Add test for merge sections. * testsuite/pr22266_script.t: Add rule for .rodata.
2017-11-19Fix typo in ChangeLog entry.Cary Coutant1-2/+2
2017-11-19Fix DWARF reader to use correct size for DW_FORM_ref_addr.Cary Coutant3-2/+33
2017-11-19 Ian Lance Taylor <iant@google.com> Cary Coutant <ccoutant@gmail.com> gold/ * gold/dwarf_reader.h (class Dwarf_info_reader): Add ref_addr_size method. * gold/dwarf_reader.cc (Dwarf_die::read_attributes): Use ref_addr_size for DW_FORM_ref_addr_size. (Dwarf_die::skip_attributes): Likewise.
2017-11-08gold: Ignore def/ref from a dynamic object for special symbolsH.J. Lu4-12/+60
Since special symbol must be defined in a regular object, definition from a dynamic object should be ignored. If special symbol has the hidden or internal visibility, reference from a dynamic object should also be ignored. Also __start and __stop symbols in a dynamic object shouldn't be preempted. PR gold/22291 * layout.cc (Layout::define_section_symbols): Use STV_PROTECTED for __start and __stop symbols. * symtab.cc (Symbol_table::define_special_symbol): Add an argument, visibility. Ignore definition and reference from a dynamic object, depending on visibility. (Symbol_table::do_define_in_output_data): Pass visibility to define_special_symbol. (Symbol_table::do_define_in_output_segment): Likewise. (Symbol_table::do_define_as_constant): Likewise. (Symbol_table::add_undefined_symbol_from_command_line): Pass STV_DEFAULT to define_special_symbol. * symtab.h (Symbol_table::define_special_symbol): Add an argument, visibility.
2017-11-08Fix problems with -r.James Clarke8-64/+128
The fix committed for PR gold/19291 ended up breaking other cases. The commit added adjustment code to write_local_symbols, but in many cases compute_final_local_value_internal had already subtracted the output section's address. To fix this, all other adjustments are now removed, so only the one in write_local_symbols is left. gold/ PR gold/22266 * object.cc (Sized_relobj_file::compute_final_local_value_internal): Drop relocatable parameter and stop adjusting output value based on it. (Sized_relobj_file::compute_final_local_value): Stop passing relocatable to compute_final_local_value_internal. (Sized_relobj_file::do_finalize_local_symbols): Ditto. * object.h (Sized_relobj_file::compute_final_local_value_internal): Drop relocatable parameter.
2017-11-08Apply:Eric Christopher2-2/+7
2017-11-08 Kyle Butt <iteratee@google.com> * object.cc (do_find_special_sections): Fix a thinko with memmem return values and check for != NULL rather than == 0.
2017-11-07ngettext supportAlan Modra2-2/+13
binutils has lacked proper pluralization of output messages for a long time, for example, readelf will display information about a section that "contains 1 entries" or "There are 1 section headers". Fixing this properly requires us to use ngettext, because other languages have different rules to English. This patch defines macros for ngettext and friends to handle builds with --disable-nls, and tidies the existing nls support. I've redefined gettext rather than just defining "_" as dgettext in bfd and opcodes in case someone wants to use gettext there (which might conceivably happen with generated code). bfd/ * sysdep.h: Formatting, comment fixes. (gettext, ngettext): Redefine when ENABLE_NLS. (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. (_): Define using gettext. (textdomain, bindtextdomain): Use safer "do nothing". * hosts/alphavms.h (textdomain, bindtextdomain): Likewise. (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. opcodes/ * opintl.h: Formatting, comment fixes. (gettext, ngettext): Redefine when ENABLE_NLS. (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. (_): Define using gettext. (textdomain, bindtextdomain): Use safer "do nothing". binutils/ * sysdep.h (textdomain, bindtextdomain): Use safer "do nothing". (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. gas/ * asintl.h (textdomain, bindtextdomain): Use safer "do nothing". (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. gold/ * system.h (textdomain, bindtextdomain): Use safer "do nothing". (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. ld/ * ld.h (textdomain, bindtextdomain): Use safer "do nothing". (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS.
2017-10-25Allow for __gnu_lto_slim prefixed with extra "_"Alan Modra2-1/+8
Some targets prefix global symbols with "_". bfd/ * archive.c (_bfd_compute_and_write_armap): Match "__gnu_lto_slim" optionally prefixed with "_". * linker.c (_bfd_generic_link_add_one_symbol): Likewise. binutils/ * nm.c (filter_symbols): Match "__gnu_lto_slim" optionally prefixed with "_". gold/ * symtab.cc (Symbol_table::add_from_relobj): Match "__gnu_lto_slim" optionally prefixed with "_". ld/ * testsuite/ld-plugin/lto-3r.d: Match "__gnu_lto_v" optionally prefixed with "_". * testsuite/ld-plugin/lto-5r.d: Likewise.
2017-10-20Fix ChangeLog entry.Sriraman Tallam1-1/+1
2017-10-20New gold linker option -z,text-unlikely-segment.Sriraman Tallam7-25/+178
2017-10-04 Sriraman Tallam <tmsriram@google.com> * options.h (-z,text_unlikely_segment): New option. * layout.cc (Layout::layout): Create new output section for .text.unlikely sections with the new option. (Layout::segment_precedes): Check for the new option when segment flags match. * testsuite/text_unlikely_segment.cc: New test source. * testsuite/text_unlikely_segment.sh: New test script. * testsuite/Makefile.am (text_unlikely_segment): New test. * testsuite/Makefile.in: Regenerate.
2017-10-19Implement BE8 support for ARM.Umesh Kalappa7-8/+190
gold/ * arm.cc (Stub::do_fixed_endian_write):Far call stubs support for arm in the be8 mode. * testsuite/Makefile.am: New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/arm_farcall_arm_arm_be8.sh: New script for arm to arm far call stubs. * testsuite/arm_farcall_thumb_thumb_be8.sh: New script for thumb to thumb far call stubs.
2017-10-18[GOLD] Fix powerpc64 optimization of TOC accessesAlan Modra2-2/+9
Fixes a thinko. Given code that puts variables into the TOC (a bad idea, but some see the TOC as a small data section) this bug could result in an attempt to optimize a sequence that should not be optimized. * powerpc.cc (Target_powerpc::Scan::local): Correct dst_off calculation for TOC16 relocs. (Target_powerpc::Scan::global): Likewise.
2017-09-26Fix incorrect register mask.Cary Coutant2-1/+6
PR gold/22213 * sparc.cc (Target_sparc): Fix incorrect register mask.
2017-09-22[GOLD] Set non-exec stack for aarch64Jim Wilson2-4/+9
GNU-stack notes added in 2004, aarch64 port added in 2012, so no old object files with missing GNU-stack notes that we need to worry about. gold/ * aarch64.cc (Target_aarch64::aarch64_info): Set is_default_stack_executable to false.
2017-09-22[GOLD] clone assert breakageAlan Modra2-2/+6
* resolve.cc (clone): Fix got_offset_list test.
2017-09-22[GOLD] Set non-exec stack for ppc64Alan Modra2-2/+7
gcc doesn't emit stack notes for ELFv1, since ELFv1 never needs an executable stack. Note that ELFv1 is usually big-endian and ELFv2 little-endian, but the ABI is really orthogonal to endiannes. * powerpc.cc (Target_powerpc<64,*>::powerpc_info): Set is_default_stack_executable false.
2017-09-20Check for export dynamic symbol options when doing symbol resolution in plugins.Teresa Johnson7-17/+156
2017-09-20 Teresa Johnson <tejohnson@google.com> * plugin.cc (is_visible_from_outside): Check for export dynamic symbol option and list. * testsuite/Makefile.am (plugin_test_12): New test. * testsuite/Makefile.in: Regenerate. * testsuite/export_dynamic_plugin.cc: New test source. * testsuite/plugin_test_12.sh: New test script.
2017-09-20[GOLD] PowerPC function address in non-PICAlan Modra2-5/+26
ppc32, like many targets, defines the address of a function as the PLT call stub code for functions referenced but not defined in a non-PIC executable. ppc32 gold, unlike other targets, inherits the ppc64 multiple stub capability for dealing with very large binaries where one set of stubs can't be reached from all code locations. This means there can be multiple choices of address for a function, which might cause function pointer comparison failures. So for ppc32, make non-branch references always use the first stub group. (PowerPC64 ELFv1 is always PIC so doesn't need to define the address of an external function as the PLT stub. PowerPC64 ELFv2 needs a special set of global entry stubs to serve as the address of external functions, so it too is not affected by this bug.) * powerpc.cc (Target_powerpc::Branch_info::make_stub): Put stubs for ppc32 non-branch relocs in first stub table. (Target_powerpc::Relocate::relocate): Resolve similarly.
2017-09-19[GOLD, PowerPC] Add --no-stub-group-multiAlan Modra2-2/+8
The trouble with stubs per output section is that ppc32 uses a plt stub as the address of a global function. This needs to be unique, otherwise we'll get multiple addresses for a function. Obviously this is only a partial solution, since ppc32 will get multiple stubs when code is larger than 33M. A proper fix will involve selecting a unique stub to use for non-branch relocs. * options.h (stub-group-multi): Default to true. Add --no-stub-group-multi.
2017-08-30PowerPC TPREL16_HA/LO reloc optimizationAlan Modra2-0/+38
In the TLS GD/LD to LE optimization, ld replaces a sequence like addi 3,2,x@got@tlsgd R_PPC64_GOT_TLSGD16 x bl __tls_get_addr(x@tlsgd) R_PPC64_TLSGD x R_PPC64_REL24 __tls_get_addr nop with addis 3,13,x@tprel@ha R_PPC64_TPREL16_HA x addi 3,3,x@tprel@l R_PPC64_TPREL16_LO x nop When the tprel offset is small, this can be further optimized to nop addi 3,13,x@tprel nop bfd/ * elf64-ppc.c (struct ppc_link_hash_table): Add do_tls_opt. (ppc64_elf_tls_optimize): Set it. (ppc64_elf_relocate_section): Nop addis on TPREL16_HA, and convert insn on TPREL16_LO and TPREL16_LO_DS relocs to use r13 when addis would add zero. * elf32-ppc.c (struct ppc_elf_link_hash_table): Add do_tls_opt. (ppc_elf_tls_optimize): Set it. (ppc_elf_relocate_section): Nop addis on TPREL16_HA, and convert insn on TPREL16_LO relocs to use r2 when addis would add zero. gold/ * powerpc.cc (Target_powerpc::Relocate::relocate): Nop addis on TPREL16_HA, and convert insn on TPREL16_LO and TPREL16_LO_DS relocs to use r2/r13 when addis would add zero. ld/ * testsuite/ld-powerpc/tls.s: Add calls with tls markers. * testsuite/ld-powerpc/tls32.s: Likewise. * testsuite/ld-powerpc/powerpc.exp: Run tls marker tests. * testsuite/ld-powerpc/tls.d: Adjust for TPREL16_HA/LO optimization. * testsuite/ld-powerpc/tlsexe.d: Likewise. * testsuite/ld-powerpc/tlsexetoc.d: Likewise. * testsuite/ld-powerpc/tlsld.d: Likewise. * testsuite/ld-powerpc/tlsmark.d: Likewise. * testsuite/ld-powerpc/tlsopt4.d: Likewise. * testsuite/ld-powerpc/tlstoc.d: Likewise.