]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
4 years agoPR25629, objcopy : SIGSEGV in filter_symbols
Alan Modra [Thu, 5 Mar 2020 04:27:47 +0000 (14:57 +1030)] 
PR25629, objcopy : SIGSEGV in filter_symbols

PR 25629
* objcopy.c (filter_symbols): Don't segfault on NULL
prefix_symbols_string.

4 years agoRISC-V: Support assembler modifier %got_pcrel_hi.
Nelson Chu [Wed, 4 Mar 2020 05:08:05 +0000 (21:08 -0800)] 
RISC-V: Support assembler modifier %got_pcrel_hi.

gas/
* config/tc-riscv.c: Support the modifier %got_pcrel_hi.
* doc/c-riscv.texi: Add documentation.
* testsuite/gas/riscv/no-relax-reloc.d: Add test case for the new
modifier %got_pcrel_hi.
* testsuite/gas/riscv/no-relax-reloc.s: Likewise.
* testsuite/gas/riscv/relax-reloc.d: Likewise.
* testsuite/gas/riscv/relax-reloc.s: Likewise.

4 years agoRISC-V: Add description for RISC-V Modifiers to as doc.
Nelson Chu [Wed, 4 Mar 2020 05:08:04 +0000 (21:08 -0800)] 
RISC-V: Add description for RISC-V Modifiers to as doc.

gas/
* doc/c-riscv.texi (relocation modifiers): Add documentation.
(RISC-V-Formats): Update the section name from "Instruction Formats"
to "RISC-V Instruction Formats".

4 years agoLarge memory allocation reading fuzzed 64-bit archive
Alan Modra [Wed, 4 Mar 2020 23:12:41 +0000 (09:42 +1030)] 
Large memory allocation reading fuzzed 64-bit archive

This patch adds a sanity check for the size of an armap.

* archive64.c (_bfd_archive_64_bit_slurp_armap): Check parsed_size
against file size before allocating memory.  Use bfd_alloc rather
than bfd_zalloc for carsym/strings memory.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 5 Mar 2020 00:00:26 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoIntroduce objfile::intern
Tom Tromey [Wed, 4 Mar 2020 23:34:49 +0000 (16:34 -0700)] 
Introduce objfile::intern

This introduces a string cache on the per-BFD object, replacing the
macro and filename caches.  Both of these caches just store strings,
so this consolidation by itself saves a little memory (about the size
of a bcache per objfile).

Then this patch switches some allocations on the objfile obstack to
use this bcache instead.  This saves more space; and turns out to be a
bit faster as well.

Here are the before and after "maint time" + "maint space" results of
"file ./gdb":

    Command execution time: 4.664021 (cpu), 4.728518 (wall)
    Space used: 39190528 (+29212672 for this command)

    Command execution time: 4.216209 (cpu), 4.107023 (wall)
    Space used: 36667392 (+26689536 for this command)

The main interface to the string cache is a new pair of overloaded
methods, objfile::intern.

gdb/ChangeLog
2020-03-04  Tom Tromey  <tom@tromey.com>

* symmisc.c (print_symbol_bcache_statistics)
(print_objfile_statistics): Update.
* symfile.c (allocate_symtab): Use intern.
* psymtab.c (partial_symtab::partial_symtab): Use intern.
* objfiles.h (struct objfile_per_bfd_storage) <filename_cache,
macro_cache>: Remove.
<string_cache>: New member.
(struct objfile) <intern>: New methods.
* elfread.c (elf_symtab_read): Use intern.
* dwarf2/read.c (fixup_go_packaging): Intern package name.
(dwarf2_compute_name, dwarf2_physname)
(create_dwo_unit_in_dwp_v1, create_dwo_unit_in_dwp_v2): Intern
names.
(guess_partial_die_structure_name): Update.
(partial_die_info::fixup): Intern name.
(dwarf2_canonicalize_name): Change parameter to objfile.  Intern
name.
(dwarf2_name): Intern name.  Update.
* buildsym.c (buildsym_compunit::get_macro_table): Use
string_cache.

4 years agoMake "gnutarget" const
Tom Tromey [Wed, 4 Mar 2020 23:24:08 +0000 (16:24 -0700)] 
Make "gnutarget" const

I noticed that gnutarget was not "const".  Since writing through this
pointer would probably be a bug, I think it ought to be.  This patch
makes the change.

gdb/ChangeLog
2020-03-04  Tom Tromey  <tom@tromey.com>

* jit.c (bfd_open_from_target_memory): Make "target" const.
* corefile.c (gnutarget): Now const.
* gdbcore.h (gnutarget): Now const.

4 years agoPR25570, ld duplicate "warning: changing start of section"
Alan Modra [Wed, 4 Mar 2020 10:44:19 +0000 (21:14 +1030)] 
PR25570, ld duplicate "warning: changing start of section"

Note that because we should report a signed delta from the previous
VMA it isn't possible to use ngettext.  ngettext only supports
unsigned long values.  So byte/bytes goes from the message.

PR 25570
* ldlang.c (lang_sizing_iteration): New static var.
(lang_size_sections_1): Warn about no memory region only on first
iteration.  Warn about changing start address on first iteration
then any delta from that on subsequent iterations.  Report a signed
delta.
(one_lang_size_sections_pass): Increment lang_sizing_iteration.

4 years agoImplement debugging of WOW64 processes
Hannes Domani [Sun, 26 Jan 2020 21:04:04 +0000 (22:04 +0100)] 
Implement debugging of WOW64 processes

For WOW64 processes, the Wow64* variants of SuspendThread,
GetThreadContext, SetThreadContext, and GetThreadSelectorEntry have to
be used instead.
And instead of EnumProcessModules, EnumProcessModulesEx with
LIST_MODULES_32BIT is necessary.

gdb/ChangeLog:

2020-03-04  Hannes Domani  <ssbssa@yahoo.de>

* NEWS: Mention support for WOW64 processes.
* amd64-windows-nat.c (amd64_mappings): Rename and remove static.
(amd64_windows_segment_register_p): Remove static.
(_initialize_amd64_windows_nat): Update.
* configure.nat <windows> (NATDEPFILES): Add i386-windows-nat.o.
* i386-windows-nat.c (context_offset): Update.
(i386_mappings): Rename and remove static.
(i386_windows_segment_register_p): Remove static.
(_initialize_i386_windows_nat): Update.
* windows-nat.c (STATUS_WX86_BREAKPOINT): New macro.
(STATUS_WX86_SINGLE_STEP): New macro.
(EnumProcessModulesEx): New macro.
(Wow64SuspendThread): New macro.
(Wow64GetThreadContext): New macro.
(Wow64SetThreadContext): New macro.
(Wow64GetThreadSelectorEntry): New macro.
(windows_set_context_register_offsets): Add static.
(windows_set_segment_register_p): Likewise.
(windows_add_thread): Adapt for WOW64 processes.
(windows_fetch_one_register): Likewise.
(windows_nat_target::fetch_registers): Likewise.
(windows_store_one_register): Likewise.
(display_selector): Likewise.
(display_selectors): Likewise.
(handle_exception): Likewise.
(windows_continue): Likewise.
(windows_nat_target::resume): Likewise.
(windows_add_all_dlls): Likewise.
(do_initial_windows_stuff): Likewise.
(windows_nat_target::attach): Likewise.
(windows_get_exec_module_filename): Likewise.
(windows_nat_target::create_inferior): Likewise.
(windows_xfer_siginfo): Likewise.
(_initialize_loadable): Initialize Wow64SuspendThread,
Wow64GetThreadContext, Wow64SetThreadContext,
Wow64GetThreadSelectorEntry and EnumProcessModulesEx.
* windows-nat.h (windows_set_context_register_offsets):
Remove declaration.
(windows_set_segment_register_p): Likewise.
(i386_windows_segment_register_p): Add declaration.
(amd64_windows_segment_register_p): Likewise.

4 years agoGenerate a warning in the ARM assembler if a PC-relative thumb load instruction is...
Alexandre Oliva [Wed, 4 Mar 2020 17:28:46 +0000 (17:28 +0000)] 
Generate a warning in the ARM assembler if a PC-relative thumb load instruction is detected in a section with insufficient alignment.

* config/tc-arm.c (md_apply_fix): Warn if a PC-relative load is
detected in a section which does not have at least 4 byte
alignment.
* testsuite/gas/arm/armv8-ar-it-bad.s: Add alignment directive.
* testsuite/gas/arm/ldr-t.s: Likewise.
* testsuite/gas/arm/sp-pc-usage-t.s: Likewise.
* testsuite/gas/arm/sp-pc-usage-t.d: Finish test at end of
disassembly, ignoring any NOPs that may have been inserted because
of section alignment.
* testsuite/gas/arm/ldr-t.d: Likewise.

4 years agoRevert "gdb: Do not print empty-group regs when printing general ones"
Luis Machado [Wed, 4 Mar 2020 16:08:13 +0000 (13:08 -0300)] 
Revert "gdb: Do not print empty-group regs when printing general ones"

Revert the change since it breaks existing behavior of "info registers"
for some architectures. At least AArch64 and ARM are impacted by this change.

gdb/ChangeLog:

2020-03-04  Luis Machado  <luis.machado@linaro.org>

Revert aa66aac47b4dd38f9524ddb5546c08cc09930d37 due to regressions
in "info registers" for AArch64/ARM.

The change caused "info registers" to not print GPR's.

gdb/ChangeLog:

2020-02-01  Shahab Vahedi  <shahab@synopsys.com>

* target-descriptions.c (tdesc_register_in_reggroup_p): Return 0
when reg->group is empty and reggroup is not.

4 years ago[gdb/doc] Remove trailing done from "Reading symbols from" lines
Tom de Vries [Wed, 4 Mar 2020 15:27:56 +0000 (16:27 +0100)] 
[gdb/doc] Remove trailing done from "Reading symbols from" lines

Since commit 3453e7e409 'Clean up "Reading symbols" output' we no longer print
"done." after the "Reading symbols from" message:
...
$ gdb -q a.out
Reading symbols from a.out...
(gdb)
...

Update docs accordingly.

Build on x86_64-linux.

gdb/doc/ChangeLog:

2020-03-04  Tom de Vries  <tdevries@suse.de>

* gdb.texinfo: Remove trailing "done." in "Reading symbols from" lines.
* python.texi: Same.

4 years agogdb.fortran: Allow Flang kind printing in fortran testing
Alok Kumar Sharma [Wed, 4 Mar 2020 11:46:52 +0000 (17:16 +0530)] 
gdb.fortran: Allow Flang kind printing in fortran testing

In lib/fortran.exp, in the helper function fortran_int4, kind
parameter is expected to be printed as (kind=4) for the LLVM
Fortran compiler, Flang along with gfortran.  And in the helper
function fortran_int8 kind parameter is expected to be printed
as (kind=8).  But for the Flang compiler default kind is not
printed and non default kind is printed differently than gfortran
as below.
  integer(kind=4) => integer
  integer(kind=8) => integer*8
  real(kind=4) => real
  real(kind=8) => double precision
  complex(kind=4) => complex
  logical(kind=4) => logical
  character(kind=1) => character
This commit adds support for printing of kind parameter for the
Flang.  There should be no change when testing with gfortran.

Note: The current patch overrides earlier patch with below details.
  commit c3b149eb7697b376df1b3a47d0102afda389ee6d
  Author Alok Kumar Sharma (alokkumar.sharma@amd.com)
Earlier patch was incomplete and based on assumption that flang
should be changed to dump a type with kind like the way gfortan does.
Later it was realized that the way flang dumps this info is not
incorrect but different. And changes in gdb test framework are
finalized.

gdb/testsuite/ChangeLog:

* lib/fortran.exp (fortran_int4): Handle flang kind printing.
(fortran_int8): Likewise.
(fortran_real4): Likewise.
(fortran_real8): Likewise.
(fortran_complex4): Likewise.
(fortran_logical4): Likewise.
(fortran_character1): Likewise.

4 years agox86: support VMGEXIT
Jan Beulich [Wed, 4 Mar 2020 07:58:13 +0000 (08:58 +0100)] 
x86: support VMGEXIT

It has been publicly documented for quite some time, albeit not in the
"General-Purpose and System Instructions" volume:
https://www.amd.com/system/files/TechDocs/24593.pdf.

4 years agoRevert "PR25570, ld duplicate "warning: changing start of section""
Alan Modra [Wed, 4 Mar 2020 06:08:59 +0000 (16:38 +1030)] 
Revert "PR25570, ld duplicate "warning: changing start of section""

This reverts commit 91114f7583fac8fdf57c58a1f632839da62e43da.

4 years agoPR25570, ld duplicate "warning: changing start of section"
Alan Modra [Wed, 4 Mar 2020 05:03:26 +0000 (15:33 +1030)] 
PR25570, ld duplicate "warning: changing start of section"

PR 25570
* ldlang.c (lang_size_sections_1): Delay emitting non-fatal
errors/warnings until final pass.
* ldexp.c (fold_name): Likewise.

4 years agosh_addralign inconsistent with sh_addr
Alan Modra [Wed, 4 Mar 2020 04:56:00 +0000 (15:26 +1030)] 
sh_addralign inconsistent with sh_addr

The ELF gABI says in part of sh_addralign:  "The value of sh_addr must
be congruent to 0, modulo the value of sh_addralign."

* elf.c (elf_fake_sections): Ensure sh_addralign is such that
sh_addr mod sh_addalign is zero.

4 years agoCall cleanup on bfd_check_format_matches error exit
Alan Modra [Wed, 4 Mar 2020 00:57:29 +0000 (11:27 +1030)] 
Call cleanup on bfd_check_format_matches error exit

* format.c (bfd_check_format_matches): Call cleanup on error exit.

4 years agoobjcopy: Fix for pr19005 on machines with more than one octet per byte.
Christian Eggers [Mon, 2 Mar 2020 21:08:20 +0000 (22:08 +0100)] 
objcopy: Fix for pr19005 on machines with more than one octet per byte.

On machines with more than one octet per byte, objcopy fills only a part
of the gap between sections.

* objcopy.c (copy_object): Convert from bytes to octets for
--gap-fill and --pad-to.

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 4 Mar 2020 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoFind tailcall frames before inline frames
Tom Tromey [Tue, 3 Mar 2020 22:27:04 +0000 (15:27 -0700)] 
Find tailcall frames before inline frames

A customer reported a failure to unwind in a certain core dump.  A
lengthy investigation showed that the problem came from the
interaction between the tailcall and inline frame sniffers.

Normally, the regular DWARF unwinder may discover a chain of tail
calls ending in the current frame.  In this case, it sets a member on
the dwarf2_frame_cache object, so that a subsequent call into the
tailcall sniffer will create the tailcall frames.

However, in this scenario, what happened is that the DWARF unwinder
did find tailcall frames -- but then the PC of the first such frame
was recognized and claimed by the inline frame sniffer.

This then caused unwinding to go astray further up the stack.

This patch fixes the problem by arranging for the tailcall sniffer to
be called before the inline sniffer.  This way, if a DWARF frame has
tailcall information, the tailcalls will always be processed first.
This is safe to do, because the tailcall sniffer can only claim a
frame if the previous frame did in fact find this information.  (So,
for example, if no DWARF frame is ever found, then this sniffer will
never trigger.)

This patch also partially reverts:

    commit 1ec56e88aa9b052ab10b806d82fbdbc8d153d977
    Author: Pedro Alves <palves@redhat.com>
    Date:   Fri Nov 22 13:17:46 2013 +0000

Eliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer (move dwarf2_tailcall_sniffer_first elsewhere).

That patch moved the call to dwarf2_tailcall_sniffer_first out of
dwarf2_frame_cache, and into dwarf2_frame_prev_register.  However, in
this situation, this is too late -- by the time
dwarf2_frame_prev_register is called, the frame in question is already
recognized by the inline frame sniffer.

Rather than fully revert that patch, though, this just arranges to
call dwarf2_tailcall_sniffer_first from dwarf2_frame_cache -- which is
called shortly after the DWARF frame sniffer succeeds, via
compute_frame_id.

I don't know how to write a test case for this.

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

* dwarf2/frame.c (struct dwarf2_frame_cache)
<checked_tailcall_bottom, entry_cfa_sp_offset,
entry_cfa_sp_offset_p>: Remove members.
(dwarf2_frame_cache): Call dwarf2_tailcall_sniffer_first.
(dwarf2_frame_prev_register): Don't call
dwarf2_tailcall_sniffer_first.
(dwarf2_append_unwinders): Don't append tailcall unwinder.
* frame-unwind.c (add_unwinder): New fuction.
(frame_unwind_init): Use it.  Add tailcall unwinder.

4 years agogdbsupport: re-generate Makefile.in
Simon Marchi [Tue, 3 Mar 2020 22:11:12 +0000 (17:11 -0500)] 
gdbsupport: re-generate Makefile.in

It looks like after doing last minute changes to Makefile.am in commit
06b3c5bdb ("gdbsupport: rename source files to .cc"), I forgot to
re-generate Makefile.in.  This patch fixes it.

gdbsupport/ChangeLog:

* Makefile.in: Re-generate.

4 years agox86: Replace IgnoreSize/DefaultSize with MnemonicSize
H.J. Lu [Tue, 3 Mar 2020 19:24:16 +0000 (11:24 -0800)] 
x86: Replace IgnoreSize/DefaultSize with MnemonicSize

Since an instruction template can't have both IgnoreSize and DefaultSize,
this patch replaces IgnoreSize and DefaultSize with MnemonicSize.

gas/

* config/tc-i386.c (match_template): Replace ignoresize and
defaultsize with mnemonicsize.
(process_suffix): Likewise.

opcodes/

* i386-gen.c (opcode_modifiers): Replace IgnoreSize/DefaultSize
with MnemonicSize.
* i386-opc.h (IGNORESIZE): New.
(DEFAULTSIZE): Likewise.
(IgnoreSize): Removed.
(DefaultSize): Likewise.
(MnemonicSize): New.
(i386_opcode_modifier): Replace ignoresize/defaultsize with
mnemonicsize.
* i386-opc.tbl (IgnoreSize): New.
(DefaultSize): Likewise.
* i386-tbl.h: Regenerated.

4 years agogdb/fortran: Fix printing of logical true values for Flang
Andrew Burgess [Mon, 2 Mar 2020 18:08:49 +0000 (18:08 +0000)] 
gdb/fortran: Fix printing of logical true values for Flang

GDB is not able to print logical true values for Flang compiler.

Actual result:

  (gdb) p l
  $1 = 4294967295

Expected result:

  (gdb) p l
  $1 = .TRUE.

This is due to GDB expecting representation of true value being 1.
The Fortran standard doesnt specify how LOGICAL types are represented.
Different compilers use different non-zero values to represent logical
true. The gfortran compiler uses 1 to represent logical true and the
flang compiler uses -1. GDB should accept all the non-zero values as
true.

This is achieved by handling TYPE_CODE_BOOL in f_val_print and
printing any non-zero value as true.

gdb/ChangeLog:

* f-valprint.c (f_val_print): Handle TYPE_CODE_BOOL, any non-zero
value should be printed as true.

gdb/testsuite/ChangeLog:

* gdb.fortran/logical.exp: Add tests that any non-zero value is
printed as true.

4 years agoRebase executable to match relocated base address
Hannes Domani [Wed, 12 Feb 2020 16:53:32 +0000 (17:53 +0100)] 
Rebase executable to match relocated base address

Windows executables linked with -dynamicbase get a new base address
when loaded, which makes debugging impossible if the executable isn't
also rebased in gdb.

The new base address is read from the Process Environment Block.

gdb/ChangeLog:

2020-03-03  Hannes Domani  <ssbssa@yahoo.de>

* windows-tdep.c (windows_solib_create_inferior_hook): New function.
(windows_init_abi): Set and use windows_so_ops.

4 years agoThe patch fixed invalid compilation of instruction LD IY,(HL) and disassemble of...
Sergey Belyashov [Tue, 3 Mar 2020 16:31:42 +0000 (16:31 +0000)] 
The patch fixed invalid compilation of instruction LD IY,(HL) and disassemble of this and LD (HL),IX instruction. Also it update testsuit.

PR 25627
opcodes * z80-dis.c: Fix disassembly of LD IY,(HL) and D (HL),IX
instructions.

gas * config/tc-z80.c (emit_ld_rr_m): Fix invalid compilation of
instruction LD IY,(HL).
* testsuite/gas/z80/ez80_adl_all.d: Update expected disassembly.
* testsuite/gas/z80/ez80_adl_all.s: Add tests of the instruction.
* testsuite/gas/z80/ez80_z80_all.d: Update expected disassembly.
* testsuite/gas/z80/ez80_z80_all.s: Add tests of the instruction.

4 years agoFix printf of a convenience variable holding an inferior address
Sergio Durigan Junior [Sun, 1 Mar 2020 23:15:53 +0000 (18:15 -0500)] 
Fix printf of a convenience variable holding an inferior address

Back at:

commit 1f6f6e21fa86dc3411a6498608f32e9eb24b7851
Author: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Date:   Mon Jun 10 21:41:51 2019 +0200

    Ensure GDB printf command can print convenience var strings without a target.

GDB was extended in order to allow the printing of convenience
variables that are strings without a target.  However, this introduced
a regression that hasn't been caught by our testsuite (because there
were no tests for it).

The problem happens when we try to print a convenience variable that
holds the address of a string in the inferior.  The following
two-liners can reproduce the issue:

$ echo -e 'int main(){const char a[]="test";return 0;}' | gcc -x c - -O0-g3
$ ./gdb/gdb --data-directory ./gdb/data-directory -q ./a.out -ex 'start' -ex 'set $x = (const char *) (&a[0] + 2)' -ex 'printf "%s\n", $x'

After some investigation, I found that the problem happens on
printcmd.c:printf_c_string.  In the case above, we're taking the first
branch of the 'if' condition, which assumes that there will be a value
to be printed at "value_contents (value)".  There isn't.  We actually
need to obtain the address that the variable points to, and read the
contents from memory.

It seems to me that we should avoid this branch if the TYPE_CODE of
"value_type (value)" is TYPE_CODE_PTR (i.e., a pointer to the
inferior's memory).  This is what this patch does.

I took the liberty to extend the current testcase under
gdb.base/printcmds.exp and create a test that exercises this scenario.

No regressions have been found on Buildbot.

gdb/ChangeLog:
2020-03-03  Sergio Durigan Junior  <sergiodj@redhat.com>

* printcmd.c (print_c_string): Check also for TYPE_CODE_PTR
when verifying if dealing with a convenience variable.

gdb/testsuite/ChangeLog:
2020-03-03  Sergio Durigan Junior  <sergiodj@redhat.com>

* gdb.base/printcmds.exp: Add test to verify printf of a
variable holding an address.

4 years agoRemove a call to abort which can be triggered by running objdump on a corrupt input...
Nick Clifton [Tue, 3 Mar 2020 16:11:12 +0000 (16:11 +0000)] 
Remove a call to abort which can be triggered by running objdump on a corrupt input file.

PR 25625
* prdbg.c (pr_tag_type): Remove call to abort.

4 years agox86: Allow integer conversion without suffix in AT&T syntax
H.J. Lu [Tue, 3 Mar 2020 15:39:18 +0000 (07:39 -0800)] 
x86: Allow integer conversion without suffix in AT&T syntax

According to gas manual, suffix in instruction mnemonics isn't always
required:

When there is no sizing suffix and no (suitable) register operands to
deduce the size of memory operands, with a few exceptions and where long
operand size is possible in the first place, operand size will default
to long in 32- and 64-bit modes.

This includes cvtsi2sd, cvtsi2ss, vcvtsi2sd, vcvtsi2ss, vcvtusi2sd and
vcvtusi2ss.  Since they are used in GCC 8 and older GCC releases, they
must be allowed without suffix in AT&T syntax.

gas/

PR gas/25622
* testsuite/gas/i386/i386.exp: Run x86-64-default-suffix and
x86-64-default-suffix-avx.
* testsuite/gas/i386/noreg64.s: Remove cvtsi2sd, cvtsi2ss,
vcvtsi2sd, vcvtsi2ss, vcvtusi2sd and vcvtusi2ss entries.
* testsuite/gas/i386/noreg64.d: Updated.
* testsuite/gas/i386/noreg64.l: Likewise.
* testsuite/gas/i386/x86-64-default-suffix-avx.d: New file.
* testsuite/gas/i386/x86-64-default-suffix.d: Likewise.
* testsuite/gas/i386/x86-64-default-suffix.s: Likewise.

opcodes/

PR gas/25622
* i386-opc.tbl: Add IgnoreSize to cvtsi2sd, cvtsi2ss, vcvtsi2sd,
vcvtsi2ss, vcvtusi2sd and vcvtusi2ss for AT&T syntax.
* i386-tbl.h: Regenerated.

4 years agox86: Improve -malign-branch
Hongtao Liu [Tue, 3 Mar 2020 14:21:37 +0000 (06:21 -0800)] 
x86: Improve -malign-branch

According to intel SDM manual, not all compare flag-modifying instructions
are marcro-fusible with subsequent jcc instructions. For those non-fusible
instructions, -malign-branch doesn't need to align them, only jcc itself
needs to be aligned.

Here are 2 restrictions which separate macro-fusible instruction from not

Restriction 1:
If TEST/AND/CMP/ADD/SUB/INC/DEC is one of the following format:

   cmp m, imm
   add m, imm
   sub m, imm
   test m, imm
   and m, imm
   inc m
   dec m

it is unfusible with any jcc instruction.

Restriction 2:

/* Table 3-2. Macro-Fusible Instructions in Haswell Microarchitecture
   Note it also works for Skylake and Cascadelake.
---------------------------------------------------------------------
|   JCC   | ADD/SUB/CMP | INC/DEC | TEST/AND |
| ------  | ----------- | ------- | -------- |
|   Jo    |      N      |    N    |     Y    |
|   Jno   |      N      |    N    |     Y    |
|  Jc/Jb  |      Y      |    N    |     Y    |
| Jae/Jnb |      Y      |    N    |     Y    |
|  Je/Jz  |      Y      |    Y    |     Y    |
| Jne/Jnz |      Y      |    Y    |     Y    |
| Jna/Jbe |      Y      |    N    |     Y    |
| Ja/Jnbe |      Y      |    N    |     Y    |
|   Js    |      N      |    N    |     Y    |
|   Jns   |      N      |    N    |     Y    |
|  Jp/Jpe |      N      |    N    |     Y    |
| Jnp/Jpo |      N      |    N    |     Y    |
| Jl/Jnge |      Y      |    Y    |     Y    |
| Jge/Jnl |      Y      |    Y    |     Y    |
| Jle/Jng |      Y      |    Y    |     Y    |
| Jg/Jnle |      Y      |    Y    |     Y    |

Update maybe_fused_with_jcc_p to check if operands of CMP like instructions
can be fused with condition jump.

* gas/config/tc-i386.h (i386_tc_frag_data): Add member mf_type.
(TC_FRAG_INIT): Init mf_type.
* gas/config/tc-i386.c (enum mf_jcc_kind): New enum.
(enum mf_cmp_kind): Ditto.
(maybe_fused_with_jcc_p): Add argument mf_cmp_p to get
mf_type of corresponding instructons, exclude unfusible
instructions.
(add_fused_jcc_padding_frag_p): Likewise.
(add_branch_padding_frag_p): Likewise.
(output_insn): Record mf_type for corresponding instructions.
(i386_macro_fusible_p): New function.
(i386_next_fusible_jcc_frag): Rename from i386_next_jcc_frag,
add argument cmp_fragP to return next fusible jcc frag only.
(i386_classify_machine_dependant_frag): Seperate macro-fusible
instructions from condition jump.
* gas/testsuite/gas/i386/align-branch-9.s: New file.
* gas/testsuite/gas/i386/align-branch-9.d: Ditto.
* gas/testsuite/gas/i386/x86-64-align-branch-9.s: Ditto.
* gas/testsuite/gas/i386/x86-64-align-branch-9.d: Ditto.
* gas/testsuite/gas/i386/i386.exp: Run new tests.

4 years agoUpdate GDB to use new AUXV entry types
Luis Machado [Tue, 25 Feb 2020 00:04:05 +0000 (21:04 -0300)] 
Update GDB to use new AUXV entry types

I noticed GDB didn't know a particular AT tag (51) when doing some debugging.
Turns out we're missing a few entries compared to glibc's headers.

This patch adds them to GDB and fixes a failure in gdb.base/auxv.exp as
a result.

gdb/ChangeLog:

2020-03-03  Luis Machado  <luis.machado@linaro.org>

* auxv.c (default_print_auxv_entry): Add new AUXV entries.

4 years agoAdd missing AT tags to the ELF common header.
Luis Machado [Tue, 3 Mar 2020 13:13:53 +0000 (13:13 +0000)] 
Add missing AT tags to the ELF common header.

* elf/common.h (AT_L1I_CACHESIZE, AT_L1I_CACHEGEOMETRY)
(AT_L1D_CACHESIZE, AT_L1D_CACHEGEOMETRY, AT_L2_CACHESIZE)
(AT_L2_CACHEGEOMETRY, AT_L3_CACHESIZE, AT_L3_CACHEGEOMETRY)
(AT_MINSIGSTKSZ): New defines, imported from glibc.

4 years agoFix a potential illegal memory access in the Z80 assembler.
Sergey Belyashov [Tue, 3 Mar 2020 13:09:19 +0000 (13:09 +0000)] 
Fix a potential illegal memory access in the Z80 assembler.

PR 25604
* config/tc-z80.c (contains_register): Prevent an illegal memory
access when checking an expression for a register name.

4 years agoNote that the --rpath-link command line option will search the contents of the SEARCH...
Nick Clifton [Tue, 3 Mar 2020 12:53:00 +0000 (12:53 +0000)] 
Note that the --rpath-link command line option will search the contents of the SEARCH_DIR linker script directive, if one is provided.

PR 25588
* ld.texi (Options): Update the description of the --rpath-link
option.

4 years agobfd_check_format_matches preserving matches vs. cleanups
Alan Modra [Tue, 3 Mar 2020 09:57:36 +0000 (20:27 +1030)] 
bfd_check_format_matches preserving matches vs. cleanups

It didn't take long for oss-fuzz to find double frees due to a bug in
the cleanup logic.  It's seen when reading in any alpha-vms object
file except when alpha_vms_vec is the default.  But alpha_vms_vec is
of course the default when building for --target=alpha-dec-vms (and
naturally what I used to  test the cleanup support since that is the
only target with a cleanup that does anything currently).

Anyway, the bug is that if bfd_check_format_matches is to preserve a
match the cleanup for that match can't be run.  Quite obviously that
would destroy part of the match state.

* format.c (struct bfd_preserve): Add cleanup field.
(bfd_preserve_save): Add cleanup param and save.
(bfd_preserve_restore): Return cleanup.
(bfd_preserve_finish): Call the cleanup for the discarded match.
(bfd_check_format_matches): Pass cleanup to bfd_preserve_save,
and clear when preserving a match.  Restore cleanup too when
restoring that match.

4 years ago[gdb/testsuite] Fix gdb.mi/gdb2549.exp with check-read1
Tom de Vries [Tue, 3 Mar 2020 10:34:53 +0000 (11:34 +0100)] 
[gdb/testsuite] Fix gdb.mi/gdb2549.exp with check-read1

When running gdb.mi/gdb2549.exp with check-read1, we get:
...
Running src/gdb/testsuite/gdb.mi/gdb2549.exp ...
FAIL: gdb.mi/gdb2549.exp: register values t (timeout)
...

The problem is that the command generates a lot of output, which is matched by
a single '.*':
...
mi_gdb_test "666-data-list-register-values t" \
  "666\\^done,register-values=\\\[\{number=\"$decimal\",value=\"$binary\"\}.*\\\]" \
  "register values t"
...

Fix this by splitting up the matching and calling exp_continue after each
number/value pair.

Tested on x86_64-linux with make targets check and check-read1.

gdb/testsuite/ChangeLog:

2020-03-03  Tom de Vries  <tdevries@suse.de>

* gdb.mi/gdb2549.exp: Fix "register values t" check-read1 timeout.

4 years ago[gdb/testsuite] Fix tcl error in gdb.mi/list-thread-groups-available.exp
Tom de Vries [Tue, 3 Mar 2020 09:50:07 +0000 (10:50 +0100)] 
[gdb/testsuite] Fix tcl error in gdb.mi/list-thread-groups-available.exp

When running gdb.mi/list-thread-groups-available.exp, we get:
...
Running gdb.mi/list-thread-groups-available.exp ...
ERROR: tcl error sourcing gdb.mi/list-thread-groups-available.exp.
ERROR: Too many arguments to gdb_test_multiple
...

The problem is that the gdb_test_multiple call has as last argument a
$mi_gdb_prompt, which is no longer supported syntax since 590003dc0e
"[gdb/testsuite] Add -lbl option in gdb_test_multiple".

Fix this by using the new -prompt syntax.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-03-03  Tom de Vries  <tdevries@suse.de>

* gdb.mi/list-thread-groups-available.exp: Use -prompt syntax for
gdb_test_multiple call.

4 years ago[gdb/testsuite] Fix mi-sym-info.exp with check-read1
Tom de Vries [Tue, 3 Mar 2020 09:33:49 +0000 (10:33 +0100)] 
[gdb/testsuite] Fix mi-sym-info.exp with check-read1

When running gdb.mi/mi-sym-info.exp with check-read1, we run into:
...
FAIL: gdb.mi/mi-sym-info.exp: List all functions
FAIL: gdb.mi/mi-sym-info.exp: List all variables
...

The problem is that while the $mi_gdb_prompt is active, gdb_test_multiple is
used without -prompt "$mi_gdb_prompt$", so it defaults to matching $gdb_prompt.

Fix this by adding the missing gdb_test_multiple arguments.

Reg-tested on x86_64-linux with make targets check and check-read1.

gdb/testsuite/ChangeLog:

2020-03-03  Tom de Vries  <tdevries@suse.de>

* gdb.mi/mi-sym-info.exp: Add missing -prompt "$mi_gdb_prompt$" to
gdb_test_multiple calls.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 3 Mar 2020 00:00:46 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoTidy obj-coff.h
Alan Modra [Mon, 2 Mar 2020 22:14:26 +0000 (08:44 +1030)] 
Tidy obj-coff.h

* config/obj-coff.h: Remove vestiges of coff-m68k and pe-mips
support.

4 years agoSmall clean up of use_displaced_stepping
Simon Marchi [Mon, 2 Mar 2020 20:47:04 +0000 (15:47 -0500)] 
Small clean up of use_displaced_stepping

This function returns the result of a quite big condition.  I think it
would be more readeable if it was broken up in smaller pieces and
commented.  This is what this patch does.

I also introduced gdbarch_supports_displaced_stepping, since it shows
the intent better than checking for gdbarch_displaced_step_copy_insn_p.
I also used that new function in displaced_step_prepare_throw.

I also updated the comment on top of can_use_displaced_stepping, which
seemed a bit outdated with respect to non-stop.  The comment likely
dates from before it was possible to have targets that always operate
non-stop under the hood, even when the user-visible mode is all-stop.

No functional changes intended.

gdb/ChangeLog:

* infrun.c (gdbarch_supports_displaced_stepping): New.
(use_displaced_stepping): Break up conditions in smaller pieces.
Use gdbarch_supports_displaced_stepping.
(displaced_step_prepare_throw): Use
gdbarch_supports_displaced_stepping.

4 years agogdb: Allow GDB to _not_ load a previous command history
Andrew Burgess [Wed, 22 Jan 2020 18:21:58 +0000 (18:21 +0000)] 
gdb: Allow GDB to _not_ load a previous command history

This commit aims to give a cleaner mechanism by which the user can
prevent GDB from trying to load any previous command history.

Currently the user can change the path to the history file, either
using a command line flag, or by setting the GDBHISTFILE environment
variable, and if the path is set to a non-existent file, then
obviously GDB wont load any command history.  However, this feels like
a bit of a bodge, I'd like to add an official mechanism by which we
can disable command history loading.

Why would we want to prevent command history loading?  The specific
use case I have is GDB starting with a CWD that is a network mounted
directory, and there is no command history present.  Still GDB will
access the network in order to check for the file.  In my particular
use case I'm actually starting a large number of GDB instances in
parallel, all in the same network mounted directory, the large number
of network accesses looking for this file introduces a noticeable
delay at GDB startup.

The approach I'm proposing here is a slight adjustment to the current
rules for setting up the history filename.  Currently, if a user does
this, they see an error:

  (gdb) set history filename
  Argument required (filename to set it to.).

However, if a user does this:

  $ GDBHISTFILE= gdb --quiet
  (gdb) set history save on
  (gdb) q
  warning: Could not rename -gdb18416~ to : No such file or directory

So, we already have a bug in this area.  My plan is to allow the empty
filename to be accepted, and for this to mean, neither load, nor save
the command history.

This does mean that we now have two mechanisms to prevent saving the
command history:

  (gdb) set history filename

or

  (gdb) set history save off

But the only way to prevent loading the command history is to set the
filename to the empty string _before_ you get to a GDB prompt, either
using a command line option, or the environment variable.

I've updated some of the show commands, for example this session:

  (gdb) set history filename
  (gdb) show history filename
  There is no filename currently set for recording the command history in.
  (gdb) show history save
  Saving of the history record on exit is off.
  (gdb) set history save on
  (gdb) show history save
  Saving of the history is disabled due to the value of 'history filename'.
  (gdb) set history filename /tmp/hist
  (gdb) show history save
  Saving of the history record on exit is on.

I've updated the manual, and added some tests.

gdb/ChangeLog:

* NEWS: Mention new behaviour of the history filename.
* top.c (write_history_p): Add comment.
(show_write_history_p): Add header comment, give a different
message when history writing is on, but the history filename is
empty.
(history_filename): Add comment.
(history_filename_empty): New function.
(show_history_filename): Add header comment, give a different
message when the filename is empty.
(init_history): Compare history_filename against nullptr, and only
read history if the filename is not empty.
(set_history_filename): Add header comment, and only make
non-empty filenames absolute.
(init_main): Make the filename argument to 'set history filename'
optional.

gdb/doc/ChangeLog:

* gdb.texinfo (Command History): Extend description for
GDBHISTFILE and GDBHISTSIZE, add detail about the filename for
'set history filename' being optional.  Describe the effect of an
empty history filename on 'set history save on'.

gdb/testsuite/ChangeLog:

* gdb.base/default.exp: Remove test of 'set history filename'.
* gdb.base/gdbinit-history.exp: Add tests for setting the history
filename to the empty string.
* lib/gdb.exp (gdb_init): Unset environment variables GDBHISTFILE
and GDBHISTSIZE.

Change-Id: Ia586e4311182fac99113b60f11ef8a11fbd5450b

4 years agoFix arm-netbsd build error: convert from FPA to VFP
Christian Biesinger [Mon, 2 Mar 2020 17:28:14 +0000 (11:28 -0600)] 
Fix arm-netbsd build error: convert from FPA to VFP

The floating point register interface has changed to this:
https://github.com/NetBSD/src/blob/trunk/sys/arch/arm/include/reg.h

It now uses VFP instead of FPA registers. This patch updates
arm-nbsd-nat.c accordingly.

Also implements read_description so that these registers are correctly
printed by "info registers" et al.

Tested by compiling & running on arm-netbsd on qemu.

gdb/ChangeLog:

2020-03-02  Christian Biesinger  <cbiesinger@google.com>

* arm-nbsd-nat.c (arm_supply_fparegset): Rename to...
(arm_supply_vfpregset): ...this, and update to use VFP registers.
(fetch_fp_register): Update.
(fetch_fp_regs): Update.
(store_fp_register): Update.
(store_fp_regs): Update.
(arm_netbsd_nat_target::read_description): New function.
(fetch_elfcore_registers): Update.

4 years agogdb/remote: Restore support for 'S' stop reply packet
Andrew Burgess [Thu, 30 Jan 2020 14:35:40 +0000 (14:35 +0000)] 
gdb/remote: Restore support for 'S' stop reply packet

With this commit:

  commit 5b6d1e4fa4fc6827c7b3f0e99ff120dfa14d65d2
  Date:   Fri Jan 10 20:06:08 2020 +0000

      Multi-target support

There was a regression in GDB's support for older aspects of the
remote protocol.  Specifically, when a target sends the 'S' stop reply
packet (which doesn't include a thread-id) then GDB has to figure out
which thread actually stopped.

Before the above commit GDB figured this out by using inferior_ptid in
process_stop_reply, which contained the ptid of the current
process/thread.  This would be fine for single threaded
targets (which is the only place using an S packet makes sense), but
in the general case, relying on inferior_ptid for processing a stop is
wrong - there's no reason to believe that what was GDB's current
thread will be the same thread that just stopped in the target.

With the above commit the inferior_ptid now has the value null_ptid
inside process_stop_reply, this can be seen in do_target_wait, where
we call switch_to_inferior_no_thread before calling do_target_wait_1.

The problem this causes can be seen in the new test that runs
gdbserver using the flag --disable-packet=T, and causes GDB to throw
this assertion:

  inferior.c:279: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed.

A similar problem was fixed in this commit:

  commit 3cada74087687907311b52781354ff551e10a0ed
  Date:   Thu Jan 11 00:23:04 2018 +0000

      Fix backwards compatibility with old GDBservers (PR remote/22597)

However, this commit deals with the case where the T packet doesn't
include a thread-id, not the S packet case.  This commit solves the
problem providing a thread-id at the GDB side if the remote target
doesn't provide one.  The thread-id provided comes from
remote_state::general_thread, however, though this does work, I don't
think it is the ideal solution.

The remote_state tracks two threads, the continue_thread and the
general_thread, these are updated when GDB asks the remote target to
switch threads.  The general_thread is set before performing things
like register or memory accesses, and the continue_thread is set
before things like continue or step commands.  Further, the
general_thread is updated after a target stops to reference the thread
that stopped.

The first thing to note from the above description is that we have a
cycle of dependency, when a T packet arrives without a thread-id we
fill in the thread-id from the general_thread data.  The thread-id
from the stop event is then used to set the general_thread.  This in
itself feels a little weird.

The second question is why use the general_thread at all? You'd think
given how they are originally set that the continue thread would be a
better choice.  The problem with this is that the continue_thread, if
the user just does "continue", will be set to the minus_one_ptid, in
the remote protocol this means all threads.  When the stop arrives
with no thread-id and we use continue_thread we end up with a very
similar assertion to before because we now end up trying to lookup a
thread using the minus_one_ptid.  By contrast, once GDB has connected
to a remote target the general_thread will be set to a valid
thread-id, after which, if the target is single threaded, and stop
events arrive without a thread-id, everything works fine.

There is one slight weirdness with the above behaviour though.  When
GDB first connects to the remote target inferior_ptid is null_ptid,
however, upon connecting we query the remote for its threads.  As the
thread information arrives GDB adds the threads to its internal
database, and this process involves setting inferior_ptid to the id of
each new thread in turn.  Once we know about all the threads we wait
for a stop event from the remote target to indicate that GDB is now in
control of the target.

The problem is that after adding the new threads we don't reset
inferior_ptid, and the code path we use to wait for a stop event from
the target also doesn't reset inferior_ptid, so it turns out that
during the initial connection inferior_ptid is not null_ptid.  This is
lucky, because during the initial connection the general_thread
variable _is_ set to null_ptid.

So, during the initial connection, if the first stop event is missing
a thread-id then we "provide" a thead-id from general_thread.  This
turns out to be null_ptid meaning no thread-id is known, and then
during process_stop_reply we fill in the missing thread-id using
inferior_ptid.

This was all discussed on the mailing list here:

  https://sourceware.org/ml/gdb-patches/2020-02/msg01011.html

My proposal for a fix then is:

 1. Move the call to switch_to_inferior_no_thread into
 do_target_wait_1, this means that in all cases where we are waiting
 for an inferior the inferior_ptid will be set to null_ptid.  This is
 good as no wait code should rely on inferior_ptid.

 2. Remove the use of general_thread from the 'T' packet processing.
 The general_thread read here was only ever correct by chance, and we
 shouldn't be using it this way.

 3. Remove use of inferior_ptid from process_stop_event as this is
 wrong, and will always be null_ptid now anyway.

 4. When a stop_event has null_ptid due to a lack of thread-id (either
 from a T packet or an S packet) then pick the first non exited thread
 in the target and use that.  This will be fine for single threaded
 targets.  A multi-thread or multi-inferior aware remote target
 should be using T packets with a thread-id, so we give a warning if
 the target is multi-threaded, and we are still missing a thread-id.

 5. Extend the existing test that covered the T packet with missing
 thread-id to also cover the S packet.

gdb/ChangeLog:

* remote.c (remote_target::remote_parse_stop_reply): Don't use the
general_thread if the stop reply is missing a thread-id.
(remote_target::process_stop_reply): Use the first non-exited
thread if the target didn't pass a thread-id.
* infrun.c (do_target_wait): Move call to
switch_to_inferior_no_thread to ....
(do_target_wait_1): ... here.

gdb/testsuite/ChangeLog:

* gdb.server/stop-reply-no-thread.exp: Add test where T packet is
disabled.

4 years agogdbserver: Add mechanism to prevent sending T stop packets
Andrew Burgess [Fri, 28 Feb 2020 21:33:26 +0000 (21:33 +0000)] 
gdbserver: Add mechanism to prevent sending T stop packets

There is a developer only feature in gdbserver that provides a
command line option --disable-packet that prevents some packets from
being sent, which is used to increase test coverage within GDB.

This commit extends this mechanism to prevent GDBserver from sending
the T stop reply packets, instead limiting GDBserver to only send the
S stop reply packets.

The S stop reply packet is part of the older target control mechanism,
which has design flaws that were worked around with the introduction
of the newer target control mechanism, which uses the T stop reply
packet.

Limiting GDBserver to use S stop packets instead of T stop packets
will, inevitably, mean that GDBserver doesn't function correctly in
many cases involving multiple threads, however, I don't think this is
too important, this is a developer only feature, intended to allow us
to test GDB.

A new test that makes use of this feature will be added in the next
commit.

gdbserver/ChangeLog:

* remote-utils.cc (prepare_resume_reply): Add ability to convert T
reply into an S reply.
* server.cc (disable_packet_T): New global.
(captured_main): Set new global when appropriate.
* server.h (disable_packet_T): Declare.

4 years ago[gdb/testsuite] Add -lbl option in gdb_test_multiple
Tom de Vries [Mon, 2 Mar 2020 13:47:27 +0000 (14:47 +0100)] 
[gdb/testsuite] Add -lbl option in gdb_test_multiple

Add gdb_test_multiple option -lbl, that adds a regexp after the user code that
reads one line, and discards it:
...
           -re "\r\n\[^\r\n\]*(?=\r\n)" {
               exp_continue
           }
...

In order to be able to write:
...
gdb_test_multiple "command" "testname" -lbl {
  ...
}
...
rewrite the promp_regexp argument usage into the similar:
...
gdb_test_multiple "command" "testname" -prompt $prompt_regexp {
  ...
}
...

Build and reg-tested on x86_64-linux.

Tested gdb.base/corefile-buildid.exp with both make targets check and
check-read1.

gdb/testsuite/ChangeLog:

2020-03-02  Pedro Alves  <palves@redhat.com>
      Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gdb_test_multiple): Handle prompt_regexp option using
-prompt prefix, before user_code argument.  Add -lbl option likewise.
(skip_python_tests_prompt, skip_libstdcxx_probe_tests_prompt)
(gdb_is_target_1): Add -prompt prefix and move to before user_code
argument.
* gdb.base/corefile-buildid.exp: Use -lbl option.  Rewrite regexps to
have "\r\n" at start-of-line, instead of at end-of-line.

4 years agoRe: bfd_cleanup for object_p
Alan Modra [Mon, 2 Mar 2020 13:38:42 +0000 (00:08 +1030)] 
Re: bfd_cleanup for object_p

I hate files that you can't compile.

* cisco-core.c (cisco_core_file_p): Return bfd_cleanup.
* hpux-core.c (hpux_core_core_file_p): Update prototype.
* sco5-core.c (sco5_core_file_p): Return bfd_cleanup.
(core_sco5_vec): Correct initialisers.

4 years agoRe: bfd_cleanup for object_p
Alan Modra [Mon, 2 Mar 2020 13:12:08 +0000 (23:42 +1030)] 
Re: bfd_cleanup for object_p

More missing core file support changes.

* aix386-core.c (aix386_core_file_p): Return bfd_cleanup.
* aix5ppc-core.c (xcoff64_core_p): Likewise.
* cisco-core.c (cisco_core_file_validate): Likewise.
* hppabsd-core.c (hppabsd_core_core_file_p): Likewise.
* hpux-core.c (hpux_core_core_file_p): Likewise.
* irix-core.c (irix_core_core_file_p): Likewise.
* lynx-core.c (lynx_core_file_p): Likewise.
* netbsd-core.c (netbsd_core_file_p): Likewise.
* osf-core.c (osf_core_core_file_p): Likewise.
* ptrace-core.c (ptrace_unix_core_file_p): Likewise.
* sco5-core.c (sco5_core_file_p): Likewise.

4 years agogdb: Move defs.h before any system header in debuginfod-support.c
Jon Turney [Sat, 29 Feb 2020 13:33:35 +0000 (13:33 +0000)] 
gdb: Move defs.h before any system header in debuginfod-support.c

* defs.h includes config.h
* config.h may define _GNU_SOURCE
* if _GNU_SOURCE is defined, that must be before including any system
header (see feature_test_macro(7))

This is necessary to ensure that a prototype for mkostemp() is brought
into scope by <stdlib.h> when compiling filestuff.h, on platforms where
_GNU_SOURCE isn't unconditionally defined for C++.

In file included from ../../gdb/../gdbsupport/scoped_fd.h:24,
                 from ../../gdb/debuginfod-support.c:22:
../../gdb/../gdbsupport/filestuff.h: In function ‘int gdb_mkostemp_cloexec(char*, int)’:
../../gdb/../gdbsupport/filestuff.h:59:10: error: ‘mkostemp’ was not declared in this scope; did you mean ‘mkstemp’?

gdb/ChangeLog:

2020-02-29  Jon Turney  <jon.turney@dronecode.org.uk>

* debuginfod-support.c: Include defs.h first.

4 years agoThe procedure to find an unused port for the debuginfod tests is susceptible to a...
Aaron Merey [Mon, 2 Mar 2020 12:46:47 +0000 (12:46 +0000)] 
The procedure to find an unused port for the debuginfod tests is susceptible to a TOCTOU failure.  Change port finding in order to avoid this. Also use 'expect' to interact with the server process since we now use the server's output to determine whether a port is in use.

* binutils/testsuite/binutils-all/debuginfod.exp: Improve port
selection.

4 years agotrad_unix_core_file_p: Return bfd_cleanup
H.J. Lu [Mon, 2 Mar 2020 12:35:23 +0000 (04:35 -0800)] 
trad_unix_core_file_p: Return bfd_cleanup

* trad-core.c (trad_unix_core_file_p): Return bfd_cleanup.

4 years agoImport latest fixes to libiberty from GCC
H.J. Lu [Mon, 2 Mar 2020 11:56:36 +0000 (03:56 -0800)] 
Import latest fixes to libiberty from GCC

lto: Also copy .note.gnu.property section

When generating the separate file with LTO debug sections, we should
also copy .note.gnu.property section.

PR lto/93966
* simple-object.c (handle_lto_debug_sections): Also copy
.note.gnu.property section.

4 years agoRestore readelf's string dump to previous behaviour where newlines were caused line...
Nick Clifton [Mon, 2 Mar 2020 10:02:02 +0000 (10:02 +0000)] 
Restore readelf's string dump to previous behaviour where newlines were caused line breaks.

PR 25543
* readelf.c (dump_section_as_strings): Display new-line characters
as \n and then insert a line break.
* testsuite/binutils-all/pr25543.s: New test.
* testsuite/binutils-all/pr25543.d: Test driver.
* testsuite/binutils-all/readelf.exp: Run the new test.

4 years agobfd_cleanup for object_p
Alan Modra [Mon, 2 Mar 2020 04:51:09 +0000 (15:21 +1030)] 
bfd_cleanup for object_p

The object_p (and archive_p, core_file_p) functions are not supposed
to have any target specific malloc'd memory attached to the bfd on
their return.  This should be obvious on a failure return, but it's
also true for a successful return.  The reason is that even though the
object_p recognises the file, that particular target may not be used
and thus the bfd won't be closed calling close_and_cleanup for the
target that allocated the memory.

It turns out that the object_p bfd_target* return value isn't needed.
In all cases except ld/plugin.c the target is abfd->xvec and with
ld/plugin.c the target isn't used.  So this patch returns a cleanup
function from object_p instead, called in bfd_check_format_matches to
tidy the bfd before trying a different target match.  The only cleanup
that does anything at this stage is the alpha-vms one.

bfd/
* targets.c (bfd_cleanup): New typedef.
(struct bfd <_bfd_check_format>): Return a bfd_cleanup.
* libbfd-in.h (_bfd_no_cleanup): Define.
* format.c (bfd_reinit): Add cleanup parameter, call it.
(bfd_check_format_matches): Set cleanup from _bfd_check_format
call and pass to bfd_reinit.  Delete temp, use abfd->xvec instead.
* aout-target.h (callback, object_p): Return bfd_cleanup.
* aout-tic30.c (tic30_aout_callback, tic30_aout_object_p): Likewise.
* archive.c (bfd_generic_archive_p): Likewise.
* binary.c (binary_object_p): Likewise.
* coff-alpha.c (alpha_ecoff_object_p): Likewise.
* coff-ia64.c (ia64coff_object_p): Likewise.
* coff-rs6000.c (_bfd_xcoff_archive_p, rs6000coff_core_p): Likewise.
* coff-sh.c (coff_small_object_p): Likewise.
* coff-stgo32.c (go32_check_format): Likewise.
* coff64-rs6000.c (xcoff64_archive_p, rs6000coff_core_p),
(xcoff64_core_p): Likewise.
* coffgen.c (coff_real_object_p, coff_object_p): Likewise.
* elf-bfd.h (bfd_elf32_object_p, bfd_elf32_core_file_p),
(bfd_elf64_object_p, bfd_elf64_core_file_p): Likewise.
* elfcode.h (elf_object_p): Likewise.
* elfcore.h (elf_core_file_p): Likewise.
* i386msdos.c (msdos_object_p): Likewise.
* ihex.c (ihex_object_p): Likewise.
* libaout.h (some_aout_object_p): Likewise.
* libbfd-in.h (bfd_generic_archive_p, _bfd_dummy_target),
(_bfd_vms_lib_alpha_archive_p, _bfd_vms_lib_ia64_archive_p): Likewise.
* libbfd.c (_bfd_dummy_target): Likewise.
* libcoff-in.h (coff_object_p): Likewise.
* mach-o-aarch64.c (bfd_mach_o_arm64_object_p),
(bfd_mach_o_arm64_core_p): Likewise.
* mach-o-arm.c (bfd_mach_o_arm_object_p),
(bfd_mach_o_arm_core_p): Likewise.
* mach-o-i386.c (bfd_mach_o_i386_object_p),
(bfd_mach_o_i386_core_p): Likewise.
* mach-o-x86-64.c (bfd_mach_o_x86_64_object_p),
(bfd_mach_o_x86_64_core_p): Likewise.
* mach-o.c (bfd_mach_o_header_p, bfd_mach_o_gen_object_p),
(bfd_mach_o_gen_core_p, bfd_mach_o_fat_archive_p): Likewise.
* mach-o.h (bfd_mach_o_object_p, bfd_mach_o_core_p),
(bfd_mach_o_fat_archive_p, bfd_mach_o_header_p): Likewise.
* mmo.c (mmo_object_p): Likewise.
* pef.c (bfd_pef_object_p, bfd_pef_xlib_object_p): Likewise.
* peicode.h (coff_real_object_p, pe_ILF_object_p),
(pe_bfd_object_p): Likewise.
* plugin.c (ld_plugin_object_p, bfd_plugin_object_p): Likewise.
* ppcboot.c (ppcboot_object_p): Likewise.
* rs6000-core.c (rs6000coff_core_p): Likewise.
* som.c (som_object_setup, som_object_p): Likewise.
* srec.c (srec_object_p, symbolsrec_object_p): Likewise.
* tekhex.c (tekhex_object_p): Likewise.
* vms-alpha.c (alpha_vms_object_p): Likewise.
* vms-lib.c (_bfd_vms_lib_archive_p, _bfd_vms_lib_alpha_archive_p),
(_bfd_vms_lib_ia64_archive_p, _bfd_vms_lib_txt_archive_p): Likewise.
* wasm-module.c (wasm_object_p): Likewise.
* xsym.c (bfd_sym_object_p): Likewise.
* xsym.h (bfd_sym_object_p): Likewise.
* aoutx.h (some_aout_object_p): Likewise, and callback parameter
return type.
* pdp11.c (some_aout_object_p): Likewise.
* plugin.c (register_ld_plugin_object_p): Update object_p
parameter type.
* plugin.h (register_ld_plugin_object_p): Likewise.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* libcoff.h: Regenerate.
ld/
* plugin.c (plugin_object_p): Return a bfd_cleanup.
(plugin_cleanup): New function.

4 years agoplugin: Copy the no_export field to the IR dummy object
H.J. Lu [Mon, 2 Mar 2020 01:07:12 +0000 (17:07 -0800)] 
plugin: Copy the no_export field to the IR dummy object

Copy the no_export field to the IR dummy object when claiming an IR
object.

PR ld/25618
* plugin.c (plugin_object_p): Copy the no_export field to the IR
dummy object.
* testsuite/ld-plugin/lto.exp (lto_link_elf_tests): Add
PR ld/25618 tests.
* testsuite/ld-plugin/pr25618.d: New file.
* testsuite/ld-plugin/pr25618a.cc: Likewise.
* testsuite/ld-plugin/pr25618a.h: Likewise.
* testsuite/ld-plugin/pr25618b.cc: Likewise.
* testsuite/ld-plugin/pr25618b.h: Likewise.

4 years agomiscellaneous SEC_SMALL_DATA
Alan Modra [Sun, 1 Mar 2020 23:47:18 +0000 (10:17 +1030)] 
miscellaneous SEC_SMALL_DATA

This patch arranges for symbols defined in .sdata and .sbss to be
reported by nm with 'g' and 's' flags, for coff targets that support
.sdata and .sbss.

The assembler changes regarding SEC_SMALL_DATA are really just
documentation.  As far as I'm aware, this won't change any assembler
output.

bfd/
* coff-alpha.c (alpha_ecoff_le_vec): Add SEC_SMALL_DATA to
applicable section flags.
* coff-mips.c (mips_ecoff_le_vec, mips_ecoff_be_vec): Likewise.
(mips_ecoff_bele_vec): Likewise.
* coffcode.h (sec_to_styp_flags): Set SEC_SMALL_DATA for .sdata
and .sbss sections.
* ecoff.c (_bfd_ecoff_new_section_hook): Likewise.
(_bfd_ecoff_styp_to_sec_flags): Likewise.
gas/
* config/tc-m32r.c (md_begin): Set SEC_SMALL_DATA on .scommon section.
* config/tc-mips.c (s_change_sec): Set SEC_SMALL_DATA for .sdata
and .sbss sections.
* config/tc-score.c: Delete !BFD_ASSEMBLER code throughout.
(s3_s_change_sec): Set SEC_SMALL_DATA for .sbss section.
(s3_s_score_lcomm): Likewise.
* config/tc-score7.c: Similarly.
* read.c (bss_alloc): Set SEC_SMALL_DATA for .sbss section.

4 years agoELF SEC_SMALL_DATA
Alan Modra [Sun, 1 Mar 2020 23:46:39 +0000 (10:16 +1030)] 
ELF SEC_SMALL_DATA

For those ELF targets that have .sdata or .sbss sections, or similar
sections, arrange to mark the sections with the SEC_SMALL_DATA flag.
This fixes regressions in nm symbol type caused by removing .sdata
and .sbss from coff_section_type with commit 49d9fd42ac.

* elf32-m32r.c (m32r_elf_section_flags): New function.
(elf_backend_section_flags): Define.
* elf32-nds32.c (nds32_elf_section_flags): New function.
(elf_backend_section_flags): Define.
* elf32-ppc.c (ppc_elf_section_from_shdr): Set SEC_SMALL_DATA for
.sbss and .sdata sections.
* elf32-v850.c (v850_elf_section_from_shdr): Set SEC_SMALL_DATA
for SHF_V850_GPREL sections.
* elf64-alpha.c (elf64_alpha_section_from_shdr): Delete outdated
FIXME.
* elf64-hppa.c (elf64_hppa_section_from_shdr): Set SEC_SMALL_DATA
for SHF_PARISC_SHORT sections.
* elf64-ppc.c (ppc64_elf_section_flags): New function.
(elf_backend_section_flags): Define.
* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Set SEC_SMALL_DATA
for SHF_MIPS_GPREL sections.  Delete FIXME.

4 years agoelf_backend_section_flags and _bfd_elf_init_private_section_data
Alan Modra [Sun, 1 Mar 2020 23:46:02 +0000 (10:16 +1030)] 
elf_backend_section_flags and _bfd_elf_init_private_section_data

I was looking at elf_backend_section_flags as a means of setting
SEC_SMALL_DATA for .sdata, .sbss and the like, and condidered adding
an asection* parameter to access the section name easily before
realising that hdr->bfd_section of course makes the section
available.  So no new parameter needed.  In fact the flagword*
parameter isn't needed either, so out it goes.

The patch also tidies some horrible code in _bfd_elf_new_section_hook
that can change whether known ABI sections have sh_type and sh_flags
set up depending on which of the bfd_make_section functions is used.
(Some of those set section flags before _bfd_elf_new_section_hook is
called, others leave the flags zero.)  The function also had some
hacks for .init_array and .fini_array to affect how
_bfd_elf_init_private_section_data behaved for those sections.  It's
cleaner to do that in _bfd_elf_init_private_section_data.  So that all
goes and we now init sh_type and sh_flags for all known ABI sections
in _bfd_elf_new_section_hook.  _bfd_elf_init_private_section_data is
changed to suit, and now doesn't just single out SHT_INIT_ARRAY and
SHT_FINI_ARRAY but rather any of the special section types.

The _bfd_elf_new_section_hook change resulting in
+FAIL: ld-aarch64/erratum835769-843419
exposing some errors in the aarch64 backend.  elfNN_aarch64_size_stubs
should not be looking at linker created sections in the stub bfd.  Nor
should code like "symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr" be
run without first checking that input_bfd is ELF.

* elf-bfd.h (elf_backend_section_flags): Remove flagword* param.
* elf.c (_bfd_elf_make_section_from_shdr): Set section flags before
calling elf_backend_section_flags with adjusted params.  Use
newsect->flags past that point.
(_bfd_elf_new_section_hook): Always set sh_type and sh_flags for
special sections.
(_bfd_elf_init_private_section_data): Allow normal sh_type sections
to have their type overridden, and all sh_flags but processor and
os specific.
* elf32-arm.c (elf32_arm_section_flags): Adjust for changed params.
* elf32-mep.c (mep_elf_section_flags): Likewise.
* elf32-nios2.c (nios2_elf32_section_flags): Likewise.
* elf64-alpha.c (elf64_alpha_section_flags): Likewise.
* elf64-ia64-vms.c (elf64_ia64_section_flags): Likewise.
* elfnn-ia64.c (elfNN_ia64_section_flags): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_size_stubs): Exclude the linker
stub BFD and non-aarch64 input files when scanning for stubs.

4 years agoalpha-coff: large memory allocation
Alan Modra [Sun, 1 Mar 2020 23:45:36 +0000 (10:15 +1030)] 
alpha-coff: large memory allocation

* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Provide an upper
limit to decompressed element size.

4 years agoalpha-vms: prevent endless recursion
Alan Modra [Sun, 1 Mar 2020 23:40:55 +0000 (10:10 +1030)] 
alpha-vms: prevent endless recursion

* vms-lib.c (vms_traverse_index): Add recur_count param and
update calls.  Fail on excessive recursion.

4 years agoalpha-vms: error paths not freeing memory and malloc result checks
Alan Modra [Sun, 1 Mar 2020 23:44:57 +0000 (10:14 +1030)] 
alpha-vms: error paths not freeing memory and malloc result checks

When realloc fails it doesn't free the old memory.  In BFD we usually
will exit with an error on a realloc fail, so want to tidy up memory
on error paths.  That's done by bfd_realloc_or_free.

* vms-alpha.c (vms_get_remaining_object_record): Use
bfd_realloc_or_free rather than bfd_realloc.
(add_symbol_entry, vector_grow1, alpha_vms_slurp_relocs): Likewise.
(dst_define_location, parse_module): Likewise, and check realloc
return status before using memory.  Return status from function
adjusting all callers.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 2 Mar 2020 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 1 Mar 2020 00:01:11 +0000 (00:01 +0000)] 
Automatic date update in version.in

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 29 Feb 2020 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoUpdate libinproctrace.so path in lib/trace-support.exp
Simon Marchi [Fri, 28 Feb 2020 23:58:17 +0000 (18:58 -0500)] 
Update libinproctrace.so path in lib/trace-support.exp

Following the move to gdbserver to the top-level, the path to
libinproctrace.so in testsuite/lib/trace-support.exp is no longer valid.
This can be observed by running:

    $ make check TESTS="gdb.trace/ftrace.exp" RUNTESTFLAGS="--target_board=native-gdbserver"
    ...
    ERROR: error copying "/home/smarchi/build/binutils-gdb/gdb/testsuite/../gdbserver/libinproctrace.so": no such file or directory

Adjust the path to libinproctrace.so by adding a "..".  With this patch,
the test mentioned above runs fine.

gdb/testsuite/ChangeLog:

* lib/trace-support.exp (get_in_proc_agent): Adjust path to
libinproctrace.so.

4 years agoFix comment for 'gdb_dlopen'
Sergio Durigan Junior [Tue, 25 Feb 2020 20:50:16 +0000 (15:50 -0500)] 
Fix comment for 'gdb_dlopen'

The 'gdb_dlopen' function doesn't return NULL if the shlib load
fails; it actually throws an error.  This patch updates the comment
to reflect this.

gdbsupport/ChangeLog:
2020-02-28  Sergio Durigan Junior  <sergiodj@redhat.com>

* gdb-dlfcn.h (gdb_dlopen): Update comment.

4 years agoFix SVE-related failure in gdb.arch/aarch64-fp.exp
Luis Machado [Wed, 26 Feb 2020 13:37:28 +0000 (10:37 -0300)] 
Fix SVE-related failure in gdb.arch/aarch64-fp.exp

The gdb.arch/aarch64-fp.exp test assumes it is dealing with a regular SIMD
target that exposes the V registers as raw registers.  SVE-enabled targets
turn the V registers into pseudo-registers.

That is all fine, but the testcase uses the "info registers" command, which
prints pseudo-register's contents twice. One for the hex format and another
for the natural format of the type.

(gdb) info registers v0
v0             {d = {f = {0x0, 0x0}, u = {0x1716151413121110, 0x1f1e1d1c1b1a1918}, s = {0x1716151413121110, 0x1f1e1d1c1b1a1918}}, s = {f = {0x0, 0x0, 0x0, 0x0}, u = {0x13121110, 0x17161514, 0x1b1a1918, 0x1f1e1d1c}, s = {0x13121110, 0x17161514, 0x1b1a1918, 0x1f1e1d1c}}, h = {f = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u = {0x1110, 0x1312, 0x1514, 0x1716, 0x1918, 0x1b1a, 0x1d1c, 0x1f1e}, s = {0x1110, 0x1312, 0x1514, 0x1716, 0x1918, 0x1b1a, 0x1d1c, 0x1f1e}}, b = {u = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}, s = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}}, q = {u = {0x1f1e1d1c1b1a19181716151413121110}, s = {0x1f1e1d1c1b1a19181716151413121110}}} {d = {f = {1.846323925681849e-197, 8.5677456166123577e-159}, u = {16635402883234572962242261671028070680}, s = {16635402883234572962242261671028070680}}, s = {f = {1.84362032e-27, 4.84942184e-25, 1.27466897e-22, 3.34818801e-20}, u = {319951120387323156454695192522067228}, s = {319951120387323156454695192522067228}}, h = {f = {0.00061798, 0.00086308, 0.0012398, 0.00173, 0.0024872, 0.0034676, 0.0049896, 0.0069504}, u = {4368, 4882, 5396, 5910, 6424, 6938, 7452, 7966}, s = {4368, 4882, 5396, 5910, 6424, 6938, 7452, 7966}}, b = {u = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}, s = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}}, q = {u = {41362427191743139026751447860679676176}, s = {41362427191743139026751447860679676176}}}

(gdb) p/x $v0
$1 = {d = {f = {0x0, 0x0}, u = {0x1716151413121110, 0x1f1e1d1c1b1a1918}, s = {0x1716151413121110, 0x1f1e1d1c1b1a1918}}, s = {f = {0x0, 0x0, 0x0, 0x0}, u = {0x13121110, 0x17161514, 0x1b1a1918, 0x1f1e1d1c}, s = {0x13121110, 0x17161514, 0x1b1a1918, 0x1f1e1d1c}}, h = {f = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u = {0x1110, 0x1312, 0x1514, 0x1716, 0x1918, 0x1b1a, 0x1d1c, 0x1f1e}, s = {0x1110, 0x1312, 0x1514, 0x1716, 0x1918, 0x1b1a, 0x1d1c, 0x1f1e}}, b = {u = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}, s = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}}, q = {u = {0x1f1e1d1c1b1a19181716151413121110}, s = {0x1f1e1d1c1b1a19181716151413121110}}}

Since the testcase is not expecting that, we run into a couple failures:

FAIL: gdb.arch/aarch64-fp.exp: check register v0 value
FAIL: gdb.arch/aarch64-fp.exp: check register v1 value

The following patch switches to using "p/x" for printing register values, which
prints the values once with the hex format, instead of twice.

gdb/testsuite/ChangeLog

2020-02-28  Luis Machado  <luis.machado@linaro.org>

* gdb.arch/aarch64-fp.exp: Switch from "info registers" command
to "p/x".

4 years agoFix gdb.arch/aarch64-dbreg-contents.exp build failures
Luis Machado [Tue, 25 Feb 2020 13:09:19 +0000 (10:09 -0300)] 
Fix gdb.arch/aarch64-dbreg-contents.exp build failures

I ran into the following failures when running tests under QEMU:

--

gdb compile failed, binutils-gdb/gdb/testsuite/gdb.arch/aarch64-dbreg-contents.c: In function 'set_watchpoint':
binutils-gdb/gdb/testsuite/gdb.arch/aarch64-dbreg-contents.c:41:29: error: storage size of 'dreg_state' isn't known
   struct user_hwdebug_state dreg_state;
                             ^~~~~~~~~~
In file included from /usr/include/aarch64-linux-gnu/bits/types/struct_iovec.h:23:0,
                 from /usr/include/aarch64-linux-gnu/sys/uio.h:23,
                 from binutils-gdb/gdb/testsuite/gdb.arch/aarch64-dbreg-contents.c:17:
binutils-gdb/gdb/testsuite/gdb.arch/aarch64-dbreg-contents.c:69:18: error: invalid use of undefined type 'struct user_hwdebug_state'
   iov.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs)
                  ^
binutils-gdb/gdb/testsuite/gdb.arch/aarch64-dbreg-contents.c:74:5: warning: implicit declaration of function 'error'; did you mean 'errno'? [-Wimplicit-function-declaration]
     error (1, errno, "PTRACE_SETREGSET: NT_ARM_HW_WATCH");
     ^~~~~
     errno
binutils-gdb/gdb/testsuite/gdb.arch/aarch64-dbreg-contents.c: In function 'main':
binutils-gdb/gdb/testsuite/gdb.arch/aarch64-dbreg-contents.c:87:3: warning: implicit declaration of function 'atexit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   atexit (cleanup);
   ^~~~~~
   _Exit
binutils-gdb/gdb/testsuite/gdb.arch/aarch64-dbreg-contents.c:89:11: warning: implicit declaration of function 'fork' [-Wimplicit-function-declaration]
   child = fork ();

           ^~~~

--

The following patch fixes those by adding the necessary include files.

With that said, the test doesn't pass at present. I'll have to investigate it
a bit more.

gdb/testsuite/ChangeLog:

2020-02-28  Luis Machado  <luis.machado@linaro.org>

* gdb.arch/aarch64-dbreg-contents.c: Include stdlib.h, unistd,
asm/ptrace.h and error.h.

4 years ago[gdb] Don't set initial language using previous language
Tom de Vries [Fri, 28 Feb 2020 15:14:53 +0000 (16:14 +0100)] 
[gdb] Don't set initial language using previous language

When language is set to auto, part of loading an executable is to update the
language accordingly.  This is implemented by set_initial_language.

In case of a c++ executable without DW_AT_main_subprogram,
set_initial_language finds "main" in the minimal symbols, and does a lookup of
"main" in the symbol tables to determine the language of the symbol, and uses
that as initial language.

The symbol lookup is done using lookup_symbol which is a wrapper around
lookup_symbol_in_language, using the current language.

So, consider two c++ executables a.out and b.out, which we'll load one after
another.  If we track the resulting lookup_symbol_in_language calls:
...
$ gdb -batch \
    -ex "b lookup_symbol_in_language" \
    -ex r -ex c -ex c \
    --args gdb
...
we find that indeed lookup_symbol_in_language is called once using language_c, and
once using language_c_plus:
...
(gdb) file a.out
Reading symbols from a.out...

Breakpoint 1, lookup_symbol_in_language (name=0x5555568c2050 "main", \
  block=0x0, domain=VAR_DOMAIN, lang=language_c, is_a_field_of_this=0x0) \
  at ../../gdb/symtab.c:1905
1905    {
(gdb) file b.out
Load new symbol table from "b.out"? (y or n) y
Reading symbols from b.out...

Breakpoint 1, lookup_symbol_in_language (name=0x5555568c2030 "main", \
  block=0x0, domain=VAR_DOMAIN, lang=language_cplus, is_a_field_of_this=0x0) \
  at ../../gdb/symtab.c:1905
1905    {
(gdb)
...

It seems like a bad idea to have the previous language play a role
in determining the executable language.

Fix this by using lookup_symbol_in_language in set_initial_language with the
default language c as argument.

Tested on x86_64-linux.

gdb/ChangeLog:

2020-02-28  Tom de Vries  <tdevries@suse.de>

* symfile.c (set_initial_language): Use default language for lookup.

4 years agoPass correct die_reader_specs in cutu_reader::init_tu_and_read_dwo_dies
Simon Marchi [Fri, 28 Feb 2020 15:07:46 +0000 (10:07 -0500)] 
Pass correct die_reader_specs in cutu_reader::init_tu_and_read_dwo_dies

Running anything with the fission.exp board fails since commit
c0ab21c22bb ("Replace init_cutu_and_read_dies with a class").
GDB crashes while reading the DWARF info.  cu is NULL in
read_signatured_type:

    Thread 1 "gdb" received signal SIGSEGV, Segmentation fault.
    0x000055555780663e in read_signatured_type
    sig_type=0x6210000c3600) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22782
    22782         gdb_assert (cu->die_hash == NULL);
    (top-gdb) bt
    #0  0x000055555780663e in read_signatured_type (sig_type=0x6210000c3600) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22782
    #1  0x00005555578062dd in load_full_type_unit (per_cu=0x6210000c3600) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22758
    #2  0x00005555577c5fb7 in queue_and_load_dwo_tu (slot=0x60600007fc00, info=0x6210000c34e0) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:12674
    #3  0x0000555559934232 in htab_traverse_noresize (htab=0x60b000063670, callback=0x5555577c5e61 <queue_and_load_dwo_tu(void**, void*)>, info=0x6210000c34e0)
        at /home/simark/src/binutils-gdb/libiberty/hashtab.c:775
    #4  0x00005555577c6252 in queue_and_load_all_dwo_tus (per_cu=0x6210000c34e0) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:12701
    #5  0x000055555777ebd8 in dw2_do_instantiate_symtab (per_cu=0x6210000c34e0, skip_partial=false) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:2371
    #6  0x000055555777eea2 in dw2_instantiate_symtab (per_cu=0x6210000c34e0, skip_partial=false) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:2395
    #7  0x0000555557786ab6 in dw2_lookup_symbol (objfile=0x614000007240, block_index=GLOBAL_BLOCK, name=0x602000025310 "main", domain=VAR_DOMAIN)
        at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:3539

After creating the reader object, the reader.cu field should not be
NULL.  By checking the commit previous to the faulty one mentioned
above, I noticed that the cu field is normally set by
init_cu_die_reader, called from read_cutu_die_from_dwo, itself called
from cutu_reader::init_tu_and_read_dwo_dies, itself called from
cutu_reader's constructor.

However, cutu_reader::init_tu_and_read_dwo_dies calls
read_cutu_die_from_dwo, passing a pointer to a local `die_reader_specs`
variable.  So it's the `cu` field of that object that gets set.
cutu_reader itself is a `die_reader_specs` (it inherits from it), and
the intention was most likely to pass `this` to read_cutu_die_from_dwo.
This way, the fields of the cutu_reader object, which
read_signatured_type will use, are set.

With this, I am able to use:

  make check RUNTESTFLAGS='--target_board=fission'

and it looks much better.  There are still some failures to be
investigated, but that's the usual state of the testsuite.

gdb/ChangeLog:

* dwarf2/read.c (cutu_reader::init_tu_and_read_dwo_dies): Remove
reader variable, pass `this` to read_cutu_die_from_dwo.

4 years ago[gdb/testsuite] Fix psymtab expansion postponement in c-linkage-name.exp
Tom de Vries [Fri, 28 Feb 2020 15:05:50 +0000 (16:05 +0100)] 
[gdb/testsuite] Fix psymtab expansion postponement in c-linkage-name.exp

The test-case gdb.base/c-linkage-name.exp starts with the following test:
...
gdb_test "print symada__cS" \
         " = {a = 100829103}" \
         "print symada__cS before partial symtab expansion"
...

However, printing the state of the partial symtabs using maint info psymtabs
shows that in fact the symtab has already been expanded:
...
  { psymtab c-linkage-name.c ((struct partial_symtab *) 0x1e27b40)^M
    readin yes^M
...

This is due to set_initial_language, which looks up the main symbol, which
expands the psymtab containing main.

Fix this by moving all but main into a separate source file c-linkage-name-2.c.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-02-28  Tom de Vries  <tdevries@suse.de>

* gdb.base/c-linkage-name.c (main): Call do_something_other_cu.
(struct wrapper, do_something, mundane/symada__cS): Move ...
* gdb.base/c-linkage-name-2.c: ... here.  New source file.
* gdb.base/c-linkage-name.exp: Add verification of psymtab expansion.
Update "print symada__cS before partial symtab expansion" regexp.
Update breakpoint location.  Flush symbol cache after expansion.

4 years agoHarden gdb.arch/aarch64-pauth.exp and fix a failure
Luis Machado [Fri, 21 Feb 2020 20:58:48 +0000 (17:58 -0300)] 
Harden gdb.arch/aarch64-pauth.exp and fix a failure

When running this testcase against a QEMU with PAC support, i noticed we
were failing to recognize the additional [PAC] that is emitted in the
backtrace, resulting in this failure:

FAIL: gdb.arch/aarch64-pauth.exp: backtrace

I've made the test use multi_line to make the pattern more clear.

Tested against aarch64-linux-gnu with and without PAC support.

gdb/testsuite/ChangeLog:

2020-02-28  Luis Machado  <luis.machado@linaro.org>

* gdb.arch/aarch64-pauth.exp: Recognize optional PAC output.

4 years agoMIPS/fix_loongson3_llsc: fix when target has multi labels
YunQiang Su [Fri, 28 Feb 2020 07:58:13 +0000 (15:58 +0800)] 
MIPS/fix_loongson3_llsc: fix when target has multi labels

When there is multi-labels on the same insn, the current code
will take care about the last one. it may cause that no sync
is added at the target.

Here we scan all labels with same value of
   S_GET_VALUE(label_list->label)
by label_list->next.

2020-02-28  YunQiang Su  <syq@debian.org>

    PR gas/25539
    * config/tc-mips.c (fix_loongson3_llsc): Compare label value
    to handle multi-labels.
    (has_label_name): New.

4 years agoalpha-vms: memory leak
Alan Modra [Fri, 28 Feb 2020 02:32:42 +0000 (13:02 +1030)] 
alpha-vms: memory leak

* vms-lib.c (_bfd_vms_lib_archive_p): Free memory on error paths.

4 years agoalpha-vms: large memory allocation
Alan Modra [Fri, 28 Feb 2020 02:05:44 +0000 (12:35 +1030)] 
alpha-vms: large memory allocation

This patch simplifies reading of image headers.  It's really not worth
trying to avoid re-reading a 12 byte buffer and then read in
VMS_BLOCK_SIZE chunks, better just to throw the buffer away and use
_bfd_malloc_and_read which does checks against file size.

* vms-alpha.c (alpha_vms_object_p): Use _bfd_malloc_and_read.
Remove duplicate undersize check.

4 years agogdb: Check for nullptr when computing srcpath
Aaron Merey [Fri, 28 Feb 2020 00:07:01 +0000 (19:07 -0500)] 
gdb: Check for nullptr when computing srcpath

This fixes a regression caused by commit 0d79cdc494d5:

  $ make check TESTS="gdb.dwarf2/dw2-ranges-base.exp"
  [...]
  ERROR: GDB process no longer exists

This error is caused by an abort during the computation of srcpath
when SYMTAB_DIRNAME (s) == NULL.

Computing srcpath only when SYMTAB_DIRNAME (s) is not NULL fixes this
error. Also change the condition for calling debuginfod_source_query
to include whether srcpath could be computed.

gdb/ChangeLog:

2020-02-27  Aaron Merey  <amerey@redhat.com>

        * source.c (open_source_file): Check for nullptr when computing
        srcpath.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 28 Feb 2020 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoRemove field_info::nfields member
Tom Tromey [Thu, 27 Feb 2020 21:05:49 +0000 (14:05 -0700)] 
Remove field_info::nfields member

I noticed that there's no real reason to have field_info::nfields in
the DWARF reader.  It simply mirrors information that is already
available.  This patch removes it, in favor of a convenience method.

gdb/ChangeLog
2020-02-27  Tom Tromey  <tromey@adacore.com>

* dwarf2/read.c (struct field_info) <nfields>: Now a method, not a
member.
(dwarf2_add_field): Don't update nfields.
(dwarf2_attach_fields_to_type, process_structure_scope): Update.

4 years agommix-mmo set SEC_DATA for .data section
Alan Modra [Thu, 27 Feb 2020 05:56:19 +0000 (16:26 +1030)] 
mmix-mmo set SEC_DATA for .data section

With the bfd_decode_symclass change, ld SIZEOF test fails due to
data_end being reported as type '?'.

bfd/
PR 24511
* mmo.c (mmo_scan): Set SEC_DATA for .data.
ld/
PR 24511
* testsuite/ld-mmix/b-fixo2.d: Adjust for .data change.
* testsuite/ld-mmix/sec-2.d: Likewise.
* testsuite/ld-mmix/sec-3.d: Likewise.
* testsuite/ld-mmix/sec-4.d: Likewise.
* testsuite/ld-mmix/spec802.d: Likewise.
* testsuite/ld-mmix/spec803.d: Likewise.
* testsuite/ld-mmix/spec804.d: Likewise.
* testsuite/ld-mmix/spec805.d: Likewise.
* testsuite/ld-mmix/spec806.d: Likewise.
* testsuite/ld-mmix/spec807.d: Likewise.
* testsuite/ld-mmix/spec808.d: Likewise.

4 years ago.idata symbols should be reported with i or I flag by nm
Alan Modra [Thu, 27 Feb 2020 03:53:34 +0000 (14:23 +1030)] 
.idata symbols should be reported with i or I flag by nm

PR 24511
* syms.c (stt): Trim off all but 'e', 'i' and 'p' entries.
(coff_section_type): Adjust comment.
(decode_section_type): Likewise.  Call coff_section_type before
decode_section_type.
(bfd_decode_symclass): Use 'c' for common sections other than
the standard one.

4 years agogdb: Use std::abs instead of abs on LONGEST types
Andrew Burgess [Thu, 27 Feb 2020 16:42:17 +0000 (16:42 +0000)] 
gdb: Use std::abs instead of abs on LONGEST types

Use std::abs so that we get the C++ overloaded version that matches
the argument type instead of the C abs function which is only for int
arguments.

There should be no user visible change after this commit.

gdb/ChangeLog:

* gdbtypes.c (create_array_type_with_stride): Use std::abs not
abs.

4 years agoFix an illegal memory access by readelf when displaying the contents of a corrupt...
Nick Clifton [Thu, 27 Feb 2020 16:28:25 +0000 (16:28 +0000)] 
Fix an illegal memory access by readelf when displaying the contents of a corrupt IA64 binary.

PR 25526
* readelf.c (process_ia64_vms_dynamic_relocs): Check to see if
get_data is unable to load the string table.

4 years ago[gdb/testsuite] Remove unused globals
Tom de Vries [Thu, 27 Feb 2020 13:27:09 +0000 (14:27 +0100)] 
[gdb/testsuite] Remove unused globals

Remove unused global variable declarations.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-02-27  Tom de Vries  <tdevries@suse.de>

* config/sid.exp: Remove unused globals.
* gdb.base/attach.exp: Same.
* gdb.base/catch-load.exp: Same.
* gdb.base/dbx.exp: Same.
* lib/gdb.exp: Same.
* lib/mi-support.exp: Same.
* lib/prompt.exp: Same.

4 years ago[gdb/testsuite] Fix spawn in tuiterm.exp
Tom de Vries [Thu, 27 Feb 2020 09:16:00 +0000 (10:16 +0100)] 
[gdb/testsuite] Fix spawn in tuiterm.exp

When running gdb.stabs/weird.exp by itself it passes, but if we run a gdb.tui
test before it, we get:
...
$ make check RUNTESTFLAGS="gdb.stabs/weird.exp gdb.tui/basic.exp"
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.tui/basic.exp ...
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.stabs/weird.exp ...
ERROR: Couldn't make test case. -1 {spawn failed}
...

In more detail, using -v:
...
Executing on build: sed  -f aout.sed weird.def weird.s (timeout = 300)
builtin_spawn [open ...]^M
pid is 19060 19061 -19060 -19061
spawn -open file10 failed, 1 can't read "spawn_out(slave,name)": \
  no such variable, can't read "spawn_out(slave,name)": no such variable
    while executing
"set gdb_spawn_name $spawn_out(slave,name)"
    (procedure "spawn" line 5)
    invoked from within
"spawn -ignore SIGHUP -leaveopen file10"
    invoked from within
"catch "spawn -ignore SIGHUP -leaveopen $id" result2"
ERROR: Couldn't make test case. -1 {spawn failed}
...

When running the gdb.tui test, spawn gets renamed to a local version from
lib/tuiterm.exp.  The local version calls expect's spawn, and then makes the
local spawn_out(slave,name) variable accessible in the global variable
gdb_spawn_name.

However, the weird.exp test-case uses remote_exec build, which ends up using
local_exec, which given that there's input/output redirection uses open:
...
    set result [catch {open "| ${commandline} $inp |& tee $outpf" RDONLY} id]
...
followed by spawn using the -leaveopen option:
...
    set result [catch "spawn -ignore SIGHUP -leaveopen $id" result2]
...
which apparently has the effect that spawn_out(slave,name) is not set.

Fix this in the lib/tuiterm.exp local spawn proc by detecting the case that
spawn_out(slave,name) is not set, and handling it accordingly.

Tested gdb.stabs/weird.exp and gdb.tui/*.exp on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-02-27  Tom de Vries  <tdevries@suse.de>

* lib/tuiterm.exp (spawn): Handle case that spawn_out(slave,name) is
not set.

4 years ago_bfd_xcoff_read_ar_hdr tidy
Alan Modra [Thu, 27 Feb 2020 03:41:35 +0000 (14:11 +1030)] 
_bfd_xcoff_read_ar_hdr tidy

* coff-rs6000.c (_bfd_xcoff_read_ar_hdr): Put all data in one
malloc'd block.

4 years agobfd_stat_arch_elt buffer overflow
Alan Modra [Thu, 27 Feb 2020 03:20:21 +0000 (13:50 +1030)] 
bfd_stat_arch_elt buffer overflow

If you manage to put an xcoff object file into a non-xcoff archive
(created by first putting a non-xcoff object file into it), and have
xcoff support compiled into libbfd, then objdump -x on the archive
can segfault.  The problem is that _bfd_xcoff_stat_arch_elt expects
abfd->arelt_data->arch_header to be one of the xcoff variants, but
arelt_data is generated depending on the archive format, *not* the
element format.

* bfd.c (bfd_stat_arch_elt): Use vector of containing archive,
if file is an archive element.
* bfd-in2.h: Regenerate.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 27 Feb 2020 00:00:26 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoSpecialize partial_symtab for DWARF include files
Tom Tromey [Wed, 26 Feb 2020 22:41:07 +0000 (15:41 -0700)] 
Specialize partial_symtab for DWARF include files

Include files are represented by a partial symtab, but don't expand to
anything.  From dwarf2_psymtab::expand_psymtab:

  if (per_cu == NULL)
    {
      /* It's an include file, no symbols to read for it.
         Everything is in the parent symtab.  */
      readin = true;
      return;
    }

This patch introduces a new specialization of partial_symtab to handle
this case.  In addition to being slightly smaller, I believe an
include file is the only situation where a DWARF psymtab can result in
a null compunit_symtab.  This adds an assert to that effect as well.
This change will simplify one of the psymtab sharing patches.

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

* dwarf2/read.c (struct dwarf2_include_psymtab): New.
(dwarf2_create_include_psymtab): Use dwarf2_include_psymtab.
(dwarf2_psymtab::expand_psymtab, dwarf2_psymtab::readin_p)
(dwarf2_psymtab::get_compunit_symtab): Remove null checks for
per_cu_data.

4 years agoRemove casts from dwarf2/index-write.c
Tom Tromey [Wed, 26 Feb 2020 22:41:07 +0000 (15:41 -0700)] 
Remove casts from dwarf2/index-write.c

dwarf2/index-write.c casts pointers to "dwarf2_psymtab *", but as far
as I can tell, it does not actually use any DWARF-specific fields of
the psymtab.  So, this patch changes this code to use partial_symtab
instead.  This removes nearly every cast, leaving just the unavoidable
one from addrmap iteration.

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

* dwarf2/index-write.c (psym_index_map): Change type.
(add_address_entry_worker, write_one_signatured_type)
(recursively_count_psymbols, recursively_write_psymbols)
(class debug_names, psyms_seen_size, write_gdbindex)
(write_debug_names): Use partial_symtab, not dwarf2_psymtab.

4 years agoAdd debuginfod support to GDB
Aaron Merey [Wed, 26 Feb 2020 22:40:49 +0000 (17:40 -0500)] 
Add debuginfod support to GDB

debuginfod is a lightweight web service that indexes ELF/DWARF debugging
resources by build-id and serves them over HTTP.

This patch enables GDB to query debuginfod servers for separate debug
files and source code when it is otherwise not able to find them.

GDB can be built with debuginfod using the --with-debuginfod configure
option.

This requires that libdebuginfod be installed and found at configure time.

debuginfod is packaged with elfutils, starting with version 0.178.

For more information see https://sourceware.org/elfutils/.

Tested on x86_64 Fedora 31.

gdb/ChangeLog:
2020-02-26  Aaron Merey  <amerey@redhat.com>

        * Makefile.in: Handle optional debuginfod support.
        * NEWS: Update.
        * README: Add --with-debuginfod summary.
        * config.in: Regenerate.
        * configure: Regenerate.
        * configure.ac: Handle optional debuginfod support.
        * debuginfod-support.c: debuginfod helper functions.
        * debuginfod-support.h: Ditto.
        * doc/gdb.texinfo: Add --with-debuginfod to configure options
        summary.
        * dwarf2/read.c (dwarf2_get_dwz_file): Query debuginfod servers
        when a dwz file cannot be found.
        * elfread.c (elf_symfile_read): Query debuginfod servers when a
        debuginfo file cannot be found.
        * source.c (open_source_file): Query debuginfod servers when a
        source file cannot be found.
        * top.c (print_gdb_configuration): Include
        --{with,without}-debuginfod in the output.

gdb/testsuite/ChangeLog:
2020-02-26  Aaron Merey  <amerey@redhat.com>

        * gdb.debuginfod: New directory for debuginfod tests.
        * gdb.debuginfod/main.c: New test file.
        * gdb.debuginfod/fetch_src_and_symbols.exp: New tests.

4 years agogdb: print thread names in thread apply command output
Jérémie Galarneau [Tue, 18 Feb 2020 00:08:03 +0000 (19:08 -0500)] 
gdb: print thread names in thread apply command output

This makes the thread apply command print the thread's name.  The use
of target_pid_to_str is replaced by thread_target_id_str, which
provides the same output as "info threads".

Before:
(gdb) thread apply 2 bt

Thread 2 (Thread 0x7fd245602700 (LWP 3837)):
[...]

After:
(gdb) thread apply 2 bt

Thread 2 (Thread 0x7fd245602700 (LWP 3837) "HT cleanup"):
[...]

The thread's description header is pre-computed before running the
command since the command may change the selected inferior. This is
not permitted by thread_target_id_str as target_thread_name asserts
that `info->inf == current_inferior ()`.

This situation arises in the `gdb.threads/threadapply.exp` test which
kills and removes the inferior as part of a "thread apply" command.

gdb/ChangeLog:

        * thread.c (thr_try_catch_cmd): Print thread name.

4 years agoMove more declarations from dwarf2/loc.h to dwarf2/read.h
Simon Marchi [Wed, 26 Feb 2020 14:35:22 +0000 (09:35 -0500)] 
Move more declarations from dwarf2/loc.h to dwarf2/read.h

All these functions have their implementations in dwarf2/read.c, so move
their declarations to dwarf2/read.h.  Move the doc to the header, at the
same time.

gdb/ChangeLog:

* dwarf2/loc.h (dwarf2_fetch_die_loc_sect_off,
dwarf2_fetch_die_loc_cu_off, dwarf2_fetch_constant_bytes,
dwarf2_fetch_die_type_sect_off): Move to...
* dwarf2/read.h (dwarf2_fetch_die_loc_sect_off,
dwarf2_fetch_die_loc_cu_off, dwarf2_fetch_constant_bytes,
dwarf2_fetch_die_type_sect_off): ... here.
* dwarf2/read.c (dwarf2_fetch_die_loc_sect_off,
dwarf2_fetch_die_loc_cu_off, dwarf2_fetch_constant_bytes,
dwarf2_fetch_die_type_sect_off): Move doc to header file.

4 years ago[binutils][arm] Arm CDE CX*A instructions allow condition code
Matthew Malcomson [Wed, 26 Feb 2020 14:23:11 +0000 (14:23 +0000)] 
[binutils][arm] Arm CDE CX*A instructions allow condition code

The implementation of the Arm CDE CX*A instructions doesn't allow a
condition code on the instructions but does allow the instruction in an
ITBlock.

The specification has been recently updated, though this is yet to be
published.

The instructions now should allow a suffix, and should behave in the
standard way around ITBlocks.

This patch removes the custom pred_instruction_type and handling for
these instructions, and uses the standard INSIDE_IT_INSN predication
type to describe the new instructions.

gas/ChangeLog:

2020-02-26  Matthew Malcomson  <matthew.malcomson@arm.com>

* config/tc-arm.c (enum pred_instruction_type): Remove
NEUTRAL_IT_NO_VPT_INSN predication type.
(cxn_handle_predication): Modify to require condition suffixes.
(handle_pred_state): Remove NEUTRAL_IT_NO_VPT_INSN cases.
* testsuite/gas/arm/cde-scalar.s: Update test.
* testsuite/gas/arm/cde-warnings.l: Update test.
* testsuite/gas/arm/cde-warnings.s: Update test.

4 years ago[gdb] Don't set initial language if set manually
Tom de Vries [Wed, 26 Feb 2020 13:52:00 +0000 (14:52 +0100)] 
[gdb] Don't set initial language if set manually

Initially, gdb sets the language to auto/c:
...
$ gdb -q
(gdb) show language
The current source language is "auto; currently c".
...

And after loading a c++ executable, that changes to auto/c++:
...
(gdb) file a.out
Reading symbols from a.out...
(gdb) show language
The current source language is "auto; currently c++".
...

Now consider setting the language manually to c:
...
$ gdb -q
(gdb) show language
The current source language is "auto; currently c".
(gdb) set language c
(gdb) show language
The current source language is "c".
...
The resulting language is manual/c.

Surprisingly, a subsequent load of the c++ executable:
...
(gdb) file a.out
Reading symbols from a.out...
(gdb) show language
The current source language is "c++".
...
gets us language manual/c++.

Loading the file should get us either:
- auto/c++, or
- manual/c.
That is, either the manual setting should be reset by loading, or the manual
setting should persist.

Fix this in the manual/c fashion. [ Though we could make some gdb setting to
choose one or the other. ]

Build and reg-tested on x86_64-linux.

[ Note: In PR23710 comment 1 a cc1 binary is attached for which gdb is slow when
loading and settting a breakpoint on do_rpo_vn:
...
$ time.sh gdb cc1 -batch -ex "b do_rpo_vn"
Breakpoint 1 at 0xd40e30: do_rpo_vn. (2 locations)
maxmem: 1463496
real: 8.88
user: 8.59
system: 0.35
...

This fix enables a speedup by manually setting the language before
loading, reducing executing time with ~17%, due to not having to load the full
symtab containing main:
...
$ time.sh gdb -iex "set language c++" cc1 -batch -ex "b do_rpo_vn"
Breakpoint 1 at 0xd40e30: do_rpo_vn. (2 locations)
maxmem: 1067308
real: 7.36
user: 7.14
system: 0.28
... ]

gdb/ChangeLog:

2020-02-26  Tom de Vries  <tdevries@suse.de>

PR gdb/25603
* symfile.c (set_initial_language): Exit-early if
language_mode == language_mode_manual.

gdb/testsuite/ChangeLog:

2020-02-26  Tom de Vries  <tdevries@suse.de>

PR gdb/25603
* gdb.base/persistent-lang.cc: New test.
* gdb.base/persistent-lang.exp: New file.

4 years agold: Add PR ld/25593 tests
H.J. Lu [Wed, 26 Feb 2020 11:56:28 +0000 (03:56 -0800)] 
ld: Add PR ld/25593 tests

PR ld/25593
* testsuite/ld-plugin/lto.exp: Run PR ld/25593 tests.
* testsuite/ld-plugin/pr25593.d: New file.
* testsuite/ld-plugin/pr25593a-1.c: Likewise.
* testsuite/ld-plugin/pr25593a-2.c: Likewise.
* testsuite/ld-plugin/pr25593b.c: Likewise.
* testsuite/ld-plugin/pr25593c.c: Likewise.
* testsuite/ld-plugin/pr25593d.c: Likewise.
* testsuite/ld-plugin/pr25593e.c: Likewise.

4 years agoArchive sanity checks
Alan Modra [Wed, 26 Feb 2020 06:32:38 +0000 (17:02 +1030)] 
Archive sanity checks

Adds some sanity checking to size values read from file.

* archive.c (do_slurp_bsd_armap): Increase minimum parsed_size, and
bfd_set_error on failing test.  Don't bother changing bfd_error on
file read error.  Check symdef_count is multiple of BSD_SYMDEF_SIZE.
Check sym name is within string buffer.  Use size_t for some vars.
(do_slurp_coff_armap): Use size_t for some variables, fix size of
int_buf.  Don't change bfd_error on file read error.  Use
_bfd_mul_overflow when calculating carsym buffer size.  Reorder
calculations to catch overflows before they occur.  malloc and
free raw armap rather than using bfd_alloc.  Read raw armap before
allocating carsym+strings buffer.
(_bfd_slurp_extended_name_table): Localize variables.  Check
name size against file size.

4 years agoRe: vms buffer overflows and large memory allocation
Alan Modra [Wed, 26 Feb 2020 04:44:48 +0000 (15:14 +1030)] 
Re: vms buffer overflows and large memory allocation

git commit c893ce360a changed buffer management, in the process
introducing a bug on an error return path.

* vms-lib.c (vms_lib_read_index): Release correct buffer.

4 years agoMove dwarf2_read_addr_index declaration to dwarf2/read.h
Simon Marchi [Wed, 26 Feb 2020 04:38:26 +0000 (23:38 -0500)] 
Move dwarf2_read_addr_index declaration to dwarf2/read.h

The implementation is in dwarf2/read.c, so the declaration belongs in
dwarf2/read.h.  Also, move the documentation there.

gdb/ChangeLog:

* dwarf2/loc.h (dwarf2_read_addr_index): Move...
* dwarf2/read.h (dwarf2_read_addr_index): ... here.
* dwarf2/read.c (dwarf2_read_addr_index): Move doc to header.

4 years agorx: memory allocation without checking for NULL return
Alan Modra [Wed, 26 Feb 2020 02:32:42 +0000 (13:02 +1030)] 
rx: memory allocation without checking for NULL return

* elf32-rx.c (rx_elf_relocate_section): Use bfd_malloc rather than
malloc.  Check for NULL return from bfd_malloc.
(rx_table_find, rx_table_map): Likewise.
(rx_set_section_contents): Check bfd_alloc return.
(rx_dump_symtab): Don't alloc internal_syms or external_syms.

4 years agogas gettext warning
Alan Modra [Wed, 26 Feb 2020 02:27:19 +0000 (12:57 +1030)] 
gas gettext warning

gettext("") returns the header entry with meta information, not the
empty string.

* config/tc-arm.c (reg_expected_msgs[REG_TYPE_RNB]): Don't use
N_() on empty string.