Commit Graph

102763 Commits

Author SHA1 Message Date
Nick Clifton 6248d9d647 Remove the use of the register keyword in the libiberty.h header file - it is deprecated and incompatible with C++17.
* libiberty.h (bsearch_r): Remove use of the register keyword from
	the prototype.
2020-06-25 11:16:42 +01:00
Nick Clifton b59d128a11 Stop the assembler from generating R_ARM_THM_JMP11 relocations as these are not supported by the kernel.
PR 26141
	* config/tc-arm.c (arm_force_relocation): Force resolution of
	BFD_RELOC_THUMB_PCREL_BRANCH12 relocations.
	* testsuite/gas/arm/plt-1.d: Adjust expected disassembly.
2020-06-25 11:11:51 +01:00
Jan Beulich 8f570d6288 x86: make J disassembler macro available for new use
There's clearly a shortage of available macro characters, as can be seen
from the various two-character macros that had to be introduced. Don't
waste characters for things that can be expressed differently. In the
case of J this alternative is {l|}.
2020-06-25 09:31:50 +02:00
Jan Beulich 464dc4af9a x86: drop left-over 4-way alternative disassembler templates
Commit 7c52e0e865, dropping the general concept of 4-way alternatives,
for whatever reason, omitted cleaning up these two instances.
2020-06-25 09:30:39 +02:00
Jan Beulich c423d21a43 x86: move ImmExt processing
With abuses of ImmExt gone, all templates using it have operands. Move
its main invocation into process_operands(), matching its secondary one
for the SSE2AVX case.
2020-06-25 09:30:09 +02:00
Jan Beulich 8bbb3ad806 x86: operand sizing prefixes can disambiguate insns
Use of an explicit data size or REX.W prefix is sufficient indication of
the intended operation when operand size can't be derived from suffix or
register operands. Avoid the ambiguity warning and make in particular
immediate handling (sizing) cope with explicitly specified prefixes.

Extending/reusing the noreg16 test made me notice a few cases of
unintentional 32-bit addressing, which gets corrected at the same time.
2020-06-25 09:29:29 +02:00
Jan Beulich 589958d6ff x86: fix SYSRET disassembly, improve {,V}CVTSI2S{S,D} and PTWRITE
SYSRET can't use the same macro as IRET, since there's no 16-bit operand
size form of it. Re-use LQ for it instead.

Doing so made obvious that outside of 64-bit mode {,V}CVTSI2S{S,D} and
PTWRITE should have an 'l' suffix printed only in suffix-always mode.
2020-06-25 09:27:21 +02:00
Jan Beulich 0b9404fd37 x86-64: REX prefix is invalid with VEX etc
Just like for the data size prefix (see commit 7a8655d2bb ["x86: don't
abort() upon DATA16 prefix on (E)VEX encoded insn"]), any form of REX
prefix is invalid with VEX/XOP/EVEX.
2020-06-25 09:26:28 +02:00
Jan Beulich a5aeccd9d3 x86-64: honor REX prefixes for SSE2AVX
Legacy encoded insns do so, and their automatic conversion to AVX ones
ought to produce functionally identical code. Therefore explicit REX
prefixes cannot simply be ignored. This is in particular relevant
because at least PCMPESTR{I,M}'s 64-bit forms couldn't be expressed in
older gas by other than using a REX64 prefix.
2020-06-25 09:25:52 +02:00
Jan Beulich 40d231b4fb x86: also refuse data size prefix on SIMD insns
The data size prefix alters the meaning of legacy encoded SIMD insns,
and hence shouldn't be accepted there. Use of it also leads to
inconsistencies in SSE2AVX mode. Don't match insns with data size prefix
against SSE2AVX templates.
2020-06-25 09:25:12 +02:00
Jan Beulich 11abe42647 x86: drop stray assignment from build_evex_prefix()
Unlike in build_vex_prefix() this is not needed here.
2020-06-25 09:24:23 +02:00
GDB Administrator 0a3eb8aeb3 Automatic date update in version.in 2020-06-25 00:00:08 +00:00
H.J. Lu 727b7b1864 Sync config, include and libiberty with GCC
config/

2020-06-24  H.J. Lu  <hongjiu.lu@intel.com>

	Sync with GCC
	2020-05-29  H.J. Lu  <hjl.tools@gmail.com>

	PR bootstrap/95413
	* cet.m4: Replace save_CFLAGS and save_LDFLAGS with
	cet_save_CFLAGS and cet_save_LDFLAGS.

include/

2020-06-24  H.J. Lu  <hongjiu.lu@intel.com>

	Sync with GCC
	2020-06-23  Nick Alcock  <nick.alcock@oracle.com>

	* libiberty.h (bsearch_r): New.

	2020-04-17  Martin Liska  <mliska@suse.cz>
		    Jonathan Yong <10walls@gmail.com>

	PR gcov-profile/94570
	* filenames.h (defined): Do not define HAVE_DOS_BASED_FILE_SYSTEM
	for CYGWIN.

libiberty/

2020-06-23  Nick Alcock  <nick.alcock@oracle.com>

	* bsearch_r.c: New file.
	* Makefile.in (CFILES): Add bsearch_r.c.
	(REQUIRED_OFILES): Add bsearch_r.o.
	* functions.texi: Regenerate.

2020-05-29  H.J. Lu  <hjl.tools@gmail.com>

	PR bootstrap/95413
	* configure: Regenerated.

2020-05-15  Iain Buclaw  <ibuclaw@gdcproject.org>

	* d-demangle.c (dlang_attributes): Add @live attribute.
	* testsuite/d-demangle-expected: Add new tests.

2020-05-14  Rainer Schuetze  <r.sagitario@gmx.de>
	    Iain Buclaw  <ibuclaw@gdcproject.org>

	* d-demangle.c (enum dlang_symbol_kinds): Remove enum.
	(struct dlang_info): New struct
	(dlang_decode_backref): New function.
	(dlang_backref): New function.
	(dlang_symbol_backref): New function.
	(dlang_type_backref): New function.
	(dlang_symbol_name_p): New function.
	(dlang_function_type_noreturn): New function.
	(dlang_function_type): Add 'info' parameter.  Decode function type
	with dlang_function_type_noreturn.
	(dlang_function_args): Add 'info' parameter.
	(dlang_type): Add 'info' parameter.  Handle back referenced types.
	(dlang_identifier): Replace 'kind' parameter with 'info'.  Handle back
	referenced symbols.  Split off decoding of plain identifiers to...
	(dlang_lname): ...here.
	(dlang_parse_mangle): Replace 'kind' parameter with 'info'.  Decode
	function type and return with dlang_type.
	(dlang_parse_qualified): Replace 'kind' parameter with 'info', add
	'suffix_modifier' parameter.  Decode function type with
	dlang_function_type_noreturn.
	(dlang_parse_tuple): Add 'info' parameter.
	(dlang_template_symbol_param): New function.
	(dlang_template_args): Add 'info' parameter.  Decode symbol parameter
	with dlang_template_symbol_param.  Handle back referenced values, and
	externally mangled parameters.
	(dlang_parse_template): Add 'info' parameter.
	(dlang_demangle_init_info): New function.
	(dlang_demangle): Initialize and pass 'info' parameter.
	* testsuite/d-demangle-expected: Add new tests.
2020-06-24 16:52:48 -07:00
Pedro Alves 221db974e6 W/ Clang, compile/link C++ test programs with "-x c++"
Some testcases want to compile .c files with a C++ compiler.  So they
pass the "c++" option to gdb_compile.  That works fine with GCC, but
with Clang, it results in:

  gdb compile failed, clang-5.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

and the testcase is skipped with UNTESTED.

A previous patch fixed a case like that in
gdb.compile/compile-cplus.exp, by adding -Wno-deprecated to the build
options.  However, there are other testcases that use the same
pattern, and all fail for the same reason.  For example:

 gdb.base/info-types-c++.exp
 gdb.base/max-depth-c++.exp
 gdb.base/msym-lang.exp
 gdb.base/whatis-ptype-typedefs.exp
 gdb.btrace/rn-dl-bind.exp

Fix this in a central place, within gdb_compile, by passing "-x c++"
to the compiler driver when we're compiling/linking C++.

This revealed that gdb.compile/compile-cplus.exp and
gdb.arch/amd64-entry-value-paramref.exp tests are compiling an
assembly file with the "c++" option, which would now fail to compile,
with the C++ compiler not grokking the assembly, of course.  We just
need to not pass "c++" and all the other related C++ options when
compiling an assembly file.

gdb/testsuite/ChangeLog:
2020-06-24  Pedro Alves  <palves@redhat.com>

	* gdb.arch/amd64-entry-value-paramref.exp: Use
	prepare_for_testing_full and don't pass "c++" for the .S file
	build spec.
	* gdb.compile/compile-cplus.exp: Don't compile $srcfile3 with
	$options, since it's an assembly file.  Remove -Wno-deprecated.
	* lib/gdb.exp (gdb_compile): Pass "-x c++" explicitly when
	compiling C++ programs.
2020-06-24 23:18:19 +01:00
Pedro Alves 331733cd4e W/ Clang, compile C/C++ testcases with -Wno-unknown-warning-option
Some C/C++ testcases unconditionally pass -Wno-foo as additional
options to disable some warning.  That is OK with GCC, because GCC
accepts -Wno-foo silently even if it doesn't support -Wfoo.  This is a
feature which allows disabling warnings with newer compilers without
breaking builds with older compilers.  Clang however warns about
unknown -Wno-foo by default, unless you pass
-Wno-unknown-warning-option as well:

 $ gcc -Wno-foo test.c
 * nothing, compiles successfuly *

 $ clang -Wno-foo test.c
 warning: unknown warning option '-Wno-foo [-Wunknown-warning-option]

This commit adds -Wunknown-warning-option centrally in gdb_compile, so
that individual testcases don't have to worry about breaking older
Clangs.

IOW, this avoids this problematic scenario:

#1 - A testcase compiles successfully with Clang version X.
#2 - Clang version "X + 1" adds a new warning, enabled by default,
     which breaks the test.
#3 - We add -Wno-newwarning to the testcase, fixing the testcase with
     clang "X + 1".
#4 - Now building the test with Clang version X no longer works, due
     to "unknown warning option".

gdb/testsuite/ChangeLog:
2020-06-24  Pedro Alves  <palves@redhat.com>

	* lib/gdb.exp (gdb_compile): Update intro comment.  If C/C++ with
	Clang, add "-Wno-unknown-warning-option" to the options.
2020-06-24 23:18:19 +01:00
Philippe Waroquiers a8654e7d78 Fixes PR 25475: ensure exec-file-mismatch "ask" always asks in case of mismatch.
As explained in https://sourceware.org/bugzilla/show_bug.cgi?id=25475,
when the currently loaded file has no debug symbol,
symbol_file_add_with_addrs does not ask a confirmation to the user
before loading the new symbol file.  The behaviour is not consistent
when symbol_file_add_with_addrs is called due to exec-file-mismatch "ask"
setting.

The PR discusses several solutions/approaches.
The preferred approach (suggested by Joel) is to ensure that GDB always asks
a confirmation when it loads a new symbol file due to exec-file-mismatch,
using a new SYMFILE add-flag.

I tested this manually.  If OK, we can remove the bypass introduced by Tom
in 6b9374f1, in order to always answer to the 'load' question.

gdb/ChangeLog
2020-06-24  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* symfile-add-flags.h: New flag SYMFILE_ALWAYS_CONFIRM.
	* exec.c (validate_exec_file): If from_tty, set both
	SYMFILE_VERBOSE (== from_tty) and SYMFILE_ALWAYS_CONFIRM.
	* symfile.c (symbol_file_add_with_addrs): if always_confirm
	and from_tty, unconditionally ask a confirmation.
2020-06-24 22:21:07 +02:00
Andrew Burgess 069057bf0f bfd/riscv: tighten matching rules in riscv_scan
The following GDB behaviour was observed:

  (gdb) x/1i 0x0001014a
     0x1014a <main+8>:	jal	0x10132 <foo>
  (gdb) show architecture
  The target architecture is set automatically (currently riscv:rv32)
  (gdb) set architecture riscv:rv32
  The target architecture is assumed to be riscv:rv32
  (gdb) x/1i 0x0001014a
     0x1014a <main+8>:	0x37e5
  (gdb)

Notice that initially we can disassemble the instruction (it's a
compressed jal instruction), but after setting the architecture we can
no longer disassemble the instruction.

This is particularly puzzling as GDB initially thought the
architecture was 'riscv:rv32', but when we force the architecture to
be that, the disassembly stops working.

This issue was introduced with this commit:

  commit c35d018b1a
  Date:   Mon Jan 27 15:19:30 2020 -0800

      RISC-V: Fix gdbserver problem with handling arch strings.

In this commit we try to make riscv_scan handle cases where we see
architecture strings like 'riscv:rv32imc' (for example).  Normally
this wouldn't match as bfd_default_scan requires an exact match, so we
extended riscv_scan to ignore trailing characters.

Unfortunately the default riscv arch is called 'riscv', is 64-bit,
and has its mach type set to 0, which I think is intended to pair with
code is riscv-dis.c:riscv_disassemble_insn that tries to guess if we
are 32 or 64 bit.

What happens then is that 'riscv:rv32' is first tested against 'riscv'
using bfd_default_scan, this doesn't match, we then compare this to
'riscv', but allowing trailing characters to be ignored, this matches,
and our 'riscv:rv32' matches against the default (64-bit)
architecture.

The solution I propose is to prevent the default architecture from
taking part in this "ignore trailing characters" extra match case,
only the more specific 'riscv:rv32' and 'riscv:rv64' get this extra
matching.

bfd/ChangeLog:

	* cpu-riscv.c (riscv_scan): Don't allow shorter matches using the
	default architecture.
2020-06-24 19:15:07 +01:00
Nick Clifton fb58f5e928 Fix a potential use of an uninitialised variable error in gold.
* target-reloc.h (issue_discarded_error): Initialise the
	key_symndx variable.
2020-06-24 17:38:16 +01:00
H.J. Lu 4bf05d4a90 ld: Correct --dependency-file order
Change ld --help output to

  -d, -dc, -dp                Force common symbols to be defined
  --dependency-file FILE      Write dependency file

instead of

  -d, -dc                     Force common symbols to be defined
  --dependency-file FILE, -dp Write dependency file

	PR ld/26165
	* lexsup.c (ld_options): Correct --dependency-file order.
2020-06-24 06:39:03 -07:00
H.J. Lu 2c8e370829 csky: Don't generate unnecessary dynamic tags
Dynamic tags, DT_JMPREL, PLTREL and PLTRELSZ, are needed only if there
are relocation entries for PLT.  Don't generate them if there are no
relocation entries for PLT.

bfd/

	PR ld/26083
	* elf32-csky.c (csky_elf_size_dynamic_sections): Call
	_bfd_elf_add_dynamic_tags.

ld/

	PR ld/26083
	* testsuite/ld-csky/tls-ie-v1.d: Updated.
	* testsuite/ld-csky/tls-ie.d: Likewise.
2020-06-24 06:14:28 -07:00
H.J. Lu c679ec98a1 cris: Don't generate unnecessary dynamic tags
Dynamic tags, DT_JMPREL, PLTREL and PLTRELSZ, are needed only if there
are relocation entries for PLT.  Don't generate them if there are no
relocation entries for PLT.

bfd/

	PR ld/26083
	* elf32-cris.c (elf_cris_size_dynamic_sections): Call
	_bfd_elf_add_dynamic_tags.

ld/

	PR ld/26083
	* testsuite/ld-cris/libdso-15b.d: Updated.
	* testsuite/ld-cris/libdso-1c.d: Likewise.
	* testsuite/ld-cris/libdso-1d.d: Likewise.
	* testsuite/ld-cris/libdso-15c.d: New file.
2020-06-24 04:00:31 -07:00
H.J. Lu 5376d47f66 ld: Set non_ir_ref_regular on source for assignment
We need to set non_ir_ref_regular on the source for assignment to get
the correct LTO resolution:

190 a27be7f4ad90c5ce PREVAILING_DEF real_g

instead of

190 30c3b2d8f967f5ea PREVAILING_DEF_IRONLY real_g

	PR ld/26163
	* ldexp.c (exp_fold_tree_1): Set non_ir_ref_regular on the source
	for assignment.
	* testsuite/ld-plugin/lto.exp: Run ld/26163 test.
	* testsuite/ld-plugin/pr26163a.c: New file.
	* testsuite/ld-plugin/pr26163b.c: Likewise.
2020-06-24 03:56:16 -07:00
Alan Modra a5aae5087c ld --help output
It's best if help message output does not contain tabs, since we don't
know tab stop settings or even if tabs are handled by the output
device.  This reverts some 2020-06-23 changes and fixes the csky help
message.

	* lexsup.c (elf_shlib_list_options): Properly format help message.
	(elf_plt_unwind_list_options): Likewise.
	* emultempl/cskyelf.em (PARSE_AND_LIST_OPTIONS): Likewise.
2020-06-24 20:00:08 +09:30
Alan Modra f8b1e5f6fc ubsan: alpha-vms: shift exponent 536874240 is too large
C_OPR_ASH is supposed to be an arithmetic shift.  By the look of it,
this operator implemented logical shifts since the original binutils
support was added.  This patch corrects that and avoids some nonsense
ubsan complaints.  I chose to implement infinite precision shifts
rather than masking shift counts to the word size as the spec I had is
silent on what is supposed to happen with overlarge shift counts.

	* vms-alpha.c (_bfd_vms_slurp_etir <ETIR__C_OPR_ASH>): Implement
	shifts without undefined behaviour.
2020-06-24 10:48:15 +09:30
GDB Administrator d5722d3be2 Automatic date update in version.in 2020-06-24 00:00:07 +00:00
Andrew Burgess caa7fd04f6 gdb: New maintenance command to print XML target description
This commit adds a new maintenance command that dumps the current
target description as an XML document.  This is a maintenance command
as I currently only see this being useful for GDB developers, or for
people debugging a new remote target.

By default the command will print whatever the current target
description is, whether this was delivered by the remote, loaded by
the user from a file, or if it is a built in target within GDB.

The command can also take an optional filename argument.  In this case
GDB loads a target description from the file, and then reprints it.
This could be useful for testing GDB's parsing of target descriptions,
or to check that GDB can successfully parse a particular XML
description.

It is worth noting that the XML description printed will not be an
exact copy of the document fed into GDB.  For example this minimal
input file:

  <target>
    <feature name="abc">
      <reg name="r1" bitsize="32"/>
    </feature>
  </target>

Will produce this output:

  (gdb) maint print xml-tdesc path/to/file.xml
  <?xml version="1.0"?>
  <!DOCTYPE target SYSTEM "gdb-target.dtd">
  <target>
    <feature name="abc">
      <reg name="r1" bitsize="32" type="int" regnum="0"/>
    </feature>
  </target>

Notice that GDB filled in both the 'type' and 'regnum' fields of the
<reg>.  I think this is actually a positive as it means we get to
really understand how GDB processed the document, if GDB made some
assumptions that differ to those the user expected then hopefully this
will bring those issues to the users attention.

To implement this I have tweaked the output produced by the
print_xml_feature which is defined within the gdbsupport/ directory.
The changes I have made to this class are:

  1. The <architecture>...</architecture> tags are now not produced if
  the architecture name is NULL.

  2. The <osabi>...</osabi> tags get a newline at the end.

  3. And, the whole XML document is indented using white space in a
  nested fashion (as in the example output above).

I think that these changes should be fine, the print_xml_feature class
is used:

  1. In gdbserver to generate an XML document to send as the target
  description to GDB.

  2. In GDB as part of a self-check function, a target_desc is
  converted to XML then parsed back into a target_desc.  We then check
  the before and after target_desc objects are the same.

  3. In the new 'maint print xml-tdesc' command.

In all of these use cases adding the extra white space should be fine.

gdbsupport/ChangeLog:

	* tdesc.cc (print_xml_feature::visit_pre): Use add_line to add
	output content, and call indent as needed in all overloaded
	variants.
	(print_xml_feature::visit_post): Likewise.
	(print_xml_feature::visit): Likewise.
	(print_xml_feature::add_line): Two new overloaded functions.
	* tdesc.h (print_xml_feature::indent): New member function.
	(print_xml_feature::add_line): Two new overloaded member
	functions.
	(print_xml_feature::m_depth): New member variable.

gdb/ChangeLog:

	* target-descriptions.c (tdesc_architecture_name): Protect against
	NULL pointer dereference.
	(maint_print_xml_tdesc_cmd): New function.
	(_initialize_target_descriptions): Register new 'maint print
	xml-tdesc' command and give it the filename completer.
	* NEWS: Mention new 'maint print xml-tdesc' command.

gdb/testsuite/ChangeLog:

	* gdb.xml/tdesc-reload.c: New file.
	* gdb.xml/tdesc-reload.exp: New file.
	* gdb.xml/maint-xml-dump-01.xml: New file.
	* gdb.xml/maint-xml-dump-02.xml: New file.
	* gdb.xml/maint-xml-dump.exp: New file.

gdb/doc/ChangeLog:

	* gdb.texinfo (Maintenance Commands): Document new 'maint print
	xml-desc' command.
2020-06-23 22:17:20 +01:00
Andrew Burgess fbf42f4e6d gdb: Print compatible information within print_xml_feature
The gdbsupport directory contains a helper class print_xml_feature
that is shared between gdb and gdbserver.  This class is used for
printing an XML representation of a target_desc object.

Currently this class doesn't have the ability to print the
<compatible> entities that can appear within a target description, I
guess no targets have needed that functionality yet.

The print_xml_feature classes API is based around operating on the
target_desc class, however, the sharing between gdb and gdbserver is
purely textural, we rely on their being a class called target_desc in
both gdb and gdbserver, but there is no shared implementation.  We
then have a set of functions declared that operate on an object of
type target_desc, and again these functions have completely separate
implementations.

Currently then the gdb version of target_desc contains a vector of
bfd_arch_info pointers which represents the compatible entries from a
target description.  The gdbserver version of target_desc has no such
information.  Further, the gdbserver code doesn't seem to include the
bfd headers, and so doesn't know about the bfd types.

I was reluctant to include the bfd headers into gdbserver just so I
can reference the compatible information, which isn't (currently) even
needed in gdbserver.

So, the approach I take in this patch is to wrap the compatible
information into a new helper class.  This class is declared in the
gdbsupport library, but implemented separately in both gdb and
gdbserver.

In gdbserver the class is empty.  The compatible information within
the gdbserver is an empty list, of empty classes.

In gdb the class contains a pointer to the bfd_arch_info object.

With this in place we can now add support to print_xml_feature for
printing the compatible information if it is present.  In the
gdbserver code this will never happen, as the gdbserver never has any
compatible information.  But in gdb, this code will trigger when
appropriate.

gdb/ChangeLog:

	* target-descriptions.c (class tdesc_compatible_info): New class.
	(struct target_desc): Change type of compatible vector.
	(tdesc_compatible_p): Update for change in type of
	target_desc::compatible.
	(tdesc_compatible_info_list): New function.
	(tdesc_compatible_info_arch_name): New function.
	(tdesc_add_compatible): Update for change in type of
	target_desc::compatible.
	(print_c_tdesc::visit_pre): Likewise.

gdbserver/ChangeLog:

	* tdesc.cc (struct tdesc_compatible_info): New struct.
	(tdesc_compatible_info_list): New function.
	(tdesc_compatible_info_arch_name): New function.

gdbsupport/ChangeLog:

	* tdesc.cc (print_xml_feature::visit_pre): Print compatible
	information.
	* tdesc.h (struct tdesc_compatible_info): Declare new struct.
	(tdesc_compatible_info_up): New typedef.
	(tdesc_compatible_info_list): Declare new function.
	(tdesc_compatible_info_arch_name): Declare new function.
2020-06-23 22:17:19 +01:00
Andrew Burgess 20821f4ed1 gdb: Allow target description to be dumped even when it is remote
The maintenance command 'maintenance print c-tdesc' can only print the
target description if it was loaded from a local file, or if the local
filename is passed to the maintenance command as an argument.

Sometimes it would be nice to know what target description GDB was
given by the remote, however, if I connect to a remote target and try
this command I see this:

  (gdb) maintenance print c-tdesc
  The current target description did not come from an XML file.
  (gdb)

Which is not very helpful.

This commit changes things so that if the description came from the
remote end then GDB will use a fake filename 'fetched from target' as
the filename for the description, GDB will then create the C
description of the target as though it came from this file.  Example
output would look like this (I snipped the feature creation from the
middle as that hasn't changed):

  (gdb) maintenance print c-tdesc
  /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
    Original: fetched from target */

  #include "defs.h"
  #include "osabi.h"
  #include "target-descriptions.h"

  struct target_desc *tdesc_fetched_from_target;
  static void
  initialize_tdesc_fetched_from_target (void)
  {
    struct target_desc *result = allocate_target_description ();
    struct tdesc_feature *feature;

    /* ... features created here ... */

    tdesc_fetched_from_target = result;
  }
  (gdb)

In order to support using 'fetched from target' I had to update the
print_c_tdesc code to handle filenames that include a space.  This has
the benefit that we can now print out real files with spaces in the
name, for example the file 'with space.xml':

  (gdb) maint print c-tdesc with space.xml

I originally added this functionality so I could inspect the
description passed to GDB by the remote target.  After using this for
a while I realised that actually having GDB recreate the XML would be
even better, so a later commit will add that functionality too.

Still, given how small this patch is I thought it might be nice to
include this in GDB anyway.

While I was working on this anyway I've added filename command
completion to this command.

gdb/ChangeLog:

	* target-descriptions.c (print_c_tdesc::print_c_tdesc): Change
	whitespace to underscore.
	(maint_print_c_tdesc_cmd): Use fake filename for target
	descriptions that came from the target.
	(_initialize_target_descriptions): Add filename command completion
	for 'maint print c-tdesc'.
2020-06-23 22:17:18 +01:00
Simon Marchi 1fb5ee6203 gdb: add some more empty lines in loc.c
Add some empty lines at places I forgot in the previous patch.

gdb/ChangeLog:

	* dwarf2/loc.c (decode_debug_loclists_addresses): Add empty
	lines.

Change-Id: I8a9f3766ede1ce750e0703023285dca873bce0da
2020-06-23 15:40:24 -04:00
Simon Marchi fc3ecb3e61 gdb: add empty lines in loc.c
I always found that some switch statements in this file were a bit too
packed.  I think having empty lines between each case helps with
reading.  I'm pushing this as obvious, I hope it won't be too
controversial.

gdb/ChangeLog:

	* dwarf2/loc.c (decode_debug_loc_dwo_addresses): Add empty
	lines.
	(dwarf2_find_location_expression): Likewise.
	(call_site_parameter_matches): Likewise.
	(dwarf2_compile_expr_to_ax): Likewise.
	(disassemble_dwarf_expression): Likewise.
	(loclist_describe_location): Likewise.

Change-Id: I381366a0468ff1793faa612c46ef48a9d4773192
2020-06-23 15:34:45 -04:00
Roland McGrath f37b21b481 PR 22843: ld, gold: Add --dependency-file option.
gold/
	* options.h (class General_options): Add --dependency-file option.
	* fileread.cc (File_read::files_read): New static variable.
	(File_read::open): Add the file to the files_read list.
	(File_read::record_file_read): New static member function.
	(File_read::write_dependency_file): New static member function.
	* fileread.h (class File_read): Declare them.
	* layout.cc (Layout::read_layout_from_file): Call record_file_read.
	(Close_task_runner::run): Call write_dependency_file if
	--dependency-file was passed.

ld/
	* NEWS: Note --dependency-file.
	* ld.texi (Options): Document --dependency-file.
	* ldlex.h (enum option_values): Add OPTION_DEPENDENCY_FILE.
	* ld.h (ld_config_type): New member dependency_file.
	* lexsup.c (ld_options, parse_args): Parse --dependency-file.
	* ldmain.c (struct dependency_file): New type.
	(dependency_files, dependency_files_tail): New static variables.
	(track_dependency_files): New function.
	(write_dependency_file): New function.
	(main): Call it when --dependency-file was passed.
	* ldfile.c (ldfile_try_open_bfd): Call track_dependency_files.
	(ldfile_open_command_file_1): Likewise.
	* ldelf.c (ldelf_try_needed): Likewise.
	* pe-dll.c (pe_implied_import_dll): Likewise.
2020-06-23 12:01:24 -07:00
Pedro Alves 236ef0346d Fix "maint selftest" regression, add struct scoped_mock_context
This commit:

 commit 3922b30264
 Author:     Pedro Alves <palves@redhat.com>
 AuthorDate: Thu Jun 18 21:28:37 2020 +0100

    Decouple inferior_ptid/inferior_thread(); dup ptids in thread list (PR 25412)

caused a regression for gdb.gdb/unittest.exp when GDB is configured
with --enable-targets=all.  The failure is:

  gdb/thread.c:95: internal-error: thread_info* inferior_thread(): Assertion `current_thread_ != nullptr' failed.

The problem is in this line in regcache.c:cooked_read_test:

  /* Switch to the mock thread.  */
  scoped_restore restore_inferior_ptid
    = make_scoped_restore (&inferior_ptid, mock_ptid);

Both gdbarch-selftest.c and regcache.c set up a similar mock context,
but the series the patch above belongs to only updated the
gdbarch-selftest.c context to not write to inferior_ptid directly, and
missed updating regcache.c's.

Instead of copying the fix over to regcache.c, share the mock context
setup code in a new RAII class, based on gdbarch-selftest.c's version.

Also remove the "target already pushed" error from regcache.c, like it
had been removed from gdbarch-selftest.c in the multi-target series.
That check is unnecessary because each inferior now has its own target
stack, and the unit test pushes a target on a separate (mock)
inferior, not the current inferior on entry.

gdb/ChangeLog:
2020-06-23  Pedro Alves  <palves@redhat.com>

	* gdbarch-selftests.c: Don't include inferior.h, gdbthread.h or
	progspace-and-thread.h.  Include scoped-mock-context.h instead.
	(register_to_value_test): Use scoped_mock_context.
	* regcache.c: Include "scoped-mock-context.h".
	(cooked_read_test): Don't error out if a target is already pushed.
	Use scoped_mock_context.  Adjust.
	* scoped-mock-context.h: New file.
2020-06-23 18:57:03 +01:00
Sandra Loosemore bb8d126033 Adjust command completion output when TUI is disabled
The history-scrolling commands "+", "-", "<" and ">" are only known to
GDB when TUI is enabled.  This means the "complete pipe " command
produces different output depending on whether TUI is present, which
in turn caused

FAIL: gdb.base/shell.exp: cmd complete "pipe "

This patch provides different patterns for that test depending on
whether or not TUI is available.

2020-06-23  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* lib/completion-support.exp (test_gdb_completion_offers_commands):
	Adjust for omitted commands when TUI is disabled.
2020-06-23 09:33:31 -07:00
H.J. Lu d0dded5bc2 Add a testcase for PR binutils/26160
PR binutils/26160
	* testsuite/binutils-all/pr26160.dwp.bz2: New file.
	* testsuite/binutils-all/pr26160.r: Likewise.
	* testsuite/binutils-all/readelf.exp: Run PR binutils/26160 test.
2020-06-23 09:20:28 -07:00
Alan Modra 9221725d1f PR26150, Assertion when asm() defines global symbols, -flto and --start-group
If an archive map contains symbols that aren't actually defined by the
indexed element for any reason, then loading that element will leave
the symbol undefined (or common).  This leads to the possibility of
the element being loaded again should the archive be searched again
due to the action of --start-group/--end-group.  The testcase
triggering this problem was an archive containing fat lto objects,
with the archive map incorrectly created by ar rather than gcc-ar.

	PR 26150
	* ldlang.c (ldlang_add_file): Assert that we aren't adding the
	current end of link.next list again too.
	* ldmain.c (add_archive_element): Don't load archive elements
	again that have already been loaded.
2020-06-24 00:50:48 +09:30
Nick Clifton 39f381cb80 Fix decoding of indexed DWARF strings using pre-DWARF-5 string offset sections. Fix display of .debug_str_offsets.dwo sections.
PR 26160
	* dwarf.c (fetch_indexed_string): Detect and handle old style
	.debug_str_offset tables.
	(display_debug_str_offsets): Likewise.  Also add support for
	.debug_str_offsets.dwo sections.
2020-06-23 16:06:38 +01:00
Gary Benson 7e4b9c4cd3 Improve -Wunused-value testcase build failures fix
This commit improves upon my previous -Wunused-value fix by
replacing the various dummy variables with casts to void, as
suggested by Pedro.

gdb/testsuite/ChangeLog:

	* gdb.cp/namespace.cc: Improve -Wunused-value fix.
	* gdb.cp/nsimport.cc: Likewise.
	* gdb.cp/nsnested.cc: Likewise.
	* gdb.cp/nsnoimports.cc: Likewise.
	* gdb.cp/nsusing.cc: Likewise.
	* gdb.cp/smartp.cc: Likewise.
	* gdb.python/py-pp-integral.c: Likewise.
	* gdb.python/py-pp-re-notag.c: Likewise.
2020-06-23 15:11:27 +01:00
H.J. Lu 80fda85ca1 Add a testcase for PR binutils/26112
PR binutils/26112
	* testsuite/binutils-all/pr26112.o.bz2: New file.
	* testsuite/binutils-all/pr26112.r: Likewise.
	* testsuite/binutils-all/readelf.exp: Run PR binutils/26112 test.
2020-06-23 06:52:41 -07:00
Andrew Burgess 39e7eccae6 gdb: Convert language la_is_string_type_p field to a method
This commit changes the language_data::la_is_string_type_p function
pointer member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_is_string_type_p
	initializer.
	(ada_language::is_string_type_p): New member function.
	* c-lang.c (c_language_data): Delete la_is_string_type_p
	initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_is_string_type_p): Delete function, implementation
	moved to f_language::is_string_type_p.
	(f_language_data): Delete la_is_string_type_p initializer.
	(f_language::is_string_type_p): New member function,
	implementation from f_is_string_type_p.
	* go-lang.c (go_is_string_type_p): Delete function, implementation
	moved to go_language::is_string_type_p.
	(go_language_data): Delete la_is_string_type_p initializer.
	(go_language::is_string_type_p): New member function,
	implementation from go_is_string_type_p.
	* language.c (language_defn::is_string_type_p): Define new member
	function.
	(default_is_string_type_p): Make static, add comment copied from
	header file.
	(unknown_language_data): Delete la_is_string_type_p initializer.
	(unknown_language::is_string_type_p): New member function.
	(auto_language_data): Delete la_is_string_type_p initializer.
	(auto_language::is_string_type_p): New member function.
	* language.h (language_data): Delete la_is_string_type_p field.
	(language_defn::is_string_type_p): Declare new function.
	(default_is_string_type_p): Delete desclaration, move comment to
	definition.
	* m2-lang.c (m2_is_string_type_p): Delete function, implementation
	moved to m2_language::is_string_type_p.
	(m2_language_data): Delete la_is_string_type_p initializer.
	(m2_language::is_string_type_p): New member function,
	implementation from m2_is_string_type_p.
	* objc-lang.c (objc_language_data): Delete la_is_string_type_p
	initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_is_string_type_p): Delete function,
	implementation moved to pascal_language::is_string_type_p.
	(pascal_language_data): Delete la_is_string_type_p initializer.
	(pascal_language::is_string_type_p): New member function,
	implementation from pascal_is_string_type_p.
	* rust-lang.c (rust_is_string_type_p): Delete function,
	implementation moved to rust_language::is_string_type_p.
	(rust_language_data): Delete la_is_string_type_p initializer.
	(rust_language::is_string_type_p): New member function,
	implementation from rust_is_string_type_p.
	* valprint.c (val_print_scalar_or_string_type_p): Update call to
	is_string_type_p.
2020-06-23 13:34:11 +01:00
Andrew Burgess 4ffc13fb0e gdb: Convert language la_print_typedef field to a method
This commit changes the language_data::la_print_typedef function
pointer member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_print_typedef
	initializer.
	(ada_language::print_typedef): New member function.
	* c-lang.c (c_language_data): Delete la_print_typedef initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_language_data): Likewise.
	(f_language::print_typedef): New member function.
	* go-lang.c (go_language_data): Delete la_print_typedef
	initializer.
	* language.c (language_defn::print_typedef): Define member
	function.
	(unknown_language_data): Delete la_print_typedef initializer.
	(unknown_language::print_typedef): New member function.
	(auto_language_data): Delete la_print_typedef initializer.
	(auto_language::print_typedef): New member function.
	* language.h (language_data): Delete la_print_typedef field.
	(language_defn::print_typedef): Declare new member function.
	(LA_PRINT_TYPEDEF): Update call to print_typedef.
	(default_print_typedef): Delete declaration.
	* m2-lang.c (m2_language_data): Delete la_print_typedef
	initializer.
	(m2_language::print_typedef): New member function.
	* objc-lang.c (objc_language_data): Delete la_print_typedef
	initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	(pascal_language::print_typedef): New member function.
	* rust-lang.c (rust_print_typedef): Delete function,
	implementation moved to rust_language::print_typedef.
	(rust_language): Delete la_print_typedef initializer.
	(rust_language::print_typedef): New member function,
	implementation from rust_print_typedef.
	* typeprint.c (default_print_typedef): Delete.
2020-06-23 13:34:11 +01:00
Andrew Burgess d711ee67ac gdb: Convert language la_printstr field to a method
This commit changes the language_data::la_printstr function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_printstr initializer.
	(ada_language::printstr): New member function.
	* c-lang.c (c_language_data): Delete la_printstr initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_printstr): Rename to f_language::printstr.
	(f_language_data): Delete la_printstr initializer.
	(f_language::printstr): New member function, implementation from
	f_printstr.
	* go-lang.c (go_language_data): Delete la_printstr initializer.
	* language.c (language_defn::printstr): Define new member
	function.
	(unk_lang_printstr): Delete.
	(unknown_language_data): Delete la_printstr initializer.
	(unknown_language::printstr): New member function.
	(auto_language_data): Delete la_printstr initializer.
	(auto_language::printstr): New member function.
	* language.h (language_data): Delete la_printstr field.
	(language_defn::printstr): Declare new member function.
	(LA_PRINT_STRING): Update call to printstr.
	* m2-lang.c (m2_printstr): Rename to m2_language::printstr.
	(m2_language_data): Delete la_printstr initializer.
	(m2_language::printstr): New member function, implementation from
	m2_printstr.
	* objc-lang.c (objc_language_data): Delete la_printstr
	initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_printstr): Rename to pascal_language::printstr.
	(pascal_language_data): Delete la_printstr initializer.
	(pascal_language::printstr): New member function, implementation
	from pascal_printstr.
	* p-lang.h (pascal_printstr): Delete declaration.
	* rust-lang.c (rust_printstr): Update header comment.
	(rust_language_data): Delete la_printstr initializer.
	(rust_language::printstr): New member function.
2020-06-23 13:34:11 +01:00
Andrew Burgess 52b50f2c1b gdb: Convert language la_printchar field to a method
This commit changes the language_data::la_printchar function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_printchar initializer.
	(ada_language::printchar): New member function.
	* c-lang.c (c_language_data): Delete la_printchar initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_printchar): Rename to f_language::printchar.
	(f_language_data): Delete la_printchar initializer.
	(f_language::printchar): New member function, implementation from
	f_printchar.
	* go-lang.c (go_language_data): Delete la_printchar initializer.
	* language.c (unk_lang_printchar): Delete.
	(language_defn::printchar): Define new member function.
	(unknown_language_data): Delete la_printchar initializer.
	(unknown_language::printchar): New member function.
	(auto_language_data): Delete la_printchar initializer.
	(auto_language::printchar): New member function.
	* language.h (language_data): Delete la_printchar field.
	(language_defn::printchar): Declare new member function.
	(LA_PRINT_CHAR): Update call to printchar.
	* m2-lang.c (m2_language_data): Delete la_printchar initializer.
	(m2_language::printchar): New member function.
	* objc-lang.c (objc_language_data): Delete la_printchar
	initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Delete la_printchar
	initializer.
	(pascal_language::printchar): New member function.
	* rust-lang.c (rust_printchar): Rename to
	rust_language::printchar.
	(rust_language_data): Delete la_printchar initializer.
	(rust_language::printchar): New member function, implementation
	from rust_printchar.
2020-06-23 13:34:11 +01:00
Andrew Burgess ec8cec5b96 gdb: Convert language la_emitchar field to a method
This commit changes the language_data::la_emitchar function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (emit_char): Renamed to ada_language::emitchar.
	(ada_language_data): Delete la_emitchar initializer.
	(ada_language::emitchar): New member function, implementation from
	emit_char.
	* c-lang.c (c_language_data): Delete la_emitchar initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_emit_char): Rename to f_language::emitchar.
	(f_language_data): Delete la_emitchar initializer.
	(f_language::emitchar): New member function, implementation from
	f_emit_char.
	* go-lang.c (go_language_data): Delete la_emitchar initializer.
	* language.c (unk_lang_emit_char): Delete.
	(language_defn::emitchar): New member function definition.
	(unknown_language_data): Delete la_emitchar initializer.
	(unknown_language::emitchar): New member function.
	(auto_language_data): Delete la_emitchar initializer.
	(auto_language::emitchar): New member function.
	* language.h (language_data): Delete la_emitchar field.
	(language_defn::emitchar): New member field declaration.
	(LA_EMIT_CHAR): Update call to emitchar.
	* m2-lang.c (m2_emit_char): Rename to m2_language::emitchar.
	(m2_language_data): Delete la_emitchar initializer.
	(m2_language::emitchar): New member function, implementation from
	m2_emit_char.
	* objc-lang.c (objc_language_data): Delete la_emitchar
	initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_emit_char): Rename to pascal_language::emitchar.
	(pascal_language_data): Delete la_emitchar initializer.
	(pascal_language::emitchar): New member function, implementation
	from pascal_emit_char.
	* rust-lang.c (rust_emitchar): Rename to rust_language::emitchar.
	(rust_language_data): Delete la_emitchar initializer.
	(rust_language::emitchar): New member function, implementation
	from rust_emitchar.
2020-06-23 13:34:11 +01:00
Andrew Burgess 1bf9c36374 gdb: Convert language la_post_parser field to a method
This commit changes the language_data::la_post_parser function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (resolve): Rename to ada_language::post_parser.
	(ada_language_data): Delete la_post_parser initializer.
	(ada_language::post_parser): New member function.
	* c-lang.c (c_language_data): Delete la_post_parser initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_language_data): Likewise.
	* go-lang.c (go_language_data): Likewise.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_post_parser field.
	(language_defn::post_parser): New member function.
	* m2-lang.c (m2_language_data): Delete la_post_parser initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* parse.c (parse_exp_in_context): Update call to post_parser.
	(null_post_parser): Delete definition.
	* parser-defs.h (null_post_parser): Delete declaration.
	* rust-lang.c (rust_language_data): Delete la_post_parser
	initializer.
2020-06-23 13:34:11 +01:00
Andrew Burgess 87afa6523b gdb: Convert language la_parser field to a method
This commit changes the language_data::la_parser function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (parse): Rename to ada_language::parser.
	(ada_language_data): Delete la_parser initializer.
	(ada_language::parser): New member function, implementation from
	parse.
	* c-lang.c (c_language_data): Delete la_parser initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	(d_language::parser): New member function.
	* f-lang.c (f_language_data): Delete la_parser initializer.
	(f_language::parser): New member function.
	* go-lang.c (go_language_data): Delete la_parser initializer.
	(go_language::parser): New member function.
	* language.c (unk_lang_parser): Delete.
	(language_defn::parser): Define new member function.
	(unknown_language_data): Delete la_parser initializer.
	(unknown_language::parser): New member function.
	(auto_language_data): Delete la_parser initializer.
	(auto_language::parser): New member function.
	* language.h (language_data): Delete la_parser field.
	(language_defn::parser): Declare new member function.
	* m2-lang.c (m2_language_data): Delete la_parser initializer.
	(m2_language::parser): New member function.
	* objc-lang.c (objc_language_data): Delete la_parser initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	(pascal_language::parser): New member function.
	* parse.c (parse_exp_in_context): Update call to parser.
	* rust-lang.c (rust_language_data): Delete la_parser initializer.
	(rust_language::parser): New member function.
2020-06-23 13:34:10 +01:00
H.J. Lu 3084d7a27b ELF: Add _bfd_elf_add_dynamic_tags
All ELF backends with shared library support need to add dynamic tags.
Add dt_pltgot_required and dt_jmprel_required to elf_link_hash_table to
indicate that DT_PLTGOT and DT_JMPREL are required dynamic tags.

1. Add _bfd_elf_add_dynamic_tags to add common dynamic tags.
2. Add _bfd_elf_maybe_vxworks_add_dynamic_tags to add common VxWorks
dynamic tags.

	* elf-bfd.h (elf_link_hash_table): Add dt_pltgot_required and
	dt_jmprel_required.
	(_bfd_elf_add_dynamic_tags): New.
	* elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Call
	_bfd_elf_add_dynamic_tags.
	* elf32-arc.c (elf_arc_size_dynamic_sections): Likewise.
	* elf32-bfin.c (elf32_bfinfdpic_size_dynamic_sections): Likewise.
	* elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise.
	* elf32-frv.c (elf32_frvfdpic_size_dynamic_sections): Likewise.
	* elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise.
	* elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise.
	* elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
	* elf32-microblaze.c (microblaze_elf_size_dynamic_sections):
	Likewise.
	* elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise.
	* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise.
	* elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise.
	* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
	* elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise.
	* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
	* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
	* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections):
	Likewise.
	* elfnn-riscv.c (riscv_elf_size_dynamic_sections): Likewise.
	* elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise.
	* elf32-arm.c (elf32_arm_size_dynamic_sections): Call
	_bfd_elf_maybe_vxworks_add_dynamic_tags.
	* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections):
	Likewise.
	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Likewise.
	(_bfd_x86_elf_size_dynamic_sections): Likewise.
	* elfxx-x86.h (elf_x86_link_hash_table): Remove dt_reloc,
	dt_reloc_sz and dt_reloc_ent.
	* elf-vxworks.c (_bfd_elf_maybe_vxworks_add_dynamic_tags): New.
	* elf-vxworks.h (_bfd_elf_maybe_vxworks_add_dynamic_tags):
	Likewise.
	* elf32-hppa.c (elf32_hppa_link_hash_table_create): Set
	etab.dt_pltgot_required.
	(elf32_hppa_size_dynamic_sections): Call
	_bfd_elf_add_dynamic_tags.
	* elf32-metag.c (elf_metag_link_hash_table_create): Set
	etab.dt_pltgot_required.
	(elf_metag_size_dynamic_sections): Call _bfd_elf_add_dynamic_tags.
	* elf32-sh.c (sh_elf_link_hash_table_create): Set
	root.dt_pltgot_required for FDPIC output.
	(sh_elf_size_dynamic_sections): Call
	_bfd_elf_maybe_vxworks_add_dynamic_tags.
	* elf32-xtensa.c (elf_xtensa_link_hash_table_create): Set
	elf.dt_pltgot_required.
	(elf_xtensa_size_dynamic_sections): Call
	_bfd_elf_add_dynamic_tags.
	* elf64-hppa.c (elf64_hppa_hash_table_create): Set
	root.dt_pltgot_required.
	(elf64_hppa_size_dynamic_sections): Call
	_bfd_elf_add_dynamic_tags.
	* elfnn-ia64.c (elfNN_ia64_hash_table_create): Set
	root.dt_pltgot_required.
	(elfNN_ia64_size_dynamic_sections): Set root.dt_jmprel_required
	for rel_pltoff_sec.  Call _bfd_elf_add_dynamic_tags.
	* elflink.c (_bfd_elf_add_dynamic_tags): New.
2020-06-23 05:07:45 -07:00
Gary Benson 2e573c0a3f Avoid testcase build failures with -Wunused-value
A number of testcases fail to build with -Wunused-value enabled.
This commit adds dummy values to avoid this.

gdb/testsuite/ChangeLog:

	* gdb.cp/namespace.cc: Avoid build failure with -Wunused-value.
	* gdb.cp/nsimport.cc: Likewise.
	* gdb.cp/nsnested.cc: Likewise.
	* gdb.cp/nsnoimports.cc: Likewise.
	* gdb.cp/nsusing.cc: Likewise.
	* gdb.cp/smartp.cc: Likewise.
	* gdb.python/py-pp-integral.c: Likewise.
	* gdb.python/py-pp-re-notag.c: Likewise.
2020-06-23 12:25:34 +01:00
Andrew Burgess 378258006c gdb: Add --with-python-libdir to gdb's --configuration output
Commit:

  commit d13c7322fe
  Date:   Fri Jan 17 00:10:22 2020 +0000

      gdb: Allow more control over where to find python libraries

Added a new configuration option --with-python-libdir, but failed to
add this option to the output of 'gdb --configuration'.  This commit
fixes this mistake.

gdb/ChangeLog:

	* top.c (print_gdb_configuration): Print --with-python-libdir
	configuration value.
2020-06-23 10:06:20 +01:00
Nelson Chu 1a79004f61 RISC-V: Generate ELF priv attributes if priv instruction are explicited used.
We should generate the ELF priv attributes only if,

1. The priv attributes are already set in the assembly file.
2. The CSR are explicited used.
3. The privileged instruction are explicited used.

* There are four privileged instruction defined in the v1.11 priv spec:
`mret`, `sret`, `wfi` and `sfence.vma`.

* `sfence.vm` is dropped in the v1.10 priv spec.

* `uret` is actually a N-ext instruction.  So it is better to regard it as
an user instruction rather than the priv instruction.

* `hret` is used to return from traps in H-mode.  H-mode is removed since
the v1.10 priv spec, but probably be added in the new hypervisor spec.
Therefore, `hret` should be controlled by the hypervisor spec rather than
priv spec in the future.

* `dret` is a debug instruction.  We should record the debug spec versions
once it is explicited used in the future.

	gas/
	* config/tc-riscv.c (explicit_priv_attr): Rename explicit_csr to
	explicit_priv_attr.  It used to indicate CSR or priv instructions are
	explictly used.
	(riscv_is_priv_insn): Return True if it is a privileged instruction.
	(riscv_ip): Call riscv_is_priv_insn to check whether the instruction
	is privileged or not.  If it is, then set explicit_priv_attr to TRUE.
	(riscv_write_out_attrs): Clarification of when to generate the elf
	priv spec attributes.

	* testsuite/gas/riscv/attribute-11.s: Add comments.
	* testsuite/gas/riscv/attribute-14.s: New testcase.  Use symbol
	`priv_insn_<n>` to decide which priv instruction is expected to used.
	(<n> is a to g.)
	* testsuite/gas/riscv/attribute-14a.d: Likewise.
	* testsuite/gas/riscv/attribute-14b.d: Likewise.
	* testsuite/gas/riscv/attribute-14c.d: Likewise.
	* testsuite/gas/riscv/attribute-14d.d: Likewise.
	* testsuite/gas/riscv/attribute-14e.d: Likewise.
2020-06-23 09:38:12 +08:00
Alan Modra c7c970e4c6 Correct bfin XPASSes
bfin-elf and bfin-linux differ.  This patch fixes these:
bfin-linux-uclibc  -XPASS: PR ld/14170
bfin-linux-uclibc  -XPASS: pr17068 link --as-needed lib in group
bfin-linux-uclibc  -XPASS: -Bsymbolic-functions
bfin-linux-uclibc  -XPASS: pr22374 function pointer initialization

	* testsuite/ld-elf/shared.exp (pr14170): Clear xfail for
	bfin-*-linux*.
	(pr17068, symbolic-func.so, pr22374): Likewise.
2020-06-23 11:03:34 +09:30