aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
AgeCommit message (Collapse)AuthorFilesLines
2015-07-20Clear SHF_COMPRESSED flag bit from input to outputH.J. Lu4-6/+67
For relocatable link, we should clear the SHF_COMPRESSED flag bit from input group section. PR gold/18689 * layout.cc (Layout::layout): Clear the SHF_COMPRESSED flag bit from input group section for relocatable link. * testsuite/Makefile.am (check_SCRIPTS): Add pr18689.sh. (check_DATA): Add pr18689.stdout. (MOSTLYCLEANFILES): Add pr18689a.o pr18689b.o. (pr18689.stdout): New rule. (pr18689a.o): Likewise. (pr18689b.o): Likewise. (pr18689.o): Likewise. * testsuite/pr18689.c: New file. * testsuite/pr18689.sh: Likewise. * testsuite/Makefile.in: Regenerated.
2015-07-20Remove warning about references from shared objects to hidden symbols.Yiran Wang3-11/+20
gold/ PR gold/15574 * resolve.cc (Symbol_table): Remove warning about references from shared objects to hidden symbols. * testsuite/Makefile.am (hidden_test): Add hidden_test.syms. * testsuite/Makefile.in: Regenerate. * testsuite/hidden_test.sh: Check dynamic symbol table; update expected error messages.
2015-07-14Make default compression gABI compliantH.J. Lu2-4/+4
All programs in binutils+gdb git repo now support gABI compression with the SHF_COMPRESSED bit. This patch makes the zlib-gabi option as compression default for gas, gold, ld and objcopy, instead of the zlib-gnu option whose outputs are incompatible with gABI. binutils/ * objcopy.c (copy_file): Set BFD_COMPRESS_GABI if not zlib-gnu. * doc/binutils.texi: Change --compress-debug-sections and --compress-debug-sections=zlib to zlib-gabi. binutils/testsuite/ * binutils-all/compress.exp: Update. gas/ * as.c (parse_args): Make --compress-debug-sections and --compress-debug-sections=zlib the same as --compress-debug-sections=zlib-gabi. * doc/as.texinfo: Change --compress-debug-sections and --compress-debug-sections=zlib to zlib-gabi. gold/ * compressed_output.cc (Output_compressed_section::set_final_data_size): Make --compress-debug-sections=zlib the same as --compress-debug-sections=zlib-gabi. * testsuite/Makefile.am (flagstest_compress_debug_sections.check): Expect ".debug_.*" with the SHF_COMPRESSED bit, instead of ".zdebug_". * testsuite/Makefile.in: Regenerated. ld/ * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Make --compress-debug-sections=zlib the same as --compress-debug-sections=zlib-gabi. * ld.texinfo: Change --compress-debug-sections=zlib to zlib-gabi. ld/testsuite/ * ld-elf/zlibbegin.rS: Updated to .debug_.* with the SHF_COMPRESSED bit. * ld-elf/zlibnormal.rS: Likewise.
2015-07-12Extend --compress-debug-sections in goldH.J. Lu2-2/+221
This patch extends --compress-debug-sections= with [zlib-gnu|zlib-gabi] in gold. PR gold/18322 * compressed_output.cc (zlib_compress): Add argument for compression header size. Set header size to compression header size if it isn't 0. Don't write out the zlib header here. (Output_compressed_section::set_final_data_size): Support zlib-gnu and zlib-gabi compressions. Pass compression header size to zlib_compress and write out compression header. Set the SHF_COMPRESSED bit for zlib-gabi compression. Otherwise clear the SHF_COMPRESSED bit * options.h (compress_debug_sections): Add zlib-gnu and zlib-gabi. * output.h (Output_section::set_flags): New. * testsuite/Makefile.am (check_PROGRAMS): Add flagstest_compress_debug_sections_none, flagstest_compress_debug_sections_gnu and flagstest_compress_debug_sections_gabi. (check_DATA): Add flagstest_compress_debug_sections_none.stdout. flagstest_compress_debug_sections.stdout, flagstest_compress_debug_sections.cmp, flagstest_compress_debug_sections.check, flagstest_compress_debug_sections_gnu.stdout, flagstest_compress_debug_sections_gnu.cmp, flagstest_compress_debug_sections_gnu.check, flagstest_compress_debug_sections_gabi.stdout, flagstest_compress_debug_sections_gabi.cmp and flagstest_compress_debug_sections_gabi.check. (flagstest_compress_debug_sections_none): New. (flagstest_compress_debug_sections_none.stdout): Likewise. (flagstest_compress_debug_sections.stdout): Likewise. (flagstest_compress_debug_sections.check): Likewise. (flagstest_compress_debug_sections.cmp): Likewise. (flagstest_compress_debug_sections_gnu): Likewise. (flagstest_compress_debug_sections_gnu.stdout): Likewise. (flagstest_compress_debug_sections_gnu.check): Likewise. (flagstest_compress_debug_sections_gnu.cmp): Likewise. (flagstest_compress_debug_sections_gabi): Likewise. (flagstest_compress_debug_sections_gabi.stdout): Likewise. (flagstest_compress_debug_sections_gnu.check): Likewise. (flagstest_compress_debug_sections_gnu.cmp): Likewise. * testsuite/Makefile.in: Regenerated.
2015-07-12Add SHF_COMPRESSED section decompression to goldH.J. Lu3-0/+79
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-07-06Align text section ends so that stub tables appears at expected addresses.Doug Kwan11-4/+36
2015-06-11Fix broken gold/testsuite/script_test_12 in some setup.Jing Yu2-0/+8
This patch adds -O0 to gold script_test_12 test, hoping that compiler won't change the order of globel variables that the test assumes. Changelog: testsuite/Makefile.am: Add -O0 to compile script_test_12 test. testsuite/Makefile.in: Regenerate.
2015-06-03Fix gold to group sections correctly via linker script.Cary Coutant6-1/+256
In PR 15370, it is noted that gold does not distinguish between "*(.foo .bar)" and "*(.foo) *(.bar)" in linker scripts. In both cases, gold groups all .foo sections together, followed by all .bar sections, whereas in the first case, it should collect all .foo and .bar sections in the order seen. If you add sort specs, the Gnu linker has some bizarre corner cases that I do not try to replicate. In particular, "*(SORT_BY_NAME(.foo) SORT_BY_NAME(.bar))" does the same thing as "*(.foo) *(.bar)". But if you apply a sort spec to just one of several patterns, say, "*(SORT_BY_NAME(.foo) .bar)", the Gnu linker will collect any .bar section it sees before the first .foo, then all .foo sections, then all remaining .bar sections. With this patch, if any of the input patterns have a sort spec, gold will group them all as it did before; e.g., all .foo sections followed by all .bar sections. 2015-06-03 Cary Coutant <ccoutant@gmail.com> gold/ PR gold/15370 * script-sections.cc (Output_section_element_input::set_section_addresses): When there are several patterns with no sort spec, put all sections in the same bin. * testsuite/Makefile.am (script_test_12): New testcase. (script_test_12i): New testcase. * testsuite/Makefile.in: Regenerate. * testsuite/script_test_12.t: New test linker script. * testsuite/script_test_12i.t: New test linker script. * testsuite/script_test_12a.c: New test source file. * testsuite/script_test_12b.c: New test source file.
2015-06-02PR 17819: Fix --build-id=tree when using --compress-debug-sections.Cary Coutant2-1/+39
When --build-id=tree is selected, gold would schedule a set of tasks to run to compute md5 hashes in parallel on chunks of the file. The scheduling was done before the Write_after_input_sections_task ran, so if we are compressing debug sections, the output file will change size and be remapped to a new address, sometimes causing the build id computation to crash, but even when it doesn't crash, it wouldn't include the debug information in the hash computation. This patch delays the scheduling of the md5 tasks until after Write_after_input_sections_task. gold/ PR gold/17819 * gold.cc (queue_final_tasks): When --build-id=tree, queue a separate task to schedule the build id computation. * layout.cc (Hash_task::Hash_task): Remove build_id_blocker, add Output_file and offset. (Hash_task::run): Get and release the input views. (Hash_task::is_runnable): Always return NULL (always runnable). (Layout::queue_build_id_tasks): Remove. (Layout::write_build_id): Add array_of_hashes and size_of_hashes parameters; use them instead of class members. (Build_id_task_runner::run): New function. (Close_task_runner::run): Pass array_of_hashes and size_of_hashes to write_build_id. * layout.h (Layout::queue_build_id_tasks): Remove. (Layout::write_build_id): Add array_of_hashes and size_of_hashes parameters. (Layout::array_of_hashes_): Remove. (Layout::size_of_array_of_hashes_): Remove. (Layout::input_view_): Remove. (Build_id_task_runner): New class. (Close_task_runner::Close_task_runner): Add array_of_hashes and size_of_hashes parameters. (Close_task_runner::array_of_hashes_): New data member. (Close_task_runner::size_of_hashes_): New data member. * testsuite/Makefile.am (flagstest_compress_debug_sections_and_build_id_tree): New test. * testsuite/Makefile.in: Regenerate.
2015-04-27If a range is missing, assume the input address is mapped.Rafael Ávila de Espíndola4-5/+64
When Output_section::is_input_address_mapped is called we have entries for all dropped ranges, but not for all ranges.
2015-04-23Add option --weak-unresolved-symbols to treat unresolved symbols as weak ref.Sriraman Tallam2-3/+45
This patch adds option --weak-unresolved-symbols to treat unresolved symbols as weak references. This is helpful when we want the link to succeed with unresolved symbols and the dynamic loader to not complain at run-time. Option --warn-unresolved-symbols lets the link succeed but could fail at run-time with unresolved symbol warnings especially when the unresolved symbols have GOT entries and dynamic relocations against them, like when -fPIE is used.
2015-04-23Add option --weak-unresolved-symbols to treat unresolved as weak references.Sriraman Tallam1-0/+45
This patch adds option --weak-unresolved-symbols to treat unresolved symbols as weak references. This is helpful when we want the link to succeed with unresolved symbols and the dynamic loader to not complain at run-time. Option --warn-unresolved-symbols lets the link succeed but could fail at run-time with unresolved symbol warnings especially when the unresolved symbols have GOT entries and dynamic relocations against them, like when -fPIE is used. 2015-04-23 Sriraman Tallam <tmsriram@google.com> * options.h (--weak-unresolved-symbols): New option. * symtab.cc (Symbol_table::sized_write_globals): Change symbol binding to weak with new option. * symtab.h (is_weak_undefined): Check for new option. (is_strong_undefined): Check for new option. * testsuite/Makefile.am (weak_unresolved_symbols_test): New test. * testsuite/Makefile.in: Regenerate. * testsuite/weak_unresolved_symbols_test.cc: New file.
2015-04-09Allow gold to resolve defined TLS symbols in a PIE link.Cary Coutant3-145/+364
This patch fixes Symbol::final_value_is_known so that a defined TLS symbol in a PIE link is treated as having a known final value, thus allowing GD->LE TLS optimization, eliminating an unnecessary GOT entry and dynamic relocation. gold/ * symtab.cc (Symbol::final_value_is_known): Check for TLS symbol in a PIE link. * testsuite/Makefile.am (tls_pie_test.sh): New test. * testsuite/Makefile.in: Regenerate. * testsuite/tls_pie_test.sh: New.
2015-04-09Improve ODR checking in gold.Cary Coutant1-6/+6
gold/ * debug.h (DEBUG_LOCATION): New. (DEBUG_ALL): Include DEBUG_LOCATION. (debug_string_to_enum): Add DEBUG_LOCATION. * dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Fix debug output to print correct context. (Sized_dwarf_line_info::do_addr2line): Add debug output. Return up to 4 more locations at the beginning of the function. * symtab.cc (Symbol_table::detect_odr_violations): Get canonical result before sorting list of line numbers. * testsuite/debug_msg.sh: Allow range of line numbers for canonical results on optimized code.
2015-04-06[Gold,x86_64] Convert mov foo@GOTPCREL(%rip), %reg to lea foo(%rip), %regIlya Tocar6-0/+172
2015-04-06 Ilya Tocar <ilya.tocar@intel.com> PR gold/17641 * x86_64.cc (Target_x86_64::can_convert_mov_to_lea): New. (Target_x86_64::Scan::local): Don't create GOT entry, when we can convert mov to lea. (Target_x86_64::Scan::global): Ditto. (Target_x86_64::Relocate::relocate): Convert mov foo@GOTPCREL(%rip), %reg to lea foo(%rip), %reg if possible. * testsuite/Makefile.am (x86_64_mov_to_lea): New test. * testsuite/x86_64_mov_to_lea1.s: New. * testsuite/x86_64_mov_to_lea2.s: Ditto. * testsuite/x86_64_mov_to_lea3.s: Ditto. * testsuite/x86_64_mov_to_lea4.s: Ditto. * testsuite/x86_64_mov_to_lea.sh: Ditto. ---
2015-04-01Convert mov foo@GOT(%reg), %reg to lea foo@GOTOFF(%reg), %regIlya Tocar7-0/+141
2015-04-01 Ilya Tocar <ilya.tocar@intel.com> PR gold/17640 * i386.cc (Target_i386::can_convert_mov_to_lea): New. (Target_i386::Scan::local): Don't create GOT entry, when we can convert GOT to GOTOFF. (Target_i386::Scan::global): Ditto. (Target_i386::Relocate::relocate): Convert mov foo@GOT(%reg), %reg to lea foo@GOTOFF(%reg), %reg if possible. * testsuite/Makefile.am (i386_mov_to_lea): New test. * testsuite/i386_mov_to_lea1.s: New. * testsuite/i386_mov_to_lea2.s: Ditto. * testsuite/i386_mov_to_lea3.s: Ditto. * testsuite/i386_mov_to_lea4.s: Ditto. * testsuite/i386_mov_to_lea5.s: Ditto. * testsuite/i386_mov_to_lea.sh: Ditto.
2015-04-01Regenerate configure in goldH.J. Lu2-283/+336
Regenerate configure for zlib.m4 change, which adds --with-system-zlib and removes --with-zlib in gold. zlib is enabled unconditionally with builtin zlib imported from GCC. * Makefile.am (ZLIB): New. (ZLIBINC): Likewise. (AM_CFLAGS): Add $(ZLIBINC). (AM_CXXFLAGS): Likewise. (ldadd_varldadd_var): Add $(ZLIB). (incremental_dump_LDADD): Likewise. (dwp_LDADD): Likewise. * compressed_output.cc: Don't check HAVE_ZLIB_H to include <zlib.h>. (zlib_compress): Don't check HAVE_ZLIB_H. (zlib_decompress): Likewise. * options.h (compress_debug_sections): Likewise. * configure.ac (AM_CONDITIONAL): Removed. * testsuite/Makefile.am (ZLIB): New. (LDADD): Add $(ZLIB). Don't check HAVE_ZLIB. * Makefile.in: Regenerated. * config.in: Likewise. * configure: Likewise. * testsuite/Makefile.in: Likewise.
2015-03-21PR gold/18048: Fix INCLUDE directive support for goldCary Coutant6-2/+60
This patch fixes INCLUDE directives in script files, so that when an INCLUDE appears inside a sections block, section commands block, or memory def block, the contents are parsed in the appropriate context. gold/ PR gold/18048 * script-c.h (script_include_directive): Add first_token parameter. * script.cc (script_include_directive): Add first_token parameter, and pass it to read_script_file. * yyscript.y (PARSING_SECTIONS_BLOCK, PARSING_SECTION_CMDS) (PARSING_MEMORY_DEF): New tokens. (top): Add new productions for INCLUDE files. (file_cmd): Replace file_or_sections_cmd with copy of its productions. Pass PARSING_LINKER_SCRIPT to script_include_directive. (section_block_cmd): Likewise; pass PARSING_SECTIONS_BLOCK. (section_cmd): Pass PARSING_SECTION_CMDS. (file_or_sections_cmd): Remove. (memory_def): Pass PARSING_MEMORY_DEF. * testsuite/Makefile.am (memory_test_2): New test. * testsuite/Makefile.in: Regenerate. * testsuite/memory_test_inc.t: New script file. * testsuite/memory_test_inc_1.t.src: New script file. * testsuite/memory_test_inc_2.t.src: New script file. * testsuite/memory_test_inc_3.t.src: New script file.
2015-03-11Fix gold incremental test failures.Cary Coutant2-36/+36
Newer version of GCC pass -z relro to the linker, but incremental linking does not support relro. This patch adds a check to complain about the conflict, and changes the testsuite to pass -z norelro to the incremental tests. 2015-03-11 Cary Coutant <ccoutant@google.com> gold/ * options.cc (General_options::finalize): Don't allow -z relro with incremental linking. * testsuite/Makefile.am (incremental_test): Add -z norelro. (incremental_test_2): Likewise. (incremental_test_3): Likewise. (incremental_test_4): Likewise. (incremental_test_5): Likewise. (incremental_test_6): Likewise. (incremental_copy_test): Likewise. (incremental_common_test_1): Likewise. (incremental_comdat_test_1): Likewise. * testsuite/Makefile.in: Regenerate.
2015-02-16Fix --dynamic-list so that symbols not in the list are still exported.Cary Coutant2-2/+2
In PR 13577, the complaint was that -Bsymbolic was overriding the binding behavior for symbols listed in the --dynamic-list by setting the DT_SYMBOLIC tag in the dynamic table. In reading the Gnu ld manual, I decided that --dynamic-list should be mutually exclusive of -Bsymbolic, and modified gold so that --dynamic-list would treat symbols listed as preemptible, and all other symbols as internally bound. I was wrong. PR 16992 shows that with --dynamic-list (and not -Bsymbolic), a symbol not listed in the dynamic list is being internally bound within the shared library, but because it's still in the dynamic symbol table, we expose it to a COPY relocation, and things go really bad from there. (I can reproduce the same failure, simply by turning on -Bsymbolic-functions with the Gnu linker. Even though the symbol is bound internally, it's still exported to the dynamic symbol table, and is exposed to a COPY relocation.) I've backed out part of the fix for PR 13577, and -Bsymbolic (or -Bsymbolic-functions) can now be used with --dynamic-list, but if the two are used together, we do not set DT_SYMBOLIC or DF_SYMBOLIC (this matches Gnu ld behavior). We now treat symbols listed in the dynamic list as premptible, but we do not automatically treat symbols not listed there as non-premptible. gold/ PR gold/13577 PR gold/16992 * layout.cc (Layout::finish_dynamic_section): Don't set DT_SYMBOLIC or DF_SYMBOLIC if --dynamic-list option is used. * options.cc (General_options::finalize): --dynamic-list is not mutually exclusive with -Bsymbolic. * symtab.h (Symbol::is_preemptible): Don't exclude dynamic symbols not listed in --dynamic-list. * testsuite/Makefile.am (dynamic_list_lib2.so): Add -Bsymbolic-functions. * testsuite/Makefile.in: Regenerate.
2015-02-09Replace two_file_shared_2.so with two_file_shared_1.soH.J. Lu2-2/+2
There are two_file_shared_2_pic_1_test_LDADD = two_file_test_2_pic.o two_file_shared_1.so There should be two_file_shared_1.so, not two_file_shared_2.so in two_file_shared_2_pic_1_test_DEPENDENCIES. * testsuite/Makefile.am (two_file_shared_2_pic_1_test_DEPENDENCIES): Replace two_file_shared_2.so with two_file_shared_1.so. * testsuite/Makefile.in: Regenerated.
2015-02-09Gold testsuite make cleanAlan Modra2-5/+8
* testsuite/Makefile.am (MOSTLYCLEANFILES): Add libweak_undef_2.a, plugin_test_thin.a and defsym_test. * testsuite/Makefile.in: Regenerate.
2015-02-03Fix a file descriptor leak in gold.Cary Coutant9-133/+280
When an LTO linker plugin claims an external member of a thin archive, gold does not properly unlock the file and make its file descriptor available for reuse. This patch fixes the problem by modifying Archive::include_member to unlock the object file via an RAII class instance, ensuring that it will be unlocked no matter what path is taken through the function. gold/ PR gold/15660 * archive.cc (Thin_archive_object_unlocker): New class. (Archive::include_member): Unlock external members of thin archives. * testsuite/Makefile.am (plugin_test_1): Rename .syms files. (plugin_test_2): Likewise. (plugin_test_3): Likewise. (plugin_test_4): Likewise. (plugin_test_5): Likewise. (plugin_test_6): Likewise. (plugin_test_7): Likewise. (plugin_test_8): Likewise. (plugin_test_9): Likewise. (plugin_test_10): Likewise. (plugin_test_11): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c (claim_file_hook): Check for parallel .syms file to decide whether to claim file. (all_symbols_read_hook): Likewise. * testsuite/plugin_test_1.sh: Adjust expected output. * testsuite/plugin_test_2.sh: Likewise. * testsuite/plugin_test_3.sh: Likewise. * testsuite/plugin_test_6.sh: Likewise. * testsuite/plugin_test_tls.sh: Likewise. * testsuite/plugin_test_11.sh: New testcase.
2015-01-06Handle stack split for x32H.J. Lu8-9/+261
X32 uses cmp %fs:NN,%esp, lea NN(%rsp),%r10d, lea NN(%rsp),%r11d, instead of cmp %fs:NN,%rsp, lea NN(%rsp),%r10, lea NN(%rsp),%r11. This patch handles it. PR gold/17729 * configure.ac (DEFAULT_TARGET_X86_64): Don't set for x32. (DEFAULT_TARGET_X32): Set for x32. * x86_64.cc (cmp_insn_32): New. (lea_r10_insn_32): Likewise. (lea_r11_insn_32): Likewise. (cmp_insn_64): Likewise. (lea_r10_insn_64): Likewise. (lea_r11_insn_64): Likewise. (Target_x86_64<size>::do_calls_non_split): Handle x32. * testsuite/Makefile.am (check_SCRIPTS): Add split_x32.sh. (check_DATA): Add split_x32 files. (split_x32_[1234n].o): New targets. (split_x32_[124]): New targets. (split_x32_[1234r].stdout): New targets. * testsuite/split_x32.sh: New file. * testsuite/split_x32_1.s: Likewise. * testsuite/split_x32_2.s: Likewise. * testsuite/split_x32_3.s: Likewise. * testsuite/split_x32_4.s: Likewise. * testsuite/split_x32_n.s: Likewise. * configure: Regenerated. * testsuite/Makefile.in: Likewise.
2015-01-02ChangeLog rotatation and copyright year updateAlan Modra266-266/+266
2014-12-20Change SometimesInlineFunction to "return i * i * 3;"H.J. Lu1-1/+1
The debug_msg test has 2 implementations of SometimesInlineFunction: int SometimesInlineFunction(int i) { return i; } int SometimesInlineFunction(int i) { return i * i; } and One Definition Rule (ODR) violation detection expects they will be compiled into functions of different sizes. Hower, on x86, GCC 4.7 and newer compile them into functions of the same size and ODR violation detection test fails. This patch changes int SometimesInlineFunction(int i) { return i; } to int SometimesInlineFunction(int i) { return i * i * 3; } so that it will be compiled into a function of larger size. PR gold/14608 * testsuite/debug_msg.cc (SometimesInlineFunction): Changed to "return i * i * 3;".
2014-12-03Compile pie_copyrelocs_test.cc with -fno-exceptions ↵H.J. Lu2-5/+20
-fno-asynchronous-unwind-tables PR gold/17675 * testsuite/Makefile.am (pie_copyrelocs_test_CXXFLAGS): New. * testsuite/Makefile.in: Regenerated.
2014-10-29Misc about gold for aarch64 backend.Han Shen2-5/+5
The patch does the following things: -- Add support for ifunc. -- Enable safe icf -- Add support for TLSLD relocations R_AARCH64_TLSLD_ADR_PAGE21, R_AARCH64_TLSLD_ADD_LO12_NC, R_AARCH64_TLSLD_MOVW_DTPREL_G1, R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC. (R_AARCH64_TLSLD_MOVW_* are used by LLVM.) -- Add support for TLSLD->TLSLE relaxation. -- Add support for R_AARCH64_LD_PREL_LO19, R_AARCH64_ADR_PREL_LO21. -- Fix 2 encoding bugs in AArch64_relocate_functions::update_movnz. -- Correct TLS relocation properties in gold/aarch64-reloc.def. -- Update testsuite/icf_safe_so_test.cc, testsuite/icf_safe_test.sh. gold/ 2014-10-29 Han Shen <shenhan@google.com> Jing Yu <jingyu@google.com> * aarch64-reloc.def: Add LD_PREL_LO12, ADR_PREL_LO21, TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC, TLSLD_MOVW_DTPREL_G1, TLSLD_MOVW_DTPREL_G0_NC. Change property of TLS relocations to Symbol::TLS_REF. * aarch64.cc (Target_aarch64::do_can_check_for_function_pointers): New method. (Target_aarch64::reloc_needs_plt_for_ifunc): New method. (Target_aarch64::tls_ld_to_le): New method. (Target_aarch64::aarch64_info): Enable can_icf_inline_merge_sections for 64bit targets. (Output_data_plt_aarch64::irelative_rel_): New data member. (Output_data_plt_aarch64::add_entry): Add irelative entries to plt. (Output_data_plt_aarch64::add_local_ifunc_entry): New method. (Output_data_plt_aarch64::add_relocation): New method. (Output_data_plt_aarch64::do_write): Add gold_assert on got_irelative offset. Add got_irelative size to got size. (AArch64_relocate_functions): Typedef AArch64_valtype. Replace long type string with the new typename. (AArch64_relocate_functions::update_adr): Replace parameter x with immed. (AArch64_relocate_functions::update_movnz): Correct wrong val mask. (AArch64_relocate_functions::reloc_common): New method. (AArch64_relocate_funcsions::rela_general): Extract common part out into reloc_common method. (AArch64_relocate_functions::rela_general): Likewise. (AArch64_relocate_functions::pcrela_general): Likewise. (AArch64_relocate_functions::adr): New method. (AArch64_relocate_functions::adrp): Calculate immed before calling update_adr. (AArch64_relocate_functions::adrp): Likewise. (AArch64_relocate_functions::movnz): Cast x to SignedW type when comparing x to 0. Calculate immed from ~x when x < 0. (Target_aarch64::optimize_tls_reloc): Add new cases for TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC, TLSLD_MOVW_DTPREL_G1, TLSLD_MOVW_DTPREL_G0_NC. (Target_aarch64::possible_function_pointer_reloc): Implement this method. (Target_aarch64::Scan::local_reloc_may_be_function_pointer): Update comment. (Target_aarch64::Scan::local): Add codes to handle STT_GNU_IFUNC symbol. Add cases for TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC, TLSLD_MOVW_DTPREL_G1, TLSLD_MOVW_DTPREL_G0_NC. (Target_aarch64::Scan::global): Add codes to handle STT_GNU_IFUNC symbol. Add cases for TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC, TLSLD_MOVW_DTPREL_G1, TLSLD_MOVW_DTPREL_G0_NC. (Target_aarch64::make_plt_entry): Call add_entry with two more parameters. (Target_aarch64::make_local_ifunc_plt_entry): New method. (Target_aarch64::Relocate::relocate): Add cases for LD_PREL_LO19, ADR_PREL_LO21, TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC, TLSLD_MOVW_DTPREL_G1, TLSLD_MOVW_DTPREL_G0_NC. (Target_aarch64::Relocate::relocate_tls): Add cases for TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC, TLSLD_MOVW_DTPREL_G1, TLSLD_MOVW_DTPREL_G0_NC. * testsuite/icf_safe_so_test.cc: Correct test comment. * testsuite/icf_safe_test.sh: Add AArch64 arch.
2014-09-23Fix race condition causing assert in Eh_frame_hdr::do_sized_write().Cary Coutant2-7/+4
2014-09-23 Taiju Tsuiki <tzik@google.com> Cary Coutant <ccoutant@google.com> gold/ * gold.cc (queue_final_tasks): Add Write_sections_task as a blocker on input_sections_blocker. * layout.cc (Write_sections_task::locks): Unblock input_sections_blocker_. * layout.h (Write_sections_task::Write_sections_task): Add input_sections_blocker. * testsuite/Makefile.am (exception_x86_64_bnd_test): Add gcctestdir/ld to DEPENDENCIES. * testsuite/Makefile.in: Regenerate.
2014-09-18A a testcase for common symbol handling with plugins.Rafael Ávila de Espíndola4-14/+87
2014-09-18 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> * testsuite/Makefile.am (plugin_test_10): New test. * testsuite/Makefile.in: Regenerate * testsuite/plugin_common_test_2.c (c1): Align to 8. * testsuite/plugin_test_10.sh: New file.
2014-08-06Modify new gold test to pass on powerpc64leAlan Modra1-1/+1
* testsuite/defsym_test.sh: Allow ppc64le localentry annotation.
2014-07-08Fix --defsym to copy symbol attributes.Cary Coutant4-3/+82
Alan Modra committed a patch to Gnu ld to fix a problem encountered on PPC where the --defsym option wasn't copying the st_other bits to the newly-defined symbol. https://sourceware.org/ml/binutils/2014-07/msg00094.html Gold has the same problem, and additionally wasn't copying the symbol type. This patch fixes both problems, by copying the symbol type, visibility, and the remaining st_other bits to the new symbol for --defsym=sym1=sym2 assignments. gold/ * expression.cc (struct Expression::Expression_eval_info): Add new fields type_pointer, vis_pointer, and nonvis_pointer. (Expression::eval_maybe_dot): Add type_pointer, vis_pointer, and nonvis_pointer parameters. Adjust all calls. (Symbol_expression::value): Update type, visibility, and nonvis bits in caller. * script.cc (Symbol_assignment::sized_finalize): Update type, visibility, and remaining st_other bits for new symbol. * script.h: (Expression::eval_maybe_dot): Add type_pointer, vis_pointer, and nonvis_pointer parameters. * symtab.h (Symbol::set_type): New method. * testsuite/Makefile.am (defsym_test): New test. * testsuite/Makefile.in: Regenerate. * testsuite/defsym_test.c: New file. * testsuite/defsym_test.sh: New file.
2014-06-03Fix gold plugin_test failures on PowerPC64 ELFv2Alan Modra1-0/+7
readelf output for ELFv2 includes st_other bits specifying a function's local entry offset. * testsuite/plugin_test.c (parse_readelf_line): Skip non-visibility st_other output.
2014-05-30Fix testsuite to use newly-built linker for ehdr_start_test_4, and fixCary Coutant3-3/+3
check script to look for the right binding. gold/ * testsuite/Makefile.am (ehdr_start_test_4): Fix typo in -B option. * testsuite/Makefile.in: Regenerate. * testsuite/ehdr_start_test_4.sh: Look for "U" instead of "w".
2014-05-13With -pie and x86, the linker complains if it sees a PC-relative relocationSriraman Tallam2-10/+42
to access a global as it expects a GOTPCREL relocation. This is really not necessary as the linker could use a copy relocation to get around it. This patch enables copy relocations with pie. Context: This is useful because currently the GCC compiler with option -fpie makes every extern global access go through the GOT. That is because the compiler cannot tell if a global will end up being defined in the executable or not and is conservative. This ends up hurting performance when the binary is linked as mostly static where most of the globals do end up being defined in the executable. By allowing copy relocs with fPIE, the compiler need not generate a GOTPCREL(GOT access) for any global access. It can safely assume that all globals will be defined in the executable and generate a PC-relative access instead. Gold can then create a copy reloc for only the undefined globals. gold/ * symtab.h (may_need_copy_reloc): Remove check for position independent code. * x86_64.cc (Target_x86_64<size>::Scan::global): Add check for no position independence before pc absolute may_need_copy_reloc call. Add check for executable output befor pc relative may_need_copy_reloc call. * i386.cc: Ditto. * arm.cc: Ditto. * sparc.cc: Ditto. * tilegx.cc: Ditto. * powerpc.cc: Add check for no position independence before may_need_copy_reloc calls. * testsuite/pie_copyrelocs_test.cc: New file. * testsuite/pie_copyrelocs_shared_test.cc: New file. * Makefile.am (pie_copyrelocs_test): New test. * Makefile.in: Regenerate.
2014-05-13Optimizing accesses to Globals with -fpie -pie:Sriraman Tallam2-0/+57
With -pie and x86, the linker complains if it sees a PC-relative relocation to access a global as it expects a GOTPCREL relocation. This is really not necessary as the linker could use a copy relocation to get around it. This patch enables copy relocations with pie. Context: This is useful because currently the GCC compiler with option -fpie makes every extern global access go through the GOT. That is because the compiler cannot tell if a global will end up being defined in the executable or not and is conservative. This ends up hurting performance when the binary is linked as mostly static where most of the globals do end up being defined in the executable. By allowing copy relocs with fPIE, the compiler need not generate a GOTPCREL(GOT access) for any global access. It can safely assume that all globals will be defined in the executable and generate a PC-relative access instead. Gold can then create a copy reloc for only the undefined globals.
2014-05-02Fix handling of __ehdr_start when it cannot be defined.Cary Coutant6-26/+418
2014-05-02 Cary Coutant <ccoutant@google.com> * defstd.cc (in_segment): Define __ehdr_start here... * layout.cc (Layout::finalize): ...Instead of here. Set the output segment when known. * resolve.cc (Symbol::override_base_with_special): Remember the original binding. * symtab.cc (Symbol::set_output_segment): New function. (Symbol::set_undefined): New function. * symtab.h (Symbol::is_weak_undefined): Check original undef binding. (Symbol::is_strong_undefined): New function. (Symbol::set_output_segment): New function. (Symbol::set_undefined): New function. * target-reloc.h (is_strong_undefined): Remove. (issue_undefined_symbol_error): Call Symbol::is_weak_undefined. Check for hidden undefs. (relocate_section): Call Symbol::is_strong_undefined. * testsuite/Makefile.am (ehdr_start_test_1) (ehdr_start_test_2, ehdr_start_test_3) (ehdr_start_test_4, ehdr_start_test_5): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/ehdr_start_def.cc: New source file. * testsuite/ehdr_start_test.cc: New source file. * testsuite/ehdr_start_test.t: New linker script. * testsuite/ehdr_start_test_4.sh: New shell script.
2014-04-02Modify gold testsuite to disable plugins added by GCC driver.Cary Coutant2-8/+21
GCC 4.8 now adds linker plugin options by default, which conflict with the --incremental tests in the testsuite. This patch checks whether the compiler supports the -fno-use-linker-plugin option, and adds it to all link commands. 2014-04-02 Cary Coutant <ccoutant@google.com> * configure.ac (HAVE_PUBNAMES): Use C instead of C++. (HAVE_NO_USE_LINKER_PLUGIN): Check for -fno-use-linker-plugin. * configure: Regenerate. * testsuite/Makefile.am (OPT_NO_PLUGINS): New macro for -fno-use-linker-plugin. (LINK1, CXXLINK1): Add it to the link command. * testsuite/Makefile.in: Regenerate.
2014-03-05Update copyright yearsAlan Modra258-259/+258
2014-02-06Fix problem where -u is ignored when a weak undef is seen.Cary Coutant5-3/+176
When the linker has a weak undefined symbol, it normally does not select an archive library member just to satisfy the reference. If the same symbol is also listed in a -u option, however, we should select the archive library member. This patch reorders the code in Library_base::should_include_member so that the additional checks are performed in the case of a weak undef. gold/ 2014-02-06 Cary Coutant <ccoutant@google.com> * archive.cc (Library_base::should_include_member): Reorder code to check for -u option if a weak undef has already been seen. * testsuite/Makefile.am (weak_undef_test_2): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/weak_undef_file3.cc: New file. * testsuite/weak_undef_file4.cc: New file. * testsuite/weak_undef_test_2.cc: New file.
2014-02-05Fix problems with the --dynamic-list option.Cary Coutant9-3/+321
PR gold/13577 complains that even though symbols listed in the --dynamic-list script are exported, they are still bound symbolically if -Bsymbolic is also used. There are two underlying problems here. First, -Bsymbolic should be overridden by --dynamic-list, since the dynamic list provides an explicit list of symbols that are not bound within the library, and if we go ahead and set DT_SYMBOLIC, then the dynamic loader will bind it within the library anyway. Second, gold did not properly identify the symbols listed in the file as preemptible. PR gold/16530 complains that symbols listed in the --dynamic-list script can still be garbage collected. I've fixed this by checking the symbols as they're added to the symbol table. (Unlike the --export-dynamic-symbol option, we can't iterate over the list, because the --dynamic-list script can have wildcards in it.) gold/ 2014-02-05 Cary Coutant <ccoutant@google.com> PR gold/13577 * options.cc (General_options::parse_dynamic_list): Set have_dynamic_list_. (General_options::General_options): Initialize have_dynamic_list_. (General_options::finalize): Turn off -Bsymbolic and -Bsymbolic-functions if --dynamic-list provided. * options.h (General_options::have_dynamic_list): New function. (General_options::have_dynamic_list_): New data member. * symtab.h (Symbol::is_preemptible): Handle --dynamic-list correctly. PR gold/16530 * symtab.cc (Symbol_table::add_from_relobj): If symbol is named in --dynamic-list, mark it. * testsuite/Makefile.am (gc_dynamic_list_test.sh): New test case. (dynamic_list_2): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/dynamic_list_2.cc: New file. * testsuite/dynamic_list_2.t: New file. * testsuite/dynamic_list_lib1.cc: New file. * testsuite/dynamic_list_lib2.cc: New file. * testsuite/gc_dynamic_list_test.c: New file. * testsuite/gc_dynamic_list_test.sh: New file. * testsuite/gc_dynamic_list_test.t: New file.
2014-01-28Add .gdb_index version 7 support.Cary Coutant2-2/+2
This patch adds support for .gdb_index version 7, which adds several flag bits to the symbol index. It also fixes a problem where it did not handle compressed debug sections correctly. Tested with a google/gcc-4_8 branch compiler, which supports the -ggnu-pubnames option to generate .debug_gnu_pubnames/pubtypes tables. (We will submit that patch to GCC when stage 1 reopens.) 2014-01-28 Cary Coutant <ccoutant@google.com> * gold/dwarf_reader.cc: include <utility> (for make_pair). (Dwarf_abbrev_table::do_read_abbrevs): Check for compressed debug sections. (Dwarf_ranges_table::read_ranges_table): Likewise. (Dwarf_pubnames_table::read_section): Check for GNU-style sections, and for compressed debug sections. (Dwarf_pubnames_table::read_header): Compute end address of table. (Dwarf_pubnames_table::next_name): Return flag_byte. Check for end of list by offset, not by offset == 0. (Dwarf_info_reader::do_read_string_table): Check for compressed debug sections. * gold/dwarf_reader.h (Dwarf_pubnames_table::Dwarf_pubnames_table): Initialize new data members. (Dwarf_pubnames_table::next_name): return flag_byte. (Dwarf_pubnames_table::end_of_table_): New data member. (Dwarf_pubnames_table::is_gnu_style_): New data member. * gold/gdb-index.cc (gdb_index_version): Update to version 7. (Gdb_index_info_reader::read_pubtable): Read flag_byte. (Gdb_index_info_reader::read_pubnames_and_pubtypes): Don't read skeleton type unit DIEs. (Gdb_index::add_symbol): Add flag_byte; adjust all callers. (Gdb_index::do_write): Write flag_byte. * gold/gdb-index.h (Gdb_index::add_symbol): Add flags parameter. (Gdb_index::Cu_vector): Store flags along with cu indexes. * gold/testsuite/gdb_index_test_3.sh: Allow versions 4-7. * gold/testsuite/gdb_index_test_comm.sh: Likewise.
2013-11-22Use in-tree assembler for exception_x86_64_bnd_test.Cary Coutant2-4/+4
gold/ * testsuite/Makefile.am (exception_x86_64_bnd_test): Use in-tree assembler. * testsuite/Makefile.in: Regenerate.
2013-11-18Add R_X86_64_PC32_BND/R_X86_64_PLT32_BND suppor to goldH.J. Lu2-2/+38
elfcpp/ * x86_64.h (R_X86_64_PC32_BND): New. (R_X86_64_PLT32_BND): Likewise. gold/ * x86_64.cc (Target_x86_64<size>::Scan::get_reference_flags): Handle R_X86_64_PC32_BND and R_X86_64_PLT32_BND just like R_X86_64_PC32 and R_X86_64_PLT32, respectively. (Target_x86_64<size>::Scan::local): Likewise. (Target_x86_64<size>::Scan::global): Likewise. (Target_x86_64<size>::Relocate::relocate): Likewise. (Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc): Likewise. (Target_x86_64<size>::Scan::check_non_pic(): Handle R_X86_64_PC32_BND. * testsuite/Makefile.am (check_PROGRAMS): Add exception_x86_64_bnd_test. (exception_x86_64_bnd_test_SOURCES): New macro. (exception_x86_64_bnd_test_DEPENDENCIES): Likewise. (exception_x86_64_bnd_test_LDFLAGS): Likewise. (exception_x86_64_bnd_test_LDADD): Likewise. (exception_x86_64_bnd_1.o): New rule. (exception_x86_64_bnd_2.o): Likewise. * testsuite/Makefile.in: Regenerated.
2013-10-11Revert inappropriate portions of last change.Roland McGrath2-34/+34
2013-10-11gold/Roland McGrath2-62/+62
* testsuite/Makefile.am: Replace '-T foo' with '-Wl,-T,foo' throughout. * testsuite/Makefile.in: Regenerate.
2013-10-11gold/Roland McGrath1-1/+3
* testsuite/undef_symbol.cc (Foo::get_a): New method.
2013-10-11gold/Roland McGrath4-29/+30
* configure.ac (MERGE_CONSTANTS_FLAG): New check. * configure: Regenerate. * Makefile.in: Regenerate. * testsuite/merge_string_literals_1.c: Renamed to have .cc suffix. * testsuite/merge_string_literals_2.c: Likewise. * testsuite/Makefile.am (merge_string_literals_1.o, merge_string_literals_2.o): Update deps. (AM_CFLAGS, AM_CXXFLAGS): Use $(MERGE_CONSTANTS_FLAG) in place of literal -fmerge-constants. * testsuite/Makefile.in: Regenerate.
2013-10-07gold/Cary Coutant2-17/+22
PR gold/16010 * testsuite/Makefile.am (icf_test): Fix dependencies. (icf_safe_test): Likewise. (icf_safe_so_test): Likewise. (large_symbol_alignment): Add empty _LDADD rule. * testsuite/Makefile.in: Regenerate.
2013-07-30 gold/Cary Coutant1-1/+2
* parameters.cc (Parameters::entry): Return target-specific entry symbol name. * target.h (Target::entry_symbol_name): New function. (Target_info::entry_symbol_name): New data member. * arm.cc (Target_arm::arm_info): Add entry_symbol_name. (Target_arm_nacl::arm_nacl_info): Likewise. * i386.cc (Target_i386::i386_info): Likewise. (Target_i386_nacl::i386_nacl_info): Likewise. * powerpc.cc (Target_powerpc::powerpc_info): Likewise. * sparc.cc (Target_sparc::sparc_info): Likewise. * tilegx.cc (Target_tilegx::tilegx_info): Likewise. * x86_64.cc: (Target_x86_64::x86_64_info) Likewise. (Target_x86_64_nacl::x86_64_nacl_info) Likewise. * testsuite/testfile.cc (Target_test::test_target_info): Likewise.