Commit Graph

105130 Commits

Author SHA1 Message Date
Alan Modra
dc83f2d20e Split relocation defines out of coff/internal.h
include/
	* coff/internal.h: Delete obsolete relocation defines.  Move used
	relocation defines..
	* coff/i386.h: ..to here..
	* coff/ti.h: ..and here..
	* coff/x86_64.h: ..and here..
	* coff/z80.h: ..and here..
	* coff/z8k.h: ..and here.
bfd/
	* reloc.c: Include x86_64.h rather than internal.h.
2021-03-03 17:46:24 +10:30
GDB Administrator
ca87bad0e9 Automatic date update in version.in 2021-03-03 00:00:19 +00:00
Tom Tromey
19a9185537 Fix Readline 8.1 build on mingw
The mingw build fails with Readline 8.1, because sigprocmask is called
unconditionally.  This patch adds the missing check for
HAVE_POSIX_SIGNALS.

I reported this upstream here:

    https://lists.gnu.org/archive/html/bug-readline/2021-01/msg00011.html

readline/ChangeLog
2021-03-02  Tom Tromey  <tom@tromey.com>

	* readline/signals.c (_rl_handle_signal): Add missing check for
	HAVE_POSIX_SIGNALS.
2021-03-02 13:42:37 -07:00
Tom Tromey
b4f26d541a Import GNU Readline 8.1
This imports readline 8.1.  I did this via various hackery in a
readline git repository to make a version of readline identical to
gdb's, then did a git merge.

readline/ChangeLog
2021-03-02  Tom Tromey  <tom@tromey.com>

	* Import readline 8.1.
2021-03-02 13:42:37 -07:00
Tom Tromey
bbcdf9ab73 Rewrite GNAT-encoded fixed point types in DWARF reader
gdb currently supports two different styles of fixed-point.  The
original style, where fixed point types are "GNAT encoded", is handled
primarily in the Ada code.  The newer style, encoded using DWARF, is
handled by the core of gdb.

This patch changes gdb to read the GNAT encodings in the DWARF reader
as well.  This removes some code and unifies the two paths.  As a
result, GNAT-encoded fixed-point now works a bit better.

One possible drawback of this change is that, if someone uses stabs,
then fixed-point might now stop working.  I consider stabs to be fully
obsolete, though, so I don't intend to address this.

gdb/ChangeLog
2021-03-02  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (cast_from_gnat_encoded_fixed_point_type)
	(cast_to_gnat_encoded_fixed_point_type): Remove.
	(ada_value_cast, ada_evaluate_subexp): Update.
	(gnat_encoded_fixed_point_type_info)
	(ada_is_gnat_encoded_fixed_point_type)
	(gnat_encoded_fixed_point_delta)
	(gnat_encoded_fixed_point_scaling_factor): Remove.
	* ada-lang.h (ada_is_gnat_encoded_fixed_point_type)
	(gnat_encoded_fixed_point_delta)
	(gnat_encoded_fixed_point_scaling_factor): Don't declare.
	* ada-typeprint.c (print_gnat_encoded_fixed_point_type): Remove.
	(ada_print_type): Update.
	* ada-valprint.c (ada_value_print_num): Update.
	* dwarf2/read.c (ada_get_gnat_encoded_number)
	(ada_get_gnat_encoded_ratio): New functions.
	(finish_fixed_point_type): Use them.  Add parameters.
	(GNAT_FIXED_POINT_SUFFIX): New define.
	(gnat_encoded_fixed_point_type_info): New function.
	(read_base_type): Handle gnat encodings.

gdb/testsuite/ChangeLog
2021-03-02  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/fixed_points.exp: Remove most special cases for minimal
	encodings.
2021-03-02 13:08:25 -07:00
Tom Tromey
5f9febe0f6 Use std::string rather than grow_vect
This removes the "GROW_VECT" macro and helper function in favor of
simply using std::string in a few spots.

gdb/ChangeLog
2021-03-02  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (ada_fold_name, ada_variant_discrim_name)
	(ada_enum_name, scan_discrim_bound, to_fixed_range_type): Use
	std::string.
	(GROW_VECT): Remove.
	(grow_vect): Remove.
2021-03-02 13:00:46 -07:00
Tom Tromey
d1183b064c Return a vector from ada_lookup_symbol_list
This changes ada_lookup_symbol_list to return a std::vector, and
changes various other helper functions to follow.  This simplifies the
code, and makes it more type-safe (by using a vector where an obstack
had been used).

gdb/ChangeLog
2021-03-02  Tom Tromey  <tromey@adacore.com>

	* ada-lang.h (ada_lookup_symbol_list): Return a vector.
	* ada-lang.c (resolve_subexp): Update.
	(ada_resolve_function): Accept a vector.
	(is_nonfunction, add_defn_to_vec)
	(add_symbols_from_enclosing_procs): Likewise.
	(num_defns_collected, defns_collected): Remove.
	(remove_extra_symbols): Return a vector.
	(remove_irrelevant_renamings): Return void.
	(ada_add_local_symbols): Accept a vector.
	(struct match_data) <obstackp>: Remove.
	<resultp>: New member.
	(aux_add_nonlocal_symbols): Update.
	(ada_add_block_renamings, add_nonlocal_symbols)
	(ada_add_all_symbols): Accept a vector.
	(ada_lookup_symbol_list_worker, ada_lookup_symbol_list): Return a
	vector.
	(ada_lookup_symbol): Update.
	(ada_add_block_symbols): Accept a vector.
	(get_var_value, iterate_over_symbols): Update.
	* ada-exp.y (block_lookup, write_var_or_type, write_name_assoc):
	Update.
2021-03-02 13:00:45 -07:00
Tom Tromey
886d459fbe Simplify resolve_subexp by using C++ algorithms
This changes resolve_subexp to use any_of and the erase-remove idiom
to simplify the code somewhat.  This simplifies the next patch a bit.

gdb/ChangeLog
2021-03-02  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (resolve_subexp): Use any_of and erase-remove idiom.
2021-03-02 13:00:45 -07:00
Tom Tromey
bdcccc5639 Use new for ada_symbol_cache
This changes the ada_symbol_cache to be allocated with 'new' and
managed via unique_ptr.  This simplifies the code somewhat.  Also,
ada_clear_symbol_cache is changed so that it does not allocate a
symbol cache just to clear it.

gdb/ChangeLog
2021-03-02  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (struct ada_symbol_cache) <cache_space>: Now an
	auto_obstack.
	<root>: Initialize.
	(ada_pspace_data): Remove destructor.
	<sym_cache>: Now a unique_ptr.
	(ada_init_symbol_cache, ada_free_symbol_cache): Remove.
	(ada_get_symbol_cache): Use 'new'.
	(ada_clear_symbol_cache): Rewrite.
2021-03-02 13:00:45 -07:00
Tom Tromey
1228719f31 Check objfile->sf in ada-lang.c
Most places in gdb that reference objfile->sf also check that it is
not null.  It is valid for it to be null, because find_sym_fns can
return null for some kinds of object file.  However, it's rare to
encounter this scenario with Ada code.  I only encountered it when
looking at a fork of gdb that, I believe, makes its own objfiles
without setting 'sf'.

This patch changes ada-lang.c to check this field before using it.
This avoids any potential crash here.  There's no test case because
I'm not even sure this is possible to trip over with an unmodified
gdb.

There are some other unchecked uses in gdb, but at a quick glance they
all seem to be involved with symbol reading, which of course won't
happen when sf==null.

gdb/ChangeLog
2021-03-02  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (add_nonlocal_symbols): Handle case where objfile->sf
	is null.
2021-03-02 12:00:44 -07:00
Nick Clifton
ca8f6bc629 Fix the BFD library's parsing of DIEs where specification attributes can refer to variables that are defined later on.
PR 27484
	* dwarf2.c (scan_unit_for_symbols): Scan twice, once to accumulate
	function and variable tags and a second time to resolve their
	attributes.
2021-03-02 16:08:23 +00:00
Nick Alcock
211bcd0133 bfd, ld, libctf: skip zero-refcount strings in CTF string reporting
This is a tricky one.  BFD, on the linker's behalf, reports symbols to
libctf via the ctf_new_symbol and ctf_new_dynsym callbacks, which
ultimately call ctf_link_add_linker_symbol.  But while this happens
after strtab offsets are finalized, it happens before the .dynstr is
actually laid out, so we can't iterate over it at this stage and
it is not clear what the reported symbols are actually called.  So
a second callback, examine_strtab, is called after the .dynstr is
finalized, which calls ctf_link_add_strtab and ultimately leads
to ldelf_ctf_strtab_iter_cb being called back repeatedly until the
offsets of every string in the .dynstr is passed to libctf.

libctf can then use this to get symbol names out of the input (which
usually stores symbol types in the form of a name -> type mapping at
this stage) and extract the types of those symbols, feeding them back
into their final form as a 1:1 association with the real symtab's
STT_OBJ and STT_FUNC symbols (with a few skipped, see
ctf_symtab_skippable).

This representation is compact, but has one problem: if libctf somehow
gets confused about the st_type of a symbol, it'll stick an entry into
the function symtypetab when it should put it into the object
symtypetab, or vice versa, and *every symbol from that one on* will have
the wrong CTF type because it's actually looking up the type for a
different symbol.

And we have just such a bug.  ctf_link_add_strtab was not taking the
refcounts of strings into consideration, so even strings that had been
eliminated from the strtab by virtue of being in objects eliminated via
--as-needed etc were being reported.  This is harmful because it can
lead to multiple strings with the same apparent offset, and if the last
duplicate to be reported relates to an eliminated symbol, we look up the
wrong symbol from the input and gets its type wrong: if it's unlucky and
the eliminated symbol is also of the wrong st_type, we will end up with
a corrupted symtypetab.

Thankfully the wrong-st_type case is already diagnosed by a
this-can-never-happen paranoid warning:

  CTF warning: Symbol 61a added to CTF as a function but is of type 1

or the converse

 * CTF warning: Symbol a3 added to CTF as a data object but is of type 2

so at least we can tell when the corruption has spread to more than one
symbol's type.

Skipping zero-refcounted strings is easy: teach _bfd_elf_strtab_str to
skip them, and ldelf_ctf_strtab_iter_cb to loop over skipped strings
until it falls off the end or finds one that isn't skipped.

bfd/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* elf-strtab.c (_bfd_elf_strtab_str): Skip strings with zero refcount.

ld/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* ldelfgen.c (ldelf_ctf_strtab_iter_cb): Skip zero-refcount strings.

libctf/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-create.c (symtypetab_density): Report the symbol name as
	well as index in the name != object error; note the likely
	consequences.
	* ctf-link.c (ctf_link_shuffle_syms): Report the symbol index
	as well as name.
2021-03-02 15:10:10 +00:00
Nick Alcock
8e7e446446 libctf: free ctf_dynsyms properly
In the "no symbols" case (commonplace for executables), we were freeing
the ctf_dynsyms using free(), instead of ctf_dynhash_destroy(), leaking
a little memory.

(This is harmless in the common case of ld usage, but libctf might be
used by persistent processes too.)

libctf/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-link.c (ctf_link_shuffle_syms): Free ctf_dynsyms properly.
2021-03-02 15:10:09 +00:00
Nick Alcock
cf6a0b989a libctf: fix signed/unsigned comparison confusion
Comparing an encoding's cte_bits to a ctf_type_size needs a cast:
one is a uint32_t and the other is an ssize_t.

libctf/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-dump.c (ctf_dump_format_type): Fix signed/unsigned confusion.
2021-03-02 15:10:08 +00:00
Nick Alcock
4659554b28 libctf: minor error-handling fixes
A transient bug in the preceding change (fixed before commit) exposed a
new failure, of ld/testsuite/ld-ctf/diag-parname.d.  This attempts to
ensure that if we link a dict with child type IDs but no attached
parent, we get a suitable ECTF_NOPARENT error.  This was happening
before this commit, but only by chance, because ctf_variable_iter and
ctf_variable_next check to see if the dict they're passed is a child
dict without an associated parent.  We forgot error-checking on the
ctf_variable_next call, and as a result this was concealed -- and
looking for the problem exposed a new bug.

If any of the lookups beneath ctf_dedup_hash_type fail, the CTF link
does *not* fail, but acts quite bizarrely, skipping the type but
emitting an error to the CTF error/warning log -- so the linker will
report an error, emit a partial CTF dict missing some types, and exit
with exitcode 0 as if nothing went wrong.  Since ctf_dedup_hash_type is
never expected to fail in normal operation, this is surely wrong:
failures at emission time do not emit partial CTF dicts, so failures
at hashing time should not either.

So propagate the error back up.

Also fix a couple of smaller bugs where we fail to properly free things
and/or propagate error codes on various rare link-time errors and
out-of-memory conditions.

libctf/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-dedup.c (ctf_dedup): Pass on errors from ctf_dedup_hash_type.
	Call ctf_dedup_fini properly on other errors.
	(ctf_dedup_emit_type): Set the errno on dynhash insertion failure.
	* ctf-link.c (ctf_link_deduplicating_per_cu): Close outputs beyond
	output 0 when asserting because >1 output is found.
	(ctf_link_deduplicating): Likewise, when asserting because the
	shared output is not the same as the passed-in fp.
2021-03-02 15:10:08 +00:00
Nick Alcock
f5060e5633 libctf: add a deduplicator-specific type mapping table
When CTF linking is done, the linker has to track the association
between types in the inputs and types in the outputs.  The deduplicator
does this via the cd_output_emission_hashes, which maps from hashes of
types (valid in both the input and output) to the IDs of types in the
specific dict in which the cd_emission_hashes is held.  However, the
nondeduplicating linker and ctf_add_type used a different mechanism, a
dedicated hashtab stored in the ctf_link_type_mapping, populated via
ctf_add_type_mapping and queried via the ctf_type_mapping function.  To
allow the same functions to be used for variable and symbol population
in both the deduplicating and nondeduplicating linker, the deduplicator
carefully transferred all its input->output mappings into this hashtab
before returning.

This is *expensive*. The number of entries in this hashtab scales as the
number of input types, and unlike the hashing machinery the type mapping
machinery (the only other thing which scales that way) has not been much
optimized.

Now the nondeduplicating linker is gone, we can throw this out, move
the existing type mapping machinery to ctf-create.c and dedicate it to
ctf_add_type alone, and add a new function ctf_dedup_type_mapping which
uses the deduplicator's built-in knowledge of type mappings directly,
without requiring an expensive repopulation phase.

This speeds up a test link of nouveau.ko (a good worst-case candidate
with a lot of types in each of a lot of input files) from 9.11s to 7.15s
in my testing, a speedup of over 20%.

libctf/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-impl.h (ctf_dict_t) <ctf_link_type_mapping>: No longer used
	by the nondeduplicating linker.
	(ctf_add_type_mapping): Removed, now static.
	(ctf_type_mapping): Likewise.
	(ctf_dedup_type_mapping): New.
	(ctf_dedup_t) <cd_input_nums>: New.
	* ctf-dedup.c (ctf_dedup_init): Populate it.
	(ctf_dedup_fini): Free it again.  Emphasise that this has to be
	the last thing called.
	(ctf_dedup): Populate it.
	(ctf_dedup_populate_type_mapping): Removed.
	(ctf_dedup_populate_type_mappings): Likewise.
	(ctf_dedup_emit): No longer call it.  No longer call
	ctf_dedup_fini either.
	(ctf_dedup_type_mapping): New.
	* ctf-link.c (ctf_unnamed_cuname): New.
	(ctf_create_per_cu): Arguments must be non-null now.
	(ctf_in_member_cb_arg): Removed.
	(ctf_link): No longer populate it.  No longer discard the
	mapping table.
	(ctf_link_deduplicating_one_symtypetab): Use
	ctf_dedup_type_mapping, not ctf_type_mapping.  Use
	ctf_unnamed_cuname.
	(ctf_link_one_variable): Likewise.  Pass in args individually: no
	longer a ctf_variable_iter callback.
	(empty_link_type_mapping): Removed.
	(ctf_link_deduplicating_variables): Use ctf_variable_next, not
	ctf_variable_iter.  No longer pack arguments to
	ctf_link_one_variable into a struct.
	(ctf_link_deduplicating_per_cu): Call ctf_dedup_fini once
	all link phases are done.
	(ctf_link_deduplicating): Likewise.
	(ctf_link_intern_extern_string): Improve comment.
	(ctf_add_type_mapping): Migrate...
	(ctf_type_mapping): ... these functions...
	* ctf-create.c (ctf_add_type_mapping): ... here...
	(ctf_type_mapping): ... and make static, for the sole use of
	ctf_add_type.
2021-03-02 15:10:07 +00:00
Nick Alcock
478c04a55e libctf: remove reference to "unconflicted link mode".
There is no such thing, and the comment makes no sense, and doesn't
match what the code is doing.  We always want to put variables in the
same dicts as the types they relate to if at all possible.

libctf/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-link.c (ctf_link_one_variable): Remove reference to
	"unconflicted link mode".
2021-03-02 15:10:06 +00:00
Nick Alcock
8915c559d4 libctf, include: remove the nondeduplicating CTF linker
The nondeduplicating CTF linker was kept around when the deduplicating
one was added so that people had something to fall back to in case the
deduplicating linker turned out to be buggy.  It's now much more stable
than the nondeduplicating linker, in addition to much faster, using much
less memory and producing much better output.  In addition, while
libctf has a linker flag to invoke the nondeduplicating linker, ld does
not expose it: the only way to turn it on within ld is an intentionally-
undocumented environment variable.  So we can remove it without any ABI
or user-visibility concerns (the only thing we leave around is the
CTF_LINK_NONDEDUP flag, which can easily be interpreted as "deduplicate
less", though right now it does nothing).

This lets us remove a lot of complexity associated with tracking
filenames and CU names separately (something the deduplcating linker
never bothered with, since the cunames are always reliable and ld never
hands us useful filenames anyway)

The biggest lacuna left behind is the ctf_type_mapping machinery, which
slows down deduplicating links quite a lot.  We can't just ditch it
because ctf_add_type uses it: removing the slowdown from the
deduplicating linker is a job for another commit.

include/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-api.h (CTF_LINK_SHARE_DUPLICATED): Note that this might
	merely change how much deduplication is done.

libctf/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-link.c (ctf_create_per_cu): Drop FILENAME now that it is
	always identical to CUNAME.
	(ctf_link_deduplicating_one_symtypetab): Adjust.
	(ctf_link_one_type): Remove.
	(ctf_link_one_input_archive_member): Likewise.
	(ctf_link_close_one_input_archive): Likewise.
	(ctf_link_one_input_archive): Likewise.
	(ctf_link): No longer call it.  Drop CTF_LINK_NONDEDUP path.
	Improve header comment a bit (dicts, not files).  Adjust
	ctf_create_per_cu call.
	(ctf_link_deduplicating_variables): Simplify.
	(ctf_link_in_member_cb_arg_t) <cu_name>: Remove.
	<in_input_cu_file>: Likewise.
	<in_fp_parent>: Likewise.
	<done_parent>: Likewise.
	(ctf_link_one_variable): Turn uses of in_file_name to in_cuname.
2021-03-02 15:10:05 +00:00
Nick Alcock
fd12633780 libctf: fix ChangeLog date
I pushed this change without fixing up the date by mistake.
2021-03-02 15:09:43 +00:00
Nick Alcock
ac36e134d9 libctf: reimplement many _iter iterators in terms of _next
Ever since the generator-style _next iterators were introduced, there
have been separate implementations of the functional-style _iter
iterators that do the same thing as _next.

This is annoying and adds more dependencies on the internal guts of the
file format.  Rip them all out and replace them with the corresponding
_next iterators.  Only ctf_archive_raw_iter and ctf_label_iter survive,
the former because there is no access to the raw binary data of archives
via any _next iterator, and the latter because ctf_label_next hasn't
been implemented (because labels are currently not used for anything).

Tested by reverting the change (already applied) that reimplemented
ctf_member_iter in terms of ctf_member_next, then verifying that the
_iter and _next iterators produced the same results for every iterable
entity within a large type archive.

libctf/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-types.c (ctf_member_iter): Move 'rc' to an inner scope.
	(ctf_enum_iter): Reimplement in terms of ctf_enum_next.
	(ctf_type_iter): Reimplement in terms of ctf_type_next.
	(ctf_type_iter_all): Likewise.
	(ctf_variable_iter): Reimplement in terms of ctf_variable_next.
	* ctf-archive.c (ctf_archive_iter_internal): Remove.
	(ctf_archive_iter): Reimplement in terms of ctf_archive_next.
2021-03-02 15:09:18 +00:00
Nick Alcock
eaa2913a7a libctf: ctf_archive_next should set the parent name consistently
The top level of CTF containers is a "CTF archive", which contains a
collection of named members (each a CTF dictionary).  In the serialized
file format, this is optional and skipped if the archive would have only
one member, as when no ambiguous types are present: so it is commonplace
to have a simple ctf_dict_t written out, with no archive container
wrapped around it.

But, unlike ctf_archive_iter, ctf_archive_next didn't quite handle this
case right.  It should set the name of this fake "member" to
_CTF_SECTION, i.e. ".ctf", but it was failing to do so, so callers got
an unintialized variable back instead and were understandably confused.

So set the name properly.

libctf/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-archive.c (ctf_archive_next): Set the name of parents in
	single-member archives.
2021-03-02 15:08:03 +00:00
Alan Modra
b80e421f91 PR27451, -z start_stop_gc for powerpc64
PowerPC64 has its own gc_mark_dynamic_ref.

bfd/
	PR 27451
	* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Ignore synthesized
	linker defined start/stop symbols when start_stop_gc.
ld/
	* testsuite/ld-powerpc/startstop.d,
	* testsuite/ld-powerpc/startstop.r,
	* testsuite/ld-powerpc/startstop.s: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run it.
2021-03-02 21:49:56 +10:30
Alan Modra
f5b9c288a3 PowerPC64 undefined weak visibility vs GOT optimisation
Undefined weak symbols with non-default visibility are seen as local
by SYMBOL_REFERENCES_LOCAL.  This stops a got indirect to relative
optimisation for them, so that pies and dlls don't get non-zero values
when loading somewhere other than the address they are linked at
(which always happens).  The optimisation could be allowed for pdes,
but I thought it best not to allow it there too.

bfd/
	* elf64-ppc.c (ppc64_elf_relocate_section): Don't optimise got
	indirect to pc-relative or toc-relative for undefined symbols.
ld/
	* testsuite/ld-powerpc/weak1.d,
	* testsuite/ld-powerpc/weak1.r,
	* testsuite/ld-powerpc/weak1.s,
	* testsuite/ld-powerpc/weak1so.d,
	* testsuite/ld-powerpc/weak1so.r: New tests.
	* testsuite/ld-powerpc/powerpc.exp: Run them.
2021-03-02 21:47:42 +10:30
GDB Administrator
ec11fcffc0 Automatic date update in version.in 2021-03-02 00:00:18 +00:00
Nick Clifton
ba6eb62ff0 Add DWARF-5 section names to PE and PEP linker scripts.
PR 27268
	* scripttempl/pe.sc: Add DWARF-5 section names.
	* scripttempl/pep.sc: Likewise.
2021-03-01 16:25:06 +00:00
H.J. Lu
ecd65684f5 Warn for missing separate debug files only if needed
We shouldn't warn missing separate debug files when debug info isn't
needed.

	PR binutils/27486
	* dwarf.c (load_separate_debug_info): Issue warning only if
	do_debug_links is set.
	* testsuite/binutils-all/compress.exp: Run objdump and readelf
	with missing debug file.
2021-03-01 05:34:47 -08:00
Alan Modra
8ee10e8609 PR27451, -z start_stop_gc
When --gc-sections is in effect, a reference from a retained section
to __start_SECNAME or __stop_SECNAME causes all input sections named
SECNAME to also be retained, if SECNAME is representable as a C
identifier and either __start_SECNAME or __stop_SECNAME is synthesized
by the linker.  Add an option to disable that feature, effectively
ignoring any relocation that references a synthesized linker defined
__start_ or __stop_ symbol.

	PR 27451
include/
	* bfdlink.h (struct bfd_link_info): Add start_stop_gc.
bfd/
	* elflink.c (_bfd_elf_gc_mark_rsec): Ignore synthesized linker
	defined start/stop symbols when start_stop_gc.
	(bfd_elf_gc_mark_dynamic_ref_symbol): Likewise.
	(bfd_elf_define_start_stop): Don't modify ldscript_def syms.
	* linker.c (bfd_generic_define_start_stop): Likewise.
ld/
	* emultempl/elf.em: Handle -z start-stop-gc and -z nostart-stop-gc.
	* lexsup.c (elf_static_list_options): Display help for them.  Move
	help for -z stack-size to here from elf_shlib_list_options. Add
	help for -z start-stop-visibility and -z undefs.
	* ld.texi: Document -z start-stop-gc and -z nostart-stop-gc.
	* NEWS: Mention -z start-stop-gc.
	* testsuite/ld-gc/start2.s,
	* testsuite/ld-gc/start2.d: New test.
	* testsuite/ld-gc/gc.exp: Run it.
2021-03-01 17:28:03 +10:30
Alan Modra
7824c1d22f Weak references to __start_/__stop_ symbols
If a weak reference to a __start_foo or __stop_foo symbol ends up
having no definition due to all the foo sections being removed for
some reason, undef_start_stop currently makes the symbol strong
undefined.  That risks a linker undefined symbol error.  Fix that by
making the symbol undefweak and also undo some dynamic symbol state.

Note that saving the state of the symbol type at the time
lang_init_start_stop runs is not sufficient.  The linker may have
merged in a shared library reference by that point and made what was
an undefweak in regular objects, a strong undefined.  So it is
necessary to look at the ELF symbol flags to decide whether an
undefweak is the proper resolution.

Something probably should be done for COFF/PE too, but I'm unsure how
to do go about that.

	* ldlang.c (undef_start_stop): For ELF make undefined start/stop
	symbols undefweak if that was how they were referenced.  Undo
	dynamic state too.
2021-03-01 14:26:39 +10:30
Alan Modra
6a1224ec76 PR27128, nm -P portable output format regression
Add nm --without-symbol-versions.

binutils/
	PR 27128
	* doc/binutils.texi: Add nm --with-symbol-versions and
	--without-symbol-versions documentation.
	* nm.c (with_symbol_versions): New variable.
	(enum long_option_values): Delete OPTION_WITH_SYMBOL_VERSIONS.
	(long_options): Make --with-symbol-versions entry twiddle the flag.
	Add --without-symbol-versions.
	(print_symname): Strip version when !with_symbol_versions.  Add
	dynamic version info under control of with_symbol_versions.
	(main): Remove OPTION_WITH_SYMBOL_VERSIONS case.
ld/
	* testsuite/ld-elf/pr25708.d: Add --with-symbol-versions to nm.
	* testsuite/ld-elf/pr27128a.d: Likewise.
	* testsuite/ld-elf/pr27128b.d: Likewise.
	* testsuite/ld-elf/pr27128c.d: Likewise.
	* testsuite/ld-elf/pr27128d.d: Likewise.
	* testsuite/ld-elf/pr27128e.d: Likewise.
2021-03-01 14:26:39 +10:30
GDB Administrator
cf850febf6 Automatic date update in version.in 2021-03-01 00:00:19 +00:00
H.J. Lu
1dbde357be Add missing changes to Makefile.tpl
Update Makefile.tpl to add missing changes in

commit af019bfde9
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Jan 9 06:51:15 2021 -0800

    Support the PGO build for binutils+gdb

"autogen Makefile.def" showed no changes in Makefile.in.

	PR binutils/26766
	* Makefile.tpl (PGO_BUILD_TRAINING_FLAGS_TO_PASS): Add
	PGO_BUILD_TRAINING=yes.
	(PGO_BUILD_TRAINING_MFLAGS): New.
	(all): Pass $(PGO_BUILD_TRAINING_MFLAGS) to the PGO build.
2021-02-28 04:39:38 -08:00
Mike Frysinger
9f34b60a43 sim: igen: drop config.h & header checking
While the configure script was checking for a bunch of headers, only
one of them was conditionally included in the source (unistd.h).  The
rest were always included.  Based on those usage this whole time, we
can reasonably assume that the build also has unistd.h.

All the other files including config.h never actually used any defines
from the header.
2021-02-28 03:32:47 -05:00
Mike Frysinger
88d7273afd sim: igen: delete more unused toolchain settings
This package doesn't build any archives or install programs.
2021-02-28 03:26:24 -05:00
Mike Frysinger
9ea3e81ca0 sim: igen: delete unused FOR_BUILD vars 2021-02-28 03:21:36 -05:00
Mike Frysinger
c25ea03dd6 sim: set up build-time compiler settings
Some sim dirs were already setting up CFLAGS_FOR_BUILD in inconsistent
ways.  Move it to a common place for reuse.
2021-02-28 03:14:59 -05:00
Mike Frysinger
a3e2cc64a6 sim: use AC_CHECK_TOOL to find ar
Rather than require $AR be set and then default to `ar`, use the
standard AC_CHECK_TOOL helper to find a good prefixed tool.  In
practice this shouldn't change much as we seem to have macros in
the tree that were already setting it up, but we shouldn't rely
on that implicitly.
2021-02-28 03:03:44 -05:00
Mike Frysinger
ebe9564b99 sim: require AC_PROG_CPP explicitly
All the scripts were using this implicitly already, so there's no real
change for them, but we want to call it explicitly as the CPP tool is
used to generate nltvals.def.
2021-02-28 02:19:51 -05:00
Mike Frysinger
ed30adf750 sim: delete unused SIM_EXTRA_LIBDEPS
This was last used 15 years ago, so clearly not important enough to
keep around.  Punt it.
2021-02-28 01:39:02 -05:00
Mike Frysinger
f8069d55c1 sim: delete redundant SIM_EXTRA_ALL
We don't need a variable to add a dependency to the "all" target, and
having one doesn't really add value.  Switch to the target directly for
the few ports that actually use this.
2021-02-27 23:50:52 -05:00
GDB Administrator
b2287f90e4 Automatic date update in version.in 2021-02-28 00:00:13 +00:00
Lancelot SIX
bb3a4efe13 [PR gdb/27393] set directories: handle empty dirs.
As reported in gdb/27393, the 'directory' and 'set directories' commands
fail when parsing an empty dir name:

    (gdb) set directories ""
    /home/lsix/dev/gnu/binutils-gdb/gdbsupport/pathstuff.cc:132: internal-error: gdb::unique_xmalloc_ptr<char> gdb_abspath(const char*): Assertion `path != NULL && path[0] != '\0'' failed.

or

    (gdb) dir :
    /home/lsix/dev/gnu/binutils-gdb/gdbsupport/pathstuff.cc:132: internal-error: gdb::unique_xmalloc_ptr<char> gdb_abspath(const char*): Assertion `path != NULL && path[0] != '\0'' failed.

This patch fixes this issue by ignoring any attempt to add an empty
name to the source directories list.  'set dir ""' will reset the
directories list the same way 'set dir' would do it.

Tested on x86_64.
2021-02-27 14:29:39 +00:00
Tom Tromey
573dc0cc43 Minor fix in skip_ctf_tests
I noticed an oddity in skip_ctf_tests -- for me it ends up caching the
string "!0", because it ends with 'return ![...]'.  In Tcl, this is
just string concatenation.

The result works because the users of this function have unbraced if
conditions, like:

    if [skip_ctf_tests] {

... which works because "if" re-parses the returned string as an
expression, and evaluates that.

There's only a latent bug here, but this is also un-idiomatic, so I am
checking in this patch to fix it.  This way, if someone in the future
uses a braced condition (which is what I normally recommend), it will
continue to work.

gdb/testsuite/ChangeLog
2021-02-26  Tom Tromey  <tom@tromey.com>

	* lib/gdb.exp (skip_ctf_tests): Use expr on result.
2021-02-26 17:32:42 -07:00
GDB Administrator
0cf9ea0b16 Automatic date update in version.in 2021-02-27 00:00:21 +00:00
Fangrui Song
7fe1b1388f nm: Add --quiet to suppress "no symbols" diagnostic
PR binutils/27408
	* readelf.c (quiet): New option flag.
	(enum long_option_values): New enum to hold long option value.
	(long_options): Add --quiet.
	(usage): Mention --quiet.
	(display_rel_file): If quiet is enabled, suppress "no symbols".
	(main): Handle the new option.
	* NEWS: Mention --quiet.
	* docs/binutils.texi: Document --quiet.
2021-02-26 09:26:41 -08:00
Nick Clifton
fe0171d248 Correct an error message in the ARM assembler.
PR 27411
	* config/tc-arm.c (do_t_add_sub): Correct error message.
	* testsuite/gas/arm/pr27411.s: New test.
	* testsuite/gas/arm/pr27411.d: New test driver.
	* testsuite/gas/arm/pr27411.l: Expected error output for new test.
2021-02-26 16:37:30 +00:00
Tom de Vries
0e12f6c802 Add support for decoding DWARF v5 DW_AT_addr_base tags.
* dwarf.c (display_debug_addr): Handle dwarf-5 .debug_addr bits.
2021-02-26 15:52:39 +00:00
Jan Vrany
f821878623 testsuite: Remove extra \n from expected output of tsv notifications
Commit 2450ad54 removed extra trailing \n from tsv notifications but
did not update gdb.trace/mi-tsv-changed.exp accordingly. This commit
removes the extra \n from expected output so gdb.trace/mi-tsv-changed.exp
passes again.

gdb/testsuite/ChangeLog:

	* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv):
	Remove trailing \n from expected output.
2021-02-26 14:34:04 +00:00
Tom de Vries
32e4f96cec Add support for the split DWARF forms.
PR 27390
	* dwarf.c: (skip_attr_bytes): Add support for DW_FORM_str* and
	DW_FORM_addrx*.
	(read_and_display_attr_value): Likewise.
2021-02-26 13:30:10 +00:00
Markus Metzger
cb51b708fd testsuite: note on use_gdb_stub usage
Add a note to the comment on use_gdb_stub explaining the use of this check
for skipping tests that spawn new inferiors as discussed here:

    https://sourceware.org/pipermail/gdb-patches/2020-December/174186.html
2021-02-26 09:08:07 +01:00
Alan Modra
bfece7562d Add PR27441 testcase
PR 27441
	* testsuite/ld-plugin/pr27441a.c,
	* testsuite/ld-plugin/pr27441b.c,
	* testsuite/ld-plugin/pr27441c.c,
	* testsuite/ld-plugin/pr27441c.d: New test.
	* testsuite/ld-plugin/lto.exp: Run it.
2021-02-26 17:49:04 +10:30