Commit Graph

4774 Commits

Author SHA1 Message Date
Alan Modra
a5f92c6756 ldgram.y low_level_library_NAME_list
Beginning a new rule hidden inside another rule is horrible.

	* ldgram.y: Whitespace fixes.
2021-02-01 18:35:33 +10:30
Alan Modra
49daa38f31 Re: ld: Add a test for PR ld/27259
* testsuite/ld-elf/pr27259.d: Correct sh_link match.
2021-02-01 18:35:33 +10:30
Alan Modra
c4566785ac PR27271, c6x-uclinux-ld segfaults linking ld-uClibc-1.0.37.so
bfd/
	PR 27271
	* elflink.c (bfd_elf_link_record_dynamic_symbol): Don't segfault
	on symbols defined in absolute or other special sections.
ld/
	* testsuite/ld-tic6x/tic6x.exp: Add pr27271 test.
2021-01-29 11:07:18 +10:30
H.J. Lu
53e556e5b4 ld: Add a test for PR ld/27259
PR ld/27259
	* testsuite/ld-elf/pr27259.d: New file.
	* testsuite/ld-elf/pr27259.s: Likewise.
2021-01-28 05:40:07 -08:00
Alan Modra
def97fb945 PR27259, SHF_LINK_ORDER self-link
This stops ld from endless looping on SHF_LINK_ORDER sh_link loops.

bfd/
	PR 27259
	* elflink.c (_bfd_elf_gc_mark_extra_sections): Use linker_mark to
	prevent endless looping of linked-to sections.
ld/
	PR 27259
	* ldelf.c (ldelf_before_place_orphans): Use linker_mark to
	prevent endless looping of linked-to sections.
2021-01-28 18:53:30 +10:30
H.J. Lu
2eda57ef61 ld: Fix a typo in testsuite/ld-x86-64/bnd-plt-1.d
Pass -mx86-used-note=no to assembler.

	* testsuite/ld-x86-64/bnd-plt-1.d: Fix a typo.
2021-01-26 16:18:41 -08:00
Alan Modra
1c9c9b9b55 PR27226, ld.bfd contains huge .rodata section
This makes it possible to build ld without any compiled-in scripts,
by setting COMPILE_IN=no in the environment.  pe, beos and pdp11
targets didn't support scripts from the file system, with pdp11
nastily editing the ld/ldscripts file so that the built-in script
didn't match.

	PR 27226
	* emulparams/alphavms.sh: Don't set COMPILE_IN.
	* emulparams/elf64_ia64_vms.sh: Likewise.
	* emulparams/elf64mmix.sh: Likewise.
	* emulparams/elf_iamcu.sh: Likewise.
	* emulparams/elf_k1om.sh: Likewise.
	* emulparams/elf_l1om.sh: Likewise.
	* emulparams/mmo.sh: Likewise.
	* emulparams/pdp11.sh: Set DATA_SEG_ADDR.
	* scripttempl/pdp11.sc: Use it.
	* emultempl/pdp11.em: Don't edit .xn script for separate_code,
	instead use .xe script.  Support scripts from file system.
	* emultempl/beos.em: Support scripts from file system.
	* emultempl/pe.em: Likewise.
	* emultempl/pep.em: Likewise.
	* testsuite/ld-bootstrap/bootstrap.exp: Make tmpdir/ldscripts link.
2021-01-26 20:54:43 +10:30
Fangrui Song
9e42b97628 Add some more DWARF-5 sections 2021-01-25 11:35:57 +00:00
Nick Clifton
b8df69003d Update linker scripts with the names of new DWARF-5 debug sections.
* scripttempl/DWARF.sc: Add .debug_loclists, .debug_rnglists,
	.debug_line_str and .debug_str_offsets.  Move .debug_macro and
	.debug_addr into DWARF-5 section.
2021-01-25 11:20:20 +00:00
Alan Modra
c78eec4424 mips XPASS pr26936
git commit 994b251328 "Ignore section symbols when matching linkonce
with comdat" cured the reason why this test used to fail on mips.

	* testsuite/ld-elf/pr26936.d: No longer xfail mips.
2021-01-21 16:48:35 +10:30
Alan Modra
4bd7c90276 PowerPC: Don't generate unused section symbols
PowerPC version of git commit d1bcae833b.

bfd/
	* elf32-ppc.c: Delete outdated comment.
	(TARGET_KEEP_UNUSED_SECTION_SYMBOLS): Define.
	* elf64-ppc.c (TARGET_KEEP_UNUSED_SECTION_SYMBOLS): Define.
gas/
	* testsuite/gas/ppc/power4.d: Adjust for removal of section sym.
	* testsuite/gas/ppc/test1elf32.d: Likewise.
	* testsuite/gas/ppc/test1elf64.d: Likewise.
ld/
	* testsuite/ld-powerpc/relbrlt.s: Make symbols global.
	* testsuite/ld-powerpc/relbrlt.d: Adjust to suit.
	* testsuite/ld-powerpc/tlsget.d: Adjust for reordered stubs.
	* testsuite/ld-powerpc/tlsget.wf: Likewise.
	* testsuite/ld-powerpc/tlsget2.d: Likewise.
	* testsuite/ld-powerpc/tlsget2.wf: Likewise.
	* testsuite/ld-powerpc/tlsexe.r: Adjust for removed section syms.
	* testsuite/ld-powerpc/tlsexe32.r: Likewise.
	* testsuite/ld-powerpc/tlsexe32no.r: Likewise.
	* testsuite/ld-powerpc/tlsexeno.r: Likewise.
	* testsuite/ld-powerpc/tlsexenors.r: Likewise.
	* testsuite/ld-powerpc/tlsexers.r: Likewise.
	* testsuite/ld-powerpc/tlsexetoc.r: Likewise.
	* testsuite/ld-powerpc/tlsexetocrs.r: Likewise.
	* testsuite/ld-powerpc/tlsso.r: Likewise.
	* testsuite/ld-powerpc/tlsso32.r: Likewise.
	* testsuite/ld-powerpc/tlstocso.r: Likewise.
2021-01-20 16:12:06 +10:30
Nick Alcock
c98de297b3 libctf, ld: fix data symbol test with newer GCC
GCC 11+ spots that the extern var_1 and var_666 declarations in this
test are unused, and removes them, thus stopping them from appearing as
conflicted data symbols and rendering the test pointless.  Use them in a
function unique to this TU to prevent them from being eliminated.

ld/ChangeLog
2021-01-19  Nick Alcock  <nick.alcock@oracle.com>

	* testsuite/ld-ctf/data-func-2.c: Stop removal of the extern foo_t
	symbols by the optimizer.
	* testsuite/ld-ctf/data-func-conflicted.d: Adjust accordingly.
2021-01-19 12:45:18 +00:00
Nelson Chu
85e963f185 ld: Just xfail riscv little endian targets for compressed1d.d test.
The sizes of compressed and uncompressed .debug_aranges are the same
for the riscv big endian targets, but different for the little endian
targets.  The compress rule is fine and isn't broken by riscv, just the
original compressed1d.d fails by accident.  Ideally, we should fill the
R_RISCV_ADD/SUB relocations when disabling relaxations in the assembler.
But before that, Jim already had written an alternative test compressed1d-alt
to relpace compressed1d.d for riscv, so we can only xfail the riscv little
endian targets in the short-term.

ld/
    * testsuite/ld-elf/elf.exp (riscv_little_endian): Added.  Return true
    if target is riscv little endian.  Otherwise, return false.
    * testsuite/ld-elf/compressed1d.d: Only xfail the riscv little endian
    targets by [riscv_little_endian].
2021-01-19 09:40:18 +08:00
Alan Modra
326adec374 PR26378, sections initialised only by linker scripts are always read/write
This changes the initialisation of output sections so that it is
possible to create read-only sections fed only from linker script
BYTE, SHORT, LONG or QUAD.  That currently isn't possible even for one
of the well-known ELF sections like .rodata, because once a section is
marked read/write that sticks.  On the other hand if we start
read-only, well-known ELF sections end up read/write as appropriate.
For example .tdata will still be SHF_ALLOC + SHF_WRITE + SHF_TLS.

	PR 26378
	* ldlang.c (map_input_to_output_sections): Start with a read-only
	section for data statements.
	* testsuite/ld-elf/size-2.d: Adjust to suit.
2021-01-18 23:07:40 +10:30
H.J. Lu
994b251328 ld/elf: Ignore section symbols when matching linkonce with comdat
When deciding if a single member comdat group section in file FOO should
be discarded by a linkonce section in file BAR, we check if 2 sections
define the same set of local and global symbols.  When only one of the
files doesn't contain the unused section symbols in the symbol table,
such as object files generated by clang or GNU assembler with

commit d1bcae833b
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jan 7 06:42:00 2021 -0800

    ELF: Don't generate unused section symbols

the check will fail since one file has the extra unused section symbols.
We should ignore both undefined and section symbols in the symbol table
when making such a decision.

bfd/

	PR ld/27193
	* elflink.c (elf_create_symbuf): Also ignore section symbols.

ld/

	PR ld/27193
	* testsuite/ld-i386/i386.exp: Run PR ld/27193 test.
	* testsuite/ld-i386/pr27193.dd: New file.
	* testsuite/ld-i386/pr27193a.o.bz2: Likewise.
	* testsuite/ld-i386/pr27193b.s: Likewise.
2021-01-17 20:01:30 -08:00
H.J. Lu
edf0f284b1 PR binutils/23460: Increase the max number of open files to 20
Increase the max number of open files to 20 for PR binutils/23460 test
which may have more than 16 file descriptors open:

lr-x------ 1 hjl hjl 64 Jan 16 16:49 0 -> /dev/null
l-wx------ 1 hjl hjl 64 Jan 16 16:49 1 -> pipe:[14151430]
lr-x------ 1 hjl hjl 64 Jan 16 16:49 10 -> /export/build/gnu/tools-build/x86_64-linux-toolchain/build-x86_64-linux/binutils/src/binutils-build/ld/tmpdir/pr23460c.o
lr-x------ 1 hjl hjl 64 Jan 16 16:49 11 -> /export/build/gnu/tools-build/x86_64-linux-toolchain/build-x86_64-linux/binutils/src/binutils-build/ld/tmpdir/pr23460d.o
lr-x------ 1 hjl hjl 64 Jan 16 16:49 12 -> /export/build/gnu/tools-build/x86_64-linux-toolchain/build-x86_64-linux/binutils/src/binutils-build/ld/tmpdir/pr23460e.o
lr-x------ 1 hjl hjl 64 Jan 16 16:49 13 -> /export/build/gnu/tools-build/x86_64-linux-toolchain/build-x86_64-linux/binutils/src/binutils-build/ld/tmpdir/pr23460f.o
lrwx------ 1 hjl hjl 64 Jan 16 16:49 14 -> /export/build/gnu/tools-build/x86_64-linux-toolchain/build-x86_64-linux/binutils/src/binutils-build/ld/tmpdir/stTLiXpO
lrwx------ 1 hjl hjl 64 Jan 16 16:49 15 -> /export/build/gnu/tools-build/x86_64-linux-toolchain/build-x86_64-linux/binutils/src/binutils-build/ld/tmpdir/stTLiXpO
l-wx------ 1 hjl hjl 64 Jan 16 16:49 2 -> pipe:[14151430]
lr-x------ 1 hjl hjl 64 Jan 16 16:49 3 -> pipe:[13933216]
l-wx------ 1 hjl hjl 64 Jan 16 16:49 4 -> pipe:[13933216]
lr-x------ 1 hjl hjl 64 Jan 16 16:49 5 -> pipe:[13990857]
l-wx------ 1 hjl hjl 64 Jan 16 16:49 6 -> pipe:[13990857]
lr-x------ 1 hjl hjl 64 Jan 16 16:49 7 -> /export/build/gnu/tools-build/x86_64-linux-toolchain/build-x86_64-linux/binutils/src/binutils-build/ld/tmpdir/libpr23460.a
lr-x------ 1 hjl hjl 64 Jan 16 16:49 8 -> /export/build/gnu/tools-build/x86_64-linux-toolchain/build-x86_64-linux/binutils/src/binutils-build/ld/tmpdir/pr23460a.o
lr-x------ 1 hjl hjl 64 Jan 16 16:49 9 -> /export/build/gnu/tools-build/x86_64-linux-toolchain/build-x86_64-linux/binutils/src/binutils-build/ld/tmpdir/pr23460b.o

	PR binutils/23460
	* testsuite/ld-plugin/lto.exp: Increase the max number of open
	files to 20 for PR binutils/23460 test.
2021-01-16 18:36:54 -08:00
H.J. Lu
75a933f399 ld/elf/x86: Don't compare IFUNC address in the shared object
On x86, glibc 2.33 starts to issue a fatal error message when calling
IFUNC function defined in the unrelocated executable from a shared
library.

1. Update x86 ELF linker to always convert IFUNC function defined in
position-dependent executable (PDE) to the normal function.  GOT in PDE
will be updated by R_*_IRELATIVE at run-time.
2. Update PR ld/23169 tests not to compare function address of external
IFUNC function in the shared object to avoid calling the IFUNC function
defined in the unrelocated executable.
3. Remove pr23169e tests which call the IFUNC function defined in the
unrelocated position-independent executable from a shared library.

bfd/

	PR ld/23169
	* elfxx-x86.c (_bfd_x86_elf_link_fixup_ifunc_symbol): Don't
	check pointer_equality_needed.

ld/

	PR ld/23169
	* testsuite/ld-ifunc/ifunc.exp: Replace pr23169c.rd with
	pr23169a.rd for pr23169c and pr23169f.  Remove pr23169e tests.
	* testsuite/ld-ifunc/pr23169a.c (foo): Don't compare function
	address.
2021-01-16 07:02:36 -08:00
H.J. Lu
68b007788a ld/x86: Add -z report-relative-reloc
Linker generated relative relocations don't have symbol info:

[hjl@gnu-cfl-2 tmpdir]$ readelf -rW dump

Relocation section '.rela.dyn' at offset 0x180 contains 2 entries:
 Offset     Info    Type                Sym. Value  Symbol's Name + Addend
00002f70  00000008 R_X86_64_RELATIVE                 1000
00002f68  00000025 R_X86_64_IRELATIVE                1007
[hjl@gnu-cfl-2 tmpdir]$

Add -z report-relative-reloc to x86 ELF linker to report dynamic relative
relocations:

[hjl@gnu-cfl-2 tmpdir]$ ../ld-new -pie -melf32_x86_64 -z report-relative-reloc -o dump report-reloc-1.o
dump: R_X86_64_IRELATIVE (offset: 0x00002f68, info: 0x00000025, addend: 0x00001007) against 'ifunc' for section '.data.rel.ro.local' in report-reloc-1.o
dump: R_X86_64_RELATIVE (offset: 0x00002f70, info: 0x00000008, addend: 0x00001000) against '_start' for section '.data.rel.ro.local' in report-reloc-1.o
[hjl@gnu-cfl-2 tmpdir]$

It can be used to map relative relocations to corresponding symbols.

bfd/

	* elf-linker-x86.h (elf_linker_x86_params): Add
	report_relative_reloc.
	* elf32-i386.c (elf_i386_relocate_section): Call
	_bfd_x86_elf_link_report_relative_reloc to report relative
	relocations for -z report-relative-reloc.
	(elf_i386_finish_dynamic_symbol): Likewse.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewse.
	(elf_x86_64_finish_dynamic_symbol): Likewse.
	* elfxx-x86.c (_bfd_x86_elf_link_report_relative_reloc): New
	function.
	* elfxx-x86.h (_bfd_x86_elf_link_report_relative_reloc): New
	prototype.

ld/

	* NEWS: Mention -z report-relative-reloc.
	* ld.texi: Document -z report-relative-reloc.
	* emulparams/elf32_x86_64.sh: Source x86-report-relative.sh.
	* emulparams/elf_i386.sh: Likewse.
	* emulparams/elf_x86_64.sh: Likewse.
	* emulparams/x86-report-relative.sh: New file.
	* testsuite/ld-i386/report-reloc-1.d: Likewse.
	* testsuite/ld-i386/report-reloc-1.l: Likewse.
	* testsuite/ld-i386/report-reloc-1.s: Likewse.
	* testsuite/ld-x86-64/report-reloc-1-x32.d: Likewse.
	* testsuite/ld-x86-64/report-reloc-1.d: Likewse.
	* testsuite/ld-x86-64/report-reloc-1.l: Likewse.
	* testsuite/ld-x86-64/report-reloc-1.s: Likewse.
	* testsuite/ld-i386/i386.exp: Run report-reloc-1.
	* testsuite/ld-x86-64/x86-64.exp: Run report-reloc-1 and
	report-reloc-1-x32.
2021-01-15 18:07:07 -08:00
Alan Modra
eb6e6af8c1 PR26002 undefined symbol VER_NDX_GLOBAL vs. VER_NDX_LOCAL
This patch makes undefined unversioned dynamic symbols use
VER_NDX_GLOBAL (version 1) rather than VER_NDX_LOCAL (version 0).
There really isn't much use for an undefined local dynamic symbol, so
we may as well use the logically correct value in .gnu.version.
https://docs.oracle.com/cd/E26505_01/html/E26506/chapter6-54676.html

bfd/
	PR 26002
	* elflink.c (elf_link_output_extsym): Use version 1 in
	.gnu.version for undefined unversioned symbols.
ld/
	PR 26002
	* testsuite/ld-elfvers/vers6.dsym: Expect "Base" for undefined
	unversioned symbols.
	* testsuite/ld-elfvers/vers16.dsym: Likewise.
2021-01-16 11:11:51 +10:30
Nelson Chu
b800637e76 RISC-V: Error and warning messages tidy.
Error and warning messages usually starting with lower case letter,
and without the period at the end.  Besides, add the prefixed "internel:"
at the beginning of the messages when they are caused internally.
Also fix indents and typos.

bfd/
    * elfnn-riscv.c (riscv_merge_attributes): Fix typos of messages.
gas/
    * config/tc-riscv.c: Error and warning messages tidy.
    * testsuite/gas/riscv/priv-reg-fail-fext.l: Updated.
    * testsuite/gas/riscv/priv-reg-fail-read-only-01.l: Likewise.
    * testsuite/gas/riscv/priv-reg-fail-read-only-02.l: Likewise.
    * testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise.
    * testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise.
    * testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise.
    * testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l: Likewise.
ld/
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Updated.
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Likewise.
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Likewise.
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Likewise.
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Likewise.
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Likewise.
opcodes/
    * riscv-dis.c (parse_riscv_dis_option): Fix typos of message.
2021-01-15 17:33:59 +08:00
Nick Clifton
5a10699ff3 Updated translations for some subdirectories 2021-01-14 12:55:25 +00:00
Mike Frysinger
271bea6acd ld: tests: add -msim when testing bfin targets
The Blackfin ELF compiler requires the user to explicitly select a CPU
target else it will fail:
bfin-elf-gcc: error: no processor type specified for linking

Select the sim target for these tests since we should (hopefully) have
access to the simulator.  At least, it's more likely than having access
to a real development board.

This makes the pass/fail numbers increase by a lot:
-# of expected passes        398
-# of unexpected failures    6
+# of expected passes        587
+# of unexpected failures    109

It looks like the vast majority of new failures are due to our omission
of COPY relocations:
  /* Bfin does not currently have a COPY reloc.  */
  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
    {
      _bfd_error_handler (_("the bfin target does not currently support the generation of copy relocations"));
      return FALSE;
    }

There doesn't seem to be a way to easily disable tests that cause copy
relocations though, lets just take the hit for now.

	* testsuite/config/default.exp [bfin*-elf*] (gcc_B_opt): Append -msim.
2021-01-14 01:09:48 -05:00
Alan Modra
4120e4885b Re: SHF_LINK_ORDER fixup_link_order in ld
PR 27160
	* ldelfgen.c (compare_link_order): Protect access of ELF section
	data.
	(add_link_order_input_section): Remove redundant NULL check.
	Use bfd_get_flavour.
	(ldelf_map_segments): Use bfd_get_flavour.
2021-01-14 08:51:29 +10:30
H.J. Lu
b634d11d61 ld: Check for ELF input before accessing ELF section data
commit b209b5a6b8 accesses ELF section data without checking if input is
ELF.  It caused:

sh: line 1: 1355479 Segmentation fault      (core dumped) /export/build/gnu/tools-build/binutils-gitlab-x32/build-x86_64-linux-gnux32/ld/ld-new -o tmpdir/pe-x86-64-1 -z norelro -L/export/gnu/import/git/gitlab/x86-binutils/ld/testsuite/ld-x86-64 -m elf_x86_64 --entry=begin tmpdir/pe-x86-64-1a.obj tmpdir/pe-x86-64-1b.obj tmpdir/pe-x86-64-1c.obj 2>&1
FAIL: Build pe-x86-64-1

on Linux/x86-64 with PE/x86-64 inputs.  Add check for ELF input before
accessing ELF section data.

	* ldelfgen.c (add_link_order_input_section): Check for ELF input
	before accessing ELF section data.
2021-01-13 06:48:20 -08:00
Alan Modra
5347ed60c5 Regen Makefile.in for jobserver.m4 aclocal.m4 dependency
bfd/
	* Makefile.in: Regenerate.
	* doc/Makefile.in: Regenerate.
binutils/
	* Makefile.in: Regenerate.
	* doc/Makefile.in: Regenerate.
gas/
	* Makefile.in: Regenerate.
	* Makefile.in: Regenerate.
gprof/
	* Makefile.in: Regenerate.
ld/
	* Makefile.in: Regenerate.
libctf/
	* Makefile.in: Regenerate.
opcodes/
	* Makefile.in: Regenerate.
2021-01-13 22:06:02 +10:30
Alan Modra
b209b5a6b8 SHF_LINK_ORDER fixup_link_order in ld
This moves the SHF_LINK_ORDER sorting from bfd_elf_final_link to
the linker which means generic ELF targets now support SHF_LINK_ORDER
and  we cope with odd cases that require resizing of output sections.
The patch also fixes two bugs in the current implementation,
introduced by commit cd6d537c48.  The pattern test used by that
commit meant that sections matching something like
"*(.IA_64.unwind* .gnu.linkonce.ia64unw.*)" would not properly sort a
mix of sections matching the two wildcards.  That commit also assumed
a stable qsort.

bfd/
	PR 27160
	* section.c (struct bfd_section): Remove pattern field.
	(BFD_FAKE_SECTION): Adjust to suit.
	* bfd-in2.h: Regenerate.
	* elflink.c (compare_link_order, elf_fixup_link_order): Delete.
	(bfd_elf_final_link): Don't call elf_fixup_link_order.
ld/
	PR 27160
	* ldlang.h (lang_output_section_statement_type): Add data field.
	(lang_input_section_type, lang_section_bst_type): Add pattern field.
	(statement_list): Declare.
	(lang_add_section): Adjust prototype.
	* emultempl/aarch64elf.em: Adjust lang_add_section calls.
	* emultempl/armelf.em: Likewise.
	* emultempl/beos.em: Likewise.
	* emultempl/cskyelf.em: Likewise.
	* emultempl/hppaelf.em: Likewise.
	* emultempl/m68hc1xelf.em: Likewise.
	* emultempl/metagelf.em: Likewise.
	* emultempl/mipself.em: Likewise.
	* emultempl/mmo.em: Likewise.
	* emultempl/msp430.em: Likewise.
	* emultempl/nios2elf.em: Likewise.
	* emultempl/pe.em: Likewise.
	* emultempl/pep.em: Likewise.
	* emultempl/ppc64elf.em: Likewise.
	* emultempl/spuelf.em: Likewise.
	* emultempl/vms.em: Likewise.
	* ldelf.c: Likewise.
	* ldelfgen.c: Include ldctor.h.
	(struct os_sections): New.
	(add_link_order_input_section, link_order_scan): New functions.
	(compare_link_order, fixup_link_order): New functions.
	(ldelf_map_segments): Call link_order_scan and fixup_link_order.
	* ldlang.c (statement_list): Make global.
	(output_section_callback_fast): Save pattern in tree node.
	(lang_add_section): Add pattern parameter, save in lang_input_section.
	(output_section_callback_tree_to_list): Adjust lang_add_section calls.
	(lang_insert_orphan, output_section_callback): Likewise.
	(ldlang_place_orphan): Likewise.
	(gc_section_callback): Don't set section->pattern
	* testsuite/ld-elf/pr26256-2a.d: Don't xfail generic.
	* testsuite/ld-elf/pr26256-3b.d: Likewise.
	* testsuite/ld-elf/pr26256-2b.d: Likewise.  notarget xgate.
2021-01-13 22:06:02 +10:30
Alan Modra
8c4645b488 Remove sflag_info param from wild callback functions
* ldlang.h (callback_t): Remove flag_info function parameter.
	* ldlang.c (walk_wild_consider_section): Adjust to suit.
	(walk_wild_section_general): Likewise.
	(output_section_callback_fast, output_section_callback): Likewise.
	(check_section_callback, gc_section_callback): Likewise.
	(find_relro_section_callback): Likewise.
2021-01-13 22:01:20 +10:30
H.J. Lu
d546b61084 Implement a workaround for GNU mak jobserver
Compiling binutils using -flto=jobserver with GCC 11 leads to

libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Wwrite-strings -I../../gas/../zlib -g -O2 -fprofile-generate -flto=jobserver -o as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o symbols.o write.o config/tc-i386.o config/obj-elf.o config/atof-ieee.o  ../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a -L/tmp/binutils-gdb/objdir/zlib -lz ../libiberty/libiberty.a -ldl
lto-wrapper: warning: jobserver is not available: '--jobserver-auth=' is not present in 'MAKEFLAGS'

since the '+' is missing on the recipe line in Makefiles generated by
automake.  Add the '+' to the recipe line by hand.

bfd/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

binutils/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

config/

	PR binutils/26792
	* jobserver.m4: New file.

gas/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

gprof/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

ld/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

libctf/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

opcodes/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.
2021-01-12 05:45:44 -08:00
H.J. Lu
c2e9a4a3ed elf/x86-64: Adjust R_AMD64_DIR64/R_AMD64_DIR32 for PE/x86-64 inputs
Subtract the value of the section contents for R_AMD64_DIR64 and
R_AMD64_DIR32 relocations when generating ELF output from PE/x86-64
inputs.

bfd/

	PR ld/27171
	* reloc.c (bfd_perform_relocation): Adjust R_AMD64_DIR64 and
	R_AMD64_DIR32 relocations for PE/x86-64 inputs.

ld/

	PR ld/27171
	* testsuite/ld-x86-64/pe-x86-64-5.obj.bz2: New file.
	* testsuite/ld-x86-64/pe-x86-64-5.od: Likewise.
	* testsuite/ld-x86-64/pe-x86-64-5.rd: Likewise.
	* testsuite/ld-x86-64/pe-x86-64.exp: Run PR ld/27171 test.
2021-01-12 05:19:24 -08:00
H.J. Lu
83b33c6cb9 Binutils: Check if AR works with --plugin and rc
Check if AR works with --plugin and rc before passing --plugin to AR and
RANLIB.

bfd/

	PR ld/27173

binutils/

	PR ld/27173
	* configure: Regenerated.

gas/

	PR ld/27173
	* configure: Regenerated.

gprof/

	PR ld/27173
	* configure: Regenerated.

ld/

	PR ld/27173
	* configure: Regenerated.

libctf/

	PR ld/27173
	* configure: Regenerated.

opcodes/

	PR ld/27173
	* configure: Regenerated.
2021-01-11 16:29:45 -08:00
Matt Jenkins
c0f6e439cc Add support for more MIPS variants to the linker command line.
PR ld/27167
	* ldmain.c (get_emulation): Add mipsmips32r3, mips32r5, mips64r3
	and mips64r5 to list of known mips targets.
2021-01-11 14:31:55 +00:00
Nick Clifton
a8aa72b913 Updated translations for multiple subdirectories 2021-01-11 12:55:33 +00:00
H.J. Lu
a4966cd965 Binutils: Pass --plugin to AR and RANLIB
Detect GCC LTO plugin.  Pass --plugin to AR and RANLIB to support LTO
build.

bfd/

	* configure: Regenerated.

binutils/

	* configure: Regenerated.

gas/

	* configure: Regenerated.

gprof/

	* configure: Regenerated.

ld/

	* configure: Regenerated.

libctf/

	* configure: Regenerated.

opcodes/

	* configure: Regenerated.
2021-01-09 06:51:51 -08:00
H.J. Lu
0a94990bf6 ld/x86-64: Properly Handle -z lam-u48/lam-u57
Properly merge GNU properties for LAM_U48 and LAM_U57.

bfd/

	PR ld/27166
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Handle
	-z lam-u48 and -z lam-u57.

ld/

	PR ld/27166
	* testsuite/ld-x86-64/lam-u48.rd: New file.
	* testsuite/ld-x86-64/lam-u57.rd: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Add PR ld/27166 tests.
2021-01-09 06:13:11 -08:00
Nick Clifton
573fe3fbc1 Change version number to 2.36.50 and regenerate files 2021-01-09 11:01:01 +00:00
Nick Clifton
055bc77a80 Add Changelog entries and NEWS entries for 2.36 branch 2021-01-09 10:40:28 +00:00
H.J. Lu
ba9e922fa0 ld/x86-64: Also set LAM_U57 when setting LAM_U48
Since LAM_U48 implies LAM_U57, also set LAM_U57 when setting LAM_U48.

bfd/

	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Also set
	LAM_U57 when setting LAM_U48.

ld/

	* ld-x86-64/property-x86-lam-u48-4.d: Updated.
	* ld-x86-64/property-x86-lam-u48-5.d: Likewise.
2021-01-08 21:51:48 -08:00
Alan Modra
6430704567 configure regen
commit f478212851 did the regen by hand, missed a change in
ld/configure and didn't update line numbers.  Fix that, and an old
regen of ld/Makefile.in with the wrong automake.

bfd/
	* configure: Regenerate.
binutils/
	* configure: Regenerate.
gas/
	* configure: Regenerate.
gprof/
	* configure: Regenerate.
ld/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
libctf/
	* configure: Regenerate.
opcodes/
	* configure: Regenerate.
zlib/
	* configure: Regenerate.
2021-01-09 15:12:44 +10:30
Samuel Thibault
f478212851 libtool.m4: update GNU/Hurd test from upstream. In upstream libtool, 47a889a4ca20 ("Improve GNU/Hurd support.") fixed detection of shlibpath_overrides_runpath, thus avoiding unnecessary relink. This backports it.
.	* libtool.m4: Match gnu* along other GNU systems.

*/ChangeLog:

	* configure: Re-generate.
2021-01-07 16:47:36 +00:00
H.J. Lu
d1bcae833b ELF: Don't generate unused section symbols
For ELF targets, section symbols are required only for relocations.
With -ffunction-sections -fdata-sections, there can be many unused
section symbols.  Sizes of libstdc++.a on Linux/x86-64 in GCC 11 are

With unused section symbols   : 39411698 bytes
Without unused section symbols: 39227002 bytes

The unused section symbols in libstdc++.a occupy more than 180 KB.

Add BSF_SECTION_SYM_USED to indicate if a section symbol should be
included in the symbol table.  The BSF_SECTION_SYM_USED should be set
if the section symbol is used for relocation or the section symbol is
always included in the symbol table.

Add keep_unused_section_symbols to bfd_target to indicate if unused
section symbols should be kept.  If TARGET_KEEP_UNUSED_SECTION_SYMBOLS
is defined as FALSE, unused ection symbols will be removed.

Tested on Linux/x86.  Other ELF backends need to:

1. Define TARGET_KEEP_UNUSED_SECTION_SYMBOLS to FALSE.
2. Mark used section symbols in assembler backend.
3. Remove unused section symbols from expected assembler and linker
outputs.

bfd/

	PR 27109
	* aix386-core.c (core_aix386_vec): Initialize
	keep_unused_section_symbol to TARGET_KEEP_UNUSED_SECTION_SYMBOLS.
	* aout-target.h (MY (vec)): Likewise.
	* binary.c (binary_vec): Likewise.
	* cisco-core.c (core_cisco_be_vec): Likewise.
	(core_cisco_le_vec): Likewise.
	* coff-alpha.c (alpha_ecoff_le_vec): Likewise.
	* coff-i386.c (TARGET_SYM): Likewise.
	(TARGET_SYM_BIG): Likewise.
	* coff-ia64.c (TARGET_SYM): Likewise.
	* coff-mips.c (mips_ecoff_le_vec): Likewise.
	(mips_ecoff_be_vec): Likewise.
	(mips_ecoff_bele_vec): Likewise.
	* coff-rs6000.c (rs6000_xcoff_vec): Likewise.
	(powerpc_xcoff_vec): Likewise.
	* coff-sh.c (sh_coff_small_vec): Likewise.
	(sh_coff_small_le_vec): Likewise.
	* coff-tic30.c (tic30_coff_vec): Likewise.
	* coff-tic54x.c (tic54x_coff0_vec): Likewise.
	(tic54x_coff0_beh_vec): Likewise.
	(tic54x_coff1_vec): Likewise.
	(tic54x_coff1_beh_vec): Likewise.
	(tic54x_coff2_vec): Likewise.
	(tic54x_coff2_beh_vec): Likewise.
	* coff-x86_64.c (TARGET_SYM): Likewise.
	(TARGET_SYM_BIG): Likewise.
	* coff64-rs6000.c (rs6000_xcoff64_vec): Likewise.
	(rs6000_xcoff64_aix_vec): Likewise.
	* coffcode.h (CREATE_BIG_COFF_TARGET_VEC): Likewise.
	(CREATE_BIGHDR_COFF_TARGET_VEC): Likewise.
	(CREATE_LITTLE_COFF_TARGET_VEC): Likewise.
	* elfxx-target.h (TARGET_BIG_SYM): Likewise.
	(TARGET_LITTLE_SYM): Likewise.
	* hppabsd-core.c (core_hppabsd_vec): Likewise.
	* hpux-core.c (core_hpux_vec): Likewise.
	* i386msdos.c (i386_msdos_vec): Likewise.
	* ihex.c (ihex_vec): Likewise.
	* irix-core.c (core_irix_vec): Likewise.
	* mach-o-target.c (TARGET_NAME): Likewise.
	* mmo.c (mmix_mmo_vec): Likewise.
	* netbsd-core.c (core_netbsd_vec): Likewise.
	* osf-core.c (core_osf_vec): Likewise.
	* pdp11.c (MY (vec)): Likewise.
	* pef.c (pef_vec): Likewise.
	(pef_xlib_vec): Likewise.
	* plugin.c (plugin_vec): Likewise.
	* ppcboot.c (powerpc_boot_vec): Likewise.
	* ptrace-core.c (core_ptrace_vec): Likewise.
	* sco5-core.c (core_sco5_vec): Likewise.
	* som.c (hppa_som_vec): Likewise.
	* srec.c (srec_vec): Likewise.
	(symbolsrec_vec): Likewise.
	* tekhex.c (tekhex_vec): Likewise.
	* trad-core.c (core_trad_vec): Likewise.
	* verilog.c (verilog_vec): Likewise.
	* vms-alpha.c (alpha_vms_vec): Likewise.
	* vms-lib.c (alpha_vms_lib_txt_vec): Likewise.
	* wasm-module.c (wasm_vec): Likewise.
	* xsym.c (sym_vec): Likewise.
	* elf.c (ignore_section_sym): Return TRUE if BSF_SECTION_SYM_USED
	isn't set.
	(elf_map_symbols): Don't include ignored section symbols.
	* elfcode.h (elf_slurp_symbol_table): Also set
	BSF_SECTION_SYM_USED on STT_SECTION symbols.
	* elflink.c (bfd_elf_final_link): Generated section symbols only
	when emitting relocations or reqired.
	* elfxx-x86.h (TARGET_KEEP_UNUSED_SECTION_SYMBOLS): New.
	* syms.c (BSF_SECTION_SYM_USED): New.
	* targets.c (TARGET_KEEP_UNUSED_SECTION_SYMBOLS): New.
	(bfd_target): Add keep_unused_section_symbols.
	(bfd_keep_unused_section_symbols): New.
	* bfd-in2.h: Regenerated.

binutils/

	PR 27109
	* objcopy.c (copy_object): Handle section symbols for
	non-relocatable inputs.
	* testsuite/binutils-all/readelf.exp (readelf_test): Check
	is_elf_unused_section_symbols.
	* testsuite/binutils-all/readelf.s-64: Updated.
	* testsuite/binutils-all/readelf.ss: Likewise.
	* testsuite/binutils-all/readelf.ss-64: Likewise.
	* testsuite/binutils-all/readelf.s-64-unused: New file.
	* testsuite/binutils-all/readelf.ss-64-unused: Likewise.
	* testsuite/binutils-all/readelf.ss-unused: Likewise.
	* testsuite/lib/binutils-common.exp
	(is_elf_unused_section_symbols): New proc.

gas/ChangeLog:

	PR 27109
	* read.c (s_reloc): Call symbol_mark_used_in_reloc on the
	section symbol.
	* subsegs.c (subseg_set_rest): Set BSF_SECTION_SYM_USED if needed.
	* write.c (adjust_reloc_syms): Call symbol_mark_used_in_reloc
	on the section symbol.
	(set_symtab): Don't generate unused section symbols.
	(maybe_generate_build_notes): Call symbol_mark_used_in_reloc
	on the section symbol.
	* config/obj-elf.c (elf_adjust_symtab): Call
	symbol_mark_used_in_reloc on the group signature symbol.
	* testsuite/gas/cfi/cfi-label.d: Remove unused section symbols
	from expected output.
	* testsuite/gas/elf/elf.exp (run_elf_list_test): Check
	is_elf_unused_section_symbols.
	* testsuite/gas/elf/section2.e: Updated.
	* testsuite/gas/elf/section2.e-unused: New file.
	* testsuite/gas/elf/symver.d: Remove unused section symbols.
	* testsuite/gas/i386/ilp32/elf/symver.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-size-1.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-size-3.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-size-5.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-unwind.d: Likewise.
	* testsuite/gas/i386/size-1.d: Likewise.
	* testsuite/gas/i386/size-3.d: Likewise.
	* testsuite/gas/i386/svr4.d: Likewise.
	* testsuite/gas/i386/x86-64-size-1.d: Likewise.
	* testsuite/gas/i386/x86-64-size-3.d: Likewise.
	* testsuite/gas/i386/x86-64-size-5.d: Likewise.
	* testsuite/gas/i386/x86-64-unwind.d: Likewise.

ld/

	PR 27109
	* testsuite/ld-elf/export-class.sd: Adjust the expected output.
	* testsuite/ld-elf/loadaddr3b.d: Likewise.
	* testsuite/ld-i386/ibt-plt-1.d: Likewise.
	* testsuite/ld-i386/ibt-plt-2a.d: Likewise.
	* testsuite/ld-i386/ibt-plt-2c.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3a.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3c.d: Likewise.
	* testsuite/ld-i386/pr19636-1d.d: Likewise.
	* testsuite/ld-i386/pr19636-1l.d: Likewise.
	* testsuite/ld-i386/pr19636-2c.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-21-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-22-x86-64.d: Likewise.
	* testsuite/ld-ifunc/pr17154-i386-now.d: Likewise.
	* testsuite/ld-ifunc/pr17154-i386.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.
	* testsuite/ld-x86-64/bnd-branch-1-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-1-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-2-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-1.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2a.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2c.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3a.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3c.d: Likewise.
	* testsuite/ld-x86-64/pr19609-4e.d: Likewise.
	* testsuite/ld-x86-64/pr19609-6a.d: Likewise.
	* testsuite/ld-x86-64/pr19609-6b.d: Likewise.
	* testsuite/ld-x86-64/pr19609-7b.d: Likewise.
	* testsuite/ld-x86-64/pr19609-7d.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2l.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1d.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1h.d: Likewise.
	* testsuite/ld-x86-64/pr21038b-now.d: Likewise.
	* testsuite/ld-x86-64/pr21038b.d: Likewise.
	* testsuite/ld-x86-64/pr21038c-now.d: Likewise.
	* testsuite/ld-x86-64/pr21038c.d: Likewise.
	* testsuite/ld-x86-64/pr23854.d: Likewise.
	* testsuite/ld-x86-64/pr25416-3.d: Likewise.
	* testsuite/ld-x86-64/pr25416-4.d: Likewise.
	* testsuite/ld-i386/plt-pic.pd: Likewise.
	* testsuite/ld-i386/plt-pic2.dd: Likewise.
	* testsuite/ld-i386/plt.pd: Likewise.
	* testsuite/ld-i386/plt2.dd: Likewise.
	* testsuite/ld-i386/tlsbin.rd: Likewise.
	* testsuite/ld-i386/tlsbin2.rd: Likewise.
	* testsuite/ld-i386/tlsbindesc.rd: Likewise.
	* testsuite/ld-i386/tlsdesc.rd: Likewise.
	* testsuite/ld-i386/tlsgdesc.rd: Likewise.
	* testsuite/ld-i386/tlsnopic.rd: Likewise.
	* testsuite/ld-i386/tlspic.rd: Likewise.
	* testsuite/ld-i386/tlspic2.rd: Likewise.
	* testsuite/ld-x86-64/mpx3.dd: Likewise.
	* testsuite/ld-x86-64/mpx3n.dd: Likewise.
	* testsuite/ld-x86-64/mpx4.dd: Likewise.
	* testsuite/ld-x86-64/mpx4n.dd: Likewise.
	* testsuite/ld-x86-64/pe-x86-64-1.od: Likewise.
	* testsuite/ld-x86-64/pe-x86-64-2.od: Likewise.
	* testsuite/ld-x86-64/pe-x86-64-3.od: Likewise.
	* testsuite/ld-x86-64/pe-x86-64-4.od: Likewise.
	* testsuite/ld-x86-64/plt.pd: Likewise.
	* testsuite/ld-x86-64/plt2.dd: Likewise.
	* testsuite/ld-x86-64/tlsbin.rd: Likewise.
	* testsuite/ld-x86-64/tlsbin2.rd: Likewise.
	* testsuite/ld-x86-64/tlsbindesc.rd: Likewise.
	* testsuite/ld-x86-64/tlsdesc.rd: Likewise.
	* testsuite/ld-x86-64/tlsgdesc.rd: Likewise.
	* testsuite/ld-x86-64/tlspic.rd: Likewise.
	* testsuite/ld-x86-64/tlspic2.rd: Likewise.
	* testsuite/ld-elf/sec64k.exp: Check
	is_elf_unused_section_symbols.
2021-01-07 06:46:55 -08:00
Alan Modra
dc20061339 sh-pe ld XPASSes
* testsuite/ld-scripts/fill.d: Skip sh-*-pe rather than xfail.
	* testsuite/ld-scripts/fill16.d: Don't xfail sh-*-pe.
	* testsuite/ld-scripts/segment-start.d: Likewise.
2021-01-08 00:32:43 +10:30
Alan Modra
8e604ff077 xfail more cases of complaints about relocs in read-only sections
* testsuite/ld-elf/comm-data5.d: xfail targets that complain
	about dynamic relocations in read-only sections.
	* testsuite/ld-elf/ehdr_start-shared.d: Likewise.
	* testsuite/ld-elf/ehdr_start.d: Likewise.
	* testsuite/ld-scripts/pr22267.d: Likewise.
	* testsuite/ld-elf/shared.exp: Likewise for DT_TEXTREL tests and
	pr20995 text.
	* testsuite/ld-elf/sec64k.exp: Don't run 64ksec on lm32-linux.
2021-01-08 00:32:10 +10:30
Marcus Comstedt
4d4490b8d7 ld: xfail riscv64*-*-* for ld-scripts/empty-address-2 tests.
For now we have supported the riscv big endian targets, so
xfail riscv64*-*-* for ld-scripts/empty-address-2 tests, to
cover both little endian and big endian targets.

ld/
    * testsuite/ld-scripts/empty-address-2a.d: xfail riscv64*-*-*.
    * testsuite/ld-scripts/empty-address-2b.d: Likewise.
2021-01-07 15:08:04 +08:00
Alan Modra
f526791a6f Regen ld/po/BLD-POTFILES.in
* po/BLD-POTFILES.in: Regenerate.
2021-01-07 08:56:28 +10:30
Alan Modra
4018f4e0fc ld pr22471 test fails
* testsuite/ld-elf/shared.exp: xfail pr22471 for targets that
	complain about relocs in read-only sections.  Tidy ASFLAGS append.
2021-01-07 08:56:28 +10:30
Alan Modra
3677b72961 sparc-sun-solaris2 and sparc64-sun-solaris2 config
A bunch of ld tests fail on these targets due to the test specifying
-melf32_sparc or -melf64_sparc, which according to ld/configure.tgt
are valid.  However, config.bfd lacks the corresponding bfd target
resulting in an error.  Fix that by adding target_selvecs.

bfd/
	* config.bfd (sparc-*-solaris2*): Add sparc_elf32_vec.
	(sparc64-*-solaris2*): Add sparc_elf64_vec and
	sparc_elf32_vec.
ld/
	* testsuite/ld-sparc/sparc.exp (sparc64tests): Set text-segment
	base for some tests.
	* testsuite/ld-sparc/gotop32.dd: Match solaris output.
	* testsuite/ld-sparc/gotop32.sd: Likewise.
	* testsuite/ld-sparc/gotop32.td: Likewise.
	* testsuite/ld-sparc/gotop64.dd: Likewise.
	* testsuite/ld-sparc/gotop64.sd: Likewise.
	* testsuite/ld-sparc/gotop64.td: Likewise.
	* testsuite/ld-sparc/tlsg32.sd: Likewise.
	* testsuite/ld-sparc/tlsg64.sd: Likewise.
	* testsuite/ld-sparc/tlspie32.dd: Likewise.
	* testsuite/ld-sparc/tlspie64.dd: Likewise.
	* testsuite/ld-sparc/tlssunbin32.dd: Likewise.
	* testsuite/ld-sparc/tlssunbin32.sd: Likewise.
	* testsuite/ld-sparc/tlssunbin32.td: Likewise.
	* testsuite/ld-sparc/tlssunbin64.dd: Likewise.
	* testsuite/ld-sparc/tlssunbin64.sd: Likewise.
	* testsuite/ld-sparc/tlssunbin64.td: Likewise.
	* testsuite/ld-sparc/tlssunnopic32.dd: Likewise.
	* testsuite/ld-sparc/tlssunnopic32.sd: Likewise.
	* testsuite/ld-sparc/tlssunnopic64.dd: Likewise.
	* testsuite/ld-sparc/tlssunnopic64.sd: Likewise.
	* testsuite/ld-sparc/tlssunpic32.dd: Likewise.
	* testsuite/ld-sparc/tlssunpic32.sd: Likewise.
	* testsuite/ld-sparc/tlssunpic32.td: Likewise.
	* testsuite/ld-sparc/tlssunpic64.dd: Likewise.
	* testsuite/ld-sparc/tlssunpic64.sd: Likewise.
	* testsuite/ld-sparc/tlssunpic64.td: Likewise.
	* testsuite/ld-sparc/wdispcall.dd: Likewise.
2021-01-06 21:03:55 +10:30
Alan Modra
73624512cf ld rgn-at10 and rgn-at11 test
These fail on v850 due to that target using different .tbss section flags.

	* testsuite/ld-scripts/rgn-at10.d: xfail v850.
	* testsuite/ld-scripts/rgn-at11.d: Likewise.
2021-01-06 21:03:55 +10:30
Marcus Comstedt
f36ce378b4 RISC-V: Fix riscv gas/ld testsuites failures for big endian.
Add riscv_choose_[ilp32|lp64]_emul, and use them to choose the correct
linker script rather than set elf[32|64]lriscv directly.

gas/
    * testsuite/gas/riscv/li32.d: Accept bigriscv in addition
    to littleriscv.
    * testsuite/gas/riscv/li64.d: Likewise.
    * testsuite/gas/riscv/lla32.d: Likewise.
    * testsuite/gas/riscv/lla64.d: Likewise.
    * testsuite/gas/riscv/march-ok-g2.d: Likewise.
    * testsuite/gas/riscv/march-ok-g2_p1.d: Likewise.
    * testsuite/gas/riscv/march-ok-g2p0.d: Likewise.
    * testsuite/gas/riscv/march-ok-i2p0.d: Likewise.
    * testsuite/gas/riscv/march-ok-i2p0m2_a2f2.d: Likewise.
    * testsuite/gas/riscv/march-ok-nse-with-version.d: Likewise.
    * testsuite/gas/riscv/march-ok-two-nse.d: Likewise.

ld/
    * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Added
    riscv_choose_[ilp32|lp64]_emul to choose the correct linker script.
    * testsuite/ld-riscv-elf/attr-merge-arch-01.d: Call
    riscv_choose_[ilp32|lp64]_emul instead of hardcoding elf[32|64]lriscv.
    * testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise.
    * testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise.
    * testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Likewise.
    * testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d: Likewise.
    * testsuite/ld-riscv-elf/c-lui-2.d: Likewise.
    * testsuite/ld-riscv-elf/c-lui.d: Likewise.
    * testsuite/ld-riscv-elf/call-relax.d: Likewise.
    * testsuite/ld-riscv-elf/pcrel-lo-addend-2.d: Likewise.
    * testsuite/ld-riscv-elf/pcrel-lo-addend.d: Likewise.
    * testsuite/ld-riscv-elf/weakref32.d: Accept bigriscv in addition
    to littleriscv.
    * testsuite/ld-riscv-elf/weakref64.d: Likewise.
2021-01-06 18:01:41 +08:00
Marcus Comstedt
fbc09e7af7 RISC-V: Implement support for big endian targets.
RISC-V instruction/code is always little endian, but data might be
big-endian.  Therefore, we can not use the original bfd_get/bfd_put
to get/put the code for big endian targets.  Add new riscv_get_insn
and riscv_put_insn to always get/put code as little endian can resolve
the problem.  Just remember to update them once we have supported
the 48-bit/128-bit instructions in the future patches.

bfd/
    * config.bfd: Added targets riscv64be*-*-*, riscv32be*-*-* and
    riscvbe*-*-*.  Also added riscv_elf[32|64]_be_vec.
    * configure.ac: Handle riscv_elf[32|64]_be_vec.
    * configure: Regenerate.
    * elfnn-riscv.c: Include <limits.h> and define CHAR_BIT for
    riscv_is_insn_reloc.
    (riscv_get_insn): RISC-V instructions are always little endian, but
    bfd_get may be used for big-endian, so add new riscv_get_insn to handle
    the insturctions.
    (riscv_put_insn): Likewsie.
    (riscv_is_insn_reloc): Check if we are relocaing an instruction.
    (perform_relocation): Call riscv_is_insn_reloc to decide if we should
    use riscv_[get|put]_insn or bfd_[get|put].
    (riscv_zero_pcrel_hi_reloc): Use riscv_[get|put]_insn, bfd_[get|put]l32
    or bfd_[get|put]l16 for code.
    (riscv_elf_relocate_section): Likewise.
    (riscv_elf_finish_dynamic_symbol): Likewise.
    (riscv_elf_finish_dynamic_sections): Likewise.
    (_bfd_riscv_relax_call): Likewise.
    (_bfd_riscv_relax_lui): Likewise.
    (_bfd_riscv_relax_align): Likewise.
    (_bfd_riscv_relax_pc): Likewise.
    (riscv_elf_object_p): Handled for big endian.
    (TARGET_BIG_SYM, TARGET_BIG_NAME): Defined.
    * targets.c: Add riscv_elf[32|64]_be_vec.
    (_bfd_target_vector): Likewise.

gas/
    * config/tc-riscv.c (riscv_target_format): Add elf64-bigriscv and
    elf32-bigriscv.
    (install_insn): Always write instructions as little endian.
    (riscv_make_nops): Likewise.
    (md_convert_frag_branch): Likewise.
    (md_number_to_chars): Write data in target endianness.
    (options, md_longopts): Add -mbig-endian and -mlittle-endian options.
    (md_parse_option): Handle the endian options.
    * config/tc-riscv.h: Only define TARGET_BYTES_BIG_ENDIAN if not
    already defined.
    * configure.tgt: Added riscv64be*, riscv32be*, riscvbe*.

ld/
    * configure.tgt: Added riscvbe-*-*, riscv32be*-*-*, riscv64be*-*-*,
    riscv32be*-*-linux*, and riscv64be*-*-linux*.
    * Makefile.am: Added eelf32briscv.c, eelf32briscv_ilp32f.c and
    eelf32briscv_ilp32.c.
    * Makefile.in: Regenerate.
    * emulparams/elf32briscv.sh: Added.
    * emulparams/elf32briscv_ilp32.sh: Likewise.
    * emulparams/elf32briscv_ilp32f.sh: Likewise.
    * emulparams/elf64briscv.sh: Likewise.
    * emulparams/elf64briscv_lp64.sh: Likewise.
    * emulparams/elf64briscv_lp64f.sh: Likewise.
2021-01-06 17:57:52 +08:00
Nick Alcock
b4b6ea4680 libctf, ld: fix formatting of forwards to unions and enums
The type printer was unconditionally printing these as if they were
forwards to structs, even if they were forwards to unions or enums.

ld/ChangeLog
2021-01-05  Nick Alcock  <nick.alcock@oracle.com>

	* testsuite/ld-ctf/enum-forward.c: New test.
	* testsuite/ld-ctf/enum-forward.c: New results.

libctf/ChangeLog
2021-01-05  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-types.c (ctf_type_aname): Print forwards to unions and enums
	properly.
2021-01-05 14:53:40 +00:00