binutils-gdb.git
4 years agoFix advance/until and inline frames (PR gdb/26523)
Pedro Alves [Thu, 27 Aug 2020 20:03:53 +0000 (21:03 +0100)]
Fix advance/until and inline frames (PR gdb/26523)

If you do "tbreak LINENO; c" to advance to an inlined function, GDB
presents the stop at the inline frame instead of at the non-artificial
stack frame:

 (gdb) list 21
 18      static inline __attribute__ ((always_inline)) int
 19      inline_func (int i)
 20      {
 21        return i + 1;
 22      }

 (gdb) tbreak 21
 Temporary breakpoint 3 at 0x55555555516f: advance.cc:21.
 (gdb) c
 Continuing.

 Temporary breakpoint 3, inline_func (i=0) at advance.cc:21
 21        return i + 1;

The logic for this is in stopped_by_user_bp_inline_frame:

 /* Loop over the stop chain and determine if execution stopped in an
    inlined frame because of a breakpoint with a user-specified
    location set at FRAME_BLOCK.  */

 static bool
 stopped_by_user_bp_inline_frame (const block *frame_block, bpstat stop_chain)

If however, you do "advance LINENO" or "until LINENO" instead, GDB
presents the stop at the non-artificial frame:

 (gdb) advance 21
 main () at advance.cc:43
 43        i = inline_func (i);
 (gdb)

"advance" and "until" should really behave like user breakpoints here,
since their location is also user-specified.  As the comment in
gdb.base/advance.exp says, "advance <location>" is really just
syntactic sugar for "tbreak <location>; continue".

Fix this by making stopped_by_user_bp_inline_frame also consider
advance/until breakpoints.

A testcase covering this will be included in the next patch.

gdb/ChangeLog:

PR gdb/26523
* inline-frame.c (stopped_by_user_bp_inline_frame): Also consider
bp_until breakpoints user-specified locations.  Update intro
comment.

4 years agoreadelf: MSP430: Fix incorrect usage of "msp430x" in function names
Jozef Lawrynowicz [Thu, 27 Aug 2020 19:48:35 +0000 (20:48 +0100)]
readelf: MSP430: Fix incorrect usage of "msp430x" in function names

The "X" in "MSP430X" indicates an extension to the original MSP430 ISA, but
these functions are generically used for all MSP430 ISAs, so the names should
not use the "X" suffix.

binutils/ChangeLog:

* readelf.c (get_msp430x_section_type_name): Rename to ...
(get_msp430_section_type_name): ... this.
(get_section_type_name): Use get_msp430_section_type_name.
(display_msp430x_attribute): Rename to ...
(display_msp430_attribute): ... this.
(process_arch_specific): Use display_msp430_attribute.

4 years agold/emultempl/msp430.em: Remove unused variable
Jozef Lawrynowicz [Thu, 27 Aug 2020 17:17:43 +0000 (18:17 +0100)]
ld/emultempl/msp430.em: Remove unused variable

ld/ChangeLog:

* emultempl/msp430.em: Remove unused variable "buf".

4 years agogdb/testsuite: use multi_line in gdb.dwarf2/dw2-reg-undefined.exp
Simon Marchi [Thu, 27 Aug 2020 18:42:12 +0000 (14:42 -0400)]
gdb/testsuite: use multi_line in gdb.dwarf2/dw2-reg-undefined.exp

Use multi_line to make the expected pattern more readable.

gdb/testsuite/ChangeLog:

*  gdb.dwarf2/dw2-reg-undefined.exp: Use multi_line.

Change-Id: Ia8e42d156c0c30265121eb890e1db17a692dbaf0

4 years agogdb: fix whitespace issues in ChangeLog files
Simon Marchi [Thu, 27 Aug 2020 16:54:00 +0000 (12:54 -0400)]
gdb: fix whitespace issues in ChangeLog files

Change-Id: I423867477d4342673e629dac71a80592fd879ea1

4 years agogdb/testsuite: make test names unique in gdb.arch/*.exp
Andrew Burgess [Wed, 26 Aug 2020 13:05:45 +0000 (14:05 +0100)]
gdb/testsuite: make test names unique in gdb.arch/*.exp

Make the test names unique in gdb.arch/*.exp by either modifying the
test names or using with_test_prefix.

I have also fixed a typo 'forth' -> 'fourth' throughout gdb.arch/*.

Finally, I replaced code like this:

  gdb_test "break [gdb_get_line_number "first breakpoint here"]" \
           "Breakpoint .* at .*${srcfile}.*" \
           "set first breakpoint in main"

With this:

  gdb_breakpoint [gdb_get_line_number "first breakpoint here"]

In those files that I was already modifying for the other reasons
given above.

gdb/testsuite/ChangeLog:

* gdb.arch/amd64-byte.exp: Make test names unique, use
gdb_breakpoint, and fix typo 'forth' -> 'fourth'.
* gdb.arch/amd64-dword.exp: Likewise.
* gdb.arch/amd64-pseudo.c: Fix typo 'forth' -> 'fourth'.
* gdb.arch/amd64-stap-special-operands.exp: Make test names
unique.
* gdb.arch/amd64-tailcall-ret.exp: Likewise.
* gdb.arch/amd64-word.exp: Make test names unique, use
gdb_breakpoint, and fix typo 'forth' -> 'fourth'.
* gdb.arch/i386-byte.exp: Make test names unique, use
gdb_breakpoint.
* gdb.arch/i386-word.exp: Likewise.

4 years agoFix PR binutils/26356 on hppa*-*-hpux*.
John David Anglin [Thu, 27 Aug 2020 15:25:03 +0000 (15:25 +0000)]
Fix PR binutils/26356 on hppa*-*-hpux*.

PR 26356
* som.c (som_bfd_copy_private_section_data): Issue error when a
subspace is specified without its containing space.
* testsuite/binutils-all/objcopy.exp (objcopy --reverse-bytes): Add
"-j $PRIVATE$" to command on hppa*-*-hpux*.
* testsuite/lib/utils-lib.exp (default_binutils_run): Remove existing
dollar-sign quotes before quoting.  Do this prior to generating log
output.

4 years agoCorrects the broken line number incrementation in the Windows resource parser
Ralf Habacker [Thu, 27 Aug 2020 14:59:53 +0000 (15:59 +0100)]
Corrects the broken line number incrementation in the Windows resource parser

When the tokens MCLINE, MCENDLINE, and MCCOMMENT were created, the
line number was not increased, which led to an incorrect value in
the error output.

PR 26088
* mclex.c (skip_until_eol): if eol was found, increment line number

4 years agogdb: add gdb_bfd_sections for range-based iteration
Simon Marchi [Thu, 27 Aug 2020 12:58:43 +0000 (08:58 -0400)]
gdb: add gdb_bfd_sections for range-based iteration

I wanted to make a nicer / type-safe interface for
bfd_map_over_sections, avoiding the `void *` data parameter.

My first shot was to make a wrapper for bfd_map_over_sections,
gdb_bfd_map_over_sections that took a gdb::function_view.

However, I think that a range adapter gives nicer and simpler code, as a
simple for loop is easier to read than a callback / lambda function.  So
here it is, it uses next_iterator and next_adapter, so it's not much
code.

As an example, I ported maintenance_info_sections and friends to use it.
The maint_print_section_data type could probably be removed now, but I
didn't want to do too much in one patch.

gdb/ChangeLog:

* gdb_bfd.h (gdb_bfd_section_iterator, gdb_bfd_section_range,
gdb_bfd_sections): New.
* maint.c (print_bfd_section_info): Change param type to
maint_print_section_data.
(print_objfile_section_info): Likewise.
(print_bfd_section_info_maybe_relocated): Likewise.
(maintenance_info_sections): Use gdb_bfd_sections.

Change-Id: Ib496f6b0a0eb7aadb10da1dd381304014d934ea0

4 years agoRemove commit 9fb2400ce6
Nick Clifton [Thu, 27 Aug 2020 12:52:45 +0000 (13:52 +0100)]
Remove commit  9fb2400ce6

4 years agoFix linker testcase for alpha-linux affected by fix for PR 26416
Nick Clifton [Thu, 27 Aug 2020 12:47:02 +0000 (13:47 +0100)]
Fix linker testcase for alpha-linux affected by fix for PR 26416

PR 26416
* testsuite/ld-alpha/tlsbinr.rd: Update expected output.
* testsuite/ld-alpha/tlsbinr.dd: Likewise.
* testsuite/ld-alpha/tlsbinr.sd: Likewise.

4 years agoPR26469 UBSAN: elflink.c:8742 shift exponent 6148914691236511722
Alan Modra [Thu, 27 Aug 2020 12:14:41 +0000 (21:44 +0930)]
PR26469 UBSAN: elflink.c:8742 shift exponent 6148914691236511722

PR 26469
* elflink.c: Include limits.h.
(CHAR_BIT): Provide fallback define.
(set_symbol_value): Correct complex reloc comment.
(undefined_reference): Set bfd_error.
(BINARY_OP_HEAD, BINARY_OP_TAIL): Split out from..
(BINARY_OP): ..this.
(eval_symbol): Limit shifts.  Force unsigned for left shift.
Catch divide by zero.
* configure.ac (AC_CHECK_HEADERS): Combine, sort and add limits.h.
* configure: Regenerate.
* config.in: Regenerate.

4 years agoPR26467 UBSAN: cgen.c:762 shift exponent 18446744073709551615
Alan Modra [Thu, 27 Aug 2020 04:16:45 +0000 (13:46 +0930)]
PR26467 UBSAN: cgen.c:762 shift exponent 18446744073709551615

PR 26467
* cgen.c (weak_operand_overflow_check): Handle opmask for
operand length zero.  Use 1UL constant.

4 years agoPR26462 UBSAN: reloc.c:473 shift exponent 4294967295
Alan Modra [Thu, 27 Aug 2020 03:55:31 +0000 (13:25 +0930)]
PR26462 UBSAN: reloc.c:473 shift exponent 4294967295

PR 26462
* reloc.c (bfd_check_overflow): Return early if zero bitsize.

4 years agoarm-symbianelf segfault
Alan Modra [Thu, 27 Aug 2020 03:20:20 +0000 (12:50 +0930)]
arm-symbianelf segfault

Yes, the target is marked obsolete due to this and other segfaults,
but this one is easy enough to fix.

* elf32-arm.c (elf32_arm_final_link_relocate): Don't segfault
on sym_sec not being output.

4 years agoRe: commit eae0b5c3b2d6b
Alan Modra [Thu, 27 Aug 2020 12:24:16 +0000 (21:54 +0930)]
Re: commit eae0b5c3b2d6b

PR 26416
* elf64-alpha.c (elf64_alpha_relax_tls_get_addr): Correct "dynamic".

4 years agobinutils, ld: dequote libctf error messages
Nick Alcock [Wed, 29 Jul 2020 12:50:10 +0000 (13:50 +0100)]
binutils, ld: dequote libctf error messages

These are not identifiers and should not be quoted.  (Also, quoting them
just looks odd.)

Adjust diagnostics tests accordingly.

binutils/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* objdump.c (dump_ctf_errs): Unquote CTF error messages.
* readelf.c (dump_ctf_errs): Likewise.

ld/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* ldlang.c (dump_ctf_errs): Unquote CTF error messages.
(ldlang_open_ctf): Likewise.
(lang_merge_ctf): Likewise.
(lang_write_ctf): Likewise.
* testsuite/ld-ctf/diag-ctf-version-f.d: Adjust.
* testsuite/ld-ctf/diag-cttname-invalid.d: Adjust.
* testsuite/ld-ctf/diag-decompression-failure.d: Adjust.
* testsuite/ld-ctf/diag-parname.d: Adjust.
* testsuite/ld-ctf/diag-unsupported-flag.d: Adjust.
* testsuite/ld-ctf/diag-wrong-magic-number-mixed.d: Adjust.
* testsuite/ld-ctf/diag-wrong-magic-number.d: Adjust.

4 years agolibctf, binutils, include, ld: gettextize and improve error handling
Nick Alcock [Mon, 27 Jul 2020 15:45:15 +0000 (16:45 +0100)]
libctf, binutils, include, ld: gettextize and improve error handling

This commit follows on from the earlier commit "libctf, ld, binutils:
add textual error/warning reporting for libctf" and converts every error
in libctf that was reported using ctf_dprintf to use ctf_err_warn
instead, gettextizing them in the process, using N_() where necessary to
avoid doing gettext calls unless an error message is actually generated,
and rephrasing some error messages for ease of translation.

This requires a slight change in the ctf_errwarning_next API: this API
is public but has not been in a release yet, so can still change freely.
The problem is that many errors are emitted at open time (whether
opening of a CTF dict, or opening of a CTF archive): the former of these
throws away its incompletely-initialized ctf_file_t rather than return
it, and the latter has no ctf_file_t at all. So errors and warnings
emitted at open time cannot be stored in the ctf_file_t, and have to go
elsewhere.

We put them in a static local in ctf-subr.c (which is not very
thread-safe: a later commit will improve things here): ctf_err_warn with
a NULL fp adds to this list, and the public interface
ctf_errwarning_next with a NULL fp retrieves from it.

We need a slight exception from the usual iterator rules in this case:
with a NULL fp, there is nowhere to store the ECTF_NEXT_END "error"
which signifies the end of iteration, so we add a new err parameter to
ctf_errwarning_next which is used to report such iteration-related
errors.  (If an fp is provided -- i.e., if not reporting open errors --
this is optional, but even if it's optional it's still an API change.
This is actually useful from a usability POV as well, since
ctf_errwarning_next is usually called when there's been an error, so
overwriting the error code with ECTF_NEXT_END is not very helpful!
So, unusually, ctf_errwarning_next now uses the passed fp for its
error code *only* if no errp pointer is passed in, and leaves it
untouched otherwise.)

ld, objdump and readelf are adapted to call ctf_errwarning_next with a
NULL fp to report open errors where appropriate.

The ctf_err_warn API also has to change, gaining a new error-number
parameter which is used to add the error message corresponding to that
error number into the debug stream when LIBCTF_DEBUG is enabled:
changing this API is easy at this point since we are already touching
all existing calls to gettextize them.  We need this because the debug
stream should contain the errno's message, but the error reported in the
error/warning stream should *not*, because the caller will probably
report it themselves at failure time regardless, and reporting it in
every error message that leads up to it leads to a ridiculous chattering
on failure, which is likely to end up as ridiculous chattering on stderr
(trimmed a bit):

CTF error: `ld/testsuite/ld-ctf/A.c (0): lookup failure for type 3: flags 1: The parent CTF dictionary is unavailable'
CTF error: `ld/testsuite/ld-ctf/A.c (0): struct/union member type hashing error during type hashing for type 80000001, kind 6: The parent CTF dictionary is unavailable'
CTF error: `deduplicating link variable emission failed for ld/testsuite/ld-ctf/A.c: The parent CTF dictionary is unavailable'
ld/.libs/lt-ld-new: warning: CTF linking failed; output will have no CTF section: `The parent CTF dictionary is unavailable'

We only need to be told that the parent CTF dictionary is unavailable
*once*, not over and over again!

errmsgs are still emitted on warning generation, because warnings do not
usually lead to a failure propagated up to the caller and reported
there.

Debug-stream messages are not translated.  If translation is turned on,
there will be a mixture of English and translated messages in the debug
stream, but rather that than burden the translators with debug-only
output.

binutils/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* objdump.c (dump_ctf_archive_member): Move error-
reporting...
(dump_ctf_errs): ... into this separate function.
(dump_ctf): Call it on open errors.
* readelf.c (dump_ctf_archive_member): Move error-
reporting...
(dump_ctf_errs): ... into this separate function.  Support
calls with NULL fp. Adjust for new err parameter to
ctf_errwarning_next.
(dump_section_as_ctf): Call it on open errors.

include/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* ctf-api.h (ctf_errwarning_next): New err parameter.

ld/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* ldlang.c (lang_ctf_errs_warnings): Support calls with NULL fp.
Adjust for new err parameter to ctf_errwarning_next.  Only
check for assertion failures when fp is non-NULL.
(ldlang_open_ctf): Call it on open errors.
* testsuite/ld-ctf/ctf.exp: Always use the C locale to avoid
breaking the diags tests.

libctf/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* ctf-subr.c (open_errors): New list.
(ctf_err_warn): Calls with NULL fp append to open_errors.  Add err
parameter, and use it to decorate the debug stream with errmsgs.
(ctf_err_warn_to_open): Splice errors from a CTF dict into the
open_errors.
(ctf_errwarning_next): Calls with NULL fp report from open_errors.
New err param to report iteration errors (including end-of-iteration)
when fp is NULL.
(ctf_assert_fail_internal): Adjust ctf_err_warn call for new err
parameter: gettextize.
* ctf-impl.h (ctfo_get_vbytes): Add ctf_file_t parameter.
(LCTF_VBYTES): Adjust.
(ctf_err_warn_to_open): New.
(ctf_err_warn): Adjust.
(ctf_bundle): Used in only one place: move...
* ctf-create.c: ... here.
(enumcmp): Use ctf_err_warn, not ctf_dprintf, passing the err number
down as needed.  Don't emit the errmsg.  Gettextize.
(membcmp): Likewise.
(ctf_add_type_internal): Likewise.
(ctf_write_mem): Likewise.
(ctf_compress_write): Likewise.  Report errors writing the header or
body.
(ctf_write): Likewise.
* ctf-archive.c (ctf_arc_write_fd): Use ctf_err_warn, not
ctf_dprintf, and gettextize, as above.
(ctf_arc_write): Likewise.
(ctf_arc_bufopen): Likewise.
(ctf_arc_open_internal): Likewise.
* ctf-labels.c (ctf_label_iter): Likewise.
* ctf-open-bfd.c (ctf_bfdclose): Likewise.
(ctf_bfdopen): Likewise.
(ctf_bfdopen_ctfsect): Likewise.
(ctf_fdopen): Likewise.
* ctf-string.c (ctf_str_write_strtab): Likewise.
* ctf-types.c (ctf_type_resolve): Likewise.
* ctf-open.c (get_vbytes_common): Likewise. Pass down the ctf dict.
(get_vbytes_v1): Pass down the ctf dict.
(get_vbytes_v2): Likewise.
(flip_ctf): Likewise.
(flip_types): Likewise. Use ctf_err_warn, not ctf_dprintf, and
gettextize, as above.
(upgrade_types_v1): Adjust calls.
(init_types): Use ctf_err_warn, not ctf_dprintf, as above.
(ctf_bufopen_internal): Likewise. Adjust calls. Transplant errors
emitted into individual dicts into the open errors if this turns
out to be a failed open in the end.
* ctf-dump.c (ctf_dump_format_type): Adjust ctf_err_warn for new err
argument.  Gettextize.  Don't emit the errmsg.
(ctf_dump_funcs): Likewise.  Collapse err label into its only case.
(ctf_dump_type): Likewise.
* ctf-link.c (ctf_create_per_cu): Adjust ctf_err_warn for new err
argument.  Gettextize.  Don't emit the errmsg.
(ctf_link_one_type): Likewise.
(ctf_link_lazy_open): Likewise.
(ctf_link_one_input_archive): Likewise.
(ctf_link_deduplicating_count_inputs): Likewise.
(ctf_link_deduplicating_open_inputs): Likewise.
(ctf_link_deduplicating_close_inputs): Likewise.
(ctf_link_deduplicating): Likewise.
(ctf_link): Likewise.
(ctf_link_deduplicating_per_cu): Likewise. Add some missed
ctf_set_errnos to obscure error cases.
* ctf-dedup.c (ctf_dedup_rhash_type): Adjust ctf_err_warn for new
err argument.  Gettextize.  Don't emit the errmsg.
(ctf_dedup_populate_mappings): Likewise.
(ctf_dedup_detect_name_ambiguity): Likewise.
(ctf_dedup_init): Likewise.
(ctf_dedup_multiple_input_dicts): Likewise.
(ctf_dedup_conflictify_unshared): Likewise.
(ctf_dedup): Likewise.
(ctf_dedup_rwalk_one_output_mapping): Likewise.
(ctf_dedup_id_to_target): Likewise.
(ctf_dedup_emit_type): Likewise.
(ctf_dedup_emit_struct_members): Likewise.
(ctf_dedup_populate_type_mapping): Likewise.
(ctf_dedup_populate_type_mappings): Likewise.
(ctf_dedup_emit): Likewise.
(ctf_dedup_hash_type): Likewise. Fix a bit of messed-up error
status setting.
(ctf_dedup_rwalk_one_output_mapping): Likewise. Don't hide
unknown-type-kind messages (which signify file corruption).

4 years agolibctf, binutils: initial work towards libctf gettextization
Nick Alcock [Thu, 30 Jul 2020 16:43:12 +0000 (17:43 +0100)]
libctf, binutils: initial work towards libctf gettextization

We gettextize under our package name, which we change to a more
reasonable 'libctf'.  Our internationalization support is mostly
provided by ctf-intl.h, which is a copy of opcodes/opintl.h with
the non-gettext_noop N_() expansion debracketed to avoid pedantic
compiler warnings.

The libctf error strings returned by ctf_errmsg are marked up for
internationalization.

(We also adjust binutils's Makefile a tiny bit to allow for the
fact that libctf now uses functions from libintl.)

binutils/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* Makefile.am (readelf_LDADD): Move $(LIBINTL) after $(LIBCTF_NOBFD).
* Makefile.in: Regenerated.

libctf/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* configure.ac: Adjust package name to simply 'libctf': arbitrarily
declare this to be version 1.2.0.
* Makefile.am (AM_CPPFLAGS): Add @INCINTL@.
* Makefile.in: Regenerated.
* configure: Regenerated.
* ctf-intl.h: New file, lightly modified from opcodes/opintl.h.
* ctf-impl.h: Include it.
* ctf-error.r (_ctf_errlist_t): Mark strings as noop-translatable.
(ctf_errmsg): Actually translate them.

4 years agoChange the default characteristics of DLLs built by the linker to more secure settings.
Jeremy Drake [Thu, 27 Aug 2020 11:58:27 +0000 (12:58 +0100)]
Change the default characteristics of DLLs built by the linker to more secure settings.

PR 19011
* emultempl/pe.em (DEFAULT_DLL_CHARACTERISTICS): Define.
(pe_dll_characteristics): Initialise to DEFAULT_DLL_CHARACTERISTICS.
(add_options): Add options to disable DLL characteristics.
(list_options): List the new options.
(handle_options): Handle the new options.
* emultempl/pep.em: Similar changes to above.
(NT_EXE_IMAGE_BASE): Default to an address above 4G.
(NT_DLL_IMAGE_BASE, NT_DLL_AUTO_IMAGE_BASE,
(NT_DLL_AUTO_IMAGE_MASK): Likewise.
* ld.texi: Document the new options.
* pe-dll.c (pe_dll_enable_reloc_section): Change to default to
true.
(generate_reloc): Do nothing if there is no reloc section.
(pe_exe_fill_sections): Only assign the reloc section contents if
the section exists.
* testsuite/ld-pe/pe.exp: Add the --disable-reloc-section flag to
the .secrel32 tests.
* testsuite/ld-scripts/provide-8.d: Expect for fail on PE targets.
* NEWS: Mention the change in DLL generation.

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

4 years agoUpdate gnulib to current trunk
Christian Biesinger [Wed, 26 Aug 2020 22:37:28 +0000 (15:37 -0700)]
Update gnulib to current trunk

This fixes two issues on Windows: Update.
https://sourceware.org/pipermail/gdb-patches/2020-June/169978.html

gnulib/ChangeLog:

2020-08-26  Christian Biesinger  <cbiesinger@google.com>
    Pedro Alves  <palves@redhat.com>
    Joel Brobecker  <brobecker@adacore.com>

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.in: Regenerate.
* configure: Regenerate.
* import/Makefile.am: Update.
* import/Makefile.in: Regenerate.
* import/alloca.in.h (if): Update.
* import/assure.h (affirm): Update.
* import/at-func.c: Update.
* import/attribute.h: New file.
* import/btowc.c: New file.
* import/canonicalize-lgpl.c: Update.
* import/count-one-bits.h (COUNT_ONE_BITS_GENERIC): Update.
(COUNT_ONE_BITS): Update.
(intrinsic): Update.
(__popcnt64): Update.
(popcount_supported): Update.
* import/ctype.in.h: New file.
* import/dirent-private.h (WIN32_FIND_DATA): Update.
* import/dirent.in.h (_GL_ATTRIBUTE_PURE): Update.
* import/dirname.h: Update.
* import/dosname.h: Remove.
* import/error.h (_GL_ATTRIBUTE_FORMAT): Update.
* import/extra/update-copyright: Update.
* import/fchdir.c: Update.
* import/fcntl.in.h (GNULIB_defined_rpl_fcntl): Update.
(GNULIB_defined_fcntl): Update.
* import/filename.h (HAS_DEVICE): Update.
(IS_ABSOLUTE_PATH): Update.
(IS_PATH_WITH_DIR): Update.
(FILE_SYSTEM_PREFIX_LEN): Update.
(_IS_DRIVE_LETTER): Update.
(FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE): Update.
(IS_ABSOLUTE_FILE_NAME): Update.
(IS_RELATIVE_FILE_NAME): Update.
(IS_FILE_NAME_WITH_DIR): Update.
* import/filenamecat-lgpl.c (mfile_name_concat): Update.
* import/fnmatch.c (WIDE_CHAR_SUPPORT): Update.
(btowc): Update.
(iswctype): Update.
(mempcpy): Update.
(strnlen): Update.
(towlower): Update.
(wcscat): Update.
(wcslen): Update.
(wctype): Update.
(wmemchr): Update.
(wmempcpy): Update.
(SIZE_MAX): Update.
(isblank): Update.
(__libc_use_alloca): Update.
(alloca): Update.
(alloca_account): Update.
(STREQ): Update.
(CHAR_CLASS_MAX_LENGTH): Update.
(IS_CHAR_CLASS): Update.
(ISWCTYPE): Update.
(if): Update.
(HANDLE_MULTIBYTE): Update.
(internal_function): Update.
(FOLD): Update.
(CHAR): Update.
(UCHAR): Update.
(INT): Update.
(FCT): Update.
(EXT): Update.
(END): Update.
(L_): Update.
(BTOWC): Update.
(STRLEN): Update.
(STRCAT): Update.
(MEMPCPY): Update.
(MEMCHR): Update.
(WIDE_CHAR_VERSION): Update.
(STRUCT): Update.
(FINDIDX): Update.
(findidx): Update.
(ALLOCA_LIMIT): Update.
(SHLIB_COMPAT): Update.
* import/fnmatch_loop.c (struct STRUCT): Update.
(FCT): Update.
(EXT): Update.
(END): Update.
(str): Update.
(NEW_PATTERN): Update.
* import/getcwd.c: Update.
* import/getlogin_r.c (GetUserName): Update.
* import/getprogname.c (getprogname): Update.
* import/getrandom.c: New file.
* import/gettimeofday.c: Remove.
* import/glob.in.h (_Restrict_): Update.
* import/inttypes.in.h (_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
* import/isblank.c: New file.
* import/isnanl-nolibm.h (__has_builtin): Update.
* import/libc-config.h (versioned_symbol): Update.
(compat_symbol): Update.
* import/limits.in.h (_GL_ALREADY_INCLUDING_LIMITS_H): Update.
* import/m4/btowc.m4: New file.
* import/m4/ctype.m4: New file.
* import/m4/exponentl.m4: Update.
* import/m4/fnmatch.m4: Update.
* import/m4/getrandom.m4: New file.
* import/m4/glob.m4: Update.
* import/m4/gnulib-cache.m4: Update.
* import/m4/gnulib-common.m4: Update.
* import/m4/gnulib-comp.m4: Update.
* import/m4/inttypes.m4: Update.
* import/m4/isblank.m4: New file.
* import/m4/isnanl.m4: Update.
* import/m4/largefile.m4: Update.
* import/m4/mbtowc.m4: New file.
* import/m4/memmem.m4: Update.
* import/m4/minmax.m4: New file.
* import/m4/signal_h.m4: Update.
* import/m4/stdio_h.m4: Update.
* import/m4/stdlib_h.m4: Update.
* import/m4/string_h.m4: Update.
* import/m4/strnlen.m4: New file.
* import/m4/sys_random_h.m4: New file.
* import/m4/sys_socket_h.m4: Update.
* import/m4/sys_stat_h.m4: Update.
* import/m4/time_h.m4: Update.
* import/m4/unistd_h.m4: Update.
* import/m4/wchar_h.m4: Update.
* import/m4/wint_t.m4: Update.
* import/m4/wmemchr.m4: New file.
* import/m4/wmempcpy.m4: New file.
* import/math.in.h (__has_builtin): Update.
* import/mbrtowc.c (FALLTHROUGH): Update.
* import/mbtowc-impl.h: New file.
* import/mbtowc.c: New file.
* import/minmax.h: New file.
* import/open.c (open): Update.
* import/openat-proc.c (openat_proc_name): Update.
* import/openat.c (rpl_openat): Update.
(openat_needs_fchdir): Update.
* import/openat.h (FCHOWNAT_INLINE): Update.
(CHOWNAT_INLINE): Update.
(FCHMODAT_INLINE): Update.
(CHMODAT_INLINE): Update.
* import/opendir.c (WIN32_FIND_DATA): Update.
(GetFullPathName): Update.
(FindFirstFile): Update.
* import/readdir.c (FindNextFile): Update.
* import/rename.c (MoveFileEx): Update.
* import/rewinddir.c (FindFirstFile): Update.
* import/rmdir.c: Update.
* import/signal.in.h (_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
* import/stat-w32.c (_WIN32_WINNT): Update.
(LoadLibrary): Update.
(GetFinalPathNameByHandle): Update.
(GetProcAddress): Update.
(DWORD): Update.
(GetFileInformationByHandleExFunc): Update.
(GetFinalPathNameByHandleFunc): Update.
* import/stat.c (WIN32_FIND_DATA): Update.
(CreateFile): Update.
(FindFirstFile): Update.
* import/stdio.in.h (_GL_ATTRIBUTE_FORMAT): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
(_GL_FUNCDECL_RPL_1): Update.
(_GL_CXXALIAS_RPL_1): Update.
(_GL_CXXALIAS_SYS_CAST): Update.
* import/stdlib.in.h (_GL_ATTRIBUTE_PURE): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
* import/string.in.h (_GL_ATTRIBUTE_PURE): Update.
(_GL_WARN_ON_USE): Update.
(_GL_WARN_ON_USE_CXX): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_CXXALIAS_SYS): Update.
(mbstok_r): Update.
* import/strnlen.c: New file.
* import/sys_random.in.h: New file.
* import/sys_socket.in.h (GNULIB_defined_socklen_t): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_CXXALIAS_SYS_CAST): Update.
* import/sys_stat.in.h (_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
(lchmod): Update.
(_GL_CXXALIAS_RPL_1): Update.
(stat): Update.
* import/tempname.c (__set_errno): Update.
(__secure_getenv): Update.
(__try_tempname): Update.
(__getpid): Update.
(__gettimeofday): Update.
(RANDOM_BITS): Update.
(uint64_t): Update.
(RANDOM_VALUE_MAX): Update.
(BASE_62_DIGITS): Update.
(BASE_62_POWER): Update.
(try_tempname_len): Update.
(try_file): Update.
(try_dir): Update.
(try_nocreate): Update.
(gen_tempname_len): Update.
(__gen_tempname): Update.
(try_tempname): Update.
* import/tempname.h (gen_tempname_len): Update.
(try_tempname_len): Update.
* import/time.in.h (_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_CXXALIAS_SYS): Update.
* import/unistd.in.h (if): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
(_GL_CXXALIASWARN): Update.
(_GL_WARN_ON_USE): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
* import/verify.h: Update.
* import/warn-on-use.h (_GL_WARN_ON_USE_CXX): Update.
* import/wchar.in.h (_GL_ATTRIBUTE_PURE): Update.
(_GL_FUNCDECL_RPL): Update.
(_GL_CXXALIAS_RPL): Update.
(_GL_FUNCDECL_SYS): Update.
(_GL_CXXALIAS_SYS): Update.
(_GL_CXXALIASWARN): Update.
(_GL_WARN_ON_USE): Update.
(_GL_CXXALIAS_SYS_CAST2): Update.
(_GL_CXXALIASWARN1): Update.
* import/windows-rwlock.c (CreateEvent): Update.
* import/wmemchr-impl.h: New file.
* import/wmemchr.c: New file.
* import/wmempcpy.c: New file.
* update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add gettimeofday.
(GNULIB_COMMIT_SHA1): Update gnulib revision.

4 years agold: Add $NOSANTIZE_CFLAGS to more linker tests
H.J. Lu [Wed, 26 Aug 2020 18:28:26 +0000 (11:28 -0700)]
ld: Add $NOSANTIZE_CFLAGS to more linker tests

-fsanitize= can be used to build binutils with

$ CC="gcc -fsanitize=address,undefined" CXX="g++ -fsanitize=address,undefined" .../configure --disable-werror

Since not all linker tests are compatible with -fsanitize=, pass
$NOSANTIZE_CFLAGS to disable -fsanitize= for such tests.

* testsuite/ld-elf/indirect.exp: Append $NOSANTIZE_CFLAGS to CC.
* testsuite/ld-elf/shared.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-plugin/lto.exp: Likewise.
* testsuite/ld-plugin/plugin.exp: Likewise.
* testsuite/ld-scripts/crossref.exp: Likewise.

4 years agoFix sanitization problems in the BFD library when running the linker testsuite for...
Nick Clifton [Wed, 26 Aug 2020 16:43:39 +0000 (17:43 +0100)]
Fix sanitization problems in the BFD library when running the linker testsuite for the AVR target.

PR 26433
* elf32-avr.c (avr_final_link_relocate):  Fix undefined shift
behaviour.
(avr_elf32_load_records_from_section): Use bfd_get_16 and
bfd_get_32 to load values from potentially unaligned pointers.

4 years agoFix sanitization problems running the linker testsuite for the alpha-elf target.
Nick Clifton [Wed, 26 Aug 2020 15:26:13 +0000 (16:26 +0100)]
Fix sanitization problems running the linker testsuite for the alpha-elf target.

PR 26416
* elf64-alpha.c (elf64_alpha_relax_tls_get_addr): Test for and
ignore local symbols.
(elf64_alpha_relax_got_load): Do not check for local dynamic
symbols.
(OP_LDA, OP_LDAH, OP_LDQ, OP_BR, OP_BSR): Use unsigned constant
values.
(INSN_A) Cast the A parameter to unsigned.
(INSN_AB): Define in terms of INSN_A.
(INSN_ABC): Likewise.
(INSN_ABO): Likewise.
(INSN_AD): Likewise.

4 years agoFix a sanitization problem running the linker testsuite for the AArch64 target.
Nick Clifton [Wed, 26 Aug 2020 14:50:36 +0000 (15:50 +0100)]
Fix a sanitization problem running the linker testsuite for the AArch64 target.

PR 26411
* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Use an
unsigned long constant when creating a mask to test for alignment
issues.

4 years agoopcodes: Add missing entries to ebpf_isa_attr
Jose E. Marchesi [Wed, 26 Aug 2020 14:48:39 +0000 (16:48 +0200)]
opcodes: Add missing entries to ebpf_isa_attr

opcodes/

* disassemble.c (enum epbf_isa_attr): Add ISA_XBPFBE, ISA_EBPFMAX.

4 years agoAdd support to readelf for the OpenBSD segment types.
Nick Clifton [Wed, 26 Aug 2020 14:13:41 +0000 (15:13 +0100)]
Add support to readelf for the OpenBSD segment types.

PR 26405
binutils* readelf.c (get_segment_type): Handle OpenBSD segment types.

include * elf/common.h (PT_OPENBSD_BOOTDATA): Define.
(PT_OPENBSD_RANDOMIZE): Define.
(PT_OPENBSD_WXNEEDED): Define.

4 years agoPR26508 UBSAN: tc-xtensa.c:7764 null pointer bsearch
Alan Modra [Wed, 26 Aug 2020 10:58:40 +0000 (20:28 +0930)]
PR26508 UBSAN: tc-xtensa.c:7764 null pointer bsearch

PR 26508
* config/tc-xtensa.c (xg_get_trampoline_chain): Return early
when n_entries is zero.

4 years agoPR26507 UBSAN: elf32-xtensa.c:6013 null pointer bsearch
Alan Modra [Wed, 26 Aug 2020 10:55:04 +0000 (20:25 +0930)]
PR26507 UBSAN: elf32-xtensa.c:6013 null pointer bsearch

PR 26507
* elf32-xtensa.c (find_removed_literal): Don't bsearch empty map.

4 years agoPR26506 UBSAN: elf32-xtensa.c:3203 null pointer memcpy
Alan Modra [Wed, 26 Aug 2020 10:50:11 +0000 (20:20 +0930)]
PR26506 UBSAN: elf32-xtensa.c:3203 null pointer memcpy

PR 26506
* elf32-xtensa.c (elf_xtensa_combine_prop_entries): Return early
when section is empty.

4 years agoPR26499 UBSAN: eelf32_spu.c:537 member access null pointer
Alan Modra [Wed, 26 Aug 2020 10:42:42 +0000 (20:12 +0930)]
PR26499 UBSAN: eelf32_spu.c:537 member access null pointer

Another &p->field.

PR 26499
* emultempl/spuelf.em (spu_elf_relink): Check for NULL tmp_file_list.

4 years agoPR26498 UBSAN: elf32-spu.c:2292 left shift overflow
Alan Modra [Wed, 26 Aug 2020 10:32:07 +0000 (20:02 +0930)]
PR26498 UBSAN: elf32-spu.c:2292 left shift overflow

PR 26498
* elf32-spu.c (find_function_stack_adjust): Use unsigned vars to
avoid UB left shift.

4 years agoPR 26484-26488, 26490 UBSAN &h->elf null pointer
Alan Modra [Wed, 26 Aug 2020 10:13:18 +0000 (19:43 +0930)]
PR 26484-26488, 26490 UBSAN &h->elf null pointer

PR 26484
PR 26485
PR 26486
PR 26487
PR 26488
PR 26490
* elf64-ppc.c (is_tls_get_addr): Avoid UB &h->elf when h is NULL.
(ppc64_elf_tls_setup): Likewise.
(branch_reloc_hash_match): Likewise.
(build_plt_stub): Likewise.
(ppc64_elf_relocate_section): Likewise.

4 years agoPR26478 UBSAN: mmo.c:2941 null pointer memcpy
Alan Modra [Wed, 26 Aug 2020 09:02:30 +0000 (18:32 +0930)]
PR26478 UBSAN: mmo.c:2941 null pointer memcpy

PR 26478
* mmo.c (mmo_write_symbols_and_terminator): Don't memcpy empty table.

4 years agoPR26475 UBSAN: elfxx-mips.c:12180 null pointer memset
Alan Modra [Wed, 26 Aug 2020 08:52:07 +0000 (18:22 +0930)]
PR26475 UBSAN: elfxx-mips.c:12180 null pointer memset

Another memset(0,0,0)

PR 26475
* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Check
sstubs->contents != NULL.

4 years agoPR26458 UBSAN: elf32-i386.c:3615 left shift of negative value
Alan Modra [Wed, 26 Aug 2020 01:30:22 +0000 (11:00 +0930)]
PR26458 UBSAN: elf32-i386.c:3615 left shift of negative value

Happens when poking symbol index -2 into r_info.  (The index is
updated before writing out to file.)

PR 26458
* elf/common.h (ELF32_R_INFO): Cast symbol index to unsigned.

4 years agoPR26453 UBSAN: som.c:2885 null pointer memcpy
Alan Modra [Wed, 26 Aug 2020 08:28:40 +0000 (17:58 +0930)]
PR26453 UBSAN: som.c:2885 null pointer memcpy

PR 26453
* som.c (som_prep_for_fixups): Return early when no symbols.

4 years agoPR26448 UBSAN: symbols.c:1586 left shift of negative value
Alan Modra [Wed, 26 Aug 2020 08:09:58 +0000 (17:39 +0930)]
PR26448 UBSAN: symbols.c:1586 left shift of negative value

Besides avoiding the UB, this also makes right shifts inside
expression symbols unsigned, consistent with the way gas evaluates
expressions in source.

PR 26448
* symbols.c: Include limits.h.
(resolve_symbol_value <O_left_shift, O_right_shift>): Do an
unsigned shift.  Warn if shift count larger than valueT size.

4 years agoPR26447 UBSAN: expr.c:1936 left shift of negative value
Alan Modra [Wed, 26 Aug 2020 05:25:39 +0000 (14:55 +0930)]
PR26447 UBSAN: expr.c:1936 left shift of negative value

PR 26447
* expr.c (expr <O_left_shift>): Do an unsigned shift.

4 years agoPR26431 UBSAN: pe-dll.c:568 null pointer bsearch
Alan Modra [Wed, 26 Aug 2020 04:53:42 +0000 (14:23 +0930)]
PR26431 UBSAN: pe-dll.c:568 null pointer bsearch

PR 26431
* pe-dll.c (auto_export): Don't call bsearch with zero count.

4 years agoPR26418 UBSAN: cache.c:386 null pointer fwrite
Alan Modra [Wed, 26 Aug 2020 04:48:53 +0000 (14:18 +0930)]
PR26418 UBSAN: cache.c:386 null pointer fwrite

PR 26418
* ecofflink.c (WRITE): Don't write size 0 chunks.

4 years agoasan: alpha-vms: mmember access within null pointer
Alan Modra [Wed, 26 Aug 2020 02:02:51 +0000 (11:32 +0930)]
asan: alpha-vms: mmember access within null pointer

* bfdio.c (bfd_get_file_size): Don't segv on NULL adata.

4 years agoPR26415 UBSAN: vms-misc.c:636 left shift cannot be represented
Alan Modra [Wed, 26 Aug 2020 01:56:35 +0000 (11:26 +0930)]
PR26415 UBSAN: vms-misc.c:636 left shift cannot be represented

An unsigned short value is promoted to int, thus triggering UB on a
left shift of a positive value that results in a negative int.

PR 26415
* vms-misc.c (vms_time_t_to_vms_time): Don't use unsigned short vars.

4 years agoPR26412 UBSAN: objcopy.c:3026 null pointer fwrite
Alan Modra [Wed, 26 Aug 2020 00:41:38 +0000 (10:11 +0930)]
PR26412 UBSAN: objcopy.c:3026 null pointer fwrite

PR 26412
* objcopy.c (copy_object): Don't fwrite NULL contents.

4 years agobpf: add xBPF ISA
David Faust [Wed, 26 Aug 2020 13:39:00 +0000 (15:39 +0200)]
bpf: add xBPF ISA

This patch adds support for xBPF, another ISA targetting the BPF
virtual architecture. For now, the primary difference between eBPF
and xBPF is that xBPF supports indirect calls through the
'call %reg' form of the call instruction.

bfd/
* archures.c (bfd_mach_xbpf): Define.
* bfd-in2.h: Regenerate.
* cpu-bpf.c (bfd_xbpf_arch) New.
(bfd_bpf_arch) Update next in list field to point to xbpf arch.

cpu/
* bpf.cpu (arch bpf): Add xbpf mach and isas.
(define-xbpf-isa) New pmacro.
(all-isas) Add xbpfle,xbpfbe.
(endian-isas): New pmacro.
(mach xbpf): New.
(model xbpf-def): Likewise.
(h-gpr): Add xbpf mach.
(f-dstle, f-srcle, dstle, srcle): Add xbpfle isa.
(f-dstbe, f-srcbe, dstbe, srcbe): Add xbpfbe isa.
(define-alu-insn-un): Use new endian-isas pmacro.
(define-alu-insn-bin, define-alu-insn-mov): Likewise.
(define-endian-insn, define-lddw): Likewise.
(dlind, dxli, dxsi, dsti): Likewise.
(define-cond-jump-insn, define-call-insn): Likewise.
(define-atomic-insns): Likewise.

gas/
* config/tc-bpf.c: Add option -mxbpf to select xbpf isa.
* testsuite/gas/bpf/indcall-1.d: New file.
* testsuite/gas/bpf/indcall-1.s: Likewise.
* testsuite/gas/bpf/indcall-bad-1.l: Likewise.
* testsuite/gas/bpf/indcall-bad-1.s: Likewise.
* testsuite/gas/bpf/bpf.exp: Run new tests.

opcodes/
* bpf-desc.c: Regenerate.
* bpf-desc.h: Likewise.
* bpf-opc.c: Likewise.
* bpf-opc.h: Likewise.
* disassemble.c (disassemble_init_for_target): Set bits for xBPF
ISA when appropriate.

4 years agowindres: AUTOCHECKBOX default style must have WS_TABSTOP style
Katayama Hirofumi [Wed, 26 Aug 2020 10:57:02 +0000 (11:57 +0100)]
windres: AUTOCHECKBOX default style must have WS_TABSTOP style

PR 26340
* rcparse.y (AUTOCHECKBOX): Add WS_TABSTOP to the base style.

4 years agogdb: Add ARC target and maintainer to MAINTAINERS
Shahab Vahedi [Wed, 5 Aug 2020 15:58:45 +0000 (17:58 +0200)]
gdb: Add ARC target and maintainer to MAINTAINERS

This patch updates gdb/MAINTAINERS with ARC as a target and
myself as the maintainer.  There is no mention of "-Werror"
because that is enabled by default for gdb/ targets now.

gdb/ChangeLog:

* MAINTAINERS: Add ARC target and maintainer.

4 years agoRe: CSKY: Add new arch CK860
Alan Modra [Wed, 26 Aug 2020 02:10:28 +0000 (11:40 +0930)]
Re: CSKY: Add new arch CK860

bfd-in2.h is a generated file.  Put the new machine where it belongs.

* archures.c (bfd_mach_ck860): Define.

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

4 years agoarc: Add GNU/Linux support for ARC
Anton Kolesov [Wed, 6 Jul 2016 17:36:49 +0000 (20:36 +0300)]
arc: Add GNU/Linux support for ARC

ARC Linux targets differences from baremetal:

- No support for hardware single instruction stepping.
- Different access rules to registers.
- Use of another instruction for breakpoints.

v2: Changes after Tom's remarks [1]
 arc-linux-tdep.c
  - Use true/false instead of TRUE/FALSE.
  - arc_linux_sw_breakpoint_from_kind (): Break long lines into two.
  - arc_linux_sw_breakpoint_from_kind (): Remove starting blank line.
  - Use explicit number evaluation, e.g: if (a & b) -> if ((a & b) != 0)
 arc-tdep.c
  - Use explicit number evaluation, e.g: if (a & b) -> if ((a & b) != 0)
 gdb/configure.tgt
  - arc*-*-linux*): Remove "build_gdbserver=yes".

v3: Changes after Simon's remarks [2]
  arc-linux-tdep.c
  - Use "return trap_size" instead of cryptic "return 2".
  - Removed unnecessary curly braces.
  - Removed "void" from "_initialize_arc_linux_tdep (void)".

v5: Changes after Simon's remarks [3]
- Remove unnecessary empty lines.
- Replace "breakpoint uses" with "breakpoints use" in a comment.
- "return condition;" i.s.o. "if (condition) return true; else return false;"

[1] Tom's remarks
https://sourceware.org/pipermail/gdb-patches/2020-April/167887.html

[2] Simon's remarks on v2
https://sourceware.org/pipermail/gdb-patches/2020-May/168513.html

[3] Simon's remarks on v4
https://sourceware.org/pipermail/gdb-patches/2020-August/170994.html

gdb/ChangeLog:

2020-08-25  Anton Kolesov  <anton.kolesov@synopsys.com>

* configure.tgt: ARC support for GNU/Linux.
* Makefile.in (ALL_TARGET_OBJS): Likewise.
* arc-linux-tdep.c: New file.
* arc-tdep.h (ARC_STATUS32_L_MASK, ARC_STATUS32_DE_MASK): Declare.
* arc-tdep.c (arc_write_pc): Use it.

4 years agoarc: Add hardware loop detection
Shahab Vahedi [Thu, 9 Jul 2020 15:44:01 +0000 (17:44 +0200)]
arc: Add hardware loop detection

For ARC there are registers that are not part of a required set in XML
target descriptions by default, but are almost always present on ARC
targets and are universally exposed by the ptrace interface.  Hardware
loop registers being one of them.

LP_START and LP_END auxiliary registers are hardware loop start and end.
Formally, they are optional, but it is hard to find an ARC configuration
that doesn't have them.  They are always present in processors that can
run GNU/Linux.  GDB needs to know about those registers to implement
proper software single stepping, since they affect  what instruction
will be next.

This commit adds the code to check for the existance of "lp_start" and
"lp_end" in XML target descriptions. If they exist, then the function
reports that the target supports hardware loops.

gdb/ChangeLog:

* arc-tdep.c (arc_check_for_hardware_loop): New.
* arc-tdep.h (gdbarch_tdep): New field has_hw_loops.

gdb/doc/ChangeLog:

* gdb.texinfo (Synopsys ARC): Document LP_START, LP_END and BTA.

4 years agoarc: Add inclusion of "gdbarch.h" in "arc-tdep.h"
Shahab Vahedi [Mon, 3 Aug 2020 18:41:42 +0000 (20:41 +0200)]
arc: Add inclusion of "gdbarch.h" in "arc-tdep.h"

The "arc-tdep.h" makes use of definitions in "gdbarch.h", but it
does not include it explicitly.  I have piggy backed this fix
in another commit [1], but I was asked to do it separately [2].

[1] arc: Add hardware loop detection
https://sourceware.org/pipermail/gdb-patches/2020-July/170800.html

[2] Simon's remarks to "arc: Add hardware loop detection"
https://sourceware.org/pipermail/gdb-patches/2020-August/170993.html

gdb/ChangeLog:

* arc-tdep.h: Include "gdbarch.h".

4 years agoarc: Add ARCv2 XML target along with refactoring
Shahab Vahedi [Thu, 9 Jul 2020 15:43:13 +0000 (17:43 +0200)]
arc: Add ARCv2 XML target along with refactoring

A few changes have been made to make the register support simpler,
more flexible and extendible.  The trigger for most of these changes
are the remarks [1] made earlier for v2 of this patch.  The noticeable
improvements are:

- The arc XML target features are placed under gdb/features/arc
- There are two cores (based on ISA) and one auxiliary feature:
  v1-core: ARC600, ARC601, ARC700
  v2-core: ARC EM, ARC HS
  aux: common in both
- The XML target features represent a minimalistic sane set of
  registers irrespective of application (baremetal or linux).
- A concept of "feature" class has been introduced in the code.
  The "feature" object is constructed from BFD and GDBARCH data.
  It contains necessary information (ISA and register size) to
  determine which XML target feature to use.
- A new structure (ARC_REGISTER_FEATURE) is added that allows
  providing index, names, and the necessity of registers. This
  simplifies the sanity checks and future extendibility.
- Documnetation has been updated to reflect ARC features better.
- Although the feature names has changed, there still exists
  backward compatibility with older names through
  find_obsolete_[core,aux]_names() functions.

The last two points were inspired from RiscV port.

[1]
https://sourceware.org/pipermail/gdb-patches/2020-May/168511.html

gdb/ChangeLog:

* arch/arc.h
  (arc_gdbarch_features): New class to stir the selection of target XML.
  (arc_create_target_description): Use FEATURES to choose XML target.
  (arc_lookup_target_description): Use arc_create_target_description
  to create _new_ target descriptions or return the already created
  ones if the FEATURES is the same.
* arch/arc.c: Implementation of prototypes described above.
* gdb/arc-tdep.h (arc_regnum enum): Add more registers.
  (arc_gdbarch_features_init): Initialize the FEATURES struct.
* arc-tdep.c (*_feature_name): Make feature names consistent.
  (arc_register_feature): A new struct to hold information about
  registers of a particular target/feature.
  (arc_check_tdesc_feature): Check if XML provides registers in
  compliance with ARC_REGISTER_FEATURE structs.
  (arc_update_acc_reg_names): Add aliases for r58 and r59.
  (determine_*_reg_feature_set): Which feature name to look for.
  (arc_gdbarch_features_init): Given MACH and ABFD, initialize FEATURES.
  (mach_type_to_arc_isa): Convert from a set of binutils machine types
  to expected ISA enums to be used in arc_gdbarch_features structs.
* features/Makefile (FEATURE_XMLFILES): Add new files.
* gdb/features/arc/v1-aux.c: New file.
* gdb/features/arc/v1-aux.xml: Likewise.
* gdb/features/arc/v1-core.c: Likewise.
* gdb/features/arc/v1-core.xml: Likewise.
* gdb/features/arc/v2-aux.c: Likewise.
* gdb/features/arc/v2-aux.xml: Likewise.
* gdb/features/arc/v2-core.c: Likewise.
* gdb/features/arc/v2-core.xml: Likewise.
* NEWS (Changes since GDB 9): Announce obsolence of old feature names.

gdb/doc/ChangeLog:

* gdb.texinfo (Synopsys ARC): Update the documentation for ARC
Features.

gdb/testsuite/ChangeLog:

* gdb.arch/arc-tdesc-cpu.xml: Use new feature names.

4 years agogdb/testsuite: fix gdb.threads/stepi-random-signal.exp pattern (gdb/26532)
Simon Marchi [Tue, 25 Aug 2020 15:06:43 +0000 (11:06 -0400)]
gdb/testsuite: fix gdb.threads/stepi-random-signal.exp pattern (gdb/26532)

Commit 1eb8556f5a8b ("gdb: add infrun_debug_printf macro") changed the
debug output format for `set debug infrun 1`.  The test
gdb.threads/stepi-random-signal.exp uses that debug output, and was
updated, but not correctly.  It results in this failure:

    FAIL: gdb.threads/stepi-random-signal.exp: stepi (no random signal)

Fix it by adjusting the pattern in the test.

gdb/testsuite/ChangeLog:

PR gdb/26532
* gdb.threads/stepi-random-signal.exp: Update pattern.

Change-Id: If5fa525e9545e32a286effe6a6184358374bd37c

4 years agogdb/testsuite: fix gdb.base/ui-redirect.exp pattern (gdb/26532)
Simon Marchi [Tue, 25 Aug 2020 15:06:27 +0000 (11:06 -0400)]
gdb/testsuite: fix gdb.base/ui-redirect.exp pattern (gdb/26532)

Commit 1eb8556f5a8b ("gdb: add infrun_debug_printf macro") changed the
debug output format for `set debug infrun 1`.  It broke test
gdb.base/ui-redirect.exp, which I missed:

    FAIL: gdb.base/ui-redirect.exp: debugging: continue

Fix it by adjusting the pattern in the test to the new reality.

gdb/testsuite/ChangeLog:

PR gdb/26532
* gdb.base/ui-redirect.exp: Update pattern.

Change-Id: Ie8a8f6675e35a0cab55109b1534b44eb51baec9d

4 years agoFix ChangeLog entry for commit b04aa1fc8c9d4a79e6293a3a1df7507052afedf3
Gary Benson [Tue, 25 Aug 2020 14:53:33 +0000 (15:53 +0100)]
Fix ChangeLog entry for commit b04aa1fc8c9d4a79e6293a3a1df7507052afedf3

4 years agoFix the linker's handling of DWARF-5 line number tables.
Mark Wielaard [Tue, 25 Aug 2020 14:33:00 +0000 (15:33 +0100)]
Fix the linker's handling of DWARF-5 line number tables.

When building with gcc with -gdwarf-5 ld tests (including ld-elf/dwarf.exp)
fail because they try to read the .debug_ranges section. But DWARF5
introduces a new .debug_rnglists section that encodes the address ranges
more efficiently. Implement reading the debug_rnglists in bfd/dwarf2.c.
Which makes all tests pass again and fixes several gcc testsuite tests
when defaulting to DWARF5.

*  dwarf2.c (struct dwarf2_debug_file): Add dwarf_rnglists_buffer
and dwarf_rnglists_size fields.
(dwarf_debug_sections): Add debug_rnglists.
(dwarf_debug_section_enum): Likewise.
(read_debug_rnglists): New function.
(read_rangelist): New function to call either read_ranges or
read_rnglists. Rename original function to...
(read_ranges): ...this.
(read_rnglists): New function.

4 years agoDisable Clang's integrated assembler for two testcases
Gary Benson [Tue, 25 Aug 2020 14:25:04 +0000 (15:25 +0100)]
Disable Clang's integrated assembler for two testcases

gdb.dwarf2/dw2-dir-file-name.exp fails to build using Clang because
the generated assembly language contains .ascii directives with more
than one string literal.  gdb.dwarf2/dw2-restore.exp fails to build
using Clang because it contains .func and .endfunc directives.
This commit causes Clang to invoke the system assembler to assemble
the relevant files.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-dir-file-name.exp: Use system assembler
when compiling with clang.
* gdb.dwarf2/dw2-restore.exp: Likewise

4 years agoEnable gdb.cp/ambiguous.exp with GCC and clang
Gary Benson [Tue, 25 Aug 2020 14:14:46 +0000 (15:14 +0100)]
Enable gdb.cp/ambiguous.exp with GCC and clang

gdb.cp/ambiguous.exp failed to build using clang with the following
error:

 gdb compile failed, /gdbtest/src/gdb/testsuite/gdb.cp/ambiguous.cc:70:36:
   warning: direct base 'A1' is inaccessible due to ambiguity:
     class JVA1 -> class KV -> class A1
     class JVA1 -> class A1 [-Winaccessible-base]
 class JVA1 : public KV, public LV, public A1 {
                                   ^~~~~~~~~

This commit builds this testcase with -Wno-inaccessible-base when
using clang, to avoid this failure.

Furthermore, gdb.cp/ambiguous.exp has been disabled when using GCC
since 1998.  This commit enables this testcase, building with
-Wno-inaccessible-base when using GCC >= 10.1, and -w otherwise.

gdb/testsuite/ChangeLog:

* gdb.cp/ambiguous.exp: Enable test when compiling with GCC.
Add additional_flags=-Wno-inaccessible-base when compiling
with GCC >= 10.1 or clang.  Add additional_flags=-w when
compiling with GCC < 10.

4 years agoPR26505, ASAN: xstormy16_elf_relax_section elf32-xstormy16.c:595
Alan Modra [Tue, 25 Aug 2020 08:26:08 +0000 (17:56 +0930)]
PR26505, ASAN: xstormy16_elf_relax_section elf32-xstormy16.c:595

PR 26505
* elf32-xstormy16.c (xstormy16_elf_relax_section): Check
is_elf_hash_table before accessing elf fields.

4 years agoPR26504, ASAN: parse_disassembler_options vax-dis.c:142
Alan Modra [Tue, 25 Aug 2020 08:16:59 +0000 (17:46 +0930)]
PR26504, ASAN: parse_disassembler_options vax-dis.c:142

PR 26504
* vax-dis.c (parse_disassembler_options): Always add at least one
to entry_addr_total_slots.

4 years agoPR26501, ASAN: tic54x_undefined_symbol tc-tic54x.c:5015
Alan Modra [Tue, 25 Aug 2020 07:46:28 +0000 (17:16 +0930)]
PR26501, ASAN: tic54x_undefined_symbol tc-tic54x.c:5015

PR26501
* gas/config/tc-tic54x.c (tic54x_undefined_symbol): Properly treat
misc_symbol_hash entries without values.

4 years agoPR26500, ASAN: tic4x_inst_make tc-tic4x.c:1247
Alan Modra [Tue, 25 Aug 2020 07:26:07 +0000 (16:56 +0930)]
PR26500, ASAN: tic4x_inst_make tc-tic4x.c:1247

PR 26500
* tc-tic4x.c (tic4x_inst_make): Don't die on terminating insn
with name = "".

4 years agoPR26482, ASAN: _bfd_xcoff_sizeof_headers coff-rs6000.c:2585
Alan Modra [Tue, 25 Aug 2020 06:45:27 +0000 (16:15 +0930)]
PR26482, ASAN: _bfd_xcoff_sizeof_headers coff-rs6000.c:2585

PR 26482
* coff-rs6000.c (_bfd_xcoff_sizeof_headers): Ignore sections that
won't be output.

4 years agoPR26463, ASAN: m32c_elf_relax_section elf32-m32c.c:1448
Alan Modra [Tue, 25 Aug 2020 08:53:38 +0000 (18:23 +0930)]
PR26463, ASAN: m32c_elf_relax_section elf32-m32c.c:1448

PR 26463
* elf32-m32c.c (m32c_elf_relax_section): Check is_elf_hash_table
before accessing elf fields.

4 years agoPR26452, ASAN: som_compute_checksum som.c:4293
Alan Modra [Tue, 25 Aug 2020 06:16:02 +0000 (15:46 +0930)]
PR26452, ASAN: som_compute_checksum som.c:4293

PR 26452
* som.c (som_compute_checksum): XOR 32-bit words in header,
not unsigned long sized words.

4 years agoPR26441, ASAN: get_b_cc tc-cr16.c:1521
Alan Modra [Tue, 25 Aug 2020 06:04:10 +0000 (15:34 +0930)]
PR26441, ASAN: get_b_cc tc-cr16.c:1521

PR 26441
* config/tc-cr16.c (get_b_cc): Return NULL early if op isn't
two or three chars, and don't bother copying.

4 years agoPR26430, ASAN: nacl_modify_segment_map elf-nacl.c:164
Alan Modra [Tue, 25 Aug 2020 05:17:50 +0000 (14:47 +0930)]
PR26430, ASAN: nacl_modify_segment_map elf-nacl.c:164

PR 26430
* elf-nacl.c (nacl_modify_segment_map): Correct alloc size and
amount copied for elf_segment_map defined with one element
sections array.

4 years agoPR26426, ASAN: neon_quad tc-arm.c:15175
Alan Modra [Tue, 25 Aug 2020 04:42:49 +0000 (14:12 +0930)]
PR26426, ASAN: neon_quad tc-arm.c:15175

PR 26426
* config/tc-arm.c (do_neon_mvn, do_neon_swp): Bail out on
NS_NULL shape.

4 years agoPR26422, ASAN: elf32_arm_final_link_relocate elf32-arm.c:10351
Alan Modra [Tue, 25 Aug 2020 04:35:10 +0000 (14:05 +0930)]
PR26422, ASAN: elf32_arm_final_link_relocate elf32-arm.c:10351

Always reading 32 bits in order to extract addends from instruction
fields is wrong when the field size is smaller.  It also leads to
reading past the end of the section.  This patch tidies that by
reading the proper field size, which allows some later refetching of
addends to disappear.

PR 26422
* elf32-arm.c (elf32_arm_final_link_relocate): Use the appropriate
bfd_get_x size function to read addends out of fields.  Apply
rightshift adjustment too.  Don't apply the now unnecessary
howto->size shift to branch REL addends.  Don't refetch R_ARM_ABS8
and R_ARM_ABS16 addends.  Don't refetch thumb branch addends.
Correct R_ARM_THM_JUMP6 addend.

4 years agoPR26419, ASAN: mn10300_elf_relax_section elf-m10300.c:3943
Alan Modra [Tue, 25 Aug 2020 00:07:23 +0000 (09:37 +0930)]
PR26419, ASAN: mn10300_elf_relax_section elf-m10300.c:3943

PR 26419
* elf-m10300.c (mn10300_elf_relax_section): Don't attempt access
before start of section.

4 years agoPR26410, UBSAN: symbols.c:1818
Alan Modra [Tue, 25 Aug 2020 05:21:21 +0000 (14:51 +0930)]
PR26410, UBSAN: symbols.c:1818

Don't memset(0,0,0).

PR 26410
* symbols.c (dollar_label_count, dollar_label_max): Make size_t.
(dollar_label_clear): Don't call memset with NULL pointer.

4 years agogas warning fixes
Alan Modra [Tue, 25 Aug 2020 00:27:58 +0000 (09:57 +0930)]
gas warning fixes

Some versions of gcc with -Werror=format-overflow complain about using
a perfectly good 7 char buffer for "r%dr%d" when the int is between 0
and 64, apparently not seeing the value range.

note: __builtin___sprintf_chk output between 5 and 24 bytes into a destination of size 7

* config/tc-arc.c (declare_register_set): Avoid false positive
format-overflow warning.
* config/tc-epiphany.c (md_assemble): Likewise.
* config/tc-mips.c (md_begin): Likewise.
* config/tc-mmix.c (mmix_md_begin): Likewise.
* config/tc-nds32.c (nds32_elf_append_relax_relocs): Avoid false
positive "may be used uninitialized" warning.

4 years agotic54x ld testsuite
Alan Modra [Mon, 24 Aug 2020 16:29:55 +0000 (01:59 +0930)]
tic54x ld testsuite

* testsuite/ld-libs/libs.exp: Don't run on sh-pe, tic30 or tic54x.
* testsuite/ld-scripts/data.d: xfail tic4x and tic54x.
* testsuite/ld-scripts/empty-address-2a.d: xfail tic54x.
* testsuite/ld-scripts/empty-address-2b.d: Likewise.
* testsuite/ld-scripts/include-1.d: xfail tic4x and tic54x.
* testsuite/ld-scripts/provide-1.d: xfail tic54x.
* testsuite/ld-scripts/provide-2.d: Likewise.
* testsuite/ld-scripts/provide-4.d: Likewise.

4 years agogdb/modula-2: parsing of multi-subscript arrays
Gaius Mulley [Tue, 25 Aug 2020 08:39:27 +0000 (09:39 +0100)]
gdb/modula-2: parsing of multi-subscript arrays

Fix bug PR m2/26372, GDB's inability to parse multi-dimensional
modula-2 arrays.

We previously had two rules for handling the parsing of array
sub-scripts.  I have reproduced them here with the actual handler
blocks removed to make the bug clearer:

  exp     :    exp '[' non_empty_arglist ']'
          ;

  exp     :    exp '[' exp ']'
          ;

  non_empty_arglist
          :       exp
          ;

  non_empty_arglist
          :       non_empty_arglist ',' exp
          ;

This is ambiguous as the pattern "exp '[' exp" could match either of
the 'exp' rules.  Currently it just so happens that the parser picks
the second 'exp' rule which means we can only handle a single array
index.

As the handler code for the first 'exp' pattern will correctly handle
and number of array indexes then lets just remove the second pattern.

gdb/ChangeLog:

PR m2/26372
        * m2-exp.y (exp): Improve comment for non_empty_arglist case, add
an assert.  Remove single element array indexing pattern as the
MULTI_SUBSCRIPT support will handle this case too.

gdb/testsuite/ChangeLog:

PR m2/26372
        * gdb.modula2/multidim.c: New file.
        * gdb.modula2/multidim.exp: New file.

4 years agoRevert "Fix for Bug 26372 [Modula-2] Parsing of multi-subscript arrays"
Andrew Burgess [Tue, 25 Aug 2020 09:25:32 +0000 (10:25 +0100)]
Revert "Fix for Bug 26372 [Modula-2] Parsing of multi-subscript arrays"

This reverts commit 07758bdfa9e5a762f2ec0deeb51b11d6ad5fe376.

4 years agoFix for Bug 26372 [Modula-2] Parsing of multi-subscript arrays
Gaius Mulley [Tue, 25 Aug 2020 09:16:56 +0000 (11:16 +0200)]
Fix for Bug 26372 [Modula-2] Parsing of multi-subscript arrays

Here is a bugfix for Pr 26372 [Modula-2] Parsing of multi-subscript arrays.
Also included is a dejagnu testcase.  No extra regressions are caused on
Debian GNU/Linux Buster amd64.

gdb/ChangeLog:

2020-08-25  Gaius Mulley  <gaiusmod2@gmail.com>

PR m2/26372
* m2-exp.y: Rewrite array subscript rules to support multidimension
array access.  (ArgumentList) replaces non_empty_arglist.

gdb/testsuite/ChangeLog:

2020-08-25  Gaius Mulley  <gaiusmod2@gmail.com>

PR m2/26372
* testsuite/gdb.modula2/multidim.exp: New file.
* testsuite/gdb.modula2/multidim.c: New file.

4 years agogdb: move declaration of valprint_check_validity to valprint.h
Simon Marchi [Tue, 25 Aug 2020 02:51:50 +0000 (22:51 -0400)]
gdb: move declaration of valprint_check_validity to valprint.h

The implementation is in valprint.c, so the declaration belongs in
valprint.h.

gdb/ChangeLog:

* value.h (valprint_check_validity): Move declaration from
here...
* valprint.h (valprint_check_validity): ... to here.

Change-Id: Ibe577d3696720099e6d79888d4ee8e3c1bf05a26

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

4 years agogdb/testsuite: make runto always emit a FAIL on internal error
Simon Marchi [Mon, 24 Aug 2020 23:44:53 +0000 (19:44 -0400)]
gdb/testsuite: make runto always emit a FAIL on internal error

I noticed that when a test uses `runto_main` and a GDB internal error
happens while running to main, no error or fail is emitted.  This is
because `runto_main` uses the `no-message` option of `runto`.

As a result, if a test fails to run to main and exits, no sign that
something went wrong is emitted.  For example, add this always-false
assertion to compute_frame_id:

    --- a/gdb/frame.c
    +++ b/gdb/frame.c
    @@ -545,6 +545,7 @@ static void
     compute_frame_id (struct frame_info *fi)
     {
       gdb_assert (!fi->this_id.p);
    +  gdb_assert (false);

       if (frame_debug)
         fprintf_unfiltered (gdb_stdlog, "{ compute_frame_id (fi=%d) ",

... and run gdb.dwarf2/dw2-align.exp.  No fail or sign that something
went wrong is shown.  It just appears as if the test gets skipped.

A developer introducing such a regression in this test today would
likely notice it, because we are used to diff-ing test results.  So we
would see some PASSes dispappear for no good reason and look into it.

But I find it worrysome for two reasons:

1. Scripts that analyze regressions (such as the one on the buildbot)
   may only look for new FAILs or new ERRORs.  It would probably miss
   this.
2. Imagine that we one day have a testsuite that runs cleanly (some
   people might already run subsets of the testsuite and expect it to
   all pass), we would just run the testsuite and check that there are
   no fails.  It would be easy to miss something like this.

In case of internal error, I suggest making `runto` emit a FAIL even if
`no-message` was passed.  This is different from other failure modes
that might be expected (whchi rightfully cause the test to simply be
skipped).  An internal error is always bad, so if it happens it should
noisily fail.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (runto): Always emit fail on internal error.

Change-Id: I6e6faed4868ea821541a23042b2d01c30058b0d3

4 years agogdb: add debug_prefixed_vprintf
Simon Marchi [Mon, 24 Aug 2020 19:50:19 +0000 (15:50 -0400)]
gdb: add debug_prefixed_vprintf

To help ensure that all debug statements have the same format, introduce
the debug_prefixed_vprintf helper.  Implement linux_nat_debug_printf_1
and infrun_debug_printf_1 with it.

I would eventually like to style the module and function name with some
color, to help them stick out, but I don't really know how to do that
yet, it can always be done later.

gdb/ChangeLog:

* debug.h: New file.
* debug.c (debug_prefixed_vprintf): New function.
* infrun.c (infrun_debug_printf_1): Use debug_prefixed_vprintf.
* linux-nat.c (linux_nat_debug_printf_1): Likewise.

Change-Id: Iccc290a2dc6b5fffcbe1c2866ed8d804ad380764

4 years agogdb: add infrun_debug_printf macro
Simon Marchi [Mon, 24 Aug 2020 19:49:46 +0000 (15:49 -0400)]
gdb: add infrun_debug_printf macro

Introduce this macro to print debug statements in the infrun.c file,
same idea as what was done in 9327494e0eeb ("gdb: add
linux_nat_debug_printf macro").

Although in this case, there are places outside infrun.c that print
debug statements if debug_infrun is set.  So the macro has to be
declared in the header file, so that it can be used in these other
files.

Note one special case.  In stop_all_threads, I've used an explicit

    if (debug_infrun)
      infrun_debug_printf_1 ("stop_all_threads", "done");

for the message in the SCOPE_EXIT.  Otherwise, the message appears like
this:

  [infrun] operator(): done

Until we find a better solution for extracting a meaningful function
name for lambda functions, I think it's fine to handle these special
cases manually, they are quite rare.

Some tests need to be updated, because they rely on some infrun debug
statements.

gdb/ChangeLog:

* infrun.h (infrun_debug_printf_1): New function declaration.
(infrun_debug_printf): New macro.
* infrun.c (infrun_debug_printf_1): Use infrun_debug_printf
throughout.
(infrun_debug_printf): New function.
* breakpoint.c (should_be_inserted): Use infrun_debug_printf.
(handle_jit_event): Likewise.

gdb/testsuite/ChangeLog:

* gdb.base/gdb-sigterm.exp (do_test): Update expected regexp.
* gdb.threads/signal-while-stepping-over-bp-other-thread.exp:
Likewise.
* gdb.threads/stepi-random-signal.exp: Likewise.

Change-Id: I66433c8a9caa64c8525ab57c593022b9d1956d5c

4 years agoelf_hash_table_id access
Alan Modra [Mon, 24 Aug 2020 17:07:02 +0000 (02:37 +0930)]
elf_hash_table_id access

* elf-m10300.c (elf32_mn10300_hash_table): Test is_elf_hash_table
before accessing elf_hash_table_id.
* elf32-arc.c (elf_arc_hash_table): Likewise.
* elf32-arm.c (elf32_arm_hash_table): Likewise.
* elf32-avr.c (avr_link_hash_table): Likewise.
* elf32-bfin.c (bfinfdpic_hash_table): Likewise.
* elf32-cris.c (elf_cris_hash_table): Likewise.
* elf32-csky.c (csky_elf_hash_table): Likewise.
* elf32-frv.c (frvfdpic_hash_table): Likewise.
* elf32-hppa.c (hppa_link_hash_table): Likewise.
* elf32-lm32.c (lm32_elf_hash_table): Likewise.
* elf32-m32r.c (m32r_elf_hash_table): Likewise.
* elf32-m68hc1x.h (m68hc11_elf_hash_table): Likewise.
* elf32-m68k.c (elf_m68k_hash_table): Likewise.
* elf32-metag.c (metag_link_hash_table): Likewise.
* elf32-microblaze.c (elf32_mb_hash_table): Likewise.
* elf32-nds32.h (nds32_elf_hash_table): Likewise.
* elf32-or1k.c (or1k_elf_hash_table): Likewise.
* elf32-s390.c (elf_s390_hash_table): Likewise.
* elf32-sh.c (sh_elf_hash_table): Likewise.
* elf32-spu.c (spu_hash_table): Likewise.
* elf32-tilepro.c (tilepro_elf_hash_table): Likewise.
* elf32-xtensa.c (elf_xtensa_hash_table): Likewise.
* elf64-alpha.c (alpha_elf_hash_table): Likewise.
* elf64-hppa.c (hppa_link_hash_table): Likewise.
* elf64-ia64-vms.c (elf64_ia64_hash_table): Likewise.
* elf64-s390.c (elf_s390_hash_table): Likewise.
* elfnn-ia64.c (elfNN_ia64_hash_table): Likewise.
* elfnn-riscv.c (riscv_elf_hash_table): Likewise.
* elfxx-mips.c (mips_elf_hash_table): Likewise.
* elfxx-sparc.h (_bfd_sparc_elf_hash_table): Likewise.
* elfxx-tilegx.c (tilegx_elf_hash_table): Likewise.

4 years agoFix erroroneous use of '%zu' in elfcore_grok_win32pstatus
Jon Turney [Fri, 21 Aug 2020 15:30:00 +0000 (16:30 +0100)]
Fix erroroneous use of '%zu' in elfcore_grok_win32pstatus

As reported in [1], _bfd_error_handler() doesn't support '%zu'.

module_name_size is always 32-bits in the data structure we are
extracting it from, so use an unsigned int to store it instead.

[1] https://sourceware.org/pipermail/gdb-patches/2020-August/171391.html

bfd/ChangeLog:

2020-08-21  Jon Turney  <jon.turney@dronecode.org.uk>

* elf.c (elfcore_grok_win32pstatus): Change name_size to unsigned
int. Use '%u' format with  _bfd_error_handler to render it.

4 years agoPR26489, ASAN: ppc64_elf_size_stubs elf64-ppc.c:13389
Alan Modra [Mon, 24 Aug 2020 16:25:38 +0000 (01:55 +0930)]
PR26489, ASAN: ppc64_elf_size_stubs elf64-ppc.c:13389

Stub sections are inserted after sec_info is sized, so have higher ids.
Test flags that will exclude stub sections before looking at the
sec_info array.

PR 26489
* elf64-ppc.c (ppc64_elf_size_stubs): Test code_sec->has_toc_reloc
and code_sec->makes_toc_func_call before sec_info[code_sec->id].

4 years agoPR26492, ASAN: ppc64_elf_before_check_relocs elf64-ppc.c:4337
Alan Modra [Mon, 24 Aug 2020 16:21:39 +0000 (01:51 +0930)]
PR26492, ASAN: ppc64_elf_before_check_relocs elf64-ppc.c:4337

PR 26492
* elf64-ppc.c (ppc_hash_table): Test is_elf_hash_table before
accessing elf_hash_table_id.

4 years agoPR26483, ASAN: ppc_elf_link_params elf32-ppc.c:2314
Alan Modra [Mon, 24 Aug 2020 16:18:08 +0000 (01:48 +0930)]
PR26483, ASAN: ppc_elf_link_params elf32-ppc.c:2314

PR 26483
* elf32-ppc.c (ppc_elf_hash_table): Test is_elf_hash_table before
accessing elf_hash_table_id.

4 years agobfd: Handle DW_FORM_data16 for .debug_line tables containing MD5
Mark Wielaard [Mon, 24 Aug 2020 14:52:53 +0000 (15:52 +0100)]
bfd: Handle DW_FORM_data16 for .debug_line tables containing MD5

* dwarf2.c (read_attribute_value): Handle DW_FORM_data16.
(read_formatted_entries): Likewise. And skip zero entry.

4 years agoCSKY: Add new arch CK860.
Cooper Qu [Mon, 24 Aug 2020 12:13:47 +0000 (20:13 +0800)]
CSKY: Add new arch CK860.

bfd/
        * bfd-in2.h (bfd_mach_ck860): New.
        * cpu-csky.c (arch_info_struct): Add item for CK860.

gas/
        * config/tc-csky.c (csky_archs): Add item for CK860,
        change ck810 and ck807's arch_flag.
        (csky_cpus): Add item for CK860.
        (md_begin): Enable DSP for CK810 and CK807 by default.
        (md_apply_fix): Fix CKCORE_TLS_IE32 relocation failure.
        * gas/testsuite/gas/csky/cskyv2_all.d: Change 'sync 0'
        to 'sync'.
        * gas/testsuite/gas/csky/cskyv2_all.s: Likewise.
        * gas/testsuite/gas/csky/cskyv2_ck860.d: New.
        * gas/testsuite/gas/csky/cskyv2_ck860.s: New.
        * gas/testsuite/gas/csky/enhance_dsp.d: Change plsli.u16
        to plsli.16.
        * gas/testsuite/gas/csky/enhance_dsp.s: Likewise.

include/
        * opcode/csky.h (CSKYV2_ISA_10E60): New.
        (CSKY_ARCH_860): New.

opcode/
        * csky-dis.c (csky_find_inst_info): Skip CK860's instructions
        in other CPUs to speed up disassembling.
        * csky-opc.h (csky_v2_opcodes): Add CK860's instructions,
        Change plsli.u16 to plsli.16, change sync's operand format.

Change-Id: I80ec1a9c0cc600d668082a9b91ae6d45b33ec0fc

4 years agosparc testsuite fallout
Alan Modra [Mon, 24 Aug 2020 08:00:30 +0000 (17:30 +0930)]
sparc testsuite fallout

4 years agotic54x fixes
Alan Modra [Sun, 23 Aug 2020 11:35:34 +0000 (21:05 +0930)]
tic54x fixes

A number of the tic54x tests were failing, and I thought it worth
investigating since the target makes use of a lot of hash tables, and
we've just changed gas hash tables.  It turns out none of the gas
failures were due to hashing.

* config/tc-tic54x.c (stag_add_field_symbols): Don't free "name"
in case where it isn't copied.
* config/tc-tic54x.h (LOCAL_LABELS_FB): Undef.
* testsuite/gas/tic54x/field.d: Dump section contents and symbols
rather than disassembling.
* testsuite/gas/tic54x/set.d: Adjust for newer disassembly.

4 years agoPowerPC TPREL_HA/LO optimisation
Alan Modra [Mon, 24 Aug 2020 07:02:57 +0000 (16:32 +0930)]
PowerPC TPREL_HA/LO optimisation

ppc64 ld optimises sequences like the following
addis 3,13,wot@tprel@ha
lwz 3,wot@tprel@l(3)
to
nop
lwz 3,wot@tprel(13)
when "wot" is located near enough to the thread pointer.
However, the ABI doesn't require that R_PPC64_TPREL16_HA always be on
an addis rt,13,imm instruction, and while ld checked for that on the
high-part instruction it didn't disable the optimisation on the
low-part instruction.  This patch fixes that problem, disabling the
tprel optimisation globally if high-part instructions don't pass
sanity checks.  The optimisation is also enabled for ppc32, where
before ld.bfd had the code in the wrong place and ld.gold had it in a
block only enabled for ppc64.

bfd/
* elf32-ppc.c (ppc_elf_check_relocs): Set has_tls_reloc for
high part tprel16 relocs.
(ppc_elf_tls_optimize): Sanity check high part tprel16 relocs.
Clear do_tls_opt on odd instructions.
(ppc_elf_relocate_section): Move TPREL16_HA/LO optimisation later.
Don't sanity check them here.
* elf64-ppc.c (ppc64_elf_check_relocs): Set has_tls_reloc for
high part tprel16 relocs.
(ppc64_elf_tls_optimize): Sanity check high part tprel16 relocs.
Clear do_tls_opt on odd instructions.
(ppc64_elf_relocate_section): Don't sanity check TPREL16_HA.
ld/
* testsuite/ld-powerpc/tls32.d: Update for TPREL_HA/LO optimisation.
* testsuite/ld-powerpc/tlsexe32.d: Likewise.
* testsuite/ld-powerpc/tlsldopt32.d: Likewise.
* testsuite/ld-powerpc/tlsmark32.d: Likewise.
* testsuite/ld-powerpc/tlsopt4_32.d: Likewise.
* testsuite/ld-powerpc/tprel.s,
* testsuite/ld-powerpc/tprel.d,
* testsuite/ld-powerpc/tprel32.d: New tests.
* testsuite/ld-powerpc/tprelbad.s,
* testsuite/ld-powerpc/tprelbad.d: New test.
* testsuite/ld-powerpc/powerpc.exp: Run them.
gold/
* powerpc.cc (Target_powerpc): Add tprel_opt_ and accessors.
(Target_powerpc::Scan::local): Sanity check tprel high relocs.
(Target_powerpc::Scan::global): Likewise.
(Target_powerpc::Relocate::relocate): Control tprel optimisation
with tprel_opt_ and enable for 32-bit.

4 years agoRemove "memory exhausted" messages
Alan Modra [Mon, 24 Aug 2020 03:51:31 +0000 (13:21 +0930)]
Remove "memory exhausted" messages

Since we use xcalloc to set up hash table memory, htab_create won't
ever return a failure.

* config/tc-aarch64.c (md_begin): Don't bother checking for
out of memory failure from str_htab_create.
* config/tc-arc.c (arc_insert_opcode, md_begin): Likewise.
(arc_extcorereg, arc_stralloc): Likewise.
* config/tc-arm.c (md_begin): Likewise.
* config/tc-cr16.c (initialise_reg_hash_table, md_begin): Likewise.
* config/tc-cris.c (md_begin): Likewise.
* config/tc-crx.c (md_begin): Likewise.
* config/tc-pdp11.c (md_begin): Likewise.
* config/tc-score.c (s3_build_reg_hsh, s3_begin): Likewise.
* config/tc-score7.c (s7_build_reg_hsh, s7_begin): Likewise.

4 years agogcc-4 -Og false positive "may be used uninitialised"
Alan Modra [Mon, 24 Aug 2020 03:28:14 +0000 (12:58 +0930)]
gcc-4 -Og false positive "may be used uninitialised"

binutils/
* readelf.c (dump_section_as_strings) Avoid false positive
"may be used uninitialised".
gas/
* config/tc-arm.c (move_or_literal_pool): Avoid false positive
"may be used uninitialised".
(opcode_lookup): Likewise.

4 years agoPR26526, 5014c2d22b2 breaks compiling the Linux kernel for ARM
Alan Modra [Mon, 24 Aug 2020 03:36:46 +0000 (13:06 +0930)]
PR26526, 5014c2d22b2 breaks compiling the Linux kernel for ARM

PR 26526
* symbols.c (local_symbol_convert): Clear out xtra.

4 years agoCSKY: Add ck803r2 series cpu.
Cooper Qu [Fri, 21 Aug 2020 10:08:10 +0000 (18:08 +0800)]
CSKY: Add ck803r2 series cpu.

gas/
        * config/tc-csky.c (CSKY_ISA_803R2): New.
        (csky_archs): Add ck803r2 series.
        (md_begin): Fix warning about -medsp.
        (csky_get_freg_val): Support lowercase of fpu register name.
        * testsuite/gas/csky/cskyv2_ck803r2.s: New file.
        * testsuite/gas/csky/cskyv2_ck803r2.d: New file.

include/
        * csky.h (CSKYV2_ISA_3E3R2): New.

opcodes/
        * csky-opc.h (csky_v2_opcodes): Add instruction bnezad.

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

4 years agoDisable default ELF plugins on 32-bit hppa*-*-hpux*.
John David Anglin [Sun, 23 Aug 2020 16:44:22 +0000 (16:44 +0000)]
Disable default ELF plugins on 32-bit hppa*-*-hpux*.

PR binutils/26357
* configure.ac: Disable plugins by default on 32-bit hppa*-*-hpux*.
* configure: Regenerate.

4 years agoPR26513, 629310abec breaks assembling PowerPC Linux kernels
Alan Modra [Sat, 22 Aug 2020 08:29:57 +0000 (17:59 +0930)]
PR26513, 629310abec breaks assembling PowerPC Linux kernels

Inserting with replacement is wrong for some gas hash table uses.
This patch implements an htab_insert that conditionally replaces, and
similarly for str_hash_insert.  str_hash_insert with replace=0 is
roughly equivalent to the older hash_insert, and str_hash_insert with
replace=1 to the older hash_jam, but return values are different.  I
found it useful to know whether the slot was occupied prior to
inserting/replacing.  I've also reinstated the fatal errors on messing
up opcode tables with duplicates.

PR 26513
* hash.h (htab_insert): Update prototype and comment.
(struct string_tuple): Make "value" a const void*.
(string_tuple_alloc): Likewise.
(str_hash_find, str_hash_find_n): Cast returned value.
(str_hash_insert): Add "replace" parameter, and return slot pointer.
Free alloc'd element when not inserted.
* hash.c (htab_insert): Likewise.  Return slot when element exists,
otherwise return NULL.
* read.c (pop_insert): Insert into hash table without first searching.
* config/tc-avr.c (md_begin): Likewise.
* config/tc-msp430.c (md_begin): Likewise.
* config/tc-nds32.c (nds32_init_nds32_pseudo_opcodes): Likewise.
* config/tc-v850.c (md_begin): Likewise.
* macro.c (do_formals, define_macro, macro_expand_body): Likewise.
(delete_macro): Delete from hash table.
* config/tc-tic54x.c (subsym_create_or_replace): Correct logic.

* symbols.c (local_symbol_make, symbol_table_insert): Allow
replacement of hash table entries.
* config/obj-coff-seh.c (seh_hash_insert): Likewise.
* config/obj-coff.c (tag_insert): Likewise.
* config/tc-iq2000.c (iq2000_add_macro): Likewise.
* config/tc-m68k.c (md_begin): Likewise for aliases.
* config/tc-tic4x.c (tic4x_asg): Likewise.
* config/tc-tic6x.c (md_begin): Likewise.

* dw2gencfi.c (dwcfi_hash_find_or_make): Disallow replacement of
hash table entries.
* ecoff.c (add_string, get_tag): Likewise.
* macro.c (expand_irp): Likewise.
* config/obj-elf.c (build_additional_section_info): Likewise.
* config/tc-aarch64.c (insert_reg_alias): Likewise.
(checked_hash_insert): Likewise.
* config/tc-alpha.c (get_alpha_reloc_tag, md_begin): Likewise.
* config/tc-arc.c (arc_insert_opcode, declare_register): Likewise.
(declare_addrtype, md_begin, arc_extcorereg): Likewise.
* config/tc-arm.c (insert_reg_alias): Likewise.
(arm_tc_equal_in_insn, md_begin): Likewise.
* config/tc-cr16.c (initialise_reg_hash_table, md_begin): Likewise.
* config/tc-cris.c (md_begin): Likewise.
* config/tc-crx.c (md_begin): Likewise.
* config/tc-csky.c (md_begin): Likewise.
* config/tc-d10v.c (md_begin): Likewise.
* config/tc-dlx.c (md_begin): Likewise.
* config/tc-ft32.c (md_begin): Likewise.
* config/tc-h8300.c (md_begin): Likewise.
* config/tc-hppa.c (md_begin): Likewise.
* config/tc-i386.c (md_begin): Likewise.
* config/tc-ia64.c (dot_rot, dot_entry, declare_register): Likewise.
(md_begin, dot_alias): Likewise.
* config/tc-m68hc11.c (md_begin): Likewise.
* config/tc-m68k.c (md_begin): Likewise.
* config/tc-mcore.c (md_begin): Likewise.
* config/tc-microblaze.c (md_begin): Likewise.
* config/tc-mips.c (md_begin): Likewise.
* config/tc-mmix.c (md_begin): Likewise.
* config/tc-mn10200.c (md_begin): Likewise.
* config/tc-mn10300.c (md_begin): Likewise.
* config/tc-moxie.c (md_begin): Likewise.
* config/tc-nds32.c (nds32_relax_hint, md_begin): Likewise.
* config/tc-nios2.c (md_begin): Likewise.
* config/tc-ns32k.c (md_begin): Likewise.
* config/tc-pdp11.c (md_begin): Likewise.
* config/tc-pj.c (fake_opcode, md_begin): Likewise.
* config/tc-ppc.c (ppc_setup_opcodes): Likewise.
* config/tc-pru.c (md_begin): Likewise.
* config/tc-riscv.c (init_ext_version_hash): Likewise.
(init_opcode_names_hash, hash_reg_name, init_opcode_hash): Likewise.
(riscv_init_csr_hash): Likewise.
* config/tc-s390.c (s390_setup_opcodes, md_begin): Likewise.
* config/tc-score.c (s3_insert_reg): Likewise.
(s3_build_score_ops_hsh, s3_build_dependency_insn_hsh): Likewise.
* config/tc-score7.c (s7_build_score_ops_hsh): Likewise.
(s7_build_dependency_insn_hsh, s7_insert_reg): Likewise.
* config/tc-sh.c (md_begin): Likewise.
* config/tc-sparc.c (md_begin): Likewise.
* config/tc-spu.c (md_begin): Likewise.
* config/tc-tic30.c (md_begin): Likewise.
* config/tc-tic4x.c (tic4x_inst_insert): Likewise.
* config/tc-tic54x.c (stag_add_field_symbols, md_begin): Likewise.
(tic54x_endstruct, tic54x_var, tic54x_macro_info): Likewise.
(subsym_substitute): Likewise.
* config/tc-tilegx.c (md_begin): Likewise.
* config/tc-tilepro.c (md_begin): Likewise.
* config/tc-vax.c (vip_begin): Likewise.
* config/tc-wasm32.c (md_begin): Likewise.
* config/tc-xgate.c (md_begin): Likewise.
* config/tc-z8k.c (md_begin): Likewise.
* testsuite/gas/ppc/dcbt.d,
* testsuite/gas/ppc/dcbt.s: New test.
* testsuite/gas/ppc/ppc.exp: Run it.

* ecoff.c (add_string): Report fatal error on duplicates.
* config/tc-alpha.c (md_begin): Likewise.
* config/tc-arc.c (arc_insert_opcode, declare_register): Likewise.
(declare_addrtype, md_begin, arc_extcorereg): Likewise.
* config/tc-cr16.c (initialise_reg_hash_table, md_begin): Likewise.
* config/tc-cris.c (md_begin): Likewise.
* config/tc-crx.c (md_begin): Likewise.
* config/tc-dlx.c (md_begin): Likewise.
* config/tc-hppa.c (md_begin): Likewise.
* config/tc-i386.c (md_begin): Likewise.
* config/tc-ia64.c (dot_rot, dot_entry, declare_register): Likewise.
(md_begin): Likewise.
* config/tc-m68k.c (md_begin): Likewise.
* config/tc-mips.c (md_begin): Likewise.
* config/tc-nios2.c (md_begin): Likewise.
* config/tc-ns32k.c (md_begin): Likewise.
* config/tc-ppc.c (ppc_setup_opcodes): Likewise.
* config/tc-pru.c (md_begin): Likewise.
* config/tc-riscv.c (init_ext_version_hash): Likewise.
(init_opcode_names_hash, hash_reg_name, init_opcode_hash): Likewise.
* config/tc-s390.c (s390_setup_opcodes, md_begin): Likewise.
* config/tc-sparc.c (md_begin): Likewise.
* config/tc-tic30.c (md_begin): Likewise.
* config/tc-tic4x.c (tic4x_inst_insert): Likewise.
* config/tc-tilegx.c (md_begin): Likewise.
* config/tc-tilepro.c (md_begin): Likewise.
* config/tc-vax.c (vip_begin): Likewise.

* config/tc-alpha.c,
* config/tc-arm.c,
* config/tc-avr.c,
* config/tc-cr16.c,
* config/tc-csky.c,
* config/tc-i386.c,
* config/tc-m68hc11.c,
* config/tc-m68k.c,
* config/tc-microblaze.c,
* config/tc-ns32k.c,
* config/tc-pj.c,
* config/tc-ppc.c,
* config/tc-score.c,
* config/tc-score7.c,
* config/tc-tic4x.c,
* config/tc-tic54x.c,
* config/tc-tilegx.c,
* config/tc-tilepro.c,
* config/tc-xgate.c: Formatting.