Commit Graph

2154 Commits

Author SHA1 Message Date
Alan Modra
b14ce8bfe1 Re: Update year range in copyright notice of binutils files
Add the ChangeLog entry.
2020-01-01 18:55:18 +10:30
Alan Modra
b3adc24a07 Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
Alan Modra
0b11474080 ChangeLog rotation 2020-01-01 18:12:08 +10:30
Martin Liska
5fa5f8f5fe
Introduce new .text.sorted.* sections.
gold/ChangeLog:

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

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

ld/ChangeLog:

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

	* scripttempl/arclinux.sc: Add .text.sorted.* which is sorted
	by default.
	* scripttempl/elf.sc: Likewise.
	* scripttempl/elf64bpf.sc: Likewise.
	* scripttempl/nds32elf.sc: Likewise.
	* testsuite/ld-arm/arm-no-rel-plt.ld: Expect .text.sorted.*
	in the default linker script.
	* testsuite/ld-arm/fdpic-main.ld: Likewise.
	* testsuite/ld-arm/fdpic-shared.ld: Likewise.
2019-11-26 17:20:10 +01:00
Alan Modra
aa465b19c8 [GOLD] OSABI not set when STT_GNU_IFUNC or STB_GNU_UNIQUE symbols output
This patch arranges to have OSABI set to ELFOSABI_GNU (if not set to
some other non-zero value) when gold outputs an ifunc local or global
symbol, or a unique global symbol to either .dynsym or .symtab.
STT_GNU_IFUNC and STB_GNU_UNIQUE have values in the LOOS to HIOS range
and therefore require interpretation according to OSABI.

I'm not sure why parameters->target() is const Target& while
parameters->sized_target() is Sized_target*, but it's inconvenient to
use the latter in Symbol_table::finalize.  So this patch adds another
const_cast complained about in layout.cc and gold.cc.

	PR 24853
	* symtab.h (set_has_gnu_output, has_gnu_output_): New.
	* symtab.cc (Symbol_table::Symbol_table): Init has_gnu_output_.
	(Symbol_table::finalize): Set ELFOSABI_GNU when has_gnu_output_.
	(Symbol_table::set_dynsym_indexes, Symbol_table::sized_finalize):
	Call set_has_gnu_output for STT_GNU_IFUNC and STB_GNU_UNIQUE globals.
	* object.cc (Sized_relobj_file::do_finalize_local_symbols): Call
	set_has_gnu_output when STT_GNU_IFUNC locals will be output.
2019-11-19 07:36:20 +10:30
Miguel Saldivar
6f485ad416 PR24996, Gold fix for ternary operator within linker scripts
PR 24996
	* expression.cc (Trinary_expression::arg2_value): Use correct integer
	expression when calling "eval_maybe_dot" method.
	(Trinary_expression::arg3_value): Likewise.
2019-11-11 10:56:44 +10:30
Alan Modra
ea8e302e12 PR16794, gold ignores R_386_GOTOFF addend
An R_386_GOTOFF relocation has an addend, typically used when a
symbol can be replaced by its section symbol plus an offset.
psymval->value(object,0) is quite wrong then, fix it.

	PR 16794
	* i386.cc (Target_i386::Relocate::relocate <R_386_GOTOFF>): Don't
	ignore addend, apply using pcrel32.
	* x86_64.cc (Target_x86_64::Relocate::relocate <R_X86_64_GOTOFF64>):
	Similarly use pcrel64.
2019-09-28 16:47:52 +09:30
Nick Clifton
5d33705c7b Fix building gold with gcc-10.
* descriptors.cc: Include <string>
2019-09-24 10:07:56 +01:00
Alan Modra
6831670dd3 implicit conversion from enum ld_plugin_level to enum ld_plugin_status
This is a gcc10 warning fix.

gold/
	* testsuite/plugin_new_section_layout.c (new_input_hook): Correct
	return status enum values.
2019-09-23 23:44:21 +09:30
Alan Modra
4c51dacacf [GOLD] Fix spurious "plugin needed to handle lto object" warnings
lto_slim_object_ was unitialized.  I also thought it worth adding
a sanity check on the .gnu.lto_.lto.* section size, and made some
other tidies.

	PR 24768
	* layout.cc (Layout::Layout): Init lto_slim_object_.
	* object.cc (Sized_relobj_file::do_layout): Wrap overlong line.
	Don't use C cast.  Validate section size.  Don't copy contents.
2019-09-20 15:37:11 +09:30
Alan Modra
e59a100122 PowerPC64, error on unsupported dynamic relocation
This patch corrects the set of dynamic relocations recognised by gold
as supported by glibc, and teaches ld.bfd to report an error similar
to the gold error.  Note that ld --noinhibit-exec can be used to
produce an output, supporting older ld with newer glibc if the set of
supported glibc dynamic relocations changes.

bfd/
	* elf64-ppc.c (ppc64_glibc_dynamic_reloc): New function.
	(ppc64_elf_relocate_section): Error if emitting unsupported
	dynamic relocations.
gold/
	* powerpc.cc (Target_powerpc::Scan::check_non_pic): Move REL24
	to 32-bit supported.
2019-09-20 12:51:19 +09:30
Simon Marchi
e0b2a78c83 Re-generate many configure and Makefile.in files
I get some spurious changes when running autoconf/automake for various
projects in the tree.  This is likely because they were generated using
distro-patched tools last time.

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

bfd/ChangeLog:

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

binutils/ChangeLog:

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

gas/ChangeLog:

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

gold/ChangeLog:

	* testsuite/Makefile.in: Re-generate.

gprof/ChangeLog:

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

ld/ChangeLog:

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

opcodes/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.
2019-09-18 09:09:15 -04:00
Phil Blundell
60391a255b Add markers for 2.33 branch to NEWS and ChangeLog files. 2019-09-09 10:27:40 +01:00
Martin Liska
b4c555cfc4
Fix detection of missing plugin for LTO objects.
2019-08-16  Martin Liska  <mliska@suse.cz>

	PR ld/24912
	* elflink.c: Report error only for not relocatable.
	* linker.c (_bfd_generic_link_add_one_symbol): Do not handle
	here lto_slim_object as it's handled in caller.
2019-08-16  Martin Liska  <mliska@suse.cz>

	PR ld/24912
	* object.cc (big_endian>::do_layout): Do not report error,
	but only set a flag.
	(big_endian>::do_add_symbols): Report error only for when
	relocatable.
2019-08-16 13:14:36 +02:00
Alan Modra
89c52ae3a2 [GOLD] PowerPC64 pc-relative TLS support
Gold version of git commit c213164ad2.

elfcpp/
	* powerpc.h (R_PPC64_TPREL34, R_PPC64_DTPREL34),
	(R_PPC64_GOT_TLSGD34, R_PPC64_GOT_TLSLD34),
	(R_PPC64_GOT_TPREL34, R_PPC64_GOT_DTPREL34): Define.
gold/
	* powerpc.cc (Target_powerpc::Scan::get_reference_flags): Set
	flags for new relocations, and some missing older relocs.
	(Target_powerpc::Scan::local): Handle new pcrel tls relocs.
	Call set_has_static_tls for tprel relocs.
	(Target_powerpc::Scan::global): Likewise.
	(Target_powerpc::Relocate::relocate): Handle new pcrel tls relocs.
2019-08-02 18:41:34 +09:30
Alan Modra
6a010cf67a [GOLD] PowerPC relocation signed overflow check
Relocations with right shifts were calculating wrong overflow status.
Since the addr34 split-field reloc is implemented as an 18-bit high
part with value shifted right by 16 and a 16-bit low part, most of the
pc-relative relocs were affected.

	* powerpc.cc (Powerpc_relocate_functions::rela, rela_ua): Perform
	signed right shift for signed overflow check.
2019-08-02 18:22:42 +09:30
Martin Liska
cc5277b173 Support .gnu.lto_.lto section in ELF files (PR 24768).
bfd/ChangeLog:

2019-07-22  Martin Liska  <mliska@suse.cz>

	PR 24768
	* archive.c (_bfd_compute_and_write_armap): Come up with
	report_plugin_err variable.
	* bfd-in2.h (struct bfd): Add lto_slim_object flag.
	* elf.c (struct lto_section): New.
	(_bfd_elf_make_section_from_shdr): Parse content of
	.gnu_lto_.lto section.
	* elflink.c: Report error for a missing LTO plugin.
	* linker.c (_bfd_generic_link_add_one_symbol): Likewise.

binutils/ChangeLog:

2019-07-22  Martin Liska  <mliska@suse.cz>

	PR 24768
	* nm.c (filter_symbols): Set report_plugin_err if
	error is reported.
	(display_rel_file): Report error for a missing LTO plugin.

gold/ChangeLog:

2019-07-22  Martin Liska  <mliska@suse.cz>

	PR 24768
	* layout.h (class Layout): Add is_lto_slim_object and
	set_lto_slim_object.
	* object.cc (struct lto_section): Add lto_slim_object_.
	(big_endian>::do_layout): Parse content of
	.gnu_lto_.lto section.
	(big_endian>::do_add_symbols): Report error for a missing
	LTO plugin.
2019-07-29 10:11:44 +02:00
Alan Modra
0c951c25c6 [GOLD] PowerPC R_PPC64_PCREL_OPT support
* powerpc.cc (xlate_pcrel_opt): New function.
	(Target_powerpc::Relocate::relocate): Optimise PCREL34 and
	GOT_PCREL34 sequences marked with PCREL_OPT.
2019-07-13 09:57:50 +09:30
Alan Modra
c9b8abb7af [GOLD] PowerPC got reloc optimisation
Note that gold won't remove unused GOT entries, in contrast to ld.bfd
which will.

	* powerpc.cc (Powerpc_relobj::make_got_relative): New function.
	(relative_value_is_known): New functions.
	(Target_powerpc::Relocate::relocate): Edit code using
	GOT16_HA, GOT16_LO_DS, and GOT_PCREL34 relocs.
2019-07-13 09:57:50 +09:30
Alan Modra
e4dff7651b [GOLD] PowerPC relocations for prefix insns
Also use pc-relative instructions for notoc stubs.

elfcpp/
	* powerpc.h (R_PPC64_PCREL_OPT, R_PPC64_D34, R_PPC64_D34_LO),
	(R_PPC64_D34_HI30, R_PPC64_D34_HA30, R_PPC64_PCREL34),
	(R_PPC64_GOT_PCREL34, R_PPC64_PLT_PCREL34, R_PPC64_PLT_PCREL34_NOTOC),
	(R_PPC64_ADDR16_HIGHER34, R_PPC64_ADDR16_HIGHERA34),
	(R_PPC64_ADDR16_HIGHEST34, R_PPC64_ADDR16_HIGHESTA34),
	(R_PPC64_REL16_HIGHER34, R_PPC64_REL16_HIGHERA34),
	(R_PPC64_REL16_HIGHEST34, R_PPC64_REL16_HIGHESTA34),
	(R_PPC64_D28, R_PPC64_PCREL28): Define.
gold/
	* powerpc.cc (Target_powerpc): Add powerxx_stubs_ and accessor
	functions.
	(Target_powerpc::maybe_skip_tls_get_addr_call): Handle PLT_PCREL34
	and PLT_PCREL34_NOTOC relocs.
	(Powerpc_relocate_functions): Add addr34, addr34_hi, addr34_ha,
	addr28, addr16_higher34, addr16_highera34, addr16_highest34,
	addr16_highest34a functions.
	(li_11_0, ori_11_11_0, sldi_11_11_34): Define.
	(paddi_12_pc, pld_12_pc, pnop): Define.
	(d34, ha34): New inline functions.
	(Stub_table::add_plt_call_entry): Handle powerxx_stubs.
	(Stub_table::add_eh_frame): Likewise.
	(build_powerxx_offset): New function.
	(Stub_table::plt_call_size): Handle powerxx_stubs.
	(Stub_table::branch_stub_size): Likewise.
	(Stub_table::do_write): Likewise.
	(Target_powerpc::Scan::get_reference_flags): Handle new relocs.
	(Target_powerpc::Scan::reloc_needs_plt_for_ifunc: Likewise.
	(Target_powerpc::Scan::local, global, relocate): Likewise.
2019-07-13 09:57:50 +09:30
Alan Modra
220f99066d [GOLD] PowerPC notoc eh_frame
When generating notoc call and branch stubs without the benefit of
pc-relative insns, the stubs need to use LR to access the run time PC.
All LR changes must be described in .eh_frame if we're to support
unwinding through asynchronous exceptions.  That's what this patch
does.

The patch has gone through way too many iterations.  At first I
attempted to add multiple FDEs, one for each stub.  That ran into
difficulties with do_plt_fde_location which is only capable of setting
the address of a single FDE per Output_data section, and with removing
any FDEs added on a previous do_relax pass.  Removing FDEs (git commit
be897fb774) went overboard in matching the FDE contents.  That means
either stashing the contents created for add_eh_frame_for_plt to use
when calling remove_eh_frame_for_plt, or recreating contents on the
fly (*) just to remove FDEs.  In fact, FDE content matching is quite
unnecesary.  FDEs added by a previous do_relax pass are those with
u_.from_linker.post_map set.  So they can easily be recognised just by
looking at that flag.  This patch keeps that part of the multiple FDE
changes.

In the end I went for just one FDE per stub group to describe the call
stubs.  That's reasonably efficient for the common case of only
needing to describe the __tls_get_addr_opt call stub.  We don't expect
to be making many calls using notoc stubs without pc-relative insns.

*) Which has it's own set of problems.  The contents must be recreated
using the old stub layout, but .eh_frame size can affect stub
requirements so you need to temporarily keep the old .eh_frame size
when creating new stubs, then reset .eh_frame size before adding new
FDEs.

	* ehframe.cc (Fde::operator==): Delete.
	(Cie::remove_fde): Delete.
	(Eh_frame::remove_ehframe_for_plt): Delete fde_data and fde_length
	parameters.  Remove all post-map plt FDEs.
	* ehframe.h (Fde:post_map): Make const, add variant to compare plt.
	(Fde::operator==): Delete.
	(Cie::remove_fde): Implement here.
	(Cie::last_fde): New accessor.
	(Eh_frame::remove_ehframe_for_plt): Update prototype.
	* layout.cc (Layout::remove_eh_frame_for_plt): Delete fde_data and
	fde_length parameters.
	* layout.h (Layout::remove_eh_frame_for_plt): Update prototype.
	* powerpc.cc (Stub_table::tls_get_addr_opt_bctrl_): Delete.
	(Stub_table::plt_fde_len_, plt_fde_, init_plt_fde): Delete.
	(Stub_table::add_plt_call_entry): Don't set tls_get_addr_opt_bctrl_.
	(eh_advance): New function.
	(stub_sort): New function.
	(Stub_table::add_eh_frame): Emit eh_frame for notoc plt calls and
	branches as well as __tls_get_addr_opt plt call stub.
	(Stub_table::remove_eh_frame): Update to suit.
2019-07-13 09:57:50 +09:30
Alan Modra
32f5984419 [GOLD] PowerPC64 ELFv2 notoc support
Calls from notoc functions via the PLT need different stubs.  Even
calls to local functions requiring a valid toc pointer must go via a
stub.  This patch provides the support in gold.

elfcpp/
	* powerpc.h (R_PPC64_PLTSEQ_NOTOC, R_PPC64_PLTCALL_NOTOC): Define.
gold/
	* powerpc.cc (Target_powerpc::maybe_skip_tls_get_addr_call): Handle
	notoc calls.
	(is_branch_reloc): Template on size.  Return true for REL24_NOTOC.
	Update all callers.
	(max_branch_delta): Likewise.
	(Target_powerpc::Branch_info::make_stub): Add a stub for notoc
	calls to functions needing a valid toc pointer.
	(Target_powerpc::do_relax): Layout stubs again if any need resize.
	(add_12_11_12, addi_12_11, addis_12_11, ldx_12_11_12, ori_12_12_0),
	(oris_12_12_0, sldi_12_12_32): Define.
	(Stub_table::Plt_stub_ent): Add notoc_ and iter_ fields.
	(Stub_table::Branch_stub_key, Branch_stub_key_hash): Rename from
	Branch_stub_ent and Branch_stub_ent hash.  Remove save_res_ from key.
	(Stub_table::Branch_stub_ent): New struct.
	(class Stub_table): Add need_resize and resizing vars.
	(Stub_table::need_resize, branch_size): New accessors.
	(Stub_table::set_resizing): New function.
	(Stub_table::add_plt_call_entry): Handle notoc calls and resizing
	on seeing such or a tocsave stubs after a normal stub using the
	same sym.
	(Stub_table::add_long_branch_entry): Similarly.
	(Stub_table::find_long_branch_entry): Return a Branch_stub_ent*.
	(Stub_table::define_stub_syms): Adjust
	(Stub_table::build_tls_opt_head, build_tls_opt_tail): New functions.
	(build_notoc_offset): New function.
	(Stub_table::plt_call_size): Move out of line.  Handle notoc calls.
	(Stub_table::branch_stub_size): Similarly.
	(Stub_table::do_write): Separate loop for ELFv2 stubs, handling
	notoc calls.  Simplify ELFv1 loop.  Output notoc branch stubs.
	Use build_tls_opt_head and build_tls_opt_tail.
	(Target_powerpc::Scan::get_reference_flags): Handle REL24_NOTOC.
	(Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Likewise,
	and PLTSEQ_NOTOC and PLTCALL_NOTOC.
	(Target_powerpc::Scan::local, global, relocate): Likewise.
2019-07-13 09:57:50 +09:30
Alan Modra
f60c61e60e [GOLD] PowerPC tweak relnum tests
There is a call of relocate() to perform a single relocation.  In that
case the "relnum" parameter is -1U and of course it isn't appropriate
to consider any of the PowerPC code sequence optimisations triggered
by a following relocation.

	* powerpc.cc (Target_powerpc::Relocate::relocate): Don't look
	at next/previous reloc when relnum is -1.
2019-06-28 10:18:03 +09:30
Alan Modra
f073a3e8c6 [GOLD] PowerPC linkage table error
This fixes a segfault when attempring to output a "linkage table
error".  "object" is only non-NULL in the local symbol case.

	* powerpc.cc (Stub_table::plt_error): New function.
	(Stub_table::do_write): Use it.
	(Output_data_glink::do_write): Don't segfault emitting linkage
	table error.
2019-06-28 10:17:45 +09:30
Alan Modra
c432bbbaaa [GOLD] R_PPC64_REL16_HIGH relocs
These relocs have been around for quite a while.  It's past time gold
supported them.

elfcpp/
	* powerpc.h (R_PPC64_REL16_HIGH, R_PPC64_REL16_HIGHA),
	(R_PPC64_REL16_HIGHER, R_PPC64_REL16_HIGHERA),
	(R_PPC64_REL16_HIGHEST, R_PPC64_REL16_HIGHESTA): Define.

gold/
	* powerpc.cc (Target_powerpc::Scan::get_reference_flags): Handle
	REL16_HIGH* relocs.
	(Target_powerpc::Scan::local): Likewise.
	(Target_powerpc::Scan::global): Likewise.
	(Target_powerpc::Relocate::relocate): Likewise.
2019-06-28 10:17:08 +09:30
Martin Liska
a3972330f4 Fix a missing include of <string>
gold/ChangeLog:

2019-06-07  Martin Liska  <mliska@suse.cz>

	* errors.h: Include string.
2019-06-10 12:26:33 +02:00
Joshua Oreman
e173ea00c2 Fix problem with ICF where diffs in EH frame info is ignored.
PR gold/21066
	* gc.h (gc_process_relocs): Track relocations in .eh_frame sections
	when ICF is enabled, even though the .eh_frame sections themselves
	are not foldable.
	* icf.cc (get_section_contents): Change arguments to permit operation
	on just part of a section. Include extra identity regions in the
	referring section's contents recursively.
	(match_sections): Lock object here instead of in get_section_contents
	so that get_section_contents can operate recursively.
	(Icf::add_ehframe_links): New method.
	(Icf::find_identical_sections): Pass .eh_frame sections to
	add_ehframe_links(). Increase default iteration count from 2 to 3
	because handling exception info typically requires one extra iteration.
	* icf.h (Icf::extra_identity_list_): New data member with accessor.
	(is_section_foldable_candidate): Include .gcc_except_table sections.
	* options.h: Update documentation for new default ICF iteration count.
	* testsuite/Makefile.am (icf_test_pr21066): New test case.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/icf_test_pr21066.cc: New source file.
	* testsuite/icf_test_pr21066.sh: New test script.
2019-05-11 07:27:10 +08:00
Egeyar Bagcioglu
7ae39e2d40 Check whether symbols with MOVW_.ABS relocations require PLT entries (aarch64).
2019-02-19  Egeyar Bagcioglu  <egeyar.bagcioglu@oracle.com>

gold/
     PR gold/23870
     * aarch64.cc (Target_aarch64::Scan::global): Check if a symbol with
     R_AARCH64_MOVW_.ABS_* relocations requires a PLT entry.
     * testsuite/Makefile.am: Add aarch64_pr23870 test case.
     * testsuite/Makefile.in: Regenerate.
     * testsuite/aarch64_pr23870_bar.c: New file.
     * testsuite/aarch64_pr23870_foo.c: New file.
     * testsuite/aarch64_pr23870_main.S: New file.
2019-02-19 16:13:24 -08:00
Nick Clifton
e486594504 Updated French translation for ld/ and gold/ subdirectories 2019-02-12 13:22:42 +00:00
Nick Clifton
375cd4233d Updated translations for various binutils subdirectories. 2019-01-21 12:59:20 +00:00
Nick Clifton
f48dfe417e Change version to 2.32.51 and regenerate configure and pot files. 2019-01-19 16:51:42 +00:00
Nick Clifton
f974f26cb1 Add markers for 2.32 branch to NEWS and ChangeLog files. 2019-01-19 15:55:50 +00:00
Andrew Paprocki
3107326d3d Adjust bfd/warning.m4 egrep patterns
Adjust the `bfd/warning.m4` `egrep` patterns to handle preprocessors
that do not define `__GNUC__`, leaving the string in the output.

bfd/
	* warning.m4: Adjust egrep pattern for non-GNU compilers.
	* configure: Regenerate.
binutils/
	* configure: Regenerate.
gas/
	* configure: Regenerate.
gold/
	* configure: Regenerate.
gprof/
	* configure: Regenerate.
ld/
	* configure: Regenerate.
opcodes/
	* configure: Regenerate.
2019-01-09 13:51:08 +10:30
Alan Modra
827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
Alan Modra
d5c04e1bf8 ChangeLog rotation 2019-01-01 21:25:40 +10:30
Alan Modra
a529dcc854 [GOLD] Tweak keep_text_section_prefix test for PowerPC64 ELFv1
This test checks code layout by function symbol ordering, but that
doesn't work on powerpc64 ELFv1 where the function symbol is on a
descriptor.  A simple work-around is to have nm emit synthetic symbols
marking the code entry point of functions.  Since the text segment is
laid out before the data segment, the synthetic symbols will have
lower addresses than function descriptor symbols and be seen first in
nm -n output.

On other targets, nm --synthetic typically emits symbols on plt
entries.  Since the testcase doesn't call any of the functions of
interest there shouldn't be plt entries for those functions, so there
should be no potentially confusing extra symbols.

	* testsuite/Makefile.am (keep_text_section_prefix_nm.stdout):
	Pass --synthetic to nm.
	* testsuite/Makefile.in: Regenerate.
2018-12-18 11:57:45 +10:30
Alan Modra
c0ab2ae3cc [GOLD] icf_safe_so_test
PR 21128
	* testsuite/icf_safe_so_test.sh (check_fold): Rewrite to check
	multiple symbols at once.
	(arch_specific_safe_fold): Likewise, and call with the four foo*
	symbols expected to fold.
2018-12-08 13:24:14 +10:30
H.J. Lu
9da0a9988d gold: Provide more failed archive member info in error message
When gold fails to get an archive member, its error message doesn't
have information for

1. The failed archive member name.
2. The cause of failure: non-ELF object vs non-IR object.

This patch adds the failed archive member name and non-ELF/non-IR info
to gold error message.

	* archive.cc (Archive::get_elf_object_for_member): Also print
	archive member and non-ELF/non-IR info on error.
2018-12-06 12:29:01 -08:00
Alan Modra
9af7cc783a gold won't build with gcc-9
* symtab.h (Symbol::Symbol): Avoid -Wclass-memaccess warning.
2018-12-05 14:32:13 +10:30
Alexey Neyman
f4238194a2 Restore build on x86_64-w64-mingw32.
gold/
	PR gold/23594
	* configure.ac: Add checks for link, mkdtemp.
	* configure: Regenerate.
	* config.in: Regenerate.
	* plugin.cc (Plugin_recorder::init): Fall back to mktemp
	if mkdtemp is not available.
	(link_or_copy_file): Fall back to copy if link() is not available.
2018-12-03 23:50:48 -08:00
H.J. Lu
5f6c22aee7 gold: Get alignment of uncompressed section from ch_addralign
The ELF compression header has a field (ch_addralign) that is set to
the alignment of the uncompressed section. This way the section itself
can have a different alignment than the decompressed section.  Update
decompress_input_section to get alignment of the decompressed section
and use it when merging decompressed strings.

	PR binutils/23919
	* merge.cc (Output_merge_string<Char_type>::do_add_input_section):
	Get addralign from decompressed_section_contents.
	* object.cc (build_compressed_section_map): Set info.addralign.
	(Object::decompressed_section_contents): Add a palign
	argument and store p->second.addralign in *palign if it isn't
	NULL.
	* object.h (Compressed_section_info): Add addralign.
	(section_is_compressed): Add a palign argument, default it
	to NULL, store p->second.addralign in *palign if it isn't NULL.
	(Object::decompressed_section_contents): Likewise.
	* output.cc (Output_section::add_input_section): Get addralign
	from section_is_compressed.
2018-12-02 05:43:04 -08:00
Alan Modra
9b4e3a5e23 [GOLD] justsyms_exec test fail on powerpc64
This test fails on powerpc64le due to the justsyms_lib being built
with exported_data at 0x2010000, apparently due to the powerpc target
code generating an empty relro .branch_lt section.  Since the test
relies on the library having exported_data at 0x2000000, avoid the
problem by linking with -z norelro.  Also, the test doesn't need to
avoid checking the function symbol on powerpc elfv2.

	* testsuite/Makefile.am (justsyms_lib): Link with -z norelro.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/justsyms_exec.c (main): Do check exported_func
	on PowerPC64 ELFv2.
2018-11-26 22:07:46 +10:30
Alan Modra
2eccb8f91f [GOLD] support objdump -T display of st_other
PowerPC64 ELFv2 uses the top 3 bits of st_other to encode a function's
local entry point offset from its global entry point.  Allow st_other
bits except for visibility==default.

	* testsuite/ver_test_14.sh: Accept objdump -T display of st_other
	bits on powerpc64le.
2018-11-26 22:05:54 +10:30
Alan Modra
5acaada745 Make gold testsuite work with CC and CXX specifying -B
The patch allows the gold testsuite to pass when using something like
the following configure line, which works for the rest of the binutils
testsuite.  At least, it does if you don't configure your gcc with any
of the options that force a particular path to as or ld.

gccdir="/home/alan/build/gcc/prev-"
gccsrc="/home/alan/src/gcc.git"
gcctarg="x86_64-linux"
CC="${gccdir}gcc/xgcc -B${gccdir}gcc/" \
CXX="${gccdir}gcc/xg++ -B${gccdir}gcc/ -I${gccdir}$gcctarg/libstdc++-v3/include -I${gccdir}$gcctarg/libstdc++-v3/include/$gcctarg -I${gccsrc}/libstdc++-v3/libsupc++ -L${gccdir}$gcctarg/libstdc++-v3/src/.libs/" \
~/src/binutils-gdb/configure ...

gold's -Bgcctestdir/ option must come before the -B supplied by $CC
or $CXX, in order to pick up the linker we want to test.  Also when
using a not-yet-installed gcc, it is necessary to provide a collect-ld
in gcctestdir/ as otherwise a collect-ld script in -B${gccdir}gcc/
will be used and the wrong linker tested.

Besides this, the patch fixes some bugs: The $COMPILE -D_FORTIFY_SOURCE
edit was wrong (but worked for usual values), and the $CXXLINK_S edit
unnecessarily but harmlessly used extra backslash quoting.  See
posix shell documentation regarding quoting, or
www.gnu.org/software/bash/manual/bashref.html#Command-Substitution

Also, -Bgcctestdir/ in one place makes it less likely a new test will
be added that accidentally lacks the option.

	* Makefile.am (gcctestdir1/ld): Use $@ and absolute paths.
	(gcctestdir1/collect-ld): New.
	(ld1_DEPENDENCIES): Add gcctestdir1/collect-ld.
	(ld1_LDFLAGS): Remove -Bgcctestdir1/.
	(editcc1, ld1_LINK): Define.
	(gcctestdir2/ld, gcctestdir2/collect-ld, ld2_DEPENDENCIES),
	(ld2_LDFLAGS, editcc2, ld2_LINK),
	(ld1_r_DEPENDENCIES, ld1_r_LDFLAGS, ld1_r_LINK),
	(gcctestdir2-r/ld, gcctestdir2-r/collect-ld, ld2_r_DEPENDENCIES),
	(ld2_r_LDFLAGS, editcc2r, ld2_r_LINK),
	(gcctestdir3/ld, gcctestdir3/collect-ld, ld3_DEPENDENCIES),
	(ld3_LDFLAGS, editcc3, ld3_LINK),
	(gcctestdir4/ld, gcctestdir4/collect-ld, ld4_DEPENDENCIES),
	(ld4_LDFLAGS, editcc4, ld4_LINK): Similarly.
	* Makefile.in: Regenerate.
	* testsuite/Makefile.am (editcc): Define sed command to put
	our -B option first.  Remove other occurrences of -Bgcctestdir/
	throughout file.
	(editcc1): Define for -D_FORTIFY_SOURCE stripping.
	(editcc2): Define for -static-libgcc/libstdc++ stripping.
	(LINK1, CXXLINK1): Don't use CCLD or CXXLD.
	(CCLD, CXXLD, COMPILE, LINK, CXXCOMPILE, CXXLINK, CXXLINK_S): Define
	using editcc macros.
	(gcctestdir/collect-ld): New rule, add as a dependency of..
	(gcctestdir/ld): ..this.  Use $@ and abs_top_buildir.
	(gcctestdir/as): Use $@.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/incremental_test.sh (actual): Match collect-ld too.
2018-11-08 11:20:34 +10:30
Alan Modra
396ce99883 [GOLD] make clean
Cleans a few more test files.

	* Makefile.am (MOSTLYCLEANFILES): Define.
	* Makefile.in: Regnerate.
	* testsuite/Makefile.am (MOSTLYCLEANFILES): Add ver_test_14 and
	gnu_property_test.
	* testsuite/Makefile.in: Regnerate.
2018-11-02 14:00:15 +10:30
Cherry Zhang
08ea4a7805 PR23769, mixing split-stack and non-split-stack error message
Corrects which file is reported as being split-stack.

	PR 23769
	* gold.cc (queue_middle_tasks): Correct split-stack error message.
2018-10-16 16:41:57 +10:30
Chenghua Xu
9108bc33b1 [MIPS] Add Loongson 2K1000 proccessor support.
bfd/
	* archures.c (bfd_architecture): New machine
	bfd_mach_mips_gs264e.
	* bfd-in2.h (bfd_architecture): Likewise.
	* cpu-mips.c (enum I_xxx): Likewise.
	(arch_info_struct): Likewise.
	* elfxx-mips.c (_bfd_elf_mips_mach): Handle
	E_MIPS_MACH_GS264E.
	(mips_set_isa_flags): Likewise.
	(mips_mach_extensions): Map bfd_mach_mips_gs264e to
	bfd_mach_mips_gs464e extension.

binutils/
	* NEWS: Mention Loongson 2K1000 proccessor support.
	* readelf.c (get_machine_flags): Handle gs264e.

elfcpp/
	* mips.c (EF_MIPS_MACH): New E_MIPS_MACH_GS264E.

gas/
	* config/tc-mips.c (ISA_HAS_ODD_SINGLE_FPR): Exclude CPU_GS264E.
	(mips_cpu_info_table): Add gs264e descriptors.
	* doc/as.texi (march table): Add gs264e.

include/
	* elf/mips.h (E_MIPS_MACH_XXX): New E_MIPS_MACH_GS264E.
	* opcode/mips.h (CPU_XXX): New CPU_GS264E.

ld/
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Run good_combination
	gs264e and gs464e.

opcodes/
	* mips-dis.c (mips_arch_choices): Add gs264e descriptors.
2018-08-29 20:55:25 +08:00
Chenghua Xu
bd782c07b9 [MIPS] Add Loongson 3A2000/3A3000 proccessor support.
bfd/
	* archures.c (bfd_architecture): New machine
	bfd_mach_mips_gs464e.
	* bfd-in2.h (bfd_architecture): Likewise.
	* cpu-mips.c (enum I_xxx): Likewise.
	(arch_info_struct): Likewise.
	* elfxx-mips.c (_bfd_elf_mips_mach): Handle
	E_MIPS_MACH_GS464E.
	(mips_set_isa_flags): Likewise.
	(mips_mach_extensions): Map bfd_mach_mips_gs464e to
	bfd_mach_mips_gs464 extension.

binutils/
	* NEWS: Mention Loongson 3A2000/3A3000 proccessor support.
	* readelf.c (get_machine_flags): Handle gs464e.

elfcpp/
	* mips.c (EF_MIPS_MACH): New E_MIPS_MACH_GS464E.

gas/
	* config/tc-mips.c (ISA_HAS_ODD_SINGLE_FPR): Exclude CPU_GS464E.
	(mips_cpu_info_table): Add gs464e descriptors.
	* doc/as.texi (march table): Add gs464e.

include/
	* elf/mips.h (E_MIPS_MACH_XXX): New E_MIPS_MACH_GS464E.
	* opcode/mips.h (CPU_XXX): New CPU_GS464E.

ld/
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Run good_combination
	gs464e and gs464.

opcodes/
	* mips-dis.c (mips_arch_choices): Add gs464e descriptors.
2018-08-29 20:43:19 +08:00
Chenghua Xu
ac8cb70f36 [MIPS] Add Loongson 3A1000 proccessor support.
bfd/
	* archures.c (bfd_architecture): Rename
	bfd_mach_mips_loongson_3a to bfd_mach_mips_gs464.
	* bfd-in2.h (bfd_architecture): Likewise.
	* cpu-mips.c (enum I_xxx): Likewise.
	(arch_info_struct): Likewise.
	* elfxx-mips.c (_bfd_elf_mips_mach): Likewise.
	(mips_set_isa_flags): Likewise.
	(mips_mach_extensions): Likewise.
	(bfd_mips_isa_ext_mach): Likewise.
	(bfd_mips_isa_ext): Likewise.
	(print_mips_isa_ext): Delete AFL_EXT_LOONGSON_3A.

binutils/
	* NEWS: Mention Loongson 3A1000 proccessor support.
	* readelf.c (get_machine_flags): Rename loongson-3a to gs464.
	(print_mips_isa_ext): Delete AFL_EXT_LOONGSON_3A.

elfcpp/
	* mips.c (EF_MIPS_MACH): Rename E_MIPS_MACH_LS3A to
	E_MIPS_MACH_GS464.

gas/
	* config/tc-mips.c (ISA_HAS_ODD_SINGLE_FPR): Rename
	CPU_LOONGSON_3A to CPU_GS464.
	(mips_cpu_info_table): Add gs464 descriptors, Keep
	loongson3a as an alias of gs464 for compatibility.
	* doc/as.texi (march table): Rename loongson3a to gs464.
	* testsuite/gas/mips/loongson-3a-mmi.d: Set "ISA Extension"
	flag to None.

gold/
	* mips.cc (Mips_mach, add_machine_extensions, elf_mips_mach):
	Rename loongson3a to gs464.
	(mips_isa_ext_mach, mips_isa_ext): Delete loongson3a.
	(infer_abiflags): Use ases instead of isa_ext for infer ABI
flags.
	(elf_mips_mach_name): Rename loongson3a to gs464.

include/
	* elf/mips.h (E_MIPS_MACH_XXX): Rename E_MIPS_MACH_LS3A to
	E_MIPS_MACH_GS464.
	(AFL_EXT_XXX): Delete AFL_EXT_LOONGSON_3A.
	* opcode/mips.h (INSN_XXX): Delete INSN_LOONGSON_3A.
	(CPU_XXX): Rename CPU_LOONGSON_3A to CPU_GS464.
	* opcode/mips.h (mips_isa_table): Delete CPU_LOONGSON_3A case.

ld/
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Rename loongson3a
	to gs464.

opcodes/
	* mips-dis.c (mips_arch_choices): Add gs464 descriptors, Keep
	loongson3a as an alias of gs464 for compatibility.
	* mips-opc.c (mips_opcodes): Change Comments.
2018-08-29 20:32:30 +08:00
Tulio Magno Quites Machado Filho
f6f9ed015e Fix "may be used uninitialized" warning.
* object.cc (Sized_relobj_file::map_to_kept_section): Initialize
	kept_file.
2018-08-07 22:40:33 -07:00