binutils-gdb.git
4 years agoaarch64: Add base support for Armv8-R
Alex Coplan [Tue, 8 Sep 2020 13:13:45 +0000 (14:13 +0100)]
aarch64: Add base support for Armv8-R

This patch adds the basic infrastructure needed to support Armv8-R in
AArch64 binutils: new command-line flags, new feature bits, a new BFD
architecture, and support for differentiating between architecture
variants in the disassembler.

The new command-line options added by this patch are -march=armv8-r in
GAS and -m aarch64:armv8-r in objdump.

The disassembler support is necessary since Armv8-R AArch64 introduces a
system register (VSCTLR_EL2) which shares an encoding with a different
system register (TTBR0_EL2) in Armv8-A. This also allows us to use the
correct preferred disassembly for the new DFB alias introduced in
Armv8-R.

bfd/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

* archures.c (bfd_mach_aarch64_8R): New.
* bfd-in2.h: Regenerate.
* cpu-aarch64.c (bfd_aarch64_arch_v8_r): New.
(bfd_aarch64_arch_ilp32): Update tail pointer.

gas/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

* config/tc-aarch64.c (aarch64_archs): Add armv8-r.
* doc/c-aarch64.texi: Document -march=armv8-r.

include/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

* opcode/aarch64.h (AARCH64_FEATURE_V8_A): New.
(AARCH64_FEATURE_V8_R): New.
(AARCH64_ARCH_V8): Include new A-profile feature bit.
(AARCH64_ARCH_V8_R): New.

opcodes/ChangeLog:

2020-09-08  Alex Coplan  <alex.coplan@arm.com>

* aarch64-dis.c (arch_variant): New.
(determine_disassembling_preference): Disassemble according to
arch variant.
(select_aarch64_variant): New.
(print_insn_aarch64): Set feature set.

4 years agoPR26580, Size and alignment of commons vs as-needed shared lib
Alan Modra [Tue, 8 Sep 2020 03:32:31 +0000 (13:02 +0930)]
PR26580, Size and alignment of commons vs as-needed shared lib

Two pieces to this puzzle:
1) Revert HJ's fix for PR13250 so that size and alignment isn't
   sticky, instead attack the real underlying problem that
   _bfd_generic_link_add_one_symbol does the wrong thing in making a
   common section in a shared library bfd.
2) Save and restore common u.c.p fields, which hold the section and
   alignment.

A better fix for (2) would be to throw away all of that horrible code
saving and restoring the hash table when loading as-needed library
symbols, and instead do a scan over as-needed library symbols before
adding anything.

bfd/
PR 13250
PR 26580
* elflink.c (_bfd_elf_merge_symbol): Make "override" a bfd**.
Return oldbfd in override when old common should override new
common.
(_bfd_elf_add_default_symbol): Adjust to suit.
(elf_link_add_object_symbols): Likewise.  Pass "override" to
_bfd_generic_link_add_one_symbol.  Save and restore common u.c.p
field for --as-needed shared libraries.  Revert pr13250 changes.
ld/
* testsuite/ld-elf/pr26580-a.s,
* testsuite/ld-elf/pr26580-b.s,
* testsuite/ld-elf/pr26580-1.sd,
* testsuite/ld-elf/pr26580-2.sd: New tests
* testsuite/ld-elf/comm-data.exp: Run new tests.
* testsuite/ld-elf/pr26580-a.c,
* testsuite/ld-elf/pr26580-b.c,
* testsuite/ld-elf/pr26580-3.out,
* testsuite/ld-elf/pr26580-4.out: New tests.
* testsuite/ld-elf/shared.exp: Run new tests.

4 years agosync libiberty from gcc
Alan Modra [Tue, 8 Sep 2020 09:27:15 +0000 (18:57 +0930)]
sync libiberty from gcc

config/
Sync from gcc
2020-07-15  H.J. Lu  <hjl.tools@gmail.com>
PR bootstrap/96202
* cet.m4 (GCC_CET_HOST_FLAGS): Don't enable CET without CET
support in stage1 nor for build support.
libiberty/
* configure: Regenerate.

Sync from gcc
2020-09-08  Alan Modra  <amodra@gmail.com>
* d-demangle.c: Include limits.h.
(ULONG_MAX, UINT_MAX): Provide fall-back definition.
(dlang_number): Simplify and correct overflow test.  Only
write *ret on returning non-NULL.  Make "ret" an unsigned long*.
Only succeed for result of [0,UINT_MAX].
(dlang_decode_backref): Simplify and correct overflow test.
Only write *ret on returning non-NULL.  Only succeed for
result [1,MAX_LONG].
(dlang_backref): Remove now unnecessary range check.
(dlang_symbol_name_p): Likewise.
(string_need): Take a size_t n arg, and use size_t tem.
(string_append): Use size_t n.
(string_appendn, string_prependn): Take a size_t n arg.
(TEMPLATE_LENGTH_UNKNOWN): Define as -1UL.
(dlang_lname, dlang_parse_template): Take an unsigned long len
arg.
(dlang_symbol_backref, dlang_identifier, dlang_parse_integer),
(dlang_parse_integer, dlang_parse_string),
(dlang_parse_arrayliteral, dlang_parse_assocarray),
(dlang_parse_structlit, dlang_parse_tuple),
(dlang_template_symbol_param, dlang_template_args): Use
unsigned long variables.
* testsuite/d-demangle-expected: Add new tests.

2020-08-04  Iain Buclaw  <ibuclaw@gdcproject.org>
* d-demangle.c (dlang_function_args): Handle 'in' and 'in ref'
parameter storage classes.
(dlang_type): Remove identifier type.
* testsuite/d-demangle-expected: Update tests.

2020-08-03  Richard Biener  <rguenther@suse.de>
PR lto/96385
* simple-object-elf.c
(simple_object_elf_copy_lto_debug_sections): Localize global
UNDEFs and reuse the prevailing name.

2020-07-10  Ian Lance Taylor  <iant@golang.org>
PR demangler/96143
* cp-demangle.c (d_lambda): Don't add substitution candidate.
* testsuite/demangle-expected: Update a few existing test cases
accordingly, and add a new test case.

2020-07-04  Jason Merrill  <jason@redhat.com>
* cp-demangle.c (cplus_demangle_operators): Add di, dx, dX.
(d_expression_1): Handle di and dX.
(is_designated_init, d_maybe_print_designated_init): New.
(d_print_comp_inner): Use d_maybe_print_designated_init.
* testsuite/demangle-expected: Add designator tests.

2020-06-25  Nick Clifton  <nickc@redhat.com>
* bsearch.c (bsearch): Remove use of register keyword.
* bsearch_r.c (bsearch_r): Likewise.

4 years ago[gdb/testsuite] Fix gdb.dwarf2/frame-inlined-in-outer-frame.exp
Tom de Vries [Tue, 8 Sep 2020 09:51:29 +0000 (11:51 +0200)]
[gdb/testsuite] Fix gdb.dwarf2/frame-inlined-in-outer-frame.exp

I'm running into the following FAIL:
...
(gdb) starti ^M
Starting program: frame-inlined-in-outer-frame frame^M
^M
^M
Program stopped.^M
0x0000000000401000 in _start ()^M
(gdb) PASS: gdb.dwarf2/frame-inlined-in-outer-frame.exp: frame
frame^M
(gdb) FAIL: gdb.dwarf2/frame-inlined-in-outer-frame.exp: step into foo
stepi^M
0x0000000000401001 in foo ()^M
...

The problem is that the .exp file issues a gdb_starti_cmd without consuming
the resulting prompt.  Consequently, the gdb_test issuing the frame command
consumes that prompt, and things are out-of-sync from that point onwards.

Fix this by consuming the gdb prompt after gdb_starti_cmd.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-09-08  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/frame-inlined-in-outer-frame.exp: Consume gdb prompt
after gdb_starti_cmd.

4 years agoStop the plugin handler from ignoring unknown symbol types when conanicalizing weak...
Nick Clifton [Tue, 8 Sep 2020 08:49:15 +0000 (09:49 +0100)]
Stop the plugin handler from ignoring unknown symbol types when conanicalizing weak definitions.

* plugin.c (bfd_plugin_canonicalize_symtab): Handle the case of an
unrecognized symbol type in a weak definition.

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

4 years agogdb/infrun: use switch_to_target_no_thread to switch the target
Tankut Baris Aktemur [Mon, 7 Sep 2020 12:40:40 +0000 (14:40 +0200)]
gdb/infrun: use switch_to_target_no_thread to switch the target

Use the available `switch_to_target_no_thread` function to switch the
target.  This is a refactoring.

gdb/ChangeLog:
2020-09-07  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* infrun.c (fetch_inferior_event): Use
`switch_to_target_no_thread` to switch the target.

4 years agogas: Output directory and file names in .debug_line_str for DWARF5
Mark Wielaard [Mon, 7 Sep 2020 13:03:20 +0000 (14:03 +0100)]
gas: Output directory and file names in .debug_line_str for DWARF5

* dwarf2dbg.c (add_line_strp): New function.
(out_dir_and_file_list): Take line_seg and sizeof_offset as
arguments, Use DW_FORM_line_strp for dir and file. Call
add_line_strp and set symbol offset for DWARF2_LINE_VERSION 5.
(out_debug_line): Call out_dir_and_file_list with line_seg and
sizeof_offset.
* gas/testsuite/gas/elf/dwarf-5-file0.d: Expect indirect line
strings.

4 years agogas: Output .debug_rnglists for DWARF 5.
Mark Wielaard [Mon, 7 Sep 2020 12:04:45 +0000 (13:04 +0100)]
gas: Output .debug_rnglists for DWARF 5.

* dwarf2dbg.c (DWARF2_RNGLISTS_VERSION): New constant.
(out_debug_ranges): Add ranges_sym argument and set it.
(out_debug_rnglists): New function.
(out_debug_info): Change ranges_seg argument to ranges_sym
and use it to set DW_AT_ranges value.
(dwarf2_finish): Remove ranges_seg, add ranges_sym. For
DWARF2_VERSION 5 call out_debug_rnglists.

4 years agogas: Make sure to only add an md5 to a .file when requested.
Mark Wielaard [Mon, 7 Sep 2020 11:08:07 +0000 (12:08 +0100)]
gas: Make sure to only add an md5 to a .file when requested.

* dwarf2dbg.c (dwarf2_directive_filename): Initialize with_md5 to
FALSE.
* gas/testsuite/gas/elf/dwarf-5-file0.s: Add a random bignum.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 7 Sep 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoRemove unused declaration from symfile.h
Tom Tromey [Sun, 6 Sep 2020 21:50:59 +0000 (15:50 -0600)]
Remove unused declaration from symfile.h

dwarf2_free_objfile no longer exists, so this patch removes its
declaration from symfile.h.

gdb/ChangeLog
2020-09-06  Tom Tromey  <tom@tromey.com>

* symfile.h (dwarf2_free_objfile): Don't declare.

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 6 Sep 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 5 Sep 2020 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoPR26574, heap buffer overflow in _bfd_elf_slurp_secondary_reloc_section
Alan Modra [Fri, 4 Sep 2020 09:49:18 +0000 (19:19 +0930)]
PR26574, heap buffer overflow in _bfd_elf_slurp_secondary_reloc_section

A horribly fuzzed object with section headers inside the ELF header.
Disallow that, and crazy reloc sizes.

PR 26574
* elfcode.h (elf_object_p): Sanity check section header offset.
* elf.c (_bfd_elf_slurp_secondary_reloc_section): Sanity check
sh_entsize.

4 years agoAllow plugin syms to mark as-needed shared libs needed
Alan Modra [Fri, 4 Sep 2020 04:24:21 +0000 (13:54 +0930)]
Allow plugin syms to mark as-needed shared libs needed

We must tell LTO about symbols in all shared libraries loaded.  That
means we can't load extra shared libraries after LTO recompilation, at
least, not those that affect the set of symbols that LTO cares about,
the IR symbols.

This change will likely result in complaints about --as-needed
libraries being loaded unnecessarily, but being correct is more
important than being optimal.  One of the PR15146 tests regresses, and
while that could be hidden by disabling the missing dso message by
making it conditional on h->root.non_ir_ref_regular, that would just
be sweeping a problem under the rug.

bfd/
PR 15146
PR 26314
PR 26530
* elflink.c (elf_link_add_object_symbols): Do set def_regular
and ref_regular for IR symbols.  Don't clear dynsym, allowing
IR symbols to load --as-needed shared libraries, but prevent
IR symbols from becoming dynamic.
ld/
* testsuite/ld-plugin/lto.exp: Don't run pr15146 tests.
* testsuite/ld-plugin/pr15146.d: Delete.
* testsuite/ld-plugin/pr15146a.c: Delete.
* testsuite/ld-plugin/pr15146b.c: Delete.
* testsuite/ld-plugin/pr15146c.c: Delete.
* testsuite/ld-plugin/pr15146d.c: Delete.

4 years agold: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS
H.J. Lu [Fri, 4 Sep 2020 00:17:19 +0000 (17:17 -0700)]
ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS

* testsuite/config/default.exp: Change NOSANTIZE_CFLAGS to
NOSANITIZE_CFLAGS.
* testsuite/ld-elf/dwarf.exp: Likewise.
* testsuite/ld-elf/indirect.exp: Likewise.
* testsuite/ld-elf/linux-x86.exp: Likewise.
* testsuite/ld-elf/shared.exp: Likewise.
* testsuite/ld-elf/tls.exp: Likewise.
* testsuite/ld-elfcomm/elfcomm.exp: Likewise.
* testsuite/ld-elfvers/vers.exp: Likewise.
* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
* testsuite/ld-elfweak/elfweak.exp: Likewise.
* testsuite/ld-gc/gc.exp: Likewise.
* testsuite/ld-plugin/lto.exp: Likewise.
* testsuite/ld-plugin/plugin.exp: Likewise.
* testsuite/ld-scripts/crossref.exp: Likewise.
* testsuite/ld-selective/selective.exp: Likewise.
* testsuite/ld-shared/shared.exp: Likewise.
* testsuite/ld-size/size.exp: Likewise.
* testsuite/ld-srec/srec.exp: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Likewise.

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

4 years agoAllow Flang kind printing in complex.exp,pointer-to-pointer.exp,vla-ptr-info.exp
Alok Kumar Sharma [Thu, 3 Sep 2020 16:35:18 +0000 (22:05 +0530)]
Allow Flang kind printing in complex.exp,pointer-to-pointer.exp,vla-ptr-info.exp

In the test cases complex.exp,pointer-to-pointer.exp,vla-ptr-info.exp
fortran.exp routines are not used, which are to determine the type/kind
string. Due to this these test incorrectly fail for Flang.
Now test cases are modified to use fortran.exp routines. fortran.exp
file is modified to add absent routines fortran_complex8 and
fortran_complex16.

gdb/testsuite/ChangeLog

* lib/fortran.exp (fortran_complex8): New proc.
(fortran_complex16): New proc.
* gdb.fortran/complex.exp: Use routines from fortran.exp
* gdb.fortran/pointer-to-pointer.exp: Likewise.
* gdb.fortran/vla-ptr-info.exp: Likewise.

4 years agoSupport printing of 16 byte real/complex type for Flang compiler
Alok Kumar Sharma [Thu, 3 Sep 2020 16:21:01 +0000 (21:51 +0530)]
Support printing of 16 byte real/complex type for Flang compiler

Currently GDB is not able to print correct value for real/complex type
from binary generated from Flang compiler. This is due to GDB not able
to recognise and determine correct format floatformats_ia64_quad and
instead falling back to default_floatformat_for_type. This leads
incorrect output.
Now function i386_floatformat_for_type is fixed to correctly identify
Flang generated 16 byte real/complex type.

gdb/ChangeLog

* gdb/i386-tdep.c (i386_floatformat_for_type): Added conditions
to match 16 byte real/complex type generated by Flang compiler.

4 years agobpf: several small fixes in the simulator
Jose E. Marchesi [Thu, 3 Sep 2020 14:24:51 +0000 (16:24 +0200)]
bpf: several small fixes in the simulator

This patch fixes the following problems:
- Missing includes in several files leading to implicit function
  declarations.
- Missing prototype for bpf_trace_printk in bpf-helpers.h
- The simulator bitsize was set to 32 bits, causing truncation of
  the program counter.

Tested in bpf-unknown-none.

sim/ChangeLog:

2020-09-03  Jose E. Marchesi  <jose.marchesi@oracle.com>

* bpf/bpf.c: Include bpf-helpers.h.
* bpf/bpf-helpers.h: Provide a prototype for bpf_trace_printk.
* bpf/configure.ac: Set simulator bitsize to 64.
* bpf/configure (includedir): Regenerate.
* bpf/sim-if.c: Include stdlib.h.
* bpf/traps.c: Likewise.

4 years agosim: better handle builds of primary targets lacking sims
Jose E. Marchesi [Thu, 3 Sep 2020 13:22:05 +0000 (15:22 +0200)]
sim: better handle builds of primary targets lacking sims

When building with a primary target that doesn't feature a simulator,
one would expect for nothing to be done in sim/.  However, a
$(top_builddir)/sim/testsuite directory is created, with a Makefile
containing a rule like:

check-DEJAGNU: site.exp
echo "Dejagnu-checking in `pwd` directory ..."
rootme=`pwd`; export rootme; echo rootme = $$rootme; \
srcdir=`cd ${srcdir}; pwd`; export srcdir ; echo srcdir = $$srcdir; \
EXPECT=${EXPECT} ; export EXPECT ; echo EXPECT = $$EXPECT; \
if [ -f $$rootme/../../expect/expect ]; then \
  TCL_LIBRARY=`cd $$srcdir/../../tcl/library && pwd`; \
  export TCL_LIBRARY; \
fi; \
        echo TCL_LIBRARY = $$TCL_LIBRARY; \
runtest=$(RUNTEST); echo runtest = $$runtest; \
if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
  $$runtest $(RUNTESTFLAGS); \
else echo "WARNING: could not find \`runtest'" 1>&2; :;\
fi

Consequently, when `make check' recurses into sim/testsuite, the above
rule is executed.  Until now, the desired effect (of doing nothing)
was achieved because `runtest --version' fails due to a malformed
site.exp being generated in objdir: it is malformed because the
primary target doesn't configure a $sim_arch. i.e. this was doing the
right thing just by chance.

However, the git version of dejagnu seems to have changed in a way
runtest doesn't try to load site.exp when it gets --version.  The net
effect is that the rule above tries to actually run the tests, failing
miserably.

This little patch makes sim/configure to not recurse into
sim/testsuite if the primary target didn't configure a simulator.

Tested with:
- A simulator target (bpf-unkonwn-none).
- A simulator-less target (x86_64-linux-gnu).
- A simulator-less target and --build-targets=all.

sim/ChangeLog:

2020-09-03  Jose E. Marchesi  <jose.marchesi@oracle.com>

* configure.ac: Do not configure sim/testsuite nor sim/igen if the
primary target doesn't have a simulator.
* configure: Regenerate.

4 years agogas: Use DW_FORM_sec_offset for DWARF version 4 or higher.
Mark Wielaard [Tue, 1 Sep 2020 13:29:56 +0000 (15:29 +0200)]
gas: Use DW_FORM_sec_offset for DWARF version 4 or higher.

Older DWARF versions used DW_FORM_data4 or DW_FORM_data8 for offsets
into sections for e.g. DW_AT_stmt_list ot DW_AT_ranges. But version 4
introduced a dedicated form for such section offsets. Make sure to emit
the proper form for newer DWARF versions.

gas/ChangeLog:

* dwarf2dbg.c (out_debug_abbrev): Use DW_FORM_sec_offset for DWARF
version 4 or higher.

4 years agoFix a division by zero error when processing secondary relocs in a fuzzed input file.
Nick Clifton [Thu, 3 Sep 2020 15:11:43 +0000 (16:11 +0100)]
Fix a division by zero error when processing secondary relocs in a fuzzed input file.

PR 26521
* elf.c (_bfd_elf_write_secondary_reloc_section): Check for
secondary reloc sections with a zero sh_entsize field.

4 years ago[gdb/breakpoint, PIE] Handle setting breakpoint on label without address
Tom de Vries [Thu, 3 Sep 2020 10:30:10 +0000 (12:30 +0200)]
[gdb/breakpoint, PIE] Handle setting breakpoint on label without address

When adding:
...
if ![runto_main] then {
    fail "can't run to main"
    return 0
}
...
to test-case gdb.base/label-without-address.exp and running it with target
board unix/-fPIE/-pie, we run into:
...
(gdb) break main:L1^M
Breakpoint 2 at 0x555555554000: file label-without-address.c, line 22.^M
...
That is, for a label with optimized-out address, we set a breakpoint at the
relocation base.

The root cause is that the dwarf reader, despite finding that attribute
DW_AT_low_pc is missing, still tags the L1 symbol as having LOC_LABEL, which
means it has a valid address, which defaults to 0.

Fix this by instead tagging the L1 symbol with LOC_OPTIMIZED_OUT.

Tested on x86_64-linux.

gdb/ChangeLog:

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

PR breakpoint/26546
* dwarf2/read.c (new_symbol): Tag label symbol without DW_AT_low_pc as
LOC_OPTIMIZED_OUT instead of LOC_LABEL.

gdb/testsuite/ChangeLog:

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

PR breakpoint/26546
* gdb.base/label-without-address.exp: Runto main first.

4 years agoRISC-V: Minor cleanup and typos when merging elf attributes.
Nelson Chu [Wed, 19 Aug 2020 03:49:24 +0000 (11:49 +0800)]
RISC-V: Minor cleanup and typos when merging elf attributes.

bfd/
* elfnn-riscv.c (riscv_i_or_e_p): Minor cleanup for warnings/errors.
(riscv_merge_std_ext): Likewise.
(riscv_merge_arch_attr_info): Likewise.
(riscv_merge_attributes): Likewise and fix comment typos.

ld/
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Remove
the useless `warnings` keywords.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Likewise.

4 years agoRISC-V: Report warnings rather than errors for the mis-matched ISA versions.
Nelson Chu [Tue, 18 Aug 2020 09:48:34 +0000 (17:48 +0800)]
RISC-V: Report warnings rather than errors for the mis-matched ISA versions.

Same as the privileged spec attributes check - different ISA versions
should be compatible, unless there are some known conflicts.  Therefore,
we should allow to link objects with different ISA versions, and update
the output ISA versions once the corresponding input ones are newer.
But it's better to also warn people that the conflicts may happen when
the ISA versions are mis-matched.

bfd/
* elfnn-riscv.c (riscv_version_mismatch): Change the return type
from void to bfd_boolean.  Report warnings rather than errors
when the ISA versions are mis-matched.  Afterwards, remember to
update the output ISA versions to the newest ones.
(riscv_merge_std_ext): Allow to link objects with different
standard ISA versions.  Try to add output ISA versions to
merged_subsets first.
(riscv_merge_multi_letter_ext): Likewise.  But for standard additional
ISA and non-standard ISA versions.

ld/
* testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Update the
message from error to warning.
* testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d: New testcases.
* testsuite/ld-riscv-elf/attr-merge-arch-failed-02a.s: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-failed-02b.s: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-failed-02c.s: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-failed-02d.s: Likewise.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.

4 years agoRISC-V: Improve the error message for the mis-matched ISA versions.
Kito Cheng [Tue, 7 Jul 2020 02:30:36 +0000 (19:30 -0700)]
RISC-V: Improve the error message for the mis-matched ISA versions.

Consider the updated attr-merge-arch-failed-01.d testcase.  Extension
A's version are mis-matched between attr-merge-arch-failed-01a.s and
attr-merge-arch-failed-01b.s.  But the old binutils reports that the
mis-matched extension is M rather than A.  This commit is used to fix
the wrong mis-matched error message.

Besides, when parsing the arch string in the riscv_parse_subset, it
shouldn't be NULL or empty.  However, it might be empty when we failed
to merge the arch string in the riscv_merge_attributes.  Since we should
already issue the correct error message in another side, and the message
- ISA string must begin with rv32 or rv64 - is meaninglesss when the arch
string is empty, so do not issue it.

bfd/
* elfnn-riscv.c (riscv_merge_std_ext): Fix to report the correct
error message when the versions of extension are mis-matched.
* elfxx-riscv.c (riscv_parse_subset): Don't issue the error when
the string is empty.

ld/
* testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s: Likewise.

4 years agoheap use after free in xcoff_archive_info_eq
Alan Modra [Thu, 3 Sep 2020 00:04:37 +0000 (09:34 +0930)]
heap use after free in xcoff_archive_info_eq

Using an input file objalloc memory for anything that isn't created
when opening the bfd is not a good idea.  The problem is that this
memory can disappear if bfd_free_cached_info is called or when bfd
closes files in order to keep the number of open files reasonable.

bfd/
* xcofflink.c (xcoff_get_archive_info): Allocate xcoff_archive_info
on the output bfd objalloc memory.
ld/
* testsuite/ld-scripts/sysroot-prefix.exp (single_sysroot_prefix_test):
Log $scriptname.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 3 Sep 2020 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb: remove maint_print_section_data
Simon Marchi [Wed, 2 Sep 2020 18:36:50 +0000 (14:36 -0400)]
gdb: remove maint_print_section_data

Since the "maintenance info sections" helper functions are not used
through a callback with a void* parameter anymore, the
maint_print_section_data is not needed anymore.  Remove it, replace it
with regular parameters.

Break out the index digits computation in its own function.

gdb/ChangeLog:

* maint.c (index_digits): New function.
(struct maint_print_section_data): Remove.
(print_bfd_section_info): Remove print_data parameter, add arg
and index_digits.
(print_objfile_section_info): Likewise.
(print_bfd_section_info_maybe_relocated): Likewise (plus
objfile).
(maintenance_info_sections): Adjust calls.

Change-Id: Idfeca5e7e0a95e72fade15cb1488058865c0258e

4 years agoDo not auto-dereference null pointers in Ada MI varobj
Tom Tromey [Mon, 10 Aug 2020 11:21:06 +0000 (05:21 -0600)]
Do not auto-dereference null pointers in Ada MI varobj

The Ada varobj code automatically dereferences access types.  This is
often handy, but it also does so for null pointers -- showing children
with empty values.

These children are weird, but even weirder when a variant type is
involved, because only the non-varying parts of the type are
displayed.  This behavior conflicts a bit with my ongoing quest to
move the Ada code to use DWARF rather than gnat encodings, in that
reproducing this behavior with the DWARF code seems rather hacky.

So, this patch instead changes the Ada varobj code so that it does not
automatically dereference null pointers.

As this patch only affects Ada, and it was already reviewed internally
by Joel, I am checking it in.

2020-09-02  Tom Tromey  <tromey@adacore.com>

* ada-varobj.c (ada_varobj_get_ptr_number_of_children): Return 0
for null pointers.
(ada_varobj_adjust_for_child_access): Special-case null pointers.

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

* gdb.ada/mi_var_access.exp: Test children of access variable.
* gdb.ada/mi_var_access/mi_access.adb: Add new stop markers.
* gdb.ada/mi_var_array.exp: Update.

4 years agoubsan: v850-opc.c:412 left shift cannot be represented
Alan Modra [Wed, 2 Sep 2020 01:30:15 +0000 (11:00 +0930)]
ubsan: v850-opc.c:412 left shift cannot be represented

include/
* opcode/v850.h (struct v850_operand <insert>): Make param op an
unsigned long.
opcodes/
* v850-opc.c (insert_i5div1, insert_i5div2, insert_i5div3),
(insert_d5_4, insert_d8_6, insert_d8_7, insert_v8, insert_d9),
(insert_u16_loop, insert_d16_15, insert_d16_16, insert_d17_16),
(insert_d22, insert_d23, insert_d23_align1, insert_i9, insert_u9),
(insert_spe, insert_r4, insert_POS, insert_WIDTH, insert_SELID),
(insert_VECTOR8, insert_VECTOR5, insert_CACHEOP, insert_PREFOP),
(nsert_IMM10U, insert_SRSEL1, insert_SRSEL2): Use unsigned long
for value parameter and update code to suit.
(extract_d9, extract_d16_15, extract_d16_16, extract_d17_16),
(extract_d22, extract_d23, extract_i9): Use unsigned long variables.

4 years agoubsan: i386-dis.c
Alan Modra [Wed, 2 Sep 2020 01:17:33 +0000 (10:47 +0930)]
ubsan: i386-dis.c

i386-dis.c:12207 left shift of 128 by 24 places cannot be represented in type 'long int'
i386-dis.c:12220 left shift of 128 by 24 places cannot be represented in type 'long int'
i386-dis.c:12222 left shift of 1 by 31 places cannot be represented in type 'long int'
i386-dis.c:12222 signed integer overflow: 162254319 - -2147483648 cannot be represented in type 'long int'

* i386-dis.c (OP_E_memory): Don't cast to signed type when
negating.
(get32, get32s): Use unsigned types in shift expressions.

4 years agoubsan: csky-dis.c:1038 left shift cannot be represented
Alan Modra [Wed, 2 Sep 2020 01:14:32 +0000 (10:44 +0930)]
ubsan: csky-dis.c:1038 left shift cannot be represented

* csky-dis.c (print_insn_csky): Use unsigned type for "given".

4 years agoubsan: crx-dis.c:571 left shift of negative value
Alan Modra [Wed, 2 Sep 2020 01:12:53 +0000 (10:42 +0930)]
ubsan: crx-dis.c:571 left shift of negative value

* crx-dis.c: Whitespace.
(print_arg): Use unsigned type for longdisp and mask variables,
and for left shift constant.

4 years agoubsan: *-ibld.c
Alan Modra [Wed, 2 Sep 2020 01:05:10 +0000 (10:35 +0930)]
ubsan: *-ibld.c

bfin-dis.c:160 shift exponent 32 is too large for 32-bit type 'long unsigned int'
bpf-ibld.c:196 left shift of 1 by 31 places cannot be represented in type 'long int'
bpf-ibld.c:196 negation of -2147483648 cannot be represented in type 'long int'; cast to an unsigned type to negate this
 itself
bpf-ibld.c:197 left shift of 1 by 31 places cannot be represented in type 'long int'
bpf-ibld.c:197 signed integer overflow: -2147483648 - 1 cannot be represented in type 'long int'
bpf-ibld.c:501 left shift of 1 by 31 places cannot be represented in type 'long int'

* cgen-ibld.in (insert_normal, extract_normal): Use 1UL in left shift.
* bpf-ibld.c: Regenerate.
* epiphany-ibld.c: Regenerate.
* fr30-ibld.c: Regenerate.
* frv-ibld.c: Regenerate.
* ip2k-ibld.c: Regenerate.
* iq2000-ibld.c: Regenerate.
* lm32-ibld.c: Regenerate.
* m32c-ibld.c: Regenerate.
* m32r-ibld.c: Regenerate.
* mep-ibld.c: Regenerate.
* mt-ibld.c: Regenerate.
* or1k-ibld.c: Regenerate.
* xc16x-ibld.c: Regenerate.
* xstormy16-ibld.c: Regenerate.

4 years agoubsan: bfin-dis.c:160 shift exponent 32 is too large
Alan Modra [Wed, 2 Sep 2020 01:03:07 +0000 (10:33 +0930)]
ubsan: bfin-dis.c:160 shift exponent 32 is too large

* bfin-dis.c (MASKBITS): Use SIGNBIT.

4 years agoubsan: expr.c:1725,1741 signed integer overflow
Alan Modra [Wed, 2 Sep 2020 00:59:21 +0000 (10:29 +0930)]
ubsan: expr.c:1725,1741 signed integer overflow

* expr.c (add_to_result, subtract_from_result): Use unsigned
addition and subtraction.

4 years agoubsan: tc-z80.c:3656 shift exponent 32 is too large
Alan Modra [Wed, 2 Sep 2020 00:56:31 +0000 (10:26 +0930)]
ubsan: tc-z80.c:3656 shift exponent 32 is too large

* config/tc-z80.c (is_overflow): Avoid too large shift.

4 years agoubsan: tc-sparc.c:1146 left shift cannot be represented
Alan Modra [Wed, 2 Sep 2020 00:54:31 +0000 (10:24 +0930)]
ubsan: tc-sparc.c:1146 left shift cannot be represented

* config/tc-sparc.c (in_signed_range): Use an unsigned type for
sign mask.

4 years agoubsan: tc-nios2.c:1403 shift exponent 32 is too large
Alan Modra [Wed, 2 Sep 2020 00:52:39 +0000 (10:22 +0930)]
ubsan: tc-nios2.c:1403 shift exponent 32 is too large

* config/tc-nios2.c (md_apply_fix): Avoid too large shift.

4 years agoubsan: tc-mips.c:9606 shift exponent 32 is too large
Alan Modra [Wed, 2 Sep 2020 00:50:53 +0000 (10:20 +0930)]
ubsan: tc-mips.c:9606 shift exponent 32 is too large

* config/tc-mips.c (load_register): Avoid too large shift.

4 years agoubsan: tc-d30v.c left shift cannot be represented
Alan Modra [Wed, 2 Sep 2020 00:47:21 +0000 (10:17 +0930)]
ubsan: tc-d30v.c left shift cannot be represented

* config/tc-d30v.c (parallel_ok): Use 1UL for left shift expression.

4 years agoubsan: rx-parse.y:1743 shift exponent 32 is too large
Alan Modra [Wed, 2 Sep 2020 00:45:09 +0000 (10:15 +0930)]
ubsan: rx-parse.y:1743 shift exponent 32 is too large

* config/rx-parse.y (rx_intop): Avoid too large shifts.
(rx_intop, rx_uintop, rx_disp3op, rx_disp5op, displacement),
(rtsd_immediate): Use correctly typed unsigned variables.

4 years agoubsan: obj-macho.c:503 left shift cannot be represented
Alan Modra [Wed, 2 Sep 2020 00:40:45 +0000 (10:10 +0930)]
ubsan: obj-macho.c:503 left shift cannot be represented

* config/obj-macho.c (obj_mach_o_zerofill): Correct type of
constant shifted left.

4 years agoubsan: bfin-lex.l:503 left shift cannot be represented
Alan Modra [Wed, 2 Sep 2020 00:38:11 +0000 (10:08 +0930)]
ubsan: bfin-lex.l:503 left shift cannot be represented

* config/bfin-lex.l: Use an unsigned type for "value".

4 years agoubsan: objdump.c:3009 negation of -2147483648
Alan Modra [Wed, 2 Sep 2020 00:35:52 +0000 (10:05 +0930)]
ubsan: objdump.c:3009 negation of -2147483648

* objdump.c (disassemble_bytes): Use an unsigned type for "addend".

4 years agoubsan elfnn-aarch64.c:7142 shift exponent 32 is too large
Alan Modra [Wed, 2 Sep 2020 00:33:14 +0000 (10:03 +0930)]
ubsan elfnn-aarch64.c:7142 shift exponent 32 is too large

* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Correct type
of constant shifted left.

4 years agoubasn: elf32-pru.c:570 left shift of negative value
Alan Modra [Wed, 2 Sep 2020 00:29:16 +0000 (09:59 +0930)]
ubasn: elf32-pru.c:570 left shift of negative value

* elf32-pru.c (pru_elf32_do_ldi32_relocate): Use an unsigned
type for "relocation".

4 years ago32-bit host pdp11 breakage
Alan Modra [Tue, 1 Sep 2020 11:53:52 +0000 (21:23 +0930)]
32-bit host pdp11 breakage

If bfd_vma is 32 bits, gcc complains about shift counts exceeding
width of the type.

* config/tc-pdp11.c (md_number_to_chars): Condition nbytes=8 code
on BFD64.

4 years agoCSKY: Add CPU CK803r3.
Cooper Qu [Wed, 2 Sep 2020 06:06:03 +0000 (14:06 +0800)]
CSKY: Add CPU CK803r3.

Move divul and divsl to CSKYV2_ISA_3E3R3 instruction set, which is
enabled by ck803r3, and it's still a part of enhance DSP instruction
set.

gas/
* config/tc-csky.c (csky_cpus): Add ck803r3.
(CSKY_ISA_803R3): Define.
(CSKY_ISA_803R2): Refine, use CSKY_ISA_803R1.

include/
* opcode/csky.h (CSKYV2_ISA_3E3R3): Define.

opcodes/
* csky-opc.h (csky_v2_opcodes): Move divul and divsl
to CSKYV2_ISA_3E3R3 instruction set.

4 years agoCSKY: Fix Encode of mulsws.
Cooper Qu [Wed, 2 Sep 2020 06:05:49 +0000 (14:05 +0800)]
CSKY: Fix Encode of mulsws.

gas/
* testsuite/gas/csky/cskyv2_dsp.d : Fix Encode of mulsws.

opcodes/
* csky-opc.h (csky_v2_opcodes): Fix Encode of mulsws.

4 years agoCSKY: Refine literals pool dump process and float register parser.
Cooper Qu [Wed, 2 Sep 2020 06:04:52 +0000 (14:04 +0800)]
CSKY: Refine literals pool dump process and float register parser.

gas/
* config/tc-csky.c (struct literal): New member bignum.
(dump_literals): Handle big constant.
(enter_literal): Likewise.
(parse_type_freg): Handle vector register.

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

4 years agogdb: change bcache::insert `added` parameter to bool
Simon Marchi [Tue, 1 Sep 2020 16:54:38 +0000 (12:54 -0400)]
gdb: change bcache::insert `added` parameter to bool

It is currently an int, but it is used as a bool.

gdb/ChangeLog:

* bcache.h (struct bcache) <insert>: Change type of `added` to
pointer to bool.
* bcache.c (bcache::insert): Likewise.
* gdbtypes.c (check_types_worklist): Adjust.
* psymtab.c (add_psymbol_to_bcache): Adjust.

Change-Id: I06b1041636c656782a89cb6106c9ae2593f61616

4 years agoELF: Document the .tls_common directive
H.J. Lu [Tue, 1 Sep 2020 14:10:56 +0000 (07:10 -0700)]
ELF: Document the .tls_common directive

Document the .tls_common directive added by

commit b8871f357fdfa9c0c06d2d3e5600391d8c994f37
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Feb 22 09:18:52 2016 -0800

    Properly implement STT_COMMON

* doc/as.texi: Document the .tls_common directive.

4 years agomep: ubsan: mep-ibld.c:1635,1645,1652 left shift of negative value
Alan Modra [Mon, 31 Aug 2020 22:18:02 +0000 (07:48 +0930)]
mep: ubsan: mep-ibld.c:1635,1645,1652 left shift of negative value

cpu/
* mep-core.cpu (f-8s8a2, f-12s4a2, f-17s16a2): Multiply signed
value by two rather than shifting left.
(f-24s5a2n): Similarly multiply signed f-24s5a2n-hi to extract.
opcodes/
* mep-ibld.c: Regenerate.

4 years agoarm: ubsan: shift exponent 4G
Alan Modra [Tue, 1 Sep 2020 03:08:03 +0000 (12:38 +0930)]
arm: ubsan: shift exponent 4G

* reloc.c (N_ONES): Handle N=0.
* elf32-arm.c (elf32_arm_howto_table_1): Set complain_overflow_dont
for R_ARM_TLS_DESCSEQ and R_ARM_THM_TLS_DESCSEQ.

4 years agoPR26420, PR26421, PR26425, PR26427 UBSAN: tc-arm.c left shifts
Alan Modra [Tue, 1 Sep 2020 02:05:37 +0000 (11:35 +0930)]
PR26420, PR26421, PR26425, PR26427 UBSAN: tc-arm.c left shifts

PR 26420
PR 26421
PR 26425
PR 26427
* config/tc-arm.c (struct arm_it): Make size, size_req, cond and
uncond_value unsigned.
(parse_vfp_reg_list): Make setmask unsigned, vpr_str_len size_t.
(parse_big_immediate): Cast generic_bignum elements to unsigned.
(encode_thumb32_immediate): Shift left 0xffU.
(double_to_single): Make sign unsigned.  Tidy.
(move_or_literal_pool): Cast LITTLE_NUM elements to uint64_t or
valueT.
(vfp_or_neon_is_neon): Adjust inst.uncond_value expression.
(md_assemble): Likewise.
(handle_pred_state): Make cond unsigned.
(thumb32_negate_data_op): Make variables unsigned.
(md_apply_fix): Make value and newval unsigned, adjust uses.

4 years agoPR26429 UBSAN: elf32-arm.c load /store misaligned address
Alan Modra [Mon, 31 Aug 2020 23:29:05 +0000 (08:59 +0930)]
PR26429 UBSAN: elf32-arm.c load /store misaligned address

PR 26429
* elf32-arm.c (elf32_arm_allocate_local_sym_info): Allocate arrays
in descending order of alignment.

4 years agoPR26423 UBSAN: elf32-arm.c:10237 left shift cannot be represented
Alan Modra [Mon, 31 Aug 2020 22:33:52 +0000 (08:03 +0930)]
PR26423 UBSAN: elf32-arm.c:10237 left shift cannot be represented

PR 26423
* elf32-arm.c (calculate_group_reloc_mask): Use 3u in shift.

4 years agocorefile.exp: XFAIL warning-free test when testing on docker
Kevin Buettner [Tue, 11 Aug 2020 16:36:12 +0000 (09:36 -0700)]
corefile.exp: XFAIL warning-free test when testing on docker

When testing on docker using the AUFS storage driver, loading a core
file will often print a number of warnings.  Here's an example (with
the pathname shortened somewhat):

warning: Can't open file /var/lib/docker/aufs/diff/d07..e21/lib/x86_64-linux-gnu/libc-2.27.so during file-backed mapping note processing

The "warning-free" test in gdb.base/corefile.exp will fail if any
warnings are printed, but this particular warning is unavoidable when
running in the docker environment.  Fortunately, the path mentions
both "docker" and "aufs", making it easy to XFAIL this case.

gdb/testsuite/ChangeLog:

* gdb.base/corefile.exp (warning-free): XFAIL test when running
on docker w/ AUFS storage driver.

4 years agoWork around incorrect/broken pathnames in NT_FILE note
Kevin Buettner [Fri, 7 Aug 2020 20:07:44 +0000 (13:07 -0700)]
Work around incorrect/broken pathnames in NT_FILE note

Luis Machado reported some regressions after I pushed recent core file
related patches fixing BZ 25631:

    FAIL: gdb.base/corefile.exp: backtrace in corefile.exp
    FAIL: gdb.base/corefile.exp: core-file warning-free
    FAIL: gdb.base/corefile.exp: print func2::coremaker_local
    FAIL: gdb.base/corefile.exp: up in corefile.exp
    FAIL: gdb.base/corefile.exp: up in corefile.exp (reinit)

This commit fixes these regressions.  Thanks to Luis for testing
an earlier version of the patch.  (I was unable to reproduce these
regressions in various test environments that I created.)

Luis is testing in a docker container which is using the AUFS storage
driver.  It turns out that the kernel is placing docker host paths in
the NT_FILE note instead of paths within the container.

I've made a similar docker environment (though apparently not similar
enough to reproduce the regressions).  This is one of the paths that
I see mentioned in the warning messages printed while loading the
core file during NT_FILE note processing - note that I've shortened
the path component starting with "d07c4":

/var/lib/docker/aufs/diff/d07c4...21/lib/x86_64-linux-gnu/ld-2.27.so

This is a path on the docker host; it does not exist in the
container.  In the docker container, this is the path:

/lib/x86_64-linux-gnu/ld-2.27.so

My first thought was to disable all NT_FILE mappings when any path was
found to be bad.  This would have caused GDB to fall back to accessing
memory using the file stratum as it did before I added the NT_FILE
note loading code.  After further consideration, I realized that we
could do better than this.  For file-backed memory access, we can
still use the NT_FILE mappings when available, and then attempt to
access memory using the file stratum constrained to those address
ranges corresponding to the "broken" mappings.

In order to test it, I made some additions to corefile2.exp in which
the test case's executable is renamed.  The core file is then loaded;
due to the fact that the executable has been renamed, those mappings
will be unavailable.  After loading the core file, the executable is
renamed back to its original name at which point it is loaded using
GDB's "file" command.  The "interesting" tests are then run.  These
tests will print out values in file-backed memory regions along with
mmap'd regions placed within/over the file-backed regions.  Despite
the fact that the executable could not be found during the NT_FILE
note processing, these tests still work correctly due to the fact that
memory is available from the file stratum combined with the fact that
the broken NT_FILE mappings are used to prevent file-backed access
outside of the "broken" mappings.

gdb/ChangeLog:

* corelow.c (unordered_set): Include.
(class core_target): Add field 'm_core_unavailable_mappings'.
(core_target::build_file_mappings): Print only one warning
per inaccessible file.  Add unavailable/broken mappings
to m_core_unavailable_mappings.
(core_target::xfer_partial): Call...
(core_target::xfer_memory_via_mappings): New method.

gdb/testsuite/ChangeLog:

* gdb.base/corefile2.exp (renamed binfile): New tests.

4 years agogdb: change type of field_info::non_public_fields to bool
Simon Marchi [Tue, 1 Sep 2020 01:06:06 +0000 (21:06 -0400)]
gdb: change type of field_info::non_public_fields to bool

gdb/ChangeLog:

* dwarf2/read.c (struct field_info) <non_public_fields>: Change
type to bool.
(dwarf2_add_field): Use true instead of 1.

Change-Id: I7e9c86429402c28d4f15861d17976b9c50049f94

4 years agogdb: fix indentation of struct field_info
Simon Marchi [Tue, 1 Sep 2020 01:05:37 +0000 (21:05 -0400)]
gdb: fix indentation of struct field_info

The indentation is off, fix it before doing other changes.

gdb/ChangeLog:

* dwarf2/read.c (struct field_info): Fix indentation.

Change-Id: Ife6a3d017abcf0a33e49e47e51429e95d504343c

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

4 years agogdb: fix nits in previous patches
Simon Marchi [Mon, 31 Aug 2020 17:31:01 +0000 (13:31 -0400)]
gdb: fix nits in previous patches

I forgot to fix some nits pointed out in review before merging the
"frame inlined in outer frame series", this patch fixes them.

gdb/ChangeLog:

* frame-unwind.h (frame_prev_register_ftype): Fix adjective
ordering in comment.
* frame.c (frame_id_eq): Fix indentation.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-reg-undefined.exp: Remove spurious #.

Change-Id: Iaddde9677fc3f68382558d1a16f5a0b4beb78bac

4 years agogdb: support frames inlined into the outer frame
Scott Linder [Mon, 31 Aug 2020 17:24:20 +0000 (13:24 -0400)]
gdb: support frames inlined into the outer frame

Remove the restriction (gdb_assert) that prevents creating frames
inlined in the outer frame.  Like for frames inlined in a standard frame
(FID_STACK_VALID), a frame inlined into the outer frame will have:

 - artificial_depth greater than 0
 - code_addr equal to the first executed instruction in the block
   corresponding to the inlined function

It will however have its stack_status set to FID_STACK_OUTER, like the
outer frame.

This is not typically seen on your everyday system (e.g. a Linux /
x86-64 process), because the outer frame would be for instance the
_start function, probably written in assembly and very unlikely to have
anything inlined in it.  However this could happen in more "bare-metal"
scenarios.  In particular, this was seen in ROCm GDB [1], where the
compiler does inline functions in the top-level kernel functions (kernel
in the sense of compute kernel, not userspace vs kernel).

I however wrote a test that replicates the issue on x86-64 and a few
other arches I had access to.  Since we need to control precisely the
emitted DWARF CFI, I didn't find another way than to write it in
assembly.  The DWARF is generated using the testsuite's DWARF assembler,
except the unwind information, which is written using CFI directives
(and therefore generated by the actual assembler).  I think the test is
adequately commented, but if anything is unclear, just ask and I'll add
more info.

[1] https://github.com/ROCm-Developer-Tools/ROCgdb/

gdb/ChangeLog:

YYYY-MM-DD  Scott Linder  <scott@scottlinder.com>
YYYY-MM-DD  Simon Marchi  <simon.marchi@efficios.com>

* inline-frame.c (inline_frame_this_id): Remove assert that prevents
inline frame ids in outer frame.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/frame-inlined-in-outer-frame.exp: New file.
* gdb.dwarf2/frame-inlined-in-outer-frame.S: New file.

Change-Id: I8aa129c667dccc31590ffdf426586418493a6ebe

4 years agogdb: introduce explicit outer frame id kind
Simon Marchi [Mon, 31 Aug 2020 17:23:12 +0000 (13:23 -0400)]
gdb: introduce explicit outer frame id kind

In the following patch, we'll need to easily differentiate the frame_id
of the outer frame (or the frame id of a frame inlined into the outer
frame) from a simply invalid frame id.

Currently, the frame id of the outer frame has `stack_status` set to
FID_STACK_INVALID plus special_addr_p set.  A frame inlined into the
outer frame would also have `artificial_depth` set to greater than one.
That makes the job of differntiating the frame id of the outer frame (or a
frame inlined into the outer frame) cumbersome.

To make it easier, give the outer frame id its own frame_id_stack_status
enum value.  outer_frame_id then becomes very similar to
sentinel_frame_id, another "special" frame id value.

In frame_id_p, we don't need a special case for the outer frame id, as
it's no long a special case of FID_STACK_INVALID.  Same goes for
frame_id_eq.

So in the end, FID_STACK_OUTER isn't even used (except in
fprint_frame_id).  But that's expected: all the times we wanted to
identify an outer frame was to differentiate it from an otherwise
invalid frame.  Since their frame_id_stack_status value is different
now, that is done naturally.

gdb/ChangeLog:

* frame.h (enum frame_id_stack_status) <FID_STACK_OUTER>: New.
* frame.c (fprint_frame_id): Handle FID_STACK_OUTER.
(outer_frame_id): Use FID_STACK_OUTER instead of
FID_STACK_INVALID.
(frame_id_p): Don't check for outer_frame_id.

Change-Id: I654e7f936349debc4f04f7f684b15e71a0c37619

4 years agogdb: make frame_unwind_got_optimized return a not_lval value
Simon Marchi [Mon, 31 Aug 2020 17:22:54 +0000 (13:22 -0400)]
gdb: make frame_unwind_got_optimized return a not_lval value

TLDR: frame_unwind_got_optimized uses wrong frame id value, trying to
fix it makes GDB sad, return not_lval value and don't use frame id value
instead.

Longer version:

The `prev_register` method of the `frame_unwind` interface corresponds
to asking the question: "where did this frame - passed as a parameter -
save the value this register had in its caller frame?".  When "this
frame" did not save that register value (DW_CFA_undefined in DWARF), the
implementation can use the `frame_unwind_got_optimized` function to
create a struct value that represents the optimized out / not saved
register.

`frame_unwind_got_optimized` marks the value as fully optimized out,
sets the lval field to lval_register and assigns the required data for
lval_register: the next frame id and the register number.  The problem
is that it uses the frame id from the wrong frame (see below for in
depth explanation).  In practice, this is not problematic because the
frame id is never used: the value is already not lazy (and is marked as
optimized out), so the value is never fetched from the target.

When trying to change it to put the right next frame id in the value, we
bump into problems: computing the frame id for some frame requires
unwinding some register, if that register is not saved / optimized out,
we try to get the frame id that we are currently computing.

This patch addresses the problem by changing
`frame_unwind_got_optimized` to return a not_lval value instead.  Doing
so, we don't need to put a frame id, so we don't hit that problem.  It
may seem like an unnecessary change today, because it looks like we're
fixing something that is not broken (from the user point of view).
However, the bug becomes user visible with the following patches, where
inline frames are involved.  I put this change in its own patch to keep
it logically separate.

Let's now illustrate how we are putting the wrong frame id in the value
returned by `frame_unwind_got_optimized`.  Let's assume this stack:

    frame #0
    frame #1
    frame #2
    frame #3

Let's suppose that we are calling `frame_unwind_register_value` with
frame #2 as the "next_frame" parameter and some register number X as the
regnum parameter.  That is like asking the question "where did frame #2
save frame #3's value for register X".

`frame_unwind_register_value` calls the frame unwinder's `prev_register`
method, which in our case is `dwarf2_frame_prev_register`.  Note that in
`dwarf2_frame_prev_register`, the parameter is now called `this_frame`,
but its value is still frame #2, and we are still looking for where
frame #2 saved frame #3's value of register X.

Let's now suppose that frame #2's CFI explicitly indicates that the
register X is was not saved (DW_CFA_undefined).  We go into
`frame_unwind_got_optimized`.

In `frame_unwind_got_optimized`, the intent is to create a value that
represents register X in frame #3.  An lval_register value requires that
we specify the id of the _next_ frame, that is the frame from which we
would need to unwind in order to get the value.  Therefore, we would
want to put the id of frame #2 in there.

However, `frame_unwind_got_optimized` does:

    VALUE_NEXT_FRAME_ID (val)
      = get_frame_id (get_next_frame_sentinel_okay (frame));

where `frame` is frame #2.  The get_next_frame_sentinel_okay call
returns frame #1, so we end up putting frame #1's id in the value.

Let's now pretend that we try to "fix" it by placing the right frame id,
in other words doing this change:

    --- a/gdb/frame-unwind.c
    +++ b/gdb/frame-unwind.c
    @@ -260,8 +260,7 @@ frame_unwind_got_optimized (struct frame_info *frame, int regnum)
       mark_value_bytes_optimized_out (val, 0, TYPE_LENGTH (type));
       VALUE_LVAL (val) = lval_register;
       VALUE_REGNUM (val) = regnum;
    -  VALUE_NEXT_FRAME_ID (val)
    -    = get_frame_id (get_next_frame_sentinel_okay (frame));
    +  VALUE_NEXT_FRAME_ID (val) = get_frame_id (frame);
       return val;
     }

This makes some tests fails, such as gdb.dwarf2/dw2-undefined-ret-addr.exp,
like so:

    ...
    #9  0x0000557a8ab15a5d in internal_error (file=0x557a8b31ef80 "/home/simark/src/binutils-gdb/gdb/frame.c", line=623, fmt=0x557a8b31efe0 "%s: Assertion `%s' failed.") at /home/simark/src/binutils-gdb/gdbsupport/errors.cc:55
    #10 0x0000557a87f816d6 in get_frame_id (fi=0x62100034bde0) at /home/simark/src/binutils-gdb/gdb/frame.c:623
    #11 0x0000557a87f7cac7 in frame_unwind_got_optimized (frame=0x62100034bde0, regnum=16) at /home/simark/src/binutils-gdb/gdb/frame-unwind.c:264
    #12 0x0000557a87a71a76 in dwarf2_frame_prev_register (this_frame=0x62100034bde0, this_cache=0x62100034bdf8, regnum=16) at /home/simark/src/binutils-gdb/gdb/dwarf2/frame.c:1267
    #13 0x0000557a87f86621 in frame_unwind_register_value (next_frame=0x62100034bde0, regnum=16) at /home/simark/src/binutils-gdb/gdb/frame.c:1288
    #14 0x0000557a87f855d5 in frame_register_unwind (next_frame=0x62100034bde0, regnum=16, optimizedp=0x7fff5f459070, unavailablep=0x7fff5f459080, lvalp=0x7fff5f4590a0, addrp=0x7fff5f4590b0, realnump=0x7fff5f459090, bufferp=0x7fff5f459150 "") at /home/simark/src/binutils-gdb/gdb/frame.c:1191
    #15 0x0000557a87f860ef in frame_unwind_register (next_frame=0x62100034bde0, regnum=16, buf=0x7fff5f459150 "") at /home/simark/src/binutils-gdb/gdb/frame.c:1247
    #16 0x0000557a881875f9 in i386_unwind_pc (gdbarch=0x621000190110, next_frame=0x62100034bde0) at /home/simark/src/binutils-gdb/gdb/i386-tdep.c:1971
    #17 0x0000557a87fe58a5 in gdbarch_unwind_pc (gdbarch=0x621000190110, next_frame=0x62100034bde0) at /home/simark/src/binutils-gdb/gdb/gdbarch.c:3062
    #18 0x0000557a87a6267b in dwarf2_tailcall_sniffer_first (this_frame=0x62100034bde0, tailcall_cachep=0x62100034bee0, entry_cfa_sp_offsetp=0x7fff5f4593f0) at /home/simark/src/binutils-gdb/gdb/dwarf2/frame-tailcall.c:387
    #19 0x0000557a87a70cdf in dwarf2_frame_cache (this_frame=0x62100034bde0, this_cache=0x62100034bdf8) at /home/simark/src/binutils-gdb/gdb/dwarf2/frame.c:1198
    #20 0x0000557a87a711c2 in dwarf2_frame_this_id (this_frame=0x62100034bde0, this_cache=0x62100034bdf8, this_id=0x62100034be40) at /home/simark/src/binutils-gdb/gdb/dwarf2/frame.c:1226
    #21 0x0000557a87f81167 in compute_frame_id (fi=0x62100034bde0) at /home/simark/src/binutils-gdb/gdb/frame.c:587
    #22 0x0000557a87f81803 in get_frame_id (fi=0x62100034bde0) at /home/simark/src/binutils-gdb/gdb/frame.c:635
    #23 0x0000557a87f7efef in scoped_restore_selected_frame::scoped_restore_selected_frame (this=0x7fff5f459920) at /home/simark/src/binutils-gdb/gdb/frame.c:320
    #24 0x0000557a891488ae in print_frame_args (fp_opts=..., func=0x621000183b90, frame=0x62100034bde0, num=-1, stream=0x6030000caa20) at /home/simark/src/binutils-gdb/gdb/stack.c:750
    #25 0x0000557a8914e87a in print_frame (fp_opts=..., frame=0x62100034bde0, print_level=0, print_what=SRC_AND_LOC, print_args=1, sal=...) at /home/simark/src/binutils-gdb/gdb/stack.c:1394
    #26 0x0000557a8914c2ae in print_frame_info (fp_opts=..., frame=0x62100034bde0, print_level=0, print_what=SRC_AND_LOC, print_args=1, set_current_sal=1) at /home/simark/src/binutils-gdb/gdb/stack.c:1119
    ...

We end up calling get_frame_id (in the hunk above, frame #10)  while we are
computing it (frame #21), and that's not good.

Now, the question is how do we fix this.  I suggest making the unwinder
return a not_lval value in this case.

The reason why we return an lval_register here is to make sure that this
is printed as "not saved" and not "optimized out" down the line.  See
these two commits:

1. 901461f8eb40 ("Print registers not saved in the frame as "<not saved>"
   instead of "<optimized out>".").
2. 6bd273ae450b ("Make "set debug frame 1" output print <not saved> instead of
   <optimized out>.")

The current design (introduced by the first commit) is to check the
value's lval to choose which one to print (see val_print_optimized_out).

Making the unwinder return not_lval instead of lval_register doesn't
break "not saved" when doing "print $rax" or "info registers", because
value_fetch_lazy_register only consumes the contents and optimized-out
property from the value the unwinder returned.  The value being
un-lazified stays an lval_register.

I believe that this is a correct technical solution (and not just
papering over the problem), because what we expect of unwinders is to
tell us where a given register's value is saved.  If the value is saved
in memory, -> lval_memory.  If the value is saved in some other register
of the next frame, -> lval_register.  If the value is not saved, it
doesn't really make sense to return an lval_register value.  not_lval
would be more appropriate.  If the code then wants to represent an
optimized out register value (like value_fetch_lazy_register does), then
it's a separate concern which shouldn't involve the unwinder.

This change breaks the output of "set debug frame 1" though (introduced
by the second commit), since that logging statement consumes the return
value of the unwinder directly.  To keep the correct behavior, just make
`frame_unwind_register_value` call `val_print_not_saved` directly,
instead of `val_print_optimized_out`.  This is fine because we know in
this context that we are always talking about a register value, and that
we want to show "not saved" for those.

I augmented the gdb.dwarf2/dw2-reg-undefined.exp test case to test some
cases I stumbled on while working on this, which I think are not tested
anywhere:

- the "set debug frame 1" debug output mentioned above.  It's just debug
  output, but if we want to make sure it doesn't change, it should be
  tested
- printing not-saved register values from the history (should print not
  saved)
- copying a not-saved register value in a convenience variable.  In this
  case, we expect that printing the convenience variable shows
  "optimized out", because we copied the value, not the property of
  where the value came from.

gdb/ChangeLog:

* frame-unwind.c (frame_unwind_got_optimized): Don't set
regnum/frame in value.  Call allocate_value_lazy.
* frame.c (frame_unwind_register_value): Use
val_print_not_saved.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-reg-undefined.exp: Test "set debug frame 1"
output, printing a "not saved" value from history and printing a
convenience variable created from a "not saved" value.

Change-Id: If451739a3ef7a5b453b1f50707e21ce16d74807e

4 years agogdb: remove NULL_TYPE
Simon Marchi [Mon, 31 Aug 2020 14:44:33 +0000 (10:44 -0400)]
gdb: remove NULL_TYPE

The NULL_TYPE macro is not very useful... remove it and just use
nullptr.

gdb/ChangeLog:

* gdbtypes.h (NULL_TYPE): Remove, change all uses to nullptr.

Change-Id: Ic6215921413dad5649192b012f1a41d0a650a644

4 years agoPR26510 UBSAN: tc-z8k.c left shift of negative value
Alan Modra [Mon, 31 Aug 2020 08:04:39 +0000 (17:34 +0930)]
PR26510 UBSAN: tc-z8k.c left shift of negative value

This also fixes the packing of the nibble buffer, which contains
rubbish in the top 4 bits of each element.

PR 26510
* config/tc-z8k.c (buffer): Use unsigned char.
(apply_fix): Use unsigned char* pointers.
(build_bytes): Likewise and mask nibbles when packing.

4 years agoPR26503 UBSAN: tc-v850.c:1447 left shift cannot be represented
Alan Modra [Mon, 31 Aug 2020 07:51:06 +0000 (17:21 +0930)]
PR26503 UBSAN: tc-v850.c:1447 left shift cannot be represented

PR 26503
* config/tc-v850.c (parse_register_list): Shift 1u left.

4 years agoPR26502 UBSAN: tc-tic6x.c left shift of negative value
Alan Modra [Mon, 31 Aug 2020 07:46:21 +0000 (17:16 +0930)]
PR26502 UBSAN: tc-tic6x.c left shift of negative value

PR 26502
* config/tc-tic6x.c (md_apply_fix): Use unsigned variables.

4 years agoPR26497 UBSAN: tc-sh.c:2467 left shift cannot be represented
Alan Modra [Mon, 31 Aug 2020 07:12:42 +0000 (16:42 +0930)]
PR26497 UBSAN: tc-sh.c:2467 left shift cannot be represented

PR 26497
* config/tc-sh.c (assemble_ppi): Use unsigned variables.

4 years agoPR26495 UBSAN: tc-score.c, tc-score7.c left shift of negative value
Alan Modra [Mon, 31 Aug 2020 07:00:45 +0000 (16:30 +0930)]
PR26495 UBSAN: tc-score.c, tc-score7.c left shift of negative value

PR 26495
* config/tc-score.c (s3_apply_fix): Use unsigned variables.
* config/tc-score7.c (s7_apply_fix): Likewise.

4 years agoPR26480 UBSAN: tc-nios2.c:1634 left shift cannot be represented
Alan Modra [Mon, 31 Aug 2020 06:25:20 +0000 (15:55 +0930)]
PR26480 UBSAN: tc-nios2.c:1634 left shift cannot be represented

PR 26480
* config/tc-nios2.c (nios2_parse_reglist): Shift 1UL left.

4 years agoPR26479 UBSAN: tc-nios2.c:244 left shift cannot be represented
Alan Modra [Mon, 31 Aug 2020 06:21:24 +0000 (15:51 +0930)]
PR26479 UBSAN: tc-nios2.c:244 left shift cannot be represented

PR 26479
* config/tc-nios2.c (md_chars_to_number): Cast buf[i] before shifting.

4 years agoPR26472, PR26473, PR26474 UBSAN: tc-mips.c shift left UB
Alan Modra [Mon, 31 Aug 2020 06:08:25 +0000 (15:38 +0930)]
PR26472, PR26473, PR26474 UBSAN: tc-mips.c shift left UB

PR 26472
PR 26473
PR 26474
* config/tc-mips.c (operand_reg_mask): Shift 1u left.
(load_register): Shift 0xffffU left.

4 years agoPR26471 UBSAN: tc-metag.c:7038 left shift cannot be represented
Alan Modra [Mon, 31 Aug 2020 05:06:34 +0000 (14:36 +0930)]
PR26471 UBSAN: tc-metag.c:7038 left shift cannot be represented

PR 26471
* config/tc-metag.c (md_chars_to_number): Make retval unsigned.

4 years agoPR26468 UBSAN: tc-mep.c:1684 left shift of negative value
Alan Modra [Mon, 31 Aug 2020 05:01:55 +0000 (14:31 +0930)]
PR26468 UBSAN: tc-mep.c:1684 left shift of negative value

PR 26468
* config/tc-mep.c (md_convert_frag): Use uint32_t for addend and
other variables.

4 years agoPR26493 UBSAN: tc-riscv.c left shift negative and not representable
Alan Modra [Mon, 31 Aug 2020 08:35:54 +0000 (18:05 +0930)]
PR26493 UBSAN: tc-riscv.c left shift negative and not representable

PR 26493
* config/tc-riscv.c (riscv_ip): Cast X_add_number passed to
VALID_* macros to unsigned.

4 years agoPR26493 UBSAN: elfnn-riscv.c left shift of negative value
Alan Modra [Mon, 31 Aug 2020 03:47:06 +0000 (13:17 +0930)]
PR26493 UBSAN: elfnn-riscv.c left shift of negative value

include/
PR 26493
* opcode/riscv.h (OP_MASK_CSR, OP_MASK_CUSTOM_IMM)
(OP_MASK_FUNCT7, OP_MASK_RS3): Make unsigned.
bfd/
PR 26493
* elfnn-riscv.c (riscv_make_plt_header): Cast PLT_HEADER_SIZE to
unsigned when using with RISCV_ITYPE.
(_bfd_riscv_relax_call): Use an unsigned foff.

4 years agoPR26476, PR26477 UBSAN: elfxx-mips.c:2695,5370 cannot be represented
Alan Modra [Mon, 31 Aug 2020 02:08:05 +0000 (11:38 +0930)]
PR26476, PR26477 UBSAN: elfxx-mips.c:2695,5370 cannot be represented

PR 26476
PR 26477
* elfxx-mips.c (CRINFO_CTYPE, CRINFO_RTYPE, CRINFO_DIST2TO),
(CRINFO_RELVADDR): Make unsigned.
(mips_elf_nullify_got_load): Use unsigned constant when shifting
into sign bit.

4 years agoPR26466 UBSAN: elf32-mep.c:300 left shift of negative value
Alan Modra [Mon, 31 Aug 2020 01:44:31 +0000 (11:14 +0930)]
PR26466 UBSAN: elf32-mep.c:300 left shift of negative value

PR 26466
* mep-relocs.pl (emit_apply): Handle HI16S adjustment.  Use "u"
variable and rewrite signed overflow check.
* elf32-mep.c: Regenerate.
(mep_final_link_relocate): Delete "s".

4 years agoPR26461 UBSAN: elfxx-ia64.c:747 cannot be represented
Alan Modra [Mon, 31 Aug 2020 00:45:34 +0000 (10:15 +0930)]
PR26461 UBSAN: elfxx-ia64.c:747 cannot be represented

PR 26461
* elfxx-ia64.c (ia64_elf_install_value): Make expressions unsigned
that might shift values into sign bit.

4 years agoPR26457 UBSAN: som.c:1794 left shift cannot be represented
Alan Modra [Mon, 31 Aug 2020 00:33:59 +0000 (10:03 +0930)]
PR26457 UBSAN: som.c:1794 left shift cannot be represented

PR 26457
* som/aout.h (SOM_SUBSPACE_ACCESS_CONTROL_BITS_MASK): Make unsigned.
(SOM_SUBSPACE_MEMORY_RESIDENT, SOM_SUBSPACE_DUP_COMMON)
(SOM_SUBSPACE_IS_COMMON, SOM_SUBSPACE_IS_LOADABLE)
(SOM_SUBSPACE_QUADRANT_MASK, SOM_SUBSPACE_INITIALLY_FROZEN)
(SOM_SUBSPACE_IS_FIRST, SOM_SUBSPACE_CODE_ONLY)
(SOM_SUBSPACE_SORT_KEY_MASK, SOM_SUBSPACE_REPLICATE_INIT)
(SOM_SUBSPACE_CONTINUATION, SOM_SUBSPACE_IS_TSPECIFIC)
(SOM_SUBSPACE_IS_COMDAT): Likewise.

4 years agoPR26445 UBSAN: elf32-csky.c:4115 left shift of negative value
Alan Modra [Mon, 31 Aug 2020 00:20:49 +0000 (09:50 +0930)]
PR26445 UBSAN: elf32-csky.c:4115 left shift of negative value

PR 26445
* elf32-csky.c (csky_relocate_contents): Make relocation a bfd_vma,
and similarly for variables dealing with overflow.

4 years agocrx: ubsan: cannot be represented
Alan Modra [Sun, 30 Aug 2020 23:37:03 +0000 (09:07 +0930)]
crx: ubsan: cannot be represented

* config/tc-crx.c: Formatting.
(CRX_PRINT): Wrap params in parentheses.  Remove parens from uses
throughout file.
(reset_vars, get_register, get_copregister, get_optype, get_opbits),
(get_opflags, get_number_of_operands, parse_operand, gettrap),
(handle_LoadStor, getconstant, check_range, getreg_image),
(parse_operands, parse_insn, print_operand, print_constant),
(exponent2scale, mask_reg, process_label_constant, set_operand),
(assemble_insn, print_insn): Delete unnecessary forward declaration.
(print_insn): Make static.
(print_constant): Make "constant" unsigned.
(assemble_insn): Tidy REVERSE_MATCH index calc.
* expr.c (generic_bignum_to_int32): Cast elements to valueT.

4 years agoPR26442 UBSAN: elf32-crx.c:512 cannot be represented in int
Alan Modra [Sun, 30 Aug 2020 23:02:32 +0000 (08:32 +0930)]
PR26442 UBSAN: elf32-crx.c:512 cannot be represented in int

PR 26442
* elf32-crx.c (crx_elf_final_link_relocate): Calculate reloc_bits
without undefined behaviour.  Tidy excess casts.

4 years agoPR26509 UBSAN: tc-z80.c:3656 shift exponent is too large
Alan Modra [Sun, 30 Aug 2020 22:43:19 +0000 (08:13 +0930)]
PR26509 UBSAN: tc-z80.c:3656 shift exponent is too large

PR 26509
* config/tc-z80.c (is_overflow): Use 1UL in mask shift expression.

4 years agomn10300: ubsan: shift exponent too large
Alan Modra [Sun, 30 Aug 2020 22:39:23 +0000 (08:09 +0930)]
mn10300: ubsan: shift exponent too large

* elf-m10300.c (mn10300_elf_relax_delete_bytes): Calculate
alignment from reloc addend after reloc type R_MN10300_ALIGN is
found.

4 years agotic4x-coff: ubsan: various shift UB
Alan Modra [Sun, 30 Aug 2020 14:13:54 +0000 (23:43 +0930)]
tic4x-coff: ubsan: various shift UB

* config/tc-tic4x.c (tic4x_gen_to_words): Rewrite mantissa
overflow test without UB.  Avoid other UB shifts by making them
unsigned.

4 years ago[gdb/testsuite] Add nopie to gdb.base/eh_return.exp
Tom de Vries [Mon, 31 Aug 2020 08:42:01 +0000 (10:42 +0200)]
[gdb/testsuite] Add nopie to gdb.base/eh_return.exp

When running test-case gdb.base/eh_return.exp with target board
unix/-fPIE/-pie, we run into:
...
(gdb) break *0x88e^M
Breakpoint 1 at 0x88e: file eh_return.c, line 54.^M
(gdb) PASS: gdb.base/eh_return.exp: setting breakpoint at *0x88e
run ^M
Starting program: eh_return ^M
Warning:^M
Cannot insert breakpoint 1.^M
Cannot access memory at address 0x88e^M
^M
(gdb) FAIL: gdb.base/eh_return.exp: hit breakpoint
...

The problem is that gdb does not support setting breakpoints on unrelocated
addresses.

Fix this by using nopie for the test-case.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-08-31  Tom de Vries  <tdevries@suse.de>

* gdb.base/eh_return.exp: Use nopie.

4 years agoCSKY: Refine operand format error reporting.
Cooper Qu [Mon, 31 Aug 2020 03:27:54 +0000 (11:27 +0800)]
CSKY: Refine operand format error reporting.

Rename SET_ERROR_NUMBER to SET_ERROR_STRING, and add SET_ERROR_INTEGER
to report error message which pass an integer argument.

gas/
* config/tc-csky.c (csky_error_state): New member 'arg_int'.
(SET_ERROR_NUMBER): Rename to SET_ERROR_STRING.
(SET_ERROR_INTEGER): New.
(err_formats): Add error format for ERROR_FREG_OVER_RANGE and
ERROR_VREG_OVER_RANGE.
(csky_show_error): Pass an integer argument for some error
numbers.
(parse_exp): Call SET_ERROR_STRING instead of SET_ERROR_NUMBER.
(parse_rt): Likewise.
(parse_type_ctrlreg): Likewise.
(csky_get_reg_val): Likewise.
(is_reglist_legal): Likewise.
(is_freglist_legal): Likewise.
(is_reglist_dash_comma_legal): Likewise.
(is_reg_lshift_illegal): Likewise.
(is_psr_bit): Likewise.
(parse_type_cpreg): Likewise.
(parse_type_cpcreg): Likewise.
(parse_type_areg): Likewise.
(parse_type_freg): Likewise.
(parse_ldst_imm): Likewise and call SET_ERROR_INTEGER.
(get_operand_value): Likewise.
(parse_operands_op): Likewise and call is_imm_within_range,
is_imm_within_range_ext and is_oimm_within_range.
(md_assemble): Likewise.
(is_imm_within_range): New.
(is_imm_within_range_ext): Rename from is_imm_over_range.
(is_oimm_within_range): Rename from is_oimm_over_range.
(v2_work_add_sub): Call SET_ERROR_INTEGER.
(csky_rolc): call is_imm_within_range instead of
is_imm_over_range.

opcodes/
* csky-dis.c (csky_output_operand): Assign dis_info.value for
OPRND_TYPE_VREG.

4 years agoCSKY: Add warning when -mdsp and -mcpu=ck803ern are both added.
Cooper Qu [Mon, 31 Aug 2020 02:55:06 +0000 (10:55 +0800)]
CSKY: Add warning when -mdsp and -mcpu=ck803ern are both added.

gas/
* config/tc-csky.c (md_begin): Add warning when -mdsp and
  -mcpu=ck803ern are both added.
  (parse_ldst_imm): Fix error message.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 31 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agold: Add $NOSANTIZE_CFLAGS to more linker tests
H.J. Lu [Sun, 30 Aug 2020 14:27:02 +0000 (07:27 -0700)]
ld: Add $NOSANTIZE_CFLAGS to more linker tests

* testsuite/ld-elf/dwarf.exp: Append $NOSANTIZE_CFLAGS to CFLAGS.
* testsuite/ld-elf/shared.exp: Likewise.
* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
* testsuite/ld-shared/shared.exp: Likewise.
* testsuite/ld-size/size.exp: Likewise.

4 years agochangelog PR fix
Alan Modra [Sun, 30 Aug 2020 13:29:13 +0000 (22:59 +0930)]
changelog PR fix

for the lack of a space