Commit Graph

2370 Commits

Author SHA1 Message Date
Alan Modra
eb14a8b4bf [GOLD] reporting local symbol names
get_symbol_name currently returns "" for the usual STT_SECTION symbols
generated by gas.  That's not very helpful, return the section name.
Demangle local symbols too, fixing an inconsistency in
issue_discarded_error where global symbols are demangled.

	* object.cc (Sized_relobj_file::get_symbol_name): Return a
	std::string.  Return section name for STT_SECTION symbols with
	zero st_name.  Sanity check st_name, and don't run off the end
	of an improperly terminated .strtab.  Demangle sym names.
	* object.h (Sized_relobj_file::get_symbol_name): Update decl.
	* target-reloc.h (issue_discarded_error): Adjust.
	* powerpc.cc (Target_powerpc::Relocate::relocate): Report reloc
	type and symbol for relocation overflows.
2023-07-26 10:23:27 +09:30
Nick Clifton
4701770c57 Updated translations for bfd, gold and opcodes 2023-07-24 09:13:29 +01:00
Alan Modra
03c02b696e [GOLD, PowerPC64] Debug info relocation overflow
It is possible to build huge binaries on powerpc64, where 32-bit
addresses in debug info are insufficient to descibe locations in the
binary.  Help out the user, and only warn about debug overflows.

	* powerpc.cc (Target_powerpc::Relocate::relocate): Warn on
	relocation overflows in debug info.
2023-07-19 11:07:03 +09:30
Alan Modra
02d2a36902 PR10957, Missing option to really print section+offset
Many of the reloc error messages have already been converted from
using %C to using %H in ld.bfd, to print section+offset as well as
file/line/function.  This catches a few remaining, and changes gold to
do the same.

	PR 10957
bfd/
	* elf32-sh.c (sh_elf_relocate_section): Use %H in error messages.
gold/
	* object.cc (Relocate_info::location): Always report section+offset.
	* testsuite/debug_msg.sh: Adjust to suit.
	* testsuite/x32_overflow_pc32.sh: Likewise.
	* testsuite/x86_64_overflow_pc32.sh: Likewise.
ld/
	* emultempl/pe.em (read_addend): Use %H in error message.
	* emultempl/pep.em (read_addend): Likewise.
	* ldcref.c (check_reloc_refs): Likewise.
	* ldmain.c (warning_find_reloc, undefined_symbol): Likewise.
	* pe-dll.c (pe_create_import_fixup): Likewise.
	* testsuite/ld-cris/undef2.d: Adjust expected output to suit.
	* testsuite/ld-cris/undef3.d: Likewise.
	* testsuite/ld-elf/shared.exp: Likewise.
	* testsuite/ld-i386/compressed1.d: Likewise.
	* testsuite/ld-ia64/line.exp: Likewise.
	* testsuite/ld-plugin/lto.exp: Likewise.
	* testsuite/ld-undefined/undefined.exp: Likewise.
	* testsuite/ld-x86-64/compressed1.d: Likewise.
	* testsuite/ld-x86-64/line.exp: Likewise.
	* testsuite/ld-x86-64/pr27587.err: Likewise.
2023-07-17 08:17:44 +09:30
Nick Clifton
3baacfd61d Udated Freach and Romainian translations for various sub-directories 2023-07-07 09:40:20 +01:00
Nick Clifton
a34339a82f Updated Ukranian, Romanian and German translations for various sub-directories 2023-07-04 11:55:27 +01:00
Nick Clifton
87485f5349 Change version number to 2.41.50 and regenerate files 2023-07-03 11:54:06 +01:00
Nick Clifton
d501d38488 Add markers for the 2.41 branch 2023-07-03 11:12:15 +01:00
Nick Clifton
8527c36694 Updated French translation for the gold sub-directory 2023-06-28 11:43:13 +01:00
Alan Modra
5a97377e55 [GOLD] PowerPC64 huge branch dynamic relocs
PowerPC64 gold and ld.bfd implement an indirect branch trampoline,
used when the destination of a branch exceeds a bounce through another
"b" instruction.  When generating PIEs or shared libraries, the
addresses need dynamic relocations.  This was implemented in gold
using a dedicated relocation section, but this means the relative
relocations for these addresses are not sorted properly with other
dynamic relative relocations: gold doesn't support merging relocation
sections, then sorting.  Instead we need to use a single .rela.dyn
section.

This is done by increasing the size of rela_dyn_ during do_relax to
account for needed dynamic relocations, delaying adding the actual
relocations until the end of relaxation once the layout has
stabilised.

	* powerpc.cc (Target_powerpc): Add rela_dyn_size_;
	(update_current_size): New function.
	(Target_powerpc::do_relax): Capture the size of rela_dyn_ at
	the start of relaxation.  Artifically increase its size during
	relaxation to account for needed indirect branches, and add
	those relocations at the end.
	(Output_data_brlt_powerpc::rel_, reset_brlt_sizes),
	(finalize_brlt_sizes, add_reloc, set_current_size): Delete.
	(Target_powerpc::make_brlt_section): Don't make reloc section.
2023-06-23 21:02:48 +09:30
Alan Modra
bdad2ad579 [GOLD] Support setting DT_RELACOUNT late
PowerPC gold adds relative dynamic relocs in do_relax.  These aren't
accounted for in the value set in add_target_dynamic_tags, which is
called before do_relax.  Provide a way of setting DT_RELCOUNT and
DT_RELACOUNT at the point where .dynamic is written.

	* layout.cc (Layout::add_target_dynamic_tags): Add custom_relcount
	parameter.  Emit DT_RELCOUNT/RELACOUNT as a custom target handled
	dynamic tag if set.
	* layout.h(Layout::add_target_dynamic_tags): Update prototype.
	* aarch64.cc (Target_aarch64::do_finalize_sections): Adjust
	add_target_dynamic_tags call.
	* arm.cc (Target_arm::do_finalize_sections): Likewise.
	* i386.cc (Target_i386::do_finalize_sections): Likewise.
	* mips.cc (Target_mips::do_finalize_sections): Likewise.
	* s390.cc (Target_s390::do_finalize_sections): Likewise.
	* sparc.cc (Target_sparc::do_finalize_sections): Likewise.
	* tilegx.cc (Target_tilegx::do_finalize_sections): Likewise.
	* x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.
	* powerpc.cc (Target_powerpc::do_finalize_sections): Likewise.
	(Target_powerpc::do_dynamic_tag_custom_value): New function.
2023-06-23 21:02:48 +09:30
Alan Modra
027614abf1 [GOLD] powerpc DT_RELACOUNT
DT_RELACOUNT was calculated incorrectly, and relative relocs not
sorted as they should be to the start of .rela.dyn, due to adding one
particular class of dynamic reloc using the wrong "add" method.

	* powerpc.cc (Target_powerpc::Scan::global): Add relative
	dyn relocs for ADDR64 and similar using add_global_relative.
2023-06-23 21:02:48 +09:30
Alan Modra
dc808a2eba PR30536, ppc64el gold linker produces unusable clang-16 binary
In commit 0961e63157, the fix for PR30217, make_lplt_section and
make_brlt_section were changed to use rela_dyn_ rather than their own
separate dynamic reloc sections.  This fails miserably whenever brlt_
is needed for long branches, due to needing to iterate sizing and thus
reset brlt_ sizes.

	PR 30536
	PR 30217
	* powerpc.cc (Target_powerpc::make_brlt_section): Don't use
	rela_dyn_.
2023-06-21 23:02:29 +09:30
YunQiang Su
32f1c80375 MIPS: support mips*64 as CPU and gnuabi64 as ABI
For MIPS64r6 ports, Debian as an example, `mipsisa64r6el` is
used as the cpu name in triple.
Let's recognize them by `mips*64*(el)`.

For 64bit Ports, like Debian's mips64el and mips64r6el ports,
`gnuabi64` is used as the abi section.
Let's use N64 abi by default for the triple with gnuabi64.
2023-04-23 14:32:43 +08:00
Nick Clifton
eb42b9d6f9 Add an option to the gold linker to put its version string into the .comment section.
PR 30187
  * options.h (class General_options): Add enable-linker-version.
  * layout.cc (Layout::create_gold_note): If linker-version is enabled put the version string into the .comment section.
2023-03-27 11:10:10 +01:00
Alan Modra
0961e63157 PR30217, dynamic relocations using local dynamic symbols
glibc's ld.so ignores local dynamic symbols.  It's been that way
forever.  We therefore can't use them on dynamic relocations.  Fixing
that problem uncovered another problem in sorting of dynamic relocs,
caused no doubt by copying make_iplt_section (where we don't want
reloc sorting by the generic gold function, we want iplt relocs last)
to make_lplt_section (where we do want sorting).

	PR 30217
	* powerpc.cc (branch_needs_plt_entry): New function.
	(Target_powerpc::plt_off): Use it here..
	(Target_powerpc::Scan::global): ..and here to correct PLT16 reloc
	handling for forced-local global symbols.
	(Output_data_plt_powerpc::add_entry): Rename "stash"
	parameter "is_local".  Emit relative relocs for globals that
	are forced local, and don't set_needs_dynsym_entry.
	(Target_powerpc::make_lplt_section): Don't create a separate
	reloc section, use rela_dyn.
	(Target_powerpc::make_brlt_section): Likewise.
2023-03-16 11:11:44 +10:30
Nick Clifton
85b922fcdd Updated Serbian translations for gold, gprof and opcodes sub-directories 2023-02-27 12:50:31 +00:00
Alan Modra
4981a31d52 Use __func__ rather than __FUNCTION__
We already use C99's __func__ in places, use it more generally.  This
patch doesn't change uses in the testsuite.  I've also left one in
gold.h that is protected by GCC_VERSION < 4003.  If any of the
remaining uses bothers anyone I invite patches.

bfd/
	* bfd-in.h: Replace __FUNCTION__ with __func__.
	* elf32-bfin.c: Likewise.
	* elfnn-aarch64.c: Likewise.
	* elfxx-sparc.c: Likewise.
	* bfd-in2.h: Regenerate.
gas/
	* config/tc-cris.c: Replace __FUNCTION__ with __func__.
	* config/tc-m68hc11.c: Likewise.
	* config/tc-msp430.c: Likewise.
gold/
	* dwp.h: Replace __FUNCTION__ with __func__.
	* gold.h: Likewise, except for use inside GCC_VERSION < 4003.
ld/
	* emultempl/pe.em: Replace __FUNCTION__ with __func__.
	* emultempl/pep.em: Likewise.
	* pe-dll.c: Likewise.
2023-01-12 17:20:21 +10:30
Nick Clifton
11982f9f8b Updated translations for various languages and sub-directories 2023-01-03 11:32:42 +00:00
Alan Modra
d87bef3a7b 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-01 21:50:11 +10:30
Nick Clifton
a72b07181d Add markers for 2.40 branch 2022-12-31 12:05:28 +00:00
Nick Clifton
d14b3ea1c8 New Romainian translation for the GOLD subdirectory. 2022-12-19 09:47:36 +00:00
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
Martin Liska
8ad93045ed ld, gold: remove support for -z bndplt (MPX prefix)
bfd/ChangeLog:

	* elf-linker-x86.h (struct elf_linker_x86_params): Remove
	bndplt.
	* elf64-x86-64.c (elf_x86_64_scan_relocs): Ignore
        R_X86_64_PLT32_BND.
	(elf_x86_64_relocate_section): Similarly here.
	(elf_x86_64_link_setup_gnu_properties): Ignore bndplt.
	* elfxx-x86.c: Likewise.
	* elfxx-x86.h: Likewise.

gold/ChangeLog:

	* NEWS: Document -z bndplt.
	* options.h (class General_options): Remove bndplt option.
	* x86_64.cc (class Output_data_plt_x86_64_bnd): Remove.
	(Target_x86_64::do_make_data_plt): Do not use
	Output_data_plt_x86_64_bnd.
	(Target_x86_64::Scan::get_reference_flags): Likewise.
	(Target_x86_64::Scan::check_non_pic): Likewise.
	(Target_x86_64::Scan::local): Likewise.
	(Target_x86_64::Scan::global): Likewise.

ld/ChangeLog:

	* NEWS: Document -z bndplt.
	* emulparams/elf_x86_64.sh: Remove bndplt option.
	* ld.texi: Likewise.
	* testsuite/ld-x86-64/x86-64.exp:
	* testsuite/ld-x86-64/bnd-branch-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-branch-1.d: Removed.
	* testsuite/ld-x86-64/bnd-branch-1.s: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1.s: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2-now.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2.s: Removed.
	* testsuite/ld-x86-64/bnd-plt-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-plt-1.d: Removed.
	* testsuite/ld-x86-64/mpx.exp: Removed.
	* testsuite/ld-x86-64/mpx1.out: Removed.
	* testsuite/ld-x86-64/mpx1a.c: Removed.
	* testsuite/ld-x86-64/mpx1a.rd: Removed.
	* testsuite/ld-x86-64/mpx1b.c: Removed.
	* testsuite/ld-x86-64/mpx1c.c: Removed.
	* testsuite/ld-x86-64/mpx1c.rd: Removed.
	* testsuite/ld-x86-64/mpx2.out: Removed.
	* testsuite/ld-x86-64/mpx2a.c: Removed.
	* testsuite/ld-x86-64/mpx2a.rd: Removed.
	* testsuite/ld-x86-64/mpx2b.c: Removed.
	* testsuite/ld-x86-64/mpx2c.c: Removed.
	* testsuite/ld-x86-64/mpx2c.rd: Removed.
	* testsuite/ld-x86-64/mpx3.dd: Removed.
	* testsuite/ld-x86-64/mpx3a.s: Removed.
	* testsuite/ld-x86-64/mpx3b.s: Removed.
	* testsuite/ld-x86-64/mpx3n.dd: Removed.
	* testsuite/ld-x86-64/mpx4.dd: Removed.
	* testsuite/ld-x86-64/mpx4a.s: Removed.
	* testsuite/ld-x86-64/mpx4b.s: Removed.
	* testsuite/ld-x86-64/mpx4n.dd: Removed.
	* testsuite/ld-x86-64/pr20800a.S: Removed.
	* testsuite/ld-x86-64/pr20800b.S: Removed.
	* testsuite/ld-x86-64/pr21038a-now.d: Removed.
	* testsuite/ld-x86-64/pr21038a.d: Removed.
	* testsuite/ld-x86-64/pr21038a.s: Removed.
	* testsuite/ld-x86-64/pr21038b-now.d: Removed.
	* testsuite/ld-x86-64/pr21038b.d: Removed.
	* testsuite/ld-x86-64/pr21038b.s: Removed.
	* testsuite/ld-x86-64/pr21038c-now.d: Removed.
	* testsuite/ld-x86-64/pr21038c.d: Removed.
	* testsuite/ld-x86-64/pr21038c.s: Removed.
2022-12-14 08:48:13 +01:00
H.J. Lu
1bf337caba gold: Remove BND from 64-bit x86-64 IBT PLT
Since MPX support has been removed from x86-64 psABI, remove BND from
64-bit IBT PLT by using 32-bit IBT PLT.

	PR gold/29851
	* x86_64.cc (Output_data_plt_x86_64_ibt<32>::first_plt_entry):
	Renamed to ...
	(Output_data_plt_x86_64_ibt<size>::first_plt_entry): This.
	(Output_data_plt_x86_64_ibt<64>::first_plt_entry): Removed.
	(Output_data_plt_x86_64_ibt<size>::do_fill_first_plt_entry):
	Drop the size == 32 check.
	(Output_data_plt_x86_64_ibt<32>::plt_entry): Renamed to ...
	(Output_data_plt_x86_64_ibt<size>::plt_entry): This.
	(Output_data_plt_x86_64_ibt<64>::plt_entry): Removed.
	(Output_data_plt_x86_64_ibt<32>::aplt_entry): Renamed to ...
	(Output_data_plt_x86_64_ibt<size>::aplt_entry): This.
	(Output_data_plt_x86_64_ibt<64>::aplt_entry): Removed.
	(Output_data_plt_x86_64_ibt<size>::do_fill_plt_entry): Drop the
	size == 32 check.
	(Output_data_plt_x86_64_ibt<size>::fill_aplt_entry): Likewise.
2022-12-13 09:02:36 -08:00
Alan Modra
772e1fe54a Re: gold: add --compress-debug-sections=zstd [PR 29641]
Fix the following:
compressed_output.cc:86:8: error: assignment of read-only variable ‘size’
   86 |   size = ZSTD_compress(*compressed_data + header_size, size, uncompressed_data,
2022-11-11 18:05:36 +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
Vladislav Khmelevsky
cde010e1a8 Fix adrp distance check
gold/
	* aarch64.cc (aarch64_valid_for_adrp_p): Shift offset
	as a signed number.
2022-11-10 16:49:05 -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
Tsukasa OI
f7aa1a5acc gold: Suppress "unused" variable warning on Clang
Clang generates a warning if there is a variable that is set but not used
otherwise ("-Wunused-but-set-variable").  On the default configuration, it
causes a build failure (unless "--disable-werror" is specified).

Because the cause of this error is in the Bison-generated code
($(srcdir)/gold/yyscript.y -> $(builddir)/gold/yyscript.c),
this commit suppresses this warning ("-Wunused-but-set-variable") by placing
DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE macro at the end of user
prologue on yyscript.y.

	* yyscript.y: Suppress -Wunused-but-set-variable warning on
	the Bison-generated code.
2022-09-27 15:04:02 +09:30
Alan Modra
c21736aed1 PR29542, PowerPC gold internal error in get_output_view,
We were attempting to set a BSS style section contents.

	PR 29542
	* powerpc.cc (Output_data_plt_powerpc::do_write): Don't set .plt,
	.iplt or .lplt section contents when position independent.
2022-09-26 14:23:29 +09:30
Nick Clifton
7e19db932c New Serbian translations for various binutils sub-directories. 2022-09-20 11:33:16 +01:00
Tsukasa OI
491cf3178f bfd: Stop using -Wstack-usage=262144 when built with Clang
Some components of GNU Binutils will pass "-Wstack-usage=262144" when
"GCC >= 5.0" is detected.  However, Clang does not support "-Wstack-usage",
despite that related configuration part in bfd/warning.m4 handles the latest
Clang (15.0.0 as of this writing) as "GCC >= 5.0".

The option "-Wstack-usage" was ignored when the first version of Clang is
released but even this "ignoring" behavior is removed before Clang 4.0.0.
So, if we give Clang "-Wstack-usage=262144", it generates a warning, making
the build failure.

This commit checks "__clang__" macro to prevent adding the option if the
compiler is identified as Clang.

bfd/ChangeLog:

	* warning.m4: Stop appending "-Wstack-usage=262144" option when
	compiled with Clang.
	* configure: Regenerate.

binutils/ChangeLog:

	* configure: Regenerate.

gas/ChangeLog:

	* configure: Regenerate.

gold/ChangeLog:

	* configure: Regenerate.

gprof/ChangeLog:

	* configure: Regenerate.

ld/ChangeLog:

	* configure: Regenerate.

opcodes/ChangeLog:

	* configure: Regenerate.
2022-09-14 05:42:17 +00:00
Alan Modra
6158b25f77 PR29462, internal error in relocate, at powerpc.cc:10796
Prior to the inline plt call support (commit 08be322439), the only
local syms with plt entries were local ifunc symbols.  There shouldn't
be stubs for other local symbols so don't look for them.  The patch
also fixes minor bugs in get_reference_flags; Many relocs are valid
only for ppc64 and a couple only for ppc32.

	PR 29462
	* powerpc.cc (Target_powerpc::Relocate::relocate): Rename
	use_plt_offset to pltcal_to_direct, invert logic.  For relocs
	not used with inline plt sequences against local symbols, only
	look for stubs when the symbol is an ifunc.
	(Target_powerpc::Scan::get_reference_flags): Correct reloc
	handling for relocs not valid for both 32-bit and 64-bit.
2022-08-10 15:31:35 +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
Nick Clifton
e8f4567b9c Updated translations for various sub-directories 2022-07-26 13:06:29 +01:00
Nick Clifton
631ec08cb1 Update version to 2.39.50 and regenerate files 2022-07-08 11:19:44 +01:00
Nick Clifton
0bd0932314 Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
Nick Clifton
2a4fc266db Have gold's File_read::do_read() function check the start parameter
PR 23765
	* fileread.cc (File_read::do_read): Check start parameter before
	computing number of bytes to read.
2022-06-27 13:07:40 +01:00
Nick Clifton
2a89fa9613 Fix compile time warning building gold with Clang-14.
* int_encoding.cc (get_length_as_unsigned_LEB_128): Remove
	current_length variable.
2022-05-18 16:29:57 +01: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
Nick Clifton
36d285b9da Updated Serbian translations for the bfd, gold, ld and opcodes directories 2022-02-17 15:18:59 +00:00
Nick Clifton
a698397481 Updated French translation for the ld/ and gold/ sub-directories 2022-02-02 15:05:05 +00:00
Mike Frysinger
7d9d9c1078 gold: drop old cygnus install hack
The gold subdir doesn't actually have a manual, so this hack doesn't
do anything.  Plus the automake cygnus option was removed years ago
by Simon in d0ac1c4488 ("Bump to autoconf 2.69 and
automake 1.15.1").  So delete it here.
2022-01-24 19:58:33 -05:00
Nick Clifton
5fe73d4624 Update Bulgarian, French, Romaniam and Ukranian translation for some of the sub-directories 2022-01-24 14:22:49 +00: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
H.J. Lu
31b0378d53 Regenerate configure files with autoconf 2.69
Regenerate configure files with the unmodified autoconf 2.69 to remove

  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]

bfd/

	* configure: Regenerate.

binutils/

	* configure: Regenerate.

gas/

	* configure: Regenerate.

gold/

	* configure: Regenerate.

gprof/

	* configure: Regenerate.

ld/

	* configure: Regenerate.

opcodes/

	* configure: Regenerate.
2022-01-23 05:27:01 -08:00
Nick Clifton
f908e960c5 Change version number to 2.38.50 and regenerate files 2022-01-22 12:39:28 +00:00
Nick Clifton
a74e1cb344 Add markers for 2.38 branch 2022-01-22 12:08:55 +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
eb97d02405 [GOLD] PowerPC64 @notoc in non-power10 code
Gold version of commit 7aba54da42.

elfcpp/
	* powerpc.h (R_PPC64_REL24_P9NOTOC): Define.
gold/
	* powerpc.cc (Target_powerpc::maybe_skip_tls_get_addr_call,
	is_branch_reloc, max_branch_delta): Handle R_PPC64_REL24_P9NOTOC.
	(Target_powerpc::Branch_info::make_stub): Likewise.
	(struct Plt_stub_ent): Add p9notoc_, p9off_, tsize_.
	(struct Branch_stub_ent): Add p9notoc_, p9off_.
	(Stub_table::add_plt_call_entry): Handle R_PPC64_REL24_P9NOTOC.
	(Stub_table::add_long_branch_entry): Likewise.
	(Stub_table::add_eh_frame): Likewise.
	(Stub_table::plt_call_size): Return aligned size.  Adjust callers.
	Handle p9notoc_ sizing.
	(Stub_table::do_write): Write out p9notoc_ stubs.
	(Target_powerpc::Scan::get_reference_flags, local, global):
	Handle R_PPC64_REL24_P9NOTOC.
	(Target_powerpc::Relocate::relocate): Likewise.
2021-12-11 14:52:36 +10:30
Alan Modra
f21dbd7c80 [GOLD] PowerPC64 inline plt sequences
The fixes gold failures to handle inline PLT sequences properly.
PowerPC gold was always turning these back into direct calls due to
gsym->use_plt_offset() returning false.  This is fixed for dynamic
linking by correcting get_reference_flags, and for static linking by
overriding use_plt_offset() in relocate().  The rest of the patch
revolves around needing to create PLT entries for inline PLT calls
when statically linking (for gcc -mlongcall).  The lplt section
handled that for local symbols, now it does globals too.

	* powerpc.cc (Target_powerpc::plt_off): Return proper section
	for static link.
	(Target_powerpc::symval_for_branch): Make public.
	(Target_powerpc::make_lplt_section): Add Symbol_table* param.
	Adjust all calls.
	(Target_powerpc::make_local_plt_entry): Likewise.
	(Target_powerpc::make_local_plt_entry): New variant for global syms.
	(Powerpc_relobj::do_relocate_sections): Don't write lplt contents.
	(Output_data_plt_powerpc::do_write): Write lplt contents here.
	(Output_data_plt_powerpc::Output_data_plt_powerpc): Save
	symbol table pointer.  Adjust all uses.
	(Output_data_plt_powerpc::add_entry): Add stash parameter.  Don't
	do dynamic reloc handling when no reloc section.  Save symbol
	for local plt entries.
	(Output_data_plt_powerpc::add_local_entry): Save symbol.
	(Output_data_plt_powerpc::Local_plt_ent): New class.
	(Output_data_plt_powerpc::sym_ents_): New vector.
	(Target_powerpc::Scan::get_reference_flags): Return
	FUNCTION_CALL|RELATIVE_REF for inline plt relocs.
	(Target_powerpc::Scan::global): Make entries in lplt for inline
	plt call relocation symbols.
	(Target_powerpc::Relocate::relocate): Rename has_plt_offset to
	use_plt_offset.  Set use_plt_offset for inline plt relocs.
2021-12-06 22:16:46 +10:30
Mike Frysinger
360ef3b94a gold: enable silent build rules 2021-11-30 19:41:31 -05:00
Alan Modra
2990bf4096 Update bug reporting address
https://sourceware.org/bugzilla/ everywhere

bfd/
	* configure.ac (ACX_BUGURL): Set to https://sourceware.org/bugzilla/
	* po/Make-in (msgid-bugs-address): Likewise.
	* README: Report bugs to the above.
	* configure: Regenerate.
binutils/
	* po/Make-in (msgid-bugs-address): Update.
gas/
	* README: Update bug address.  Delete mention of gcc.
	* po/Make-in: Update bug address.
gold/
	* po/Make-in: Update bug address.
gprof/
	* po/Make-in: Update bug address.
ld/
	* po/Make-in: Update bug address.
opcodes/
	* po/Make-in: Update bug address.
2021-11-23 15:39:26 +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
H.J. Lu
f85dcfc3af gold: Place .note.gnu.property section before other note sections
Place the .note.gnu.property section before all other note sections to
avoid being placed between other note sections with different alignments.

	PR gold/28494
	* layout.cc (Layout::create_note): Set order to ORDER_PROPERTY_NOTE
	for the .note.gnu.property section.
	* layout.h (Output_section_order): Add ORDER_PROPERTY_NOTE.
2021-10-26 16:24:24 -07:00
Alan Modra
068a039b8b PR28417, std::string no longer allows accepting nullptr_t
PR 28417
	* incremental.cc (Sized_relobj_incr::do_section_name): Avoid
	std:string undefined behaviour.
	* options.h (Search_directory::Search_directory): Likewise.
2021-10-21 07:54:27 +10:30
Alan Modra
c7fdac09d9 Re: PR27625, powerpc64 gold __tls_get_addr calls
My previous PR27625 patch had a problem or two.  For one, the error
"__tls_get_addr call lacks marker reloc" on processing some calls
before hitting a call without markers typically isn't seen.  Instead a
gold assertion fails.  Either way it would be a hard error, which
triggers on a file contained in libphobos.a when running the gcc
testsuite.  A warning isn't even appropriate since the call involved
is one built by hand without any of the arg setup relocations that
might result in linker optimisation.

So this patch reverts most of commit 0af4fcc25d, instead entirely
ignoring the problem of mis-optimising old-style __tls_get_addr calls
without marker relocs.  We can't handle them gracefully without
another pass over relocations before decisions are made about GOT
entries in Scan::global or Scan::local.  That seems too costly, just
to link object files from 2009.  What's more, there doesn't seem to be
any way to allow the libphobos explicit __tls_get_addr call, but not
old TLS sequences without marker relocs.  Examining instructions
before the __tls_get_addr call is out of the question: program flow
might reach the call via a branch.  Putting an R_PPC64_TLSGD marker
with zero sym on the call might be a solution, but current linkers
will then merrily optimise away the call!

	PR gold/27625
	* powerpc.cc (Powerpc_relobj): Delete no_tls_marker_, tls_marker_,
	and tls_opt_error_ variables and accessors.  Remove all uses.
2021-10-21 07:54:27 +10:30
Alan Modra
a1251fdcb5 [GOLD] Re: PowerPC64: Don't pretend to support multi-toc
We can't get at section->address() until everything is laid out, so
trying to generalise the offset calculation rather than using a value
of 0x8000 (the old object->toc_base_offset()) was bound to fail.
got->g_o_t() is a little better than a hard-coded 0x8000.

	* powerpc.cc (Target_powerpc::Scan::local, global): Don't use
	toc_pointer() here.
2021-10-14 20:02:32 +10:30
Alan Modra
f19c3684a6 [GOLD] Two GOT sections for PowerPC64
Split .got into two piece, one with the header and entries for small
model got entries, the other with entries for medium/large model got
entries.  The idea is to better support mixed pcrel/non-pcrel code
where non-pcrel small-model .toc entries need to be within 32k of the
toc pointer.

	* target.h (Target::tls_offset_for_local): Add got param.
	(Target::tls_offset_for_global): Likewise.
	(Target::do_tls_offset_for_local, do_tls_offset_for_global): Likewise.
	* output.h (Output_data_got::Got_entry::write): Add got param.
	* output.cc (Output_data_got::Got_entry::write): Likewise, pass to
	tls_offset_for_local/global calls.
	(Output_data_got::do_write): Adjust to suit.
	* s390.cc (Target_s390::do_tls_offset_for_local): Likewise.
	(Target_s390::do_tls_offset_for_global): Likewise.
	* powerpc.cc (enum Got_type): Extend with small types, move from
	class Target_powerpc.
	(Target_powerpc::biggot_): New.
	(Traget_powerpc::do_tls_offset_for_local, do_tls_offset_for_global,
	got_size, got_section, got_base_offset): Handle biggot_.
	(Target_powerpc::do_define_standard_symbols): Adjust.
	(Target_powerpc::make_plt_section, do_finalize_sections): Likewise.
	(Output_data_got_powerpc::Output_data_got_powerpc): Only make
	64-bit header for small got section.
	(Output_data_got_powerpc::g_o_t): Only return a result for small
	got section.
	(Output_data_got_powerpc::write): Only write small got section
	header.
	(Target_powerpc::Scan::local, global): Select small/big Got_type
	and section to suit reloc.
	(Target_powerpc::Relocate::relocate): Similarly.
	(Sort_toc_sections): Rewrite.
2021-10-14 13:08:46 +10:30
Alan Modra
a19da04b3c [GOLD] PowerPC64: Don't pretend to support multi-toc
Code in powerpc.cc is pretending to support a per-object toc pointer
value, but powerpc gold has no real support for multi-toc.  This patch
removes the pretense, tidying quite a lot in preparation for a
followup patch.  If multi-toc is ever to be supported, don't revert
this patch but start by adding object parameter to toc_pointer() and
an object to Branch_stub_key.

	* powerpc.cc (Powerpc_relobj::toc_base_offset): Delete.
	(Target_powerpc::toc_pointer): New function.  Use throughout.
	(Target_powerpc::got_base_offset): New function.  Use throughout..
	(Output_data_got_powerpc::got_base_offset): ..in place of
	this.  Delete.
	(Output_data_got_powerpc::Output_data_got_powerpc): Init
	header_index_ to -1u for 64-bit, and make header here.
	(Output_data_got_powerpc::set_final_data_size, reserve_ent): Don't
	make 64-bit header here.
	(Output_data_got_powerpc::g_o_t): Return toc pointer offset in
	section for 64-bit.  Use throughout.
	(Stub_table): Remove toc_base_off_ from Branch_stub_key, and
	object param on add_long_branch_entry and find_long_branch_entry.
	Adjust all uses.
2021-10-14 13:08:46 +10:30
Alan Modra
5cdb4f1442 [GOLD] PowerPC64 support for sym+addend GOT entries
Pass addends to all the GOT handling functions, plus remove some
extraneous asserts.

	PR 28192
	* powerpc.cc (Output_data_got_powerpc): Add addend parameter to
	all methods creating got entries.
	(Target_powerpc::Scan::local): Pass reloc addend to got handling
	functions, and when creating dynamic got relocations.
	(Target_powerpc::Scan::global): Likewise.
	(Target_powerpc::Relocate::relocate): Likewise.  Remove extraneous
	assertions.
2021-09-18 08:20:11 +09:30
Alan Modra
e4d49a0f90 [GOLD] Got_entry::write addends
This takes care of writing out GOT entries with addends.  The local
symbol case was already largely handled, except for passing the addend
to tls_offset_for_local which might need the addend in a
local_got_offset call.  That's needed also in tls_offset_for_global.

I'm assuming here that GOT entries for function symbols won't ever
have addends, and in particular that a GOT entry referencing PLT call
stub code won't want an offset into the code.

	PR 28192
	* output.cc (Output_data_got::Got_entry::write): Include addend
	in global symbol value.  Pass addend to tls_offset_for_*.
	* powerpc.cc (Target_powerpc::do_tls_offset_for_local): Handle addend.
	(Target_powerpc::do_tls_offset_for_global): Likewise.
	* s390.cc (Target_s390::do_tls_offset_for_local): Likewise.
	(Target_s390::do_tls_offset_for_global): Likewise.
	* target.h (Target::tls_offset_for_local): Add addend param.
	(Target::tls_offset_for_global): Likewise.
	(Target::do_tls_offset_for_local): Likewise.
	(Target::do_tls_offset_for_global): Likewise.
2021-09-18 08:20:11 +09:30
Alan Modra
2cc9ed14fa [GOLD] Output_data_got create entry method addends
This patch makes all the Output_data_got methods that create new
entries accept an optional addend.

	PR 28192
	* output.h (Output_data_got::add_global): Add optional addend
	parameter.  Update comment.  Delete overload without addend.
	(Output_data_got::add_global_plt): Likewise.
	(Output_data_got::add_global_tls): Likewise.
	(Output_data_got::add_global_with_rel): Likewise.
	(Output_data_got::add_global_pair_with_rel): Likewise.
	(Output_data_got::add_local_plt): Likewise.
	(Output_data_got::add_local_tls): Likewise.
	(Output_data_got::add_local_tls_pair): Likewise.
	(Output_data_got::reserve_local): Likewise.
	(Output_data_got::reserve_global): Likewise.
	(Output_data_got::Got_entry): Include addend in global sym
	constructor.  Delete local sym constructor without addend.
	* output.cc (Output_data_got::add_global): Add addend param,
	pass to got handling methods.
	(Output_data_got::add_global_plt): Likewise.
	(Output_data_got::add_global_with_rel): Likewise.
	(Output_data_got::add_global_pair_with_rel): Likewise.
	(Output_data_got::add_local_plt): Likewise.
	(Output_data_got::add_local_tls_pair): Likewise.
	(Output_data_got::reserve_local): Likewise.
	(Output_data_got::reserve_global): Likewise.
2021-09-18 08:20:11 +09:30
Alan Modra
54721a930e [GOLD] Output_data_got tidy
Some Output_data_got methods already have support for addends, but
were implemented as separate methods.  This removes unnecessary code
duplication.

Relobj::local_has_got_offset and others there get a similar treatment.
Comments are removed since it should be obvious without a comment, and
the existing comments are not precisely what the code does.  For
example, a local_has_got_offset call without an addend does not return
whether the local symbol has *a* GOT offset of type GOT_TYPE, it
returns whether there is a GOT entry of type GOT_TYPE for the symbol
with addend of zero.

	PR 28192
	* output.h (Output_data_got::add_local): Make addend optional.
	(Output_data_got::add_local_with_rel): Likewise.
	(Output_data_got::add_local_pair_with_rel): Likewise.
	* output.cc (Output_data_got::add_local): Delete overload
	without addend.
	(Output_data_got::add_local_with_rel): Likewise.
	(Output_data_got::add_local_pair_with_rel): Likewise.
	* object.h (Relobj::local_has_got_offset): Make addend optional.
	Delete overload without addend later.  Update comment.
	(Relobj::local_got_offset): Likewise.
	(Relobj::set_local_got_offset): Likewise.
2021-09-18 08:20:11 +09:30
Alan Modra
973b2b402e [GOLD] Remove addend from Local_got_entry_key
This patch removes the addend from Local_got_entry_key, which is
unnecessary now that Got_offset_list has an addend.  Note that it
might be advantageous to keep the addend in Local_got_entry_key when
linking objects containing a large number of section_sym+addend@got
relocations.  I opted to save some memory by removing the field but
left the class there in case we might need to restore {sym,addend}
lookup.  That's also why this change is split out from the
Got_offset_list change.

	PR 28192
	* object.h (Local_got_entry_key): Delete addend_ field.
	Adjust constructor and methods to suit.
	* object.cc (Sized_relobj::do_for_all_local_got_entries):
	Update key.
2021-09-18 08:20:11 +09:30
Alan Modra
912697efc1 [GOLD] Got_offset_list: addend field
This is the first in a series of patches aimed at supporting GOT
entries against symbol plus addend generally for PowerPC64 rather than
just section symbol plus addend as gold has currently.

This patch adds an addend field to Got_offset_list, so that both local
and global symbols can have GOT entries with addend.

	PR 28192
	* object.h (Got_offset_list): Add addend_ field, init in both
	constructors.  Adjust all accessors to suit.
	(Sized_relobj::do_local_has_got_offset): Adjust to suit.
	(Sized_relobj::do_local_got_offset): Likewise.
	(Sized_relobj::do_set_local_got_offset): Likewise.
	* symtab.h (Symbol::has_got_offset): Add optional addend param.
	(Symbol::got_offset, Symbol::set_got_offset): Likewise.
	* incremental.cc (Local_got_offset_visitor::visit): Add unused
	uint64_t parameter with FIXME.
	(Global_got_offset_visitor::visit): Add unused uint64_t parameter.
2021-09-18 08:20:11 +09:30
Fangrui Song
7a554b2725 gold: --export-dynamic-symbol: don't imply -u
to match GNU ld.

gold/
	* archive.cc (Library_base::should_include_member): Don't handle
	--export-dynamic-symbol.
	* symtab.cc (Symbol_table::do_add_undefined_symbols_from_command_line):
	Likewise.
2021-09-02 19:07:53 -07:00
Alan Modra
89c905a342 [GOLD] PowerPC64 relocation overflow for -Os register save/restore funcs
Fixes a silly mistake in calculating the address of -Os out-of-line
register save/restore function copies.  Copies of these linker defined
functions are added to stub sections when the original (in
target->savres_section) can't be reached.

	* powerpc.cc (Target_powerpc::Relocate::relocate): Correct address
	calculation of out-of-line save/restore function copies.
2021-08-18 13:36:57 +09:30
John Ericson
ab4f385b3c Deprecate a.out support for NetBSD targets.
As discussed previously, a.out support is now quite deprecated, and in
some cases removed, in both Binutils itself and NetBSD, so this legacy
default makes little sense. `netbsdelf*` and `netbsdaout*` still work
allowing the user to be explicit about there choice. Additionally, the
configure script warns about the change as Nick Clifton requested.

One possible concern was the status of NetBSD on NS32K, where only a.out
was supported. But per [1] NetBSD has removed support, and if it were to
come back, it would be with ELF. The binutils implementation is
therefore marked obsolete, per the instructions in the last message.

With that patch and this one applied, I have confirmed the following:

--target=i686-unknown-netbsd
--target=i686-unknown-netbsdelf
  builds completely

--target=i686-unknown-netbsdaout
  properly fails because target is deprecated.

--target=vax-unknown-netbsdaout builds completely except for gas, where
the target is deprecated.

[1]: https://mail-index.netbsd.org/tech-toolchain/2021/07/19/msg004025.html
---
 bfd/config.bfd                             | 43 +++++++++++++--------
 bfd/configure.ac                           |  5 +--
 binutils/testsuite/binutils-all/nm.exp     |  2 +-
 binutils/testsuite/lib/binutils-common.exp |  7 +---
 config/picflag.m4                          |  4 +-
 gas/configure.tgt                          |  9 +++--
 gas/testsuite/gas/arm/blx-bl-convert.d     |  2 +-
 gas/testsuite/gas/arm/blx-local-thumb.d    |  2 +-
 gas/testsuite/gas/sh/basic.exp             |  2 +-
 gdb/configure.host                         | 34 +++++++----------
 gdb/configure.tgt                          |  2 +-
 gdb/testsuite/gdb.asm/asm-source.exp       |  6 +--
 intl/configure                             |  2 +-
 ld/configure.tgt                           | 44 +++++++++++-----------
 ld/testsuite/ld-arm/arm-elf.exp            |  4 +-
 ld/testsuite/ld-elf/elf.exp                |  2 +-
 ld/testsuite/ld-elf/shared.exp             |  4 +-
 libiberty/configure                        |  4 +-
2021-08-11 13:17:54 +01:00
Nick Clifton
3ee0cd9e55 Updated Serbian and Russian translations for various sub-directories 2021-08-10 16:40:37 +01:00
Alan Modra
b97bd97623 PR28106, build of 2.37 fails on FreeBSD and Clang
https://en.cppreference.com/w/cpp/types/NULL says NULL might be
defined as nullptr.
https://en.cppreference.com/w/cpp/language/reinterpret_cast says
reinterpret_cast can't be used on nullptr.

	PR gold/28106
	PR gold/27815
	* gc.h (gc_process_relocs): Use static_cast in Section_id constructor.
2021-07-20 20:15:48 +09:30
Michael Krasnyk
7c6ff8af98 PR28098 Skip R_*_NONE relocation entries with zero r_sym without counting
PR gold/28098
	* reloc.cc (Track_relocs::advance): Skip R_*_NONE relocation entries
	with r_sym of zero without counting in advance method.
2021-07-18 22:04:36 +09:30
Nick Clifton
6e0dfbf420 Updated translations (mainly Ukranian and French) triggered by creation of 2.37 branch. 2021-07-05 15:54:35 +01:00
Nick Clifton
346d80ef33 Update version number and regenerate files 2021-07-03 15:16:48 +01:00
Nick Clifton
514192487e Add markers for 2.37 branch 2021-07-03 14:50:57 +01:00
Alan Modra
5d7f11f0e7 [GOLD] PR27815, gold fails to build with latest GCC
Don't use nullptr, it requires -std=c++11 on versions of gcc prior to
6.1.  It would be possible to arrange to pass -std=c++11 automatically
when required (top level configure does that for gcc builds) but that
seems overkill and since we're not up-to-date on the top level config
files would mean someone would need to sync those over.

	PR gold/27815
	* gc.h (gc_process_relocs): Use cast in Section_id constructor.
2021-05-25 16:47:16 +09:30
Alan Modra
1f1fb219fd [GOLD] PR27815, gold fails to build with latest GCC
...gold/gc.h:250:37: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: [-Werror]
  250 |                 (*secvec).push_back(Section_id(NULL, 0));
      |                                     ^~~~~~~~~~~~~~~~~~~

	PR gold/27815
	* gc.h (gc_process_relocs): Use nullptr in Section_id constructor.
2021-05-22 17:23:06 +09:30
Alan Modra
7c96e6120f [GOLD]: Re: Add -Bno-symbolic
PR 27834
	* options.cc (General_options::General_options): Init bsymbolic_.
2021-05-15 14:16:54 +09:30
Fangrui Song
823241a27c gold: Add -Bno-symbolic
gold/
    PR 27834
    * options.h (General_options): Make -Bsymbolic and
    -Bsymbolic-functions special and adjust the help messages. Add
    enum Bsymbolic_kind and -Bno-symbolic.
    * options.cc (General_options): Define parse_Bno_symbolic,
    parse_Bsymbolic_functions, and parse_Bsymbolic.
2021-05-14 15:51:17 -07:00
Alan Modra
0af4fcc25d PR27625, powerpc64 gold __tls_get_addr calls
This patch supports linking powerpc64 glibc with gold, specifically
the __tls_get_addr call in elf/dl-sym.c.  That call lacks marker
relocations tying it to the arg setup instructions, but the arg setup
insns are also contructed lacking the usual relocations on a Global
Dynamic TLS code sequence.  So there is no chance that anything in
that sequence might be wrongly edited by the linker.

In fact, the aim of linking glibc could have been supported by simply
omitting the error whenever TLS optimisation is disabled, as it is
when linking a shared library.  The patch goes further than that,
disabling TLS GD and LD sequence optimisation on a per-object basis
for object files lacking marker relocs.

	PR gold/27625
	* powerpc.cc (Powerpc_relobj): Add no_tls_marker_, tls_marker_,
	and tls_opt_error_ variables and accessors.
	(Target_powerpc::Scan::local, global): Call set_tls_marker and
	set_no_tls_marker for GD and LD code sequence relocations.
	(Target_powerpc::Relocate::relocate): Downgrade the "lacks marker
	reloc" error to a warning when safe to do so, and omit the error
	entirely if not optimising TLS sequences.  Do not optimise GD and
	LD sequences for objects lacking marker relocs.
	(Target_powerpc::relocate_relocs): Heed no_tls_marker here too.
2021-03-30 13:38:41 +10:30
Cary Coutant
35891b4775 Use stdout when printing object file names for -t option.
gold/
	PR gold/27615
	* errors.cc (Errors::trace): New method.
	(gold_trace): New function.
	* errors.h (Errors::trace): New method.
	* gold.h (gold_trace): New function.
	* object.cc (Input_objects::add_object): Use gold_trace to print
	object file names.
2021-03-19 18:41:12 -07:00
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
Holger Berger
07b1c3dbd9 Fix call to system fallocate to handle errno correctly.
2021-03-19  Holger Berger  <holger.berger@googlemail.com>

gold/
	PR gold/26541
	* output.cc (gold_fallocate): Use errno when calling system fallocate.
2021-03-19 16:18:53 -07:00
Cary Coutant
cc1849716f Fix typo in previous patch: should use struct mallinfo2.
PR gold/26585
	* main.cc (main): Fix typo in previous patch.
2021-03-19 15:29:49 -07:00
Cary Coutant
9331846e44 Regenerate config.in, missing from previous commit.
PR gold/26585
	* config.in: Regenerate from previous commit.
2021-03-19 15:23:49 -07:00
Duncan Simpson
4ee6049505 Fix gold to use mallinfo2 if available instead of deprecated mallinfo.
gold/
	PR gold/26585
	* configure.ac: Add check for mallinfo2.
	* configure: Regenerate.
	* main.cc (main): Use mallinfo2 if available.
2021-03-19 14:22:08 -07:00
Cary Coutant
5cde809b7b Add DWARF 5 support in gold.
elfcpp/
	PR gold/27246
	* dwarf.h (enum DW_LNCT): Add line number table content type codes.
	(enum DW_LINE_OPS): Reformat.
	(enum DW_LINE_EXTENDED_OPS): Reformat.
	(enum DW_CHILDREN): Reformat.
	(enum DW_RLE): Add range list entry types.
	(enum DW_SECT): Update values for DWARF 5.

gold/
	PR gold/27246
	* dwarf_reader.cc (Dwarf_abbrev_table::do_get_abbrev): Handle
	DW_FORM_implicit_const.
	(Dwarf_ranges_table::read_ranges_table): Add version parameter;
	Adjust all callers.  Look for .debug_rnglists section if DWARF 5.
	(Dwarf_ranges_table::read_range_list_v5): New method.
	(Dwarf_die::read_attributes): Handle new DWARF 5 DW_FORM codes.
	(Dwarf_die::skip_attributes): Likewise.
	(Dwarf_info_reader::do_parse): Support DWARF 5 unit header format.
	(Dwarf_info_reader::read_3bytes_from_pointer): New method.
	(Sized_dwarf_line_info::Sized_dwarf_line_info): Initialize
	str_buffer_, str_buffer_start, reloc_map_, line_number_map_.
	Look for .debug_line_str section.
	(Sized_dwarf_line_info::read_header_prolog): Support DWARF 5 prolog.
	(Sized_dwarf_line_info::read_header_tables): Rename to...
	(Sized_dwarf_line_info::read_header_tables_v2): ... this.
	(Sized_dwarf_line_info::read_header_tables_v5): New method.
	(Sized_dwarf_line_info::process_one_opcode): Insert missing "this->".
	Change advance_line to signed int64_t.
	(Sized_dwarf_line_info::read_lines): Add endptr parameter; adjust
	callers.  Insert missing "this->".
	(Sized_dwarf_line_info::read_line_mappings): Support DWARF 5.
	(Sized_dwarf_line_info::do_addr2line): Add debug code.
	* dwarf_reader.h (Dwarf_abbrev_table::Attribute): Add implicit_const
	field. Adjust constructor.
	(Dwarf_abbrev_table::add_sttribute): Add implicit_const parameter.
	(Dwarf_ranges_table::read_ranges_table): Add version parameter.
	(Dwarf_ranges_table::read_range_list_v5): New method.
	(Dwarf_die): Remove unused attr_off field.
	(Dwarf_info_reader::Dwarf_info_reader): Initialize unit_type_ field.
	(Dwarf_info_reader::is_type_unit): New method.
	(Dwarf_info_reader::read_3bytes_from_pointer): New method.
	(Dwarf_info_reader::read_range_list): Call read_range_list_v5 for
	DWARF 5 range lists.
	(Dwarf_info_reader::is_type_unit_): Remove.
	(Dwarf_info_reader::unit_type_): New field.
	(Sized_dwarf_line_info::~Sized_dwarf_line_info): Delete
	str_buffer_start_.
	(Sized_dwarf_line_info::read_header_tables): Rename to...
	(Sized_dwarf_line_info::read_header_tables_v2): ... this.
	(Sized_dwarf_line_info::read_header_tables_v5): New method.
	(Sized_dwarf_line_info::read_lines): Add endptr parameter.
	(Sized_dwarf_line_info::Dwarf_line_infoHeader): Add address_size field.
	(Sized_dwarf_line_info::str_buffer_): New field.
	(Sized_dwarf_line_info::str_buffer_end_): New field.
	(Sized_dwarf_line_info::str_buffer_start_): New field.
	(Sized_dwarf_line_info::end_of_header_length_): New field.
	(Sized_dwarf_line_info::end_of_unit_): New field.
2021-03-19 13:55:35 -07:00
H.J. Lu
0318cca493 gold: Skip address size and segment selector for DWARF5
The .debug_line secton in DWARF5 has a byte for address size and a byte
for segment selector after DWARF version.  Skip them for DWARF5.

	PR gold/27246
	* dwarf_reader.cc (Sized_dwarf_line_info::read_header_prolog):
	Skip address size and segment selector for DWARF5.
2021-01-28 04:21:31 -08:00
Alan Modra
a75a6a4164 [GOLD] powerpc assertion failure
A testcase with only ifuncs can result in no plt section (ifunc plt
entries might instead be in iplt), which means we can get to this code
without a static link.

	PR 27203
	* powerpc.cc (do_plt_fde_location): Remove doing_static_link
	assertion.
2021-01-19 13:27:13 +10:30
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
Nick Clifton
5a10699ff3 Updated translations for some subdirectories 2021-01-14 12:55:25 +00:00
Nick Clifton
a8aa72b913 Updated translations for multiple subdirectories 2021-01-11 12:55:33 +00:00
Nick Clifton
055bc77a80 Add Changelog entries and NEWS entries for 2.36 branch 2021-01-09 10:40:28 +00:00
Alan Modra
e3b53295d5 PR27140, ppc32 segmentation fault in make_stub
This fixes a thinko in commit fa40fbe484.  st_other global entry bits
are relevant only for 64-bit ELFv2.  PowerPC gold leaves local sym
vector of st_other bits as NULL for 32-bit, hence the segfault.

	PR 27140
	* powerpc.cc (Target_powerpc::Branch_info::make_stub): Only access
	object->st_other() when 64-bit.
	(Stub_table::add_long_branch_entry): Ignore "other" when 32-bit.
2021-01-03 12:49:47 +10:30
Alan Modra
f9a6a8f09d PR27116, Spelling errors found by Debian style checker
PR 27116
bfd/
	* xcofflink.c: Correct spelling in comments.
binutils/
	* coffgrok.c (do_type): Correct spelling of auxiliary in errors.
	* doc/binutils.texi: Correct grammar.
	* readelf.c (process_version_sections): Correct spelling of auxiliary
	in warning.
	* testsuite/binutils-all/vax/objdump.exp: Comment grammar fix.
config/
	* override.m4: Correct comment grammar.
gas/
	* config/tc-i386.c: Correct comment spelling.
	* config/tc-riscv.c: Likewise.
	* config/tc-s390.c: Correct comment grammar.
	* doc/c-i386.texi: Correct spelling.
	* doc/c-s390.texi: Correct grammar.
gold/
	* tilegx.cc: Correct comment spelling.
gprof/
	* README: Correct grammar.
	* gprof.texi: Likewise.
include/
	* coff/internal.h: Correct comment spelling.
	* coff/sym.h: Likewise.
	* opcode/aarch64.h: Likewise.
ld/
	* configure.tgt: Correct comment grammar.
	* emultempl/m68hc1xelf.em: Likewise.
	* ld.texi: Correct grammar.
2021-01-01 14:36:35 +10:30
Alan Modra
250d07de5c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
Alan Modra
c2795844e6 ChangeLog rotation 2021-01-01 10:31:02 +10:30