summaryrefslogtreecommitdiff
path: root/gold/object.h
Commit message (Collapse)AuthorAgeFilesLines
* Update year range in copyright notice of binutils filesAlan Modra2023-01-011-1/+1
| | | | | | The newer update-copyright.py fixes file encoding too, removing cr/lf on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
* Update year range in copyright notice of binutils filesAlan Modra2022-01-021-1/+1
| | | | | | | | | | The result of running etc/update-copyright.py --this-year, fixing all the files whose mode is changed by the script, plus a build with --enable-maintainer-mode --enable-cgen-maint=yes, then checking out */po/*.pot which we don't update frequently. The copy of cgen was with commit d1dd5fcc38ead reverted as that commit breaks building of bfp opcodes files.
* [GOLD] Output_data_got tidyAlan Modra2021-09-181-30/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | Some Output_data_got methods already have support for addends, but were implemented as separate methods. This removes unnecessary code duplication. Relobj::local_has_got_offset and others there get a similar treatment. Comments are removed since it should be obvious without a comment, and the existing comments are not precisely what the code does. For example, a local_has_got_offset call without an addend does not return whether the local symbol has *a* GOT offset of type GOT_TYPE, it returns whether there is a GOT entry of type GOT_TYPE for the symbol with addend of zero. PR 28192 * output.h (Output_data_got::add_local): Make addend optional. (Output_data_got::add_local_with_rel): Likewise. (Output_data_got::add_local_pair_with_rel): Likewise. * output.cc (Output_data_got::add_local): Delete overload without addend. (Output_data_got::add_local_with_rel): Likewise. (Output_data_got::add_local_pair_with_rel): Likewise. * object.h (Relobj::local_has_got_offset): Make addend optional. Delete overload without addend later. Update comment. (Relobj::local_got_offset): Likewise. (Relobj::set_local_got_offset): Likewise.
* [GOLD] Remove addend from Local_got_entry_keyAlan Modra2021-09-181-9/+6
| | | | | | | | | | | | | | | | | This patch removes the addend from Local_got_entry_key, which is unnecessary now that Got_offset_list has an addend. Note that it might be advantageous to keep the addend in Local_got_entry_key when linking objects containing a large number of section_sym+addend@got relocations. I opted to save some memory by removing the field but left the class there in case we might need to restore {sym,addend} lookup. That's also why this change is split out from the Got_offset_list change. PR 28192 * object.h (Local_got_entry_key): Delete addend_ field. Adjust constructor and methods to suit. * object.cc (Sized_relobj::do_for_all_local_got_entries): Update key.
* [GOLD] Got_offset_list: addend fieldAlan Modra2021-09-181-14/+19
| | | | | | | | | | | | | | | | | | | | | This is the first in a series of patches aimed at supporting GOT entries against symbol plus addend generally for PowerPC64 rather than just section symbol plus addend as gold has currently. This patch adds an addend field to Got_offset_list, so that both local and global symbols can have GOT entries with addend. PR 28192 * object.h (Got_offset_list): Add addend_ field, init in both constructors. Adjust all accessors to suit. (Sized_relobj::do_local_has_got_offset): Adjust to suit. (Sized_relobj::do_local_got_offset): Likewise. (Sized_relobj::do_set_local_got_offset): Likewise. * symtab.h (Symbol::has_got_offset): Add optional addend param. (Symbol::got_offset, Symbol::set_got_offset): Likewise. * incremental.cc (Local_got_offset_visitor::visit): Add unused uint64_t parameter with FIXME. (Global_got_offset_visitor::visit): Add unused uint64_t parameter.
* Update year range in copyright notice of binutils filesAlan Modra2021-01-011-1/+1
|
* Cosmetic improvements for OSABI access.Cary Coutant2020-12-151-6/+4
| | | | | | | | | | | | | | | | | Add accessor methods to elfcpp::Ehdr class for EI_OSABI and EI_ABIVERSION; use those to simplify initialization of Osabi class and eliminate the need to template the class. elfcpp/ * elfcpp.h (class Ehdr): Add get_ei_osabi and get_ei_abiversion methods. gold/ * dwp.cc (class Dwo_file): Use new Ehdr::get_ei_osabi and get_ei_abiversion methods. * incremental.cc (make_sized_incremental_binary): Likewise. * object.cc (Sized_relobj_file::Sized_relobj_file): Likewise. (make_elf_sized_object): Likewise. * object.h (class Osabi): Make the class untemplated.
* Keep input SHF_GNU_RETAIN sections and strip output SHF_GNU_RETAIN for ↵Cary Coutant2020-12-141-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GNU/FreBSD ELFOSABIs. 2020-12-14 H.J. Lu <hjl.tools@gmail.com> Cary Coutant <ccoutant@gmail.com> elfcpp/ PR gold/27039 * elfcpp.h (SHF): Add SHF_GNU_RETAIN. gold/ PR gold/27039 * layout.cc (Layout::layout): Strip SHF_GNU_RETAIN. * object.cc (Sized_relobj_file::Sized_relobj_file): Initialize osabi_. (Sized_relobj_file::do_layout): Keep SHF_GNU_RETAIN sections for GNU/FreBSD ELFOSABIs. * object.h (Osabi) New class. (Sized_relobj_file): Add osabi() and osabi_. * testsuite/Makefile.am (check_SCRIPTS): Add retain.sh. (check_DATA): Add retain_1.out retain_2.out. (MOSTLYCLEANFILES): Add retain_1 retain_2. (retain_1.out): New target. (retain_1): Likewise. (retain_1.o): Likewise. (retain_2.out): Likewise. (retain_2): Likewise. (retain_2.o): Likewise. * testsuite/Makefile.in: Regenerate. * testsuite/retain.sh: New file. * testsuite/retain_1.s: Likewise. * testsuite/retain_2.s: Likewise.
* Update year range in copyright notice of binutils filesAlan Modra2020-01-011-1/+1
|
* Update year range in copyright notice of binutils filesAlan Modra2019-01-011-1/+1
|
* gold: Get alignment of uncompressed section from ch_addralignH.J. Lu2018-12-021-2/+6
| | | | | | | | | | | | | | | | | | | | | | The ELF compression header has a field (ch_addralign) that is set to the alignment of the uncompressed section. This way the section itself can have a different alignment than the decompressed section. Update decompress_input_section to get alignment of the decompressed section and use it when merging decompressed strings. PR binutils/23919 * merge.cc (Output_merge_string<Char_type>::do_add_input_section): Get addralign from decompressed_section_contents. * object.cc (build_compressed_section_map): Set info.addralign. (Object::decompressed_section_contents): Add a palign argument and store p->second.addralign in *palign if it isn't NULL. * object.h (Compressed_section_info): Add addralign. (section_is_compressed): Add a palign argument, default it to NULL, store p->second.addralign in *palign if it isn't NULL. (Object::decompressed_section_contents): Likewise. * output.cc (Output_section::add_input_section): Get addralign from section_is_compressed.
* Add support for .note.gnu.property sections.Cary Coutant2018-06-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | elfcpp/ PR gold/22914 * elfcpp.h (NT_GNU_PROPERTY_TYPE_0): New note type. (GNU_PROPERTY_*): New Gnu property types. * x86_64.h (GNU_PROPERTY_X86_FEATURE_1_IBT) (GNU_PROPERTY_X86_FEATURE_1_SHSTK): New x86 feature bits. gold/ PR gold/22914 * layout.cc (Layout::Layout): Initialize gnu_properties_. (read_sized_value, write_sized_value): New functions. (Layout::layout_gnu_property): New method. (Layout::create_notes): Call create_gnu_properties_note. (Layout::create_gnu_properties_note): New method. * layout.h (Layout::layout_gnu_property): New method. (Layout::create_gnu_properties_note): New method. (Layout::Gnu_property, Layout::Gnu_properties): New types. (Layout::gnu_properties_): New data member. * object.cc (Sized_relobj_file::layout_gnu_property_section): New method. (Sized_relobj_file::do_layout): Handle .note.gnu.property sections. * object.h (Sized_relobj_file::layout_gnu_property_section): New method. * target.h (Target::merge_gnu_property): New method. (Target::do_merge_gnu_property): New virtual method. * x86_64.cc (Target_x86_64::do_merge_gnu_property): New method. * testsuite/Makefile.am (gnu_property_test): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/gnu_property_a.S: New source file. * testsuite/gnu_property_b.S: New source file. * testsuite/gnu_property_c.S: New source file. * testsuite/gnu_property_main.c: New source file. * testsuite/gnu_property_test.sh: New test script.
* Further improve warnings for relocations referring to discarded sections.Cary Coutant2018-04-061-12/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Relocations referring to discarded sections are now treated as errors instead of warnings. Also with this patch, we will now print the section group signature and the object file with the prevailing definition of that group along with the name of the symbol that the relocation is referring to. This additional information should be much more useful to anyone trying to track down the source of such errors. To do so, we now map each discarded section to the Kept_section info in the Layout class, and defer the logic that maps a discarded section to its counterpart in the kept group. This gives us the information we need to identify the signature symbol given the discarded section, and the name of the object file that provided the prevailing (i.e., first) definition of that group. gold/ * object.cc (Sized_relobj_file::include_section_group): Store reference to Kept_section info for discarded comdat sections regardless of size. Move size checking to map_to_kept_section. (Sized_relobj_file::include_linkonce_section): Likewise. (Sized_relobj_file::map_to_kept_section): Add section name parameter. Insert size checking logic from above functions. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. * object.h (Sized_relobj_file::map_to_kept_section): Add section_name parameter. Adjust all callers. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. (Sized_relobj_file::Kept_comdat_section): Replace object and shndx fields with sh_size, kept_section, symndx, and is_comdat fields. (Sized_relobj_file::set_kept_comdat_section): Replace kept_object and kept_shndx parameters with is_comdat, symndx, sh_size, and kept_section. (Sized_relobj_file::get_kept_comdat_section): Likewise. * target-reloc.h (enum Comdat_behavior): Change CB_WARNING to CB_ERROR. Adjust all references. (issue_undefined_symbol_error): New function template. (relocate_section): Pass section name to map_to_kept_section. Move discarded section code to new function above. * aarch64.cc (Target_aarch64::scan_reloc_section_for_stubs): Move declaration for gsym out one level. Call issue_discarded_error. * arm.cc (Target_arm::scan_reloc_section_for_stubs): Likewise. * powerpc.cc (Relocate_comdat_behavior): Change CB_WARNING to CB_ERROR.
* Fix problem where mixed section types can cause internal error during a -r link.Cary Coutant2018-04-021-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During a -r (or --emit-relocs) link, if two sections had the same name but different section types, gold would put relocations for both sections into the same relocation section even though the data sections remained separate. For .eh_frame sections, when one section is PROGBITS and another is X86_64_UNWIND, we really should be using the UNWIND section type and combining the sections anyway. For other sections, we should be creating one relocation section for each output data section. gold/ PR gold/23016 * incremental.cc (can_incremental_update): Check for unwind section type. * layout.h (Layout::layout): Add sh_type parameter. * layout.cc (Layout::layout): Likewise. (Layout::layout_reloc): Create new output reloc section if data section does not already have one. (Layout::layout_eh_frame): Check for unwind section type. (Layout::make_eh_frame_section): Use unwind section type for .eh_frame and .eh_frame_hdr. * object.h (Sized_relobj_file::Shdr_write): New typedef. (Sized_relobj_file::layout_section): Add sh_type parameter. (Sized_relobj_file::Deferred_layout::Deferred_layout): Add sh_type parameter. * object.cc (Sized_relobj_file::check_eh_frame_flags): Check for unwind section type. (Sized_relobj_file::layout_section): Add sh_type parameter; pass it to Layout::layout. (Sized_relobj_file::do_layout): Make local copy of sh_type. Force .eh_frame sections to unwind section type. Pass sh_type to layout_section. (Sized_relobj_file<size, big_endian>::do_layout_deferred_sections): Pass sh_type to layout_section. * output.cc (Output_section::Output_section): Initialize reloc_section_. * output.h (Output_section::reloc_section): New method. (Output_section::set_reloc_section): New method. (Output_section::reloc_section_): New data member. * target.h (Target::unwind_section_type): New method. (Target::Target_info::unwind_section_type): New data member. * aarch64.cc (aarch64_info): Add unwind_section_type. * arm.cc (arm_info, arm_nacl_info): Likewise. * i386.cc (i386_info, i386_nacl_info, iamcu_info): Likewise. * mips.cc (mips_info, mips_nacl_info): Likewise. * powerpc.cc (powerpc_info): Likewise. * s390.cc (s390_info): Likewise. * sparc.cc (sparc_info): Likewise. * tilegx.cc (tilegx_info): Likewise. * x86_64.cc (x86_64_info, x86_64_nacl_info): Likewise. * testsuite/Makefile.am (pr23016_1, pr23016_2): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/testfile.cc: Add unwind_section_type. * testsuite/pr23016_1.sh: New test script. * testsuite/pr23016_1a.s: New source file. * testsuite/pr23016_1b.s: New source file. * testsuite/pr23016_2.sh: New test script. * testsuite/pr23016_2a.s: New source file. * testsuite/pr23016_2b.s: New source file.
* Update year range in copyright notice of binutils filesAlan Modra2018-01-031-1/+1
|
* Allow multiple .eh_frame sections per object file.Cary Coutant2017-11-281-3/+0
| | | | | | | | | | | | | | | | | | LLVM is experimenting with placing .eh_frame sections in the COMDAT group with the function's text. This triggers an internal error in gold because we don't expect to see but one .eh_frame section in an object, and we use a single data member in class Sized_relobj_file to keep track of that section. This patch removes that data member, and instead checks the output section and the input section offset to identify an optimized .eh_frame section. gold/ * object.h (class Sized_relobj_file): Remove discarded_eh_frame_shndx_. * object.cc (Sized_relobj_file::Sized_relobj_file): Likewise. (Sized_relobj_file::layout_eh_frame_section): Likewise. (Sized_relobj_file::do_count_local_symbols): Check for optimized .eh_frame section by other means. (Sized_relobj_file::compute_final_local_value_internal): Likewise.
* Fix symbol values and relocation addends for relocatable links.Cary Coutant2017-11-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix problems with -r.James Clarke2017-11-081-3/+1
| | | | | | | | | | | | | | | | | | | The fix committed for PR gold/19291 ended up breaking other cases. The commit added adjustment code to write_local_symbols, but in many cases compute_final_local_value_internal had already subtracted the output section's address. To fix this, all other adjustments are now removed, so only the one in write_local_symbols is left. gold/ PR gold/22266 * object.cc (Sized_relobj_file::compute_final_local_value_internal): Drop relocatable parameter and stop adjusting output value based on it. (Sized_relobj_file::compute_final_local_value): Stop passing relocatable to compute_final_local_value_internal. (Sized_relobj_file::do_finalize_local_symbols): Ditto. * object.h (Sized_relobj_file::compute_final_local_value_internal): Drop relocatable parameter.
* Refactor Sized_relobj_file::do_relocate_sections.Cary Coutant2017-01-101-0/+7
| | | | | | | | | | | gold/ * aarch64.cc (AArch64_relobj::do_relocate_sections): Call Sized_relobj_file::relocate_section_range(). * arm.cc (Arm_relobj::do_relocate_sections): Likewise. * object.h (Sized_relobj_file::relocate_section_range): New method. * reloc.cc (Sized_relobj_file::do_relocate_sections): Move implementation... (Sized_relobj_file::relocate_section_range): ...to new method.
* Update year range in copyright notice of all files.Alan Modra2017-01-021-1/+1
|
* Refactor gold to enable support for MIPS-64 relocation format.Cary Coutant2016-01-111-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Copyright update for binutilsAlan Modra2016-01-011-1/+1
|
* Remove const from return type of get_output_view.Cary Coutant2015-12-131-3/+3
| | | | | | | | gold/ * object.h (Object::get_output_view): remove const from return type. (Object::do_get_output_view): Likewise. (Sized_relobj_file::do_get_output_view): Likewise. * reloc.cc (Sized_relobj_file::do_get_output_view): Likewise.
* Make output views accessible to Target during do_relocate().Cary Coutant2015-12-111-0/+16
| | | | | | | | | | | | | gold/ * object.cc (Sized_relobj_file::Sized_relobj_file): Initialize output_views_. * object.h (Object::get_output_view): New function. (Object::do_get_output_view): New function. (Sized_relobj_file::do_get_output_view): New function. (Sized_relobj_file::output_views_): New data member. * reloc.cc: (Sized_relobj_file::do_relocate): Store pointer to output views in class object. (Sized_relobj_file::do_get_output_view): New function.
* [GOLD] Relocate::relocate() paramsAlan Modra2015-12-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Take addend into account when making GOT entries for local symbols.Vladimir Radosavljevic2015-12-031-22/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | gold/ * object.cc (Sized_relobj::do_for_all_local_got_entries): Use Local_got_entry_key for searching in local_got_offsets_. * object.h (class Local_got_entry_key): New class. (Relobj::local_has_got_offset): New overloaded method. (Relobj::local_got_offset): Likewise. (Relobj::set_local_got_offset): Likewise. (Relobj::do_local_has_got_offset): Add addend argument. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Add addend argument, and use Local_got_entry_key for searching through local_got_offsets_. (Sized_relobj::do_local_got_offset): Likewise. (Sized_relobj::do_set_local_got_offset): Likewise. (Sized_relobj::Local_got_offsets): Change type of the key from unsigned int to Local_got_entry_key, and add hash and equal_to. * output.cc (Got_entry::write): Take addend into account for calculating value of the local symbol for GOT. (Output_data_got::add_local): New definition of overloaded method. (Output_data_got::add_local_with_rel): Likewise. (Output_data_got::add_local_pair_with_rel): Likewise. * output.h (Output_data_got::add_local): New declaration of overloaded method.
* Fix --no-as-needed when shared library is listed twice on the command line.Cary Coutant2015-08-251-1/+6
| | | | | | | | | | | | | | | | | When a shared library is listed twice on the command line, the linker ignores the second mention. If the first mention is in the scope of an --as-needed option, and the second one is under the scope of a --no-as-needed option, the --no-as-needed should take effect, but doesn't. This patch keeps track of the objects we've already seen, and updates the --as-needed flag so that if a shared object is ever seen with --no-as-needed, it will be marked as such. gold/ PR gold/18859 * object.cc (Input_objects::add_object): Store objects in a map, indexed by soname; update as-needed flag when necessary. * object.h (Object::clear_as_needed): New method. (Input_objects::so_names_): Change from set to map.
* Add SHF_COMPRESSED section decompression to goldH.J. Lu2015-07-121-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds SHF_COMPRESSED section decompression to gold. PR gold/18321 * compressed_output.h (decompress_input_section): Add arguments for ELF class, big endian and sh_flags. * compressed_output.cc (decompress_input_section): Likewise. Support the SHF_COMPRESSED section. * dynobj.h (Dynobj): Add elfsize and is_big_endian member functions. * plugin.h (Pluginobj): Likewise. * layout.cc (Layout::get_output_section_flags): Also clear the SHF_COMPRESSED bit. * object.h (Compressed_section_info): Add flag to store sh_flags. (Object): Add pure virtual elfsize and is_big_endian member functions. * object.cc (need_decompressed_section): Don't skip the ".zdebug" prefix here. (build_compressed_section_map): Check SHF_COMPRESSED for uncompressed size. Store sh_flags in Compressed_section_info. Pass size, big_endian and sh_flags to decompress_input_section. Skip the ".debug"/".zdebug" prefix when passing section name to need_decompressed_section. (Sized_relobj_file<size, big_endian>::do_find_special_section): Don't check ".zdebug_*" sections. (Object::decompressed_section_contents): Pass ELF class, big endian and sh_flags to decompress_input_section. * reloc.cc (Sized_relobj_file<size, big_endian>::write_sections): Likewise. * testsuite/Makefile.am (check_DATA): Add debug_msg_cdebug_gabi.err and gdb_index_test_2_gabi.stdout. (MOSTLYCLEANFILES): Add debug_msg_cdebug_gabi.err and gdb_index_test_2_gabi.stdout. (debug_msg_cdebug_gabi.o): New. (odr_violation1_cdebug_gabi.o): Likewise. (odr_violation2_cdebug_gabi.o): Likewise. (debug_msg_cdebug_gabi.err): Likewise. (check_SCRIPTS): Add gdb_index_test_2_gabi.sh. (gdb_index_test_cdebug_gabi.o): Likewise. (gdb_index_test_2_gabi): Likewise. (gdb_index_test_2_gabi.stdout): Likewise. * testsuite/gdb_index_test_2_gabi.sh: New file. * testsuite/Makefile.in: Regenerated.
* Change Section_id type to use Relobj* instead of Object*.Cary Coutant2015-05-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2015-04-29 Cary Coutant <cary@google.com> Rafael Ávila de Espíndola <rafael.espindola@gmail.com> gold/ * gc.h (Garbage_collection::is_section_garbage): Change Object* to Relobj*. (Garbage_collection::add_reference): Likewise. (Garbage_collection::gc_process_relocs): Likewise. Don't push object/shndx pair onto *secvec for dynamic objects. Don't follow relocations pointing to dynamic objects for GC. * icf.cc (Icf::find_identical_sections): Change Object* to Relobj*. (Icf::unfold_section): Likewise. (Icf::is_section_folded): Likewise. (Icf::get_folded_section): Likewise. * icf.h: (Icf::get_folded_section): Likewise. (Icf::unfold_section): Likewise. (Icf::is_section_folded): Likewise. (Icf::section_has_function_pointers): Likewise. (Icf::set_section_has_function_pointers): Likewise. * object.h (Section_id): Likewise. (Const_section_id): Likewise. * output.cc (Output_section::update_section_layout): Likewise. * output.h: (Output_section_lookup_maps::find_relaxed_input_section): Likewise. * plugin.cc (update_section_order): Likewise. (unique_segment_for_sections): Likewise. * powerpc.cc (Powerpc_relobj::add_reference): Likewise. (Target_powerpc::do_gc_add_reference): Likewise. (Target_powerpc::gc_process_relocs): Likewise. (Target_powerpc::do_gc_add_reference): Likewise. * symtab.cc (Symbol_table::is_section_folded): Likewise. (Symbol_table::gc_mark_symbol): Likewise. * symtab.h: (Symbol_table::is_section_folded): Likewise. * target.h: (Sized_target::gc_add_reference): Likewise. (Sized_target::do_gc_add_reference): Likewise.
* Avoid looking up Input_merge_map multiple times.Rafael Ávila de Espíndola2015-03-271-0/+3
| | | | | Avoid looking up Input_merge_map multiple times when we know were are processing items from the same input section.
* Remove is_merge_section_for.Rafael Ávila de Espíndola2015-03-231-3/+2
| | | | | | Now that Input_merge_map has an Output_section_data, we can use it in implementing find_merge_section and replace the only use of is_merge_section_for with it.
* Support compressed debug sections in dynamic object files.Cary Coutant2015-03-211-73/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for reading compressed debug info in shared objects. It actually simplifies things, by moving the support for compressed sections all the way up to the top-level Object class, eliminating the need for several virtual methods. gold/ * dwp.cc (Sized_relobj_dwo::do_section_contents): Delete. (Sized_relobj_dwo::setup): Build compressed section map. (Sized_relobj_dwo::do_decompressed_section_contents): Delete. * dynobj.cc (Sized_dynobj::base_read_symbols): Build compressed section map. * object.cc (Sized_relobj_file::Sized_relobj_file): Remove compressed_sections_ field. (build_compressed_section_map): Take Object instead of Sized_relobj_file parameter; add decompress_if_needed parameter. (Sized_relobj_file::do_find_special_sections): Store compressed section map in parent Object. (Sized_relobj_file::do_decompressed_section_contents): Move implementation to Object::decompressed_section_contents. (Sized_relobj_file::do_discard_decompressed_sections): Move implementation to Object::discard_decompressed_sections. * object.h (build_compressed_section_map): Declare. (Object::Object): Add compressed_sections_ field. (Object::section_is_compressed): Move implementation here. (Object::decompressed_section_contents): De-virtualize. (Object::discard_decompressed_sections): De-virtualize. (Object::do_section_is_compressed): Delete. (Object::do_decompressed_section_contents): Delete. (Object::set_compressed_sections): New method. (Object::compressed_sections): New method. (Object::compressed_sections_): New data member. (Compressed_section_info, Compressed_section_map): Move to top of file. (Sized_relobj_file::do_section_is_compressed): Delete. (Sized_relobj_file::do_decompressed_section_contents): Delete. (Sized_relobj_file::do_discard_decompressed_sections): Delete. (Sized_relobj_file::compressed_sections_): Move to Object class.
* Remove empty class Merge_map.Rafael Ávila de Espíndola2015-03-041-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2015-03-02 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> * ehframe.cc (Cie::set_output_offset): Pass in and use a Output_section_data instead of a Merge_map. (Eh_frame::Eh_frame): Don't initialize merge_map_. (Eh_frame::read_cie): Use add_merge_mapping instead of Merge_map::add_mapping. (Eh_frame::read_fde): Ditto. (Eh_frame::set_final_data_size): Use this instead of this->merge_map_. (Eh_frame::do_output_offset): Use merge_output_offset istead of merge_map_->get_output_offset. (Eh_frame::do_is_merge_section_for): Delete. * ehframe.h (Fde::add_mapping): Pass in and use a Output_section_data instead of a Merge_map. (Cie::set_output_offset): Pass in a Output_section_data instead of a Merge_map. (Eh_frame::do_is_merge_section_for): Delete. (Eh_frame::merge_map_): Delete. * merge.cc (Object_merge_map::get_or_make_input_merge_map): Pass in and use a Output_section_data instead of a Merge_map. (Object_merge_map::add_mapping): Ditto. (Object_merge_map::get_output_offset): Remove the merge_map argument. (Object_merge_map::is_merge_section_for): Pass in and use a Output_section_data instead of a Merge_map. (Merge_map): Delete. (Output_merge_base::do_output_offset): Use merge_output_offset instead of merge_map_.get_output_offset. (Output_merge_base::do_is_merge_section_for): Delete. (Output_merge_data::do_add_input_section): Use object->add_merge_mapping instead of add_mapping. (Output_merge_string<Char_type>::finalize_merged_data): Ditto. * merge.h (Merge_map): Delete forward declaration. (Object_merge_map::add_mapping): Pass in and use a Output_section_data instead of a Merge_map. (Object_merge_map::get_output_offset): Remove the merge_map argument. (Object_merge_map::is_merge_section_for): Pass in and use a Output_section_data instead of a Merge_map. (Input_merge_map::Object_merge_map::merge_map): Replace with output_data. (Object_merge_map::get_or_make_input_merge_map): Pass in and use a Output_section_data instead of a Merge_map. (Merge_map): Delete. (Output_merge_base::Output_merge_base): Don't initialize merge_map_. (Output_merge_base::do_is_merge_section_for): Delete. (Output_merge_base::add_mapping): Delete. (Output_merge_base::merge_map_): Delete. * object.cc (Relobj::initialize_input_to_output_map): New. (Relobj::initialize_input_to_output_map): New. (Relobj::merge_output_offset): New. (Relobj::is_merge_section_for): New. (Relobj::initialize_input_to_output_map): Instantiate for 32 and 64 bits. * object.h (Relobj::merge_map): Delete. (initialize_input_to_output_map): New. (set_merge_map): Delete. (add_merge_mapping): New. (merge_output_offset): New. (is_merge_section_for): New. * output.cc (Output_section::Input_section::is_merge_section_for): Use object->is_merge_section_for. * output.h (Output_section_data::is_merge_section_for): Delete. (Output_section_data::do_is_merge_section_for): Delete. * reloc.cc (Merged_symbol_value<size>::initialize_input_to_output_map): Use object->initialize_input_to_output_map. (Merged_symbol_value<size>::value_from_output_section): Use object->merge_output_offset.
* ChangeLog rotatation and copyright year updateAlan Modra2015-01-021-1/+1
|
* Fix corrupted .eh_frame section with LTO and --gc-sections.Cary Coutant2014-11-251-0/+7
| | | | | | | | | | | | | | | | When --gc-sections is turned on during an LTO link, the .eh_frame sections from deferred files are processed before those from the replacement files. As a result, the section end-cap from crtendS.o is placed ahead of the .eh_frame data from the replacement files. This patch fixes the bug by skipping the layout of the deferred sections during GC pass 2. gold/ PR gold/17639 * object.cc (Sized_relobj_file): Initialize is_deferred_layout_. (Sized_relobj_file::do_layout): Handle deferred sections properly during GC pass 1. Don't add reloc sections to deferred list twice. * object.h (Sized_relobj_file::is_deferred_layout): New function. (Sized_relobj_file::is_deferred_layout_): New data member.
* Make Elf_file::section_name() a const function, so that it can be used inCary Coutant2014-09-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | places where we have only a const Elf_file*. elfcpp/ * elfcpp_file.h (Elf_file::shnum): New const function. (Elf_file::shstrndx): New const function. (Elf_file::large_shndx_offset): New const function. (Elf_file::section_name): Add const attribute. (Elf_file::section_header_offset): Likewise. gold/ * dwp.cc (Sized_relobj_dwo::do_section_name): Add const attribute. * dynobj.h (Sized_dynobj::do_section_name): Likewise. * incremental.cc (Sized_relobj_incr::do_section_name): Likewise. (Sized_incr_dynobj::do_section_name): Likewise. * incremental.h (Sized_relobj_incr::do_section_name): Likewise. (Sized_incr_dynobj::do_section_name): Likewise. * object.h (Object::section_name): Likewise. (Object::do_section_name): Likewise. (Sized_relobj_file::do_section_name): Likewise. * plugin.cc (Sized_pluginobj::do_section_name): Likewise. * plugin.h (Sized_pluginobj::do_section_name): Likewise.
* Fix internal error with LTO on ARM.Cary Coutant2014-07-081-0/+5
| | | | | | | | | | | | | | | | | This prevents the target-specific do_read_symbols methods from being called twice when do_layout_deferred_sections needs to layout an .eh_frame section. gold/ PR gold/15639 * dynobj.h (Sized_dynobj::base_read_symbols): New method. * dynobj.cc (Sized_dynobj::do_read_symbols): Move body to... (Sized_dynobj::base_read_symbols): ...new method. * object.h (Sized_relobj_file::base_read_symbols): New method. * object.cc (Sized_relobj_file::do_read_symbols): Move body to... (Sized_relobj_file::base_read_symbols): ...new method. * arm.cc (Arm_relobj::do_read_symbols): Call base_read_symbols. * mips.cc: (Mips_relobj::do_read_symbols): Likewise. * powerpc.cc (Powerpc_dynobj::do_read_symbols): Likewise.
* Update copyright yearsAlan Modra2014-03-051-2/+1
|
* PR binutils/15834Nick Clifton2013-08-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Fix typos: --- bfd/bfdio.c | 2 +- bfd/elf32-spu.c | 2 +- bfd/elfnn-aarch64.c | 2 +- binutils/od-xcoff.c | 2 +- config/tcl.m4 | 2 +- gas/config/tc-ia64.c | 2 +- gas/config/tc-sparc.c | 2 +- gas/config/tc-z80.c | 12 ++++++------ gas/doc/c-i386.texi | 6 +++--- gas/doc/c-m32r.texi | 2 +- gas/testsuite/gas/d10v/instruction_packing.d | 2 +- gas/testsuite/gas/z80/atend.d | 2 +- gold/object.h | 2 +- include/gdb/remote-sim.h | 2 +- include/opcode/ChangeLog | 2 +- include/opcode/i960.h | 2 +- ld/testsuite/ld-mips-elf/mips16-pic-1.inc | 2 +- opcodes/aarch64-asm.c | 2 +- opcodes/aarch64-dis.c | 2 +- opcodes/msp430-dis.c | 2 +-
* gold/Cary Coutant2013-07-311-0/+16
| | | | | | | | | * object.cc (Sized_relobj::do_output_section_address): New function. (Sized_relobj): Instantiate explicitly. * object.h (Object::output_section_address): New function. (Object::do_output_section_address): New function. (Sized_relobj::do_output_section_address): New function. * powerpc.cc (Target_powerpc::symval_for_branch): Use it.
* gold/Cary Coutant2013-05-211-2/+2
| | | | | | | | | * object.cc (Sized_relobj_file::get_symbol_location_info): Set type of enclosing symbol. (Relocate_info::location): Check symbol type when describing symbol. * object.h (Symbol_location_info): Remove unused line_number; add enclosing_symbol_type. * testsuite/debug_msg.sh: Adjust expected output.
* * gold.cc (queue_middle_tasks): Move detect_odr_violations..Alan Modra2013-03-101-9/+10
| | | | | | | | | | | | | | | | | | | * layout.cc (Layout_task_runner::run): ..to here. * symtab.h (struct Symbol_location): Extract from.. (class Symbol_table): ..here. * symtab.cc (Symbol_table::linenos_from_loc): Invoke function_location. * target.h (class Target): Add function_location and do_function_location functions. (class Sized_target): Add do_function_location. * object.h (class Sized_relobj_file): Move find_shdr.. (class Object): ..to here. * object.cc: Likewise. Update to suit. Instantiate. (Sized_relobj_file::find_eh_frame): Update find_shdr call. * powerpc.cc (class Powerpc_dynobj): New. (Target_powerpc::do_function_location): New function. (Powerpc_relobj::do_find_special_sections): Update find_shdr call. (Powerpc_dynobj::do_read_symbols): New function. (Target_powerpc::do_make_elf_object): Make a Powerpc_dynobj.
* gold/Cary Coutant2012-10-231-0/+30
| | | | | | | | | | * dwarf_reader.cc (make_elf_reloc_mapper): Check size and endianness from object, not parameters. (Dwarf_info_reader::parse): Likewise. * object.h (Relobj::elfsize, Relobj::is_big_endian): New methods. (Relobj::do_elfsize, Relobj::do_is_big_endian): New methods. (Sized_relobj::do_elfsize, Sized_relobj::do_is_big_endian): New methods.
* * object.h (Sized_relobj_file::adjust_local_symbol,Alan Modra2012-09-251-0/+12
| | | | | | | | | | | | do_adjust_local_symbol): New functions. * object.cc (Sized_relobj_file::do_count_local_symbols): Use the above. * powerpc.cc (Powerpc_relobj::do_adjust_local_symbol): New function. (Powerpc_relobj::scan_opd_relocs): Warn on unexpected opd relocs and irregular opd entry spacing. (Powerpc_relobj::do_read_relocs): Add opd size checks. (Global_symbol_visitor_opd): New functor. (Target_powerpc::do_finalize_sections): Omit global symbols defined on deleted opd entries.
* PR gold/14570Ian Lance Taylor2012-09-121-0/+14
| | | | | | | | | | | | * output.cc: Rename Output_data_got template parameter from size to got_size for all functions. Compile all variants of Output_data_got. (Output_data_got::Got_entry::write): Correct use of size for symbol value. Use local_is_tls rather than casting to Sized_relobj_file. * object.h (class Object): Add local_is_tls and do_local_is_tls. (class Sized_relobj_file): Add do_local_is_tls. * incremental.h (class Sized_relobj_incr): Add do_local_is_tls.
* * object.h (Sized_relobj_file::emit_relocs): Delete.Alan Modra2012-09-051-21/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* * object.h (Sized_relobj_file::find_shdr): New function.Alan Modra2012-08-111-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | (Sized_relobj_file::find_special_sections): New function. * object.cc (Sized_relobj_file::find_shdr): New function. (Sized_relobj_file::find_eh_frame): Use find_shdr. (Sized_relobj_file::find_special_sections): New function, split out.. (Sized_relobj_file::do_read_symbols): ..from here. * output.h (Output_data_got::replace_constant): New function. (Output_data_got::num_entries): New function. (Output_data_got::last_got_offset,set_got_size): Use num_entries. (Output_data_got::got_offset): Protected rather than private. (Output_data_got::replace_got_entry): New function. * output.cc (Output_data_got::replace_got_entry): New function. * powerpc.cc (class Powerpc_relobj): New. (class Powerpc_relocate_functions): Delete all psymval variants or convert to value,addend type. Delete pcrela, pcrela_unaligned. Implement _ha functions using corresponding _hi function. (Powerpc_relobj::find_special_sections): New function. (Target_powerpc::do_make_elf_object): New function. (class Output_data_got_powerpc): New. (class Output_data_glink): New. (class Powerpc_scan_relocatable_reloc): New. Many more changes througout file.
* * arm.cc (Target_arm::do_is_defined_by_abi): Make sym a constIan Lance Taylor2012-04-261-2/+3
| | | | | | | | | | | | pointer. (Stub_addend_reader::operator()): Declare Arm_relocate_functions as a class, not a struct. (Target_arm::scan_span_for_cortex_a8_erratum): Likewise. (Target_arm::apply_cortex_a8_workaround): Likewise. * gc.h: Declare Reloc_types as a struct, not a class. * object.h: Declare Symbols_data as a struct. * reloc.h: Declare Read_relocs_data as a struct. * target.h: Declare Relocate_info as a struct.
* 2012-03-21 Cary Coutant <ccoutant@google.com>Cary Coutant2012-03-211-8/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile.am: Add gdb-index.cc, gdb-index.h. * Makefile.in: Regenerate. * dwarf_reader.cc (Sized_elf_reloc_mapper::do_initialize): New function. (Sized_elf_reloc_mapper::symbol_section): New function. (Sized_elf_reloc_mapper::do_get_reloc_target): New function. (make_elf_reloc_mapper): New function. (Dwarf_abbrev_table::clear_abbrev_codes): New function. (Dwarf_abbrev_table::do_read_abbrevs): New function. (Dwarf_abbrev_table::do_get_abbrev): New function. (Dwarf_ranges_table::read_ranges_table): New function. (Dwarf_ranges_table::read_range_list): New function. (Dwarf_pubnames_table::read_section): New function. (Dwarf_pubnames_table::read_header): New function. (Dwarf_pubnames_table::next_name): New function. (Dwarf_die::Dwarf_die): New function. (Dwarf_die::read_attributes): New function. (Dwarf_die::skip_attributes): New function. (Dwarf_die::set_name): New function. (Dwarf_die::set_linkage_name): New function. (Dwarf_die::attribute): New function. (Dwarf_die::string_attribute): New function. (Dwarf_die::int_attribute): New function. (Dwarf_die::uint_attribute): New function. (Dwarf_die::ref_attribute): New function. (Dwarf_die::child_offset): New function. (Dwarf_die::sibling_offset): New function. (Dwarf_info_reader::check_buffer): New function. (Dwarf_info_reader::parse): New function. (Dwarf_info_reader::do_parse): New function. (Dwarf_info_reader::do_read_string_table): New function. (Dwarf_info_reader::lookup_reloc): New function. (Dwarf_info_reader::get_string): New function. (Dwarf_info_reader::visit_compilation_unit): New function. (Dwarf_info_reader::visit_type_unit): New function. (Sized_dwarf_line_info::Sized_dwarf_line_info): Use Sized_elf_reloc_mapper. (Sized_dwarf_line_info::symbol_section): Remove function. (Sized_dwarf_line_info::read_relocs): Use Sized_elf_reloc_mapper. (Sized_dwarf_line_info::read_line_mappings): Remove object parameter, adjust callers. (Sized_dwarf_line_info::format_file_lineno): Fix type of cast. * dwarf_reader.h: Include <sys/types.h>. (class Track_relocs): Remove forward declaration. (class Elf_reloc_mapper): New class. (class Sized_elf_reloc_mapper): New class. (class Dwarf_abbrev_table): New class. (class Dwarf_range_list): New class. (class Dwarf_ranges_table): New class. (class Dwarf_pubnames_table): New class. (class Dwarf_die): New class. (class Dwarf_info_reader): New class. (Sized_dwarf_line_info::read_line_mappings): Remove object parameter. (Sized_dwarf_line_info::symbol_section): Remove member function. * dynobj.h (Sized_dynobj::do_section_contents): Refactor code from base class. * gdb-index.cc: New source file. * gdb-index.h: New source file. * incremental.cc (Sized_relobj_incr::do_layout): Track .debug_info and .debug_types sections, call Layout::add_to_gdb_index. (Sized_relobj_incr::do_section_name): Implement. (Sized_relobj_incr::do_section_contents): Adjust parameter list and return type; Implement. (Sized_incr_dynobj::do_section_contents): Adjust parameter list and return type. * incremental.h (Sized_relobj_incr::do_section_contents): Adjust parameter list and return type. (Sized_incr_dynobj::do_section_contents): Likewise. * layout.cc: Include gdb-index.h. (Layout::Layout): Initialize gdb_index_data_. (Layout::init_fixed_output_section): Check for .gdb_index section. (Layout::add_to_gdb_index): New function. Instantiate. * layout.h: Add forward declaration for class Gdb_index. (Layout::add_to_gdb_index): New member function. (Layout::gdb_index_data_): New data member. * main.cc: Include gdb-index.h. (main): Print statistics for gdb index. * object.cc (Object::section_contents): Move code into do_section_contents. (need_decompressed_section): Check for sections needed when building gdb index. (build_compressed_section_map): Likewise. (Sized_relobj_file::do_read_symbols): Need local symbols when building gdb index. (Sized_relobj_file::do_layout): Track .debug_info and .debug_types sections; call Layout::add_to_gdb_index. (Sized_relobj_file::do_decompressed_section_contents): Call do_section_contents directly. * object.h (Object::do_section_contents): Adjust parameter list and return type. (Object::do_decompressed_section_contents): Call do_section_contents directly. (Sized_relobj_file::do_section_contents): Adjust parameter list and return type. * options.h (class General_options): Add --gdb-index option. * plugin.cc (Sized_pluginobj::do_section_contents): Adjust parameter list and return type. * plugin.h (Sized_pluginobj::do_section_contents): Likewise. * reloc.h (Track_relocs::checkpoint): New function. (Track_relocs::reset): New function. * testsuite/Makefile.am (gdb_index_test_1.sh, gdb_index_test_2.sh): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/gdb_index_test.cc: New test source file. * testsuite/gdb_index_test_1.sh: New test source file. * testsuite/gdb_index_test_2.sh: New test source file.
* * dwarf_reader.cc (Sized_dwarf_line_info::Sized_dwarf_line_info):Cary Coutant2012-02-291-4/+58
| | | | | | | | | | | | | | | | | | | | | | Call Object::decompressed_section_contents. * dwarf_reader.h (Sized_dwarf_line_info::~Sized_dwarf_line_info): New dtor. (Sized_dwarf_line_info::buffer_start_): New data member. * merge.cc (Output_merge_data::do_add_input_section): Call Object::decompressed_section_contents. (Output_merge_string::do_add_input_section): Likewise. * object.cc (need_decompressed_section): New function. (build_compressed_section_map): Decompress sections needed later. (Sized_relobj_file::do_decompressed_section_contents): New function. (Sized_relobj_file::do_discard_decompressed_sections): New function. * object.h (Object::decompressed_section_contents): New function. (Object::discard_decompressed_sections): New function. (Object::do_decompressed_section_contents): New function. (Object::do_discard_decompressed_sections): New function. (Compressed_section_info): New type. (Compressed_section_map): Include decompressed section contents. (Sized_relobj_file::do_decompressed_section_contents): New function. (Sized_relobj_file::do_discard_decompressed_sections): New function.