aboutsummaryrefslogtreecommitdiff
path: root/gold
AgeCommit message (Collapse)AuthorFilesLines
2015-07-07Make gold aarch64 accept long form of mapping symbols.Han Shen2-4/+18
2015-07-07 Han Shen <shenhan@google.com> gold/ChangeLog: 2015-07-06 Han Shen <shenhan@google.com> * aarch64.cc (AArch64_relobj::do_count_local_symbols): Make legal of mapping symbols.
2015-07-06Align text section ends so that stub tables appears at expected addresses.Doug Kwan12-4/+51
2015-06-29Patch for gold internal error while fixing erratum 843419.Han Shen2-4/+56
The crash reason is that the insn to be moved to stub may be a relocation spot, so instead of placing the origin insn (that is insn before-relocation) to the stub, I have to place the relocated one. Note the relocation involved is non-pc-relative, so it is safe to move the relocated insn. gold/ChangeLog: 2015-06-29 Han Shen <shenhan@google.com> * AArch64.cc (Erratum_stub::Insn_utilities): New typedef. (Erratum_stub::update_erratum_insn): New method. (Stub_table::relocate_stubs): Modified to place relocated insn. (AArch64_relobj::fix_errata): Modified gold_assert.
2015-06-12[gold][aarch64] Fix erratum 835769.Han Shen3-44/+285
gold/ChangeLog: * aarch64.cc (AArch64_insn_utilities::BYTES_PER_INSN): Move defintion outside class definition. (AArch64_insn_utilities::AARCH64_ZR): New static constant. (AArch64_insn_utilities::aarch64_op31): New member. (AArch64_insn_utilities::aarch64_ra): New member. (AArch64_insn_utilities::aarch64_mac): New member. (AArch64_insn_utilities::aarch64_mlxl): New member. (ST_E_835769): New global enum member. (Stub_table::relocate_stubs): Add 835769 handler. (Stub_template_repertoire::Stub_template_repertoire): Install new stub type. (AArch64_relobj::scan_errata): This func is renamed from scan_erratum_843419. (AArch64_relobj::do_count_local_symbols): Add 835769 handler. (AArch64_relobj::do_relocate_sections): Add 835769 handler. (AArch64_relobj::scan_sections_for_stubs): Add 835769 handler. (Target_aarch64::scan_erratum_835769_span): New method. (Target_aarch64::create_erratum_stub): New method. (Target_aarch64::is_erratum_835769_sequence): New method. (Target_aarch64::scan_erratum_843419_sequence): Move part of the code into create_erratum_stub. * options.h (fix_cortex_a53_835769): New option.
2015-06-11Fix gold build error at -O0.Cary Coutant2-2/+12
In aarch64.cc, Erratum_stub::STUB_ADDR_ALIGN and Reloc_stub::STUB_ADDR_ALIGN are declared as static const int, and initialized in the class body. These values are referenced from outside the class body, and with no optimization, the references go unresolved. gold/ * aarch64.cc (Erratum_stub::STUB_ADDR_ALIGN): Move initialization outside class body. (Reloc_stub::STUB_ADDR_ALIGN): Likewise.
2015-06-11Fix bug where SECTIONS clause does not handle compressed debug sections.Cary Coutant4-12/+33
When laying out .debug_* sections, we translate the names of compressed debug sections that start with ".zdebug", but when processing input section specs in a linker script, we do not handle the translation there. This results in an internal error as reported in PR 17731. gold/ PR gold/17731 * layout.cc (corresponding_uncompressed_section_name): New function. (Layout::choose_output_section): Call it. * layout.h (corresponding_uncompressed_section_name): New function. * script-sections.cc (Input_section_info::set_section_name): Check for compressed debug section (.zdebug style).
2015-06-11Fix broken gold/testsuite/script_test_12 in some setup.Jing Yu3-0/+13
This patch adds -O0 to gold script_test_12 test, hoping that compiler won't change the order of globel variables that the test assumes. Changelog: testsuite/Makefile.am: Add -O0 to compile script_test_12 test. testsuite/Makefile.in: Regenerate.
2015-06-11[GOLD] Fix handling of __start/__stop symbolsDavide Italiano2-2/+6
If the section contains 'Q' in the name, is_cident() returns false, __start and __stop symbols for the section are not generated.. * gold.h (is_cident): Correct typo.
2015-06-10Patch for erratum-843419 (2 of 2 - fix erratum occurrences).Han Shen2-176/+710
Now fixing for 843419 is fully functional. The first part of the erratum fix CL is here - https://sourceware.org/ml/binutils/2015-04/msg00229.html gold/ChangeLog 2015-06-10 Han Shen <shenhan@google.com> * aarch64.cc(global enum): New constants representing stub types. (Stub_template): New POD struct. (Stub_template_repertoire): New class. (Stub_base): New class. (Erratum_stub): New class. (Reloc_stub): Refactored to be a subclass of Stub_base. (Reloc_stub::Stub_type): Removed. (Reloc_stub::offset): Moved to Stub_base. (Reloc_stub::set_offset): Moved to Stub_base. (Reloc_stub::destination_address): Moved to Stub_base. (Reloc_stub::set_destination_address): Moved to Stub_base. (Reloc_stub::reset_destination_address): Moved to Stub_base. (Reloc_stub::stub_type): Renamed and moved to Stub_base. (Reloc_stub::stub_size): Renamed and moved to Stub_base. (Reloc_stub::stub_insns): Renamed and moved to Stub_base. (Reloc_stub::write): Moved to Stub_base. (Reloc_stub::invalid_offset): Moved to Stub_base. (Reloc_stub::invalid_address): Moved to Stub_base. (Reloc_stub::stub_type_): Renamed and moved to Stub_base. (Reloc_stub::stub_insns_): Moved to Stub_base. (Reloc_stub::offset_): Moved to Stub_base. (Reloc_stub::destination_address_): Moved to Stub_base. (Stub_table::The_aarch64_relobj): New typedef. (Stub_table::The_erratum_stub): New typedef. (Stub_table::The_erratum_stub_less): New typedef. (Stub_table::The_erratum_stub_set): New typedef. (Stub_table::The_erratum_stub_set_iter): New typedef. (Stub_table::empty): Added emptiness testing for erratum stubs. (Stub_table::add_erratum_stub): New method to add an erratum stub. (Stub_table::find_erratum_stub): New method. (Stub_table::find_erratum_stubs_for_input_section): New method. (Stub_table::erratum_stub_address): New method. (Stub_table::update_date_size_changed_p): Modified to handle erratum stubs. (Stub_table::do_addralign): Modified to handle erratum stubs. (Stub_table::erratum_stubs_): New member. (Stub_table::erratum_stub_size_): New member. (Stub_table::relocate_stubs): Modified to handle erratum stubs. (Stub_table::do_write): Modified to handle erratum stubs. (AArch64_relobj::The_erratum_stub): New typedef. (AArch64_relobj::Erratum_stub_set_iter): New typedef. (AArch64_relobj::fix_errata): New method. (Target_aarch64::The_reloc_stub_type): Removed. (Target_aarch64::The_erratum_stub): New typede. (AArch64_relocate_functions::construct_b): New method.
2015-06-08Update French Translations for LD and GOLD.Nick Clifton2-0/+3410
ld * po/fr.po: Updated French Translation. gold * po/fr.po: New French Translation.
2015-06-07Fix incorrect handling of STT_COMMON symbols in shared libraries.Cary Coutant3-15/+27
The gABI allows STT_COMMON symbols to appear in executables and shared objects, so that the dynamic loader can resolve commons across modules. When reading a shared object, however, an STT_COMMON symbol should be treated as a regular definition at link time. In a relocatable object, the gABI requires that any STT_COMMON symbols must also be defined in the special SHN_COMMON section (which we extend to include target-specific small and large common sections). Thus, there is no need for gold to treat STT_COMMON symbols as common unless the st_shndx field is also set to a common section. gold/ PR gold/18288 * resolve.cc (symbol_to_bits): Remove type parameter; adjust all callers. Don't use STT_COMMON to check for common symbols. (Symbol_table::resolve): Warn if relocatable object has STT_COMMON symbol that's not in a common section. * symtab.h (Symbol::is_common): Don't use STT_COMMON to check for common symbols.
2015-06-04Add diststuff target to Makefile.Cary Coutant3-2/+12
gold/ PR gold/18200 * Makefile.am (diststuff): Add target. * Makefile.in: Regenerate.
2015-06-04Change default to discard temporary local symbols in merge sections.Cary Coutant4-6/+81
Add --discard-none to keep all local symbols. gold/ PR gold/17498 * object.cc (Sized_relobj_file::do_count_local_symbols): Discard temporary locals in merge sections. * options.cc (General_options::parse_discard_all): New method. (General_options::parse_discard_locals): New method. (General_options::parse_discard_none): New method. (General_options::General_options): Initialize discard_locals_. * options.h (--discard-all): Convert to special option. (--discard-locals): Likewise. (--discard-none): New option. (General_options::discard_all): New method. (General_options::discard_locals): New method. (General_options::discard_sec_merge): New method. (General_options::Discard_locals): New enum. (General_options::discard_locals_): New data member.
2015-06-03Fix SIZEOF_HEADERS in gold.Cary Coutant3-3/+35
Gold undercounts the number of program headers it's going to add when initially evaluating the SIZEOF_HEADERS expression. As a result, scripts that use it end up skipping a page unnecessarily when the starting address is too low. The undercounting is because it doesn't count the PT_INTERP segment. Then, when finalizing symbols, gold overcounts the program headers: all segments have already been created, but we still count the headers we expected to add from the script. This patch fixes both problems. gold/ * script-sections.cc (Script_sections::Script_sections): Initialize segments_created_. (Script_sections::create_note_and_tls_segments): Set flag when segments are created. (Script_sections::expected_segment_count): Count PT_INTERP. (Script_sections::attach_sections_using_phdrs_clause): Set flag when segments are created. * script-sections.h (Script_sections::segments_created_): New data member.
2015-06-03Fix gold to group sections correctly via linker script.Cary Coutant8-2/+298
In PR 15370, it is noted that gold does not distinguish between "*(.foo .bar)" and "*(.foo) *(.bar)" in linker scripts. In both cases, gold groups all .foo sections together, followed by all .bar sections, whereas in the first case, it should collect all .foo and .bar sections in the order seen. If you add sort specs, the Gnu linker has some bizarre corner cases that I do not try to replicate. In particular, "*(SORT_BY_NAME(.foo) SORT_BY_NAME(.bar))" does the same thing as "*(.foo) *(.bar)". But if you apply a sort spec to just one of several patterns, say, "*(SORT_BY_NAME(.foo) .bar)", the Gnu linker will collect any .bar section it sees before the first .foo, then all .foo sections, then all remaining .bar sections. With this patch, if any of the input patterns have a sort spec, gold will group them all as it did before; e.g., all .foo sections followed by all .bar sections. 2015-06-03 Cary Coutant <ccoutant@gmail.com> gold/ PR gold/15370 * script-sections.cc (Output_section_element_input::set_section_addresses): When there are several patterns with no sort spec, put all sections in the same bin. * testsuite/Makefile.am (script_test_12): New testcase. (script_test_12i): New testcase. * testsuite/Makefile.in: Regenerate. * testsuite/script_test_12.t: New test linker script. * testsuite/script_test_12i.t: New test linker script. * testsuite/script_test_12a.c: New test source file. * testsuite/script_test_12b.c: New test source file.
2015-06-02Fix Sniff_file to get an aligned view.Cary Coutant2-1/+6
gold/ * nacl.h (Sniff_file): Switch parameters to get_view to get an aligned view.
2015-06-02PR 17819: Fix --build-id=tree when using --compress-debug-sections.Cary Coutant6-97/+194
When --build-id=tree is selected, gold would schedule a set of tasks to run to compute md5 hashes in parallel on chunks of the file. The scheduling was done before the Write_after_input_sections_task ran, so if we are compressing debug sections, the output file will change size and be remapped to a new address, sometimes causing the build id computation to crash, but even when it doesn't crash, it wouldn't include the debug information in the hash computation. This patch delays the scheduling of the md5 tasks until after Write_after_input_sections_task. gold/ PR gold/17819 * gold.cc (queue_final_tasks): When --build-id=tree, queue a separate task to schedule the build id computation. * layout.cc (Hash_task::Hash_task): Remove build_id_blocker, add Output_file and offset. (Hash_task::run): Get and release the input views. (Hash_task::is_runnable): Always return NULL (always runnable). (Layout::queue_build_id_tasks): Remove. (Layout::write_build_id): Add array_of_hashes and size_of_hashes parameters; use them instead of class members. (Build_id_task_runner::run): New function. (Close_task_runner::run): Pass array_of_hashes and size_of_hashes to write_build_id. * layout.h (Layout::queue_build_id_tasks): Remove. (Layout::write_build_id): Add array_of_hashes and size_of_hashes parameters. (Layout::array_of_hashes_): Remove. (Layout::size_of_array_of_hashes_): Remove. (Layout::input_view_): Remove. (Build_id_task_runner): New class. (Close_task_runner::Close_task_runner): Add array_of_hashes and size_of_hashes parameters. (Close_task_runner::array_of_hashes_): New data member. (Close_task_runner::size_of_hashes_): New data member. * testsuite/Makefile.am (flagstest_compress_debug_sections_and_build_id_tree): New test. * testsuite/Makefile.in: Regenerate.
2015-06-01Use a std::vector instead of a std::map to hold Input_merge_map.Rafael Ávila de Espíndola3-35/+19
A std::map is hardly the best data structure for a small map from small integers.
2015-05-16[GOLD] Add PowerPC64 -fsplit-stack supportAlan Modra3-6/+139
PowerPC64 ELFv1 requires a tweak to find_functions in order to return code addresses, rather than OPD entry addresses. * reloc.cc (Sized_relobj_file::find_functions): Use function_location. * powerpc.cc (Target_powerpc::do_calls_non_split): New function. (addi_12_1, addis_2_12, addis_12_1, cmpld_7_12_0): New constants. (lis_0): Rename from lis_0_0.
2015-05-02Change Section_id type to use Relobj* instead of Object*.Cary Coutant12-43/+80
2015-04-29 Cary Coutant <cary@google.com> Rafael Ávila de Espíndola <rafael.espindola@gmail.com> gold/ * gc.h (Garbage_collection::is_section_garbage): Change Object* to Relobj*. (Garbage_collection::add_reference): Likewise. (Garbage_collection::gc_process_relocs): Likewise. Don't push object/shndx pair onto *secvec for dynamic objects. Don't follow relocations pointing to dynamic objects for GC. * icf.cc (Icf::find_identical_sections): Change Object* to Relobj*. (Icf::unfold_section): Likewise. (Icf::is_section_folded): Likewise. (Icf::get_folded_section): Likewise. * icf.h: (Icf::get_folded_section): Likewise. (Icf::unfold_section): Likewise. (Icf::is_section_folded): Likewise. (Icf::section_has_function_pointers): Likewise. (Icf::set_section_has_function_pointers): Likewise. * object.h (Section_id): Likewise. (Const_section_id): Likewise. * output.cc (Output_section::update_section_layout): Likewise. * output.h: (Output_section_lookup_maps::find_relaxed_input_section): Likewise. * plugin.cc (update_section_order): Likewise. (unique_segment_for_sections): Likewise. * powerpc.cc (Powerpc_relobj::add_reference): Likewise. (Target_powerpc::do_gc_add_reference): Likewise. (Target_powerpc::gc_process_relocs): Likewise. (Target_powerpc::do_gc_add_reference): Likewise. * symtab.cc (Symbol_table::is_section_folded): Likewise. (Symbol_table::gc_mark_symbol): Likewise. * symtab.h: (Symbol_table::is_section_folded): Likewise. * target.h: (Sized_target::gc_add_reference): Likewise. (Sized_target::do_gc_add_reference): Likewise.
2015-04-29Updated translations for various binutils components.Nick Clifton2-629/+1856
gold * po/fi.po: Updated Finnish translation. opcodes * po/fr.po: Updated French translation. gprof * po/da.po: Update Danish translation.
2015-04-28Tidy PowerPC gold find_global_entry usesAlan Modra2-17/+35
Completely removing the assert probably wasn't the best idea, so reinstate it for allocated sections. Also cope with debug info potentially referring to a missing plt call stub. And a tidy. find_global_entry now returns an Address, so make temps holding the return value of type Address, and compare against invalid_address. * powerpc.cc (Target_powerpc::do_dynsym_value): Use Address rather than unsigned int for find_global_entry result temp. Compare against invalid_address. (Target_powerpc::do_plt_address_for_global): Likewise. (Target_powerpc::Relocate::relocate): Likewise. Don't assert on plt call stub existence for debug info. Do assert for plt and global entry stub existence if an alloc section.
2015-04-28PowerPC gold assertion on missing global entry stubAlan Modra2-14/+23
Global entry stubs are used on ELFv2 to provide addresses for functions not defined in a non-PIC executable but whose address is taken, in much the same way as PLT stub code is used on other targets to provide function addresses. We don't want to insert a global entry stub just because (bogus) debug info refers to the address of a non-local function, but we also don't want gold to die. * powerpc.cc (Target_powerpc::Relocate::relocate): Don't assert on missing global entry stub due to bogus debug info.
2015-04-27[gold] Rename '--fix-cortex-a53' to '--fix-cortex-a53-843419'.Han Shen3-6/+14
Keep gold consistent with bfd erratum-fixing option names, so as to ease life in Makefile/scripts. gold/ * options.h (--fix-cortex-a53-843419): Rename option. * aarch64.cc (AArch64_relobj::do_count_local_symbols): Use renamed option. (AArch64_relobj::scan_sections_for_stubs): Use renamed option.
2015-04-27If a range is missing, assume the input address is mapped.Rafael Ávila de Espíndola6-6/+77
When Output_section::is_input_address_mapped is called we have entries for all dropped ranges, but not for all ranges.
2015-04-23Add option --weak-unresolved-symbols to treat unresolved symbols as weak ref.Sriraman Tallam6-5/+69
This patch adds option --weak-unresolved-symbols to treat unresolved symbols as weak references. This is helpful when we want the link to succeed with unresolved symbols and the dynamic loader to not complain at run-time. Option --warn-unresolved-symbols lets the link succeed but could fail at run-time with unresolved symbol warnings especially when the unresolved symbols have GOT entries and dynamic relocations against them, like when -fPIE is used.
2015-04-23Add option --weak-unresolved-symbols to treat unresolved as weak references.Sriraman Tallam1-0/+45
This patch adds option --weak-unresolved-symbols to treat unresolved symbols as weak references. This is helpful when we want the link to succeed with unresolved symbols and the dynamic loader to not complain at run-time. Option --warn-unresolved-symbols lets the link succeed but could fail at run-time with unresolved symbol warnings especially when the unresolved symbols have GOT entries and dynamic relocations against them, like when -fPIE is used. 2015-04-23 Sriraman Tallam <tmsriram@google.com> * options.h (--weak-unresolved-symbols): New option. * symtab.cc (Symbol_table::sized_write_globals): Change symbol binding to weak with new option. * symtab.h (is_weak_undefined): Check for new option. (is_strong_undefined): Check for new option. * testsuite/Makefile.am (weak_unresolved_symbols_test): New test. * testsuite/Makefile.in: Regenerate. * testsuite/weak_unresolved_symbols_test.cc: New file.
2015-04-20Ensure that dynamically loaded libraries won't use separate copies of ↵Ian Coolidge2-1/+10
GNU_UNIQUE symbols. gold/ * symtab.cc (Symbol::should_add_dynsym_entry): Return true for GNU_UNIQUE.
2015-04-17Use LIFO instead of FIFO to implement gc's transitive closure.Rafael Ávila de Espíndola6-9/+19
FIFO is harder to implement and has less locality than LIFO. It is also not necessary to implement a transitive closure, a LIFO works just as well.
2015-04-16[gold] The first patch to address cortex-a53 erratum-843419.Han Shen3-2/+600
It implemented scanning the binary and reporting occurrences to users when '--fix-cortex-a53' is turned on. With this, gold users will be able to see if or not there are such erratum occurrences in the output binary. Also included in the CL is reading/recording mapping symbols, which is needed during scan. gold/ChangeLog: * aarch64.cc (AArch64_insn_utilities): New utility class. (AArch64_relobj::Mapping_symbol_position): New struct. (AArch64_relobj::Mapping_symbol_info): New typedef. (AArch64_relobj::do_count_local_symbols): New function overriding parent's implementation. (AArch64_relobj::mapping_symbol_info_): New member (AArch64_relobj::scan_erratum_843419): New method. (Target_aarch64::scan_erratum_843419_span): New method. (Target_aarch64::is_erratum_843419_sequence): New method. * options.h (fix_cortex_a53): New option.
2015-04-09Allow gold to resolve defined TLS symbols in a PIE link.Cary Coutant5-148/+378
This patch fixes Symbol::final_value_is_known so that a defined TLS symbol in a PIE link is treated as having a known final value, thus allowing GD->LE TLS optimization, eliminating an unnecessary GOT entry and dynamic relocation. gold/ * symtab.cc (Symbol::final_value_is_known): Check for TLS symbol in a PIE link. * testsuite/Makefile.am (tls_pie_test.sh): New test. * testsuite/Makefile.in: Regenerate. * testsuite/tls_pie_test.sh: New.
2015-04-09Improve ODR checking in gold.Cary Coutant5-17/+57
gold/ * debug.h (DEBUG_LOCATION): New. (DEBUG_ALL): Include DEBUG_LOCATION. (debug_string_to_enum): Add DEBUG_LOCATION. * dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Fix debug output to print correct context. (Sized_dwarf_line_info::do_addr2line): Add debug output. Return up to 4 more locations at the beginning of the function. * symtab.cc (Symbol_table::detect_odr_violations): Get canonical result before sorting list of line numbers. * testsuite/debug_msg.sh: Allow range of line numbers for canonical results on optimized code.
2015-04-07Add AArch32 support for arm gold linker.Han Shen2-1/+28
2015-04-06Fix the signature of a virtual method to match the one in the parent class.Rafael Ávila de Espíndola2-6/+8
2015-04-06Avoid a call to find by using the return value of insert.Rafael Ávila de Espíndola2-9/+7
2015-04-06Avoid a copy constructor call.Rafael Ávila de Espíndola2-2/+8
2015-04-06[Gold,x86_64] Convert mov foo@GOTPCREL(%rip), %reg to lea foo(%rip), %regIlya Tocar8-6/+275
2015-04-06 Ilya Tocar <ilya.tocar@intel.com> PR gold/17641 * x86_64.cc (Target_x86_64::can_convert_mov_to_lea): New. (Target_x86_64::Scan::local): Don't create GOT entry, when we can convert mov to lea. (Target_x86_64::Scan::global): Ditto. (Target_x86_64::Relocate::relocate): Convert mov foo@GOTPCREL(%rip), %reg to lea foo(%rip), %reg if possible. * testsuite/Makefile.am (x86_64_mov_to_lea): New test. * testsuite/x86_64_mov_to_lea1.s: New. * testsuite/x86_64_mov_to_lea2.s: Ditto. * testsuite/x86_64_mov_to_lea3.s: Ditto. * testsuite/x86_64_mov_to_lea4.s: Ditto. * testsuite/x86_64_mov_to_lea.sh: Ditto. ---
2015-04-02Regenerate configure in bfd/binutils/gas/gdb/goldH.J. Lu2-2/+6
bfd/ * configure: Regenerated. binutils/ * configure: Regenerated. gas/ * configure: Regenerated. gdb/ * Makefile.in (top_srcdir): New. * configure: Regenerated. gold/ * configure: Regenerated.
2015-04-01Convert mov foo@GOT(%reg), %reg to lea foo@GOTOFF(%reg), %regIlya Tocar9-33/+252
2015-04-01 Ilya Tocar <ilya.tocar@intel.com> PR gold/17640 * i386.cc (Target_i386::can_convert_mov_to_lea): New. (Target_i386::Scan::local): Don't create GOT entry, when we can convert GOT to GOTOFF. (Target_i386::Scan::global): Ditto. (Target_i386::Relocate::relocate): Convert mov foo@GOT(%reg), %reg to lea foo@GOTOFF(%reg), %reg if possible. * testsuite/Makefile.am (i386_mov_to_lea): New test. * testsuite/i386_mov_to_lea1.s: New. * testsuite/i386_mov_to_lea2.s: Ditto. * testsuite/i386_mov_to_lea3.s: Ditto. * testsuite/i386_mov_to_lea4.s: Ditto. * testsuite/i386_mov_to_lea5.s: Ditto. * testsuite/i386_mov_to_lea.sh: Ditto.
2015-04-01Regenerate configure in goldH.J. Lu10-420/+397
Regenerate configure for zlib.m4 change, which adds --with-system-zlib and removes --with-zlib in gold. zlib is enabled unconditionally with builtin zlib imported from GCC. * Makefile.am (ZLIB): New. (ZLIBINC): Likewise. (AM_CFLAGS): Add $(ZLIBINC). (AM_CXXFLAGS): Likewise. (ldadd_varldadd_var): Add $(ZLIB). (incremental_dump_LDADD): Likewise. (dwp_LDADD): Likewise. * compressed_output.cc: Don't check HAVE_ZLIB_H to include <zlib.h>. (zlib_compress): Don't check HAVE_ZLIB_H. (zlib_decompress): Likewise. * options.h (compress_debug_sections): Likewise. * configure.ac (AM_CONDITIONAL): Removed. * testsuite/Makefile.am (ZLIB): New. (LDADD): Add $(ZLIB). Don't check HAVE_ZLIB. * Makefile.in: Regenerated. * config.in: Likewise. * configure: Likewise. * testsuite/Makefile.in: Likewise.
2015-03-30Support AARCH64_TLSLD_ADD_DTPREL_* relocations.Jing Yu3-9/+34
Also Change _TLS_MODULE_BASE_. Always let it point to the start of TLS segment. 2015-03-28 Jing Yu <jingyu@google.com> * aarch64-reloc.def: New TLSLD_ADD_DTPREL_HI12, TLSLD_ADD_DTPREL_LO12_NC. * aarch64.cc (Target_aarch64::define_tls_base_symbol): Always let _TLS_MODULE_BASE_ point to the start of tls segment. (Target_aarch64::optimize_tls_reloc): Add cases for R_AARCH64_TLSLD_ADD_DTPREL_HI12 and R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC. (Target_aarch64::Scan::local): Likewise. (Target_aarch64::Scan::global): Likewise. (Target_aarch64::Relocate::relocate): Likewise. (Target_aarch64::Relocate::relocate_tls): Likewise. And remove subtracting tls segment size from symbol value for TLSLD_*_DTPREL relocations.
2015-03-27Avoid looking up Input_merge_map multiple times.Rafael Ávila de Espíndola5-29/+67
Avoid looking up Input_merge_map multiple times when we know were are processing items from the same input section.
2015-03-24PR18147, relocation overflow when --unresolved-symbols=ignore-allAlan Modra2-1/+7
If ignoring unresolved symbols, ignore reloc overflows too. If not ignoring unresolved symbols we will report an error about the symbol being undefined, making any report about reloc overflow superfluous. PR18147 * powerpc.cc (Target_powerpc::Relocate::relocate): Don't report relocation errors for branches to strong undefined symbols.
2015-03-23Remove is_merge_section_for.Rafael Ávila de Espíndola7-115/+71
Now that Input_merge_map has an Output_section_data, we can use it in implementing find_merge_section and replace the only use of is_merge_section_for with it.
2015-03-22Fix support for i386 TLS GD-to-IE optimization.Cary Coutant2-19/+14
There are two cases to support, one with an SIB-form (6-byte) LEA, the other with a 5-byte LEA and a NOP after the call __tls_get_addr. Gold did not yet support the second case. This patch adds that support. gold/ PR gold/18106 * i386.cc (Target_i386::Relocate::tls_gd_to_ie): Fix support for non-SIB form of lea, with nop after the call.
2015-03-21Fix internal error with -z relro when .tbss is last relro section.Cary Coutant2-3/+10
When calculating the padding necessary to align the end of the relro segment to a page boundary, gold erroneously ignores the .tdata section when checking to see if there are any relro sections (so if .tdata is the only relro section, we fail to align the segment properly), and erroneously pads the cumulative size of the segment based on the alignment of .tbss. If there are no relro sections following .tbss, it then fails to note the padding needed at the end of .tdata. This patch fixes both problems. is_first_section_relro() will return true when it sees a .tdata section, and we do not align the cumulative size until after checking for the .tbss section. gold/ PR gold/14217 * output.cc (Output_segment::is_first_section_relro): Don't ignore .tdata section. (Output_segment::set_section_addresses): Don't align size of relro segment for .tbss.
2015-03-21Fix bug when optimizing string pools of aligned strings.Cary Coutant2-1/+9
Tail optimization of string pools (enabled when linker is run with -O2 or greater) should not be done when the section alignment is greater than the size of the characters in the strings; otherwise, unaligned strings may result. gold/ PR gold/18010 * stringpool.cc (Stringpool_template): Don't optimize if section alignment is greater than sizeof(char).
2015-03-21PR gold/18048: Fix INCLUDE directive support for goldCary Coutant10-22/+112
This patch fixes INCLUDE directives in script files, so that when an INCLUDE appears inside a sections block, section commands block, or memory def block, the contents are parsed in the appropriate context. gold/ PR gold/18048 * script-c.h (script_include_directive): Add first_token parameter. * script.cc (script_include_directive): Add first_token parameter, and pass it to read_script_file. * yyscript.y (PARSING_SECTIONS_BLOCK, PARSING_SECTION_CMDS) (PARSING_MEMORY_DEF): New tokens. (top): Add new productions for INCLUDE files. (file_cmd): Replace file_or_sections_cmd with copy of its productions. Pass PARSING_LINKER_SCRIPT to script_include_directive. (section_block_cmd): Likewise; pass PARSING_SECTIONS_BLOCK. (section_cmd): Pass PARSING_SECTION_CMDS. (file_or_sections_cmd): Remove. (memory_def): Pass PARSING_MEMORY_DEF. * testsuite/Makefile.am (memory_test_2): New test. * testsuite/Makefile.in: Regenerate. * testsuite/memory_test_inc.t: New script file. * testsuite/memory_test_inc_1.t.src: New script file. * testsuite/memory_test_inc_2.t.src: New script file. * testsuite/memory_test_inc_3.t.src: New script file.
2015-03-21Support compressed debug sections in dynamic object files.Cary Coutant5-129/+128
This patch adds support for reading compressed debug info in shared objects. It actually simplifies things, by moving the support for compressed sections all the way up to the top-level Object class, eliminating the need for several virtual methods. gold/ * dwp.cc (Sized_relobj_dwo::do_section_contents): Delete. (Sized_relobj_dwo::setup): Build compressed section map. (Sized_relobj_dwo::do_decompressed_section_contents): Delete. * dynobj.cc (Sized_dynobj::base_read_symbols): Build compressed section map. * object.cc (Sized_relobj_file::Sized_relobj_file): Remove compressed_sections_ field. (build_compressed_section_map): Take Object instead of Sized_relobj_file parameter; add decompress_if_needed parameter. (Sized_relobj_file::do_find_special_sections): Store compressed section map in parent Object. (Sized_relobj_file::do_decompressed_section_contents): Move implementation to Object::decompressed_section_contents. (Sized_relobj_file::do_discard_decompressed_sections): Move implementation to Object::discard_decompressed_sections. * object.h (build_compressed_section_map): Declare. (Object::Object): Add compressed_sections_ field. (Object::section_is_compressed): Move implementation here. (Object::decompressed_section_contents): De-virtualize. (Object::discard_decompressed_sections): De-virtualize. (Object::do_section_is_compressed): Delete. (Object::do_decompressed_section_contents): Delete. (Object::set_compressed_sections): New method. (Object::compressed_sections): New method. (Object::compressed_sections_): New data member. (Compressed_section_info, Compressed_section_map): Move to top of file. (Sized_relobj_file::do_section_is_compressed): Delete. (Sized_relobj_file::do_decompressed_section_contents): Delete. (Sized_relobj_file::do_discard_decompressed_sections): Delete. (Sized_relobj_file::compressed_sections_): Move to Object class.
2015-03-21Fix internal error in do_relocate_sections when using plugins.Cary Coutant2-3/+9
In a previous patch for PR 14675, to fix a problem with the .eh_frame section when static linking, I added a step to finalize the .eh_frame section at the end of the first link pass. This patch caused PR 18152, where a plugin-claimed object caused a non-claimed object's layout to be deferred until replacement files were read. The call to finalize_eh_frame_section() is happening before the layout of the deferred objects, leading to the internal error in do_relocate_sections. This patch moves the finalization of the .eh_frame section to after deferred objects have been processed. gold/ PR gold/14675 PR gold/18152 * gold.cc (queue_middle_tasks): Finalize .eh_frame after laying out deferred objects.