aboutsummaryrefslogtreecommitdiff
path: root/gold/symtab.cc
AgeCommit message (Collapse)AuthorFilesLines
2024-01-04Update year range in copyright notice of binutils filesAlan Modra1-1/+1
Adds two new external authors to etc/update-copyright.py to cover bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then updates copyright messages as follows: 1) Update cgen/utils.scm emitted copyrights. 2) Run "etc/update-copyright.py --this-year" with an extra external author I haven't committed, 'Kalray SA.', to cover gas testsuite files (which should have their copyright message removed). 3) Build with --enable-maintainer-mode --enable-cgen-maint=yes. 4) Check out */po/*.pot which we don't update frequently.
2023-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
The newer update-copyright.py fixes file encoding too, removing cr/lf on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2022-01-02Update year range in copyright notice of binutils filesAlan Modra1-1/+1
The result of running etc/update-copyright.py --this-year, fixing all the files whose mode is changed by the script, plus a build with --enable-maintainer-mode --enable-cgen-maint=yes, then checking out */po/*.pot which we don't update frequently. The copy of cgen was with commit d1dd5fcc38ead reverted as that commit breaks building of bfp opcodes files.
2021-09-02gold: --export-dynamic-symbol: don't imply -uFangrui Song1-6/+0
to match GNU ld. gold/ * archive.cc (Library_base::should_include_member): Don't handle --export-dynamic-symbol. * symtab.cc (Symbol_table::do_add_undefined_symbols_from_command_line): Likewise.
2021-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2020-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2019-11-19[GOLD] OSABI not set when STT_GNU_IFUNC or STB_GNU_UNIQUE symbols outputAlan Modra1-4/+31
This patch arranges to have OSABI set to ELFOSABI_GNU (if not set to some other non-zero value) when gold outputs an ifunc local or global symbol, or a unique global symbol to either .dynsym or .symtab. STT_GNU_IFUNC and STB_GNU_UNIQUE have values in the LOOS to HIOS range and therefore require interpretation according to OSABI. I'm not sure why parameters->target() is const Target& while parameters->sized_target() is Sized_target*, but it's inconvenient to use the latter in Symbol_table::finalize. So this patch adds another const_cast complained about in layout.cc and gold.cc. PR 24853 * symtab.h (set_has_gnu_output, has_gnu_output_): New. * symtab.cc (Symbol_table::Symbol_table): Init has_gnu_output_. (Symbol_table::finalize): Set ELFOSABI_GNU when has_gnu_output_. (Symbol_table::set_dynsym_indexes, Symbol_table::sized_finalize): Call set_has_gnu_output for STT_GNU_IFUNC and STB_GNU_UNIQUE globals. * object.cc (Sized_relobj_file::do_finalize_local_symbols): Call set_has_gnu_output when STT_GNU_IFUNC locals will be output.
2019-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2018-08-06Add --warn-drop-version option; by default, do not warn when discarding ↵Cary Coutant1-5/+6
version info. gold/ PR gold/23455 * options.h (General_options): Add --warn-drop-version option. * symtab.cc (Symbol_table::set_dynsym_indexes): Check it.
2018-07-14Fix problem causing duplicated linker-generated symbols with versions.Cary Coutant1-2/+5
When generating _end, _edata, etc. symbols, and a version script provides a version name, and we are linking against another shared library that provides those symbols with a different version, gold ends up trying to resolve the other shared library's symbols to the new definitions, resulting in two copies of each symbol, one as default, and one as non-default. This patch tests for that condition, and ignores the symbols provided by the other shared library. gold/ PR gold/23409 * symtab.cc (Symbol_table::define_special_symbol): Add check for version name on existing symbol. * testsuite/Makefile.am (ver_test_pr23409): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/ver_test_pr23409.sh: New test script. * testsuite/ver_test_pr23409_1.script: New version script. * testsuite/ver_test_pr23409_2.script: New version script.
2018-06-21Fix treatment of symbol versions with unused as-needed libraries.Cary Coutant1-25/+8
When we have a weak reference to a symbol defined in an as-needed library, and that library ends up not-needed, gold simply clears the version information in the symbol table, even if the symbol could have been resolved by a needed library later in the link order. This results in a loss of version information, which can cause the program to bind to the wrong version at run time. This patch lets a dynamic definition override an earlier one if the earlier one is from a not-needed library, so that we can retain the version information from the binding to the needed library. In order to do that, the tracking of needed/not-needed had to be moved up to symbol resolution time, instead of during Symbol_table::set_dynsym_indexes(). In cases where we still end up discarding version information, I've added a warning. For the original problem report and discussion, see: https://stackoverflow.com/questions/50751421/undefined-behavior-in-shared-lib-using-libpthread-but-not-having-it-in-elf-as-d gold/ * resolve.cc (Symbol_table::resolve): Rename tobinding to orig_tobinding. Call set_is_needed() for objects that resolve non-weak references. (Symbol_table::should_override): Allow a dynamic definition to override an earlier one in a not-needed library. * symtab.cc (Symbol_table::set_dynsym_indexes): Remove separate processing for as-needed symbols. Add warning when discarding version informatin. * testsuite/Makefile.am (weak_as_needed): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/weak_as_needed.sh: New test script. * testsuite/weak_as_needed_a.c: New source file. * testsuite/weak_as_needed_b.c: New source file. * testsuite/weak_as_needed_b.script: New version script. * testsuite/weak_as_needed_c.c: New source file. * testsuite/weak_as_needed_c.script: New version script.
2018-04-24Fix internal error caused by conflicting default version definitions.Cary Coutant1-11/+36
gold/ PR gold/16504 * dynobj.cc (Versions::symbol_section_contents): Don't set VERSYM_HIDDEN flag for undefined symbols. * symtab.cc (Symbol_table::add_from_object): Don't override default version definition with a different default version. * symtab.h (Symbol::from_dyn): New method. * testsuite/plugin_test.c (struct sym_info): Add ver field. (claim_file_hook): Pass symbol version to plugin API. (parse_readelf_line): Parse symbol version. * testsuite/Makefile.am (ver_test_pr16504): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/ver_test_pr16504.sh: New test script. * testsuite/ver_test_pr16504_a.c: New source file. * testsuite/ver_test_pr16504_a.script: New version script. * testsuite/ver_test_pr16504_b.c: New source file. * testsuite/ver_test_pr16504_b.script: New version script.
2018-01-03Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2017-12-01Fix problem where undef can fail to trigger archive rescan.Stephen Crane1-7/+8
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-08gold: Ignore def/ref from a dynamic object for special symbolsH.J. Lu1-9/+39
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-10-25Allow for __gnu_lto_slim prefixed with extra "_"Alan Modra1-1/+3
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-08-29[GOLD] Reduce size of class SymbolAlan Modra1-19/+19
On 64-bit targets there is a 32-bit hole in symbol->u_, and another due to symbol flags exceeding 32 bits. By splitting the union, the total size of the class reduces by one 64-bit word. * symtab.h (Symbol): Split u_ into u1_ and u2_. Adjust accessors to suit. Move plt_offset_ before got_offsets_. * symtab.cc (Symbol::init_fields): Adjust for union change. (Symbol::init_base_output_data): Likewise. (Symbol::init_base_output_segment): Likewise. (Symbol::allocate_base_common): Likewise. (Symbol::output_section): Likewise. (Symbol::set_output_section): Likewise. (Symbol::set_output_segment): Likewise. * resolve.cc (Symbol::override_base): Likewise. (Symbol::override_base_with_special): Likewise.
2017-08-28[GOLD] Symbol flag for PowerPC64 localentry:0 trackingAlan Modra1-0/+1
This patch provides a flag for PowerPC64 ELFv2 use in class Symbol, and modifies Sized_target::resolve to return whether the symbol has been resolved. If not, normal processing continues. I use this for PowerPC64 ELFv2 to keep track of whether a symbol has any definition with non-zero localentry, in order to disable --plt-localentry for that symbol. PR 21847 * powerpc.cc (Target_powerpc::is_elfv2_localentry0): Test non_zero_localentry. (Target_powerpc::resolve): New function. (powerpc_info): Set has_resolve for 64-bit. * target.h (Sized_target::resolve): Return bool. * resolve.cc (Symbol_table::resolve): Continue with normal processing when target resolve returns false. * symtab.h (Symbol::non_zero_localentry, set_non_zero_localentry): New accessors. (Symbol::non_zero_localentry_): New flag bit. * symtab.cc (Symbol::init_fields): Init non_zero_localentry_.
2017-01-02Update year range in copyright notice of all files.Alan Modra1-1/+1
2016-12-22Fix placement of forced local symbols in the dynamic symbol table.Cary Coutant1-4/+38
Gold was not placing forced-local symbols (e.g., hidden visibility) at the front of the dynamic symbol table, or including them in the count of local symbols recorded in the .dynsym section's sh_info field. gold/ * layout.cc (Layout::finalize): Track count of forced-local symbols in .dynsym. (Layout::create_symtab_sections): Add local_dynamic_count parameter; use that instead of sh_info value. (Layout::create_dynamic_symtab): Add pforced_local_dynamic_count parameter; pass it to Symtab::set_dynsym_indexes(). Include forced locals in sh_info value. Pass index of first real global to Dynobj::create_gnu_hash_table() and Dynobj::create_elf_hash_table(). * layout.h (Layout::create_symtab_sections): Add local_dynamic_count parameter. (Layout::create_dynamic_symtab): Add pforced_local_dynamic_count parameter. * symtab.cc (Symbol_table::set_dynsym_indexes): Add pforced_local_count parameter. Process forced-local symbols first and return the count. (Symbol_table::finalize): Update comments. * symtab.h (Symbol_table::set_dynsym_indexes): Add pforced_local_count parameter. (Symbol_table::first_dynamic_global_index_): Update comment. (Symbol_table::dynamic_count_): Update comment. * testsuite/Makefile.am (ifuncmod1.sh): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/ifuncmod1.sh: New shell script.
2016-12-22Fix problem where version script causes predefined hidden symbol to be ↵Cary Coutant1-22/+27
defined twice. When creating a predefined hidden symbol like _GLOBAL_OFFSET_TABLE_, gold was incorrectly letting a version script add a version to the symbol, resulting in two copies of the symbol, both STB_LOCAL, but one of which was grouped in the globals part of the symbol table. gold/ * symtab.cc (Symbol_table::define_special_symbol): Add is_forced_local parameter; if set, do not check version script. (Symbol_table::do_define_in_output_data): Pass is_forced_local for STB_LOCAL predefined symbols. (Symbol_table::do_define_in_output_segment): Likewise. (Symbol_table::do_define_in_output_segment): Likewise. (Symbol_table::do_define_as_constant): Likewise. * symtab.h (Symbol_table::define_special_symbol): Add is_forced_local parameter. Adjust all callers. * testsuite/Makefile.am (ver_test_8.sh): New test case. * testsuite/Makefile.in: Regenerate. * ver_test_8.sh: New test script.
2016-12-21Make linker-created symbols relocatable where appropriate.Cary Coutant1-1/+8
Linker-created symbols like __ehdr_start, __etext, __edata, and end should be relocatable, not absolute. gold/ * output.cc (Output_segment::first_section): Return NULL if there are no sections in the segment. * output.h (Output_segment::first_section_load_address): Assert that first section is not NULL. * symtab.cc (Symbol_table::sized_write_globals): Attach linker-created segment-relative symbols to first section of the segment.
2016-12-19Fix forced allocation of common (-d) during -r links.Cary Coutant1-1/+5
If the .bss section has other data in it besides common allocations, gold was subtracting the wrong section start address from the symbol value. gold/ PR gold/20976 * symtab.cc (Symbol_table::sized_write_globals): Use address of output section, not input section. * testsuite/Makefile.am (pr20976): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/pr20976.c: New source file.
2016-09-27Don't treat as separate symbols if unversioned symbol is undefined.Cary Coutant1-0/+1
When we see an unversioned symbol reference in a shared library, followed by a default definition of the symbol in another shared library, we were treating them as separate symbols. That should only happen when both are definitions. gold/ PR gold/20238 * symtab.cc (Symbol_table::define_default_version): Check that unversioned symbol is defined.
2016-08-10Fix potential crashes when Target::make_symbol() returns NULL.James Clarke1-4/+9
2016-08-10 James Clarke <jrtc27@jrtc27.com> gold/ PR gold/20443 * symtab.cc (Symbol_table::add_from_relobj): Handle NULL symbols, which will be present for STT_SPARC_REGISTER. (Symbol_table::add_from_pluginobj): Likewise. (Symbol_table::add_from_dynobj): Likewise. (Symbol_table::add_from_incrobj): Removed dead code.
2016-05-19Don't allow COPY relocations for protected symbols.Cary Coutant1-0/+8
gold/ PR gold/19823 * copy-relocs.cc (Copy_relocs::make_copy_reloc): Add object parameter; check for protected symbol. * copy-relocs.h (Copy_relocs::make_copy_reloc): Add object parameter. * mips.cc (Mips_copy_relocs): Adjust call to make_copy_reloc. * symtab.cc (Symbol::init_fields): Initialize is_protected_. (Symbol_table::add_from_dynobj): Mark protected symbols. * symtab.h (Symbol::is_protected): New method. (Symbol::set_is_protected): New method. (Symbol::is_protected_): New data member. * testsuite/Makefile.am (copy_test_protected): New test. * testsuite/Makefile.in: Regenerate. * testsuite/copy_test.cc (main): Add legal reference to protected symbol. * testsuite/copy_test_v1.cc (main): Likewise. * testsuite/copy_test_2.cc (ip): Add protected symbol. * testsuite/copy_test_protected.cc: New test source file. * testsuite/copy_test_protected.sh: New test script.
2016-03-30Don't override definition a shared object by one in a later shared object.Cary Coutant1-0/+7
In PR 16979, a reference to malloc is being resolved to an unversioned reference in libmalloc.so. When linked with --as-needed, however, the dynamic table does not list libmalloc.so as a DT_NEEDED library. If we have a reference to an unversioned symbol in a shared object, and we later see a versioned definition in another shared object, we were overriding the first definition with the second in the process of defining the default version. As a result, we no longer think that the first shared object was actually needed to resolve any symbols, and we don't list it as a DT_NEEDED library. This patch fixes the problem by treating the two definitions as separate symbols, so the second definition does not override the first. 2016-03-30 Cary Coutant <ccoutant@gmail.com> gold/ PR gold/16979 * symtab.cc (Symbol_table::define_default_version): Check for case where symbols are both in different shared objects.
2016-03-04Fix undefined symbol errors introduced with previous commit.Cary Coutant1-0/+30
gold/ PR gold/19019 PR gold/19763 * symtab.cc: Instantiate Sized_symbol::init_constant and Sized_symbol::init_undefined.
2016-03-03Add support for STT_SPARC_REGISTER symbols.Cary Coutant1-7/+78
gold/ PR gold/19019 * layout.h (Layout::add_target_specific_dynamic_tag): New function. * layout.cc (Layout::add_target_specific_dynamic_tag): New function. * mips.cc (Target_mips::make_symbol): Adjust function signature. * sparc.cc (Target_sparc::Target_sparc): Initialize register_syms_. (Target_sparc::do_is_defined_by_abi): Remove test for STT_SPARC_REGISTER. (Target_sparc::Register_symbol): New struct type. (Target_sparc::register_syms_): New data member. (Target_sparc<64, true>::sparc_info): Set has_make_symbol to true. (Target_sparc::make_symbol): New function. (Target_sparc::do_finalize_sections): Add register symbols and new dynamic table entries. * symtab.h (Sized_symbol::init_undefined): Add value parameter. (Symbol_table::add_target_global_symbol): New function. (Symbol_table::target_symbols_): New data member. * symtab.cc (Sized_symbol::init_undefined): Add value parameter. (Symbol_table::Symbol_table): Initialize target_symbols_. (Symbol_table::add_from_object): Pass additional parameters to Target::make_symbol. (Symbol_table::define_special_symbol): Likewise. (Symbol_table::add_undefined_symbol_from_command_line): Pass 0 for undefined symbol value. (Symbol_table::set_dynsym_indexes): Process target-specific symbols. (Symbol_table::sized_finalize): Likewise. (Symbol_table::sized_write_globals): Likewise. * target.h (Sized_target::make_symbol): Add name, st_type, object, st_shndx, and value parameters.
2016-01-01Copyright update for binutilsAlan Modra1-1/+1
2015-12-10ld -r doesn't need plugin for slim lto objectH.J. Lu1-1/+2
Plugin isn't required on slim lto object for relocatable link. PR ld/19317 * symtab.cc (Symbol_table::add_from_relobj): Don't complain plugin needed to handle slim lto object for relocatable link.
2015-11-14Fix problem where bss symbols for copy relocations are marked local.Cary Coutant1-2/+3
gold/ PR gold/19244 PR gold/18548 * symtab.cc (Symbol_table::do_define_in_output_data): Check for forced local symbols only for predefined symbols.
2015-09-07Fix internal error caused by IFUNC patch.Cary Coutant1-2/+8
The previous commit to fix PR gold/18886 converted STT_IFUNC to STT_FUNC when resolving to a symbol defined in a shared library. This leads to an internal error if the shared library symbol is seen first, as we do not convert the symbol at all. We need to override the STT_IFUNC in add_from_dynobj() instead of in override_base(). gold/ PR gold/18930 PR gold/18886 * resolve.cc (Symbol::override_base): Don't convert IFUNC symbols here. * symtab.cc (Symbol_table::add_from_dynobj): Convert them here instead.
2015-09-02Turn IFUNC symbols from shared libraries into normal FUNC symbolsH.J. Lu1-4/+1
Turn IFUNC symbols from shared libraries into normal FUNC symbols when we are resolving symbol references, instead of when we are writing out the symbol table. PR gold/18886 * resolve.cc (Symbol::override_base): Turn IFUNC symbols from shared libraries into normal FUNC symbols. * symtab.cc (Symbol_table::sized_write_symbol): Assert IFUNC symbols aren't from shared libraries.
2015-08-25Fix regression introduced by fix for PR 18703.Cary Coutant1-15/+17
When a user object overrides a versioned definition in a shared object, it's possible to trigger an internal error because the versioned definition we saw didn't override the unversioned definition. This was introduced by the fix for PR 18703. This patch fixes the problem by reordering the tests so that we do not check ret->is_default() until we're confident that the symbol is in fact versioned. gold/ PR gold/18866 PR gold/18703 * symtab.cc (Symbol_table): Reorder conditions to avoid internal error.
2015-08-18Fix symbol versioning problems in PR 18703.Cary Coutant1-3/+28
If a symbol is defined with ".symver foo,foo@VER", the assembler creates two symbols in the object: one unversioned, and one with the (non-default) version "VER". If foo is listed in a version script, gold would then make the first of those symbols the default version, and would ignore the second symbol as a duplicate, without making it a non-default version. While this is arguably reasonable behavior, it doesn't match Gnu ld behavior, so this patch fixes that by allowing the second definition to override the first by resetting the "default version" indication. Several test cases from the Gnu ld testsuite also exposed another related problem, where a symbol defined with ".symver foo,foo@", placed into a shared library, is not handled properly by gold. This patch also fixes that case, binding the symbol to the base version. gold/ PR gold/18703 * dynobj.cc (Versions::record_version): Handle symbol defined with base version. (Versions::symbol_section_contents): Likewise. * symtab.h (Symbol::set_is_not_default): New class method. (Symbol_table::resolve): Add is_default_version parameter. (Symbol_table::should_override): Likewise. * resolve.cc (Symbol_table::resolve): Add is_default_version parameter, and pass to should_override. Adjust all callers and explicit instantiations. (Symbol_table::should_override): Add is_default_value parameter; allow default version in a dynamic object to override existing definition from same object. * symtab.cc (Symbol_table::add_from_object): Handle case where same symbol is defined as unversioned and non-default version in the same object. * testsuite/Makefile.am (ver_test_13): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/ver_test_4.cc: Add test for symbol with base version. * testsuite/ver_test_4.sh: Likewise. * testsuite/ver_test_13.c: New source file. * testsuite/ver_test_13.script: New version script. * testsuite/ver_test_13.sh: New test case.
2015-07-21Fix problem where __start_ and __stop_ section symbols do not honor version ↵Cary Coutant1-0/+9
script. When creating the special __start_ and __stop_ section symbols, gold does not check the version script to see if they should be local instead of global. 2015-07-21 Cary Coutant <ccoutant@gmail.com> gold/ PR gold/18548 * symtab.cc (Symbol_table::do_define_in_output_data): Check for forced local symbol even when oldsym != NULL. (Symbol_table::do_define_in_output_segment): Likewise. (Symbol_table::do_define_as_constant): Likewise.
2015-05-02Change Section_id type to use Relobj* instead of Object*.Cary Coutant1-3/+4
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-23Add option --weak-unresolved-symbols to treat unresolved symbols as weak ref.Sriraman Tallam1-0/+7
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-20Ensure that dynamically loaded libraries won't use separate copies of ↵Ian Coolidge1-1/+5
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índola1-1/+1
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-09Allow gold to resolve defined TLS symbols in a PIE link.Cary Coutant1-3/+6
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 Coutant1-4/+7
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-01-02ChangeLog rotatation and copyright year updateAlan Modra1-1/+1
2014-12-04powerpc gold, work around pr17670Alan Modra1-1/+0
pr17670 is about an assert triggering on a branch to an undefined weak symbol, the symbol being undefined due to dropping its comdat group section. (Well sort of. The symbol is actually defined in an .opd section which isn't part of the group, but the code section the opd entry points at is dropped.) So don't assert. Also, don't make long branch stubs to such symbols, and arrange to have target-reloc.h code warn when applying relocs that use the sym. PR 17670 * symtab.cc (Symbol::set_undefined): Remove assertion. * powerpc.cc (Target_powerpc::symval_for_branch): Don't assert on symbols defined in discarded sections, instead return false. Rearrange params, update all callers. (Target_powerpc::Branch_info::make_stub): Don't make stubs for branches to syms in discarded sections. (Global_symbol_visitor_opd::operator()): Set discarded opd syms undefined and flag as discarded. (Target_powerpc::Relocate::relocate): Localize variable.
2014-09-25Fix problem where TLS common symbols are not allocated properly during LTO.Cary Coutant1-4/+8
The plugin API doesn't provide a way for the claimed file handler to identify a TLS symbol, so when adding a common TLS symbol, gold mistakenly places the symbol in the non-TLS commons list, and does not override it when we see the replacement symbol that is marked as TLS. Consequently, we allocate the TLS common symbol as a regular common, and, if it's the only TLS in the program, we'll give an internal error because we haven't allocated a TLS segment. This patch fixes the problem by removing an exclusion where common symbols would not override the placeholder symbols, but checking to see if the size needs adjusting (the original reason for the exclusion). Furthermore, we need to avoid putting placeholder symbols in the common list, and wait until we see a real common symbol with a type we can trust. gold/ PR gold/17432 * resolve.cc (Symbol_table::resolve): Override common placeholder symbols, but adjust sizes. * symtab.cc (Symbol_table::add_from_object): Don't add placeholder symbols to common lists.
2014-08-06Warn for gold on lto objects without pluginAlan Modra1-0/+4
PR 13227 * symtab.cc (Symbol_table::add_from_relobj): Warn on __gnu_lto_slim.
2014-06-27Fix undefined symbol errors from mips.ccAlan Modra1-1/+1
* symtab.cc (Symbol::should_add_dynsym_entry): Don't make inline.
2014-05-02Fix handling of __ehdr_start when it cannot be defined.Cary Coutant1-0/+25
2014-05-02 Cary Coutant <ccoutant@google.com> * defstd.cc (in_segment): Define __ehdr_start here... * layout.cc (Layout::finalize): ...Instead of here. Set the output segment when known. * resolve.cc (Symbol::override_base_with_special): Remember the original binding. * symtab.cc (Symbol::set_output_segment): New function. (Symbol::set_undefined): New function. * symtab.h (Symbol::is_weak_undefined): Check original undef binding. (Symbol::is_strong_undefined): New function. (Symbol::set_output_segment): New function. (Symbol::set_undefined): New function. * target-reloc.h (is_strong_undefined): Remove. (issue_undefined_symbol_error): Call Symbol::is_weak_undefined. Check for hidden undefs. (relocate_section): Call Symbol::is_strong_undefined. * testsuite/Makefile.am (ehdr_start_test_1) (ehdr_start_test_2, ehdr_start_test_3) (ehdr_start_test_4, ehdr_start_test_5): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/ehdr_start_def.cc: New source file. * testsuite/ehdr_start_test.cc: New source file. * testsuite/ehdr_start_test.t: New linker script. * testsuite/ehdr_start_test_4.sh: New shell script.
2014-03-10Add explicit instantiations for Sized_symbol::init_output_data.Cary Coutant1-0/+26
2014-03-10 Sasa Stankovic <Sasa.Stankovic@imgtec.com> gold/ * symtab.cc (Sized_symbol<32>::init_output_data): Instantiate the template. (Sized_symbol<64>::init_output_data): Likewise.