binutils-gdb.git
4 years agox86: Run unique tests only for ELF targets
H.J. Lu [Thu, 6 Feb 2020 12:44:39 +0000 (04:44 -0800)]
x86: Run unique tests only for ELF targets

* testsuite/gas/i386/i386.exp: Run unique and x86-64-unique
only for ELF targets.
* testsuite/gas/i386/unique.d: Don't xfail.
* testsuite/gas/i386/x86-64-unique.d: Likewise.

4 years agoEnable ld-ifunc tests for more targets
Alan Modra [Thu, 6 Feb 2020 00:53:43 +0000 (11:23 +1030)]
Enable ld-ifunc tests for more targets

Also fix some ix86 fails.

* testsuite/ld-ifunc/ifunc.exp: Enable for more targets, specifying
targets that don't support ifunc rather than ones that do.
(contains_irelative_reloc): Match R_PARISC_IPLT.
* testsuite/ld-ifunc/lib.c: Don't use .set in asm.
* testsuite/ld-ifunc/ifunc-23-x86.s,
* testsuite/ld-ifunc/ifunc-24-x86.s,
* testsuite/ld-ifunc/ifunc-25-x86.s,
* testsuite/ld-ifunc/ifunc-4-local-x86.s,
* testsuite/ld-ifunc/ifunc-4-x86.s: Define _main.
* testsuite/ld-ifunc/ifunc-10-i386.d,
* testsuite/ld-ifunc/ifunc-11-i386.d,
* testsuite/ld-ifunc/ifunc-12-i386.d,
* testsuite/ld-ifunc/ifunc-13-i386.d,
* testsuite/ld-ifunc/ifunc-14a-i386.d,
* testsuite/ld-ifunc/ifunc-14b-i386.d,
* testsuite/ld-ifunc/ifunc-14c-i386.d,
* testsuite/ld-ifunc/ifunc-14d-i386.d,
* testsuite/ld-ifunc/ifunc-14e-i386.d,
* testsuite/ld-ifunc/ifunc-14f-i386.d,
* testsuite/ld-ifunc/ifunc-15-i386.d,
* testsuite/ld-ifunc/ifunc-16-i386-now.d,
* testsuite/ld-ifunc/ifunc-16-i386.d,
* testsuite/ld-ifunc/ifunc-17a-i386.d,
* testsuite/ld-ifunc/ifunc-17b-i386.d,
* testsuite/ld-ifunc/ifunc-18a-i386.d,
* testsuite/ld-ifunc/ifunc-18b-i386.d,
* testsuite/ld-ifunc/ifunc-19a-i386.d,
* testsuite/ld-ifunc/ifunc-19b-i386.d,
* testsuite/ld-ifunc/ifunc-2-i386-now.d,
* testsuite/ld-ifunc/ifunc-2-i386.d,
* testsuite/ld-ifunc/ifunc-2-local-i386-now.d,
* testsuite/ld-ifunc/ifunc-2-local-i386.d,
* testsuite/ld-ifunc/ifunc-20-i386.d,
* testsuite/ld-ifunc/ifunc-21-i386.d,
* testsuite/ld-ifunc/ifunc-22-i386.d,
* testsuite/ld-ifunc/ifunc-26.d,
* testsuite/ld-ifunc/ifunc-5a-i386.d,
* testsuite/ld-ifunc/ifunc-5a-local-i386.d,
* testsuite/ld-ifunc/ifunc-5b-i386.d,
* testsuite/ld-ifunc/ifunc-5b-local-i386.d,
* testsuite/ld-ifunc/ifunc-5r-local-i386.d,
* testsuite/ld-ifunc/ifunc-6a-i386.d,
* testsuite/ld-ifunc/ifunc-6b-i386.d,
* testsuite/ld-ifunc/ifunc-7a-i386.d,
* testsuite/ld-ifunc/ifunc-7b-i386.d,
* testsuite/ld-ifunc/ifunc-8-i386.d,
* testsuite/ld-ifunc/ifunc-9-i386.d,
* testsuite/ld-ifunc/pr17154-i386-now.d,
* testsuite/ld-ifunc/pr17154-i386.d: xfail lynxos, nto, and solaris.

4 years agoxfail x86 gas unique test
Alan Modra [Thu, 6 Feb 2020 00:22:29 +0000 (10:52 +1030)]
xfail x86 gas unique test

* testsuite/gas/i386/unique.d: xfail for non-elf targets.
* testsuite/gas/i386/x86-64-unique.d: Likewise.

4 years agombind gas tests and supports_gnu_osabi testsuite infrastructure
Alan Modra [Wed, 5 Feb 2020 05:49:17 +0000 (16:19 +1030)]
mbind gas tests and supports_gnu_osabi testsuite infrastructure

With the addition of section16 tests we have multiple tests
advertising themselves as "mbind sections" and "mbind section
contents".  This patch fixes that, and fails on quite a few targets
that force an OSABI value.  It's a pain specifying all the relevant
arm targets on an xfail line, so I wrote supports_gnu_osabi.

binutils/
* testsuite/lib/binutils-common.exp (match_target): Accept '!' before
TCL procedure.
(supports_gnu_osabi): New procedure.
(is_generic): New, from ld-lib.exp.
(supports_gnu_unique): Use the above.
gas/
* testsuite/gas/elf/section12a.d: Use supports_gnu_osabi in
xfail, and rename test.
* testsuite/gas/elf/section12b.d: Likewise.
* testsuite/gas/elf/section16a.d: Likewise.
* testsuite/gas/elf/section16b.d: Likewise.
ld/
* testsuite/lib/ld-lib.exp (is_generic): Delete.
* testsuite/ld-unique/unique.exp: Exclude tic6x.

4 years agoi386-moss and i386-openbsd ld config
Alan Modra [Thu, 6 Feb 2020 00:38:37 +0000 (11:08 +1030)]
i386-moss and i386-openbsd ld config

i386-moss is an ELF target needing ldelf.c.  x86 openbsd wouldn't even
build, so I added entries to do the same as netbsd.  Quite likely this
isn't ideal but if the openbsd folk don't contribute their changes
this is what they get.

* configure.tgt (i[3-7]86-*-moss*): Don't clear targ_extra_ofiles.
(i[3-7]86-*-openbsd*, x86_64-*-openbsd*): Add.

4 years agoDisambiguate info_print_options
Ali Tamur [Sat, 25 Jan 2020 03:40:40 +0000 (19:40 -0800)]
Disambiguate info_print_options

struct info_print_options is defined in both symtab.c and stack.c, which is
an ODR violation. So, I am renaming info_print_options and related
structs/functions in symtab.c:

info_print_options                ==> info_vars_funcs_options
info_print_options_defs           ==> info_vars_funcs_options_defs
make_info_print_options_def_group ==> make_info_vars_funcs_options_def_group
info_print_command_completer      ==> info_vars_funcs_command_completer

gdb/ChangeLog:

* symtab.c (info_print_options): Rename to
info_vars_funcs_options.
(info_print_options_defs): Rename to
info_vars_funcs_options_defs.
(make_info_print_options_def_group): Rename to
make_info_vars_funcs_options_def_group.
(info_print_command_completer): Rename to
info_vars_funcs_command_completer.
(info_variables_command): Apply name changes.
(info_functions_command): Likewise.
(_initialize_symtab): Likewise.

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

4 years agoFix base class function call
Christian Biesinger [Wed, 5 Feb 2020 17:43:22 +0000 (11:43 -0600)]
Fix base class function call

This was a typo introduced in f6ac5f3d63e03a81c4ff3749aba234961cc9090e.

Found by looking through NetBSD's GDB patches:
https://github.com/NetBSD/pkgsrc-wip/blob/master/gdb-netbsd/patches/patch-gdb_sparc-nat.h

This patch can't be tested on Linux because Linux does not use the
sparc_target template.

gdb/ChangeLog:

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

* sparc-nat.h (struct sparc_target) <xfer_partial>: Fix base class
function call.

Change-Id: I4fa88cbdc365efe89b84cc0619b60db38718d9ce

4 years agoFix header guard name in #endif comment
Christian Biesinger [Wed, 5 Feb 2020 17:33:42 +0000 (11:33 -0600)]
Fix header guard name in #endif comment

Makes the comment match the macro name in the #define/#ifdef.

gdb/ChangeLog:

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

* ppc-nbsd-tdep.h: Fix macro name in #endif comment.

Change-Id: If7b2e49e65495b8eb9ed7b6c9a11277579a93a05

4 years agoRISC-V/Linux/native: Factor out target description determination
Maciej W. Rozycki [Wed, 5 Feb 2020 17:21:12 +0000 (17:21 +0000)]
RISC-V/Linux/native: Factor out target description determination

In preparation for RISC-V/Linux `gdbserver' support factor out parts of
native target description determination code that can be shared between
the programs.

gdb/
* nat/riscv-linux-tdesc.h: New file.
* nat/riscv-linux-tdesc.c: New file, taking code from...
* riscv-linux-nat.c (riscv_linux_nat_target::read_description):
... here.
* configure.nat <linux> <riscv*>: Add nat/riscv-linux-tdesc.o to
NATDEPFILES.

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

4 years agoRe: Support fusion for ELFv2 stubs
Alan Modra [Tue, 4 Feb 2020 20:42:48 +0000 (07:12 +1030)]
Re: Support fusion for ELFv2 stubs

git commit 397998fc32a3 changed the stubs but not the comments.

* elf64-ppc.c (ppc_stub_plt_branch): Match comment with reality.

4 years agogdb/fortran: Allow for using Flang in Fortran testing
Alok Kumar Sharma [Tue, 4 Feb 2020 17:17:20 +0000 (17:17 +0000)]
gdb/fortran: Allow for using Flang in Fortran testing

In lib/fortran.exp, in the helper function fortran_int4, there is
currently no support for the LLVM Fortran compiler, Flang.  As a
result we return the default pattern 'unknown' to match against all
4-byte integer types, which causes many tests to fail.

The same is true for all of the other helper functions related to
finding a suitable type pattern.

This commit adds support for Flang.  There should be no change when
testing with gfortran.

gdb/testsuite/ChangeLog:

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

Change-Id: Ife0d9828f78361fbd992bf21af746042b017dafc

4 years agogdb/sim: Assert that the simulator ptid is not null_ptid
Andrew Burgess [Tue, 4 Feb 2020 09:07:16 +0000 (09:07 +0000)]
gdb/sim: Assert that the simulator ptid is not null_ptid

We assign the simulator inferior a fake ptid.  If this ptid is ever
set to null_ptid then we are going to run into problems - the
simulator ptid is what we return from gdbsim_target::wait, and this in
turn is used to look up the inferior data with a call to
find_inferior_pid, which asserts the pid is not 0 (which it is in
null_pid).

This commit adds an assert that the simulator's fake pid is not
null_ptid.  There should be no user visible changes after this commit.

gdb/ChangeLog:

* remote-sim.c (sim_inferior_data::sim_inferior_data): Assert that
we don't set the fake simulator ptid to the null_ptid.

Change-Id: I6e08effe70e70855aea13c9caf4fd6913d5af56d

4 years ago[gdb/testsuite] Add note to 'Race detection' entry in README
Tom de Vries [Tue, 4 Feb 2020 16:36:17 +0000 (17:36 +0100)]
[gdb/testsuite] Add note to 'Race detection' entry in README

Add note to 'Race detection' entry in README about the possibility that
check-read1 makes failing tests pass.

gdb/testsuite/ChangeLog:

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

* README (Race detection): Add note.

Change-Id: I12ef2f0ec35abc5a0221585bf30e5f4f0616aa7c

4 years ago[gdb/testsuite] Make inferior_exited_re match a single line
Tom de Vries [Tue, 4 Feb 2020 16:30:05 +0000 (17:30 +0100)]
[gdb/testsuite] Make inferior_exited_re match a single line

The current inferior_exited_re regexp contains a '.*':
...
set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
...

This means that while matching a single line:
...
$ tclsh
% set re "(?:\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
(?:\[Inferior [0-9]+ \(.*\) exited)
% set line "\[Inferior 1 (process 33) exited\]\n"
[Inferior 1 (process 33) exited]

% regexp $re $line
1
...
it also matches more than one line:
...
$ tclsh
% set re "(?:\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
(?:\[Inferior [0-9]+ \(.*\) exited)
% set line "\[Inferior 1 (process 33) exited\]\n\[Inferior 2 (process 44) exited\]\n"
[Inferior 1 (process 33) exited]
[Inferior 2 (process 44) exited]

% regexp $re $line
1
...

Fix this by using "\[^\n\r\]*" instead of ".*".

Build and reg-tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

* lib/gdb.exp (inferior_exited_re): Use "\[^\n\r\]*" instead of ".*".

Change-Id: Id7b1dcecd8c7fda3d1ab34b4fa1364d301748333

4 years agoMinor fix for R_PPC_VLE_ADDR20
Alan Modra [Tue, 4 Feb 2020 11:04:45 +0000 (21:34 +1030)]
Minor fix for R_PPC_VLE_ADDR20

It is incorrect to "continue" in the ppc_elf_relocate_section reloc
processing loop except when editing or deleting relocs.  The normal
loop processing arranges to write the relocs if shuffling them over a
deleted entry.  Deleting only happens for debug sections currently and
those sections won't contain R_PPC_VLE_ADDR20 relocs, so this patch
doesn't fix a bug that would trigger with any normal object file.

* elf32-ppc.c (ppc_elf_relocate_section): After applying
R_PPC_VLE_ADDR20, goto copy_reloc.

4 years agoMissing objdump dependency od-elf32_avr
Alan Modra [Tue, 4 Feb 2020 05:44:55 +0000 (16:14 +1030)]
Missing objdump dependency od-elf32_avr

* Makefile.am (CFILES): Add od-elf32_avr.c.
* Makefile.in: Regenerate.
* po/POTFILES.in: Regenerate.

4 years ago[gdb/testsuite] Use non-capturing parentheses for inferior_exited_re
Tom de Vries [Tue, 4 Feb 2020 08:53:50 +0000 (09:53 +0100)]
[gdb/testsuite] Use non-capturing parentheses for inferior_exited_re

The inferior_exited_re regexp uses capturing parentheses by default:
...
set inferior_exited_re "(\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
...

The parentheses are there to be able to use the expression as an atom, f.i.,
to have '+' apply to the whole regexp in "${inferior_exited_re}+".

But the capturing is not necessary, and it can be confusing because it's not
obvious in a regexp using "$inferior_exited_re (bla|bli)" that the first
captured expression is in $inferior_exited_re.

Replace by non-capturing parentheses.  If we still want to capture the
expression, we can simply (and more clearly) use "($inferior_exited_re)".

Build and reg-tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

* lib/gdb.exp (inferior_exited_re): Use non-capturing parentheses.

Change-Id: I7640c6129b1ada617424d6a63730d4b119c58ef3

4 years agoChange ints to bools around thread_info executing/resumed
Simon Marchi [Tue, 4 Feb 2020 04:02:28 +0000 (23:02 -0500)]
Change ints to bools around thread_info executing/resumed

Switch thread_info::resumed to bool (thread_info::executing already is a bool),
and try to change everything more or less related to that to consistently use
true/false instead of 1/0.

gdb/ChangeLog:

* fork-child.c (gdb_startup_inferior): Use bool instead of int.
* gdbthread.h (class thread_info) <resumed>: Likewise.
* infrun.c (resume_1): Likewise.
(proceed): Likewise.
(infrun_thread_stop_requested): Likewise.
(stop_all_threads): Likewise.
(handle_inferior_event): Likewise.
(restart_threads): Likewise.
(finish_step_over): Likewise.
(keep_going_stepped_thread): Likewise.
* linux-nat.c (attach_proc_task_lwp_callback): Likewise.
(linux_handle_extended_wait): Likewise.
* record-btrace.c (get_thread_current_frame_id): Likewise.
* record-full.c (record_full_wait_1): Likewise.
* remote.c (remote_target::process_initial_stop_replies): Likewise.
* target.c (target_resume): Likewise.
* thread.c (set_running_thread): Likewise.

4 years agoubsan: d30v: negation of -2147483648
Alan Modra [Mon, 3 Feb 2020 22:00:22 +0000 (08:30 +1030)]
ubsan: d30v: negation of -2147483648

include/
* opcode/d30v.h (struct pd_reg): Make value field unsigned.
opcodes/
* d30v-dis.c (print_insn): Make "val" and "opnum" unsigned.

4 years agogdb: fix powerpc disassembly tests
Rogerio Alves [Mon, 3 Feb 2020 20:55:03 +0000 (17:55 -0300)]
gdb: fix powerpc disassembly tests

This patch fixes test failures power8 and power9 caused by changes on
opcodes:

The dissasembler does not emit whitespace for instructions
anymore (c2b1c2754526acff8aae2fe8f5a56c2dd11d0b7f)

The dissasembler generates extended mnemonics for some instructions
instead (aae9718e4d4e8d01dcee22684e82b000203d3e52)

The ldmx instruction was removed. This instruction was never
implemented (6fbc939cfdbdf02f205c20925583738b0f835e62)

gdb/testsuite/ChangeLog:
2020-02-03  Rogerio A. Cardoso  <rcardoso@linux.ibm.com>

* gdb.arch/powerpc-power8.exp: Delete trailing whitespace of
tbegin., tend. instructions. Replace bctar-, bctar+, bctarl-,
bctarl+ extended mnemonics when avaliable by bgttar, bnstarl,
blttar, bnetarl.
* gdb.arch/powerpc-power8.s: Fix comments. Fix instructions
binary for blttar, bnetarl.
* gdb.arch/powerpc-power9.exp: Delete trailing whitespace of
wait instruction. Delete ldmx test.
* gdb.arch/powerpc-power9.s: Delete ldmx instruction.

4 years agoFixed gdb to print arrays with very high indexes
Alok Kumar Sharma [Tue, 4 Feb 2020 01:24:34 +0000 (20:24 -0500)]
Fixed gdb to print arrays with very high indexes

In the function f77_print_array_1, the variable 'i' which holds the
index is of datatype 'int', while bounds are of datatype LONGEST. Due to
size of int being smaller than LONGEST, the variable 'i' stores
incorrect values for high indexes (higher than max limit of int).  Due
to this issue in sources, two abnormal behaviors are seen while printing
arrays with high indexes (please check array-bounds-high.f90) For high
indexes with negative sign, gdb prints empty array even if the array has
elements.

    (gdb) p arr
    $1 = ()

For high indexes with positive sign, gdb crashes.  We have now changed
the datatype of 'i' to LONGEST which is same as datatype of bounds.

gdb/ChangeLog:

* f-valprint.c (f77_print_array_1): Changed datatype of index
variable to LONGEST from int to enable it to contain bound
values correctly.

gdb/testsuite/ChangeLog:

* gdb.fortran/array-bounds-high.exp: New file.
* gdb.fortran/array-bounds-high.f90: New file.

Change-Id: Ie2dce9380a249e634e2684b9c90f225e104369b7

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

4 years agoreadelf: add missing newlines to error messages
Andreas Schwab [Sun, 2 Feb 2020 09:15:22 +0000 (10:15 +0100)]
readelf: add missing newlines to error messages

* readelf.c (dump_relocations, dump_relocations)
(decode_arm_unwind_bytecode, process_dynamic_section)
(get_symbol_visibility, get_alpha_symbol_other): Add newline to
error message.

4 years agoRISC-V/Linux/native: Determine FLEN dynamically
Maciej W. Rozycki [Mon, 3 Feb 2020 12:07:02 +0000 (12:07 +0000)]
RISC-V/Linux/native: Determine FLEN dynamically

Fix RISC-V native Linux support to handle a 64-bit FPU (FLEN == 64) with
both RV32 and RV64 systems, which is a part of the current Linux ABI for
hard-float systems, rather than assuming that (FLEN == XLEN) in target
description determination and that (FLEN == 64) in register access.

We can do better however and not rely on any particular value of FLEN
and probe for it dynamically, by observing that the PTRACE_GETREGSET
ptrace(2) call will only accept an exact regset size, and that will
reflect FLEN.  Therefore iterate over the call in target description
determination with a geometrically increasing regset size until a match
is marked by a successful ptrace(2) call completion or we run beyond the
maximum size we can support.

Update register accessors accordingly, using FLEN determined to size the
buffer used for NT_PRSTATUS requests and then to exchange data with the
regcache.

Also handle a glibc bug where ELF_NFPREG is defined in terms of NFPREG,
however NFPREG is nowhere defined.

gdb/
* riscv-linux-nat.c [!NFPREG] (NFPREG): New macro.
(supply_fpregset_regnum, fill_fpregset): Handle regset buffer
offsets according to FLEN determined.
(riscv_linux_nat_target::read_description): Determine FLEN
dynamically.
(riscv_linux_nat_target::fetch_registers): Size regset buffer
according to FLEN determined.
(riscv_linux_nat_target::store_registers): Likewise.

4 years agoFix compilation error with musl in gdb/testsuite/gdb.base/fileio.c
Lukas Durfina [Mon, 3 Feb 2020 10:36:17 +0000 (14:36 +0400)]
Fix compilation error with musl in gdb/testsuite/gdb.base/fileio.c

Musl is giving warnings about these includes in this way:
warning: #warning redirecting incorrect #include <sys/errno.h> to <errno.h>
warning: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>

gdb/testsuite/Changelog:

* gdb.base/fileio.c: Remove #include of <sys/errno.h>.
Replace #include of <sys/fcntl.h> by <fcntl.h>.

4 years agobinutils: drop redundant 'program_name' definition (-fno-common)
Sergei Trofimovich [Sat, 1 Feb 2020 23:16:11 +0000 (23:16 +0000)]
binutils: drop redundant 'program_name' definition (-fno-common)

* coffdump.c (program_name): Drop redundant definition.
* srconv.c (program_name): Likewise
* sysdump.c (program_name): Likewise

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
4 years agoubsan: m32c: left shift of negative value
Alan Modra [Mon, 3 Feb 2020 00:56:30 +0000 (11:26 +1030)]
ubsan: m32c: left shift of negative value

cpu/
* m32c.cpu (f-dsp-64-s16): Mask before shifting signed value.
opcodes/
* m32c-ibld.c: Regenerate.

4 years agosection.c: Fix typo in comments (withe -> with)
H.J. Lu [Mon, 3 Feb 2020 01:14:12 +0000 (17:14 -0800)]
section.c: Fix typo in comments (withe -> with)

* bfd-in2.h: Regenerated.
* section.c (SEC_ASSEMBLER_SECTION_ID): Fix a typo in comments.

4 years agoELF: Add support for unique section ID to assembler
H.J. Lu [Mon, 3 Feb 2020 01:07:51 +0000 (17:07 -0800)]
ELF: Add support for unique section ID to assembler

Clang's integrated assembler supports multiple section with the same
name:

.section .text,"ax",@progbits,unique,1
nop
.section .text,"ax",@progbits,unique,2
nop

"unique,N" assigns the number, N, as the section ID, to a section.  The
valid values of the section ID are between 0 and 4294967295.  It can be
used to distinguish different sections with the same section name.

This is useful with -fno-unique-section-names -ffunction-sections.
-ffunction-sections by default generates .text.foo, .text.bar, etc.
Using the same string can save lots of space in .strtab.

This patch adds section_id to bfd_section and reuses the linker
internal bit in BFD section flags, SEC_LINKER_CREATED, for assmebler
internal use to mark valid section_id.  It also updates objdump to
compare section pointers if 2 sections comes from the same file since
2 different sections can have the same section name.

bfd/

PR gas/25380
* bfd-in2.h: Regenerated.
* ecoff.c (bfd_debug_section): Add section_id.
* section.c (bfd_section): Add section_id.
(SEC_ASSEMBLER_SECTION_ID): New.
(BFD_FAKE_SECTION): Add section_id.

binutils/

PR gas/25380
* objdump.c (sym_ok): Return FALSE if 2 sections are in the
same file with different section pointers.

gas/

PR gas/25380
* config/obj-elf.c (section_match): Removed.
(get_section): Also match SEC_ASSEMBLER_SECTION_ID and
section_id.
(obj_elf_change_section): Replace info and group_name arguments
with match_p.  Also update the section ID and flags from match_p.
(obj_elf_section): Handle "unique,N".  Update call to
obj_elf_change_section.
* config/obj-elf.h (elf_section_match): New.
(obj_elf_change_section): Updated.
* config/tc-arm.c (start_unwind_section): Update call to
obj_elf_change_section.
* config/tc-ia64.c (obj_elf_vms_common): Likewise.
* config/tc-microblaze.c (microblaze_s_data): Likewise.
(microblaze_s_sdata): Likewise.
(microblaze_s_rdata): Likewise.
(microblaze_s_bss): Likewise.
* config/tc-mips.c (s_change_section): Likewise.
* config/tc-msp430.c (msp430_profiler): Likewise.
* config/tc-rx.c (parse_rx_section): Likewise.
* config/tc-tic6x.c (tic6x_start_unwind_section): Likewise.
* doc/as.texi: Document "unique,N" in .section directive.
* testsuite/gas/elf/elf.exp: Run "unique,N" tests.
* testsuite/gas/elf/section15.d: New file.
* testsuite/gas/elf/section15.s: Likewise.
* testsuite/gas/elf/section16.s: Likewise.
* testsuite/gas/elf/section16a.d: Likewise.
* testsuite/gas/elf/section16b.d: Likewise.
* testsuite/gas/elf/section17.d: Likewise.
* testsuite/gas/elf/section17.l: Likewise.
* testsuite/gas/elf/section17.s: Likewise.
* testsuite/gas/i386/unique.d: Likewise.
* testsuite/gas/i386/unique.s: Likewise.
* testsuite/gas/i386/x86-64-unique.d: Likewise.
* testsuite/gas/i386/i386.exp: Run unique and x86-64-unique.

ld/

PR gas/25380
* testsuite/ld-i386/pr22001-1c.S: Use "unique,N" in .section
directives.
* testsuite/ld-i386/tls-gd1.S: Likewise.
* testsuite/ld-x86-64/pr21481b.S: Likewise.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 3 Feb 2020 00:00:49 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoelf/section13.s: Replace @nobits with %nobits
H.J. Lu [Sun, 2 Feb 2020 16:20:18 +0000 (08:20 -0800)]
elf/section13.s: Replace @nobits with %nobits

* testsuite/gas/elf/section13.s: Replace @nobits with %nobits.

4 years agomoxie: don't force big-endian mode
Gitea [Sun, 2 Feb 2020 01:59:19 +0000 (20:59 -0500)]
moxie: don't force big-endian mode

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

4 years agoUpdate release making documentation
Nick Clifton [Sat, 1 Feb 2020 13:14:16 +0000 (13:14 +0000)]
Update release making documentation

4 years agoMove pending obsolete targets onto the definitely obsolete list
Nick Clifton [Sat, 1 Feb 2020 13:13:14 +0000 (13:13 +0000)]
Move pending obsolete targets onto the definitely obsolete list

4 years agoubsan: frv: left shift of negative value
Alan Modra [Sat, 1 Feb 2020 02:38:43 +0000 (13:08 +1030)]
ubsan: frv: left shift of negative value

More non-bugs flagged by ubsan, unless you happen to be compiling for
a 1's complement host.

cpu/
* frv.cpu (f-u12): Multiply rather than left shift signed values.
(f-label16, f-label24): Likewise.
opcodes/
* frv-ibld.c: Regenerate.

4 years agogdb: Do not print empty-group regs when printing general ones
Shahab Vahedi [Fri, 31 Jan 2020 22:10:11 +0000 (22:10 +0000)]
gdb: Do not print empty-group regs when printing general ones

When the command "info registers" (same as "info registers general"),
is issued, _all_ the registers from a tdesc XML are printed. This
includes the registers with empty register groups (set as "") which
are supposed to be only printed by "info registers all" (or "info
all-registers").

This bug got introduced after all the overhauls that the
tdesc_register_in_reggroup_p() went through. You can see that the
logic of tdesc_register_in_reggroup_p() did NOT remain the same after
all those changes:

  git difftool c9c895b9666..HEAD -- gdb/target-descriptions.c

With the current implementation, when the reg->group is an empty
string, this function returns -1, while in the working revision
(c9c895b9666), it returned 0. This patch makes sure that the 0 is
returned again.

The old implementation of tdesc_register_in_reggroup_p() returned
-1 when "reggroup" was set to "all_reggroups" at line 4 below:

1  tdesc_register_reggroup_p (...)
2  {
3   ...
4   ret = tdesc_register_in_reggroup_p (gdbarch, regno, reggroup);
5   if (ret != -1)
6     return ret;
7
8   return default_register_reggroup_p (gdbarch, regno, reggroup);
9  }

As a result, the execution continued at line 8 and the
default_register_reggroup_p(..., reggroup=all_reggroups) would
return 1. However, with the current implementation of
tdesc_register_in_reggroup_p() that allows checking against any
arbitrary group name, it returns 0 when comparing the "reg->group"
against the string "all" which is the group name for "all_reggroups".
I have added a special check to cover this case and
"info all-registers" works as expected.

gdb/ChangeLog:

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

Change-Id: I9eaf9d7fb36410ed5684ae652fe4756b1b2e61a3

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

4 years ago[gdb/testsuite] Fix typo in gdb.server/server-kill-python.exp
Tom de Vries [Fri, 31 Jan 2020 23:05:42 +0000 (00:05 +0100)]
[gdb/testsuite] Fix typo in gdb.server/server-kill-python.exp

Fix typo '$gdb_tst_name' -> '$gdb_test_name'.

gdb/testsuite/ChangeLog:

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

* gdb.server/server-kill-python.exp: Fix $gdb_tst_name typo.

Change-Id: Iad050dab0e8aad2f2692e54e398021558250f1ac

4 years agonios2: Add BFD support for GOT-relative DW_EH_PE_datarel encodings
Sandra Loosemore [Fri, 31 Jan 2020 18:34:42 +0000 (10:34 -0800)]
nios2: Add BFD support for GOT-relative DW_EH_PE_datarel encodings

There's already existing logic to handle this on other targets, so
this patch just makes nios2 use it.

2020-01-31  Sandra Loosemore  <sandra@codesourcery.com>

bfd/
* elf-eh-frame.c (_bfd_elf_write_section_eh_frame): DW_EH_PE_datarel
encodings are relative to the GOT on nios2, too.

4 years agonios2: recognize %gotoff relocation in assembler
Sandra Loosemore [Fri, 31 Jan 2020 18:32:48 +0000 (10:32 -0800)]
nios2: recognize %gotoff relocation in assembler

The nios2 ABI documentation lists %gotoff as assembler syntax for the
R_NIOS2_GOTOFF relocation, used to represent a 32-bit GOT-relative offset
in data sections.  This was previously unimplemented in GAS.

2020-01-31  Sandra Loosemore  <sandra@codesourcery.com>

gas/
* config/tc-nios2.c (nios2_cons): Handle %gotoff as well as
%tls_ldo.

4 years agoAdd missing ChangeLog for last patch
Andre Vieira [Fri, 31 Jan 2020 17:13:18 +0000 (17:13 +0000)]
Add missing ChangeLog for last patch

4 years agoarm: PR gas/25472 Enable DSP instructions with +mve
Andre Vieira [Fri, 31 Jan 2020 17:09:27 +0000 (17:09 +0000)]
arm: PR gas/25472 Enable DSP instructions with +mve

We noticed +mve was not enabling DSP instructions as it should, reported in PR
25472.
The MVE architecture extension for Armv8.1-M Mainline implies DSP extensions.
This patch reflects that in the '+mve' command line option.

gas/ChangeLog:
2020-01-31  Andre Vieira  <andre.simoesdiasvieira@arm.com>

PR gas/25472
* config/tc-arm.c (armv8m_main_ext_table): Refactored +dsp adding.
(armv8_1m_main_ext_table): Refactored +dsp adding and enabled dsp for
+mve.
* testsuite/gas/arm/mve_dsp.d: New test.

4 years agoFix compile time build problem building the s390 assembler.
Nick Clifton [Fri, 31 Jan 2020 16:43:57 +0000 (16:43 +0000)]
Fix compile time build problem building the s390 assembler.

* config/tc-s390.c (s390_elf_suffix): Return ELF_SUFFIX_NONE
rather than BFD_RELOC_NONE.

4 years ago[ARM]: Add support for vldmia/vldmdb/vstmia/vstmdb instructions in MVE.
Srinath Parvathaneni [Fri, 31 Jan 2020 16:16:19 +0000 (16:16 +0000)]
[ARM]: Add support for vldmia/vldmdb/vstmia/vstmdb instructions in MVE.

This patch adds support for assembly instructions vldmia, vldmdb, vstmia
and vstmdb in MVE.  This instructions are already supported for Armv8-M
Floating-point Extension.

gas/ChangeLog:

2020-01-31  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

* config/tc-arm.c (fldmias): Moved inside "THUMB_VARIANT & arm_ext_v6t2"
to support VLDMIA instruction for MVE.
(fldmdbs): Moved inside "THUMB_VARIANT & arm_ext_v6t2" to support VLDMDB
instruction for MVE.
(fstmias): Moved inside "THUMB_VARIANT & arm_ext_v6t2" to support VSTMIA
instruction for MVE.
(fstmdbs): Moved inside "THUMB_VARIANT & arm_ext_v6t2" to support VSTMDB
instruction for MVE.
* testsuite/gas/arm/mve-ldst.d: New test.
* testsuite/gas/arm/mve-ldst.s: Likewise.

4 years agoUpdated translations for some of the binutils sub-directories
Nick Clifton [Fri, 31 Jan 2020 14:45:51 +0000 (14:45 +0000)]
Updated translations for some of the binutils sub-directories

4 years agox86: replace EXxmm_mdq by EXVexWdqScalar
Jan Beulich [Fri, 31 Jan 2020 13:29:18 +0000 (14:29 +0100)]
x86: replace EXxmm_mdq by EXVexWdqScalar

There's no need to have two operand specifiers / enumerators for the
same purpose. This then renders xmm_mdq_mode unused.

4 years agox86: drop unused EXVexWdq / vex_w_dq_mode
Jan Beulich [Fri, 31 Jan 2020 13:28:43 +0000 (14:28 +0100)]
x86: drop unused EXVexWdq / vex_w_dq_mode

4 years agoaarch64: Fix MOVPRFX markup for bf16 conversions
Richard Sandiford [Fri, 31 Jan 2020 08:03:56 +0000 (08:03 +0000)]
aarch64: Fix MOVPRFX markup for bf16 conversions

bfcvt converts a .S input to a .H output, so any predicated movprfx
needs to operate on .S rather than .H.  In common with SVE2 narrowing
top operations, bfcvtnt doesn't accept movprfx.

2020-01-31  Richard Sandiford  <richard.sandiford@arm.com>

opcodes/
* aarch64-tbl.h (aarch64_opcode): Set C_MAX_ELEM for SVE bfcvt.
Remove C_SCAN_MOVPRFX for SVE bfcvtnt.

gas/
* testsuite/gas/aarch64/sve-bfloat-movprfx.s: Use .h rather than
.s for the movprfx.
* testsuite/gas/aarch64/sve-bfloat-movprfx.d: Update accordingly.
* testsuite/gas/aarch64/sve-movprfx_28.d,
* testsuite/gas/aarch64/sve-movprfx_28.l,
* testsuite/gas/aarch64/sve-movprfx_28.s: New test.

4 years agoFix ravenscar-thread.c for multi-target
Tom Tromey [Wed, 22 Jan 2020 19:30:40 +0000 (12:30 -0700)]
Fix ravenscar-thread.c for multi-target

ravenscar-thread.c needed a change to adapt to multi-target:
ravenscar_thread_target::mourn_inferior called the mourn_inferior
method on the target beneat -- but when the target beneath was the
remote target, this resulted in the ravenscar target being deleted.

Switching the order of the calls to unpush_target and the beneath's
mourn_inferior fixes this problem.

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

* ravenscar-thread.c (ravenscar_thread_target::mourn_inferior):
Call beneath target's mourn_inferior after unpushing.

Change-Id: Ia80380515c403adc40505a6b3420c9cb35754370

4 years agogdb/tui: Disassembler scrolling of very small programs
Andrew Burgess [Fri, 24 Jan 2020 12:46:56 +0000 (12:46 +0000)]
gdb/tui: Disassembler scrolling of very small programs

In TUI mode, if the disassembly output for the program is less than
one screen long, then currently if the user scrolls down until on the
last assembly instruction is displayed and then tries to scroll up
using Page-Up, the display doesn't update - they are stuck viewing the
last line.

If the user tries to scroll up using the Up-Arrow, then the display
scrolls normally.

What is happening is on the Page-Up we ask GDB to scroll backward the
same number of lines as the height of the TUI ASM window.  The back
scanner, which looks for a good place to start disassembling, fails to
find a starting address which will provide the requested number of new
lines before we get back to the original starting address (which is
not surprising, our whole program contains less than a screen height
of instructions), as a result the back scanner gives up and returns
the original starting address.

When we scroll with Up-Arrow we only ask the back scanner to find 1
new instruction, which it manages to do, so this scroll works.

The solution here is, when we fail to find enough instructions, to
return the lowest address we did manage to find.  This will ensure we
jump to the lowest possible address in the disassembly output.

gdb/ChangeLog:

PR tui/9765
* tui/tui-disasm.c (tui_find_disassembly_address): If we don't
have enough lines to fill the screen, still return the lowest
address we found.

gdb/testsuite/ChangeLog:

PR tui/9765
* gdb.tui/tui-layout-asm-short-prog.S: New file.
* gdb.tui/tui-layout-asm-short-prog.exp: New file.

Change-Id: I6a6a7972c68a0559e9717fd8d82870b669a40af3

4 years agogdb/tui: Update help text for scroll commands
Andrew Burgess [Fri, 24 Jan 2020 14:18:56 +0000 (14:18 +0000)]
gdb/tui: Update help text for scroll commands

GDB has some commands ('+', '-', '<', and '>') for scrolling the SRC
and ASM TUI windows from the CMD window, however the help text for
these commands lists the arguments in the wrong order.

This commit updates the help text to match how GDB actually works, and
also extends the text to describe what the arguments mean, and what
the defaults are.

There should be no change in GDBs functionality after this commit.

gdb/ChangeLog:

* tui/tui-win.c (_initialize_tui_win): Update help text for '+',
'-', '<', and '>' commands.

Change-Id: Ib2624891de1f4ba983838822206304e4c3ed982e

4 years agoTidy bfd.pot
Alan Modra [Thu, 30 Jan 2020 23:51:02 +0000 (10:21 +1030)]
Tidy bfd.pot

This patch removes the leak of Nick's source directory into bfd.pot,
and emits #line for some generated files so that those files aren't
referenced by comments in the .pot file.  You can see both of these
effects in the following diff.  I've also removed use of an
unnecessary temp file in the make rules.

@@ -92,10 +92,8 @@ msgstr ""
 #: elf64-nfp.c:238 elf64-ppc.c:1014 elf64-ppc.c:1349 elf64-ppc.c:1358
 #: elf64-s390.c:328 elf64-s390.c:378 elf64-x86-64.c:285 elfn32-mips.c:3786
 #: elfxx-ia64.c:324 elfxx-riscv.c:955 elfxx-sparc.c:589 elfxx-sparc.c:639
-#: elfxx-tilegx.c:912 elfxx-tilegx.c:952
-#: /work/sources/binutils/current/bfd/elfnn-aarch64.c:2215
-#: /work/sources/binutils/current/bfd/elfnn-aarch64.c:2313 elf32-ia64.c:214
-#: elf32-ia64.c:3862 elf64-ia64.c:214 elf64-ia64.c:3862
+#: elfxx-tilegx.c:912 elfxx-tilegx.c:952 elfnn-aarch64.c:2215
+#: elfnn-aarch64.c:2313 elfnn-ia64.c:214 elfnn-ia64.c:3862
 #, c-format
 msgid "%pB: unsupported relocation type %#x"
 msgstr ""

* Makefile.am (elf32-target.h, elf64-target.h): Don't use a temp
file.  Use $< and $@ in rules.
(elf32-aarch64.c, elf64-aarch64.c): Likewise.
(elf32-ia64.c, elf64-ia64.c): Likewise.
(elf32-riscv.c, elf64-riscv.c): Likewise.
(peigen.c, pepigen.c, pex64igen.c): Likewise.
(elf32-aarch64.c, elf64-aarch64.c): Don't emit $srcdir on #line.
(elf32-riscv.c, elf64-riscv.c): Likewise, and use $(SED).
(elf32-ia64.c, elf64-ia64.c): Do emit #line.
(peigen.c, pepigen.c, pex64igen.c): Likewise.
* Makefile.in: Regenerate.

4 years agoOOM in setup_group
Alan Modra [Thu, 30 Jan 2020 14:23:59 +0000 (00:53 +1030)]
OOM in setup_group

We alloc, seek and read using section sizes in object files.  Fuzzed
objects can have silly sizes, but that's OK if the system supports
memory over-commit.  The read fails because we hit EOF and that
usually results in a graceful exit.

But if we memset before the read then the invalid size results in
attempting to write to a huge number of memory pages, and an eventual
Out Of Memory after probably swapping like crazy.  So don't memset.
There really isn't a need to clear the section contents anyway.  All
bytes are written with a good object file by the read and following
loop converting section index in target order to ELF section header
pointer, and the only untidy bytes are the 4 bytes past the group
flags when pointers are 8 bytes.  Those don't matter but the patch
clears them for anyone poking around in a debugger.  On error paths
it's as good to free section contents as it is to clear them.

Noticed when looking at PR4110 fourth test case.

PR 4110
* elf.c (setup_group): Don't clear entire section contents,
just the padding after group flags.  Release alloc'd memory
after a seek or read failure.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 31 Jan 2020 00:00:46 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agox86: prevent undue use of GOT32X and alike relocations
Jan Beulich [Thu, 30 Jan 2020 16:03:22 +0000 (17:03 +0100)]
x86: prevent undue use of GOT32X and alike relocations

Comparison of i.tm.base_opcode against particular but not sufficiently
specific values needs to be accompanied by other qualification. Exclude
VEX and alike encodings here, and also exclude all forms of prefixes
explicitly specified in the opcodes table. While using @GOT with such
insns may not be very useful, it also isn't with e.g. ADC and SBB, yet
these get explicitly listed in comments as supported.

4 years agold/doc: drop blank between @option and brace
Jan Beulich [Thu, 30 Jan 2020 16:02:33 +0000 (17:02 +0100)]
ld/doc: drop blank between @option and brace

Commit 9e7028aa1e78 ("PowerPC64 __tls_get_addr_desc") introduced a use
of @option which apparently newer makeinfo tolerates, but older ones
reject. Drop the unnecessary (a per all other uses of @option) blank.

4 years agoubsan: m32c: left shift of negative value
Alan Modra [Thu, 30 Jan 2020 11:29:20 +0000 (21:59 +1030)]
ubsan: m32c: left shift of negative value

More nonsense fixing "bugs" with left shifts of signed values.  Yes,
the C standard does say this is undefined (and right shifts of signed
values are implementation defined BTW) but in practice there is no
problem with current machines.  1's complement is a thing of the past.

cpu/
* m32c.cpu (f-src32-rn-unprefixed-QI): Shift before inverting.
(f-src32-rn-prefixed-QI, f-dst32-rn-unprefixed-QI): Likewise.
(f-dst32-rn-prefixed-QI): Likewise.
(f-dsp-32-s32): Mask before shifting left.
(f-dsp-48-u32, f-dsp-48-s32): Likewise.
(f-bitbase32-16-s11-unprefixed): Multiply signed field rather than
shifting left.
(f-bitbase32-24-s11-prefixed, f-bitbase32-24-s19-prefixed): Likewise.
(h-gr-SI): Mask before shifting.
opcodes/
* m32c-ibld.c: Regenerate.

4 years agoIdentify reproducible builds in 'objdump -p' output for PE files
Jon Turney [Wed, 15 Jan 2020 17:03:48 +0000 (17:03 +0000)]
Identify reproducible builds in 'objdump -p' output for PE files

These are produced by MSVC when the '/Brepro' flag is used.

To quote from the PE specification [1]:

"The presence of an entry of type IMAGE_DEBUG_TYPE_REPRO indicates the
PE file is built in a way to achieve determinism or reproducibility. If
the input does not change, the output PE file is guaranteed to be
bit-for-bit identical no matter when or where the PE is produced.
Various date/time stamp fields in the PE file are filled with part or
all the bits from a calculated hash value that uses PE file content as
input, and therefore no longer represent the actual date and time when a
PE file or related specific data within the PE is produced. The raw data
of this debug entry may be empty, or may contain a calculated hash value
preceded by a four-byte value that represents the hash value length."

[1] https://docs.microsoft.com/en-us/windows/win32/debug/pe-format

bfd/ChangeLog:

2020-01-16  Jon Turney  <jon.turney@dronecode.org.uk>

* peXXigen.c (pe_is_repro): New function.
(_bfd_XX_print_private_bfd_data_common): Note timestamp is
actually a build hash if PE_IMAGE_DEBUG_TYPE_REPRO is present.

4 years agoAdd some new PE_IMAGE_DEBUG_TYPE values
Jon Turney [Wed, 15 Jan 2020 18:50:31 +0000 (18:50 +0000)]
Add some new PE_IMAGE_DEBUG_TYPE values

IMAGE_DEBUG_TYPE_REPRO is defined in the latest version of the PE
specification [1]. The others are defined in Windows SDK headers and/or
reported by DUMPBIN.

[1] https://docs.microsoft.com/en-us/windows/win32/debug/pe-format

bfd/ChangeLog:

2020-01-16  Jon Turney  <jon.turney@dronecode.org.uk>

* peXXigen.c (debug_type_names): Add names for new debug data type
values.

include/ChangeLog:

2020-01-16  Jon Turney  <jon.turney@dronecode.org.uk>

* coff/internal.h (PE_IMAGE_DEBUG_TYPE_VC_FEATURE)
(PE_IMAGE_DEBUG_TYPE_POGO, PE_IMAGE_DEBUG_TYPE_ILTCG)
(PE_IMAGE_DEBUG_TYPE_MPX, PE_IMAGE_DEBUG_TYPE_REPRO): Add.

4 years agoBugfixes for pe_print_debugdata()
Jon Turney [Wed, 15 Jan 2020 18:48:13 +0000 (18:48 +0000)]
Bugfixes for pe_print_debugdata()

Use a separate iteration variable for inner loop (:blush:).  This
generally prevented any debug directory entries after a
IMAGE_DEBUG_TYPE_CODEVIEW entry from being reported.

Don't leak the memory allocated for the section containing the debug
directory.

bfd/ChangeLog:

2020-01-16  Jon Turney  <jon.turney@dronecode.org.uk>

* peXXigen.c (pe_print_debugdata): Fix the iteration variable for
inner loop.  Fix a memory leak.

4 years agocpu,opcodes,gas: fix neg and neg32 instructions in BPF
Jose E. Marchesi [Thu, 30 Jan 2020 12:59:04 +0000 (13:59 +0100)]
cpu,opcodes,gas: fix neg and neg32 instructions in BPF

This patch fixes the neg/neg32 BPF instructions, which have K (=0)
instead of X (=1) in their header source bit, despite operating on
registes.

cpu/ChangeLog:

2020-01-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

* bpf.cpu (define-alu-insn-un): The unary BPF instructions
(neg and neg32) use OP_SRC_K even if they operate only in
registers.

opcodes/ChangeLog:

2020-01-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

* bpf-opc.c: Regenerate.

gas/ChangeLog:

2020-01-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

* testsuite/gas/bpf/alu.d: Update expected opcode for `neg'.
* testsuite/gas/bpf/alu-be.d: Likewise.
* testsuite/gas/bpf/alu32.d: Likewise for `neg32'.
* testsuite/gas/bpf/alu32-be.d: Likewise.

4 years agox86-64: honor vendor specifics for near RET
Jan Beulich [Thu, 30 Jan 2020 10:36:33 +0000 (11:36 +0100)]
x86-64: honor vendor specifics for near RET

While vendors agree about default operand size (64 bits) and hence
unavilability of a 32-bit form, AMD honors a 16-bit operand size
override (0x66) while Intel doesn't.

4 years agox86-64: also diagnose far returns / IRET with ambiguous operand size
Jan Beulich [Thu, 30 Jan 2020 10:35:20 +0000 (11:35 +0100)]
x86-64: also diagnose far returns / IRET with ambiguous operand size

Other than near returns these default to 32-bit operand size, and hence
it isn't really unlikely that 64-bit forms are meant. Hence these should
have disambiguating suffixes. In Intel mode, however, don't error in
these cases unconditionally - MASM accepts these without suffix _and_
without warning.

4 years agox86: drop further pointless/bogus DefaultSize
Jan Beulich [Thu, 30 Jan 2020 10:33:53 +0000 (11:33 +0100)]
x86: drop further pointless/bogus DefaultSize

- 64-bit CALL permitting just a single operand size doesn't need it.
- FLDENV et al should never have had it.

It remains suspicious that a number of 64-bit only insns continue to
have the attribute, despite this being intended for .code16gcc handling
only.

4 years agoubsan: tic4x: left shift cannot be represented in type 'int'
Alan Modra [Thu, 30 Jan 2020 06:36:54 +0000 (17:06 +1030)]
ubsan: tic4x: left shift cannot be represented in type 'int'

The patch also fixes a case where libopcodes built for a 64-bit
bfd_vma may print different results to libopcodes built for a 32-bit
bfd_vma.

* tic4x-dis.c (tic4x_dp): Make unsigned.

4 years agoRemove need to clear obj_coff_keep_syms in coff object_p
Alan Modra [Thu, 30 Jan 2020 06:36:35 +0000 (17:06 +1030)]
Remove need to clear obj_coff_keep_syms in coff object_p

* coffgen.c (coff_real_object_p): Don't clear obj_coff_keep_syms
or obj_coff_keep_strings here.
(coff_get_normalized_symtab): Free external syms directly.
* xcofflink.c (xcoff_link_input_bfd): Restore obj_coff_keep_syms
on error exit path.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 30 Jan 2020 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoFix -Werror-stringop error on infcmd.c:construct_inferior_arguments
Pedro Alves [Wed, 29 Jan 2020 17:53:55 +0000 (12:53 -0500)]
Fix -Werror-stringop error on infcmd.c:construct_inferior_arguments

While testing a GCC 10 build of our git HEAD, Sergio noticed an error
triggered by -Werror-stringop on
infcmd.c:construct_inferior_arguments.  One of the things the function
does is calculate the length of the string that will hold the
inferior's arguments.  GCC warns us that 'length' can be 0, which can
lead to undesired behaviour:

../../gdb/infcmd.c: In function 'char* construct_inferior_arguments(int, char**)':
../../gdb/infcmd.c:369:17: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  369 |       result[0] = '\0';
      |       ~~~~~~~~~~^~~~~~
../../gdb/infcmd.c:368:33: note: at offset 0 to an object with size 0 allocated by 'xmalloc' here
  368 |       result = (char *) xmalloc (length);
      |                         ~~~~~~~~^~~~~~~~

The solution here is to assert that 'argc' is greater than 0 on entry,
which makes GCC understand that the loops always run at least once,
and thus 'length' is always > 0.

Tested by rebuilding.

gdb/ChangeLog:
2020-01-29  Pedro Alves  <palves@redhat.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>

* infcmd.c (construct_inferior_arguments): Assert that
'argc' is greater than 0.

Change-Id: Ide8407cbedcb4921de1843a6a15bbcb7676c7d26

4 years agoAdjust src-release.sh's getver due to gdbsupport's move to toplevel
Sergio Durigan Junior [Tue, 28 Jan 2020 22:21:41 +0000 (17:21 -0500)]
Adjust src-release.sh's getver due to gdbsupport's move to toplevel

The move of gdbsupport to the top level directory requires a small
change to src-release.sh's "getver" function, which is responsible for
determining the version string that will be appended to the release
tarball: now the create-version.sh script lives under ./gdbsupport,
and not under gdb/gdbsupport anymore.

This patch unbreaks the snapshot generation, which hasn't been working
since January 14th.

ChangeLog:
2020-01-29  Sergio Durigan Junior  <sergiodj@redhat.com>

* src-release.sh (getver): Look for gdbsupport's
create-version.sh script at the current directory if tool is
"gdb".

Change-Id: Id3b8bed6583a1aaa120c07009366f6c94a62d5db

4 years agogdbserver: Fix whitespace configure.srv damage for `i[34567]86-*-mingw*'
Maciej W. Rozycki [Wed, 29 Jan 2020 18:26:15 +0000 (18:26 +0000)]
gdbserver: Fix whitespace configure.srv damage for `i[34567]86-*-mingw*'

Fix fallout from commit 42cd72aa0279 ("gdbserver: Make `make TAGS'
actually work") add a missing newline to configure.srv for
`i[34567]86-*-mingw*'.

gdb/gdbserver/
* configure.srv <i[34567]86-*-mingw*>: Fix whitespace damage.

4 years agoFix configure.srv error for Linux on PowerPC
Pedro Franco de Carvalho [Wed, 29 Jan 2020 17:42:40 +0000 (14:42 -0300)]
Fix configure.srv error for Linux on PowerPC

An error in commit 42cd72aa0279520384327a1f6d0ebd2eb2200645 caused
srv_tgtobj to be overwritten and linux-ppc-low.o to be missed when
linking gdbserver for Linux on PowerPC.  This patch fixes the error.

gdb/gdbserver/ChangeLog:
2020-01-29  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

* configure.srv (powerpc*-*-linux*): Use srv_tgtobj in second
assignment instead of srv_linux_obj.

4 years agoTest handling of additional brk instruction patterns
Luis Machado [Mon, 13 Jan 2020 15:31:01 +0000 (12:31 -0300)]
Test handling of additional brk instruction patterns

New in v5:

- Use gdb_test_name for gdb_test_multiple.
- Use gdb_assert.
- Verify count matches the expected sigtraps exactly.

New in v4:

- Fix formatting nit in gdb/testsuite/gdb.arch/aarch64-brk-patterns.c.

New in v3:

- Minor formatting and code cleanups.
- Added count check to validate number of brk SIGTRAP's.
- Moved count to SIGTRAP check conditional block.

This test exercises the previous patch's code and makes sure GDB can
properly get a SIGTRAP from various brk instruction patterns.

GDB needs to be able to see the program exiting normally. If GDB doesn't
support the additional brk instructions, we will see timeouts.

We bail out with the first timeout since we won't be able to step through
the program breakpoint anyway, so it is no use carrying on.

gdb/testsuite/ChangeLog:

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

* gdb.arch/aarch64-brk-patterns.c: New source file.
* gdb.arch/aarch64-brk-patterns.exp: New test.

4 years agoRecognize more program breakpoint patterns
Luis Machado [Mon, 23 Dec 2019 15:04:26 +0000 (12:04 -0300)]
Recognize more program breakpoint patterns

New in v3:

- Code cleanups based on reviews.

New in v2:

- Fixed misc problems based on reviews.
- Switched to using gdbarch_program_breakpoint_here_p as opposed to
gdbarch_insn_is_breakpoint.
- Fixed matching of brk instructions. Previously the mask was incorrect, which
was showing up as a few failures in the testsuite. Now it is clean.
- New testcase (separate patch).
- Moved program_breakpoint_here () to arch-utils.c and made it the default
implementation of gdbarch_program_breakpoint_here_p.

--

It was reported to me that program breakpoints (permanent ones inserted into
the code itself) other than the one GDB uses for AArch64 (0xd4200000) do not
generate visible stops when continuing, and GDB will continue spinning
infinitely.

This happens because GDB, upon hitting one of those program breakpoints, thinks
the SIGTRAP came from a delayed breakpoint hit...

(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk     #0x90f
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 14198)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 14198
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14198.14198.0 [process 14198],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14198.14198.0 [process 14198],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14198.14198.0 [process 14198],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14198.14198.0 [process 14198],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14198.14198.0 [process 14198],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
...

... which is not the case.

If the program breakpoint is one GDB recognizes, then it will stop when it
hits it.

(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk     #0x0
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 14193)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 14193
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14193] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14193.14193.0 [process 14193],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: random signal (GDB_SIGNAL_TRAP)
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun:   process 14193 not executing
infrun: stop_all_threads, pass=1, iterations=1
infrun:   process 14193 not executing
infrun: stop_all_threads done

Program received signal SIGTRAP, Trace/breakpoint trap.
problem_function () at brk_0.c:7
7        asm("brk %0\n\t" ::"n"(0x0));
infrun: infrun_async(0)

Otherwise GDB will keep trying to resume the inferior and will keep
seeing the SIGTRAP's, without stopping.

To the user it appears GDB has gone into an infinite loop, interruptible only
by Ctrl-C.

Also, windbg seems to use a different variation of AArch64 breakpoint compared
to GDB. This causes problems when debugging Windows on ARM binaries, when
program breakpoints are being used.

The proposed patch creates a new gdbarch method (gdbarch_program_breakpoint_here_p)
that tells GDB whether the underlying instruction is a breakpoint instruction
or not.

This is more general than only checking for the instruction GDB uses as
breakpoint.

The existing logic is still preserved for targets that do not implement this
new gdbarch method.

The end result is like so:

(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk     #0x90f
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 16417)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 16417
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 16417] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   16417.16417.0 [process 16417],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: random signal (GDB_SIGNAL_TRAP)
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun:   process 16417 not executing
infrun: stop_all_threads, pass=1, iterations=1
infrun:   process 16417 not executing
infrun: stop_all_threads done

Program received signal SIGTRAP, Trace/breakpoint trap.
problem_function () at brk.c:7
7        asm("brk %0\n\t" ::"n"(0x900 + 0xf));
infrun: infrun_async(0)

gdb/ChangeLog:

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

* aarch64-tdep.c (BRK_INSN_MASK): Define to 0xffe0001f.
(BRK_INSN_MASK): Define to 0xd4200000.
(aarch64_program_breakpoint_here_p): New function.
(aarch64_gdbarch_init): Set gdbarch_program_breakpoint_here_p hook.
* arch-utils.c (default_program_breakpoint_here_p): Moved from
breakpoint.c.
* arch-utils.h (default_program_breakpoint_here_p): Moved from
breakpoint.h
* breakpoint.c (bp_loc_is_permanent): Changed return type to bool and
call gdbarch_program_breakpoint_here_p.
(program_breakpoint_here): Moved to arch-utils.c, renamed to
default_program_breakpoint_here_p, changed return type to bool and
simplified.
* breakpoint.h (program_breakpoint_here): Moved prototype to
arch-utils.h, renamed to default_program_breakpoint_here_p and changed
return type to bool.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (program_breakpoint_here_p): New method.
* infrun.c (handle_signal_stop): Call
gdbarch_program_breakpoint_here_p.

4 years agotestsuite, cp: add expected failures to pass-by-ref tests for certain compilers
Tankut Baris Aktemur [Wed, 29 Jan 2020 08:05:20 +0000 (09:05 +0100)]
testsuite, cp: add expected failures to pass-by-ref tests for certain compilers

There exist expected failures in the pass-by-ref.exp and
pass-by-ref-2.exp tests based on the GCC and Clang version.

* GCC version <= 6 and Clang do not emit DW_AT_deleted and
  DW_AT_defaulted.

* Clang version >= 7 emits DW_AT_calling_convention, which helps the
  debugger make the right calling convention decision in some cases
  despite lacking the 'defaulted' and 'deleted' attributes.

Mark the related tests as XFAIL based on the compiler version.

Tested on X86_64 using GCC 5.5.0, 6.5.0, 7.4.0, 8.3.0, 9.2.1;
and Clang 5.0.1, 6.0.0, 7.0.0, 8.0.0, 9.0.1, 10.0.0.

gdb/testsuite/ChangeLog:
2020-01-29  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.cp/pass-by-ref-2.exp: Mark some tests as XFAIL based on the
GCC/Clang version.
* gdb.cp/pass-by-ref.exp: Ditto.

Change-Id: I1d8440aa438049f7c4da7f4f76f201c48550f1e4

4 years ago[gdb/testsuite] Fix gdb.threads/watchpoint-fork.exp race
Tom de Vries [Wed, 29 Jan 2020 07:48:53 +0000 (08:48 +0100)]
[gdb/testsuite] Fix gdb.threads/watchpoint-fork.exp race

I ran into:
...
Thread 3.1 "watchpoint-fork" hit Breakpoint 3, marker () at \
  watchpoint-fork-mt.c:42^M
42      }^M
(gdb) parent2: 1945^M

FAIL: gdb.threads/watchpoint-fork.exp: child: multithreaded: breakpoint (A) \
  after the second fork (timeout)
...
The problem is that the FAILing gdb_test expects '(gdb) ' to be the last thing
printed, but the inferior prints something after that.

A similar FAIL is described in the sources in watchpoint-fork-parent.c:
...
      printf ("child%d: %d\n", nr, (int) getpid ());
      /* Delay to get both the "child%d" and "parent%d" message printed
        without a race breaking expect by its endless wait on `$gdb_prompt$':
         Breakpoint 3, marker () at watchpoint-fork.c:33
         33      }
         (gdb) parent2: 14223  */
      i = sleep (1);
...

I noticed that while the executables print output, the output is not verified in
the test-case, so it's merely debug output.

Fix this by:
- guarding the prints in the executables (as well as related
  sleep and setbuf calls) with #if DEBUG, and
- compiling by default with DEBUG=0.

gdb/testsuite/ChangeLog:

2020-01-29  Tom de Vries  <tdevries@suse.de>

* gdb.threads/watchpoint-fork-child.c: Guard prints with #if DEBUG.
* gdb.threads/watchpoint-fork-mt.c: Same.
* gdb.threads/watchpoint-fork-parent.c: Same.
* gdb.threads/watchpoint-fork-st.c: Same.
* gdb.threads/watchpoint-fork.exp: Compile with DEBUG=0.

Change-Id: I63efd4c7771f96b5f5cd87ef2ab36795484ae2be

4 years agoPR25477, ld 2.34 tries to load ${prefix}/etc/ld.so.conf
Alan Modra [Tue, 28 Jan 2020 23:55:58 +0000 (10:25 +1030)]
PR25477, ld 2.34 tries to load ${prefix}/etc/ld.so.conf

PR 25477
* ldelf.c (ldelf_check_ld_so_conf): Add prefix parameter and
correct concat.
(ldelf_after_open): Add prefix parameter.
* ldelf.h (ldelf_after_open): Update prototype.
* emultempl/elf.em (gld${EMULATION_NAME}_after_open): Pass $prefix
to ldelf_after_open.
* Makefile.am: Correct z80 dependencies.
* Makefile.in: Regenerate.

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

4 years agoFix library segment-address for 64bit values
Hannes Domani [Tue, 28 Jan 2020 17:24:31 +0000 (18:24 +0100)]
Fix library segment-address for 64bit values

The address was written as a long value, but long is always a 32bit value
on Windows, which lead to truncated addresses.
The solution was to use paddress instead.

gdb/gdbserver/ChangeLog:

2020-01-28  Hannes Domani  <ssbssa@yahoo.de>

* server.c (handle_qxfer_libraries): Write segment-address with
paddress.

4 years agoImprove warning message from debuginfod support in readelf.
Nick Clifton [Tue, 28 Jan 2020 11:30:55 +0000 (11:30 +0000)]
Improve warning message from debuginfod support in readelf.

* readelf.c (get_build_id): Simplify warning message about corrupt
notes encountered whilst scanning for the build-id.

4 years agoDon't report symbol lookup failure in first phase of linking
Alan Modra [Mon, 27 Jan 2020 23:37:46 +0000 (10:07 +1030)]
Don't report symbol lookup failure in first phase of linking

Until the symbol table is created, symbols can't be created.

* ldexp.c (fold_name): Don't print bfd_link_hash_lookup failed
in first phase.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 28 Jan 2020 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoRISC-V: Fix gdbserver problem with handling arch strings.
Jim Wilson [Mon, 27 Jan 2020 23:19:30 +0000 (15:19 -0800)]
RISC-V: Fix gdbserver problem with handling arch strings.

Maciej reported a problem found by his RISC-V gdbserver port.
warning: while parsing target description (at line 4): Target description specified unknown architecture "riscv:rv64id"
warning: Could not load XML target description; ignoring

We only have two arches defined, riscv:rv32 and riscv:rv64.  Both bfd and
gdb are creating arch strings that have extension letters added to the base
architecture.  The bfd_default_scan function requires an exact match, so
these strings fail to map to a bfd_arch.  I think we should ignore the
extension letters in a RISC-V specific scan function.

bfd/
* cpu-riscv.c (riscv_scan): New.
(N): Change bfd_default_scan to riscv_scan.

Change-Id: I096476705e1da5cb8934c5005b1eed2a8989f7a7

4 years agoHarden gdb.base/step-over-syscall.exp
Luis Machado [Tue, 14 Jan 2020 16:46:07 +0000 (13:46 -0300)]
Harden gdb.base/step-over-syscall.exp

New in v3:
- Verify if the syscall number matches what is expected for the target.
- Used gdb_assert for one more check.

New in v2:

- Set initial values to -1 instead of 0.
- Rewrote RE to prevent unexpected matching when parsing one character at a
  time.
- Used gdb_assert for an additional check.
- Validated with check-read1

There are a couple problems with this test.

First
--

gdb.base/step-over-syscall.exp records the address of a syscall instruction
within fork/vfork/clone functions and also the address of the instruction
after that syscall instruction.

It uses these couples addresses to make sure we stepped over a syscall
instruction (fork/vfork/clone events) correctly.

The way the test fetches the addresses of the instructions is by stepi-ing
its way through the fork/vfork/clone functions until it finds a match for
a syscall. Then it stepi's once again to get the address of the next
instruction.

This assumes that stepi-ing over a syscall is working correctly and landing
in the right PC. This is not the case for AArch64/Linux, where we're
landing a couple instructions after the syscall in some cases.

The following patch lets the test execute as before, but adds a new instruction
address check using the x command as opposed to stepi.

I didn't want to change how the test works since we may also be
interested in checking if stepi-ing over the syscall under different
conditions (displaced stepping on/off) yields the same results. I don't
feel strongly about this, so i'm OK with changing how we compare PC's for
the entire test if folks decide it is reasonable.

Second
--

FAIL: gdb.base/step-over-syscall.exp: vfork: displaced=off: continue to vfork (3rd time) (the program exited)
FAIL: gdb.base/step-over-syscall.exp: vfork: displaced=off: continue to syscall insn vfork (the program is no longer running)
FAIL: gdb.base/step-over-syscall.exp: vfork: displaced=off: single step over vfork (the program is no longer running)

Depending on the glibc version we may have different code generated for the
fork/vfork/clone functions.

I ran into the situation where vfork for newer glibc's on AArch64/Linux is
very short, so "break vfork" will put a breakpoint right at the syscall
instruction, which is something the testcase isn't expecting (a off-by-1
of sorts).

The patch adds extra code to handle this case. If the test detects we're
already sitting at a syscall instruction, it records the address and moves
on to record the address after that particular instruction.

Another measure is to "break *$syscall" instead of "break $syscall". That
guarantees we're stopping at the first instruction of the syscall function,
if it ever happens that the syscall instruction is the first instruction of
those functions.

With these changes i can fix some failures for aarch64-linux-gnu and also
expose the problems i've reported here:

https://sourceware.org/ml/gdb-patches/2019-12/msg01071.html

These tests now fail for aarch64-linux-gnu (patch for this is going through
reviews):

FAIL: gdb.base/step-over-syscall.exp: vfork: displaced=off: pc after stepi matches insn addr after syscall
FAIL: gdb.base/step-over-syscall.exp: vfork: displaced=on: pc after stepi matches insn addr after syscall

gdb/testsuite/ChangeLog:

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

* gdb.base/step-over-syscall.exp (setup): Check if we're already
sitting at a syscall instruction when we hit the syscall function's
breakpoint.
Check PC against one obtained with the x command.
Validate syscall number.
(step_over_syscall): Don't continue to the syscall instruction if
we're already there.

4 years agoFix objcopy --merge-notes dependency on qsort implementation behavior.
Roland McGrath [Mon, 27 Jan 2020 19:14:33 +0000 (11:14 -0800)]
Fix objcopy --merge-notes dependency on qsort implementation behavior.

binutils/
* objcopy.c (compare_gnu_build_notes): Fix comparison results
for overlapping ranges so that (A == B) == (B == A) holds.

4 years agoRemove cpu-plugin.c
Andreas Schwab [Mon, 27 Jan 2020 13:09:00 +0000 (14:09 +0100)]
Remove cpu-plugin.c

After commit 999d6dff80f cpu-plugin.c is no longer begin used.

* Makefile.am (ALL_MACHINES): Remove cpu-plugin.lo.
(ALL_MACHINES_CFILES): Remove cpu-plugin.c.
* Makefile.in: Regenerate.
* cpu-plugin.c: Remove.
* archures.c (enum bfd_architecture): Remove bfd_arch_plugin.
(bfd_plugin_arch): Remove declaration.
* bfd-in2.h: Regenerate.
* po/SRC-POTFILES.in: Regenerate.

4 years agox86-64: Properly encode and decode movsxd
H.J. Lu [Mon, 27 Jan 2020 12:38:10 +0000 (04:38 -0800)]
x86-64: Properly encode and decode movsxd

movsxd is a 64-bit only instruction.  It supports both 16-bit and 32-bit
destination registers.  Its AT&T mnemonic is movslq which only supports
64-bit destination register.  There is also a discrepancy between AMD64
and Intel64 on movsxd with 16-bit destination register.  AMD64 supports
32-bit source operand and Intel64 supports 16-bit source operand.

This patch updates movsxd encoding and decoding to alow 16-bit and 32-bit
destination registers.  It also handles movsxd with 16-bit destination
register for AMD64 and Intel 64.

gas/

PR binutils/25445
* config/tc-i386.c (check_long_reg): Also convert to QWORD for
movsxd.
* doc/c-i386.texi: Add a node for AMD64 vs. Intel64 ISA
differences.  Document movslq and movsxd.
* testsuite/gas/i386/i386.exp: Run PR binutils/25445 tests.
* testsuite/gas/i386/x86-64-movsxd-intel.d: New file.
* testsuite/gas/i386/x86-64-movsxd-intel64-intel.d: Likewise.
* testsuite/gas/i386/x86-64-movsxd-intel64-inval.l: Likewise.
* testsuite/gas/i386/x86-64-movsxd-intel64-inval.s: Likewise.
* testsuite/gas/i386/x86-64-movsxd-intel64.d: Likewise.
* testsuite/gas/i386/x86-64-movsxd-intel64.s: Likewise.
* testsuite/gas/i386/x86-64-movsxd-inval.l: Likewise.
* testsuite/gas/i386/x86-64-movsxd-inval.s: Likewise.
* testsuite/gas/i386/x86-64-movsxd.d: Likewise.
* testsuite/gas/i386/x86-64-movsxd.s: Likewise.

opcodes/

PR binutils/25445
* i386-dis.c (MOVSXD_Fixup): New function.
(movsxd_mode): New enum.
(x86_64_table): Use MOVSXD_Fixup and movsxd_mode on movsxd.
(intel_operand_size): Handle movsxd_mode.
(OP_E_register): Likewise.
(OP_G): Likewise.
* i386-opc.tbl: Remove Rex64 and allow 32-bit destination
register on movsxd.  Add movsxd with 16-bit destination register
for AMD64 and Intel64 ISAs.
* i386-tbl.h: Regenerated.

4 years agoReplace deprecated tcl case statements with switch statements
Alan Modra [Mon, 27 Jan 2020 00:21:52 +0000 (10:51 +1030)]
Replace deprecated tcl case statements with switch statements

binutils/
* testsuite/lib/binutils-common.exp (big_or_little_endian): Replace
case statement with switch statement.
gas/
* testsuite/gas/all/gas.exp: Replace case statements with switch
statements.
* testsuite/gas/elf/elf.exp: Likewise.
* testsuite/gas/macros/macros.exp: Likewise.
* testsuite/lib/gas-defs.exp: Likewise.
ld/
* testsuite/ld-elfvers/vers.exp: Replace case statements with
switch statements.
* testsuite/ld-ifunc/ifunc.exp: Likewise.
* testsuite/ld-unique/unique.exp: Likewise.

4 years agoAArch64: Fix cfinv disassembly issues
Tamar Christina [Mon, 27 Jan 2020 10:40:02 +0000 (10:40 +0000)]
AArch64: Fix cfinv disassembly issues

This fixes the preferred disassembly for cfinv.  The Armv8.4-a instruction
overlaps with the possible encoding space for msr.  This because msr allows you
to use unallocated encoding space using the general sA_B_cC_cD_E form.

However when an encoding does become allocated then we need to ensure that it's
used as the preferred disassembly.  The problem with cfinv is that its mask has
all bits sets because it has no arguments.

This causes issues for the Alias resolver in gas as it uses the mask to build
alias graph.  In this case it can't do it since it thinks almost everything
would alias with cfinv.  So instead we can only fix this by moving cfinv before
msr.

gas/ChangeLog:

PR 25403
* testsuite/gas/aarch64/armv8_4-a.d: Add cfinv.
* testsuite/gas/aarch64/armv8_4-a.s: Likewise.

opcodes/ChangeLog:

PR 25403
* aarch64-tbl.h (struct aarch64_opcode): Re-order cfinv.
* aarch64-asm-2.c: Regenerate
* aarch64-dis-2.c: Likewise.
* aarch64-opc-2.c: Likewise.

4 years agoTwo minor changes in ctfread.c
Tom Tromey [Mon, 27 Jan 2020 01:43:17 +0000 (18:43 -0700)]
Two minor changes in ctfread.c

I noticed a couple of minor issues in ctfread.c, both fixed by this
patch:

* ctf_fp_info was not indented properly; and
* _initialize_ctfread is no longer needed

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

* ctfread.c (struct ctf_fp_info): Reindent.
(_initialize_ctfread): Remove.

Change-Id: I72707b74bc59e6e426b3a7bc8843d96c0d786f1e

4 years agoMark all weak aliases for copy relocations
Alan Modra [Sun, 26 Jan 2020 23:57:42 +0000 (10:27 +1030)]
Mark all weak aliases for copy relocations

bfd/
PR ld/25458
* elflink.c (_bfd_elf_gc_mark_rsec): Mark all weak aliases.
ld/
PR ld/25458
* testsuite/ld-elf/pr25458.map: New file.
* testsuite/ld-elf/pr25458.rd: Likewise.
* testsuite/ld-elf/pr25458a.s: Likewise.
* testsuite/ld-elf/pr25458b.s: Likewise.
* testsuite/ld-elf/shared.exp: Run PR ld/25458 test.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 27 Jan 2020 00:00:49 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoVirtualize "readin" and "compunit_symtab"
Tom Tromey [Wed, 23 Oct 2019 15:50:58 +0000 (09:50 -0600)]
Virtualize "readin" and "compunit_symtab"

This patch removes the "readin" and "compunit_symtab" members from
partial_symtab, replacing them with methods.  Then it introduces a new
"standard_psymtab" class, which restores these members; and changes
the symbol readers to use this intermediate class as the base class of
their partial symtab subclasses.

The reason for this is to make it possible for a symbol reader to
implement an alternate mapping between partial and full symbol tables.
This is important in order to be able to share psymtabs across
objfiles -- whether a psymtab has been "readin" is objfile-dependent,
as are the pointers to the full symbol tables.

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

* psymtab.c (partial_map_expand_apply)
(psym_find_pc_sect_compunit_symtab, psym_lookup_symbol)
(psymtab_to_symtab, psym_find_last_source_symtab, dump_psymtab)
(psym_print_stats, psym_expand_symtabs_for_function)
(psym_map_symbol_filenames, psym_map_matching_symbols)
(psym_expand_symtabs_matching)
(partial_symtab::read_dependencies, maintenance_info_psymtabs)
(maintenance_check_psymtabs): Use new methods.
* psympriv.h (struct partial_symtab) <readin_p,
get_compunit_symtab>: New methods.
<readin, compunit_symtab>: Remove members.
(struct standard_psymtab): New.
(struct legacy_psymtab): Derive from standard_psymtab.
* dwarf2read.h (struct dwarf2_psymtab): Derive from
standard_psymtab.
* ctfread.c (struct ctf_psymtab): Derive from standard_psymtab.

Change-Id: Idb923f196d7e03bf7cb9cfc8134ed06dd3f211ce

4 years agoConsolidate partial symtab dependency reading
Tom Tromey [Wed, 23 Oct 2019 15:46:25 +0000 (09:46 -0600)]
Consolidate partial symtab dependency reading

Most of the symbol readers have code to iterate over a partial symtabs
dependencies, expanding each one and optionally printing a message.
Now that the "second-stage" psymtab expansion is available as a
method, these implementations can all be merged.

This patch also changes a couple more warnings into assertions.

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

* xcoffread.c (xcoff_psymtab_to_symtab_1): Call
read_dependencies.  Add assert.
* psymtab.c (partial_symtab::read_dependencies): New method.
* psympriv.h (struct partial_symtab) <read_dependencies>: New
method.
* mdebugread.c (psymtab_to_symtab_1): Call read_dependencies.
* dwarf2read.c (dwarf2_psymtab::expand_psymtab): Call
read_dependencies.
* dbxread.c (dbx_psymtab_to_symtab_1): Call read_dependencies.
Add assert.

Change-Id: I8151e05677794e90223edc1a4cb70f7f69137d46

4 years agoIntroduce partial_symtab::expand_psymtab method
Tom Tromey [Wed, 23 Oct 2019 15:40:54 +0000 (09:40 -0600)]
Introduce partial_symtab::expand_psymtab method

The symbol readers generally used two functions to expand a partial
symtab: an outer function (now the "read_symtab" method), and an inner
function, typically named something like "psymtab_to_symtab".

This patch changes this second step to be a method on partial_symtab,
and updates all the callers.  For legacy_psymtab, a new function
pointer member is introduced.

This patch enables a subsequent cleanup.

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

* xcoffread.c (xcoff_psymtab_to_symtab_1): Change argument order.
Call expand_psymtab.
(xcoff_read_symtab): Call expand_psymtab.
(xcoff_start_psymtab, xcoff_end_psymtab): Set
legacy_expand_psymtab.
* psympriv.h (struct partial_symtab) <expand_psymtab>: New
method.
(struct legacy_psymtab) <expand_psymtab>: Implement.
<legacy_expand_psymtab>: New member.
* mdebugread.c (mdebug_read_symtab): Call expand_psymtab.
(parse_partial_symbols): Set legacy_expand_psymtab.
(psymtab_to_symtab_1): Change argument order.  Call
expand_psymtab.
(new_psymtab): Set legacy_expand_psymtab.
* dwarf2read.h (struct dwarf2_psymtab) <expand_psymtab>: Declare.
* dwarf2read.c (dwarf2_psymtab::read_symtab): Call
expand_psymtab.
(dwarf2_psymtab::expand_psymtab): Rename from
psymtab_to_symtab_1.  Call expand_psymtab.
* dbxread.c (start_psymtab): Set legacy_expand_psymtab.
(dbx_end_psymtab): Likewise.
(dbx_psymtab_to_symtab_1): Change argument order. Call
expand_psymtab.
(dbx_read_symtab): Call expand_psymtab.
* ctfread.c (struct ctf_psymtab) <expand_psymtab>: Declare.
(ctf_psymtab::expand_psymtab): Rename from psymtab_to_symtab.
(ctf_psymtab::read_symtab): Call expand_psymtab.

Change-Id: Ic39a2d7aa7b424088d910b59dbd21271fa1c3430

4 years agoConsolidate psymtab "Reading" messages
Tom Tromey [Wed, 23 Oct 2019 03:13:10 +0000 (21:13 -0600)]
Consolidate psymtab "Reading" messages

Each symbol reader implemented its own "Reading..." messages, and most
of them double-checked that a previously-expanded psymtab could not be
re-read.

This patch consolidates the message-printing, and changes these checks
into asserts.

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

* xcoffread.c (xcoff_read_symtab): Remove prints.  Add assert.
* psymtab.c (psymtab_to_symtab): Print verbose "Reading"
messages.
* mdebugread.c (mdebug_read_symtab): Remove prints.
* dwarf2read.c (dwarf2_psymtab::read_symtab): Remove prints.  Add
assert.
* dbxread.c (dbx_read_symtab): Remove prints.  Add assert.

Change-Id: I795be9710d42708299bb7b44972cffd27aec9413

4 years agoIntroduce partial_symtab::read_symtab method
Tom Tromey [Tue, 22 Oct 2019 23:28:37 +0000 (17:28 -0600)]
Introduce partial_symtab::read_symtab method

This introduces a new partial_symtab::read_symtab method, and updates
the symbol readers to subclass partial_symtab and implement this
method.  The old read_symtab and read_symtab_private members are
removed.

In practice, only DWARF and CTF are truly updated to take advantage of
the new setup.  The other symbol readers are less actively maintained,
and so this patch also introduces a "legacy_psymtab", which
essentially works the same way as the old partial_symtab.

(Note that, without more knowledge of the interaction between these
symbol readers, fixing this to remove the new (small) overhead is not
trivial, because these readers copy the read_symtab pointer between
partial symtabs.)

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

* xcoffread.c (this_symtab_psymtab, read_xcoff_symtab)
(xcoff_psymtab_to_symtab_1, xcoff_read_symtab)
(xcoff_start_psymtab, xcoff_end_psymtab, scan_xcoff_symtab): Use
legacy_symtab.
* stabsread.h (dbx_end_psymtab): Use legacy_symtab.
* psymtab.c (psymtab_to_symtab): Call method.
(dump_psymtab): Update.
* psympriv.h (struct partial_symtab): Add virtual destructor.
<read_symtab>: New method.
(struct legacy_symtab): New.
* mdebugread.c (mdebug_read_symtab): Use legacy_psymtab.
(struct pst_map) <pst>: Now a legacy_psymtab.
(parse_procedure, parse_partial_symbols, psymtab_to_symtab_1)
(new_psymtab): Use legacy_psymtab.
* dwarf2read.h (struct dwarf2_psymtab): New.
(struct dwarf2_per_cu_data) <psymtab>: Use it.
* dwarf2read.c (dwarf2_create_include_psymtab)
(dwarf2_build_include_psymtabs, create_type_unit_group)
(create_partial_symtab, process_psymtab_comp_unit_reader)
(build_type_psymtabs_reader, build_type_psymtab_dependencies)
(set_partial_user): Use dwarf2_psymtab.
(dwarf2_psymtab::read_symtab): Rename from dwarf2_read_symtab.
(psymtab_to_symtab_1, process_full_comp_unit)
(process_full_type_unit, dwarf2_ranges_read)
(dwarf2_get_pc_bounds, psymtab_include_file_name)
(dwarf_decode_lines): Use dwarf2_psymtab.
* dwarf-index-write.c (psym_index_map): Use dwarf2_psymtab.
(add_address_entry_worker, write_one_signatured_type)
(recursively_count_psymbols, recursively_write_psymbols)
(write_one_signatured_type, psyms_seen_size, write_gdbindex)
(write_debug_names): Likewise.
* dbxread.c (struct header_file_location): Take a legacy_psymtab.
<pst>: Now a legacy_psymtab.
(find_corresponding_bincl_psymtab): Return a legacy_psymtab.
(read_dbx_symtab, start_psymtab, dbx_end_psymtab)
(dbx_psymtab_to_symtab_1, read_ofile_symtab): Use legacy_psymtab.
* ctfread.c (struct ctf_psymtab): New.
(ctf_start_symtab, ctf_end_symtab, psymtab_to_symtab): Take a
ctf_psymtab.
(ctf_psymtab::read_symtab): Rename from ctf_read_symtab.
(create_partial_symtab): Return a ctf_psymtab.
(scan_partial_symbols): Update.

Change-Id: Ia57a828786867d6ad03200af8f996f48ed15285e

4 years agoTurn start_psymtab_common into a constructor
Tom Tromey [Tue, 22 Oct 2019 23:08:16 +0000 (17:08 -0600)]
Turn start_psymtab_common into a constructor

This turns start_psymtab_common into a constructor, and then changes
the callers to use "new" directly.  This completes the psymtab
allocation transition -- now it is possible for symbol readers to
subclass struct partial_symtab.

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

* xcoffread.c (xcoff_start_psymtab): Use new.
* psymtab.c (partial_symtab::partial_symtab): New constructor,
renamed from start_psymtab_common.
* psympriv.h (struct partial_symtab): Add new constructor.
(start_psymtab_common): Don't declare.
* mdebugread.c (parse_partial_symbols): Use new.
* dwarf2read.c (create_partial_symtab): Use new.
* dbxread.c (start_psymtab): Use new.
* ctfread.c (create_partial_symtab): Use new.

Change-Id: I5a0217bcb52bcfa442559771954bb66bd9ccbf02