aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite/Makefile.am
AgeCommit message (Collapse)AuthorFilesLines
2022-08-04Add gold support for --package-metadata option.Luca Boccassi1-4/+11
Following the same format as the implementation in ld: 9e2bb0cb5e74aed4158f08495534922d7108f928 Generate a .note.package FDO package metadata ELF note, following the spec: https://systemd.io/ELF_PACKAGE_METADATA/ If the jansson library is available at build time (and it is explicitly enabled), link ld to it, and use it to validate that the input is correct JSON, to avoid writing garbage to the file. The configure option --enable-jansson has to be used to explicitly enable it (error out when not found). This allows bootstrappers (or others who are not interested) to seamlessly skip it without issues. elfcpp/ * elfcpp.h: Add FDO_PACKAGING_METADATA note type. gold/ * Makefile.am: Add jansson flags and libraries. * configure.ac: Check for jansson library. * layout.cc (Layout::create_notes): Call create_package_metadata(). (Layout::create_package_metadata): New function. * layout.h (Layout::create_package_metadata): New function. (Layout::package_metadata_note_): New data member. * options.h (class General_options): Add --package-metadata option. * testsuite/Makefile.am (object_unittest): Add jansson libraries. (binary_unittest): Likewise. (leb128_unittest): Likewise. (overflow_unittest): Likewise. (package_metadata_test): New test. * testsuite/package_metadata_main.c: New test source.
2020-12-14Keep input SHF_GNU_RETAIN sections and strip output SHF_GNU_RETAIN for ↵Cary Coutant1-0/+16
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-13Re-enable incremental tests that were failing with GCC 9+.Cary Coutant1-4/+0
gold/ PR gold/23539 PR gold/24123 * testsuite/Makefile.am (incremental_copy_test): Re-enable for GCC 9+. (incremental_comdat_test_1): Likewise. * testsuite/Makefile.in: Regenerate.
2020-12-03[GOLD] PR26936 testAlan Modra1-4/+4
Fails if you configure with --disable-x86-used-note. Fix that. * testsuite/Makefile.am (pr26936a.o): Pass -mx86-used-note=yes. (pr26936b.o, pr26936c.o, pr26936d.o): Likewise. * testsuite/Makefile.in: Regenerate.
2020-11-29gold: Convert x86-64 GOTPCRELX only if addend == -4H.J. Lu1-2/+17
Convert x86-64 GOTPCRELX relocations only if addend == -4. PR gold/26939 * x86_64.cc (Target_x86_64<size>::Scan::local): Check get_r_addend() == -4 for GOTPCRELX conversion. (Target_x86_64<size>::Scan::global): Likewise. (Target_x86_64<size>::Relocate::relocate): Likewise. * testsuite/Makefile.am (check_DATA): Add x86_64_mov_to_lea15.stdout and x86_64_mov_to_lea16.stdout. (MOSTLYCLEANFILES): Add x86_64_mov_to_lea15 and x86_64_mov_to_lea16. (x86_64_mov_to_lea9.o): New target. (x86_64_mov_to_lea10.o): Likewise. (x86_64_mov_to_lea15): Likewise. (x86_64_mov_to_lea16): Likewise. (x86_64_mov_to_lea15.stdout): Likewise. (x86_64_mov_to_lea16.stdout): Likewise. * testsuite/Makefile.in: Regenerated. * testsuite/x86_64_mov_to_lea.sh: Updated. * testsuite/x86_64_mov_to_lea5.s: New file.
2020-11-29gold: Get linkonce/comdate sections for debugging sectionsH.J. Lu1-0/+22
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-11-03gold: ensure file_counts_lock is initialized before usingNick Gasson1-0/+6
Since upgrading to binutils 2.35 I've been experiencing random memory corruption related crashes with ld.gold --threads. It's caused by multiple threads concurrently pushing elements onto the shared std::vector in File_read::record_file_read(). This vector is supposed to be protected by file_counts_lock, but that is initialized lazily and might be NULL when File_read::open() is called, in which case Hold_optional_lock silently skips locking it. Fix by calling the initialize() method before attempting to acquire the lock, the same as other places that use file_counts_lock. PR 26827 * fileread.cc (File_read::open): Ensure file_counts_lock is initialized. * testsuite/Makefile.am (check_PROGRAMS): Add a test that passes -Wl,--threads. * testsuite/Makefile.in: Regenerate.
2020-10-13gold: Skip some incremental testsH.J. Lu1-0/+18
Skip incremental_test_2, incremental_test_3, incremental_test_4, incremental_test_5, incremental_copy_test, incremental_common_test_1 and incremental_comdat_test_1 when -fcf-protection is used to compile gold since gold doesn't properly support -fcf-protection on Intel CET enabled OS. Also skip incremental_copy_test and incremental_comdat_test_1 for GCC 9 or later since they failed with GCC 9 or later. PR gold/23539 * configure.ac: Check for GCC 9 or later and for -fcf-protection. * configure: Regenerated. * testsuite/Makefile.am (check_PROGRAMS): Skip incremental_test_2, incremental_test_3, incremental_test_4, incremental_test_5, incremental_copy_test, incremental_common_test_1 and incremental_comdat_test_1 for -fcf-protection. Also Skip incremental_copy_test and incremental_comdat_test_1 for GCC 9 or later. * testsuite/Makefile.in: Regenerated.
2020-10-13gold: Discard .note.gnu.property sectionH.J. Lu1-1/+1
Discard .note.gnu.property section since it changes the expected section order. PR gold/23503 * testsuite/Makefile.am (justsyms_lib): Pass -T $(srcdir)/justsyms_lib.t to gold. * testsuite/Makefile.in: Regenerated. * testsuite/justsyms_lib.t: New file. * testsuite/script_test_10.t: Discard .note.gnu.property section.
2020-10-13gold: Properly align the NT_GNU_PROPERTY_TYPE_0 noteH.J. Lu1-2/+2
The NT_GNU_PROPERTY_TYPE_0 note should be aligned to 8 bytes for 64-bit ELF as specified by gABI. A note section can be only placed in a PT_NOTE segment with the same alignment. PR gold/22914 PR gold/23535 * layout.cc (Layout::attach_allocated_section_to_segment): Place a note section in a PT_NOTE segment with the same alignment. Set the alignment of the PT_NOTE segment from the alignment of the note section. (Layout::create_note): Align the NT_GNU_PROPERTY_TYPE_0 note to 8 bytes for 64-bit ELF. (Layout::segment_precedes): Place segments with larger alignments first. * output.cc (Output_segment::Output_segment): Initialize align_. * output.h (Output_segment): Add align, set_align and align_. * testsuite/Makefile.am (gnu_property_test.stdout): Pass -lhSWn to $(TEST_READELF). (gnu_property_test): Pass --build-id to ld. * testsuite/Makefile.in: Regenerated. * testsuite/gnu_property_test.sh (check_alignment): New. Use check_alignment to check the NT_GNU_PROPERTY_TYPE_0 note alignment. Verify that there are 2 PT_NOTE segments.
2020-07-03Re: Change readelf's display of symbol namesAlan Modra1-1/+1
Fixes some fallout from git commit 0942c7ab94e5. PR 26028 gas/ * testsuite/gas/ia64/unwind-ilp32.d: Add -T to readelf options. gold/ * testsuite/Makefile.am (file_in_many_sections.stdout): Add -W to readelf options. * testsuite/Makefile.in: Regenerate. ld/ * testsuite/ld-arm/arm-elf.exp (vxworks1): Pass --wide to readelf when dumping relocs. * testsuite/ld-i386/i386.exp (vxworks1): Likewise. * testsuite/ld-sh/sh-vxworks.exp (vxworks1): Likewise. * testsuite/ld-sparc/sparc.exp (vxworks1): Likewise. * testsuite/ld-arm/vxworks1.rd: Adjust to suit. * testsuite/ld-i386/vxworks1.rd: Adjust. * testsuite/ld-sh/vxworks1.rd: Adjust. * testsuite/ld-sparc/vxworks1.rd: Adjust.
2020-06-16Use CXXCOMPILE in gold/testsuite/Makefile for c++ testcasesAlan Modra1-3/+3
I was playing with passing -std=c99 to an older version of gcc by using CC="gcc-4 -std=c99", and ran into cc1plus: error: command line option ‘-std=c99’ is valid for C/ObjC but not for C++ [-Werror] This obvious fix uses the correct compiler for a number of gold testcases. * testsuite/Makefile.am (export_dynamic_plugin.o): Use CXXCOMPILE. (plugin_test_wrap_symbols_1.o): Likewise. (plugin_test_wrap_symbols_2.o): Likewise. * testsuite/Makefile.in: Regenerate.
2020-05-02gold: Compile common tests with -fcommonH.J. Lu1-2/+21
Since GCC 10 defaults to -fno-common, add -fcommon to common tests to force common behavior. PR gold/25904 * testsuite/Makefile.am (COMMON_TEST_C_CFLAGS): New. (common_test_1.o): New rule. (common_test_2.o): Likewise. (common_test_3.o): Likewise. (plugin_common_test_1.o): Likewise. (plugin_common_test_2.o): Likewise. (common_test_1_v1.o): Likewise. (common_test_1_v2.o): Likewise. (common_test_2_pic.o): Compile with $(COMMON_TEST_C_CFLAGS). (common_test_3_pic.o): Likewise. * testsuite/Makefile.in: Regenerated.
2020-05-01gold: x86-64: Fix TLSDESC relaxation for x32H.J. Lu1-3/+3
X32 TLSDESC sequences can be: 40 8d 05 00 00 00 00 rex lea foo@TLSDESC(%rip), %reg ... 67 ff 10 call *foo@TLSCALL(%eax) or the same sequence as LP64: 48 8d 05 00 00 00 00 lea foo@TLSDESC(%rip), %reg ... ff 10 call *foo@TLSCALL(%rax) We need to support both sequences for x32. For both GDesc -> IE/LE transitions, 67 ff 10 call *foo@TLSCALL(%eax) should relaxed to 0f 1f 00 nopl (%rax) For GDesc -> LE transition, 40 8d 05 00 00 00 00 rex lea foo@TLSDESC(%rip), %reg should relaxed to 40 c7 c0 fc ff ff ff rex movl $foo@tpoff, %reg For GDesc -> IE transition, 40 8d 05 00 00 00 00 rex lea foo@TLSDESC(%rip), %reg should relaxed to 40 8b 05 00 00 00 00 rex movl foo@gottpoff(%rip), %eax PR gold/25426 * x86_64.cc (Target_x86_64<size>::Relocate::tls_desc_gd_to_ie): For x32, relax "rex leal foo@tlsdesc(%rip), %reg" to "rex movl foo@gottpoff(%rip), %eax" and relax ""call *(%eax)" to "nopl (%rax)". (Target_x86_64<size>::Relocate::tls_desc_gd_to_le): For x32, relax "rex leal foo@tlsdesc(%rip), %reg" to "rex movl foo@tpoff, %eax" and relax "call *foo@tlscall(%eax)" to "nopl (%rax)". * testsuite/Makefile.am (tls_test_gnu2.o): Depend on gcctestdir/as. (tls_test_file2_gnu2.o): Likewise. (tls_test_c_gnu2.o): Likewise. * testsuite/Makefile.in: Regenerated.
2020-05-01gold: x86-64: Fix TLSDESC -> LE relaxationH.J. Lu1-0/+11
X86-64 TLSDESC sequences can be: 4c 8d 0d 00 00 00 00 leaq foo@TLSDESC(%rip), %r9 4c 89 c8 movq %r9, %rax ff 10 call *foo@TLSCALL(%rax) TLSDESC -> LE relaxation can turn them into: 49 c7 c1 fc ff ff ff mov $0xfffffffffffffffc,%r9 4c 89 c8 mov %r9,%rax 66 90 xchg %ax,%ax We need to check and update the REX byte in this case. PR gold/25473 * x86_64.cc (Target_x86_64<size>::Relocate::tls_desc_gd_to_ie): Properly check r8 - r15 in "lea foo@TLSDESC(%rip), %reg". (Target_x86_64<size>::Relocate::tls_desc_gd_to_le): Properly relax r8 - r15 in "lea foo@TLSDESC(%rip), %reg". * testsuite/Makefile.am (check_SCRIPTS): Add x86_64_gd_to_le.sh. (check_DATA): Add x86_64_gd_to_le.stdout. (MOSTLYCLEANFILES): Add x86_64_gd_to_le. (x86_64_gd_to_le.o): New target. (x86_64_gd_to_le): Likewise. (x86_64_gd_to_le.stdout): Likewise. * testsuite/Makefile.in: Regenerated. * testsuite/x86_64_gd_to_le.s: New file. * testsuite/x86_64_gd_to_le.sh: Likewise.
2019-05-11Fix problem with ICF where diffs in EH frame info is ignored.Joshua Oreman1-0/+10
PR gold/21066 * gc.h (gc_process_relocs): Track relocations in .eh_frame sections when ICF is enabled, even though the .eh_frame sections themselves are not foldable. * icf.cc (get_section_contents): Change arguments to permit operation on just part of a section. Include extra identity regions in the referring section's contents recursively. (match_sections): Lock object here instead of in get_section_contents so that get_section_contents can operate recursively. (Icf::add_ehframe_links): New method. (Icf::find_identical_sections): Pass .eh_frame sections to add_ehframe_links(). Increase default iteration count from 2 to 3 because handling exception info typically requires one extra iteration. * icf.h (Icf::extra_identity_list_): New data member with accessor. (is_section_foldable_candidate): Include .gcc_except_table sections. * options.h: Update documentation for new default ICF iteration count. * testsuite/Makefile.am (icf_test_pr21066): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/icf_test_pr21066.cc: New source file. * testsuite/icf_test_pr21066.sh: New test script.
2019-02-19Check whether symbols with MOVW_.ABS relocations require PLT entries (aarch64).Egeyar Bagcioglu1-0/+20
2019-02-19 Egeyar Bagcioglu <egeyar.bagcioglu@oracle.com> gold/ PR gold/23870 * aarch64.cc (Target_aarch64::Scan::global): Check if a symbol with R_AARCH64_MOVW_.ABS_* relocations requires a PLT entry. * testsuite/Makefile.am: Add aarch64_pr23870 test case. * testsuite/Makefile.in: Regenerate. * testsuite/aarch64_pr23870_bar.c: New file. * testsuite/aarch64_pr23870_foo.c: New file. * testsuite/aarch64_pr23870_main.S: New file.
2018-12-18[GOLD] Tweak keep_text_section_prefix test for PowerPC64 ELFv1Alan Modra1-1/+1
This test checks code layout by function symbol ordering, but that doesn't work on powerpc64 ELFv1 where the function symbol is on a descriptor. A simple work-around is to have nm emit synthetic symbols marking the code entry point of functions. Since the text segment is laid out before the data segment, the synthetic symbols will have lower addresses than function descriptor symbols and be seen first in nm -n output. On other targets, nm --synthetic typically emits symbols on plt entries. Since the testcase doesn't call any of the functions of interest there shouldn't be plt entries for those functions, so there should be no potentially confusing extra symbols. * testsuite/Makefile.am (keep_text_section_prefix_nm.stdout): Pass --synthetic to nm. * testsuite/Makefile.in: Regenerate.
2018-11-26[GOLD] justsyms_exec test fail on powerpc64Alan Modra1-1/+1
This test fails on powerpc64le due to the justsyms_lib being built with exported_data at 0x2010000, apparently due to the powerpc target code generating an empty relro .branch_lt section. Since the test relies on the library having exported_data at 0x2000000, avoid the problem by linking with -z norelro. Also, the test doesn't need to avoid checking the function symbol on powerpc elfv2. * testsuite/Makefile.am (justsyms_lib): Link with -z norelro. * testsuite/Makefile.in: Regenerate. * testsuite/justsyms_exec.c (main): Do check exported_func on PowerPC64 ELFv2.
2018-11-08Make gold testsuite work with CC and CXX specifying -BAlan Modra1-396/+392
The patch allows the gold testsuite to pass when using something like the following configure line, which works for the rest of the binutils testsuite. At least, it does if you don't configure your gcc with any of the options that force a particular path to as or ld. gccdir="/home/alan/build/gcc/prev-" gccsrc="/home/alan/src/gcc.git" gcctarg="x86_64-linux" CC="${gccdir}gcc/xgcc -B${gccdir}gcc/" \ CXX="${gccdir}gcc/xg++ -B${gccdir}gcc/ -I${gccdir}$gcctarg/libstdc++-v3/include -I${gccdir}$gcctarg/libstdc++-v3/include/$gcctarg -I${gccsrc}/libstdc++-v3/libsupc++ -L${gccdir}$gcctarg/libstdc++-v3/src/.libs/" \ ~/src/binutils-gdb/configure ... gold's -Bgcctestdir/ option must come before the -B supplied by $CC or $CXX, in order to pick up the linker we want to test. Also when using a not-yet-installed gcc, it is necessary to provide a collect-ld in gcctestdir/ as otherwise a collect-ld script in -B${gccdir}gcc/ will be used and the wrong linker tested. Besides this, the patch fixes some bugs: The $COMPILE -D_FORTIFY_SOURCE edit was wrong (but worked for usual values), and the $CXXLINK_S edit unnecessarily but harmlessly used extra backslash quoting. See posix shell documentation regarding quoting, or www.gnu.org/software/bash/manual/bashref.html#Command-Substitution Also, -Bgcctestdir/ in one place makes it less likely a new test will be added that accidentally lacks the option. * Makefile.am (gcctestdir1/ld): Use $@ and absolute paths. (gcctestdir1/collect-ld): New. (ld1_DEPENDENCIES): Add gcctestdir1/collect-ld. (ld1_LDFLAGS): Remove -Bgcctestdir1/. (editcc1, ld1_LINK): Define. (gcctestdir2/ld, gcctestdir2/collect-ld, ld2_DEPENDENCIES), (ld2_LDFLAGS, editcc2, ld2_LINK), (ld1_r_DEPENDENCIES, ld1_r_LDFLAGS, ld1_r_LINK), (gcctestdir2-r/ld, gcctestdir2-r/collect-ld, ld2_r_DEPENDENCIES), (ld2_r_LDFLAGS, editcc2r, ld2_r_LINK), (gcctestdir3/ld, gcctestdir3/collect-ld, ld3_DEPENDENCIES), (ld3_LDFLAGS, editcc3, ld3_LINK), (gcctestdir4/ld, gcctestdir4/collect-ld, ld4_DEPENDENCIES), (ld4_LDFLAGS, editcc4, ld4_LINK): Similarly. * Makefile.in: Regenerate. * testsuite/Makefile.am (editcc): Define sed command to put our -B option first. Remove other occurrences of -Bgcctestdir/ throughout file. (editcc1): Define for -D_FORTIFY_SOURCE stripping. (editcc2): Define for -static-libgcc/libstdc++ stripping. (LINK1, CXXLINK1): Don't use CCLD or CXXLD. (CCLD, CXXLD, COMPILE, LINK, CXXCOMPILE, CXXLINK, CXXLINK_S): Define using editcc macros. (gcctestdir/collect-ld): New rule, add as a dependency of.. (gcctestdir/ld): ..this. Use $@ and abs_top_buildir. (gcctestdir/as): Use $@. * testsuite/Makefile.in: Regenerate. * testsuite/incremental_test.sh (actual): Match collect-ld too.
2018-11-02[GOLD] make cleanAlan Modra1-0/+2
Cleans a few more test files. * Makefile.am (MOSTLYCLEANFILES): Define. * Makefile.in: Regnerate. * testsuite/Makefile.am (MOSTLYCLEANFILES): Add ver_test_14 and gnu_property_test. * testsuite/Makefile.in: Regnerate.
2018-07-14Fix internal error when using --emit-relocs with plugins.Cary Coutant1-1/+1
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-07-14Fix problem causing duplicated linker-generated symbols with versions.Cary Coutant1-0/+9
When generating _end, _edata, etc. symbols, and a version script provides a version name, and we are linking against another shared library that provides those symbols with a different version, gold ends up trying to resolve the other shared library's symbols to the new definitions, resulting in two copies of each symbol, one as default, and one as non-default. This patch tests for that condition, and ignores the symbols provided by the other shared library. gold/ PR gold/23409 * symtab.cc (Symbol_table::define_special_symbol): Add check for version name on existing symbol. * testsuite/Makefile.am (ver_test_pr23409): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/ver_test_pr23409.sh: New test script. * testsuite/ver_test_pr23409_1.script: New version script. * testsuite/ver_test_pr23409_2.script: New version script.
2018-06-22Update support for .note.gnu.property sections.Cary Coutant1-2/+2
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/+17
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-06-21Fix treatment of symbol versions with unused as-needed libraries.Cary Coutant1-0/+17
When we have a weak reference to a symbol defined in an as-needed library, and that library ends up not-needed, gold simply clears the version information in the symbol table, even if the symbol could have been resolved by a needed library later in the link order. This results in a loss of version information, which can cause the program to bind to the wrong version at run time. This patch lets a dynamic definition override an earlier one if the earlier one is from a not-needed library, so that we can retain the version information from the binding to the needed library. In order to do that, the tracking of needed/not-needed had to be moved up to symbol resolution time, instead of during Symbol_table::set_dynsym_indexes(). In cases where we still end up discarding version information, I've added a warning. For the original problem report and discussion, see: https://stackoverflow.com/questions/50751421/undefined-behavior-in-shared-lib-using-libpthread-but-not-having-it-in-elf-as-d gold/ * resolve.cc (Symbol_table::resolve): Rename tobinding to orig_tobinding. Call set_is_needed() for objects that resolve non-weak references. (Symbol_table::should_override): Allow a dynamic definition to override an earlier one in a not-needed library. * symtab.cc (Symbol_table::set_dynsym_indexes): Remove separate processing for as-needed symbols. Add warning when discarding version informatin. * testsuite/Makefile.am (weak_as_needed): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/weak_as_needed.sh: New test script. * testsuite/weak_as_needed_a.c: New source file. * testsuite/weak_as_needed_b.c: New source file. * testsuite/weak_as_needed_b.script: New version script. * testsuite/weak_as_needed_c.c: New source file. * testsuite/weak_as_needed_c.script: New version script.
2018-06-20Fix problem where gold does not create base version for executables.Cary Coutant1-0/+7
gold/ PR gold/23268 * dynobj.cc (Versions::Versions): Change init for needs_base_version_. (Versions::record_version): Add verdefs for both shared objects and executables. (Versions::add_def): Likewise for base version. (Versions::add_need): Don't add base version for executables. (Versions::version_index): Look up version for both shared objects and executables. * testsuite/Makefile.am (ver_test_14): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/ver_test_14.script: New version script. * testsuite/ver_test_14.sh: New test script.
2018-06-19Replace thread config with automatic config using ax_pthread.m4.Cary Coutant1-22/+32
The autotools library macro (AX_PTHREAD) is now used to detect if pthreads is present and multi-threaded linking in gold is automatically enabled if it is found. This enables multi-threaded gold on platforms where pthreads is enabled via other methods than just -lpthread (e.g., MinGW). 2018-06-19 Joshua Watt <jpewhacker@gmail.com> Cary Coutant <ccoutant@gmail.com> gold/ * configure.ac: Replace manual thread configuration with AX_PTHREAD. Add --enable-threads=auto. * Makefile.am (THREADFLAGS, THREADLIBS): New defines. (AM_CFLAGS, AM_CXXFLAGS): Add $(THREADFLAGS. (THREADSLIB): Remove; change all references to THREADLIBS. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * config.in: Regenerate. * configure: Regenerate. * testsuite/Makefile.am (THREADSLIB): Replace with... (THREADFLAGS, THREADLIBS): ... these. (LDADD): Remove; add as individual defines for... (object_unittest, binary_unittest, leb128_unittest) (overflow_unittest): ... these tests. (tls_test, tls_pic_test, tls_pie_test, tls_pie_pic_test) (tls_shared_test, tls_shared_ie_test, tls_shared_gd_to_ie_test) (tls_shared_gnu2_gd_to_ie_test, tls_shared_gnu2_test_LDFLAGS) (tls_shared_nonpic_test_LDFLAGS): Add $(THREADFLAGS) and ($THREADLIBS). * testsuite/Makefile.in: Regenerate.
2018-06-19Remove *.stderr when "make clean".Cary Coutant1-1/+1
gold/ * testsuite/Makefile.am (MOSTLYCLEANFILES): Add *.stderr. * testsuite/Makefile.in: Regenerate.
2018-04-24Fix internal error caused by conflicting default version definitions.Cary Coutant1-0/+17
gold/ PR gold/16504 * dynobj.cc (Versions::symbol_section_contents): Don't set VERSYM_HIDDEN flag for undefined symbols. * symtab.cc (Symbol_table::add_from_object): Don't override default version definition with a different default version. * symtab.h (Symbol::from_dyn): New method. * testsuite/plugin_test.c (struct sym_info): Add ver field. (claim_file_hook): Pass symbol version to plugin API. (parse_readelf_line): Parse symbol version. * testsuite/Makefile.am (ver_test_pr16504): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/ver_test_pr16504.sh: New test script. * testsuite/ver_test_pr16504_a.c: New source file. * testsuite/ver_test_pr16504_a.script: New version script. * testsuite/ver_test_pr16504_b.c: New source file. * testsuite/ver_test_pr16504_b.script: New version script.
2018-04-02Fix problem where mixed section types can cause internal error during a -r link.Cary Coutant1-0/+26
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-03-26Fix case where IR file provides symbol visibility but replacement file does not.Cary Coutant1-0/+21
In PR 22868, two IR files provide conflicting visibility for a symbol. When a def with PROTECTED visibility is seen after a def with DEFAULT visibility, gold does not override the visibility. Later, if the replacement object define the symbol with DEFAULT visibility, the symbol remains DEFAULT. This was caused by a recent change to allow multiply-defined absolute symbols, combined with the fact that the plugin framework was using SHN_ABS as the section index for placeholder symbols. The solution is to use a real (but arbitrary) section index. gold/ PR gold/22868 * plugin.cc (Sized_pluginobj::do_add_symbols): Use a real section index instead of SHN_ABS for defined symbols. * testsuite/Makefile.am (plugin_pr22868): New test case. * testsuite/Makefile.in: Regenerate * testsuite/plugin_pr22868.sh: New test script. * testsuite/plugin_pr22868_a.c: New source file. * testsuite/plugin_pr22868_b.c: New source file.
2018-03-07New option -z,keep-text-section prefix.Sriraman Tallam1-0/+12
This option does not merge certain text sections with prefixes .text.hot, .text.unlikely, .text.startup and .text.exit. * layout.cc (Layout::default_section_order): Check for text section prefixes. (Layout::text_section_name_mapping): New static member. (Layout::text_section_name_mapping_count): New static member. (Layout::match_section_name): New static function. (Layout::output_section_name): Check for text section prefixes. * layout.h (Output_section_order::ORDER_TEXT_HOT): New enum value. (Output_section_order::ORDER_TEXT_STARTUP): New enum value. (Output_section_order::ORDER_TEXT_EXIT): New enum value. (Output_section_order::ORDER_TEXT_UNLIKELY): New enum value. (Layout::text_section_name_mapping): New static member. (Layout::text_section_name_mapping_count): New static member. (Layout::match_section_name): New static function. * options.h (keep_text_section_prefix): New -z option. * testsuite/Makefile.am (keep_text_section_prefix): New test. * testsuite/Makefile.in: Regenerate. * testsuite/keep_text_section_prefix.cc: New test source. * testsuite/keep_text_section_prefix.sh: New test script.
2018-02-22New plugin interface to get list of symbols wrapped with --wrap option.Sriraman Tallam1-0/+13
2018-02-22 Sriraman Tallam <tmsriram@google.com> * plugin.cc (get_wrap_symbols): New plugin interface. (load): Add get_wrap_symbols to transfer vector. * plugin-api.h (ld_plugin_get_wrap_symbols): New plugin interface. * testsuite/plugin_test.c (onload): Call and check get_wrap_symbols interface. * testsuite/plugin_test_wrap_symbols.sh: New test script. * testsuite/plugin_test_wrap_symbols_1.cc: New file. * testsuite/plugin_test_wrap_symbols_2.cc: New file. * testsuite/Makefile.am (plugin_test_wrap_symbols): New test. * testsuite/Makefile.in: Regenerate.
2018-02-15Fix symbol resolution with linker plugins for defsym symbols.Sriraman Tallam1-1/+12
2018-02-07 Sriraman Tallam <tmsriram@google.com> * expression.cc (Symbol_expression::set_expr_sym_in_real_elf): New method. (Unary_expression::set_expr_sym_in_real_elf): New method. (Binary_expression::set_expr_sym_in_real_elf): New method. (Trinary_expression::set_expr_sym_in_real_elf): New method. * plugin.cc (get_symbol_resolution_info): Fix symbol resolution if defined or used in defsyms. * plugin.h (Plugin_manager::is_defsym_def): New method. (Plugin_manager::Plugin_manager): Initialize defsym_defines_set_. (Plugin_manager::defsym_defines_set_): New member. (Plugin_manager::Defsym_defines_set): New typedef. * script.cc (Script_options::set_defsym_uses_in_real_elf): New method. (Script_options::find_defsym_defs): New method. * script.h (Expression::set_expr_sym_in_real_elf): New method. (Symbol_assignment::is_defsym): New method. (Symbol_assignment::value): New method. (Script_options::find_defsym_defs): New method. (Script_options::set_defsym_uses_in_real_elf): New method. * testsuite/Makefile.am (plugin_test_defsym): New test. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c: Check for new symbol resolution. * testsuite/plugin_test_defsym.sh: New script. * testsuite/plugin_test_defsym.c: New test source.
2017-12-11Add plugin API for processing plugin-added input filesStephen Crane1-0/+17
Gold plugins may wish to further process an input file added by a plugin. For example, the plugin may need to assign a unique segment for sections in a plugin-generated input file. This patch adds a plugin callback that the linker will call when reading symbols from a new input file added after the all_symbols_read event (i.e. an input file added by a plugin). 2017-12-11 Stephen Crane <sjc@immunant.com> * plugin-api.h: Add new plugin hook to allow processing of input files added by a plugin. (ld_plugin_new_input_handler): New function hook type. (ld_plugin_register_new_input): New interface. (LDPT_REGISTER_NEW_INPUT_HOOK): New enum val. (tv_register_new_input): New member. * plugin.cc (Plugin::load): Include hooks for register_new_input in transfer vector. (Plugin::new_input): New function. (register_new_input): New function. (Plugin_manager::claim_file): Call Plugin::new_input if in replacement phase. * plugin.h (Plugin::set_new_input_handler): New function. * testsuite/plugin_new_section_layout.c: New plugin to test new_input plugin API. * testsuite/plugin_final_layout.sh: Add new input test. * testsuite/Makefile.am (plugin_layout_new_file): New test case. * testsuite/Makefile.in: Regenerate.
2017-12-01Disallow --incremental with -pie and force -no-pie for incremental tests.Cary Coutant1-18/+18
This is a partial fix for the gold testsuite failures documented in PR 21090. The use of -fpie triggers some mov-to-lea optimizations that are not compatible with incremental linking, so those optimizations need to be disabled. We also diagnose the attempt to use -pie with incremental linking, and force -no-pie for the incremental tests in case the build has been configured to have GCC pass -pie all the time. We still have a problem where compiling with -fpie results in some GOT entries even when linking with -no-pie. This combination still causes test failures because we are not updating the GOT entries in an incremental update link. gold/ PR gold/21090 * incremental.cc (Sized_relobj_incr::do_relocate): Fix comment. * options.cc (General_options::finalize): Disallow -pie with incremental linking. * x86_64.cc (Target_x86_64::Scan::local): Don't do mov-to-lea or callq-to-direct optimizations for incremental links. (Target_x86_64::Scan::global): Likewise. (Target_x86_64::Relocate::relocate): Likewise. * testsuite/Makefile.am (incremental_test): Force -no-pie. (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.
2017-12-01Fix incremental linking failure with GCC 7+.Cary Coutant1-2/+2
With the new compiler, we're running out of patch space for the .eh_frame section. To workaround that issue, we compile the before and after versions both with no unwind tables. gold/ PR gold/22309 * testsuite/Makefile.am (two_file_test_1_v1_ndebug.o): Compile with no EH information. (two_file_test_1_ndebug.o): Likewise. * testsuite/Makefile.in: Regenerate. * testsuite/two_file_test_1.cc: Touch to force recompilation with new flags. * testsuite/two_file_test_1_v1.cc: Likewise.
2017-12-01Fix internal error from command line with unbalanced --start-lib/--end-lib.Benjamin Peterson1-0/+4
The problem is that while the command line isn't trivially empty, it contains no input files. As gold tries to configure the number of threads to use based on the number of input files, this causes the assertion failure above. Fix this problem by making the logic in gold.cc more robust and also adding a better error message about --start-lib to options.cc. gold/ PR gold/22406 * gold.cc (queue_initial_tasks) Check for number of real input files. * options.cc (Command_line::process) Check for unterminated --start-lib options. * testsuite/Makefile.am: Add new test script. * testsuite/Makefile.in: Regenerate. * testsuite/check_empty_command_lines.sh: New test script.
2017-11-08Fix problems with -r.James Clarke1-0/+6
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-10-20New gold linker option -z,text-unlikely-segment.Sriraman Tallam1-0/+10
2017-10-04 Sriraman Tallam <tmsriram@google.com> * options.h (-z,text_unlikely_segment): New option. * layout.cc (Layout::layout): Create new output section for .text.unlikely sections with the new option. (Layout::segment_precedes): Check for the new option when segment flags match. * testsuite/text_unlikely_segment.cc: New test source. * testsuite/text_unlikely_segment.sh: New test script. * testsuite/Makefile.am (text_unlikely_segment): New test. * testsuite/Makefile.in: Regenerate.
2017-10-19Implement BE8 support for ARM.Umesh Kalappa1-0/+32
gold/ * arm.cc (Stub::do_fixed_endian_write):Far call stubs support for arm in the be8 mode. * testsuite/Makefile.am: New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/arm_farcall_arm_arm_be8.sh: New script for arm to arm far call stubs. * testsuite/arm_farcall_thumb_thumb_be8.sh: New script for thumb to thumb far call stubs.
2017-09-20Check for export dynamic symbol options when doing symbol resolution in plugins.Teresa Johnson1-0/+12
2017-09-20 Teresa Johnson <tejohnson@google.com> * plugin.cc (is_visible_from_outside): Check for export dynamic symbol option and list. * testsuite/Makefile.am (plugin_test_12): New test. * testsuite/Makefile.in: Regenerate. * testsuite/export_dynamic_plugin.cc: New test source. * testsuite/plugin_test_12.sh: New test script.
2017-08-28Fix bad offset calculation for R_AARCH64_TLSDESC_* relocs.Igor Kudrin1-0/+11
If a custom linker script with an unexpected relative layout of .got and .got.plt sections was used, gold might produce a wrong offset when applying R_AARCH64_TLSDESC_* relocations. This patch fixes the issue by calculating "got_tlsdesc_offset" in a more direct way. gold/ * aarch64.cc (Target_aarch64::Relocate::relocate_tls): Make got_tlsdesc_offset signed and fix its calculation. * testsuite/Makefile.am (aarch64_tlsdesc): New test. * testsuite/Makefile.in: Regenerate. * testsuite/aarch64_tlsdesc.s: New test source file. * testsuite/aarch64_tlsdesc.sh: New test script. * testsuite/aarch64_tlsdesc.t: New test linker script.
2017-05-12Fix misplacement of a relaxed section on AArch64.Igor Kudrin1-0/+11
gold/ChangeLog PR gold/21430 * aarch64.cc (AArch64_relobj::convert_input_section_to_relaxed_section): Set the section offset to -1ULL. (Target_aarch64::relocate_section): Adjust the view in case of a relaxed input section. * testsuite/Makefile.am (pr21430): New test. * testsuite/Makefile.in: Regenerate * testsuite/pr21430.s: New test source file. * testsuite/pr21430.sh: New test script.
2017-02-15Improved support for --icf=safe when used with -pie.Rahul Chaudhry1-0/+14
gold/ * x86_64.cc (Target_x86_64::do_can_check_for_function_pointers): Return true even when building pie binaries. (Target_x86_64::possible_function_pointer_reloc): Check opcode for R_X86_64_PC32 relocations. (Target_x86_64::local_reloc_may_be_function_pointer): Pass extra arguments to local_reloc_may_be_function_pointer. (Target_x86_64::global_reloc_may_be_function_pointer): Likewise. * gc.h (gc_process_relocs): Add check for STT_FUNC. * testsuite/Makefile.am (icf_safe_pie_test): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/icf_safe_pie_test.sh: New shell script.
2016-12-27Place copy relocations in .dynbss when target is read-only.Cary Coutant1-0/+10
gold/ PR ld/20995 * copy-relocs.cc (Copy_relocs::make_copy_reloc): Use .dynbss for read-only data when linking with -z relro. * copy-relocs.h (Copy_relocs::dynrelro_): New data member. * testsuite/Makefile.am (copy_test_relro): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/copy_test_relro.cc: New source file. * testsuite/copy_test_relro_1.cc: New source file.
2016-12-22Add -z bndplt support (for Intel MPX).Cary Coutant1-1/+28
gold/ PR gold/17643 * options.h (-z bndplt): New option. * x86_64.cc (Output_data_plt_x86_64::regular_count): New method. (Output_data_plt_x86_64::address_for_global): Move implementation into virtual method. (Output_data_plt_x86_64::address_for_local): Likewise. (Output_data_plt_x86_64::got): New method. (Output_data_plt_x86_64::got_plt): New method. (Output_data_plt_x86_64::got_irelative): New method. (Output_data_plt_x86_64::do_address_for_global): New virtual method. (Output_data_plt_x86_64::do_address_for_local): New virtual method. (class Output_data_plt_x86_64_bnd): New class. (Target_x86_64::do_make_data_plt): Move out of line and specialize for each size (both overloads). (Output_data_plt_x86_64::set_final_data_size): Cosmetic changes. * testsuite/Makefile.am (bnd_plt_1): New test case. (bnd_ifunc_1): New test case. (bnd_ifunc_2): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/bnd_ifunc_1.s: New source file. * testsuite/bnd_ifunc_1.sh: New shell script. * testsuite/bnd_ifunc_2.s: New source file. * testsuite/bnd_ifunc_2.sh: New shell script. * testsuite/bnd_plt_1.s: New source file. * testsuite/bnd_plt_1.sh: New shell script.
2016-12-22Fix placement of forced local symbols in the dynamic symbol table.Cary Coutant1-0/+5
Gold was not placing forced-local symbols (e.g., hidden visibility) at the front of the dynamic symbol table, or including them in the count of local symbols recorded in the .dynsym section's sh_info field. gold/ * layout.cc (Layout::finalize): Track count of forced-local symbols in .dynsym. (Layout::create_symtab_sections): Add local_dynamic_count parameter; use that instead of sh_info value. (Layout::create_dynamic_symtab): Add pforced_local_dynamic_count parameter; pass it to Symtab::set_dynsym_indexes(). Include forced locals in sh_info value. Pass index of first real global to Dynobj::create_gnu_hash_table() and Dynobj::create_elf_hash_table(). * layout.h (Layout::create_symtab_sections): Add local_dynamic_count parameter. (Layout::create_dynamic_symtab): Add pforced_local_dynamic_count parameter. * symtab.cc (Symbol_table::set_dynsym_indexes): Add pforced_local_count parameter. Process forced-local symbols first and return the count. (Symbol_table::finalize): Update comments. * symtab.h (Symbol_table::set_dynsym_indexes): Add pforced_local_count parameter. (Symbol_table::first_dynamic_global_index_): Update comment. (Symbol_table::dynamic_count_): Update comment. * testsuite/Makefile.am (ifuncmod1.sh): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/ifuncmod1.sh: New shell script.
2016-12-22Fix problem where version script causes predefined hidden symbol to be ↵Cary Coutant1-0/+5
defined twice. When creating a predefined hidden symbol like _GLOBAL_OFFSET_TABLE_, gold was incorrectly letting a version script add a version to the symbol, resulting in two copies of the symbol, both STB_LOCAL, but one of which was grouped in the globals part of the symbol table. gold/ * symtab.cc (Symbol_table::define_special_symbol): Add is_forced_local parameter; if set, do not check version script. (Symbol_table::do_define_in_output_data): Pass is_forced_local for STB_LOCAL predefined symbols. (Symbol_table::do_define_in_output_segment): Likewise. (Symbol_table::do_define_in_output_segment): Likewise. (Symbol_table::do_define_as_constant): Likewise. * symtab.h (Symbol_table::define_special_symbol): Add is_forced_local parameter. Adjust all callers. * testsuite/Makefile.am (ver_test_8.sh): New test case. * testsuite/Makefile.in: Regenerate. * ver_test_8.sh: New test script.