Commit Graph

91718 Commits

Author SHA1 Message Date
Nick Clifton 1948519604 Prevent an infinite loop in the DWARF parsing code when encountering a CU structure with a small negative size.
PR 22219
	* dwarf.c (process_debug_info): Add a check for a negative
	cu_length field.
2017-09-27 10:42:51 +01:00
Alan Modra 6bd6a03d69 PR22216, infinite loop in readelf process_symbol_table
This should make readelf bombproof given a fuzzed DT_HASH.  Also
removes a bogus check that would have resulted in wrong histograms.

	PR 22216
	* readelf.c (process_symbol_table): Check that DT_HASH symbol
	chains are only visited once, and report an error if not.  Display
	invalid symbol index if chain is out of range.  Use the same logic
	when calculating histograms rather than the PR 17531 fix.  Delete
	bogus check that chained index is less than number of buckets.
2017-09-27 15:54:18 +09:30
Kuan-Lin Chen cd28e7aaf3 nds32: Fix a tautological comparison. 2017-09-27 13:07:19 +08:00
GDB Administrator 25c7861f70 Automatic date update in version.in 2017-09-27 00:00:23 +00:00
H.J. Lu ac69a0d75b x86-64: Don't pass output_bfd to info->callbacks->minfo
Don't pass output_bfd to info->callbacks->minfo when dumping local IFUNC
functions in the map file.

	PR ld/22199
	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Don't pass
	output_bfd to info->callbacks->minfo.
2017-09-26 14:41:22 -07:00
Walfred Tedeschi 5230b05a94 dwarf2read: Restrict ICC workaround to ICC<14
GDB has a workaround for DWARF output by ICC, related to missing
DW_AT_declaration on incomplete types.  The bug was fixed in ICC 14,
so this commit adjusts GDB accordingly.

For the version check, this adds a new parser function for the ICC
producer string.  While at it, it also adds unit tests for the
producer parsing covering the new function and preexisting parsers.

gdb/ChangeLog:
2017-09-26  Walfred Tedeschi  <walfred.tedeschi@intel.com>
	    Pedro Alves <palves@redhat.com>

	* dwarf2read.c (dwarf2_cu): Remove field producer_is_icc and add
	producer_is_icc_lt_14.
	(producer_is_icc_lt_14): New function.
	(check_producer): Add code for checking version of ICC.
	(producer_is_icc): Move to producer.c.
	(read_structure_type): Restrict ICC workaround to ICC<14.
	* producer.c: Include selftest.h.
	(producer_is_icc, producer_parsing_tests, _initialize_producer):
	New functions.
	* producer.h (producer_is_icc): New declaration.
2017-09-26 18:32:00 +01:00
Walfred Tedeschi b32b108aba Move GDB producer parsing routines to a separate file
gdb/ChangeLog:
2017-09-26  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* Makefile.in (SFILES): Add producer.c.
	(COMMON_OBS): Add producer.o
	* amd64-tdep.c (producer.h): Add new include.
	* dwarf2read.c (producer.h): Add new include.
	* producer.c: New file.
	* producer.h: New file.
	* utils.c (producer_is_gcc, producer_is_gcc_ge_4): Move to
	producer.c.
	* utils.h (producer_is_gcc, producer_is_gcc_ge_4): Move to
	producer.h.
2017-09-26 18:26:41 +01:00
Sergio Durigan Junior 75352e283f Use "switch_to_thread" more thoroughly on gdbserver
This is a technical debt that I left when I ported "switch_to_thread"
to gdbserver.  It's a simple patch that converts occurences of:

  current_thread = find_thread_ptid (ptid);

to:

  switch_to_thread (ptid);

This patch also converts a simple "if" to a "gdb_assert" on
gdbserver's version of "switch_to_thread":

  gdb_assert (ptid != minus_one_ptid);

This change makes the code more similar to what GDB already does.

Regtested on BuildBot.

gdb/gdbserver/ChangeLog:
2017-09-26  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdbthread.h: Include "common-gdbthread.h".
	* inferiors.c (switch_to_thread): Use "gdb_assert" instead of
	"if" when validating the ptid.
	* remote-utils.c: Include "gdbthread.h".
	(prepare_resume_reply): Use "switch_to_thread".
	* target.c (done_accessing_memory): Likewise.
2017-09-26 12:50:25 -04:00
Matthias Klose 5007d765ae Allow linking GDB with ncursesw
Triggered by https://launchpad.net/bugs/1275210, to be able to cope
with UTF-8 characters in gdbtui.

Reference:
  https://sourceware.org/ml/gdb-patches/2017-09/msg00356.html

gdb/ChangeLog:
2017-09-26  Matthias Klose  <doko@ubuntu.com>

	* configure.ac: Search ncursesw before ncurses.
	Check ncursesw/ncurses.h before ncurses/ncurses.h.
	* gdb_curses.h: Include <ncursesw/ncurses.h>
	* config.in, configure: Regenerate.
2017-09-26 16:23:19 +01:00
Nick Clifton 262c0a877f Fix an assertion failure when parsing a fuzzed x86_64 ELF binary.
PR 22172
	* elf64-x86-64.c (elf_x86_64_info_to_howto): Do not trigger an
	assertion failure if elf_x86_64_rtype_to_howto has already issued
	an error message.
2017-09-26 16:03:10 +01:00
Cary Coutant 00956d3a8a Fix incorrect register mask.
PR gold/22213
	* sparc.cc (Target_sparc): Fix incorrect register mask.
2017-09-26 07:33:04 -07:00
Alan Modra 33e0a9a056 Tidy reading data in read_formatted_entries
Using read_attribute_value accomplishes two things: It checks for
unexpected formats, and ensures the buffer pointer always increments.

	PR 22210
	* dwarf2.c (read_formatted_entries): Use read_attribute_value to
	read data.
2017-09-26 23:23:44 +09:30
Nick Clifton 30d0157a2a Avoid needless resource usage when processing a corrupt DWARF directory or file name table.
PR 22210
	* dwarf2.c (read_formatted_entries): Fail early if we know that
	the loop parsing data entries will overflow the end of the
	section.
2017-09-26 14:37:47 +01:00
Rainer Orth 281c444773 Remove support for Solaris < 10 (PR gdb/22185)
Given that GCC has obsoleted/removed support for Solaris 9 in GCC 4.9/5 in 2013:

    https://gcc.gnu.org/gcc-4.9/changes.html
    https://gcc.gnu.org/ml/gcc-patches/2013-05/msg00728.html

and the last gdb version that can be compiled with gcc 4.9 is 7.12.1 only when
configured with --disable-build-with-cxx, it's time to obsolete/remove support
for Solaris < 10.

This patch does this, simplifying configure.nat along the way (only a single
sol2 configuration with variants for i386 and sparc).

Some configure checks for older Solaris versions can go, too, and the check
for libthread_db.so.1 removed:

* Since Solaris 10, dlopen has moved to libc and libdl.so is just a
  filter on ld.so.1, so no need to check.

* $RDYNAMIC is already handled above (and is a no-op with Solaris ld
  anyway).

Both proc-service.c and sol-thread.c lose support for (Solaris-only)
PROC_SERVICE_IS_OLD.

The attached revised patch has been tested on sparcv9-sun-solaris2.10,
sparcv9-sun-solaris2.11.4, amd64-pc-solaris2.10, amd64-pc-solaris2.11.4,
and x86_64-pc-linux-gnu.

I've also started an i386-pc-solaris2.9 build to check that it really
stops as expected.

	PR gdb/22185
	* configure.host <*-*-solaris2.[01], *-*-solaris2.[2-9]*>: Mark as
	obsolete.
	Use gdb_host sol2 for i[34567]86-*-solaris2*, x86_64-*-solaris2*.
	Remove i386sol2 support.
	* configure.nat <i386sol2>: Remove.
	<sol2-64>: Fold into ...
	<sol2>: ... this.
	Move common settings to default section.
	Add sol-thread.o.
	* configure.tgt <i[34567]86-*-solaris2.1[0-9]*,
	x86_64-*-solaris2.1[0-9]*>: Rename to ...
	<i[34567]86-*-solaris2*, x86_64-*-solaris2*>: ... this.
	<i[34567]86-*-solaris*>: Remove.
	<sparc-*-solaris2.[0-6], sparc-*-solaris2.[0-6].*>: Remove.

	* configure.ac: Remove wctype in libw check.
	(_MSE_INT_H): Don't define on Solaris 7-9.
	<solaris*>: Remove libthread_db.so.1 check.
	* configure: Regenerate.
	* config.in: Regenerate.

	* proc-service.c: Remove PROC_SERVICE_IS_OLD handling.
	(gdb_ps_prochandle_t, gdb_ps_read_buf_t, gdb_ps_write_buf_t)
	(gdb_ps_size_t): Remove.
	Use base types in users.
	* sol-thread.c: Likewise, also for gdb_ps_addr_t.

	* NEWS (Changes since GDB 8.0): Document Solaris 2.0-9 removal.
2017-09-26 15:19:10 +02:00
Rainer Orth 39b06c208f Fix gdb 8.1 Solaris/SPARC compilation (PR build/22206)
When testing my Solaris < 10 removal patch on Solaris/SPARC, I found
that gdb mainline is currently broken there due to the recent SPARC M7
ADI patches:

/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:1876:0: error: "PSR_ICC" redefined [-Werror]
 #define PSR_ICC  0x00f00000
 ^
In file included from /usr/include/v7/sys/privregs.h:24:0,
                 from /usr/include/sys/regset.h:420,
                 from /usr/include/sys/ucontext.h:21,
                 from /usr/include/sys/signal.h:231,
                 from /usr/include/sys/procset.h:23,
                 from /usr/include/sys/wait.h:25,
                 from /usr/include/stdlib.h:21,
                 from build-gnulib/import/stdlib.h:36,
                 from /vol/src/gnu/gdb/gdb/local/gdb/common/common-defs.h:53,
                 from /vol/src/gnu/gdb/gdb/local/gdb/defs.h:28,
                 from /vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:20:
/usr/include/v7/sys/psr.h:35:0: note: this is the location of the previous definition
 #define PSR_ICC  0x00F00000 /* integer condition codes */
 ^
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:1878:0: error: "PSR_IMPL" redefined [-Werror]
 #define PSR_IMPL 0xf0000000
 ^
In file included from /usr/include/v7/sys/privregs.h:24:0,
                 from /usr/include/sys/regset.h:420,
                 from /usr/include/sys/ucontext.h:21,
                 from /usr/include/sys/signal.h:231,
                 from /usr/include/sys/procset.h:23,
                 from /usr/include/sys/wait.h:25,
                 from /usr/include/stdlib.h:21,
                 from build-gnulib/import/stdlib.h:36,
                 from /vol/src/gnu/gdb/gdb/local/gdb/common/common-defs.h:53,
                 from /vol/src/gnu/gdb/gdb/local/gdb/defs.h:28,
                 from /vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:20:
/usr/include/v7/sys/psr.h:41:0: note: this is the location of the previous definition
 #define PSR_IMPL 0xF0000000 /* implementation */
 ^

Comparing Solaris 11.4 <v7/sys/psr.h> and sparc64-tdep.c, there are more
inconsistencies:

<v7/sys/psr.h>:

#define	PSR_S		0x00000080	/* supervisor mode */
#define	PSR_ICC		0x00F00000	/* integer condition codes */
#define	PSR_VER		0x0F000000	/* mask version */
#define	PSR_IMPL	0xF0000000	/* implementation */
#define	PSR_RSV		0x000FC000	/* reserved */

sparc64-tdep.c:

#define PSR_S		0x00000080
#define PSR_ICC		0x00f00000
#define PSR_VERS	0x0f000000
#define PSR_IMPL	0xf0000000
#define PSR_V8PLUS	0xff000000
#define PSR_XCC		0x000f0000

Apart from the capitalization differences that trip g++, the names
differ (PSR_VER vs. PSR_VERS), PSR_XCC is included in Solaris' PSR_RSV,
and there's no PSR_V8PLUS on Solaris either.

/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c: In function `int adi_tag_fd()':
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:296:63: error: format `%d' expects argument of type `int', but argument 4 has type `pid_t {aka long int}' [-Werror=format=]
   snprintf (cl_name, sizeof(cl_name), "/proc/%d/adi/tags", pid);
                                                               ^
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c: In function `bool adi_is_addr_mapped(CORE_ADDR, std::size_t)':
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:314:64: error: format `%d' expects argument of type `int', but argument 4 has type `pid_t {aka long int}' [-Werror=format=]
   snprintf (filename, sizeof filename, "/proc/%d/adi/maps", pid);
                                                                ^

You cannot always print a pid_t, which can be either int or long on
Solaris, as an int.

Obviously, the ADI patch which modifies code shared between all SPARC
targets, hasn't been tested on anything but Linux/SPARC.

The patch below includes the minimal fixes necessary to unbreak the
Solaris/SPARC build.

However, as detailed in the PR, there's more breakage here: apart from
not bothering to implement ADI support on Solaris, the code contains
several more changes to shared/common SPARC code that are simply wrong
on anything but Linux/SPARC.

The patch was tested on sparcv9-sun-solaris2.10 and
sparcv9-sun-solaris2.11.4 (build and gdb/gdb gdb/gdb smoke test only).

	PR build/22206
	* sparc64-tdep.c (adi_tag_fd): Print pid as long.
	(adi_is_addr_mapped): Likewise.
	(PSR_ICC): Don't redefine.
	(PSR_IMPL): Likewise.
2017-09-26 14:58:53 +02:00
Alan Modra 1b86808a86 PR22209, invalid memory read in find_abstract_instance_name
This patch adds bounds checking for DW_FORM_ref_addr die refs, and
calculates them relative to the first .debug_info section.  See the
big comment for why calculating relative to the current .debug_info
section was wrong for relocatable object files.

	PR 22209
	* dwarf2.c (struct comp_unit): Delete sec_info_ptr field.
	(find_abstract_instance_name): Calculate DW_FORM_ref_addr relative
	to stash->info_ptr_memory, and check die_ref is within that memory.
	Set info_ptr_end correctly when another CU is refd.  Check die_ref
	for DW_FORM_ref4 etc. is within CU.
2017-09-26 22:12:40 +09:30
Nick Clifton 5c1c468d0e Fix address violations when parsing a corrupt DWARF linenumber table.
PR 22154
	* dwarf.c (get_line_filename_and_dirname): Add extra checks for
	buffer overruns.
2017-09-26 12:14:42 +01:00
Maciej W. Rozycki 28d810f7ff LD/testsuite: Fix undefined symbol tests for MIPS and S+core targets
Fix commit 647d4de92e ("Test undefined symbols in shared libraries")
and remove "undefined symbols in shared lib (dyn reloc)" test failures
for MIPS and S+core targets.

This test assumes 3 dynamic relocation entries, however the respective
psABIs define an extra single dummy *_NONE relocation at the beginning
of the dynamic relocation table, which results in test output like the
following for MIPS:

Relocation section '.rel.dyn' at offset 0x33c contains 4 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
00000000  00000000 R_MIPS_NONE
00010364  00000903 R_MIPS_REL32      00000000   undef_pfun
00010360  00000a03 R_MIPS_REL32      00000000   undef_data
00010368  00000b03 R_MIPS_REL32      00000000   undef_notype

and S+core:

Relocation section '.rel.dyn' at offset 0x274 contains 4 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
00000000  00000000 R_SCORE_NONE
5ffe0464  00000e12 R_SCORE_REL32     00000000   undef_notype
5ffe045c  00000f12 R_SCORE_REL32     00000000   undef_data
5ffe0460  00001012 R_SCORE_REL32     00000000   undef_pfun

targets respectively, and also n64 MIPS targets pad relocation triplets
they use with extra *_NONE relocations, resulting in output like this:

Relocation section '.rel.dyn' at offset 0x4c0 contains 4 entries:
  Offset          Info           Type           Sym. Value    Sym. Name
000000000000  000000000000 R_MIPS_NONE
                    Type2: R_MIPS_NONE
                    Type3: R_MIPS_NONE
000000010508  000900001203 R_MIPS_REL32      0000000000000000 undef_pfun
                    Type2: R_MIPS_64
                    Type3: R_MIPS_NONE
000000010500  000a00001203 R_MIPS_REL32      0000000000000000 undef_data
                    Type2: R_MIPS_64
                    Type3: R_MIPS_NONE
000000010510  000b00001203 R_MIPS_REL32      0000000000000000 undef_notype
                    Type2: R_MIPS_64
                    Type3: R_MIPS_NONE

Expect the right number of *_NONE relocations then, and adjust the total
number of relocations expected accordingly.

	ld/
	* testsuite/ld-undefined/undefined.exp: Correct the dyn reloc
	test for MIPS and S+core targets.
2017-09-26 12:09:50 +01:00
Nick Clifton 58a0b82744 Allow the macw and macl instructions to be used on CPUs that have emacs support.
From PR 22123:

  The common opcodes of emac and mac seem to be only implemented for mac.

  To reproduce:

    echo "macw %d3l,%a0l" > /tmp/dummy.S
    m68k-unknown-elf-as -m5208  /tmp/dummy.S

  Outputs something like:
    /tmp/dummy.S: Assembler messages:
    /tmp/dummy.S:1: Error: operands mismatch -- statement `macw %d3l,%a0l' ignored

  This behavior occurs only if the CPU supports only emac but not explicitly mac (but emac is a superset of mac).
2017-09-26 10:36:23 +01:00
Nick Clifton 78b2179a8e Add README file for creating binutils releases 2017-09-26 10:07:23 +01:00
Thomas Preud'homme df8899e5c8 Fix FAILs in compare-sections.exp
compare-sections.exp has two cases that are not handled appropriately:
1) value read with msb set
2) error while patching that section

This patch adapts the "get value of read-only section" test to print
the value as an unsigned integer to fix 1) and test for the error
message to not set the written variable if read-only section cannot
be written to so as to solve 2).

2017-09-26  Thomas Preud'homme  <thomas.preudhomme@arm.com>
	    Pedro Alves  <palves@redhat.com>

gdb/testsuite/
	* gdb.base/compare-sections.exp (get value of read-only section): Read
	as unsigned value.
	(corrupt read-only section): Likewise and don't set written if patching
	failed.
2017-09-26 09:57:18 +01:00
Alan Modra 66cfc0fd0d PR21732, String-concatenated message can not be translated
Preprocessor tokens like DWARF_VMA_FMT and BFD_VMA_FMT are not
understood by gettext, and cause the translation string to be
truncated.  Even if it were not truncated, we wouldn't want a value
that changes depending on host or configure options to be put in a
translation string.

	PR 21732
	* dwarf.c (READ_ULEB): Don't use DWARF_VMA_FMT in translated string.
	(READ_SLEB): Likewise.
	* readelf.c (bfd_vmatoa): New function.
	(get_data, get_dynamic_data): Use it for printing error messages.
2017-09-26 13:39:35 +09:30
Tom Tromey 6c3e20f177 Remove the last cleanup from regcache.c
This removes the last cleanup from regcache.c by changing one function
to use std::string.

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

	* regcache.c (regcache::dump): Use string_printf.
2017-09-25 19:54:09 -06:00
Tom Tromey b292235f66 Remove make_cleanup_regcache_invalidate
This removes make_cleanup_regcache_invalidate in favor of a simple
RAII class that handles register invalidation.

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

	* regcache.c (class regcache_invalidator): New.
	(struct register_to_invalidate): Remove.
	(make_cleanup_regcache_invalidate): Remove.
	(regcache::raw_write): Use regcache_invalidator.
2017-09-25 19:54:08 -06:00
Tom Tromey 9ac86b52da Remove make_cleanup_regcache_xfree
This removes make_cleanup_regcache_xfree in favor of using
std::unique_ptr as the return type of frame_save_as_regcache.

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

	* spu-tdep.c (spu2ppu_sniffer): Update.
	* regcache.h (make_cleanup_regcache_xfree): Don't declare.
	* regcache.c (do_regcache_xfree, make_cleanup_regcache_xfree):
	Remove.
	* ppc-linux-tdep.c (ppu2spu_sniffer): Update.
	* mi/mi-main.c (mi_cmd_data_list_changed_registers): Update.
	* frame.h (frame_save_as_regcache): Return std::unique_ptr.
	* frame.c (frame_save_as_regcache): Return std::unique_ptr.
	(frame_pop): Update.
2017-09-25 19:54:07 -06:00
Tom Tromey c0e383c638 Remove regcache_xfree
This removes regcache_xfree in favor of plain "delete".

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

	* spu-tdep.c (spu2ppu_dealloc_cache): Use delete.
	* regcache.h (regcache_xfree): Don't declare.
	* regcache.c (regcache_xfree): Remove.
	(do_regcache_xfree): Use delete.
	* ppc-linux-tdep.c (ppu2spu_dealloc_cache): Use delete.
	* linux-fork.c (free_fork): Use delete.
	(fork_save_infrun_state): Likewise.
	* jit.c (jit_dealloc_cache): Use delete.
	* infrun.c (discard_infcall_suspend_state): Use delete.
2017-09-25 19:54:06 -06:00
Tom Tromey 791199cc75 Remove regcache_xmalloc
This patch removes regcache_xmalloc in favor of plain "new".

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

	* regcache.h (regcache_xmalloc): Don't declare.
	(regcache_raw_set_cached_value): Update comment.
	* regcache.c (regcache_xmalloc): Remove.
	* ppc-linux-tdep.c (ppu2spu_sniffer): Use new.
	* jit.c (jit_frame_sniffer): Use new.
	* frame.c (frame_save_as_regcache): Use new.
2017-09-25 19:54:05 -06:00
Alan Modra a54018b72d PR22205, .debug_line file table NULL filename
The PR22200 fuzzer testcase found one way to put NULLs into .debug_line
file tables.  PR22205 finds another.  This patch gives up on trying to
prevent NULL files in the file table and instead just copes with them.
Arguably, this is better than giving up and showing no info from
.debug_line.  I've also fixed a case where the fairly recent DWARF5
support in handling broken DWARG could result in uninitialized memory
reads, and made a small tidy.

	PR 22205
	* dwarf2.c (concat_filename): Return "<unknown>" on NULL filename.
	(read_formatted_entries): Init "fe".
	(decode_line_info <DW_LNE_define_file>): Use line_info_add_file_name.
2017-09-26 09:38:26 +09:30
Alan Modra e338894dc2 PR22204, Lack of DW_LNE_end_sequence causes "infinite" loop
PR 22204
	* dwarf2.c (decode_line_info): Ensure line_ptr stays within
	bounds in inner loop.
2017-09-26 09:36:50 +09:30
GDB Administrator 898f57a89f Automatic date update in version.in 2017-09-26 00:00:21 +00:00
H.J. Lu 8dba52b604 Free memory returned from bfd_get_synthetic_symtab
PR binutils/22203
	* nm.c (display_rel_file): Free memory returned from
	bfd_get_synthetic_symtab.
2017-09-25 14:07:01 -07:00
Andreas Arnez 289e23aa03 S390: Document guarded-storage register support
This documents the newly added support for guarded-storage registers on
IBM z.

gdb/ChangeLog:

	* NEWS: Advertise support for guarded-storage registers on IBM z.

gdb/doc/ChangeLog:

	* gdb.texinfo (S/390 and System z Features): Document the new
	features org.gnu.gdb.s390.gs and org.gnu.gdb.s390.gsbc.
2017-09-25 16:02:24 +02:00
Andreas Arnez ad3396348e S390: Add guarded-storage register support to gdbserver
Enable gdbserver to deal with the new guarded-storage register sets.

gdb/gdbserver/ChangeLog:

	* configure.srv (s390*-*-linux*): Add s390-gs-linux64.o and
	s390x-gs-linux64.o to srv_regobj.  Add s390-gs-linux64.xml,
	s390x-gs-linux64.xml, s390-gs.xml, and s390-gsbc.xml to
	srv_xmlfiles.  Add s390-gs-linux64-ipa.o and
	s390x-gs-linux64-ipa.o to ipa_obj.
	* linux-s390-low.c (HWCAP_S390_GS): New define.
	(s390_fill_gs, s390_store_gs, s390_fill_gsbc, s390_store_gsbc):
	New functions.
	(s390_regsets): Add regsets for NT_S390_GS_CB and NT_S390_GS_BC.
	(s390_arch_setup): Check for guarded-storage support and choose
	appropriate tdesc.
	(initialize_low_arch): Invoke init_registers_s390_gs_linux64 and
	init_registers_s390x_gs_linux64.
	* linux-s390-tdesc.h (enum s390_linux_tdesc) <S390_TDESC_GS>: New
	enum value.
	(init_registers_s390x_gs_linux64, tdesc_s390x_gs_linux64)
	(init_registers_s390_gs_linux64, tdesc_s390_gs_linux64): Declare.
2017-09-25 16:02:23 +02:00
Andreas Arnez 1b63490c91 S390: Add guarded-storage register support to GDB
Recognize targets with the new guarded-storage feature and then present
the guarded-storage registers and the Linux-specific guarded-storage
broadcast control block appropriately.

gdb/ChangeLog:

	* s390-linux-nat.c (have_regset_gs): New static variable.
	(s390_linux_fetch_inferior_registers): Handle guarded-storage
	control block and guarded-storage broadcast control regsets.
	(s390_read_description): Detect whether the target has
	guarded-storage support, return appropriate tdesc.
	* s390-linux-tdep.c (features/s390-gs-linux64.c): New include.
	(features/s390x-gs-linux64.c): Likewise.
	(struct gdbarch_tdep) <have_gs>: New field.
	(s390_regmap_gs, s390_regmap_gsbc, s390_gs_regset)
	(s390_gsbc_regset): New variables.
	(s390_iterate_over_regset_sections): Iterate over s390_gs_regset
	and s390_gsbc_regset, if applicable.
	(s390_core_read_description): Check whether core file was from a
	target with guarded-storage support; include appropriate regsets.
	(s390_gdbarch_init): Add registers for guarded-storage support.
	(_initialize_s390_tdep): Initialize new target descriptions that
	include registers for guarded-storage support.
	* s390-linux-tdep.h (HWCAP_S390_GS, S390_GSD_REGNUM)
	(S390_GSSM_REGNUM, S390_GSEPLA_REGNUM)
	(S390_BC_GSD_REGNUM, S390_BC_GSSM_REGNUM): New defines.
	(S390_NUM_REGS): Adjust macro definition.
	(s390_gs_regset, s390_gsbc_regset, tdesc_s390_gs_linux64)
	(tdesc_s390x_gs_linux64): New declarations.
2017-09-25 16:02:23 +02:00
Andreas Arnez 96235dc1ac S390: Add guarded-storage register definitions and tdescs
Newer Linux kernel versions offer two new register sets in support of the
z/Architecture's guarded storage facility.  This patch adds XML
descriptions and the respective autogenerated .c and .dat files for
s390/s390x targets with this feature.

gdb/ChangeLog:

	* features/s390-gs-linux64.xml: New file.
	* features/s390-gs.xml: New file.
	* features/s390-gsbc.xml: New file.
	* features/s390x-gs-linux64.xml: New file.
	* features/Makefile (WHICH): Add s390-gs-linux64 and
	s390x-gs-linux64.
	(s390-gs-linux64-expedite, s390x-gs-linux64-expedite): New macros.
	(XMLTOC): Add s390-gs-linux64.xml and s390x-linux64.xml.
	* features/s390-gs-linux64.c: New generated file.
	* features/s390x-gs-linux64.c: New file.
	* regformats/s390-gs-linux64.dat: New file.
	* regformats/s390x-gs-linux64.dat: New file.
2017-09-25 16:02:23 +02:00
Alan Modra 1da5c9a485 PR22202, buffer overflow in parse_die
There was a complete lack of sanity checking in dwarf1.c

	PR 22202
	* dwarf1.c (parse_die): Sanity check pointer against section limit
	before dereferencing.
	(parse_line_table): Likewise.
2017-09-25 22:01:47 +09:30
Alan Modra 11855d8a1f PR22201, DW_AT_name with out of bounds reference
DW_AT_name ought to always have a string value.

	PR 22201
	* dwarf2.c (scan_unit_for_symbols): Ignore DW_AT_name unless it
	has string form.
	(parse_comp_unit): Likewise.
2017-09-25 22:01:47 +09:30
Alan Modra c361faae8d PR22200, DWARF5 .debug_line sanity check
The format_count entry can't be zero unless the count is also zero.

	PR 22200
	* dwarf2.c (read_formatted_entries): Error on format_count zero.
2017-09-25 22:01:47 +09:30
Sergio Durigan Junior 57a024f465 Initialize 'imm' on opcodes/aarch64-opc.c:expand_fp_imm (and fix breakage on mingw)
Hi,

While compiling GDB using a mingw compiler from Fedora 26:

  ../gdb/configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \
    --disable-binutils --disable-ld --disable-gold --disable-gas --disable-sim \
    --disable-gprof  --enable-targets=all

I stumbled upon a simple occurrence of -Werror=maybe-uninitialized:

  ../../gdb/opcodes/aarch64-opc.c: In function 'expand_fp_imm':
  ../../gdb/opcodes/aarch64-opc.c:2880:10: error: 'imm' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     return imm;
	    ^~~

It is the compiler's fault, because this function always assigns to
'imm' if the necessary conditions are met, and it calls "assert (0)"
otherwise, but I thought it'd be clearer to have 'imm' explicitly set
to zero anyway.

opcodes/ChangeLog:
2017-09-21  Sergio Durigan Junior  <sergiodj@redhat.com>

	* aarch64-opc.c (expand_fp_imm): Initialize 'imm'.
2017-09-25 01:46:23 -04:00
GDB Administrator 5b3fd0aac2 Automatic date update in version.in 2017-09-25 00:00:24 +00:00
Alan Modra 52b36c51e5 PR22197, buffer overflow in bfd_get_debug_link_info_1
PR 22197
	* opncls.c (bfd_get_debug_link_info_1): Properly check that crc is
	within section bounds.
2017-09-24 21:40:58 +09:30
Alan Modra a26a013f22 PR22191, memory leak in dwarf2.c
table->sequences is a linked list before it is replaced by a bfd_alloc
array in sort_line_sequences.

	PR 22191
	* dwarf2.c (decode_line_info): Properly free line sequences on error.
2017-09-24 21:01:30 +09:30
Alan Modra 52a93b95ec PR22187, infinite loop in find_abstract_instance_name
This patch prevents the simple case of infinite recursion in
find_abstract_instance_name by ensuring that the attributes being
processed are not the same as the previous call.

The patch also does a little cleanup, and leaves in place some changes
to the nested_funcs array that I made when I wrongly thought looping
might occur in scan_unit_for_symbols.

	PR 22187
	* dwarf2.c (find_abstract_instance_name): Add orig_info_ptr and
	pname param.  Return status.  Make name const.  Don't abort,
	return an error.  Formatting.  Exit if current info_ptr matches
	orig_info_ptr.  Update callers.
	(scan_unit_for_symbols): Start at nesting_level of zero.  Make
	nested_funcs an array of structs for extensibility.  Formatting.
2017-09-24 16:17:19 +09:30
Alan Modra d8010d3e75 PR22186, divide-by-zero in decode_line_info
PR 22186
	* dwarf2.c (decode_line_info): Fail on lh.line_range of zero
	rather than dividing by zero.
2017-09-24 16:17:19 +09:30
Alan Modra 515f23e63c PR22169, heap-based buffer overflow in read_1_byte
The .debug_line header length field doesn't include the length field
itself, ie. it's the size of the rest of .debug_line.

	PR 22169
	* dwarf2.c (decode_line_info): Correct .debug_line unit_length check.
2017-09-24 16:15:14 +09:30
Alan Modra 0d76029f92 PR22167, NULL pointer dereference in scan_unit_for_symbols
PR 22167
	* dwarf2.c (scan_unit_for_symbols): Check u.blk->data is non-NULL.
2017-09-24 14:35:33 +09:30
Alan Modra bd61e13549 PR22166, SHT_GNU_verneed memory allocation
The sanity check covers the previous minimim size, plus that the size
is at least enough for sh_info verneed entries.

Also, since we write all verneed fields or exit with an error, there
isn't any need to zero the memory allocated for verneed entries.

	PR 22166
	* elf.c (_bfd_elf_slurp_version_tables): Test sh_info on
	SHT_GNU_verneed section for sanity.  Don't zalloc memory for
	verref.
2017-09-24 14:34:57 +09:30
GDB Administrator 8d296e2d4d Automatic date update in version.in 2017-09-24 00:00:26 +00:00
Tom Tromey b4a7c69968 Removed unused declaration
An earlier patch of mine removed make_cleanup_override_quit_handler,
but neglected to remove the declaration.  This patch removes it.
Tested by rebuilding.  I'm committing this as obvious.

ChangeLog
2017-09-23  Tom Tromey  <tom@tromey.com>

	* defs.h (make_cleanup_override_quit_handler): Don't declare.
2017-09-23 14:13:12 -06:00
GDB Administrator 4102159923 Automatic date update in version.in 2017-09-23 00:00:27 +00:00