summaryrefslogtreecommitdiff
path: root/gold/target-reloc.h
AgeCommit message (Collapse)Author
2018-01-03Update year range in copyright notice of binutils filesAlan Modra
2017-11-27Fix symbol values and relocation addends for relocatable links.Cary Coutant
The fix for PR 19291 broke some other cases where -r is used with scripts, as reported in PR 22266. The original fix for PR 22266 ended up breaking many cases for REL targets, where the addends are stored in the section data, and are not being adjusted properly. The problem was basically that in a relocatable output file (ET_REL), symbol values are supposed to be relative to the start address of their section. Usually in a relocatable file, all sections start at 0, so the failure to get this right is often irrelevant, but with a linker script, we occasionally see an output section whose starting address is not 0, and gold would occasionally write a symbol with its relocated value instead of its section-relative value. This patch reverts the recent fix for PR 22266 as well as my original fix for PR 19291. The original fix moved the symbol value adjustment to write_local_symbols, but neglected to undo a few places where the adjustment was also being applied, resulting in an occasional double adjustment. The more recent fix removed those other adjustments, but then failed to re-account for the adjustment when rewriting the relocations on REL targets. With the old attempts reverted, we now apply the symbol value adjustment to the one case that had been missed (non-section symbols in merge sections). But now we also need to account for the adjustment when rewriting the addends for RELA relocations. gold/ PR gold/19291 PR gold/22266 * object.cc (Sized_relobj_file::compute_final_local_value_internal): Revert changes from 2017-11-08 patch. Adjust symbol value in relocatable links for non-section symbols. (Sized_relobj_file::compute_final_local_value): Revert changes from 2017-11-08 patch. (Sized_relobj_file::do_finalize_local_symbols): Likewise. (Sized_relobj_file::write_local_symbols): Revert changes from 2015-11-25 patch. * object.h (Sized_relobj_file::compute_final_local_value_internal): Revert changes from 2017-11-08 patch. * powerpc.cc (Target_powerpc::relocate_relocs): Adjust addend for relocatable links. * target-reloc.h (relocate_relocs): Adjust addend for relocatable links. * testsuite/pr22266_a.c (hello): New function. * testsuite/pr22266_main.c (main): Add test for merge sections. * testsuite/pr22266_script.t: Add rule for .rodata.
2017-01-02Update year range in copyright notice of all files.Alan Modra
2016-03-21Fix problem where gold fails to issue an undefined symbol error during LTO.Cary Coutant
During LTO, if (1) an IR file contains a COMDAT group that is kept, (2) a later non-claimed file contains the same group, which we discard, and (3) the plugin fails to provide a definition of the symbols in that COMDAT group, gold silently resolves any references to those symbols to 0. This patch adds a check for a placeholder symbol when deciding whether to issue an undefined symbol error. It also adds an extra note after any undefined placeholder symbol error that explains that a definition was expected from the plugin. gold/ PR gold/19842 * errors.cc (Errors::undefined_symbol): Add info message when symbol should have been provided by a plugin. * target-reloc.h (issue_undefined_symbol_error): Check for placeholder symbols defined in discarded sections. * testsuite/Makefile.am (plugin_test_9b): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test_9b_elf.cc: New test source file. * testsuite/plugin_test_9b_ir.cc: New test source file.
2016-01-11Refactor gold to enable support for MIPS-64 relocation format.Cary Coutant
For MIPS-64, the r_info field in the relocation format is replaced by several individual fields, including r_sym and r_type. To enable support for this format, I've refactored target-independent code to remove almost all uses of the r_info field. (I've left alone a couple of routines used only for incremental linking, which I can update if/when the MIPS target adds support for incremental linking.) For routines that are already templated on a Classify_reloc class (namely, gc_process_relocs, relocate_section, and relocate_relocs), I've extended the Classify_reloc interface to include sh_type (which no longer needs to be a separate template parameter) as well as get_r_sym() and get_r_type() methods for extracting the r_sym and r_type fields. For scan_relocatable_relocs, I've extended the Default_scan_relocatable_relocs class by converting it to a class template with Classify_reloc as a template parameter. For the remaining routines that need to access r_sym, I've added a virtual Target::get_r_sym() method with an override for the MIPS target. In elfcpp, I've added Mips64_rel, etc., accessor classes and corresponding internal data structures. The MIPS target uses these new classes within its own Mips_classify_reloc class. The Mips64_ accessor classes also expose the r_ssym, r_type2, and r_type3 fields from the relocation. These changes should be functionally the same for all but the MIPS target. elfcpp/ * elfcpp.h (Mips64_rel, Mips64_rel_write): New classes. (Mips64_rela, Mips64_rela_write): New classes. * elfcpp_internal.h (Mips64_rel_data, Mips64_rela_data): New structs. gold/ * gc.h (get_embedded_addend_size): Remove sh_type parameter. (gc_process_relocs): Remove sh_type template parameter. Use Classify_reloc to access r_sym, r_type, and r_addend fields. * object.h (Sized_relobj_file::split_stack_adjust): Add target parameter. (Sized_relobj_file::split_stack_adjust_reltype): Likewise. * reloc-types.h (Reloc_types::copy_reloc_addend): (SHT_REL and SHT_RELA specializations) Remove. * reloc.cc (Emit_relocs_strategy): Rename and move to target-reloc.h. (Sized_relobj_file::emit_relocs_scan): Call Target::emit_relocs_scan(). (Sized_relobj_file::emit_relocs_scan_reltype): Remove. (Sized_relobj_file::split_stack_adjust): Add target parameter. Adjust all callers. (Sized_relobj_file::split_stack_adjust_reltype): Likewise. Call Target::get_r_sym() to get r_sym field from relocations. (Track_relocs::next_symndx): Call Target::get_r_sym(). * target-reloc.h (scan_relocs): Remove sh_type template parameter; add Classify_reloc template parameter. Use for accessing r_sym and r_type. (relocate_section): Likewise. (Default_classify_reloc): New class (renamed and moved from reloc.cc). (Default_scan_relocatable_relocs): Remove sh_type template parameter. (Default_scan_relocatable_relocs::Reltype): New typedef. (Default_scan_relocatable_relocs::reloc_size): New const. (Default_scan_relocatable_relocs::sh_type): New const. (Default_scan_relocatable_relocs::get_r_sym): New method. (Default_scan_relocatable_relocs::get_r_type): New method. (Default_emit_relocs_strategy): New class. (scan_relocatable_relocs): Replace sh_type template parameter with Scan_relocatable_relocs class. Use it to access r_sym and r_type fields. (relocate_relocs): Replace sh_type template parameter with Classify_reloc class. Use it to access r_sym and r_type fields. * target.h (Target::is_call_to_non_split): Replace r_type parameter with pointer to relocation. Adjust all callers. (Target::do_is_call_to_non_split): Likewise. (Target::emit_relocs_scan): New virtual method. (Sized_target::get_r_sym): New virtual method. * target.cc (Target::do_is_call_to_non_split): Replace r_type parameter with pointer to relocation. * aarch64.cc (Target_aarch64::emit_relocs_scan): New method. (Target_aarch64::Relocatable_size_for_reloc): Remove. (Target_aarch64::gc_process_relocs): Use Default_classify_reloc. (Target_aarch64::scan_relocs): Likewise. (Target_aarch64::relocate_section): Likewise. (Target_aarch64::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_aarch64::scan_relocatable_relocs): Use Default_classify_reloc. (Target_aarch64::relocate_relocs): Use Default_classify_reloc. * arm.cc (Target_arm::Arm_scan_relocatable_relocs): Remove sh_type template parameter. (Target_arm::emit_relocs_scan): New method. (Target_arm::Relocatable_size_for_reloc): Replace with... (Target_arm::Classify_reloc): ...this. (Target_arm::gc_process_relocs): Use Classify_reloc. (Target_arm::scan_relocs): Likewise. (Target_arm::relocate_section): Likewise. (Target_arm::scan_relocatable_relocs): Likewise. (Target_arm::relocate_relocs): Likewise. * i386.cc (Target_i386::emit_relocs_scan): New method. (Target_i386::Relocatable_size_for_reloc): Replace with... (Target_i386::Classify_reloc): ...this. (Target_i386::gc_process_relocs): Use Classify_reloc. (Target_i386::scan_relocs): Likewise. (Target_i386::relocate_section): Likewise. (Target_i386::scan_relocatable_relocs): Likewise. (Target_i386::relocate_relocs): Likewise. * mips.cc (Mips_scan_relocatable_relocs): Remove sh_type template parameter. (Mips_reloc_types): New class template. (Mips_classify_reloc): New class template. (Target_mips::Reltype): New typedef. (Target_mips::Relatype): New typedef. (Target_mips::emit_relocs_scan): New method. (Target_mips::get_r_sym): New method. (Target_mips::Relocatable_size_for_reloc): Replace with Mips_classify_reloc. (Target_mips::copy_reloc): Use Mips_classify_reloc. (Target_mips::gc_process_relocs): Likewise. (Target_mips::scan_relocs): Likewise. (Target_mips::relocate_section): Likewise. (Target_mips::scan_relocatable_relocs): Likewise. (Target_mips::relocate_relocs): Likewise. (mips_get_size_for_reloc): New function, factored out from Relocatable_size_for_reloc::get_size_for_reloc. (Target_mips::Scan::local): Use Mips_classify_reloc. (Target_mips::Scan::global): Likewise. (Target_mips::Relocate::relocate): Likewise. * powerpc.cc (Target_powerpc::emit_relocs_scan): New method. (Target_powerpc::Relocatable_size_for_reloc): Remove. (Target_powerpc::gc_process_relocs): Use Default_classify_reloc. (Target_powerpc::scan_relocs): Likewise. (Target_powerpc::relocate_section): Likewise. (Powerpc_scan_relocatable_reloc): Convert to class template. (Powerpc_scan_relocatable_reloc::Reltype): New typedef. (Powerpc_scan_relocatable_reloc::reloc_size): New const. (Powerpc_scan_relocatable_reloc::sh_type): New const. (Powerpc_scan_relocatable_reloc::get_r_sym): New method. (Powerpc_scan_relocatable_reloc::get_r_type): New method. (Target_powerpc::scan_relocatable_relocs): Use Powerpc_scan_relocatable_reloc. (Target_powerpc::relocate_relocs): Use Default_classify_reloc. * s390.cc (Target_s390::emit_relocs_scan): New method. (Target_s390::Relocatable_size_for_reloc): Remove. (Target_s390::gc_process_relocs): Use Default_classify_reloc. (Target_s390::scan_relocs): Likewise. (Target_s390::relocate_section): Likewise. (Target_s390::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_s390::scan_relocatable_relocs): Use Default_classify_reloc. (Target_s390::relocate_relocs): Use Default_classify_reloc. * sparc.cc (Target_sparc::emit_relocs_scan): New method. (Target_sparc::Relocatable_size_for_reloc): Remove. (Target_sparc::gc_process_relocs): Use Default_classify_reloc. (Target_sparc::scan_relocs): Likewise. (Target_sparc::relocate_section): Likewise. (Target_sparc::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_sparc::scan_relocatable_relocs): Use Default_classify_reloc. (Target_sparc::relocate_relocs): Use Default_classify_reloc. * tilegx.cc (Target_tilegx::emit_relocs_scan): New method. (Target_tilegx::Relocatable_size_for_reloc): Remove. (Target_tilegx::gc_process_relocs): Use Default_classify_reloc. (Target_tilegx::scan_relocs): Likewise. (Target_tilegx::relocate_section): Likewise. (Target_tilegx::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_tilegx::scan_relocatable_relocs): Use Default_classify_reloc. (Target_tilegx::relocate_relocs): Use Default_classify_reloc. * x86_64.cc (Target_x86_64::emit_relocs_scan): New method. (Target_x86_64::Relocatable_size_for_reloc): Remove. (Target_x86_64::gc_process_relocs): Use Default_classify_reloc. (Target_x86_64::scan_relocs): Likewise. (Target_x86_64::relocate_section): Likewise. (Target_x86_64::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_x86_64::scan_relocatable_relocs): Use Default_classify_reloc. (Target_x86_64::relocate_relocs): Use Default_classify_reloc. * testsuite/testfile.cc (Target_test::emit_relocs_scan): New method.
2016-01-01Copyright update for binutilsAlan Modra
2015-12-09[GOLD] Relocate::relocate() paramsAlan Modra
Some linker code editing needs to change multiple insns. In some cases multiple relocations are involved and it is not sufficient to make the changes independently as relocations are processed, because doing so might lead to a partial edit. So in order to safely edit we need all the relocations available in relocate(). Also, to emit edited relocs corresponding to the edited code sequence we need some way to pass information from relocate() to relocate_relocs(), particularly if the edit depends on insns. We can't modify input relocs in relocate() as they are mmapped PROT_READ, nor it is particularly clean to write relocs to the output at that stage. So add a Relocatable_relocs* field to relinfo to mark edited relocs. Given that relocate is passed the raw reloc pointer, it makes sense to remove the rel/rela parameter and r_type too. However, that means the mips relocate() needs to know whether SHT_REL or SHT_RELA relocs are being processed. So add a rel_type for mips, which also has the benefit of removing relocate() overloading there. This patch adds the infrastructure without making use of it. Note that relinfo->rr will be NULL if not outputting relocations. * object.h (struct Relocate_info): Add "rr". * reloc.h (Relocatable_relocs::set_strategy): New accessor. * reloc.cc (Sized_relobj_file::do_relocate_sections): Init relinfo.rr for relocate_section and relocate_relocs. * powerpc.cc (relocate): Add rel_type and preloc parameters. Delete rela and r_type params, instead recalculate these from preloc. (relocate_relocs): Delete Relocatable_relocs* param, instead use relinfo->rr. * aarch64.cc: Likewise. * arm.cc: Likewise. * i386.cc: Likewise. * mips.cc: Likewise. * s390.cc: Likewise. * sparc.cc: Likewise. * target.h: Likewise. * tilegx.cc: Likewise. * x86_64.cc: Likewise. * testsuite/testfile.cc: Likewise. * target-reloc.h (relocate_section): Adjust to suit. (apply_relocation, relocate_relocs): Likewise.
2015-08-20gold --emit-relocsAlan Modra
A symbol value in an ELF final linked binary is absolute, in contrast to a relocatable object file where the value is section relative. For --emit-relocs it is therefore incorrect to use the value of a section symbol as the addend when adjusting relocs against input section symbols to output section symbols. PR gold/18846 * target-reloc.h (relocate_relocs <RELOC_ADJUST_FOR_SECTION_RELA>): Subtract os->address() from addend. * powerpc.cc (relocate_relocs): Likewise.
2015-01-02ChangeLog rotatation and copyright year updateAlan Modra
2014-05-02Fix handling of __ehdr_start when it cannot be defined.Cary Coutant
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 Modra
2014-02-05Fix issues with gold undefined symbol diagnostics.Cary Coutant
PR binutils/15435 complains that gold issues a visibility error for an weak undefined symbol with hidden visibility. The message should be suppressed if the symbol is a weak undef. An earlier patch to add an extra note about key functions when a class's vtable symbol is undefined missed a case where the reference to the vtable came from a shared library. This patch moves the check to a lower-level routine that catches both cases. gold/ 2014-02-05 Cary Coutant <ccoutant@google.com> * errors.cc (Errors::undefined_symbol): Move undef vtable symbol check to here. * target-reloc.h (is_strong_undefined): New function. (relocate_section): Move undef vtable symbol check from here. Check for is_strong_undefined.
2013-05-21gold/Cary Coutant
* symtab.h (Symbol::is_cxx_vtable): New function. * target-reloc.h (relocate_section): Check for vtable symbol. * testsuite/Makefile.am (missing_key_func.sh): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/missing_key_func.cc: New test source. * testsuite/missing_key_func.sh: New test script.
2013-04-27 * target-reloc.h (relocate_section): If the reloc offset is out ofIan Lance Taylor
range, pass VIEW as NULL to relocate.relocate. * arm.cc (Target_arm:Relocate::relocate): Check for a NULL view. * i386.cc (Target_i386::Relocate::relocate): Likewise. * powerpc.cc (Target_powerpc::Relocate::relocate): Likewise. * sparc.cc (Target_sparc::Relocate::relocate): Likewise. * tilegx.cc (Target_tilegx::Relocate::relocate): Likewise. * x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.
2012-11-01gold/Roland McGrath
* target.h (Sized_target::relocate_relocs): Use Elf_Off for offset_in_output_section parameter. (Sized_target::relocate_special_relocatable): Likewise. * arm.cc (Target_arm::relocate_relocs): Likewise. (Target_arm::relocate_special_relocatable): Likewise. * i386.cc (Target_i386::relocate_relocs): Likewise. * powerpc.cc (Target_powerpc::relocate_relocs): Likewise. * sparc.cc (Target_sparc::relocate_relocs): Likewise. * target-reloc.h (relocate_relocs): Likewise. * testsuite/testfile.cc (Target_test): Likewise. * tilegx.cc (Target_tilegx::relocate_relocs): Likewise. * x86_64.cc (Target_x86_64::relocate_relocs): Likewise.
2012-10-18 * target-reloc.h (class Default_comdat_behavior): New, package up..Alan Modra
(get_comdat_behaviour): ..this. (relocate_section): Add Relocate_comdat_behavior template arg, adjust code to suit. * arm.cc (Target_arm::relocate_section): Adjust to suit. (Target_arm::scan_reloc_section): Likewise. * i386.cc (Target_i386::relocate_section): Likewise. * sparc.cc (Target_sparc::relocate_section): Likewise. * tilegx.cc (Target_tilegx::relocate_section): Likewise. * x86_64.cc (Target_x86_64::relocate_section): Likewise. * powerpc.cc (class Relocate_comdat_behavior): New. (Target_powerpc::relocate_section): Don't zap opd relocs. Supply gold::relocate_section with new template arg.
2012-09-12 * target-reloc.h (scan_relocs): Call scan.local for relocsAlan Modra
against symbols in discarded sections. Pass is_discarded param. * arm.cc, * i386.cc, * sparc.cc, * x86_64.cc (Target_*::Scan::local): Add is_discarded param. * powerpc (Target_powerpc::Scan::local): Likewise. Use is_discarded to flag opd entry as discarded. Don't emit dyn relocs on such entries. (Target_powerpc::Scan::global): Similarly detect and handle such opd entries. (Powerpc_relobj): Replace opd_ent_shndx_ and opd_ent_off_ with opd_ent_. Update all uses. (Powerpc_relobj::get_opd_discard, set_opd_discard): New functions. (Target_powerpc::relocate_section): Zero out discarded opd entry relocs.
2012-09-05 * object.h (Sized_relobj_file::emit_relocs): Delete.Alan Modra
(Sized_relobj_file::emit_relocs_reltype): Delete. * reloc.cc (Sized_relobj_file::do_relocate_sections): Call target relocate_relocs for --emit-relocs. (Sized_relobj_file::emit_relocs, emit_relocs_reltype): Delete. * output.h: Update comment. (Output_segment::first_section): New function. (Output_segment::first_section_load_address): Use first_section. * output.cc (Output_segment::first_section): New function extracted.. (Output_segment::first_section_load_address): ..from here. Delete. * target-reloc.h (relocate_for_relocatable): Rename to relocate_relocs. * target.h (Sized_target::relocate_for_relocatable): Likewise. * arm.cc (Target_arm::relocate_for_relocatable): Likewise, and adjust call to target.h function. * i386.cc (Target_i386): Likewise. * sparc.cc (Target_sparc): Likewise. * x86_64.cc (Target_x86_64): Likewise. * powerpc.cc (Target_powerpc): Likewise. (Target_powerpc::Scan::local, global): Handle R_POWERPC_TLS. Ensure first tls section has section symbol for optimised local dynamic output relocs. (Target_powerpc::Relocate::relocate): Correct local dynamic value. (Target_powerpc::relocate_relocs): Adjust relocs emitted for optimised tls code. * testsuite/testfile.cc (Target_test::relocate_for_relocatable): Rename to relocate_relocs. Update error message.
2011-12-15Replace <64, false> with <size, big_endian>H.J. Lu
2011-12-15 H.J. Lu <hongjiu.lu@intel.com> PR gold/13505 * target-reloc.h (apply_relocation): Replace <64, false> with <size, big_endian>.
2011-11-102011-11-09 Doug Kwan <dougkwan@google.com>Doug Kwan
PR gold/13362 * arm.cc (Arm_scan_relocatable_relocs::Default_scan_relocatable_relocs): Use unaligned 4-byte relocs for static 32-bit data as required by EABI. * reloc.h (Relocatable_relocs::Reloc_strategy): New enum RELOC_ADJUST_FOR_SECTION_4_UNALIGNED. (Relocate_functions::rel_unaligned): New. (Relocate_functions::rel32_unaligned): New. * target-reloc.h (relocate_for_relocatable): Add code to handle RELOC_ADJUST_FOR_SECTION_4_UNALIGNED. * testsuite/Makefile.am (arm_unaligned_reloc_r.stdout, arm_unaligned_reloc_r): New targets. * testsuite/Makefile.in: Regenerate. * arm_unaligned_reloc.sh: Check unaligned relocs in relocatable linking.
2011-07-11 PR gold/12979Ian Lance Taylor
* options.h (class General_options): Add -Bgroup. * options.cc (General_options::finalize): If -Bgroup is set, default to --unresolved-symbols=report-all. * layout.cc (Layout::finish_dynamic_section): Implement -Bgroup. * target-reloc.h (issue_undefined_symbol_error): Handle --unresolved-symbols=report-all.
2011-07-09 PR gold/12386Ian Lance Taylor
* options.h (class General_options): Add --unresolved-symbols. * target-reloc.h (issue_undefined_symbol_error): Check --unresolved-symbols. Add comments.
2011-07-09 PR gold/11317Ian Lance Taylor
* target-reloc.h (issue_undefined_symbol_error): New inline function, broken out of relocate_section. (relocate_section): Call issue_undefined_symbol_error. * i386.cc (Target_i386::Relocate::relocate_tls): Don't crash if there is no TLS segment if we are about to issue an undefined symbol error. * x86_64.cc (Target_x86_64::relocate_tls): Likewise.
2011-05-24 * incremental-dump.cc (dump_incremental_inputs): Print dynamic relocCary Coutant
info; adjust display of GOT entries. * incremental.cc (Sized_incremental_binary::setup_readers): Allocate vector of input objects; remove file_status_. (Sized_incremental_binary::do_reserve_layout): Remove file_status_. (Sized_incremental_binary::do_process_got_plt): Adjust calls to got_plt reader; call target hooks to reserve GOT entries. (Output_section_incremental_inputs::set_final_data_size): Adjust size of input file info header and GOT info entry. (Output_section_incremental_inputs::write_info_blocks): Write dynamic relocation info. (Got_plt_view_info::got_descriptor): Remove. (Got_plt_view_info::sym_index): New data member. (Got_plt_view_info::input_index): New data member. (Local_got_offset_visitor::visit): Write input file index. (Global_got_offset_visitor::visit): Write 0 for input file index. (Global_symbol_visitor_got_plt::operator()): Replace got_descriptor with sym_index and input_index. (Output_section_incremental_inputs::write_got_plt): Adjust size of incremental info GOT entry; replace got_descriptor with input_index. (Sized_relobj_incr::Sized_relobj_incr): Adjust initializers; record map from input file index to object. (Sized_relobj_incr::do_layout): Replace direct data member reference with accessor function. (Sized_relobj_incr::do_for_all_local_got_entries): Move to base class. * incremental.h (Incremental_input_entry_reader::get_symbol_offset): Adjust size of input file info header. (Incremental_input_entry_reader::get_first_dyn_reloc): New function. (Incremental_input_entry_reader::get_dyn_reloc_count): New function. (Incremental_input_entry_reader::get_input_section): Adjust size of input file info header. (Incremental_got_plt_reader::Incremental_got_plt_reader): Adjust size of incremental info GOT entry. (Incremental_got_plt_reader::get_got_desc): Remove. (Incremental_got_plt_reader::get_got_symndx): New function. (Incremental_got_plt_reader::get_got_input_index): New function. (Sized_incremental_binary::Sized_incremental_binary): Remove file_status_; add input_objects_. (Sized_incremental_binary::~Sized_incremental_binary): Remove. (Sized_incremental_binary::set_file_is_unchanged): Remove. (Sized_incremental_binary::file_is_unchanged): Remove. (Sized_incremental_binary::set_input_object): New function. (Sized_incremental_binary::input_object): New function. (Sized_incremental_binary::file_status_): Remove. (Sized_incremental_binary::input_objects_): New data member. (Sized_relobj_incr): Rename Sized_incr_relobj to this; adjust all references. (Sized_relobj_incr::invalid_address): Move to base class. (Sized_relobj_incr::is_output_section_offset_invalid): Move to base class. (Sized_relobj_incr::do_output_section_offset): Likewise. (Sized_relobj_incr::do_for_all_local_got_entries): Likewise. (Sized_relobj_incr::section_offsets_): Likewise. * object.cc (Sized_relobj::do_for_all_local_got_entries): New function. (Sized_relobj_file::Sized_relobj_file): Remove local_got_offsets_. (Sized_relobj_file::layout_section): Replace refs to section_offsets_ with accessor function. (Sized_relobj_file::do_layout): Likewise. (Sized_relobj_file::do_layout_deferred_sections): Likewise. (Sized_relobj_file::do_for_all_local_got_entries): Move to base class. (Sized_relobj_file::compute_final_local_value): Replace refs to section_offsets_ with accessor function. (Sized_relobj_file::do_finalize_local_symbols): Likewise. * object.h (Relobj::Relobj): Initialize new data members. (Relobj::add_dyn_reloc): New function. (Relobj::first_dyn_reloc): New function. (Relobj::dyn_reloc_count): New function. (Relobj::first_dyn_reloc_): New data member. (Relobj::dyn_reloc_count_): New data member. (Sized_relobj): Rename Sized_relobj_base to this; adjust all references. (Sized_relobj::Address): New typedef. (Sized_relobj::invalid_address): Move here from child class. (Sized_relobj::Sized_relobj): Initialize new data members. (Sized_relobj::sized_relobj): New function. (Sized_relobj::is_output_section_offset_invalid): Move here from child class. (Sized_relobj::get_output_section_offset): Likewise. (Sized_relobj::local_has_got_offset): Likewise. (Sized_relobj::local_got_offset): Likewise. (Sized_relobj::set_local_got_offset): Likewise. (Sized_relobj::do_for_all_local_got_entries): Likewise. (Sized_relobj::clear_got_offsets): New function. (Sized_relobj::section_offsets): Move here from child class. (Sized_relobj::do_output_section_offset): Likewise. (Sized_relobj::do_set_section_offset): Likewise. (Sized_relobj::Local_got_offsets): Likewise. (Sized_relobj::local_got_offsets_): Likewise. (Sized_relobj::section_offsets_): Likewise. (Sized_relobj_file): Rename Sized_relobj to this; adjust all references. (Sized_relobj_file::is_output_section_offset_invalid): Move to base class. (Sized_relobj_file::sized_relobj): New function (Sized_relobj_file::local_has_got_offset): Move to base class. (Sized_relobj_file::local_got_offset): Likewise. (Sized_relobj_file::set_local_got_offset): Likewise. (Sized_relobj_file::get_output_section_offset): Likewise. (Sized_relobj_file::do_for_all_local_got_entries): Likewise. (Sized_relobj_file::do_output_section_offset): Likewise. (Sized_relobj_file::do_set_section_offset): Likewise. (Sized_relobj_file::Local_got_offsets): Likewise. (Sized_relobj_file::local_got_offsets_): Likewise. (Sized_relobj_file::section_offsets_): Likewise. * output.cc (Output_reloc::Output_reloc): Adjust type of relobj (all constructors). (set_needs_dynsym_index): Convert relobj to derived class pointer. (Output_reloc::get_symbol_index): Likewise. (Output_reloc::local_section_offset): Likewise. (Output_reloc::get_address): Likewise. (Output_reloc::symbol_value): Likewise. (Output_data_got::reserve_slot): Move to class definition. (Output_data_got::reserve_local): New function. (Output_data_got::reserve_slot_for_global): Remove. (Output_data_got::reserve_global): New function. * output.h (Output_reloc::Output_reloc): Adjust type of relobj (all constructors, two instantiations). (Output_reloc::get_relobj): New function (two instantiations). (Output_reloc::u1_.relobj, Output_reloc::u2_.relobj): Adjust type. (Output_data_reloc_base::add): Convert relobj to derived class pointer. (Output_data_reloc::add_global): Adjust type of relobj. (Output_data_reloc::add_global_relative): Likewise. (Output_data_reloc::add_symbolless_global_addend): Likewise. (Output_data_reloc::add_local): Likewise. (Output_data_reloc::add_local_relative): Likewise. (Output_data_reloc::add_symbolless_local_addend): Likewise. (Output_data_reloc::add_local_section): Likewise. (Output_data_reloc::add_output_section): Likewise. (Output_data_reloc::add_absolute): Likewise. (Output_data_reloc::add_target_specific): Likewise. (Output_data_got::reserve_slot): Move definition here. (Output_data_got::reserve_local): New function. (Output_data_got::reserve_global): New function. * reloc.cc (Sized_relobj_file::do_read_relocs): Replace refs to section_offsets_ with accessor function. (Sized_relobj_file::write_sections): Likewise. (Sized_relobj_file::do_relocate_sections): Likewise. * target.h (Sized_target::reserve_local_got_entry): New function. (Sized_target::reserve_global_got_entry): New function. * x86_64.cc (Target_x86_64::reserve_local_got_entry): New function. (Target_x86_64::reserve_global_got_entry): New function. (Target_x86_64::init_got_plt_for_update): Create rela_dyn section.
2011-04-22 * incremental.cc (Sized_incremental_binary::setup_readers): AllocateCary Coutant
global symbol map. (Sized_incremental_binary::do_apply_incremental_relocs): New function. (Sized_incr_relobj::do_add_symbols): Add symbols to global symbol map. (Sized_incr_relobj::do_relocate): Remap section indices in incremental relocations. (Sized_incr_dynobj::do_add_symbols): Add symbols to global symbol map. (Sized_incr_dynobj::do_for_all_global_symbols): Remove FIXME. (Sized_incr_dynobj::do_for_all_local_got_entries): Likewise. * incremental.h (Incremental_inputs_reader::global_symbol_reader_at_offset): New function. (Incremental_binary::apply_incremental_relocs): New function. (Incremental_binary::do_apply_incremental_relocs): New function. (Sized_incremental_binary::Sized_incremental_binary): Initialize new data member. (Sized_incremental_binary::add_global_symbol): New function. (Sized_incremental_binary::global_symbol): New function. (Sized_incremental_binary::do_apply_incremental_relocs): New function. (Sized_incremental_binary::symbol_map_): New data member. * layout.cc (Layout_task_runner::run): Apply incremental relocations. * target.h (Sized_target::apply_relocation): New function. * target-reloc.h (apply_relocation): New function. * x86_64.cc (Target_x86_64::apply_relocation): New function.
2010-12-14Fix typos in gold.Ralf Wildenhues
gold/: * dwarf_reader.cc: Remove outdated comment. * gold-threads.cc: Fix typo in error message. * archive.cc: Fix typos in comments. * archive.h: Likewise. * arm-reloc-property.cc: Likewise. * arm-reloc-property.h: Likewise. * arm-reloc.def: Likewise. * arm.cc: Likewise. * attributes.h: Likewise. * cref.cc: Likewise. * ehframe.cc: Likewise. * fileread.h: Likewise. * gold.h: Likewise. * i386.cc: Likewise. * icf.cc: Likewise. * incremental.h: Likewise. * int_encoding.cc: Likewise. * layout.h: Likewise. * main.cc: Likewise. * merge.h: Likewise. * object.cc: Likewise. * object.h: Likewise. * options.cc: Likewise. * readsyms.cc: Likewise. * reduced_debug_output.cc: Likewise. * reloc.cc: Likewise. * script-sections.cc: Likewise. * sparc.cc: Likewise. * symtab.h: Likewise. * target-reloc.h: Likewise. * target.cc: Likewise. * target.h: Likewise. * timer.cc: Likewise. * timer.h: Likewise. * x86_64.cc: Likewise.
2010-08-19 PR 10893Ian Lance Taylor
* i386.cc (class Output_data_plt_i386): Update declarations. Define Global_ifunc and Local_ifunc types. Add global_ifuncs_ and local_ifuncs_ fields. (Target_i386::do_plt_section_for_global): New function. (Target_i386::do_plt_section_for_local): New function. (Output_data_plt_i386::Output_data_plt_i386): Add symtab parameter; change all callers. Initialize global_ifuncs_ and local_ifuncs_. If doing a static link define __rel_iplt_start and __rel_iplt_end. (Output_data_plt_i386::add_entry): Handle IFUNC symbols. (Output_data_plt_i386::add_local_ifunc_entry): New function. (Output_data_plt_i386::do_write): Fix GOT entries for IFUNC symbols. (Target_i386::make_plt_section): New function, broken out of make_plt_entry. Set sh_info field of .rel.plt to point to .plt. (Target_i386::make_plt_entry): Call make_plt_section. (Target_i386::make_local_ifunc_plt_entry): New function. (Target_i386::Scan::reloc_needs_iplt_for_ifunc): New function. (Target_i386::Scan::local): Handle IFUNC symbols. Add R_386_IRELATIVE to switch. (Target_i386::Scan::global): Likewise. (Target_i386::Relocate::relocate): Likewise. (Target_i386::Relocatable_size_for_reloc): Add R_386_IRELATIVE to switch. * x86_64.cc (class Output_data_plt_x86_64): Update declarations. (Target_x86_64::do_plt_section_for_global): New function. (Target_x86_64::do_plt_section_for_local): New function. (Output_data_plt_x86_64::Output_data_plt_x86_64): Add symtab parameter; change all callers. If doing a static link define __rela_iplt_start and __rela_iplt_end. (Output_data_plt_x86_64::add_entry): Handle IFUNC symbols. (Output_data_plt_x86_64::add_local_ifunc_entry): New function. (Target_x86_64::make_plt_section): Set sh_info field of .rel.plt to point to .plt. (Target_x86_64::make_local_ifunc_plt_entry): New function. (Target_x86_64::Scan::check_non_pic): Add R_X86_64_IRELATIVE to switch. (Target_x86_64::Scan::reloc_needs_iplt_for_ifunc): New function. (Target_x86_64::Scan::local): Handle IFUNC symbols. Add R_X86_64_IRELATIVE to switch. (Target_x86_64::Scan::global): Likewise. (Target_x86_64::Relocate::relocate): Likewise. (Target_x86_64::Relocatable_size_for_reloc): Add R_X86_64_IRELATIVE to switch. * target.h (class Target): Add plt_section_for_global and plt_section_for_local functions. Add do_plt_section_for_global and do_plt_section_for_local virtual functions. * symtab.h (Symbol::needs_plt_entry): Handle IFUNC symbol. Add clarifying comments. (Symbol::use_plt_offset): Handle IFUNC symbol. * object.cc (Sized_relobj::Sized_relobj): Initialize local_plt_offsets_. (Sized_relobj::local_has_plt_offset): New function. (Sized_relobj::local_plt_offset): New function. (Sized_relobj::set_local_plt_offset): New function. (Sized_relobj::do_count): Handle IFUNC symbol. * object.h (class Symbol_value): Add is_ifunc_symbol_ field. Take a bit away from input_shndx_ field. Add set_is_func_symbol and is_ifunc_symbol functions. (class Sized_relobj): Update declarations. Remove Tls_got_entry and Local_tls_got_offsets. Define Local_plt_offsets. Add local_plt_offsets_ field. (Sized_relobj::clear_local_symbols): Clear local_plt_offsets_. * output.h (class Output_section_data): Add non-const output_section function. (class Output_data_got): Update declarations. (class Output_data_got::Got_entry): Add use_plt_offset_ field. Add use_plt_offset parameter to global and local constructors. Change all callers. Change local_sym_index_ field to 31 bits. Change GSYM_CODE and CONSTANT_CODE accordingly. * output.cc (Output_data_reloc_base::do_adjust_output_section): If doing a static link don't set sh_link field. (Output_data_got::Got_entry::write): Use PLT offset if appropriate. (Output_data_got::add_global_plt): New function. (Output_data_got::add_local_plt): New function. * target-reloc.h (relocate_section): Handle IFUNC symbol. * defstd.cc (in_section): Remove entries for __rel_iplt_start, __rel_iplt_end, __rela_iplt_start, and __rela_iplt_end. * configure.ac: Set IFUNC automake conditional for glibc >= 2.11. * testsuite/Makefile.am: Add a bunch of IFUNC tests, all within IFUNC conditional. * testsuite/ifunc-sel.h: New file. * testsuite/ifuncmain1.c: New file. * testsuite/ifuncmain1vis.c: New file. * testsuite/ifuncmod1.c: New file. * testsuite/ifuncdep2.c: New file. * testsuite/ifuncmain2.c: New file. * testsuite/ifuncmain3.c: New file. * testsuite/ifuncmod3.c: New file. * testsuite/ifuncmain4.c: New file. * testsuite/ifuncmain5.c: New file. * testsuite/ifuncmod5.c: New file. * testsuite/ifuncmain6pie.c: New file. * testsuite/ifuncmod6.c: New file. * testsuite/ifuncmain7.c: New file. * configure, testsuite/Makefile.in: Rebuild.
2010-06-10 * object.cc (Sized_relobj::do_layout): Defer layout for reloc sections.Cary Coutant
(Sized_relobj::do_layout_deferred_sections): Do layout for deferred reloc sections. * object.h (Sized_relobj::deferred_layout_relocs_): New data member. PR 11683 * symtab.h (Symbol::is_placeholder): New member function. * target-reloc.h (relocate_section): Check for placeholder symbols. * testsuite/Makefile.am (plugin_test_8): New test. (plugin_test_9): New test. * testsuite/Makefile.in: Regenerate.
2010-05-262010-05-26 Doug Kwan <dougkwan@google.com>Doug Kwan
* arm.cc (Arm_scan_relocatable_relocs): New class. (Target_arm::relocate_special_relocatable): New method. (Arm_relocate_functions::arm_branch_common): Handle relocatable link. (Arm_relocate_functions::thumb_branch_common): Same. (Target_arm::scan_relocatable_relocs): Use Arm_scan_relocatable_relocs instead of Default_scan_relocatable_relocs. * target-reloc.h (relocate_for_relocatable): Let target handle relocation strategy Relocatable_relocs::RELOC_SPECIAL. * target.h (Sized_target::relocate_special_relocatable): New method.
2010-04-202010-04-18 Sriraman Tallam <tmsriram@google.com>Sriraman Tallam
* icf.cc (get_section_contents): Check for preemptible functions. Ignore addend when appropriate. * symtab.cc (should_add_dynsym_entry): Add new parameter. Check for section folded. (add_from_relobj): Check for section folded. (set_dynsym_indexes): Fix call to should_add_dynsym_entry. * symtab.h (should_add_dynsym_entry): Add new parameter. * target-reloc.h (scan_relocs): Check for section folded. * x86_64.cc (Target_x86_64::Scan::possible_function_pointer_reloc): Check reloc types for function pointers in shared objects. * testsuite/Makefile.am (icf_virtual_function_folding_test): New test case. (icf_preemptible_functions_test): New test case. (icf_string_merge_test): New test case. * testsuite.Makefile.in: Regenerate. * testsuite/icf_safe_so_test.sh: Change to not fold foo_glob and bar_glob. Refactor code. * testsuite/icf_preemptible_functions_test.cc: New file. * testsuite/icf_preemptible_functions_test.sh: New file. * testsuite/icf_string_merge_test.cc: New file. * testsuite/icf_string_merge_test.sh: New file. * testsuite/icf_virtual_function_folding_test.cc: New file. * testsuite/icf_virtual_function_folding_test.sh: New file.
2010-03-03 * target-reloc.h (relocate_section): Check the symbol table indexIan Lance Taylor
for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-01-12 * target-reloc.h (visibility_error): New inline function.Ian Lance Taylor
(relocate_section): Call visibility_error. * testsuite/Makefile.am (check_DATA): Add protected_3.err. (MOSTLYCLEANFILES): Likewise. (protected_4_pic.o, protected_3.err): New targets. * testsuite/protected_4.cc: New file.
2010-01-09 PR 11108Ian Lance Taylor
* 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.
2009-12-30 PR 10843Ian Lance Taylor
* target-reloc.h (relocate_for_relocatable): When copying a reloc, if the input symbol index is 0, make the output symbol index 0.
2009-10-29 * object.h (class Relobj): Drop options parameter fromIan Lance Taylor
gc_process_relocs, scan_relocs, relocate, do_gc_process_relocs, do_scan_relocs, do_relocate. Change all callers. (class Sized_relobj): Drop options parameters from do_gc_process_relocs, do_scan_relocs, do_relocate, do_relocate_sections, relocate_sections, emit_relocs_scan, emit_relocs_scan_reltype. Change all callers. (struct Relocate_info): Remove options field and all references to it. * reloc.h (class Read_relocs): Remove options constructor parameter and options_ field. Change all callers. (class Gc_process_relocs, class Scan_relocs): Likewise. (class Relocate_task): Likewise. * target-reloc.h (scan_relocs): Remove options parameter. Change all callers. (scan_relocatable_relocs): Likewise. * target.h (class Sized_target): Remove options parameter from gc_process_relocs, scan_relocs, scan_relocatable_relocs. Change all callers. * gc.h (gc_process_relocs): Remove options parameter. Change all callers. * arm.cc: Update functions to remove options parameters. * i386.cc: Likewise. * powerpc.cc: Likewise. * sparc.cc: Likewise. * x86_64.cc: Likewise. * testsuite/testfile.cc: Likewise.
2009-10-06 * options.h (class General_options): DefineIan Lance Taylor
split_stack_adjust_size parameter. * object.h (class Object): Add uses_split_stack_ and has_no_split_stack_ fields. Add uses_split_stack and has_no_split_stack accessor functions. Declare handle_split_stack_section. (class Reloc_symbol_changes): Define. (class Sized_relobj): Define Function_offsets. Declare split_stack_adjust, split_stack_adjust_reltype, and find_functions. * object.cc (Object::handle_split_stack_section): New function. (Sized_relobj::do_layout): Call handle_split_stack_section. * dynobj.cc (Sized_dynobj::do_layout): Call handle_split_stack_section. * reloc.cc (Sized_relobj::relocate_sections): Call split_stack_adjust for executable sections in split_stack objects. Pass reloc_map to relocate_section. (Sized_relobj::split_stack_adjust): New function. (Sized_relobj::split_stack_adjust_reltype): New function. (Sized_relobj::find_functions): New function. * target-reloc.h: Include "object.h". (relocate_section): Add reloc_symbol_changes parameter. Change all callers. * target.h (class Target): Add calls_non_split method. Declare do_calls_non_split virtual method. Declare match_view and set_view_to_nop. * target.cc: Include "elfcpp.h". (Target::do_calls_non_split): New function. (Target::match_view): New function. (Target::set_view_to_nop): New function. * gold.cc (queue_middle_tasks): Give an error if mixing split-stack and non-split-stack objects with -r. * i386.cc (Target_i386::relocate_section): Add reloc_symbol_changes parameter. (Target_i386::do_calls_non_split): New function. * x86_64.cc (Target_x86_64::relocate_section): Add reloc_symbol_changes parameter. (Target_x86_64::do_calls_non_split): New function. * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes parameter. * powerpc.cc (Target_powerpc::relocate_section): Add reloc_symbol_changes parameter. * sparc.cc (Target_sparc::relocate_section): Add reloc_symbol_changes parameter. * configure.ac: Call AM_CONDITIONAL for the default target. * configure: Rebuild. * testsuite/Makefile.am (TEST_AS): New variable. (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh. (check_DATA): Add split_i386 and split_x86_64 files. (SPLIT_DEFSYMS): Define. (split_i386_[1234n].o): New targets. (split_i386_[124]): New targets. (split_i386_[1234r].stdout): New targets. (split_x86_64_[1234n].o): New targets. (split_x86_64_[124]): New targets. (split_x86_64_[1234r].stdout): New targets. (MOSTLYCLEANFILES): Add new executables. * testsuite/split_i386.sh: New file. * testsuite/split_x86_64.sh: New file. * testsuite/split_i386_1.s: New file. * testsuite/split_i386_2.s: New file. * testsuite/split_i386_3.s: New file. * testsuite/split_i386_4.s: New file. * testsuite/split_i386_n.s: New file. * testsuite/split_x86_64_1.s: New file. * testsuite/split_x86_64_2.s: New file. * testsuite/split_x86_64_3.s: New file. * testsuite/split_x86_64_4.s: New file. * testsuite/split_x86_64_n.s: New file. * testsuite/testfile.cc (Target_test): Update relocation_section function. * testsuite/Makefile.in: Rebuild.
2009-08-05*** empty log message ***Sriraman Tallam
2009-03-04 PR 9918Ian Lance Taylor
* target-reloc.h (relocate_section): Pass output_section to relocate. * i386.cc (Target_i386::should_apply_static_reloc): Add output_section parameter. Change all callers. (Target_i386::Relocate::relocate): Add output_section parameter. * x86_64.cc (Target_x86_64::Relocate::relocate): Likewise. * sparc.cc (Target_sparc::Relocate::relocate): Likewise. * powerpc.cc (Target_powerpc::Relocate::relocate): Likewise. * testsuite/two_file_shared.sh: New script. * testsuite/Makefile.am (check_SCRIPTS): Add two_file_shared.sh. (check_DATA): Add two_file_shared.dbg. (two_file_shared.dbg): New target. * testsuite/Makefile.in: Rebuild.
2009-02-062009-02-06 Chris Demetriou <cgd@google.com>Chris Demetriou
* gold.h (gold_undefined_symbol): Change to take only a Symbol pointer and to report location as the file name associated with the symbol. (gold_undefined_symbol_at_location): New function to replace the old gold_undefined_symbol functionality. * target-reloc.h (relocate_section): Update to use gold_undefined_symbol_at_location. * symtab.cc (Symbol_table::warn_about_undefined_dynobj_symbol): Call gold_undefined_symbol function rather than gold_error. * errors.h (Errors::undefined_symbol): Take location as a string, rather than calculating it from a relocation. * errors.cc (Errors::fatal): Print "fatal error:" before the formatted message. (Errors::error, Errors::error_at_location): Print "error: " before the formatted message. (Errors::undefined_symbol): Take location as a string, rather than calculating it from a relocation. (gold_undefined_symbol_at_location): New function akin to old gold_undefined_symbol, calculates location from relocation. (gold_undefined_symbol): Change to take only a Symbol pointer and to report location as the file name associated with the symbol. * testsuite/debug_msg.sh: Update for changed error messages. * testsuite/undef_symbol.sh: Likewise.
2008-12-12 * target-reloc.h (Default_scan_relocatable_relocs): Only discardIan Lance Taylor
r_type == 0 for a local symbol with r_sym == 0. (scan_relocatable_relocs): Pass r_sym to local_non_section_strategy. * reloc.cc (Emit_relocs_strategy::local_non_section_strategy): Add r_sym parameter.
2008-12-12 PR 7091Ian Lance Taylor
* target-reloc.h (Default_scan_relocatable_relocs): For each function, map r_type == 0 to RELOC_DISCARD.
2008-09-29 * mapfile.cc (Mapfile::print_input_section): Change -1U to -1ULL.Cary Coutant
* object.cc (Sized_relobj::do_layout): Use constant invalid_address instead of -1U. (Sized_relobj::do_finalize_local_symbols): Likewise. (Sized_relobj::map_to_kept_section): Likewise. * object.h (Sized_relobj::invalid_address): New constant. (Sized_relobj::do_output_section_offset): Check for invalid_address and return -1ULL. * output.cc (Output_reloc::local_section_offset): Use constant invalid_address instead of -1U. (Output_reloc::get_address): Likewise. (Output_section::output_address): Change -1U to -1ULL. * output.h (Output_reloc::invalid_address): New constant. * reloc.cc (Sized_relobj::write_sections): Use constant invalid_address instead of -1U. (Sized_relobj::relocate_sections): Likewise. * symtab.cc (Symbol_table::sized_finalize_symbol): Handle symbol values for merge sections. * target-reloc.h (relocate_for_relocatable): Use constant invalid_address instead of -1U.
2008-09-16 * target-reloc.h (relocate_section): Check whether a symbol isIan Lance Taylor
defined by the ABI before reporting an undefined symbol error. * target.h (Target::is_defined_by_abi): Make parameter const. (Target::do_is_defined_by_abi): Likewise. * i386.cc (Target_i386::do_is_defined_by_abi): Likewise. * powerpc.cc (Target_powerpc::do_is_defined_by_abi): Likewise. * sparc.cc (Target_sparc::do_is_defined_by_abi): Likewise. * x86_64.cc (Target_x86_64::do_is_defined_by_abi): Likewise. * testsuite/Makefile.am (tls_test_shared.so): Add -Wl,-z,defs. * testsuite/Makefile.in: Rebuild.
2008-07-10 Handle output sections with more than 0x7fffffff bytes.Ian Lance Taylor
* object.h (class Relobj): Change map_to_output_ to output_sections_, and just keep a section pointer. Change all uses. Move comdat group support to Sized_relobj. (Relobj::is_section_specially_mapped): Remove. (Relobj::output_section): Remove poff parameter. Change all callers. (Relobj::output_section_offset): New function. (Relobj::set_section_offset): Rewrite. (Relobj::map_to_output): Remove. (Relobj::output_sections): New function. (Relobj::do_output_section_offset): New pure virtual function. (Relobj::do_set_section_offset): Likewise. (class Sized_relobj): Add section_offsets_ field. Add comdat group support from Relobj. Update declarations. (Sized_relobj::get_output_section_offset): New function. (Sized_relobj::do_output_section_offset): New function. (Sized_relobj::do_set_section_offset): New function. * object.cc (Relobj::output_section_address): Remove. (Sized_relobj::Sized_relobj): Initialize new fields. (Sized_relobj::include_section_group): Cast find_kept_object to Sized_relobj. (Sized_relobj::include_linkonce_section): Likewise. (Sized_relobj::do_layout): Use separate arrays for output section and output offset. (Sized_relobj::do_count_local_symbols): Change map_to_output to output_sections. (Sized_relobj::do_finalize_local_symbols): Change map_to_output to output_sections and section_offsets. (Sized_relobj::write_local_symbols): Likewise. (map_to_kept_section): Compute output address directly. * reloc.cc (Sized_relobj::do_read_relocs): Change map_to_output to output_sections and section_offsets. (Sized_relobj::write_sections): Likewise. (Sized_relobj::relocate_sections): Likewise. * symtab.cc (sized_finalize_symbol): Use output_section_offset. * output.h (class Output_reloc): Update declarations. Change u2_.relobj to Sized_relobj*. (class Output_data_reloc): Change add functions to use Sized_relobj*. * output.cc (Output_reloc::Output_reloc): Change relobj to Sized_relobj*. (Output_reloc::local_section_offset): Change return type to Elf_Addr. Use get_output_section_offset. (Output_reloc::get_address): Likewise. (Output_section::is_input_address_mapped): Don't call is_section_specially_mapped. (Output_section::output_offset): Likewise. (Output_section::output_address): Likewise. (Output_section::starting_output_address): Likewise. * copy-relocs.cc (Copy_relocs::copy_reloc): Change object parameter to Sized_relobj*. (Copy_relocs::need_copy_reloc): Likewise. (Copy_relocs::save): Likewise. * copy-relocs.h (class Copy_relocs): Update declarations. (class Copy_relocs::Copy_reloc_entry): Change constructor to use Sized_relobj*. Change relobj_ field to Sized_relobj*. * target-reloc.h (relocate_for_relocatable): Change offset_in_output_section type to Elf_Addr. Change code that uses it as well. * layout.cc (Layout::layout): Always set *off. * mapfile.cc (Mapfile::print_input_section): Use output_section_offset. * i386.cc (Target_i386::copy_reloc): Change object parameter to Sized_relobj*. * powerpc.cc (Target_powerpc::copy_reloc): Likewise. * sparc.cc (Target_sparc::copy_reloc): Likewise. * x86_64.cc (Target_x86_64::copy_reloc): Likewise.
2008-05-29 PR 6407Ian Lance Taylor
* target-reloc.h (relocate_for_relocatable): Fix new_offset calculation.
2008-05-01 * target-reloc.h (relocate_section): Fix dead-pointer bug.Cary Coutant
2008-05-01 * layout.cc (Layout::include_section): Refactored check for debugCary Coutant
info section. (Layout::add_comdat): Add new parameters. Change type of signature parameter. Add object and shndx to signatures table. (Layout::find_kept_object): New function. * layout.h: Include <cstring>. (Layout::is_debug_info_section): New function. (Layout::add_comdat): Add new parameters. (Layout::find_kept_object): New function. (Layout::Kept_section): New struct. (Layout::Signatures): Change type of map range. * object.cc (Relobj::output_section_address): New function. (Sized_relobj::include_section_group): Add new parameters. Change calls to Layout::add_comdat. Change to build table of kept comdat groups and table mapping discarded sections to kept sections. (Sized_relobj::include_linkonce_section): Likewise. Add new parameter. (Sized_relobj::do_layout): Change calls to include_section_group and include_linkonce_section. (Sized_relobj::do_finalize_local_symbols): Do not set local symbol value to zero when section is discarded. (Sized_relobj::map_to_kept_section): New function. * object.h (Relobj::output_section_address): New function. (Relobj::Comdat_group): New type. (Relobj::find_comdat_group): New function. (Relobj::Comdat_group_table): New type. (Relobj::Kept_comdat_section): New type. (Relobj::Kept_comdat_section_table): New type. (Relobj::add_comdat_group): New function. (Relobj::set_kept_comdat_section): New function. (Relobj::get_kept_comdat_section): New function. (Relobj::comdat_groups_): New field. (Relobj::kept_comdat_sections_): New field. (Symbol_value::input_value): Update comment. (Sized_relobj::map_to_kept_section) New function. (Sized_relobj::include_linkonce_section): Add new parameter. * target-reloc.h (Comdat_behavior): New type. (get_comdat_behavior): New function. (relocate_section): Add code to map a discarded section to the corresponding kept section when applying a relocation.
2008-04-19 * object.cc (Xindex::initialize_symtab_xindex): New function.Ian Lance Taylor
(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-20From Craig Silverstein: implement -z defs.Ian Lance Taylor
2008-03-13Update copyright years. Update language files.Ian Lance Taylor