binutils-gdb.git
4 years agoChange section_offsets to a std::vector
Tom Tromey [Mon, 6 Jan 2020 21:34:52 +0000 (14:34 -0700)]
Change section_offsets to a std::vector

This changes section_offsets to be specialization of a std::vector and
updates all the users.  It also removes the ANOFFSET and
SIZEOF_N_SECTION_OFFSETS macros.

Most of this is just a generic sort of cleanup, that reduces the
number of lines of code.  However, a couple spots were doing weird
things.

objfile_relocate did:

-      std::vector<struct section_offsets>
- new_debug_offsets (SIZEOF_N_SECTION_OFFSETS (debug_objfile->num_sections));

... which seems to greatly over-estimate the number of elements
needed.

This appeared in set_objfile_default_section_offset:

-  std::vector<struct section_offsets> offsets (objf->num_sections,
-        { { offset } });

... which makes sense due to type safety, but is also actively
confusing given that section_offsets was previously also a kind of
vector type.

Tested on x86-64 Fedora 30.

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

* xcoffread.c (enter_line_range, read_xcoff_symtab)
(process_xcoff_symbol, xcoff_symfile_offsets): Update.
* symtab.h (MSYMBOL_VALUE_ADDRESS): Update.
(struct section_offsets, ANOFFSET, SIZEOF_N_SECTION_OFFSETS):
Remove.
(section_offsets): New typedef.
* symtab.c (fixup_section, get_msymbol_address): Update.
* symmisc.c (dump_msymbols): Update.
* symfile.h (relative_addr_info_to_section_offsets)
(symfile_map_offsets_to_segments): Update.
* symfile.c (build_section_addr_info_from_objfile)
(init_objfile_sect_indices): Update.
(struct place_section_arg): Change type of "offsets".
(place_section): Update.
(relative_addr_info_to_section_offsets): Change type of
"section_offsets".  Remove "num_sections" parameter.
(default_symfile_offsets, syms_from_objfile_1)
(set_objfile_default_section_offset): Update.
(reread_symbols): No need to preserve section offsets by hand.
(symfile_map_offsets_to_segments): Change type of "offsets".
* stap-probe.c (relocate_address): Update.
* stabsread.h (process_one_symbol): Update.
* solib-target.c (struct lm_info_target) <offsets>: Change type.
(solib_target_relocate_section_addresses): Update.
* solib-svr4.c (enable_break, svr4_relocate_main_executable):
Update.
* solib-frv.c (frv_relocate_main_executable): Update.
* solib-dsbt.c (dsbt_relocate_main_executable): Update.
* solib-aix.c (solib_aix_get_section_offsets): Change return
type.
(solib_aix_solib_create_inferior_hook): Update.
* remote.c (remote_target::get_offsets): Update.
* psymtab.c (find_pc_sect_psymtab): Update.
* psympriv.h (struct partial_symbol) <address, text_low,
text_high>: Update.
* objfiles.h (obj_section_offset): Update.
(struct objfile) <section_offsets>: Change type.
<num_sections>: Remove.
(objfile_relocate): Update.
* objfiles.c (entry_point_address_query): Update
(relocate_one_symbol): Change type of "section_offsets".
(objfile_relocate1, objfile_relocate1): Change type of
"new_offsets".
(objfile_rebase1): Update.
* mipsread.c (mipscoff_symfile_read): Update.
(read_alphacoff_dynamic_symtab): Remove "section_offsets"
parameter.
* mdebugread.c (parse_symbol): Change type of "section_offsets".
(parse_external, psymtab_to_symtab_1): Update.
* machoread.c (macho_symfile_offsets): Update.
* ia64-tdep.c (ia64_find_unwind_table): Update.
* hppa-tdep.c (read_unwind_info): Update.
* hppa-bsd-tdep.c (hppabsd_find_global_pointer): Update.
* dwarf2read.c (create_addrmap_from_index)
(create_addrmap_from_aranges, dw2_find_pc_sect_compunit_symtab)
(process_psymtab_comp_unit_reader, add_partial_symbol)
(add_partial_subprogram, process_full_comp_unit)
(read_file_scope, read_func_scope, read_lexical_block_scope)
(read_call_site_scope, dwarf2_rnglists_process)
(dwarf2_ranges_process, dwarf2_ranges_read)
(dwarf_decode_lines_1, var_decode_location, new_symbol)
(dwarf2_fetch_die_loc_sect_off, dwarf2_per_cu_text_offset):
Update.
* dwarf2-frame.c (execute_cfa_program, dwarf2_frame_find_fde):
Update.
* dtrace-probe.c (dtrace_probe::get_relocated_address): Update.
* dbxread.c (read_dbx_symtab, read_ofile_symtab): Update.
(process_one_symbol): Change type of "section_offsets".
* ctfread.c (get_objfile_text_range): Update.
* coffread.c (coff_symtab_read, enter_linenos)
(process_coff_symbol): Update.
* coff-pe-read.c (add_pe_forwarded_sym): Update.
* amd64-windows-tdep.c (amd64_windows_find_unwind_info): Update.

Change-Id: I147eb967e9b44d82f4048039de7bb44b80cd72fb

4 years agoUse std::string in dwarf2read.c
Tom Tromey [Thu, 31 Oct 2019 16:46:18 +0000 (10:46 -0600)]
Use std::string in dwarf2read.c

This replaces two instances of manual string management in
dwarf2read.c with std::string.

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

* dwarf2read.c (parse_macro_definition): Use std::string.
(parse_macro_definition): Likewise.

Change-Id: Iec437100105484aa4a116fb5d651d7ed52ee9d81

4 years agoUse std::vector in abbrev_table_read_table
Tom Tromey [Thu, 31 Oct 2019 16:37:35 +0000 (10:37 -0600)]
Use std::vector in abbrev_table_read_table

This removes some manual memory management from
abbrev_table_read_table, replacing it with a std::vector.

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

* dwarf2read.c (abbrev_table_read_table): Use std::vector.
(ATTR_ALLOC_CHUNK): Remove.

Change-Id: I0b0e70ac2281d89a78f4d6a642700c9f0506871d

4 years agoUse unique_xmalloc_ptr in fixup_go_packaging
Tom Tromey [Thu, 31 Oct 2019 16:34:40 +0000 (10:34 -0600)]
Use unique_xmalloc_ptr in fixup_go_packaging

This changes fixup_go_packaging to use unique_xmalloc_ptr.  I kept
this patch separate as it is slightly more complicated than the
previous changes.

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

* dwarf2read.c (fixup_go_packaging): Use unique_xmalloc_ptr.

Change-Id: I0c553d0c6579db478c27bc40fc21133a61e1a4d9

4 years agoRemove some explicit memory management from dwarf2read.c
Tom Tromey [Thu, 31 Oct 2019 16:31:28 +0000 (10:31 -0600)]
Remove some explicit memory management from dwarf2read.c

I noticed a few spots in dwarf2read.c that could be improved by moving
to unique_xmalloc_ptr or, in one case, std::vector.

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

* dwarf2read.c (add_partial_symbol): Use unique_xmalloc_ptr.
(dwarf2_compute_name, open_dwo_file): Likewise.
(process_enumeration_scope): Use std::vector.
(guess_partial_die_structure_name): Use unique_xmalloc_ptr.
(partial_die_info::fixup, dwarf2_start_subfile)
(guess_full_die_structure_name, dwarf2_name): Likewise.
(determine_prefix): Update.
(guess_full_die_structure_name): Make return type const.
(partial_die_full_name): Return unique_xmalloc_ptr.
(DW_FIELD_ALLOC_CHUNK): Remove.

Change-Id: I1cb278c608041ef36ef1f77c7e7565c921038d08

4 years agoDocument the fact that the assembler's alignment pseudo-ops can be issued without...
Nick Clifton [Wed, 8 Jan 2020 17:00:54 +0000 (17:00 +0000)]
Document the fact that the assembler's alignment pseudo-ops can be issued without any argumemtns.

PR 25284
* doc/as.texi (Align): Document the fact that all arguments can be
omitted.
(Balign): Likewise.
(P2align): Likewise.

4 years agoMake the assembler generate an error if there is an attempt to define a section with...
Nick Clifton [Wed, 8 Jan 2020 16:30:20 +0000 (16:30 +0000)]
Make the assembler generate an error if there is an attempt to define a section with the same name as an already defined symbol.

PR 14891
* config/obj-elf.c (obj_elf_section): Fail if the section name is
already defined as a different symbol type.
* testsuite/gas/elf/pr14891.s: New test source file.
* testsuite/gas/elf/pr14891.d: New test driver.
* testsuite/gas/elf/pr14891.s: New test expected error output.
* testsuite/gas/elf/elf.exp: Run the new test.

4 years agoubsan: z8k: index 10 out of bounds for type 'unsigned int const[10]'
Alan Modra [Wed, 8 Jan 2020 01:12:36 +0000 (11:42 +1030)]
ubsan: z8k: index 10 out of bounds for type 'unsigned int const[10]'

The fix is the additional ARRAY_SIZE test, the rest just tidies
variable types rather than adding a cast to avoid warnings.

opcodes/
* z8k-dis.c: Include libiberty.h
(instr_data_s): Make max_fetched unsigned.
(z8k_lookup_instr): Make nibl_index and tabl_index unsigned.
Don't exceed byte_info bounds.
(output_instr): Make num_bytes unsigned.
(unpack_instr): Likewise for nibl_count and loop.
* z8kgen.c (gas <opcode_entry_type>): Make noperands, length and
idx unsigned.
* z8k-opc.h: Regenerate.
gas/
* config/tc-z8k.c (md_begin): Make idx unsigned.
(get_specific): Likewise for this_index.

4 years agoPR25351 .ARM.attributes not found for symbol
Alan Modra [Wed, 8 Jan 2020 01:06:01 +0000 (11:36 +1030)]
PR25351 .ARM.attributes not found for symbol

PR 25351
* elflink.c (bfd_elf_final_link): Call _bfd_fix_excluded_sec_syms
after removing sections.

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

4 years agoAdd constructor to stap_static_probe_ops
Tom Tromey [Thu, 19 Dec 2019 18:35:22 +0000 (11:35 -0700)]
Add constructor to stap_static_probe_ops

PR build/24937 concerns an error given by the clang provided by a
particular version of macOS.  In particular, it reports

    error: default initialization of an object of const type 'const
    stap_static_probe_ops' without a user-provided default constructor

Although (at least according to sources I found online) this was
resolved as a bug in the standard, it seemed simple enough to work
around this.

Given that this is a trivial build fix, I think it should go on the
gdb 9 branch as well.

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

PR build/24937:
* stap-probe.c (class stap_static_probe_ops): Add constructor.

Change-Id: I18f180c17850f420e9b66afc67f9cb3d8dceb0b3

4 years agoEnable styling by default on Cygwin
Jon Turney [Sun, 29 Dec 2019 22:26:41 +0000 (22:26 +0000)]
Enable styling by default on Cygwin

Cygwin meets the expectations of gdb for styling (if TERM is set and not
'DUMB', the terminal supports 'ANSI' (ECMA-48) escape sequences.

gdb/ChangeLog:

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

* cli/cli-style.c: Set cli_styling to 'true' in the Cygwin build.

4 years ago[ARC] Improve parsing instruction operands.
Claudiu Zissulescu [Tue, 7 Jan 2020 13:29:16 +0000 (15:29 +0200)]
[ARC] Improve parsing instruction operands.

We use gas' expression function to parse the operands of an
instruction in a generic way. There are situations when we have labels
and registers having the same name as well as the substraction sign
doesn't always stands for the arithmetical operation but for the
register range (e.g. enter instruction). This patch improves parsing
symbols found in a instruction operand, cleans up code and avoids
using default or undefined variables.

gas/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

* config/tc-arc.c (parse_reloc_symbol): New function.
(tokenize_arguments): Clean up, use parse_reloc_symbol function.
(md_operand): Set X_md to absent.
(arc_parse_name): Check for X_md.

4 years ago[ARC] Add finer details for LLOCK and SCOND
Shahab Vahedi [Tue, 7 Jan 2020 13:25:15 +0000 (15:25 +0200)]
[ARC] Add finer details for LLOCK and SCOND

This patch changes the "class" of LLOCK/SCOND from "MEMORY" to
"LLOCK/SCOND" respectively. Moreover, it corrects the "data_size_mode".

These changes are necessary for GDB's atmoic sequence handler.

Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 7 Jan 2020 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoRISC-V: Fix weak function call reloc overflow on llvm build.
Jim Wilson [Mon, 6 Jan 2020 23:34:50 +0000 (15:34 -0800)]
RISC-V: Fix weak function call reloc overflow on llvm build.

bfd/
PR 25205
* elfnn-riscv.c (riscv_elf_relocate_section) <R_RISCV_CALL>: Add
check for !bfd_link_pic (info).
<R_RISCV_CALL_PLT>: Move next to R_RISCV_CALL.
<R_RISCV_JAL>: Add comment.
(_bfd_riscv_relax_section): For plt.offset check, add check for
bfd_link_pic (info).  Add comment.

Change-Id: Ie769bc3d5adf096a51df5cc12efe3d50e80acb8f

4 years agoRe: Prefer object over notype symbols when disassembling
Alan Modra [Mon, 6 Jan 2020 22:59:54 +0000 (09:29 +1030)]
Re: Prefer object over notype symbols when disassembling

Reverts unnecessary mips testsuite changes made by commit 660df28acf.

* testsuite/ld-mips-elf/eh-frame5.s,
* testsuite/ld-mips-elf/ehdr_start-new.s,
* testsuite/ld-mips-elf/ehdr_start-o32.s,
* testsuite/ld-mips-elf/mips16-call-global-1.s,
* testsuite/ld-mips-elf/mips16-intermix-1.s,
* testsuite/ld-mips-elf/mips16-pic-1b.s,
* testsuite/ld-mips-elf/mips16-pic-4c.s,
* testsuite/ld-mips-elf/no-shared-1-n64.s,
* testsuite/ld-mips-elf/no-shared-1-o32.s,
* testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s,
* testsuite/ld-mips-elf/pic-and-nonpic-1b.s,
* testsuite/ld-mips-elf/pic-and-nonpic-2a.s,
* testsuite/ld-mips-elf/pic-and-nonpic-3b.s,
* testsuite/ld-mips-elf/pic-and-nonpic-4b.s,
* testsuite/ld-mips-elf/pic-and-nonpic-5a.s,
* testsuite/ld-mips-elf/pic-and-nonpic-6-n32c.s,
* testsuite/ld-mips-elf/pic-and-nonpic-6-n64c.s,
* testsuite/ld-mips-elf/pic-and-nonpic-6-o32c.s,
* testsuite/ld-mips-elf/pie.s,
* testsuite/ld-mips-elf/relax-jalr.s: Revert 2019-12-17 change.

4 years agogdb: Fix backtrace with disassemble-next-line on
Andrew Burgess [Thu, 26 Dec 2019 20:56:01 +0000 (20:56 +0000)]
gdb: Fix backtrace with disassemble-next-line on

In this commit:

  commit ec8e2b6d3051f0b4b2a8eee9917898e95046c62f
  Date:   Fri Jun 14 23:43:00 2019 +0100

      gdb: Don't allow annotations to influence what else GDB prints

A change was accidentally made that moved a call to do_gdb_disassembly
out of an if block guarded by 'if (source_print && sal.symtab)'.  The
result was that if a user has 'set disassemble-next-line on' then the
backtrace would now include some disassembly of a few instructions in
each frame.

This change was not intentional, but was not spotted by any tests.

This commit restores the old behaviour and adds a test to ensure this
doesn't break again in the future.

gdb/ChangeLog:

* stack.c (print_frame_info): Move disassemble_next_line code
inside source_print block.

gdb/testsuite/ChangeLog:

* gdb.base/backtrace.c: New file.
* gdb.base/backtrace.exp: New file.

Change-Id: I47c52a202fa74be138382646b695827940178689

4 years agoFix MinGW native compilation of gdb/gdbsupport/gdb_wait.c
Eli Zaretskii [Mon, 6 Jan 2020 19:54:21 +0000 (21:54 +0200)]
Fix MinGW native compilation of gdb/gdbsupport/gdb_wait.c

gdb/ChangeLog
2020-01-06  Eli Zaretskii  <eliz@gnu.org>

* gdbsupport/gdb_wait.c: Include <signal.h> instead of
gdb/signals.h, as we are now using native signal symbols.

4 years agoGDB: Fix the overflow in addr/line_is_displayed()
Shahab Vahedi [Mon, 6 Jan 2020 14:27:32 +0000 (15:27 +0100)]
GDB: Fix the overflow in addr/line_is_displayed()

In tui_disasm_window::addr_is_displayed(), there can be situations
where "content" is empty. For instance, it can happen when the
"content" was not filled in tui_disasm_window::set_contents(),
because tui_disassemble() threw an exception. Usually this exception
is the result of fetching invalid PC addresses like the ones beyond
the end of the program.

Having "content.size ()" zero leads to an overflow in this condition
check inside tui_disasm_window::addr_is_displayed():

  int i = 0;
  while (i < content.size () - threshold ...) {
    ... content[i] ...
  }

"threshold" is 2 and there are times that "content.size ()" is 0.
This results into an overflow and the loop is entered whereas it
should have been skipped. Finally, "content[i]" access leads to
a segmentation fault.

Same problem applies to tui_source_window::line_is_displayed().

The issue has been discussed at length in bug 25345:
  https://sourceware.org/bugzilla/show_bug.cgi?id=25345

This commit avoids the segmentation faults with an early check:

  if (content.size () < SCROLL_THRESHOLD)
    return false;

Moreover, those functions have been overhauled to a leaner code.

gdb/ChangeLog:
2020-01-06  Shahab Vahedi  <shahab@synopsys.com>

* tui/tui-disasm.c (tui_disasm_window::addr_is_displayed): Avoid
overflow by an early check of content vs threshold.
        * tui/tui-source.c (tui_source_window::line_is_displayed):
Likewise.

4 years agoMention the recent fix of $_exitsignal on MS-Windows in gdb/NEWS
Eli Zaretskii [Mon, 6 Jan 2020 19:25:23 +0000 (21:25 +0200)]
Mention the recent fix of $_exitsignal on MS-Windows in gdb/NEWS

gdb/ChangeLog
2020-01-06  Eli Zaretskii  <eliz@gnu.org>

* NEWS: Mention the recent fix of $_exitsignal on MS-Windows.

4 years agoFix a crash with a malformed PE header
Jon Turney [Thu, 2 Jan 2020 00:25:56 +0000 (00:25 +0000)]
Fix a crash with a malformed PE header

Don't try to read the PE export table when no section contains the RVA
for it.

(I have a PE executable [1] packed with UPX, where the export table data
directory entry contains a RVA which doesn't correspond to any section.
Mistakenly trying to debug this with gdb makes it crash.)

[1] https://cygwin.com/setup/setup-2.898.x86_64.exe

gdb/ChangeLog:

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

* coff-pe-read.c (read_pe_exported_syms): Don't try to read the
export table if no section contains it's RVA.

4 years agoFix a typo in gdb/windows-tdep.c
Eli Zaretskii [Mon, 6 Jan 2020 18:22:15 +0000 (20:22 +0200)]
Fix a typo in gdb/windows-tdep.c

gdb/ChangeLog
2020-01-06  Eli Zaretskii  <eliz@gnu.org>

    * windows-tdep.c: Fix a typo in WINDOWS_SIGABRT.

4 years agoAdd -fcommon compiler command line option to linker tests that need common symbols.
Nick Clifton [Mon, 6 Jan 2020 16:24:23 +0000 (16:24 +0000)]
Add -fcommon compiler command line option to linker tests that need common symbols.

PR 25327
* testsuite/ld-elf/shared.exp: Add -fcommon option to compiler
command line when building libcomm1.o and pr13250 tests.
* testsuite/ld-plugin/lto.exp: Likewise for pr20267 tests.

4 years agoFix search in TUI
Hannes Domani [Sun, 22 Dec 2019 13:58:22 +0000 (14:58 +0100)]
Fix search in TUI

The variable last_line_listed is never set when print_source_lines_base is
called in TUI mode, so the search always started from the last line printed
outside of TUI mode.

gdb/ChangeLog:

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

* source.c (print_source_lines_base): Set last_line_listed.

4 years agoFix test of the fix for PR19579 when compiling with gcc-10.
Nick Clifton [Mon, 6 Jan 2020 14:00:34 +0000 (14:00 +0000)]
Fix test of the fix for PR19579 when compiling with gcc-10.

PR 25326
* testsuite/ld-elf/shared.exp: Add -fcommon option to compiler
command line when building pr19579 binaries.

4 years agoGDB: Remove trailing spaces in tui-disasm.c
Shahab Vahedi [Mon, 6 Jan 2020 12:54:18 +0000 (13:54 +0100)]
GDB: Remove trailing spaces in tui-disasm.c

A few trailing spaces are removed.

gdb/ChangeLog:
2020-01-06  Shahab Vahedi  <shahab@synopsys.com>

* tui/tui-disasm.c: Remove trailing spaces.

4 years agoImprove process exit status macros on MinGW
Eli Zaretskii [Mon, 6 Jan 2020 11:51:54 +0000 (11:51 +0000)]
Improve process exit status macros on MinGW

When a Windows program is terminated by a fatal exception, its exit
code is the value of that exception, as defined by the various
EXCEPTION_* symbols in the Windows API headers.  This commit emulates
WTERMSIG etc. by translating the fatal exception codes to more-or-less
equivalent Posix signals.

gdb/ChangeLog:
2020-01-06  Eli Zaretskii  <eliz@gnu.org>
    Pedro Alves  <palves@redhat.com>

* Makefile.in (COMMON_SFILES): Add gdbsupport/gdb_wait.c.
* windows-tdep.c: New enumeration of WINDOWS_SIG* signals.
(windows_gdb_signal_to_target): New function, uses the above
enumeration to convert GDB internal signal codes to equivalent
Windows codes.
(windows_init_abi): Call set_gdbarch_gdb_signal_to_target.
* windows-nat.c: Include "gdb_wait.h".
(get_windows_debug_event): Extract the fatal exception from the
exit status and convert to the equivalent Posix signal number.
* cli/cli-cmds.c (exit_status_set_internal_vars): Account for the
possibility that WTERMSIG returns GDB_SIGNAL_UNKNOWN.
* gdbsupport/gdb_wait.c: New file, implements
windows_status_to_termsig.
* gdbsupport/gdb_wait.h (WIFEXITED, WIFSIGNALED, WEXITSTATUS)
(WTERMSIG) [__MINGW32__]: Separate definitions for MinGW.

gdb/gdbserver/ChangeLog:
2020-01-06  Eli Zaretskii  <eliz@gnu.org>
    Pedro Alves  <palves@redhat.com>

* win32-low.c (get_child_debug_event): Extract the fatal exception
from the exit status and convert to the equivalent Posix signal
number.
(win32_wait): Allow TARGET_WAITKIND_SIGNALLED status as well.
* Makefile.in (OBS, SFILES): Add gdb_wait.[co].

4 years agobfd_check_format: ignore errors from coff_real_object_p
Alan Modra [Mon, 6 Jan 2020 09:21:22 +0000 (19:51 +1030)]
bfd_check_format: ignore errors from coff_real_object_p

Since 1993-11-05 git commit c188b0bec3b, bfd_check_format has failed
if any of the target object_p functions returns false with any error
but bfd_error_wrong_format.  That's just weird.  There is really no
reason why coff_real_object_p should be fixed to only return that
error instead of numerous other possible errors.  Even an out of
memory condition for one target doesn't necessarily mean other targets
can't match, assuming the failing target nicely returns all memory it
might have used.

* format.c (bfd_check_format_matches): Ignore bfd_error on target
match failures.  Don't init to bfd_error_wrong_format before
calling _bfd_check_format.

4 years agoalpha-vms: don't exit on stack underflow/overflow
Alan Modra [Mon, 6 Jan 2020 07:59:14 +0000 (18:29 +1030)]
alpha-vms: don't exit on stack underflow/overflow

BFD is not supposed to exit or abort on anything the user can do.

* vms-alpha.c (_bfd_vms_push, _bfd_vms_pop): Return pass/fail
status rather than exiting on stack overflow or underflow.
(_bfd_vms_slurp_etir): Adjust to suit.

4 years agoubsan: m32c: left shift of negative value
Alan Modra [Sat, 4 Jan 2020 09:23:19 +0000 (19:53 +1030)]
ubsan: m32c: left shift of negative value

There are probably a lot more of these still here.

cpu/
* m32c.cpu (f-dsp-8-u16, f-dsp-8-s16): Rearrange to mask any sign
bits before shifting rather than masking after shifting.
(f-dsp-16-u16, f-dsp-16-s16, f-dsp-32-u16, f-dsp-32-s16): Likewise.
(f-dsp-40-u16, f-dsp-40-s16, f-dsp-48-u16, f-dsp-48-s16): Likewise.
(f-dsp-64-u16, f-dsp-8-s24): Likewise.
(f-bitbase32-16-s19-unprefixed): Avoid signed left shift.
opcodes/
* m32c-ibld.c: Regenerate.

4 years agosom_bfd_fill_in_ar_symbols buffer overflow
Alan Modra [Mon, 6 Jan 2020 06:42:51 +0000 (17:12 +1030)]
som_bfd_fill_in_ar_symbols buffer overflow

* som.c (som_bfd_fill_in_ar_symbols): Bounds check som_dict index.

4 years agoBasic error checking for mach-o
Alan Modra [Sun, 5 Jan 2020 23:31:55 +0000 (10:01 +1030)]
Basic error checking for mach-o

Fixes lots of places the fuzzers are going to find, and the one they
already hit.

* mach-o.c (bfd_mach_o_read_dylinker): Don't read past end of
command.  Check name offset is within command.
(bfd_mach_o_read_dylib, bfd_mach_o_read_prebound_dylib),
(bfd_mach_o_read_prebind_cksum, bfd_mach_o_read_twolevel_hints),
(bfd_mach_o_read_fvmlib, bfd_mach_o_read_dysymtab),
(bfd_mach_o_read_symtab, bfd_mach_o_read_uuid),
(bfd_mach_o_read_linkedit, bfd_mach_o_read_str),
(bfd_mach_o_read_dyld_info, bfd_mach_o_read_version_min),
(bfd_mach_o_read_encryption_info, bfd_mach_o_read_source_version),
(bfd_mach_o_read_encryption_info_64, bfd_mach_o_read_main),
(bfd_mach_o_read_note, bfd_mach_o_read_build_version),
(bfd_mach_o_read_segment): Similarly.
(bfd_mach_o_read_thread): Properly bound check thread struct.
Don't repeat checks on second loop.
(bfd_mach_o_read_command): Fail on invalid command length.

4 years agoPR25344, z80 disassembler recursion
Alan Modra [Sun, 5 Jan 2020 22:22:39 +0000 (08:52 +1030)]
PR25344, z80 disassembler recursion

PR 25344
* z80-dis.c (suffix): Don't use a local struct buffer copy.
Peek at next byte to prevent recursion on repeated prefix bytes.
Ensure uninitialised "mybuf" is not accessed.
(print_insn_z80): Don't zero n_fetch and n_used here,..
(print_insn_z80_buf): ..do it here instead.

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

4 years agogdb: use tui_set_layout not show_layout to fix window focus
Andrew Burgess [Sun, 22 Dec 2019 23:45:31 +0000 (23:45 +0000)]
gdb: use tui_set_layout not show_layout to fix window focus

When calling tui_add_win_to_layout, use tui_set_layout not show_layout
so that window focus is correctly updated.  If the focus is not
correctly maintained then GDB can be crashed like this:

  start
  tui enable
  layout asm
  list SOME_FUNCTION

At this point GDB will have "popped up" the source window to
display SOME_FUNCTION.  Previously no window would have focus at this
point, and so if the user now does 'focus next' or 'focus prev', then
GDB would crash.

Calling tui_set_layout ensures that focus is correctly calculated as
the source window is "popped up", and this fixes the issue.

gdb/ChangeLog:

* tui/tui-layout.c (tui_add_win_to_layout): Use tui_set_layout not
show_layout.

gdb/testsuite/ChangeLog:

* gdb.tui/list.exp: Test 'focus next' after 'list main'.

Change-Id: Id0b13f99b0e889261efedfd0adabe82020202f44

4 years ago[AArch64] Fix erroneous use of spu architecture bfd
Luis Machado [Fri, 3 Jan 2020 19:08:16 +0000 (16:08 -0300)]
[AArch64] Fix erroneous use of spu architecture bfd

While investigating some SVE code, i noticed the use of two spu bfd variables.

This looks like an oversight, as the "id" field is available for non-spu
architectures as well, even though its primary use was the Cell BE
architecture.

gdb/ChangeLog:

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

* aarch64-linux-nat.c
(aarch64_linux_nat_target::thread_architecture): Use bfd_arch_aarch64
and bfd_mach_aarch64.

4 years agoFix libctf ChangeLog date in most recent entry.
Joel Brobecker [Sun, 5 Jan 2020 05:53:14 +0000 (09:53 +0400)]
Fix libctf ChangeLog date in most recent entry.

4 years agolibctf: Add configure check for asprintf (for MinGW)
Eli Zaretskii [Sun, 5 Jan 2020 05:50:27 +0000 (09:50 +0400)]
libctf: Add configure check for asprintf (for MinGW)

This commit fixes a compilation warning when compiling libctf
on MinGW:

    libctf/ctf-dump.c:118:8: warning: implicit declaration of function
    'asprintf'; did you mean 'vasprintf'? [-Wimplicit-function-declaration]

 if (asprintf (&bit, " %lx: [slice 0x%x:0x%x]",
     ^~~~~~~~
     vasprintf

MinGW doesn't provide that function, so we depend on the one provided
by libiberty. However, the declaration is guarded by HAVE_DECL_ASPRINTF,
which we do not have in libctf's config.h.

libctf/ChangeLog:

PR binutils/25155:
* configure.ac: Add AC_CHECK_DECLS([asprintf]).
* configure, config.h.in: Regenerate.

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

4 years agoRelease bfd_alloc memory in bfd_check_format_matches
Alan Modra [Thu, 2 Jan 2020 07:09:32 +0000 (17:39 +1030)]
Release bfd_alloc memory in bfd_check_format_matches

It's a little tricky.  We can release any memory back when we have a
match failure, but after a match success which we might want to
preserve for later use the high water mark must change to that of the
matched bfd.

* format.c (bfd_check_format_matches): Add preserve_match.
Save initial bfd state in "preserve", matched bfd state in
"preserve_match".  Save just the first match.  Release
bfd_alloc memory.  Restore and finish preserved state as
appropriate on all function exit paths.

4 years agommo tdata leak
Alan Modra [Mon, 30 Dec 2019 22:25:08 +0000 (08:55 +1030)]
mmo tdata leak

malloc'd tdata isn't freed.

* mmo.c (mmo_mkobject): Allocate tdata with bfd_zalloc.

4 years agoubsan: m32r: left shift of negative value
Alan Modra [Fri, 3 Jan 2020 21:41:43 +0000 (08:11 +1030)]
ubsan: m32r: left shift of negative value

cpu/
* m32r.cpu (f-disp8): Avoid left shift of negative values.
(f-disp16, f-disp24): Likewise.
opcodes/
* m32r-ibld.c: Regenerate.

4 years agoubsan: cr16: left shift cannot be represented in type 'int'
Alan Modra [Thu, 2 Jan 2020 21:42:00 +0000 (08:12 +1030)]
ubsan: cr16: left shift cannot be represented in type 'int'

* cr16-dis.c (cr16_match_opcode): Avoid shift left of signed value.

4 years agoubsan: crx: left shift cannot be represented in type 'int'
Alan Modra [Thu, 2 Jan 2020 20:37:17 +0000 (07:07 +1030)]
ubsan: crx: left shift cannot be represented in type 'int'

* crx-dis.c (match_opcode): Avoid shift left of signed value.

4 years agoubsan: d30v: left shift cannot be represented in type 'int'
Alan Modra [Wed, 1 Jan 2020 08:16:43 +0000 (18:46 +1030)]
ubsan: d30v: left shift cannot be represented in type 'int'

* d30v-dis.c (print_insn): Avoid signed overflow in left shift.

4 years agocoff: free malloc'd memory on successful target match too
Alan Modra [Tue, 31 Dec 2019 23:58:42 +0000 (10:28 +1030)]
coff: free malloc'd memory on successful target match too

object_p functions cannot allocate memory by malloc and not free it
before returning.  Even a successful target match may not be the best
match.  If a match isn't used then those malloc'd blocks won't be
freed.

* coffgen.c (coff_real_object_p): Free malloc'd memory on target
match too.

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

4 years agoEnsure GDB warnings are styled.
Philippe Waroquiers [Sun, 15 Dec 2019 16:58:16 +0000 (17:58 +0100)]
Ensure GDB warnings are styled.

While handling the comments of Tom related to
  [RFC] Have an option to tell GDB to detect and possibly handle mismatched exec-files.
  https://sourceware.org/ml/gdb-patches/2019-12/msg00621.html
I saw that GDB warnings are produced ignoring the given styles.

This patch:
  * ensures that style markups are properly handled by "warning".
  * changes 'set/show data-directory' so that file style is used
    in warnings and in 'show message'
  * changes all other messages in top.c to use file style when appropriate.
  * Uses the above data-directory changes in gdb.base/style.exp

2020-01-03  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* ui-file.c (stdio_file::can_emit_style_escape)
(tee_file::can_emit_style_escape): Ensure style is used also on
gdb_stderr when gdb_stderr is a tty supporting styling, similarly
to gdb_stdout.
* main.c (set_gdb_data_directory): Use file style to output the
warning that the given pathname is not a directory.
* top.c (show_history_filename, gdb_safe_append_history)
(show_gdb_datadir): Use file style.

2020-01-03  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.base/style.exp: Test that warnings are styled.

4 years agosolib_target_free_so memory leak
Hannes Domani [Fri, 27 Dec 2019 12:41:58 +0000 (13:41 +0100)]
solib_target_free_so memory leak

gdb/ChangeLog:

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

* solib-target.c (struct lm_info_target):
Change offsets to be a unique_xmalloc_ptr.
(solib_target_relocate_section_addresses): Update.

4 years agowindows_clear_solib memory leak
Hannes Domani [Tue, 24 Dec 2019 12:14:01 +0000 (13:14 +0100)]
windows_clear_solib memory leak

gdb/ChangeLog:

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

* windows-nat.c (windows_clear_solib): Free so_list linked list.

4 years agoAllow individual targets to decide if string escapes should be allowed. Disable...
Sergey Belyashov [Fri, 3 Jan 2020 16:23:19 +0000 (16:23 +0000)]
Allow individual targets to decide if string escapes should be allowed.  Disable for PPC and Z80.

PR 25311
* as.h (TC_STRING_ESCAPES): Provide a default definition.
* app.c (do_scrub_chars): Use TC_STRING_ESCAPES instead of
NO_STRING_ESCAPES.
* read.c (next_char_of_string): Likewise.
* config/tc-ppc.h (TC_STRING_ESCAPES): Define.
* config/tc-z80.h (TC_STRING_ESCAPES): Define.

4 years agoFix potential illegal memory access when parsing a corrupt PEF format file.
Nick Clifton [Fri, 3 Jan 2020 16:17:53 +0000 (16:17 +0000)]
Fix potential illegal memory access when parsing a corrupt PEF format file.

PR 25307
(bfd_pef_parse_function_stubs): Correct the test that ensures that
there is enough data remaining in the code buffer before
attempting to read a function stub.

4 years agoFix potential illegal memory access failures in the BFD library by ensuring that...
Nick Clifton [Fri, 3 Jan 2020 14:41:02 +0000 (14:41 +0000)]
Fix potential illegal memory access failures in the BFD library by ensuring that the return value from bfd_malloc() is checked before it is used.

PR 25308
* elf-properties.c (_bfd_elf_convert_gnu_properties): Check the
return value from bfd_malloc.
* elf32-arm.c (bfd_elf32_arm_vfp11_fix_veneer_locations): Likewise.
(bfd_elf32_arm_stm32l4xx_fix_veneer_locations): Likewise.
(elf32_arm_filter_cmse_symbols): Likewise.
(elf32_arm_write_section): Likewise.
* mach-o.c (bfd_mach_o_core_fetch_environment): Likewise.
(bfd_mach_o_follow_dsym): Likewise.
* pef.c (bfd_pef_print_loader_section): Likewise.
(bfd_pef_scan_start_address): Likewise.
(bfd_pef_parse_function_stubs): Likewise.
(bfd_pef_parse_symbols): Likewise.

4 years agoUpdated Swedish translation for the GAS subdirectory.
Nick Clifton [Fri, 3 Jan 2020 12:59:54 +0000 (12:59 +0000)]
Updated Swedish translation for the GAS subdirectory.

4 years agoFor PE format files, the base relocation table is necessary if the image is loaded...
Hannes Domani [Fri, 3 Jan 2020 12:55:12 +0000 (12:55 +0000)]
For PE format files, the base relocation table is necessary if the image is loaded at a different image base than specified in the PE header.  This patch provides a new option --enable-reloc-section to force the generation of this section.

* emultempl/pe.em: Add new option --enable-reloc-section.
* emultempl/pep.em: Likewise.
* ld.texi: Document --enable-reloc-section.
* pe-dll.c (pe_dll_build_sections): Use pe_dll_enable_reloc_section.
(pe_dll_fill_sections): Simplify by calling pe_exe_fill_sections.
* pe-dll.h: Add extern declaration of option flag.
* pep-dll.c (pe_dll_enable_reloc_section):
Add alias define for pep_dll_enable_reloc_section.
* pep-dll.h: Add extern declaration of option flag.

4 years agoFix ld/PR25316 for the ia64 target by refusing to support binary merging.
Sergei Trofimovich [Fri, 3 Jan 2020 11:21:00 +0000 (11:21 +0000)]
Fix ld/PR25316 for the ia64 target by refusing to support binary merging.

ld/PR25316
* elfnn-ia64.c (elfNN_ia64_merge_private_bfd_data): don't fail
        on binary inputs ld/PR25316.
        (is_ia64_elf): new helper to filter on ia64 objects.

4 years agoArm64: correct address index operands for LD1RO{H,W,D}
Jan Beulich [Fri, 3 Jan 2020 09:16:44 +0000 (10:16 +0100)]
Arm64: correct address index operands for LD1RO{H,W,D}

Just like their LD1RQ{H,W,D} counterparts, as per the specification the
index registers get scaled by element size.

4 years agoArm64: correct {su,us}dot SIMD encodings
Jan Beulich [Fri, 3 Jan 2020 09:14:16 +0000 (10:14 +0100)]
Arm64: correct {su,us}dot SIMD encodings

According to the specification these permit the Q bit to control the
vector length operated on, and hence this bit should not already be set
in the opcode table entries (it rather needs setting dynamically). Note
how the test case output did also not match its input. Besides
correcting the test case also extend it to cover both forms.

4 years agoArm64: correct uzp{1,2} mnemonics
Jan Beulich [Fri, 3 Jan 2020 09:13:31 +0000 (10:13 +0100)]
Arm64: correct uzp{1,2} mnemonics

According to the specification, and in line with the pre-existing
predicate forms, the mnemonics do not include an 'i'.

4 years agoArm64: correct 64-bit element fmmla encoding
Jan Beulich [Fri, 3 Jan 2020 09:12:49 +0000 (10:12 +0100)]
Arm64: correct 64-bit element fmmla encoding

There's just one bit of difference to the 32-bit element form, as
per the documentation.

4 years agoMach-O: misc build adjustments
Jan Beulich [Fri, 3 Jan 2020 09:11:50 +0000 (10:11 +0100)]
Mach-O: misc build adjustments

Oldish gcc warns about local variables shadowing outer scope ones.
Additionally %lx is not (always) suitable to print the result of
bfd_get_32().

4 years agoAdd myself to gdb/MAINTAINERS
Bernd Edlinger [Fri, 3 Jan 2020 08:16:38 +0000 (09:16 +0100)]
Add myself to gdb/MAINTAINERS

2020-01-03  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* MAINTAINERS (Write After Approval): Add myself.

4 years agoRemove stale references to Cell BE
Luis Machado [Mon, 30 Dec 2019 18:47:10 +0000 (15:47 -0300)]
Remove stale references to Cell BE

While reading some code i noticed we're still referencing Cell BE in a couple
parts. This patch removes those.

v2: Update comment in gdb/target.h.

gdb/ChangeLog:

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

* proc-service.c (get_ps_regcache): Remove reference to obsolete
Cell BE architecture.
* target.h (struct target_ops) <thread_architecture>: Likewise.

Change-Id: I7a9ccc603b00db22a6275bc5ab69e1417148cb72

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

4 years agoAdd support for the GBZ80, Z180, and eZ80 variants of the Z80 architecure. Add an...
Sergey Belyashov [Thu, 2 Jan 2020 14:10:40 +0000 (14:10 +0000)]
Add support for the GBZ80, Z180, and eZ80 variants of the Z80 architecure.  Add an ELF based target for these as well.

PR 25224
bfd * Makefile.am: Add z80-elf target support.
* configure.ac: Likewise.
* targets.c: Likewise.
* config.bfd: Add z80-elf target support and new arches: ez80 and z180.
* elf32-z80.c: New file.
* archures.c: Add new z80 architectures: eZ80 and Z180.
* coffcode.h: Likewise.
* cpu-z80.c: Likewise.
* bfd-in2.h: Likewise plus additional Z80 relocations.
* coff-z80.c: Add new relocations for Z80 target and local label check.

gas * config/tc-z80.c: Add new architectures: Z180 and eZ80. Add support
for assembler code generated by SDCC. Add new relocation types. Add
z80-elf target support.
* config/tc-z80.h: Add z80-elf target support. Enable dollar local
labels. Local labels starts from ".L".
* testsuite/gas/all/fwdexp.d: Fix failure due to symbol conflict.
* testsuite/gas/all/fwdexp.s: Likewise.
* testsuite/gas/z80/suffix.d: Fix failure on ELF target.
* testsuite/gas/z80/z80.exp: Add new tests
* testsuite/gas/z80/dollar.d: New file.
* testsuite/gas/z80/dollar.s: New file.
* testsuite/gas/z80/ez80_adl_all.d: New file.
* testsuite/gas/z80/ez80_adl_all.s: New file.
* testsuite/gas/z80/ez80_adl_suf.d: New file.
* testsuite/gas/z80/ez80_isuf.s: New file.
* testsuite/gas/z80/ez80_z80_all.d: New file.
* testsuite/gas/z80/ez80_z80_all.s: New file.
* testsuite/gas/z80/ez80_z80_suf.d: New file.
* testsuite/gas/z80/r800_extra.d: New file.
* testsuite/gas/z80/r800_extra.s: New file.
* testsuite/gas/z80/r800_ii8.d: New file.
* testsuite/gas/z80/r800_z80_doc.d: New file.
* testsuite/gas/z80/z180.d: New file.
* testsuite/gas/z80/z180.s: New file.
* testsuite/gas/z80/z180_z80_doc.d: New file.
* testsuite/gas/z80/z80_doc.d: New file.
* testsuite/gas/z80/z80_doc.s: New file.
* testsuite/gas/z80/z80_ii8.d: New file.
* testsuite/gas/z80/z80_ii8.s: New file.
* testsuite/gas/z80/z80_in_f_c.d: New file.
* testsuite/gas/z80/z80_in_f_c.s: New file.
* testsuite/gas/z80/z80_op_ii_ld.d: New file.
* testsuite/gas/z80/z80_op_ii_ld.s: New file.
* testsuite/gas/z80/z80_out_c_0.d: New file.
* testsuite/gas/z80/z80_out_c_0.s: New file.
* testsuite/gas/z80/z80_reloc.d: New file.
* testsuite/gas/z80/z80_reloc.s: New file.
* testsuite/gas/z80/z80_sli.d: New file.
* testsuite/gas/z80/z80_sli.s: New file.

ld * Makefile.am: Add new target z80-elf
* configure.tgt: Likewise.
* emultempl/z80.em: Add support for eZ80 and Z180 architectures.
* emulparams/elf32z80.sh: New file.
* emultempl/z80elf.em: Likewise.
* testsuite/ld-z80/arch_ez80_adl.d: Likewise.
* testsuite/ld-z80/arch_ez80_z80.d: Likewise.
* testsuite/ld-z80/arch_r800.d: Likewise.
* testsuite/ld-z80/arch_z180.d: Likewise.
* testsuite/ld-z80/arch_z80.d: Likewise.
* testsuite/ld-z80/comb_arch_ez80_z80.d: Likewise.
* testsuite/ld-z80/comb_arch_z180.d: Likewise.
* testsuite/ld-z80/labels.s: Likewise.
* testsuite/ld-z80/relocs.s: Likewise.
* testsuite/ld-z80/relocs_b_ez80.d: Likewise.
* testsuite/ld-z80/relocs_b_z80.d: Likewise.
* testsuite/ld-z80/relocs_f_z80.d: Likewise.
* testsuite/ld-z80/z80.exp: Likewise.

opcodes * z80-dis.c: Add support for eZ80 and Z80 instructions.

4 years agoAArch64: Set the correct ELF class for AArch64 stubs (PR/25210)
Tamar Christina [Thu, 2 Jan 2020 14:06:01 +0000 (14:06 +0000)]
AArch64: Set the correct ELF class for AArch64 stubs (PR/25210)

This fixes PR 25210 by specifying the the correct ELF class for AArch64 stubs.
After doing this the stub section starts behaving like a normal object file
loaded from disk.  That is SEC_LINKER_CREATED causes us to have to write the
section manually.

This flag was added as a fix for PR 24753.  I believe that
fix to still be correct as linker created sections don't have a size on disk
and it fixes the Arm bootstrap regression. But in this case specifying the
correct section class also makes the stub section not be considered by
compress.c.

So I'm partially revert this change so that we don't have to manage the section
manually as implied by SEC_LINKER_CREATED.

bfd/ChangeLog:

PR 25210
PR 24753
* elfnn-aarch64.c (_bfd_aarch64_create_stub_section): Set ELF class.

ld/ChangeLog:

PR 25210
PR 24753
* emultempl/aarch64elf.em (elf${ELFSIZE}_aarch64_add_stub_section):
Remove SEC_LINKER_CREATED.
* testsuite/ld-aarch64/aarch64-elf.exp: Add erratum835769-843419.
* testsuite/ld-aarch64/erratum835769-843419.d: New test.

4 years ago[ARM][gas] fix build breakage with gcc-10 by using correct enum type
Szabolcs Nagy [Mon, 21 Oct 2019 15:59:11 +0000 (16:59 +0100)]
[ARM][gas] fix build breakage with gcc-10 by using correct enum type

Fixes

../../gas/config/tc-arm.c: In function 'parse_reg_list':
../../gas/config/tc-arm.c:1946:35: error: implicit conversion from 'enum reg_list_els' to 'enum arm_reg_type' [-Werror=enum-conversion]
 1946 |        reg = arm_reg_parse (&str, REGLIST_RN);
      |                                   ^~~~~~~~~~

gas/ChangeLog:

* config/tc-arm.c (parse_reg_list): Use REG_TYPE_RN instead of
REGLIST_RN.

4 years agoEnable building the s12z target on Solaris hosts where REG_Y is defined in system...
Nick Clifton [Thu, 2 Jan 2020 12:04:40 +0000 (12:04 +0000)]
Enable building the s12z target on Solaris hosts where REG_Y is defined in system header files.

* opcode/s12z.h: Undef REG_Y.

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

4 years agoFix install-strip for cross-compilation
Hannes Domani [Mon, 30 Dec 2019 16:01:02 +0000 (17:01 +0100)]
Fix install-strip for cross-compilation

The variable INSTALL_PROGRAM_ENV sets up STRIPPROG for the cross-compiler.

If this is not done, the host 'strip' is used, and fails:

/bin/sh /c/src/repos/binutils-gdb.git/install-sh -c -s gdb.exe \
  /gdb/gdb64-git/bin/$transformed_name.exe
strip.exe:C:/gdb/gdb64-git/bin/_inst.33599_: file format not recognized

With this change, it's fine:

STRIPPROG='x86_64-w64-mingw32-strip' \
  /bin/sh /c/src/repos/binutils-gdb.git/install-sh -c -s gdb.exe \
  /gdb/gdb64-git/bin/$transformed_name.exe

gdb/ChangeLog:

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

* Makefile.in: Use INSTALL_PROGRAM_ENV.

gdb/gdbserver/ChangeLog:

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

* Makefile.in: Use INSTALL_PROGRAM_ENV.

4 years agoAdd myself to gdb/MAINTAINERS
Hannes Domani [Wed, 1 Jan 2020 12:00:28 +0000 (13:00 +0100)]
Add myself to gdb/MAINTAINERS

gdb/ChangeLog:

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

* MAINTAINERS (Write After Approval): Add myself.

4 years agoRe: Update year range in copyright notice of binutils files
Alan Modra [Wed, 1 Jan 2020 08:22:19 +0000 (18:52 +1030)]
Re: Update year range in copyright notice of binutils files

Add the ChangeLog entry.

4 years agoUpdate year range in copyright notice of binutils files
Alan Modra [Wed, 1 Jan 2020 07:57:01 +0000 (18:27 +1030)]
Update year range in copyright notice of binutils files

4 years agoChangeLog rotation
Alan Modra [Wed, 1 Jan 2020 07:37:11 +0000 (18:07 +1030)]
ChangeLog rotation

4 years agoUpdate copyright year in gdbarch.sh doc/gdb.texinfo and doc/refcard.tex
Joel Brobecker [Wed, 1 Jan 2020 06:37:10 +0000 (10:37 +0400)]
Update copyright year in gdbarch.sh doc/gdb.texinfo and doc/refcard.tex

These are files that need to be updated by hand, because the copyright.py
script isn't able to handle them automatically.

gdb/ChangeLog:

* gdbarch.sh: Update copyright year range of generated files.

gdb/doc/ChangeLog:

        * gdb.texinfo, refcard.tex: Update copyright year range.

4 years agoUpdate copyright year range in all GDB files.
Joel Brobecker [Wed, 1 Jan 2020 06:20:01 +0000 (10:20 +0400)]
Update copyright year range in all GDB files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.

4 years agogdb/copyright.py: Convert to Python 3
Joel Brobecker [Wed, 1 Jan 2020 06:12:57 +0000 (10:12 +0400)]
gdb/copyright.py: Convert to Python 3

gdb/ChangeLog:

        * copyright.py: Convert to Python 3.

4 years agogdb/copyright.py: Adapt after move of gnulib from gdb to toplevel
Joel Brobecker [Wed, 1 Jan 2020 05:19:14 +0000 (09:19 +0400)]
gdb/copyright.py: Adapt after move of gnulib from gdb to toplevel

gdb/ChangeLog:

* copyright.py: Adapt after move of gnulib directory from gdb
directory to toplevel directory.

4 years agogdb/copyright.py: Exit if run from the wrong directory
Joel Brobecker [Wed, 1 Jan 2020 05:08:08 +0000 (09:08 +0400)]
gdb/copyright.py: Exit if run from the wrong directory

We printed an error, but kept going anyway... ;-)

gdb/ChangeLog:

* copyright.py (main): Exit if run from the wrong directory.

4 years agoupdate copyright year in version output of gdb, gdbserver and gdbreplay
Joel Brobecker [Wed, 1 Jan 2020 04:43:08 +0000 (08:43 +0400)]
update copyright year in version output of gdb, gdbserver and gdbreplay

gdb/ChangeLog:

        * top.c (print_gdb_version): Change copyright year to 2020.

gdb/gdbserver/ChangeLog:

        * server.c (gdbserver_version): Change copyright year to 2020.
        * gdbreplay.c (gdbreplay_version): Likewise.

4 years agoRotate gdb/ChangeLog (start of New Year procedure)
Joel Brobecker [Wed, 1 Jan 2020 04:40:23 +0000 (08:40 +0400)]
Rotate gdb/ChangeLog (start of New Year procedure)

gdb/ChangeLog:

* config/djgpp/fnchange.lst: Add entry for gdb/ChangeLog-2019

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

4 years agoasan: alpha-vms: Heap-buffer-overflow
Alan Modra [Tue, 31 Dec 2019 11:54:31 +0000 (22:24 +1030)]
asan: alpha-vms: Heap-buffer-overflow

This fixes yet more errors in the alpha-vms buffer size checks.

* vms-alpha.c (_bfd_vms_slurp_eisd): Don't overflow when checking
offset.  Don't overflow when checking rec_size, and do allow
rec_size to the end of the buffer.  Ensure eisd->type can be
accessed, not just the first 32 bytes.  Don't call
_bfd_vms_save_counted_string with zero length remaining.  Fail
on empty string section name.
(_bfd_vms_slurp_egsd): Formatting.  Catch more reads past end
of record size.  Correct remaining length calculation.  Fail
on empty string section name.  Consolidate error paths.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 31 Dec 2019 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoMake some TUI globals "static"
Tom Tromey [Mon, 30 Dec 2019 16:11:32 +0000 (09:11 -0700)]
Make some TUI globals "static"

This changes a few TUI globals to be "static".  Tested by rebuilding.

gdb/ChangeLog
2019-12-30  Tom Tromey  <tom@tromey.com>

* tui/tui-win.c (tui_border_mode_translate)
(tui_border_kind_translate_vline, tui_border_kind_translate_hline)
(tui_border_kind_translate_ulcorner)
(tui_border_kind_translate_urcorner)
(tui_border_kind_translate_llcorner)
(tui_border_kind_translate_lrcorner, tui_active_border_mode)
(tui_border_mode, tui_border_kind): Now static.

Change-Id: Ibb49a0df195dfe780a5ba1f90e9125ab5f6b7ce1

4 years agoUse "bool" in more spots in TUI
Tom Tromey [Mon, 30 Dec 2019 16:07:33 +0000 (09:07 -0700)]
Use "bool" in more spots in TUI

This changes a few spots in the TUI to use "bool" rather than "int".
Tested on x86-64 Fedora 28.

gdb/ChangeLog
2019-12-30  Tom Tromey  <tom@tromey.com>

* tui/tui-interp.c (tui_start_enabled): Now bool.
(_initialize_tui_interp): Update.
* tui/tui-hooks.c (tui_refreshing_registers): Now bool.
(tui_register_changed)
(tui_refresh_frame_and_register_information): Update.
* tui/tui-win.c (tui_update_variables): Return bool.
* tui/tui-win.h (tui_update_variables): Return bool.
* tui/tui.c (tui_get_command_dimension): Return bool.
* tui/tui.h (tui_get_command_dimension): Return bool.

Change-Id: I55b7f2d62d2ef88da3587dc914ada9f463ad8d2b

4 years agovms-alpha.c object_p memory leaks
Alan Modra [Mon, 30 Dec 2019 11:10:08 +0000 (21:40 +1030)]
vms-alpha.c object_p memory leaks

* vms-alpha.c (alpha_vms_free_private): New function, extracted..
(vms_close_and_cleanup): ..from here.
(alpha_vms_object_p): Call alpha_vms_free_private on failure.

4 years agocoff object_p memory leaks
Alan Modra [Mon, 30 Dec 2019 10:47:08 +0000 (21:17 +1030)]
coff object_p memory leaks

* coffgen.c (coff_real_object_p): Free malloc'd memory on failure.

4 years agoarchive.c bfd_zalloc
Alan Modra [Mon, 30 Dec 2019 01:18:20 +0000 (11:48 +1030)]
archive.c bfd_zalloc

Quite a few bfd_zalloc calls are wasting time clearing memory, and
should be bfd_alloc instead.

* archive.c (do_slurp_bsd_armap): Use bfd_alloc rather than
bfd_zalloc when memory is all written after the call.
(do_slurp_coff_armap): Likewise.  Set bfd_error on ridiculously
large allocations that overflow bfd_size_type.  Use just one
bfd_release on error exit.
(_bfd_slurp_extended_name_table): Use bfd_alloc for extended_names,
clear last byte rather than the entire array.  Use bfd_alloc for
string table.  Rearrange and simplify code copying file names.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 30 Dec 2019 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoRe: Revise sleb128 and uleb128 reader
Alan Modra [Sun, 29 Dec 2019 23:03:46 +0000 (09:33 +1030)]
Re: Revise sleb128 and uleb128 reader

A missing part of git commit cd30bcef4a685.

* od-macho.c: Include elfcomm.h.
(dump_dyld_info_rebase, dump_dyld_info_bind): Fix read_leb128 args.
(dump_dyld_info_export_1, dump_segment_split_info): Likewise.

4 years agoRe: Usage of unitialized heap in tic4x_print_cond
Alan Modra [Sun, 29 Dec 2019 22:49:25 +0000 (09:19 +1030)]
Re: Usage of unitialized heap in tic4x_print_cond

PR 25319
* tic4x-dis.c (tic4x_print_cond): Correct order of xcalloc args.

4 years agoFix setting breakpoints or stepping on line 65535
Bernd Edlinger [Sat, 23 Nov 2019 06:37:26 +0000 (07:37 +0100)]
Fix setting breakpoints or stepping on line 65535

This removes code that was present from the very first git revisison
7b4ac7e1ed2c4616bce56d1760807798be87ac9e from 1988.  It was in the
gdb/dbxread.c at the time (and makes more sense for dbx line info format
since line numbers are 16-bit entities in that debug format and debugging
files with more than 65535 lines would not work anyway) but moved from
there to gdb/buildsym.c which is used for dwarf line info as well, and
excluding an arbitrary line number does certainly not make sense nowadays.

Add a test case for line 65535

gdb:
2019-12-29  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* buildsym.c (buildsym_compunit::record_line): Do no longer ignore
line 65535.

gdb/testsuite:
2019-12-29  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* gdb.base/line65535.exp: New file.
* gdb.base/line65535.c: New file.

4 years agoubsan: sparc: left shift cannot be represented in type 'int'
Alan Modra [Sun, 29 Dec 2019 02:27:42 +0000 (12:57 +1030)]
ubsan: sparc: left shift cannot be represented in type 'int'

* sparc-dis.c (SEX): Don't use left and right shift to sign extend.
(compare_opcodes): Avoid signed shift left overflow.
(print_insn_sparc): Likewise.

4 years agoUsage of unitialized heap in tic4x_print_cond
Alan Modra [Sun, 29 Dec 2019 02:26:29 +0000 (12:56 +1030)]
Usage of unitialized heap in tic4x_print_cond

PR 25319
* tic4x-dis.c (tic4x_print_cond): Init all of condtable.

4 years agoubsan: alpha-vms: shift exponent is too large
Alan Modra [Sun, 29 Dec 2019 02:26:04 +0000 (12:56 +1030)]
ubsan: alpha-vms: shift exponent is too large

* vms-alpha.c (_bfd_vms_slurp_egsd): Make base_addr a bfd_vma.
Limit alignment power.  Correct and simplify alignment expression.
(evax_bfd_print_relocation_records): Avoid signed shift left.

4 years agoasan: alpha-vms: memory leaks
Alan Modra [Sun, 29 Dec 2019 02:25:34 +0000 (12:55 +1030)]
asan: alpha-vms: memory leaks

* vms-misc.c (_bfd_vms_save_sized_string): Add abfd param, make
size a size_t.  Use bfd_alloc rather than bfd_malloc.
(_bfd_vms_save_counted_string): Similarly.
* vms.h (_bfd_vms_save_sized_string): Update prototype.
(_bfd_vms_save_counted_string): Likewise.
* vms-alpha.c (_bfd_vms_slurp_ehdr): Adjust
_bfd_vms_save_counted_string and bfd_vms_save_sized_string calls.
(_bfd_vms_slurp_egsd, parse_module): Likewise.
(_bfd_vms_slurp_eisd): Likewise.  Check return status.
(alpha_vms_bfd_link_hash_table_free): New function.
(alpha_vms_bfd_link_hash_table_create): Arrange to call it.
(vms_close_and_cleanup): Free more memory.  Don't release tdata.

4 years agocoff_close_and_cleanup
Alan Modra [Sun, 29 Dec 2019 02:25:20 +0000 (12:55 +1030)]
coff_close_and_cleanup

Fixes leaks in _bfd_coff_get_external_symbols and
_bfd_coff_read_string_table.

* coffcode.h (coff_close_and_cleanup): Redefine to..
* coffgen.c (_bfd_coff_close_and_cleanup): ..this.  New function.
* libcoff-in.h (_bfd_coff_close_and_cleanup): Declare.
* libcoff.h: Regenerate.

4 years agoPR15350, Fix compressed debug sections for PE targets
Alan Modra [Sun, 29 Dec 2019 02:11:12 +0000 (12:41 +1030)]
PR15350, Fix compressed debug sections for PE targets

PR 15350
* bfd.c (bfd_update_compression_header): Write zlib header for
formats other than ELF too.