aboutsummaryrefslogtreecommitdiff
path: root/gold/object.cc
AgeCommit message (Collapse)AuthorFilesLines
2024-01-04Update year range in copyright notice of binutils filesAlan Modra1-1/+1
Adds two new external authors to etc/update-copyright.py to cover bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then updates copyright messages as follows: 1) Update cgen/utils.scm emitted copyrights. 2) Run "etc/update-copyright.py --this-year" with an extra external author I haven't committed, 'Kalray SA.', to cover gas testsuite files (which should have their copyright message removed). 3) Build with --enable-maintainer-mode --enable-cgen-maint=yes. 4) Check out */po/*.pot which we don't update frequently.
2023-08-02Revert "2.41 Release sources"Sam James1-8/+37
This reverts commit 675b9d612cc59446e84e2c6d89b45500cb603a8d. See https://sourceware.org/pipermail/binutils/2023-August/128761.html.
2023-08-022.41 Release sourcesbinutils-2_41-releaseNick Clifton1-37/+8
2023-07-26[GOLD] reporting local symbol namesAlan Modra1-8/+37
get_symbol_name currently returns "" for the usual STT_SECTION symbols generated by gas. That's not very helpful, return the section name. Demangle local symbols too, fixing an inconsistency in issue_discarded_error where global symbols are demangled. * object.cc (Sized_relobj_file::get_symbol_name): Return a std::string. Return section name for STT_SECTION symbols with zero st_name. Sanity check st_name, and don't run off the end of an improperly terminated .strtab. Demangle sym names. * object.h (Sized_relobj_file::get_symbol_name): Update decl. * target-reloc.h (issue_discarded_error): Adjust. * powerpc.cc (Target_powerpc::Relocate::relocate): Report reloc type and symbol for relocation overflows.
2023-07-17PR10957, Missing option to really print section+offsetAlan Modra1-1/+1
Many of the reloc error messages have already been converted from using %C to using %H in ld.bfd, to print section+offset as well as file/line/function. This catches a few remaining, and changes gold to do the same. PR 10957 bfd/ * elf32-sh.c (sh_elf_relocate_section): Use %H in error messages. gold/ * object.cc (Relocate_info::location): Always report section+offset. * testsuite/debug_msg.sh: Adjust to suit. * testsuite/x32_overflow_pc32.sh: Likewise. * testsuite/x86_64_overflow_pc32.sh: Likewise. ld/ * emultempl/pe.em (read_addend): Use %H in error message. * emultempl/pep.em (read_addend): Likewise. * ldcref.c (check_reloc_refs): Likewise. * ldmain.c (warning_find_reloc, undefined_symbol): Likewise. * pe-dll.c (pe_create_import_fixup): Likewise. * testsuite/ld-cris/undef2.d: Adjust expected output to suit. * testsuite/ld-cris/undef3.d: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-i386/compressed1.d: Likewise. * testsuite/ld-ia64/line.exp: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-undefined/undefined.exp: Likewise. * testsuite/ld-x86-64/compressed1.d: Likewise. * testsuite/ld-x86-64/line.exp: Likewise. * testsuite/ld-x86-64/pr27587.err: Likewise.
2023-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
The newer update-copyright.py fixes file encoding too, removing cr/lf on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2022-01-02Update year range in copyright notice of binutils filesAlan Modra1-1/+1
The result of running etc/update-copyright.py --this-year, fixing all the files whose mode is changed by the script, plus a build with --enable-maintainer-mode --enable-cgen-maint=yes, then checking out */po/*.pot which we don't update frequently. The copy of cgen was with commit d1dd5fcc38ead reverted as that commit breaks building of bfp opcodes files.
2021-09-18[GOLD] Remove addend from Local_got_entry_keyAlan Modra1-1/+1
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.
2021-03-19Use stdout when printing object file names for -t option.Cary Coutant1-1/+1
gold/ PR gold/27615 * errors.cc (Errors::trace): New method. (gold_trace): New function. * errors.h (Errors::trace): New method. * gold.h (gold_trace): New function. * object.cc (Input_objects::add_object): Use gold_trace to print object file names.
2021-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2020-12-15Cosmetic improvements for OSABI access.Cary Coutant1-4/+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.
2020-12-14Keep input SHF_GNU_RETAIN sections and strip output SHF_GNU_RETAIN for ↵Cary Coutant1-1/+3
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.
2020-12-13Fix incremental tests using gcc 9, which adds Gnu properties sections.Cary Coutant1-0/+4
During an incremental link, we should simply ignore the Gnu properties sections. We were not handling them properly -- failing to process the properties from the base file. While that could be fixed, the property sections are meant for deployed binaries, and incremental linking is for development, so keeping the properties sections just adds to the likelihood of forcing a full link sooner. gold/ PR gold/23539 * object.cc (Sized_relobj_file::layout_gnu_property_section): Ignore Gnu properties during incremental links.
2020-11-29gold: Get linkonce/comdate sections for debugging sectionsH.J. Lu1-4/+6
When relocating debug sections, get the section index for the linkonce section. Since symbols referenced in debugging sections can be defined a single comdat section with a different section name, also check the single comdat section. PR gold/26937 * object.cc (Sized_relobj_file::map_to_kept_section): Get the section index for linkonce section. Also check the single comdat section. * testsuite/Makefile.am (check_SCRIPTS): Add pr26936.sh. (check_DATA): Add pr26936a.stdout and pr26936b.stdout. (MOSTLYCLEANFILES): Add pr26936a and pr26936b. (pr26936a.stdout): New target. (pr26936a): Likewise. (pr26936b.stdout): Likewise. (pr26936b): Likewise. (pr26936a.o): Likewise. (pr26936b.o): Likewise. (pr26936c.o): Likewise. (pr26936d.o): Likewise. * testsuite/Makefile.in: Regenerated. * testsuite/pr26936.sh: New file. * testsuite/pr26936a.s: Likewise. * testsuite/pr26936b.s: Likewise. * testsuite/pr26936c.s: Likewise. * testsuite/pr26936d.s: Likewise.
2020-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2019-11-19[GOLD] OSABI not set when STT_GNU_IFUNC or STB_GNU_UNIQUE symbols outputAlan Modra1-0/+4
This patch arranges to have OSABI set to ELFOSABI_GNU (if not set to some other non-zero value) when gold outputs an ifunc local or global symbol, or a unique global symbol to either .dynsym or .symtab. STT_GNU_IFUNC and STB_GNU_UNIQUE have values in the LOOS to HIOS range and therefore require interpretation according to OSABI. I'm not sure why parameters->target() is const Target& while parameters->sized_target() is Sized_target*, but it's inconvenient to use the latter in Symbol_table::finalize. So this patch adds another const_cast complained about in layout.cc and gold.cc. PR 24853 * symtab.h (set_has_gnu_output, has_gnu_output_): New. * symtab.cc (Symbol_table::Symbol_table): Init has_gnu_output_. (Symbol_table::finalize): Set ELFOSABI_GNU when has_gnu_output_. (Symbol_table::set_dynsym_indexes, Symbol_table::sized_finalize): Call set_has_gnu_output for STT_GNU_IFUNC and STB_GNU_UNIQUE globals. * object.cc (Sized_relobj_file::do_finalize_local_symbols): Call set_has_gnu_output when STT_GNU_IFUNC locals will be output.
2019-09-20[GOLD] Fix spurious "plugin needed to handle lto object" warningsAlan Modra1-4/+9
lto_slim_object_ was unitialized. I also thought it worth adding a sanity check on the .gnu.lto_.lto.* section size, and made some other tidies. PR 24768 * layout.cc (Layout::Layout): Init lto_slim_object_. * object.cc (Sized_relobj_file::do_layout): Wrap overlong line. Don't use C cast. Validate section size. Don't copy contents.
2019-08-16Fix detection of missing plugin for LTO objects.Martin Liska1-3/+3
2019-08-16 Martin Liska <mliska@suse.cz> PR ld/24912 * elflink.c: Report error only for not relocatable. * linker.c (_bfd_generic_link_add_one_symbol): Do not handle here lto_slim_object as it's handled in caller. 2019-08-16 Martin Liska <mliska@suse.cz> PR ld/24912 * object.cc (big_endian>::do_layout): Do not report error, but only set a flag. (big_endian>::do_add_symbols): Report error only for when relocatable.
2019-07-29Support .gnu.lto_.lto section in ELF files (PR 24768).Martin Liska1-1/+30
bfd/ChangeLog: 2019-07-22 Martin Liska <mliska@suse.cz> PR 24768 * archive.c (_bfd_compute_and_write_armap): Come up with report_plugin_err variable. * bfd-in2.h (struct bfd): Add lto_slim_object flag. * elf.c (struct lto_section): New. (_bfd_elf_make_section_from_shdr): Parse content of .gnu_lto_.lto section. * elflink.c: Report error for a missing LTO plugin. * linker.c (_bfd_generic_link_add_one_symbol): Likewise. binutils/ChangeLog: 2019-07-22 Martin Liska <mliska@suse.cz> PR 24768 * nm.c (filter_symbols): Set report_plugin_err if error is reported. (display_rel_file): Report error for a missing LTO plugin. gold/ChangeLog: 2019-07-22 Martin Liska <mliska@suse.cz> PR 24768 * layout.h (class Layout): Add is_lto_slim_object and set_lto_slim_object. * object.cc (struct lto_section): Add lto_slim_object_. (big_endian>::do_layout): Parse content of .gnu_lto_.lto section. (big_endian>::do_add_symbols): Report error for a missing LTO plugin.
2019-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2018-12-02gold: Get alignment of uncompressed section from ch_addralignH.J. Lu1-2/+9
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.
2018-08-07Fix "may be used uninitialized" warning.Tulio Magno Quites Machado Filho1-2/+2
* object.cc (Sized_relobj_file::map_to_kept_section): Initialize kept_file.
2018-07-14Fix internal error when using --emit-relocs with plugins.Cary Coutant1-3/+7
When an .eh_frame section has deferred layout because of plugins, gold was neglecting to mark the section as deferred. When we later processed the corresponding relocation section, we were then ignoring it, causing the internal error later on in the link. gold/ PR gold/23397 * object.cc (Sized_relobj_file::do_layout): Mark section as deferred. * testsuite/Makefile.am (plugin_test_1): Add --emit-relocs option to existing test case. * testsuite/Makefile.in: Regenerate.
2018-06-22Update support for .note.gnu.property sections.Cary Coutant1-1/+4
The original patch did not give the target enough hooks to discover that an input object file does not have a particular property. For the GNU_PROPERTY_X86_FEATURE_1_AND property, for example, where a missing property should be assumed to be all zeroes, and ANDed with other object modules, this is essential. We now store the target-specific properties locally in the Target structure as native uint32_t fields, then AND the per-object feature bits with the program's feature bits when we're finished processing each input object file. The target-specific properties are then added back to the output note section during finalization. gold/ PR gold/22914 * layout.cc (read_sized_value): Fix spelling of section name. (Layout::layout_gnu_property): Call Sized_target::record_gnu_property for target-specific properties; don't store them with target-independent properties yet. (Layout::merge_gnu_properties): New method. (Layout::add_gnu_property): New method. (Layout::create_gnu_properties_note): Call target to finalize target-specific properties. Fix spelling of output section name. * layout.h (Layout::merge_gnu_properties): New method. (Layout::add_gnu_property): New method. * object.cc (Sized_relobj_file::do_layout): Call Layout::merge_gnu_properties. * target.h (Target::merge_gnu_property): Remove. (Target::finalize_gnu_properties): New method. (Target::do_merge_gnu_property): Move to Sized_target and rename. (Target::do_finalize_gnu_properties): New virtual method. (Sized_target::record_gnu_property): Moved and renamed from Target::do_merge_gnu_property. (Sized_target::merge_gnu_properties): New virtual method. * x86_64.cc (Target_x86_64::isa_1_used_, isa_1_needed_) (feature_1_, object_feature_1_, seen_first_object_): New data members. (Target_x86_64::do_merge_gnu_property): Rename to ... (Target_x86_64::record_gnu_property): ... this. Save target-specific properties in Target class object. (Target_x86_64::merge_gnu_properties): New method. (add_property): New static inline function. (Target_x86_64::do_finalize_gnu_properties): New method. * testsuite/Makefile.am (gnu_property_test): Remove C source file; link directly without compiler driver. * testsuite/Makefile.in: Regenerate. * testsuite/gnu_property_a.S: Add _start.
2018-06-22Add support for .note.gnu.property sections.Cary Coutant1-0/+104
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.
2018-04-06Further improve warnings for relocations referring to discarded sections.Cary Coutant1-60/+119
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.
2018-04-02Fix problem where mixed section types can cause internal error during a -r link.Cary Coutant1-33/+43
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.
2018-01-03Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2017-11-28Allow multiple .eh_frame sections per object file.Cary Coutant1-13/+10
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.
2017-11-27Fix symbol values and relocation addends for relocatable links.Cary Coutant1-16/+26
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-11-08Fix problems with -r.James Clarke1-19/+8
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.
2017-11-08Apply:Eric Christopher1-2/+2
2017-11-08 Kyle Butt <iteratee@google.com> * object.cc (do_find_special_sections): Fix a thinko with memmem return values and check for != NULL rather than == 0.
2017-01-12Fix incorrect byte counts.Cary Coutant1-3/+3
gold/ * object.cc (Sized_relobj_file): Fix byte counts for calls to memmem.
2017-01-02Update year range in copyright notice of all files.Alan Modra1-1/+1
2016-12-28Add explicit instantiations for build_compressed_section_map().Cary Coutant1-0/+32
gold/ PR gold/20996 * object.cc (build_compressed_section_map): Add explicit instantiations.
2016-12-05Fix problem where absolute local symbols are omitted when output has many ↵Cary Coutant1-2/+3
sections. 2016-12-05 Cary Coutant <ccoutant@gmail.com> Tristan Gingold <gingold@adacore.com> gold/ * object.cc (Sized_relobj_file::do_count_local_symbols): Check is_ordinary before using shndx. * testsuite/Makefile.am (file_in_many_sections_test.sh): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/file_in_many_sections.c: New source file. * testsuite/file_in_many_sections_test.sh: New script.
2016-01-01Copyright update for binutilsAlan Modra1-1/+1
2015-12-11Make output views accessible to Target during do_relocate().Cary Coutant1-1/+2
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.
2015-12-03Take addend into account when making GOT entries for local symbols.Vladimir Radosavljevic1-1/+2
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.
2015-11-25Adjust local symbol value in relocatable link to be relative to section.Cary Coutant1-2/+6
gold/ PR gold/19291 * object.cc (Sized_relobj_file::write_local_symbols): If relocatable, subtract section address from symbol value.
2015-08-25Fix --no-as-needed when shared library is listed twice on the command line.Cary Coutant1-2/+11
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.
2015-07-12Add SHF_COMPRESSED section decompression to goldH.J. Lu1-16/+35
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.
2015-06-04Change default to discard temporary local symbols in merge sections.Cary Coutant1-1/+7
Add --discard-none to keep all local symbols. gold/ PR gold/17498 * object.cc (Sized_relobj_file::do_count_local_symbols): Discard temporary locals in merge sections. * options.cc (General_options::parse_discard_all): New method. (General_options::parse_discard_locals): New method. (General_options::parse_discard_none): New method. (General_options::General_options): Initialize discard_locals_. * options.h (--discard-all): Convert to special option. (--discard-locals): Likewise. (--discard-none): New option. (General_options::discard_all): New method. (General_options::discard_locals): New method. (General_options::discard_sec_merge): New method. (General_options::Discard_locals): New enum. (General_options::discard_locals_): New data member.
2015-04-17Use LIFO instead of FIFO to implement gc's transitive closure.Rafael Ávila de Espíndola1-1/+1
FIFO is harder to implement and has less locality than LIFO. It is also not necessary to implement a transitive closure, a LIFO works just as well.
2015-03-27Avoid looking up Input_merge_map multiple times.Rafael Ávila de Espíndola1-7/+10
Avoid looking up Input_merge_map multiple times when we know were are processing items from the same input section.
2015-03-23Remove is_merge_section_for.Rafael Ávila de Espíndola1-6/+4
Now that Input_merge_map has an Output_section_data, we can use it in implementing find_merge_section and replace the only use of is_merge_section_for with it.
2015-03-21Support compressed debug sections in dynamic object files.Cary Coutant1-11/+14
This patch adds support for reading compressed debug info in shared objects. It actually simplifies things, by moving the support for compressed sections all the way up to the top-level Object class, eliminating the need for several virtual methods. gold/ * dwp.cc (Sized_relobj_dwo::do_section_contents): Delete. (Sized_relobj_dwo::setup): Build compressed section map. (Sized_relobj_dwo::do_decompressed_section_contents): Delete. * dynobj.cc (Sized_dynobj::base_read_symbols): Build compressed section map. * object.cc (Sized_relobj_file::Sized_relobj_file): Remove compressed_sections_ field. (build_compressed_section_map): Take Object instead of Sized_relobj_file parameter; add decompress_if_needed parameter. (Sized_relobj_file::do_find_special_sections): Store compressed section map in parent Object. (Sized_relobj_file::do_decompressed_section_contents): Move implementation to Object::decompressed_section_contents. (Sized_relobj_file::do_discard_decompressed_sections): Move implementation to Object::discard_decompressed_sections. * object.h (build_compressed_section_map): Declare. (Object::Object): Add compressed_sections_ field. (Object::section_is_compressed): Move implementation here. (Object::decompressed_section_contents): De-virtualize. (Object::discard_decompressed_sections): De-virtualize. (Object::do_section_is_compressed): Delete. (Object::do_decompressed_section_contents): Delete. (Object::set_compressed_sections): New method. (Object::compressed_sections): New method. (Object::compressed_sections_): New data member. (Compressed_section_info, Compressed_section_map): Move to top of file. (Sized_relobj_file::do_section_is_compressed): Delete. (Sized_relobj_file::do_decompressed_section_contents): Delete. (Sized_relobj_file::do_discard_decompressed_sections): Delete. (Sized_relobj_file::compressed_sections_): Move to Object class.
2015-03-05Remove typename on elfcpp::Elf_types<size>::Elf_AddrH.J. Lu1-4/+4
GCC 4.2 complains: binutils/gold/object.cc:3261: error: using ‘typename’ outside of template This patch removes typename. It works with both GCC 4.2 and 4.8. * output.cc (Relobj::initialize_input_to_output_map<size>): Remove typename on elfcpp::Elf_types<size>::Elf_Addr.
2015-03-04Remove empty class Merge_map.Rafael Ávila de Espíndola1-0/+63
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.
2015-02-17avoid std::vector copy.Rafael Ávila de Espíndola1-1/+1