aboutsummaryrefslogtreecommitdiff
path: root/gold/resolve.cc
AgeCommit message (Collapse)AuthorFilesLines
2016-10-06[GOLD] -Wimplicit-fallthrough warning fixesAlan Modra1-0/+1
* aarch64.cc: Spell fall through comments as "// Fall through.". * arm.cc: Likewise. * mips.cc: Likewise. * powerpc.cc: Likewise. * s390.cc: Likewise. * sparc.cc: Likewise. * x86_64.cc: Likewise. * powerpc.cc (Target_powerpc::Relocate::relocate): Add missing fall through comments. * sparc.cc: (Target_sparc::Scan::global): Likewise. (Target_sparc::Relocate::relocate): Likewise. * tilegx.cc (Target_tilegx::Relocate::relocate): Likewise. * resolve.cc (symbol_to_bits): Add missing break.
2016-01-01Copyright update for binutilsAlan Modra1-1/+1
2015-09-07Fix internal error caused by IFUNC patch.Cary Coutant1-7/+1
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-1/+7
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-18Fix symbol versioning problems in PR 18703.Cary Coutant1-9/+24
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-20Remove warning about references from shared objects to hidden symbols.Yiran Wang1-9/+4
gold/ PR gold/15574 * resolve.cc (Symbol_table): Remove warning about references from shared objects to hidden symbols. * testsuite/Makefile.am (hidden_test): Add hidden_test.syms. * testsuite/Makefile.in: Regenerate. * testsuite/hidden_test.sh: Check dynamic symbol table; update expected error messages.
2015-06-07Fix incorrect handling of STT_COMMON symbols in shared libraries.Cary Coutant1-13/+17
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-01-02ChangeLog rotatation and copyright year updateAlan Modra1-1/+1
2014-09-30Fix error from previous patch where tosize and tovalue were redefinedCary Coutant1-2/+2
in a block, shadowing the declarations outside the block. gold/ PR gold/17432 * resolve.cc (Symbol_table::resolve): Fix local shadowing error.
2014-09-25Fix problem where TLS common symbols are not allocated properly during LTO.Cary Coutant1-4/+19
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-09-17Fix handling of common symbols with plugins.Rafael Ávila de Espíndola1-1/+4
gold/ChangeLog: 2014-09-17 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> * plugin.cc (Sized_pluginobj::do_add_symbols): Ignore isym->size. * resolve.cc (Symbol_table::resolve): Don't override common symbols during the replacement phase.
2014-05-02Fix handling of __ehdr_start when it cannot be defined.Cary Coutant1-0/+4
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-05Update copyright yearsAlan Modra1-1/+1
2013-06-14gold/Cary Coutant1-6/+12
* resolve.cc (Symbol::override_base): Don't override st_type from plugin placeholder symbols. (Symbol_table::resolve): Likewise. (Symbol_table::should_override): Don't complain about TLS mismatch if the TO symbol is a plugin placeholder. * testsuite/Makefile.am (plugin_test_tls): New test. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test_tls.sh: New test script. * testsuite/two_file_test_2_tls.cc: New test source. * testsuite/two_file_test_tls.cc: New test source.
2012-03-13 * resolve.cc (Symbol_table::resolve): When merging common symbols,Ian Lance Taylor1-4/+15
keep the larger alignment.
2011-12-172011-12-17 Cary Coutant <ccoutant@google.com>Cary Coutant1-2/+2
* dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Add casts. * resolve.cc (Symbol_table::resolve): Likewise. * i386.cc (Target_i386::do_code_fill): Use char constants for nop arrays. * x86_64.cc (Target_x86_64::do_code_fill): Likewise.
2011-10-18 PR gold/13245Cary Coutant1-1/+1
* plugin.cc (is_visible_from_outside): Check for symbols referenced from dynamic objects. * resolve.cc (Symbol_table::resolve): Don't count references from dynamic objects as references from real ELF files. * testsuite/plugin_test_2.sh: Adjust expected result.
2011-07-08 PR gold/12279Ian Lance Taylor1-8/+16
* resolve.cc (Symbol_table::should_override): Add fromtype parameter. Change all callers. Give error when linking together TLS and non-TLS symbol. (Symbol_table::should_override_with_special): Add fromtype parameter. Change all callers. * i386.cc (Target_i386::Relocate::relocate_tls): Don't crash if there is no TLS segment if we have reported some errors. * x86_64.cc (Target_x86_64::relocate_tls): Likewise.
2011-07-06 PR gold/12952Ian Lance Taylor1-1/+9
* resolve.cc (Symbol::override_base_with_special): Simply override version with special symbol version, ignoring previous version.
2011-07-02 PR gold/12525Ian Lance Taylor1-2/+4
PR gold/12952 * resolve.cc (Symbol::override_base_with_special): Don't override the version if the overriding symbol has a different name. * dynobj.cc (Versions::add_def): Add dynpool parameter. Change all callers. If we give an error about an undefined version, define the base version if necessary. * dynobj.h (class Versions): Update declaration. * testsuite/weak_alias_test_5.cc: New file. * testsuite/weak_alias_test.script: New file. * testsuite/weak_alias_test_main.cc: Check that versioned_symbol and versioned_alias have the right value, and call t2. * testsuite/Makefile.am (weak_alias_test_DEPENDENCIES): Add weak_alias_test_5.so. (weak_alias_test_LDADD): Likewise. (weak_alias_test_5_pic.o, weak_alias_test_5.so): New targets. * testsuite/Makefile.in: Rebuild.
2011-06-17 PR gold/12893Ian Lance Taylor1-2/+16
* resolve.cc (Symbol_table::resolve): Don't give an error if a symbol is redefined with the exact same object and value.
2011-06-08 * common.cc (Symbol_table::do_allocate_commons_list): For incrementalCary Coutant1-0/+3
update, allocate common from bss section's free list. * incremental-dump.cc (dump_incremental_inputs): Print flag for linker-defined symbols. * incremental.cc (Sized_incremental_binary::do_process_got_plt): Skip GOT and PLT entries that are no longer referenced. (Output_section_incremental_inputs::write_info_blocks): Mark linker-defined symbols. (Sized_incr_relobj::do_add_symbols): Process linker-defined symbols. * output.cc (Output_section::allocate): New function. * output.h (Output_section::allocate): New function. * resolve.cc (Symbol_table::report_resolve_problem): Add case for linker-defined symbols. (Symbol::override_base_with_special): Copy is_predefined_ flag. * symtab.cc (Symbol::init_fields): Initialize is_predefined_ flag. (Symbol::init_base_output_data): Likewise. (Symbol::init_base_output_segment): Likewise. (Symbol::init_base_constant): Likewise. (Sized_symbol::init_output_data): Likewise. (Sized_symbol::init_output_segment): Likewise. (Sized_symbol::init_constant): Likewise. (Symbol_table::do_define_in_output_data): Likewise. (Symbol_table::do_define_in_output_segment): Likewise. (Symbol_table::do_define_as_constant): Likewise. * symtab.h (Symbol::is_predefined): New function. (Symbol::init_base_output_data): Add is_predefined parameter. (Symbol::init_base_output_segment): Likewise. (Symbol::init_base_constant): Likewise. (Symbol::is_predefined_): New data member. (Sized_symbol::init_output_data): Add is_predefined parameter. (Sized_symbol::init_output_segment): Likewise. (Sized_symbol::init_constant): Likewise. (enum Symbol_table::Defined): Add INCREMENTAL_BASE.
2010-10-11 * resolve.cc (symbol_to_bits): Report the value of the unsupportedIan Lance Taylor1-1/+1
binding.
2010-08-282010-08-27 Doug Kwan <dougkwan@google.com>Doug Kwan1-2/+9
* gold/resolve.cc (Symbol_table::should_override): Let a weak reference override an existing dynamic weak reference. * testsuite/Makefile.am: Add new test dyn_weak_ref. * testsuite/Makefile.in: Regenerate. * testsuite/dyn_weak_ref.sh: New file. * testsuite/dyn_weak_ref_1.c: Ditto. * testsuite/dyn_weak_ref_2.c: Ditto.
2010-08-132010-08-12 Cary Coutant <ccoutant@google.com>Doug Kwan1-0/+5
Doug Kwan <dougkwan@google.com> * resolve.cc (Symbol_table::should_override): When a weak dynamic defintion overrides non-weak undef, remember that the original undef is not weak. * symtab.cc (Symbol_table::sized_write_global): For undef without an original weak binding, set binding to global in output. * testsuite/Makefile.am: Add new test strong_ref_weak_def. * testsuite/Makefile.in: Regenerate. * testsuite/strong_ref_weak_def.sh: New file. * testsuite/strong_ref_weak_def_1.c: Ditto. * testsuite/strong_ref_weak_def_2.c: Ditto.
2010-07-09 * resolve.cc (Symbol_table::resolve): Remember whether undef wasCary Coutant1-10/+47
weak when resolving to a dynamic def. (Symbol_table::should_override): Add adjust_dyndef flag; set it for weak undef/dynamic def cases. Adjust callers. * symtab.cc (Symbol::init_fields): Initialize undef_binding_set_ and undef_binding_weak_. (Symbol_table::sized_write_globals): Adjust symbol binding. (Symbol_table::sized_write_symbol): Add binding parameter. * symtab.h (Symbol::set_undef_binding): New method. (Symbol::is_undef_binding_weak): New method. (Symbol::undef_binding_set_, Symbol::undef_binding_weak_): New members. (Symbol_table::should_override): Add new parameter. (Symbol_table::sized_write_symbol): Add new parameter. * testsuite/weak_undef_file1.cc: Add new test case. * testsuite/weak_undef_file2.cc: Fix header comment. * testsuite/weak_undef_test.cc: Add new test case.
2010-02-052010-02-04 Doug Kwan <dougkwan@google.com>Doug Kwan1-6/+5
PR 11247 * arm-reloc-property.cc (cstdio): Include. * configure.ac (targetobjs): Remove duplicates. * configure: Regenerate. * resolve.cc (Symbol_table::resolve): Explicit instantiate both big and little endian version for a given address size.
2010-01-11 * resolve.cc (Symbol_table::resolve): Add symbols to list of ODRIan Lance Taylor1-32/+32
candidates before doing symbol resolution.
2010-01-11 * resolve.cc (Symbol_table::resolve): Add symbols to the list ofIan Lance Taylor1-5/+7
ODR candidates if only one is weak.
2010-01-09 PR 11108Ian Lance Taylor1-2/+1
* symtab.h (class Symbol): Remove fields is_target_special_ and has_plt_offset_. Add field is_defined_in_discarded_section_. (Symbol::is_defined_in_discarded_section): New function. (Symbol::set_is_defined_in_discarded_section): New function. (Symbol::has_plt_offset): Rewrite. (Symbol::set_plt_offset): Verify that new offset is not -1U. * symtab.cc (Symbol::init_fields): Initialize plt_offset_ to -1U. Don't initialize is_target_special_ or has_plt_offset_. Initialize is_defined_in_discarded_section_. (Symbol_table::add_from_relobj): If appropriate, set is_defined_in_discarded_section. * resolve.cc (Symbol::override_base_with_special): Don't test is_target_special_. Change has_plt_offset_ to has_plt_offset(). * target-reloc.h (relocate_section): Do special handling for symbols defined in discarded sections for global symbols as well as local symbols.
2010-01-05 * options.h (class General_options): Use DEFINE_bool_alias forIan Lance Taylor1-3/+2
allow_multiple_definition. * resolve.cc (Symbol_table::should_override): Don't test allow_multiple_definition.
2010-01-05 PR 10980Ian Lance Taylor1-3/+5
* options.h (class General_options): Add --allow-multiple-definition and -z muldefs. * resolve.cc (Symbol_table::should_override): Don't warn about a multiple symbol definition if --allow-multiple-definition or -z muldefs.
2009-12-29 * symtab.h (class Symbol_table): Add enum Defined.Ian Lance Taylor1-18/+38
* resolve.cc (Symbol_table::should_override): Add defined parameter. Change all callers. Test whether object is NULL before calling a method on it. (Symbol_table::report_resolve_problem): Add defined parameter. Change all callers. (Symbol_table::should_override_with_special): Likewise. * symtab.cc (Symbol_table::define_in_output_data): Add defined parameter. Change all callers. (Symbol_table::do_define_in_output_data): Likewise. (Symbol_table::define_in_output_segment): Likewise. (Symbol_table::do_define_in_output_segment): Likewise. (Symbol_table::define_as_constant): Likewise. (Symbol_table::do_define_as_constant): Likewise. * script.h (class Symbol_assignment): Add is_defsym parameter to constructor; change all callers. * script.cc (Script_options::add_symbol_assignment): Add is_defsym parameter. Change all callers. Add is_defsym_ field. (class Parser_closure): Add parsing_defsym parameter to constructor; change all callers. Add parsing_defsym accessor function. Add parsing_defsym_ field.
2009-12-14 Revert -Wshadow changes, all changes from:Ian Lance Taylor1-19/+19
2009-12-11 Doug Kwan <dougkwan@google.com> 2009-12-11 Nick Clifton <nickc@redhat.com> * configure.ac: Remove -Wshadow when setting WARN_CXXFLAGS.
2009-12-11Add -Wshadow to the gcc command line options used when compiling the binutils.Nick Clifton1-19/+19
Fix up all warnings generated by the addition of this switch.
2009-12-052009-12-04 H.J. Lu <hongjiu.lu@intel.com>H.J. Lu1-0/+2
* resolve.cc (symbol_to_bits): Treat STB_GNU_UNIQUE as STB_GLOBAL. (Symbol_table::override_with_special): Likewise. (Symbol_table::add_from_object): Likewise.
2009-11-04 PR 10860Ian Lance Taylor1-15/+78
* options.h (class General_options): Add --warn-common. * resolve.cc (Symbol_table::resolve): Handle --warn-common when merging two common symbols. (Symbol_table::should_override): Handle --warn-common when merging a common symbol with a defined symbol. Use report_resolve_problem for multiple definitions. (Symbol_table::report_resolve_problem): New function. * symtab.h (class Symbol_table): Declare report_resolve_problem.
2009-09-30 * object.h (class Object): Remove target_ field, and target,Ian Lance Taylor1-2/+2
sized_target, and set_target methods. (Object::sized_target): Remove. (class Sized_relobj): Update declarations. Remove sized_target. * object.cc (Sized_relobj::setup): Remove target parameter. Change all callers. (Input_objects::add_object): Don't do anything with the target. (make_elf_sized_object): Add punconfigured parameter. Change all callers. Set or test parameter target. * dynobj.cc (Sized_dynobj::target): Remove target parameter. Change all callers. * parameters.cc (Parameters::set_target): Change parameter type to be non-const. (Parameters::default_target): Remove. (set_parameters_target): Change parameter type to be non-const. (parameters_force_valid_target): New function. (parameters_clear_target): New function. * parameters.h (class Parameters): Update declarations. Remove default_target method. Add sized_target and clear_target methods. Change target_ to be non-const. (set_parameters_target): Update declaration. (parameters_force_valid_target): Declare. (parameters_clear_target): Declare. * readsyms.cc (Read_symbols::do_read_symbols): Pass punconfigured as NULL if we aren't searching. (Add_symbols::run): Don't check for compatible target. * fileread.cc (Input_file::open_binary): Call parameters_force_valid_target. * gold.cc (queue_middle_tasks): Likewise. * plugin.cc (make_sized_plugin_object): Likewise. Don't call set_target on object. * dynobj.h (class Sized_dynobj): Update declarations. * archive.cc (Archive::get_elf_object_for_member): Return NULL if make_elf_object returns NULL. (Archive::include_member): Don't check whether object target is compatible. * output.cc (Output_section::add_input_section): Get target from parameters. (Output_section::relax_input_section): Likewise. * reloc.cc (Sized_relobj::do_gc_process_relocs): Get target from parameters. (Sized_relobj::do_scan_relocs): Likewise. (Sized_relobj::relocate_sections): Likewise. * resolve.cc (Symbol_table::resolve): Likewise. * symtab.cc (Symbol_table::wrap_symbol): Likewise. Remove object parameter. Change all callers. (Symbol_table::add_from_object): Get target from parameters. (Symbol_table::add_from_relobj): Don't check object target. (Symbol_table::add_from_dynobj): Likewise. (Symbol_table::define_special_symbol): Get target from parameters. * symtab.h (class Symbol_table): Update declaration. * testsuite/binary_unittest.cc (gold_testsuite): Remove target parameter. Change all callers. Clear parameter target. (Binary_test): Test target here. * testsuite/object_unittest.cc (gold_testsuite): Remove target_test_pointer parameter. Change all callers. (Object_test): Test target here.
2009-08-19 * resolve.cc (Symbol_table::resolve): Don't complain about definedCary Coutant1-2/+3
symbols in shared libraries overridden by hidden or internal symbols in the main program.
2009-08-12 PR 10471Cary Coutant1-0/+14
* resolve.cc (Symbol_table::resolve): Check for references from dynamic objects to hidden and internal symbols. * testsuite/Makefile.am (hidden_test.sh): New test. * testsuite/Makefile.in: Regenerate. * testsuite/hidden_test.sh: New script. * testsuite/hidden_test_1.c: New test source. * testsuite/hidden_test_main.c: New test source.
2009-06-22 * layout.cc (Layout::make_output_section): CallIan Lance Taylor1-0/+2
Target::new_output_section. (Layout::attach_allocated_section_to_segment): Put large section sections in a separate load segment with the large segment flag set. (Layout::segment_precedes): Sort large data segments after other load segments. (align_file_offset): New static function. (Layout::set_segment_offsets): Use align_file_offset. * output.h (class Output_section): Add is_small_section_ and is_large_section_ fields. (Output_section::is_small_section): New function. (Output_section::set_is_small_section): New function. (Output_section::is_large_section): New function. (Output_section::set_is_large_section): New function. (Output_section::is_large_data_section): New function. (class Output_segment): Add is_large_data_segment_ field. (Output_segment::is_large_data_segment): New function. (Output_segment::set_is_large_data_segment): New function. * output.cc (Output_section::Output_section): Initialize new fields. (Output_segment::Output_segment): Likewise. (Output_segment::add_output_section): Add assertion that large data sections always go in large data segments. Force small data sections to the end of the list of data sections. Force small BSS sections to the start of the list of BSS sections. For large BSS sections to the end of the list of BSS sections. * symtab.h (class Symbol): Declare is_common_shndx. (Symbol::is_defined): Check Symbol::is_common_shndx. (Symbol::is_common): Likewise. (class Symbol_table): Define enum Commons_section_type. Update declarations. Add small_commons_ and large_commons_ fields. * symtab.cc (Symbol::is_common_shndx): New function. (Symbol_table::Symbol_table): Initialize new fields. (Symbol_table::add_from_object): Put small and large common symbols in the right list. (Symbol_table::sized_finalized_symbol): Check Symbol::is_common_shndx. (Symbol_table::sized_write_globals): Likewise. * common.cc (Symbol_table::do_allocate_commons): Allocate new common symbol lists. Don't call do_allocate_commons_list if the list is empty. (Symbol_table::do_allocate_commons_list): Remove is_tls parameter. Add comons_section_type parameter. Change all callers. Handle small and large common symbols. * object.cc (Sized_relobj::do_finalize_local_symbols): Check Symbol::is_common_shndx. * resolve.cc (symbol_to_bits): Likewise. * target.h (Target::small_common_shndx): New function. (Target::small_common_section_flags): New function. (Target::large_common_shndx): New function. (Target::large_common_section_flags): New function. (Target::new_output_section): New function. (Target::Target_info): Add small_common_shndx, large_common_shndx, small_common_section_flags, and large_common_section_flags fields. (Target::do_new_output_section): New virtual function. * arm.cc (Target_arm::arm_info): Initialize new fields. * i386.cc (Target_i386::i386_info): Likewise. * powerpc.cc (Target_powerpc::powerpc_info) [all versions]: Likewise. * sparc.c (Target_sparc::sparc_info) [all versions]: Likewise. * x86_64.cc (Target_x86_64::x86_64_info): Likewise. (Target_x86_64::do_new_output_section): New function. * configure.ac: Define conditional MCMODEL_MEDIUM. * testsuite/Makefile.am (check_PROGRAMS): Add large. (large_SOURCES, large_CFLAGS, large_DEPENDENCIES): Define. (large_LDFLAGS): Define. * testsuite/large.c: New file. * testsuite/testfile.cc (Target_test::test_target_info): Initialize new fields. * configure, testsuite/Makefile.in: Rebuild.
2009-02-27 PR 9836Ian Lance Taylor1-4/+32
* symtab.cc (Symbol_table::add_from_object): If the visibility is hidden or internal, force the symbol to be local. * resolve.cc (Symbol::override_visibility): Define. (Symbol::override_base): Use override_visibility. (Symbol_table::resolve): Likewise. (Symbol::override_base_with_special): Likewise. (Symbol_table::override_with_special): If the visibility is hidden or internal, force the symbol to be local. * symtab.h (class Symbol): Add set_visibility and override_visibility. * testsuite/ver_test_1.sh: New file. * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_1.sh. (check_DATA): Add ver_test_1.syms. (ver_test_1.syms): New target. * testsuite/Makefile.in: Rebuild.
2008-09-19Add plugin functionality for link-time optimization (LTO).Cary Coutant1-0/+19
include/: * plugin-api.h: New file. gold/: * configure.ac (plugins): Add --enable-plugins option. * configure: Regenerate. * config.in: Regenerate. * Makefile.am (LIBDL): New variable. (CCFILES): Add plugin.cc. (HFILES): Add plugin.h. (ldadd_var): Add LIBDL. * Makefile.in: Regenerate. * archive.cc: Include "plugin.h". (Archive::setup): Don't preread archive symbols when using a plugin. (Archive::get_file_and_offset): Add memsize parameter. Change callers. (Archive::get_elf_object_for_member): Call plugin hooks for claiming files. (Archive::include_member): Add symbols from plugin objects. * archive.h (Archive::get_file_and_offset): Add memsize parameter. * descriptors.cc (Descriptors::open): Check for file descriptors abandoned by plugins. (Descriptors::claim_for_plugin): New function. * descriptors.h (Descriptors::claim_for_plugin): New function. (Open_descriptor::is_claimed): New field. (claim_descriptor_for_plugin): New function. * fileread.cc (File_read::claim_for_plugin): New function. * fileread.h (File_read::claim_for_plugin): New function. (File_read::descriptor): New function. * gold.cc: Include "plugin.h". (queue_initial_tasks): Add task to call plugin hooks for generating new object files. * main.cc: Include "plugin.h". (main): Load plugin libraries. * object.h (Pluginobj): Declare. (Object::pluginobj): New function. (Object::do_pluginobj): New function. (Object::set_target): New function. * options.cc: Include "plugin.h". (General_options::parse_plugin): New function. (General_options::General_options): Initialize plugins_ field. (General_options::add_plugin): New function. * options.h (Plugin_manager): Declare. (General_options): Add --plugin option. (General_options::has_plugins): New function. (General_options::plugins): New function. (General_options::add_plugin): New function. (General_options::plugins_): New field. * plugin.cc: New file. * plugin.h: New file. * readsyms.cc: Include "plugin.h". (Read_symbols::do_read_symbols): Check for archive before checking for ELF file. Call plugin hooks to claim files. * resolve.cc (Symbol_table::resolve): Record when symbol is referenced from a real object file; force override when processing replacement files. * symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field. (Symbol::init_base_object): Likewise. (Symbol::init_base_output_data): Likewise. (Symbol::init_base_output_segment): Likewise. (Symbol::init_base_constant): Likewise. (Symbol::init_base_undefined): Likewise. (Symbol::output_section): Assert that object is not a plugin. (Symbol_table::add_from_pluginobj): New function. (Symbol_table::sized_finalize_symbol): Treat symbols from plugins as undefined. (Symbol_table::sized_write_globals): Likewise. (Symbol_table::add_from_pluginobj): Instantiate template. * symtab.h (Sized_pluginobj): Declare. (Symbol::in_real_elf): New function. (Symbol::set_in_real_elf): New function. (Symbol::in_real_elf_): New field. (Symbol_table::add_from_pluginobj): New function. * testsuite/Makefile.am (AM_CFLAGS): New variable. (LIBDL): New variable. (LDADD): Add LIBDL. (check_PROGRAMS): Add plugin_test_1 and plugin_test_2. (check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh. (check_DATA): Add plugin_test_1.err and plugin_test_2.err. (MOSTLYCLEANFILES): Likewise. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c: New file. * testsuite/plugin_test_1.sh: New file. * testsuite/plugin_test_2.sh: New file.
2008-07-23 * symtab.cc (Symbol_table::resolve): Remove version parameter.Ian Lance Taylor1-1/+1
Change all callers. * symtab.h (class Symbol_table): Update declaration. * testsuite/ver_test_9.cc: New file. * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_9. (ver_test_9_SOURCES, ver_test_9_DEPENDENCIES): Define. (ver_test_9_LDFLAGS, ver_test_9_LDADD): Define. (ver_test_9.so, ver_test_9.o): New targets. * testsuite/Makefile.in: Rebuild.
2008-05-08 * symtab.c (Symbol::init_base_output_data): Add versionIan Lance Taylor1-11/+32
parameter. Change all callers. (Symbol::init_base_output_segment): Likewise. (Symbol::init_base_constant): Likewise. (Symbol::init_base_undefined): Likewise. (Sized_symbol::init_output_data): Likewise. (Sized_symbol::init_output_segment): Likewise. (Sized_symbol::init_constant): Likewise. (Sized_symbol::init_undefined): Likewise. (Symbol_table::do_define_in_output_data): If the new symbol has a version, mark it as the default. (Symbol_table::do_define_in_output_segment): Likewise. (Symbol_table::do_define_as_constant): Likewise. * symtab.h (class Symbol): Update declarations. (class Sized_symbol): Likewise. * resolve.cc (Symbol::override_version): New function. (Symbol::override_base: Call override_version. (Symbol::override_base_with_special): Likewise. * testsuite/ver_script_8.script: New file. * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_8. (ver_test_8_SOURCES, ver_test_8_DEPENDENCIES): Define. (ver_test_8_LDFLAGS, ver_test_8_LDADD): Define. (ver_test_8_1.so, ver_test_8_2.so): New targets.
2008-05-07 PR 6049Ian Lance Taylor1-2/+6
* options.h (DEFINE_set): Add VARNAME_begin and VARNAME_end functions. (class General_options): Remove existing --undefined, and add --no-undefined instead. Add new --undefined as synonym for -u. * archive.cc (Archive::add_symbols): Check whether symbol was named with -u. * gold.cc (queue_middle_tasks): Add -u symbols to symbol table. * symtab.h (class Symbol): Rename CONSTANT to IS_CONSTANT; change all uses. Add IS_UNDEFINED. Update declarations to split different versions of init_base. Declare init_base_undefined. (Symbol::is_defined): Handle IS_UNDEFINED. (Symbol::is_undefined): Likewise. (Symbol::is_weak_undefined): Call is_undefined. (Symbol::is_absolute): Handle IS_CONSTANT. (class Sized_symbol): Update declarations to split different versions of init. Declare init_undefined. (class Symbol_table): Declare new functions. * symtab.cc (Symbol::init_base_object): Rename from init_base. Change all callers. (Symbol::init_base_output_data): Likewise. (Symbol::init_base_output_segment): Likewise. (Symbol::init_base_constant): Likewise. (Symbol::init_base_undefined): New function. (Sized_symbol::init_object): Rename from init. Change all callers. (Sized_symbol::init_output_data): Likewise. (Sized_symbol::init_output_segment): Likewise. (Sized_symbol::init_constant): Likewise. (Sized_symbol::init_undefined): New function. (Symbol_table::add_undefined_symbols_from_command_line): New function. (Symbol_table::do_add_undefined_symbols_from_command_line): New function. (Symbol::final_value_is_known): Handle IS_UNDEFINED. (Symbol::output_section): Likewise. (Symbol::set_output_section): Likewise. (Symbol_table::sized_finalize_symbol): Likewise. (Symbol_table::sized_write_globals): Likewise. * resolve.cc (Symbol_table::should_override): Likewise. (Symbol::override_base_with_special): Likewise.
2008-04-19 * object.cc (Xindex::initialize_symtab_xindex): New function.Ian Lance Taylor1-35/+56
(Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-03-25 * i386.cc (Target_i386::Got_type): New enum declaration.Cary Coutant1-1/+0
(Target_i386::Scan::local): Updated callers of Output_data_got member functions. (Target_i386::Scan::global): Likewise. (Target_i386::Relocate::relocate): Likewise. (Target_i386::Relocate::relocate_tls): Likewise. * object.h (Got_offset_list): New class. (Sized_relobj::local_has_got_offset): Added got_type parameter. (Sized_relobj::local_got_offset): Likewise. (Sized_relobj::set_local_got_offset): Likewise. (Sized_relobj::local_has_tls_got_offset): Removed. (Sized_relobj::local_tls_got_offset): Removed. (Sized_relobj::set_local_tls_got_offset): Removed. (Sized_relobj::Local_got_offsets): Changed to store a list of offsets. * output.cc (Output_data_got::add_global): Added got_type parameter. (Output_data_got::add_global_with_rel): Likewise. (Output_data_got::add_global_with_rela): Likewise. (Output_data_got::add_global_pair_with_rel): New function. (Output_data_got::add_global_pair_with_rela): New function. (Output_data_got::add_local): Added got_type parameter. (Output_data_got::add_local_with_rel): Likewise. (Output_data_got::add_local_with_rela): Likewise. (Output_data_got::add_local_pair_with_rel): New function. (Output_data_got::add_local_pair_with_rela): New function. (Output_data_got::add_global_tls): Removed. (Output_data_got::add_global_tls_with_rel): Removed. (Output_data_got::add_global_tls_with_rela): Removed. (Output_data_got::add_local_tls): Removed. (Output_data_got::add_local_tls_with_rel): Removed. (Output_data_got::add_local_tls_with_rela): Removed. * output.h (Output_data_got::add_global): Added got_type parameter. (Output_data_got::add_global_with_rel): Likewise. (Output_data_got::add_global_with_rela): Likewise. (Output_data_got::add_global_pair_with_rel): New function. (Output_data_got::add_global_pair_with_rela): New function. (Output_data_got::add_local): Added got_type parameter. (Output_data_got::add_local_with_rel): Likewise. (Output_data_got::add_local_with_rela): Likewise. (Output_data_got::add_local_pair_with_rel): New function. (Output_data_got::add_local_pair_with_rela): New function. (Output_data_got::add_global_tls): Removed. (Output_data_got::add_global_tls_with_rel): Removed. (Output_data_got::add_global_tls_with_rela): Removed. (Output_data_got::add_local_tls): Removed. (Output_data_got::add_local_tls_with_rel): Removed. (Output_data_got::add_local_tls_with_rela): Removed. * resolve.cc (Symbol::override_base_with_special): Removed reference to has_got_offset_ field. * symtab.cc (Symbol::init_fields): Replaced initialization of got_offset_ with got_offsets_. Removed initialization of has_got_offset_ *symtab.h (Symbol::has_got_offset): Aded got_type parameter. (Symbol::got_offset): Likewise. (Symbol::set_got_offset): Likewise. (Symbol::has_tls_got_offset): Removed. (Symbol::tls_got_offset): Removed. (Symbol::set_tls_got_offset): Removed. (Symbol::got_offset_): Removed. (Symbol::tls_mod_got_offset_): Removed. (Symbol::tls_pair_got_offset_): Removed. (Symbol::got_offsets_): New field. (Symbol::has_got_offset): Removed. (Symbol::has_tls_mod_got_offset): Removed. (Symbol::has_tls_pair_got_offset): Removed. * x86_64.cc (Target_x86_64::Got_type): New enum declaration. (Target_x86_64::Scan::local): Updated callers of Output_data_got member functions. (Target_x86_64::Scan::global): Likewise. (Target_x86_64::Relocate::relocate): Likewise. (Target_x86_64::Relocate::relocate_tls): Likewise.
2008-02-29Remove gcc 3.2 compatibility hacks.Ian Lance Taylor1-13/+5
2008-02-28Don't warn about redefinitions from a --just-symbols object.Ian Lance Taylor1-0/+8