Commit Graph

550 Commits

Author SHA1 Message Date
Alan Modra
6d53c0962c Update year range in copyright notice of binutils files
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.
2023-01-04 22:14:02 +10:30
Alan Modra
8a0c029026 Re: ld, gold: remove support for -z bndplt (MPX prefix)
Don't attempt to run gold tests with -z bndplt

	* testsuite/Makefile.am (exception_x86_64_bnd_test, bnd_plt_1.sh),
	(bnd_ifunc_1.sh, bnd_ifunc_2.sh): Delete rules.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/bnd_ifunc_1.s: Delete.
	* testsuite/bnd_ifunc_1.sh: Delete.
	* testsuite/bnd_ifunc_2.s: Delete.
	* testsuite/bnd_ifunc_2.sh: Delete.
	* testsuite/bnd_plt_1.s: Delete.
	* testsuite/bnd_plt_1.sh: Delete.
2022-12-15 00:03:15 +10:30
Fangrui Song
8b2d02cbb9 gold: add --compress-debug-sections=zstd [PR 29641]
This option compresses output debug sections with zstd and sets ch_type
to ELFCOMPRESS_ZSTD.  Latest gdb and lldb support ELFCOMPRESS_ZSTD.

There will be an error if zstd is not enabled at configure time.

    error: --compress-debug-sections=zstd: gold is not built with zstd support
2022-11-10 22:09:09 -08:00
Fangrui Song
332a4eeaea gold, dwp: support zstd compressed input debug sections [PR 29641]
This feature is enabled if config/zstd.m4 uses zstd.
2022-11-10 21:42:14 -08:00
Alan Modra
67d1991b78 egrep in binutils
Apparently some distros have a nagging egrep that helpfully tells you
egrep is deprecated and to use "grep -E".  The nag message causes a ld
testsuite failure.  What's more the advice isn't that good.  The "-E"
flag may not be available with older versions of grep.

This patch fixes bare invocation of egrep within binutils, replacing
it with the autoconf $EGREP or with grep.

config/
	* lib-ld.m4 (AC_LIB_PROG_LD_GNU): Require AC_PROG_EGREP and
	invoke $EGREP.
	(AC_LIB_PROG_LD): Likewise.
binutils/
	* configure: Regenerate.
	* embedspu.sh: Replace egrep with grep.
gold/
	* testsuite/Makefile.am (flagstest_compress_debug_sections.check):
	Replace egrep with grep.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/bnd_ifunc_1.sh: Replace egrep with $EGREP.
	* testsuite/bnd_ifunc_2.sh: Likewise.
	* testsuite/bnd_plt_1.sh: Likewise.
	* testsuite/discard_locals_test.sh: Likewise.
	* testsuite/gnu_property_test.sh: Likewise.
	* testsuite/no_version_test.sh: Likewise.
	* testsuite/pr18689.sh: Likewise.
	* testsuite/pr26936.sh: Likewise.
	* testsuite/retain.sh: Likewise.
	* testsuite/split_i386.sh: Likewise.
	* testsuite/split_s390.sh: Likewise.
	* testsuite/split_x32.sh: Likewise.
	* testsuite/split_x86_64.sh: Likewise.
	* testsuite/ver_test_pr16504.sh: Likewise.
intl/
	* configure: Regenerate.
ld/
	* testsuite/ld-elfvers/vers.exp (test_ar): Replace egrep with grep.
2022-09-28 13:37:31 +09:30
Luca Boccassi
701821154b Add gold support for --package-metadata option.
Following the same format as the implementation in ld:
9e2bb0cb5e

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.
2022-08-04 17:37:32 -07:00
Xi Ruoyao
01ae03b5b9 gold: don't invoke IA32 syscall in x86_64 assembly testcase
pr17704a_test.s is a x86_64 assembly file, but it invokes IA32 exit
syscall with "int 0x80".  This causes a segfault on kernels with
CONFIG_IA32_EMULATION disabled.

gold/

	* testsuite/pr17704a_test.s (_start): Invoke x86_64 exit syscall
	instead of its IA32 counterpart.
2022-05-18 09:34:31 +02:00
H.J. Lu
ad69b6b861 Regenerate Makefile.in files with automake 1.15.1
Regenerate Makefile.in files with the unmodified automake 1.15.1 to
remove

runstatedir = @runstatedir@

bfd/

	* Makefile.in: Regenerate.

binutils/

	* Makefile.in: Regenerate.

gas/

	* Makefile.in: Regenerate.

gold/

	* Makefile.in: Regenerate.
	* testsuite/Makefile.in: Likewise.

gprof/

	* Makefile.in: Regenerate.

ld/

	* Makefile.in: Regenerate.

opcodes/

	* Makefile.in: Regenerate.
2022-01-23 06:59:20 -08:00
Nick Clifton
f908e960c5 Change version number to 2.38.50 and regenerate files 2022-01-22 12:39:28 +00:00
Alan Modra
b9255b7808 infinite recursion detected in gold testcase
gold/testsuite/icf_test.cc:32:5: error: infinite recursion detected [-Werror=infinite-recursion]
   32 | int kept_func()
      |     ^~~~~~~~~

	* testsuite/icf_test.cc: Avoid infinite recursion error.
2022-01-05 16:55:57 +10:30
Alan Modra
a2c5833233 Update year range in copyright notice of binutils files
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.
2022-01-02 12:04:28 +10:30
Alan Modra
daad0428f2 -Waddress fixes for gold testsuite
Current mainline gcc.
common_test_1.c: In function 'main':
common_test_1.c:56:14: error: comparison between two arrays [-Werror=array-compare]
   56 |   assert (c5 > c4);
      |              ^
common_test_1.c:56:14: note: use '&c5[0] > &c4[0]' to compare the addresses

	* testsuite/common_test_1.c: Avoid -Waddress warnings.
	* testsuite/common_test_1_v1.c: Likewise.
	* testsuite/common_test_1_v2.c: Likewise.
	* testsuite/script_test_2.cc: Likewise.
2021-11-15 13:26:17 +10:30
Cary Coutant
b218a83935 Fix failing test for PR 23870.
gold/
	PR gold/pr23870
	* testsuite/aarch64_pr23870_bar.c: Return a magic value.
	* testsuite/aarch64_pr23870_foo.c: Check the magic value and return
	success or failure.
2021-03-19 17:58:32 -07:00
H.J. Lu
25294ff049 gold: Remove the circular IFUNC dependency in ifuncmain6pie
On Fedora 33 x86-64 with glibc 2.32-3, ifuncmain6pie failed with:

./ifuncmain6pie: IFUNC symbol 'foo' referenced in './ifuncmod6.so' is defined in the executable and creates an unsatisfiable circular dependency.
FAIL ifuncmain6pie (exit status: 127)

Remove non-JUMP_SLOT relocations against foo in ifuncmod6.so, which
trigger the circular IFUNC dependency.

	* testsuite/ifuncmain6pie.c: Remove non-JUMP_SLOT relocations
	against foo in ifuncmod6.so.
	* testsuite/ifuncmod6.c: Likewise.
2021-01-17 16:43:59 -08:00
Alan Modra
250d07de5c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
Cary Coutant
ff4bc37d77 Keep input SHF_GNU_RETAIN sections and strip output SHF_GNU_RETAIN for 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-14 15:49:27 -08:00
Cary Coutant
f22318ef0d Re-enable incremental tests that were failing with GCC 9+.
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-13 16:50:52 -08:00
Alan Modra
c6162010ad [GOLD] PR26936 test
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-12-03 16:31:19 +10:30
H.J. Lu
568cbddc71 gold: Convert x86-64 GOTPCRELX only if addend == -4
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-29 06:00:50 -08:00
H.J. Lu
8ca751ee63 gold: Get linkonce/comdate sections for debugging sections
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-29 05:55:35 -08:00
Nick Gasson
af61e84fd2 gold: ensure file_counts_lock is initialized before using
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-11-03 10:34:51 +10:30
H.J. Lu
b8fd9b80ee gold: Support GNU_PROPERTY_X86_ISA_1_BASELINE marker
* testsuite/gnu_property_test.sh: Updated.
2020-10-30 06:51:24 -07:00
H.J. Lu
6c0005b8f4 gold: Skip some incremental tests
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-13 05:23:13 -07:00
H.J. Lu
29700bfff4 gold: Discard .note.gnu.property section
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-13 05:22:08 -07:00
H.J. Lu
586e30940e gold: Update GNU_PROPERTY_X86_XXX macros
This patch updates GNU_PROPERTY_X86_XXX macros for gold:

1. GNU_PROPERTY_X86_UINT32_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in all relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_AND_LO      0xc0000002
 #define GNU_PROPERTY_X86_UINT32_AND_HI      0xc0007fff

2. GNU_PROPERTY_X86_UINT32_OR_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_OR_LO    0xc0008000
 #define GNU_PROPERTY_X86_UINT32_OR_HI    0xc000ffff

3. GNU_PROPERTY_X86_UINT32_OR_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs and the property is
present in all relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_OR_AND_LO   0xc0010000
 #define GNU_PROPERTY_X86_UINT32_OR_AND_HI   0xc0017fff

4. GNU_PROPERTY_X86_FEATURE_2_NEEDED, GNU_PROPERTY_X86_FEATURE_2_USED
and GNU_PROPERTY_X86_FEATURE_2_XXX bits.

GNU_PROPERTY_X86_FEATURE_1_AND is unchanged.  GNU_PROPERTY_X86_ISA_1_USED
and GNU_PROPERTY_X86_ISA_1_NEEDED are updated to better support targeted
processors since GNU_PROPERTY_X86_ISA_1_?86 aren't isn't very useful.
A new set of GNU_PROPERTY_X86_ISA_1_XXX bits are defined.  The previous
GNU_PROPERTY_X86_ISA_1_XXX macros are deprecated and renamed to
GNU_PROPERTY_X86_COMPAT_ISA_1_XXX and GNU_PROPERTY_X86_COMPAT_2_ISA_1_XXX.

elfcpp/

	* elfcpp.h (GNU_PROPERTY_X86_ISA_1_USED): Renamed to ...
	(GNU_PROPERTY_X86_COMPAT_ISA_1_USED): This.
	(GNU_PROPERTY_X86_ISA_1_NEEDED): Renamed to ...
	(GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED): This.
	(GNU_PROPERTY_X86_UINT32_AND_LO): New.
	(GNU_PROPERTY_X86_UINT32_AND_HI): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_LO): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_HI): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_AND_LO): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_AND_HI): Likewise.
	(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): New.
	(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): Likewise.
	(GNU_PROPERTY_X86_FEATURE_1_AND): Updated to
	(GNU_PROPERTY_X86_UINT32_AND_LO + 0).
	(GNU_PROPERTY_X86_ISA_1_NEEDED): New.  Defined to
	GNU_PROPERTY_X86_UINT32_OR_LO + 2.
	(GNU_PROPERTY_X86_FEATURE_2_NEEDED): New.  Defined to
	(GNU_PROPERTY_X86_UINT32_OR_LO + 1).
	(GNU_PROPERTY_X86_ISA_1_USED): New.  Defined to
	GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2.
	(GNU_PROPERTY_X86_FEATURE_2_USED): New.  Defined to
	(GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1).

gold/

	* x86_64.cc (Target_x86_64::Target_x86_64): Initialize
	feature_2_used_, feature_2_needed_ and object_feature_2_used_.
	(Target_x86_64::feature_2_used_): New data member.
	(Target_x86_64::feature_2_needed_): Likewise.
	(Target_x86_64::object_isa_1_used_): Likewise.
	(Target_x86_64::record_gnu_property): Support
	GNU_PROPERTY_X86_COMPAT_ISA_1_USED,
	GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED,
	GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED,
	GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED,
	GNU_PROPERTY_X86_FEATURE_2_USED and
	GNU_PROPERTY_X86_FEATURE_2_NEEDED.
	(Target_x86_64::merge_gnu_properties): Merge FEATURE_2_USED bits.
	Initialize object_feature_2_used_.
	(Target_x86_64::do_finalize_gnu_properties): Support
	GNU_PROPERTY_X86_FEATURE_2_USED and
	GNU_PROPERTY_X86_FEATURE_2_NEEDED.
	* testsuite/gnu_property_a.S (GNU_PROPERTY_X86_ISA_1_USED): Set
	to 0xc0010002.
	(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
	* testsuite/gnu_property_b.S (GNU_PROPERTY_X86_ISA_1_USED): Set
	to 0xc0010002.
	(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
	* testsuite/gnu_property_c.S (GNU_PROPERTY_X86_ISA_1_USED): Set
	to 0xc0010002.
	(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
	* testsuite/gnu_property_test.sh: Updated.
2020-10-13 05:21:05 -07:00
H.J. Lu
6bf4a34047 gold: Properly align the NT_GNU_PROPERTY_TYPE_0 note
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-10-13 05:18:24 -07:00
H.J. Lu
aac1d94f19 Gold: Enable safe ICF for shared object on x86-64
With

commit 4aebb6312e
Author: Rahul Chaudhry <rahulchaudhry@google.com>
Date:   Wed Feb 15 00:37:10 2017 -0800

    Improved support for --icf=safe when used with -pie.

we now check opcode with R_X86_64_PC32 relocation, which tell branches
from other instructions.  We can enable safe ICF for shared object on
x86-64.  Also, global symbols with non-default visibility should be
folded like local symbols.

	PR gold/21452
	* x86_64.cc (Scan::local_reloc_may_be_function_pointer): Remove
	check for shared library.
	(Scan::global_reloc_may_be_function_pointer): Remove check for
	shared library and symbol visibility.
	* testsuite/icf_safe_so_test.cc (bar_static): New function.
	(main): Take function address of bar_static and use it.
	* testsuite/icf_safe_so_test.sh (arch_specific_safe_fold): Also
	check fold on x86-64.  Check bar_static isn't folded.
2020-10-13 05:10:36 -07:00
H.J. Lu
f511427204 gold: Update testsuite/split_[i386|x32|x86_64].sh
Update testsuite/split_i386.sh, testsuite/split_x32.sh and
testsuite/split_x86_64.sh for

commit f9ff65d4df
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Oct 8 10:27:43 2020 +1030

    [GOLD] Increase --split-stack-adjust-size

	* testsuite/split_i386.sh: Updated for --split-stack-adjust-size
	default change.
	* testsuite/split_x32.sh: Likewise.
	* testsuite/split_x86_64.sh: Likewise.
2020-10-08 05:01:22 -07:00
H.J. Lu
53752b85ac gold: Update x32 test
* testsuite/split_x32.sh: Likewise.
2020-07-19 07:30:42 -07:00
H.J. Lu
9e6b97601b gold: Update x86-64 tests
commit 36938cabf0
Author: Jan Beulich <jbeulich@suse.com>
Date:   Wed Jul 15 08:53:55 2020 +0200

    x86: avoid attaching suffixes to unambiguous insns

removed the 'a' suffix on call and jmp from disassembler output.  Update
gold x86-64 tests.

	* testsuite/bnd_ifunc_1.sh: Updated.
	* testsuite/bnd_plt_1.sh: Likewise.
	* testsuite/split_x86_64.sh: Likewise.
	* testsuite/x86_64_indirect_call_to_direct.sh: Likewise.
2020-07-19 07:18:07 -07:00
Nick Clifton
a7f987e837 Commit: Fix GOLD testsuite failures for 2.35 branch.
* testsuite/script_test_7.sh: Adjust expected address of the .bss
	section.
	* testsuite/script_test_9.sh: Do not expect the .init section to
	immediately follow the .text section in the mapping of sections to
	segments.
2020-07-08 11:08:05 +01:00
Alan Modra
b657622c3e Re: Change readelf's display of symbol names
Fixes some fallout from git commit 0942c7ab94.

	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-07-03 17:15:16 +09:30
Alan Modra
423054bead Use __asm__ rather than asm in gold testsuite
discard_locals_test.c:28:6: error: expected declaration specifiers or
‘...’ before string constant
 asm (".Lshould_be_discarded:");
      ^

	* testsuite/discard_locals_test.c: Replace uses of asm with __asm__.
	* testsuite/discard_locals_relocatable_test.c: Likewise.
2020-06-16 22:12:39 +09:30
Alan Modra
90cd2aad03 Use CXXCOMPILE in gold/testsuite/Makefile for c++ testcases
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-06-16 21:03:25 +09:30
H.J. Lu
8c16443418 gold: Compile common tests with -fcommon
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-02 06:48:26 -07:00
H.J. Lu
ccf20d460f gold: x86-64: Fix TLSDESC relaxation for x32
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-01 10:11:23 -07:00
H.J. Lu
6d520e36de gold: x86-64: Fix TLSDESC -> LE relaxation
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.
2020-05-01 10:08:48 -07:00
H.J. Lu
e10cfd0633 gold: Make Ordering::operator() even more complex
GCC 9 generates the same function size for Ordering::operator() in
odr_violation1.cc and odr_violation2.cc on x32:

  134: 00000000    31 FUNC    WEAK   DEFAULT   64 _ZN8OrderingclEii
   40: 00000000    31 FUNC    GLOBAL DEFAULT   10 _ZN8OrderingclEii

This patch makes Ordering::operator() even more complex

   134: 00000000    31 FUNC    WEAK   DEFAULT   64 _ZN8OrderingclEii
    42: 00000000    35 FUNC    GLOBAL DEFAULT   11 _ZN8OrderingclEii

	* testsuite/odr_violation2.cc (Ordering::operator()): Make
	expression even more complex.
2020-05-01 10:06:31 -07:00
H.J. Lu
de6d6067f5 gold: Update ver_test_pr16504.sh
commit df3a023bd6
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Jul 23 17:54:42 2019 +0930

    SHF_GNU_MBIND requires ELFOSABI_GNU

changed readelf to print IFUNC only for ELFOSABI_GNU.  Since

$ readelf -h ver_test_pr16504.so
...
 OS/ABI:                            UNIX - System V
...

we get

$ readelf -sW ver_test_pr16504.so
...
     3: 0000000000000378    13 <OS specific>: 10 GLOBAL DEFAULT    9 foo@@VER1
...

Update ver_test_pr16504.sh to also accept "<OS specific>: 10".

	* testsuite/ver_test_pr16504.sh: Updated.
2020-05-01 09:05:21 -07:00
Alan Modra
b3adc24a07 Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
Martin Liska
5fa5f8f5fe
Introduce new .text.sorted.* sections.
gold/ChangeLog:

2019-11-26  Martin Liska  <mliska@suse.cz>

	* layout.cc (Layout::special_ordering_of_input_section):
	Add ".text.sorted".
	* output.cc: Special case ".text.sorted".
	* testsuite/section_sorting_name.cc: Cover also .text.sorted
	subsections.
	* testsuite/section_sorting_name.sh: Likewise.

ld/ChangeLog:

2019-11-26  Martin Liska  <mliska@suse.cz>

	* scripttempl/arclinux.sc: Add .text.sorted.* which is sorted
	by default.
	* scripttempl/elf.sc: Likewise.
	* scripttempl/elf64bpf.sc: Likewise.
	* scripttempl/nds32elf.sc: Likewise.
	* testsuite/ld-arm/arm-no-rel-plt.ld: Expect .text.sorted.*
	in the default linker script.
	* testsuite/ld-arm/fdpic-main.ld: Likewise.
	* testsuite/ld-arm/fdpic-shared.ld: Likewise.
2019-11-26 17:20:10 +01:00
Alan Modra
6831670dd3 implicit conversion from enum ld_plugin_level to enum ld_plugin_status
This is a gcc10 warning fix.

gold/
	* testsuite/plugin_new_section_layout.c (new_input_hook): Correct
	return status enum values.
2019-09-23 23:44:21 +09:30
Simon Marchi
e0b2a78c83 Re-generate many configure and Makefile.in files
I get some spurious changes when running autoconf/automake for various
projects in the tree.  This is likely because they were generated using
distro-patched tools last time.

I ran `autoreconf -f` in the various automake projects of the
binutils-gdb tree, and this is the result.  The tools I am using have
been compiled from source, from the upstream release.

bfd/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.
	* doc/Makefile.in: Re-generate.

binutils/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.
	* doc/Makefile.in: Re-generate.

gas/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.
	* doc/Makefile.in: Re-generate.

gold/ChangeLog:

	* testsuite/Makefile.in: Re-generate.

gprof/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.

ld/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.

opcodes/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.
2019-09-18 09:09:15 -04:00
Joshua Oreman
e173ea00c2 Fix problem with ICF where diffs in EH frame info is ignored.
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-05-11 07:27:10 +08:00
Egeyar Bagcioglu
7ae39e2d40 Check whether symbols with MOVW_.ABS relocations require PLT entries (aarch64).
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.
2019-02-19 16:13:24 -08:00
Alan Modra
827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
Alan Modra
a529dcc854 [GOLD] Tweak keep_text_section_prefix test for PowerPC64 ELFv1
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-12-18 11:57:45 +10:30
Alan Modra
c0ab2ae3cc [GOLD] icf_safe_so_test
PR 21128
	* testsuite/icf_safe_so_test.sh (check_fold): Rewrite to check
	multiple symbols at once.
	(arch_specific_safe_fold): Likewise, and call with the four foo*
	symbols expected to fold.
2018-12-08 13:24:14 +10:30
Alan Modra
9b4e3a5e23 [GOLD] justsyms_exec test fail on powerpc64
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-26 22:07:46 +10:30
Alan Modra
2eccb8f91f [GOLD] support objdump -T display of st_other
PowerPC64 ELFv2 uses the top 3 bits of st_other to encode a function's
local entry point offset from its global entry point.  Allow st_other
bits except for visibility==default.

	* testsuite/ver_test_14.sh: Accept objdump -T display of st_other
	bits on powerpc64le.
2018-11-26 22:05:54 +10:30