Commit Graph

92129 Commits

Author SHA1 Message Date
Pedro Alves 15763a09d4 Fix 'gdb.base/quit.exp hangs forever' if the test fails
The [wait -i $gdb_spawn_id] in the test is dangerous in the sense that
it won't be subject to timeout logic.  So if GDB fails quiting, this
testcase hangs forever, hanging the test run with it.  See:
  https://sourceware.org/ml/gdb-patches/2016-10/msg00728.html

Instead of 'wait'ing directly, use gdb_test_multiple and expect 'eof'.

Tested that the testcase no longer hangs by hacking the test to send
"info threads" instead of "quit".

Tested with
  --target_board={unix, native-gdbserver,native-extended-gdbserver}
and tested with
  --host_board=local-remote-host
as well.

gdb/testsuite/ChangeLog:
2017-10-20  Pedro Alves  <palves@redhat.com>

	* gdb.base/quit.exp: Use gdb_test_multiple and expect 'eof' before
	'wait -i'.  Use gdb_assert and remote_close.
2017-10-20 15:33:57 +01:00
Pedro Alves fcc8fb2f3d Fix gdb.gdb/ selftest tests when testing optimized GDB builds
After commit bf46927112 ("Eliminate catch_errors"), GCC started
inlining captured_command_loop in captured_main.  And setting a
breakpoint on captured_command_loop makes the inferior GDB stop in
captured_main, _after_ captured_command_loop's call to
interp_pre_command_loop, which prints the inferior GDB's prompt, has
already executed, confusing the gdb.gdb/ selftest tests:

  (gdb) FAIL: gdb.gdb/complaints.exp: run until breakpoint at captured_command_loop
  WARNING: Couldn't test self

Debugging GDB with GDB manually, we see:

  (top-gdb) b captured_command_loop
  Breakpoint 1 at 0x71ee60: file src/gdb/main.c, line 324.
  (top-gdb) r
  [....]
  (gdb)                  <<<<<< PROMPT HERE
  Thread 1 "gdb" hit Breakpoint 1, captured_main (data=<optimized out>) at src/gdb/main.c:1147
  1147              captured_command_loop ();
  (top-gdb)

Note the stop at 'captured_main', and the "PROMPT HERE" line.  That
prompt does not show up when debugging a non-optimized build of GDB.

Fix this by preventing inlining of captured_command_loop.

Ref: https://sourceware.org/ml/gdb-patches/2017-10/msg00522.html

gdb/ChangeLog:
2017-10-20  Pedro Alves  <palves@redhat.com>

	* main.c (captured_command_loop): Add attribute noinline.
2017-10-20 14:47:24 +01:00
Nick Clifton 808811a369 Improve handling of REPT pseudo op with a negative count.
PR 22324
	* read.c (s_rept): Use size_t type for count parameter.
	(do_repeat): Change type of count parameter to size_t.
	Issue an error is the count parameter is negative.
	(do_repeat_with_expression): Likewise.
	* read.h: Update prototypes for do_repeat and
	do_repeat_with_expression.
	* doc/as.texinfo (Rept): Document that a zero count is allowed but
	negative counts are not.
	* config/tc-rx.c (rx_rept): Use size_t type for count parameter.
	* config/tc-tic54x.c (tic54x_loop): Cast count parameter to size_t
	type.
	* testsuite/gas/macros/end.s: Add a test using a negative repeat
	count.
	* testsuite/gas/macros/end.l: Add expected error message.
2017-10-20 11:45:19 +01:00
Umesh Kalappa 36862fc052 Implement BE8 support for ARM.
gold/
	* arm.cc (Stub::do_fixed_endian_write):Far call stubs support for arm
	in the be8 mode.
	* testsuite/Makefile.am: New test cases.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/arm_farcall_arm_arm_be8.sh: New script for arm to arm far
	call stubs.
	* testsuite/arm_farcall_thumb_thumb_be8.sh: New script for thumb to
	thumb far call stubs.
2017-10-19 20:53:14 -07:00
Simon Marchi 4c2287b0bd Get rid of VEC(interp_factory_p)
Replace it with an std::vector.

gdb/ChangeLog:

	* interps.c (struct interp_factory): Add constructor.
	(interp_factory_p): Remove typedef.
	(DEF_VEC_P(interp_factory_p)): Remove.
	(interpreter_factories): Change type to std::vector.
	(interp_factory_register): Adjust.
	(interp_lookup): Adjust.
	(interpreter_completer): Adjust.
2017-10-19 22:07:15 -04:00
GDB Administrator b5f6e74092 Automatic date update in version.in 2017-10-20 00:00:28 +00:00
Tom Tromey 3d415c26ba Remove cleanups from break-catch-syscall.c
This removes the remaining cleanups from break-catch-syscall.c by
storing temporary strings in a vector.

ChangeLog
2017-10-19  Tom Tromey  <tom@tromey.com>

	* break-catch-syscall.c (catch_syscall_completer): Use
	std::string, gdb::unique_xmalloc_ptr.
2017-10-19 15:58:43 -06:00
Tom Tromey 395423c418 Remove cleanup from call_function_by_hand_dummy
This changes call_function_by_hand_dummy to use std::string, removing
a cleanup.

ChangeLog
2017-10-19  Tom Tromey  <tom@tromey.com>

	* infcall.c (call_function_by_hand_dummy): Use std::string.
2017-10-19 15:58:12 -06:00
Tom Tromey 54f70bc145 Remove cleanups from prepare_execute_command
This changes prepare_execute_command to return a scoped_value_mark
rather than a cleanup.

ChangeLog
2017-10-19  Tom Tromey  <tom@tromey.com>

	* mi/mi-main.c (mi_cmd_execute): Update.
	* top.h (prepare_execute_command): Return scoped_value_mark.
	* value.h (class scoped_value_mark): Use DISABLE_COPY_AND_ASSIGN.
	Add move constructor.
	* top.c (prepare_execute_command): Return scoped_value_mark.
	(execute_command): Update.
2017-10-19 15:58:11 -06:00
Andrew Burgess 49a4ce2eae gdb: Remove hard-coded line number from test
Removes the use of a hard-coded line number from a test.

gdb/testsuite/ChangeLog:

	* gdb.linespec/ls-errs.exp (do_test): Update comment, use line
	number from variable rather than hard-coded.
2017-10-19 20:50:42 +01:00
Pedro Alves 63929e843d Fix build breakage in gdb/xml-support.c
The buildbots are showing that the previous change to
xml_fetch_content_from_file causes __wur warnings/errors:

  ../../binutils-gdb/gdb/xml-support.c: In function gdb::unique_xmalloc_ptr<char> xml_fetch_content_from_file(const char*, void*):
  ../../binutils-gdb/gdb/xml-support.c:1028:43: error: ignoring return value of size_t fread(void*, size_t, size_t, FILE*), declared with attribute warn_unused_result [-Werror=unused-result]
     fread (text.get (), 1, len, file.get ());
					     ^

This commit fixes it.

gdb/ChangeLog:
2017-10-19  Pedro Alves  <palves@redhat.com>

	* xml-support.c (xml_fetch_content_from_file): Check fread's
	return.
2017-10-19 18:12:03 +01:00
Palmer Dabbelt 9d06997adb RISC-V: Relax RISCV_PCREL_* to RISCV_GPREL_*
In the medany code model the compiler generates PCREL_HI20+PCREL_LO12
relocation pairs against local symbols because HI20+LO12 relocations
can't reach high addresses.  We relax HI20+LO12 pairs to GPREL
relocations when possible, which is an important optimization for
Dhrystone.  Without this commit we are unable to relax
PCREL_HI20+PCREL_LO12 pairs to GPREL when possible, causing a 10%
permormance hit on Dhrystone on Rocket.

Note that we'll now relax

  la gp, __global_pointer$

to

  mv gp, gp

which probably isn't what you want in your entry code.  Users who want
gp-relative symbols to continue to resolve should add ".option norelax"
accordingly.  Due to this, the assembler now pairs PCREL relocations
with RELAX relocations when they're expected to be relaxed just like
every other relaxable relocation.

bfd/ChangeLog

2017-10-19  Palmer Dabbelt  <palmer@dabbelt.com>

        * elfnn-riscv.c (riscv_pcgp_hi_reloc): New structure.
        (riscv_pcgp_lo_reloc): Likewise.
        (riscv_pcgp_relocs): Likewise.
        (riscv_init_pcgp_relocs): New function.
        (riscv_free_pcgp_relocs): Likewise.
        (riscv_record_pcgp_hi_reloc): Likewise.
        (riscv_record_pcgp_lo_reloc): Likewise.
        (riscv_delete_pcgp_hi_reloc): Likewise.
        (riscv_use_pcgp_hi_reloc): Likewise.
        (riscv_record_pcgp_lo_reloc): Likewise.
        (riscv_find_pcgp_lo_reloc): Likewise.
        (riscv_delete_pcgp_lo_reloc): Likewise.
        (_bfd_riscv_relax_pc): Likewise.
        (_bfd_riscv_relax_section): Handle R_RISCV_PCREL_* relocations
        via the new functions above.

gas/ChangeLog

2017-10-19  Palmer Dabbelt  <palmer@dabbelt.com>

        * config/tc-riscv.c (md_apply_fix): Mark
        BFD_RELOC_RISCV_PCREL_HI20 as relaxable when relaxations are
        enabled.
2017-10-19 09:19:46 -07:00
Palmer Dabbelt ff6f4d9b2d RISC-V: Add R_RISCV_DELETE, which marks bytes for deletion
We currently delete bytes by shifting an entire BFD backwards to
overwrite the bytes we no longer need.  The result is that relaxing a
BFD is quadratic time.

This patch adds an additional relocation that specifies a byte range
that will be deleted from the final object file, and adds a relaxation
pass (between the existing passes that delete bytes and the alignment
pass) that actually deletes the bytes.  Note that deletion is still
quadratic time, and nothing uses R_RISCV_DELETE yet.

I've been meaning to go convert all the other relaxations to use
R_RISCV_DELETE and then make it faster, but this patch has been sitting
around for months so it looks like that won't happen for a bit.  The
PCREL->GPREL relaxation that comes next uses this, and since we've been
using these two patches out of tree since I wrote them months ago I
figure it's better to just get them in now.  I (or someone else :)) can
convert all the relocations later...

R_RISCV_DELETE will never be emitted into ELF objects, so therefor isn't
exposed to the rest of binutils.  As such, we're not considering this as
part of the ABI.

bfd/ChangeLog

2017-10-19  Palmer Dabbelt  <palmer@dabbelt.com>

        * elfnn-riscv (R_RISCV_DELETE): New define.
        (_bfd_riscv_relax_delete): New function.
        (perform_relocation): Handle R_RISCV_DELETE.
        (_bfd_riscv_relax_section): Likewise.

ld/ChangeLog

2017-10-19  Palmer Dabbelt  <palmer@dabbelt.com>

        * emultempl/riscvelf.em (riscv_elf_before_allocation): Add a
        third relaxation pass.
2017-10-19 09:19:32 -07:00
Nick Clifton 95e42ad442 Fix the AVR assembler so that it will correctly issue warnings about skipped instructions even if subsections are used.
PR 21621
	* config/tc-avr.h (struct avr_frag_data): Add prev_opcode field.
	(TC_FRAG_INIT): Define.
	(avr_frag_init): Add prototype.
	* config/tc-avr.c (avr_frag_init): New function.
	(avr_operands): Replace static local 'prev' variable with
	prev_opcode field in current frag.
	* testsuite/gas/avr/pr21621.s: New test source file.
	* testsuite/gas/avr/pr21621.d: New test driver file.
	* testsuite/gas/avr/pr21621.s: New test error output file.
2017-10-19 16:21:51 +01:00
Pedro Alves a75868f50b Fix inferior deadlock with "target remote | CMD"
Comparing test results between

  --target_board=native-gdbserver
  --target_board=native-stdio-gdbserver

I noticed that gdb.base/bigcore.exp is failing with native-stdio-gdbserver:

  Running src/gdb/testsuite/gdb.base/bigcore.exp ...
  FAIL: gdb.base/bigcore.exp: continue (timeout)
  ...

The problem is that:

  1. When debugging with "target remote | CMD", the inferior's
     stdout/stderr streams are connected to a pipe.

  2. The bigcore.c program prints a lot to the screen before it
     reaches the breakpoint location that the "continue" shown above
     wants to reach.

  3. GDB is not flushing the inferior's output pipe while the inferior
     is running.

  4. The pipe becomes full.

  5. The inferior thus deadlocks.

The bug is #3 above, which is what this commit fixes.  A new test is
added, that specifically exercises this scenario.  The test fails
before the fix, and passes after, and gdb.base/bigcore.exp also starts
passing.

gdb/ChangeLog:
2017-10-19  Pedro Alves  <palves@redhat.com>

	* ser-base.c (ser_base_read_error_fd): Delete the file handler if
	async.
	(handle_error_fd): New function.
	(ser_base_async): Add/delete an event loop file handler for
	error_fd.

gdb/testsuite/ChangeLog:
2017-10-19  Pedro Alves  <palves@redhat.com>

	* gdb.base/long-inferior-output.c: New file.
	* gdb.base/long-inferior-output.exp: New file.
2017-10-19 16:00:21 +01:00
Pedro Alves 2edf834e29 xml_fetch_content_from_file: Read in whole file in one go
There doesn't seem to be a good reason we're reading the file one
chunk at a time.

gdb/ChangeLog:
2017-10-19  Pedro Alves  <palves@redhat.com>

	* xml-support.c (xml_fetch_content_from_file): Don't read in
	chunks.  Instead use fseek to determine the file's size, and read
	it in one go.
2017-10-19 15:25:59 +01:00
H.J. Lu 280958942b tilegx: Check bfd_link_executable for TLS check
Copied from x86, check bfd_link_executable, instead of bfd_link_pic,
for TLS transition check.  Not sure if it works correctly.  All usages
of bfd_link_pic should be audited.

	PR ld/22263
	* elfxx-tilegx.c (tilegx_elf_tls_transition): Replace
	bfd_link_pic with !bfd_link_executable, !bfd_link_pic with
	bfd_link_executable for TLS check.
	(tilegx_elf_check_relocs): Likewise.
	(allocate_dynrelocs): Likewise.
	(tilegx_elf_relocate_section): Likewise.
2017-10-19 05:22:35 -07:00
H.J. Lu 1ba1f393fa tilepro: Check bfd_link_executable for TLS check
Copied from x86, check bfd_link_executable, instead of bfd_link_pic,
for TLS transition check.  Not sure if it works correctly.  All usages
of bfd_link_pic should be audited.

	PR ld/22263
	* elf32-tilepro.c (tilepro_elf_tls_transition): Replace
	bfd_link_pic with !bfd_link_executable, !bfd_link_pic with
	bfd_link_executable for TLS check.
	(tilepro_elf_check_relocs): Likewise.
	(allocate_dynrelocs): Likewise.
	(tilepro_elf_relocate_section): Likewise.
2017-10-19 05:21:01 -07:00
H.J. Lu 0fb7012e88 sparc: Check bfd_link_executable for TLS check
Copied from x86, check bfd_link_executable, instead of bfd_link_pic,
for TLS transition check.  Not sure if it works correctly.  All usages
of bfd_link_pic should be audited.

	PR ld/22263
	* elfxx-sparc.c (sparc_elf_tls_transition): Replace
	bfd_link_pic with !bfd_link_executable, !bfd_link_pic with
	bfd_link_executable for TLS check.
	(_bfd_sparc_elf_check_relocs): Likewise.
	(allocate_dynrelocs): Likewise.
	(_bfd_sparc_elf_relocate_section): Likewise.
2017-10-19 05:18:22 -07:00
Andreas Krebbel fa57faa0da Fix fill-1 testcase
This fixes various issues with the fill-1 testcase causing fails on a
couple of targets.

gas/ChangeLog:

2017-10-19  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* testsuite/gas/all/fill-1.s: Use normal labels.  Change .text to
	.data. Pick different values.  Use .dc.w instead of .word.
	* testsuite/gas/all/fill-1.d: New objdump output check.
	* testsuite/gas/all/gas.exp: Use run_dump_test to execute fill-1
	testcase.
2017-10-19 09:02:15 +02:00
GDB Administrator d7dd155841 Automatic date update in version.in 2017-10-19 00:00:32 +00:00
H.J. Lu 8e35405853 tile: Mark __tls_get_addr in gc_mark_hook
TLS_GD_CALL relocations implicitly reference __tls_get_addr.  Since
elf_gc_mark_hook is called before check_relocs now, we need to call
_bfd_generic_link_add_one_symbol to mark __tls_get_addr for garbage
collection.

	* elf32-tilepro.c (tilepro_elf_gc_mark_hook): Call
	_bfd_generic_link_add_one_symbol to mark __tls_get_addr.
	* elfxx-tilegx.c (tilegx_elf_gc_mark_hook): Likewise.
2017-10-18 15:47:35 -07:00
Palmer Dabbelt 8dfa5d5a63 RISC-V: Mark unsupported gas testcases
There are individual comments that explain why each test isn't
supported, but the vast majority of them are due to RISC-V's aggressive
linker relaxation.  The SLEB test cases should eventually be supported,
but the remaining ones probably won't ever be.

2017-10-18  Palmer Dabbelt  <palmer@dabbelt.com>

        * testsuite/gas/all/align.d: Mark as unsupported on RISC-V.
        testsuite/gas/all/relax.d: Likewise.
        testsuite/gas/all/sleb128-2.d: Likewise.
        testsuite/gas/all/sleb128-4.d: Likewise.
        testsuite/gas/all/sleb128-5.d: Likewise.
        testsuite/gas/all/sleb128-7.d: Likewise.
        testsuite/gas/elf/section11.d: Likewise.
        testsuite/gas/all/gas.exp (diff1.s): Likewise.
2017-10-18 13:16:42 -07:00
Keith Seitz c8ba13ad37 Canonicalize conversion operators
Consider a conversion operator such as:

operator foo const* const* ();

There are two small parser problems, highlighted by this test:

(gdb) p operator foo const* const*
There is no field named operatorfoo const* const *

GDB is looking up the symbol "operatorfoo const* const*" -- it is missing a
space between the keyword "operator" and the type name "foo const* const*".

Additionally, this input of the user-defined type needs to be canonicalized
so that different "spellings" of the type are recognized:

(gdb) p operator const foo* const *
There is no field named operator const foo* const *

gdb/ChangeLog:

	* c-exp.y (oper): Canonicalize conversion operators of user-defined
	types.
	Add whitespace to front of type name.

gdb/testsuite/ChangeLog:

	* gdb.cp/cpexprs.cc (base) <operator fluff const* const*>: New
	method.
	(main): Call it.
	* gdb.cp/cpexprs.exp: Add new conversion operator to test matrix.
	Add additional user-defined conversion operator tests.
2017-10-18 11:26:02 -07:00
Keith Seitz 3753468682 Issue complaint instead of assert for invalid/unhandled DW_AT_accessibility
A previous patch called gdb_assert_not_reached whenever reading
the accessibility of a nested typedef definition. Wisely, Pedro has asked me
not do this.

This patch changes the previous one so that it issues a complaint instead.

gdb/ChangeLog:

	* dwarf2read.c (dwarf2_add_typedef): Issue a complaint on unhandled
	DW_AT_accessibility.
2017-10-18 10:14:01 -07:00
Eric Botcazou 2a6969e173 [Visium] Disassemble the operands of the stop instruction.
binutils/
        * MAINTAINERS: Add myself as Visium maintainer.
opcodes/
        * visium-dis.c (disassem_class1) <case 0>: Print the operands.
2017-10-18 16:30:24 +02:00
Nick Clifton 8ef027f00b Update Cris assembler tests for checks that now pass where they used to fail.
PR gas/22304
	* testsuite/gas/cris/range-err-1.s: Remove spurious xfails.
	* testsuite/gas/cris/cris.exp: Expect the shexpr-1 test to pass.
2017-10-18 15:07:36 +01:00
Nick Clifton 94ea37b3e9 Update the Swedish translation in the GAS subdirectory.
* po/sv.po: Updated Swedish translation.
2017-10-18 14:50:49 +01:00
Nick Clifton 8071ec0990 Add a warning to the how-to-make-a-release notes to check the permissions on the files in the tarball.
* README-how-to-make-a-release: A note about checking file and
	directory permissions.
2017-10-18 14:40:06 +01:00
Nick Clifton 482366c31e Move Svein Seldal to Past Maintainers section.
* MAINTAINERS: Move Svein Seldal to Past Maintainers section.
2017-10-18 14:36:48 +01:00
Yao Qi 28c7c15876 Remove features/tic6x-c62x-linux.c
c40c7bf (Remove features/tic6x-*.c files) doesn't remove
features/tic6x-c62x-linux.c.  This patch removes it.

gdb:

2017-10-18  Yao Qi  <yao.qi@linaro.org>

	* features/tic6x-c62x-linux.c: Remove.
2017-10-18 12:48:12 +01:00
Alan Modra 5396a86e43 PR22303, print_core_note out of bounds read
The print_core_note change here fixes the PR, the rest is making
readelf a little more bombproof against maliciously crafted binaries.

	PR 22303
	* readelf.c (print_core_note): Ensure "count" sanity check
	calculation doesn't overflow.
	(process_notes_at): Perform note namesz and descsz checks
	using unsigned comparisons against data remaining.  Catch
	alignment overflow of namesz and descsz too.  Don't allocate a
	temp for terminating "name" when there is space available
	before descdata.
2017-10-18 12:50:45 +10:30
H.J. Lu b7213666d6 microblaze: Check for indirect and warning symbols
Relocations against indirect and warning symbols should be applied to real
symbols.

	* elf32-microblaze.c (microblaze_elf_check_relocs): Check for
	indirect and warning symbols.
2017-10-17 17:15:02 -07:00
GDB Administrator da15dcb0aa Automatic date update in version.in 2017-10-18 00:00:29 +00:00
Alan Modra 412294daf8 [GOLD] Fix powerpc64 optimization of TOC accesses
Fixes a thinko.  Given code that puts variables into the TOC (a bad
idea, but some see the TOC as a small data section) this bug could
result in an attempt to optimize a sequence that should not be
optimized.

	* powerpc.cc (Target_powerpc::Scan::local): Correct dst_off
	calculation for TOC16 relocs.
	(Target_powerpc::Scan::global): Likewise.
2017-10-18 08:48:17 +10:30
Pedro Alves b27de576d4 Really make the native-stdio-gdbserver board non-remote
I've noticed now that due to a last-minute change, commit 739b3f1d8f
("Make native gdbserver boards no longer be "remote" (in DejaGnu
terms)") managed to miss loading "local-board" in the
native-stdio-gdbserver board...

gdb/testsuite/ChangeLog:
2017-10-17  Pedro Alves  <palves@redhat.com>

	* boards/native-stdio-gdbserver.exp: Load "local-board".
2017-10-17 19:45:35 +01:00
Tom Tromey be459434b6 Add myself as dwarf-mode.el maintainer
In https://sourceware.org/ml/binutils/2017-10/msg00160.html, Nick said I
should update MAINTAINERS to mention that I'm the dwarf-mode.el
maintainer.  So, I'm checking this in.

2017-10-17  Tom Tromey  <tom@tromey.com>

	* MAINTAINERS: Add myself as dwarf-mode.el maintainer.
2017-10-17 09:37:33 -06:00
Pedro Alves 8484c95545 Add several "quit with live inferior" tests
In my multi-target branch, I had managed to break GDB exiting
successfuly in response to "quit" or SIGHUP/SIGTERM when:

 - you're debugging with "target extended-remote",
 - have more than one inferior loaded in gdb, some running, and at
   least one not running, and,
 - quit gdb with the inferior that is not running yet selected.

The testsuite still passed cleanly anyway.  I only noticed because I
was left with a bunch of core dumps in the gdb/testsuite/ directory --
the testsuite infrastructure closes GDB's pty after running each
testcase, which results in GDB getting a SIGHUP and should make GDB
exit gracefully.  If GDB crashes at that point though, there's no
indication about it in gdb.sum/gdb.log.

This commit adds a multitude of tests exercising quitting GDB with
live inferiors, some of which would have caught the problem.

gdb/testsuite/ChangeLog:
2017-10-17  Pedro Alves  <palves@redhat.com>

	* gdb.base/quit-live.c: New file.
	* gdb.base/quit-live.exp: New file.
2017-10-17 14:58:54 +01:00
Tom Tromey 30f0b10158 Remove cleanups from disasm.c
This changes the remaining spots in disasm.c to use the RAII ui-out
emitters, removing a few cleanups.  This also fixes a regression that
Simon pointed out.

2017-10-17  Tom Tromey  <tom@tromey.com>

	* disasm.c (do_mixed_source_and_assembly_deprecated): Use
	gdb::optional, ui_out_emit_list, ui_out_emit_tuple.
	(do_mixed_source_and_assembly): Likewise.
2017-10-17 06:43:33 -06:00
Tom Tromey 57e12da97f Remove obsolete assertion from regcache.c
When building I got:

../../binutils-gdb/gdb/regcache.c:935:24: error: the address of ‘ssize_t read(int, void*, size_t)’ will never be NULL [-Werror=address]

This happens because "read" used to be a parameter to this function,
which was then removed; but the assertion wasn't updated.

I don't think the assertion is relevant any more, to this removes it.
I'm checking it in as obvious.

2017-10-17  Tom Tromey  <tom@tromey.com>

	* regcache.c (regcache::xfer_part): Remove assertion.
2017-10-17 06:42:36 -06:00
Alan Modra cf54ebff3b PR22307, Heap out of bounds read in _bfd_elf_parse_gnu_properties
When adding an unbounded increment to a pointer, you can't just check
against the end of the buffer but also must check that overflow
doesn't result in "negative" pointer movement.  Pointer comparisons
are signed.  Better, check the increment against the space left using
an unsigned comparison.

	PR 22307
	* elf-properties.c (_bfd_elf_parse_gnu_properties): Compare datasz
	against size left rather than comparing pointers.  Reorganise loop.
2017-10-17 22:12:45 +10:30
Pedro Alves 7b7009999a Fix double-free corruption
Fixes a double-free regression introduced by commit b7b030adc4
("Return unique_xmalloc_ptr from target_read_stralloc"):

gdb.sum:
  Running src/gdb/testsuite/gdb.base/catch-syscall.exp ...
  ERROR: Process no longer exists

Valgrind shows:

  (gdb) catch syscall
  ==3687== Thread 1:
  ==3687== Invalid free() / delete / delete[] / realloc()
  ==3687==    at 0x4C29CF0: free (vg_replace_malloc.c:530)
  ==3687==    by 0x610862: xfree(void*) (common-utils.c:101)
  ==3687==    by 0x440D5D: gdb::xfree_deleter<char>::operator()(char*) const (gdb_unique_ptr.h:34)
  ==3687==    by 0x446CC6: std::unique_ptr<char, gdb::xfree_deleter<char> >::reset(char*) (unique_ptr.h:344)
  ==3687==    by 0x81BE50: xml_fetch_content_from_file(char const*, void*) (xml-support.c:1042)
  ==3687==    by 0x81DA86: xml_init_syscalls_info(char const*) (xml-syscall.c:366)
  ==3687==    by 0x81DBDD: init_syscalls_info(gdbarch*) (xml-syscall.c:398)
  ==3687==    by 0x81E131: get_syscall_by_number(gdbarch*, int, syscall*) (xml-syscall.c:599)
  ==3687==    by 0x5BE86F: catch_syscall_command_1(char*, int, cmd_list_element*) (break-catch-syscall.c:481)
  ==3687==    by 0x4B46B1: do_sfunc(cmd_list_element*, char*, int) (cli-decode.c:138)
  ==3687==    by 0x4B76B8: cmd_func(cmd_list_element*, char*, int) (cli-decode.c:1952)
  ==3687==    by 0x7E91C7: execute_command(char*, int) (top.c:615)
  ==3687==  Address 0x14332ae0 is 0 bytes inside a block of size 4,096 free'd
  ==3687==    at 0x4C2AB8B: realloc (vg_replace_malloc.c:785)
  ==3687==    by 0x610792: xrealloc (common-utils.c:62)
  ==3687==    by 0x81BE3E: xml_fetch_content_from_file(char const*, void*) (xml-support.c:1042)
  ==3687==    by 0x81DA86: xml_init_syscalls_info(char const*) (xml-syscall.c:366)
  ==3687==    by 0x81DBDD: init_syscalls_info(gdbarch*) (xml-syscall.c:398)
  ==3687==    by 0x81E131: get_syscall_by_number(gdbarch*, int, syscall*) (xml-syscall.c:599)
  ==3687==    by 0x5BE86F: catch_syscall_command_1(char*, int, cmd_list_element*) (break-catch-syscall.c:481)
  ==3687==    by 0x4B46B1: do_sfunc(cmd_list_element*, char*, int) (cli-decode.c:138)
  ==3687==    by 0x4B76B8: cmd_func(cmd_list_element*, char*, int) (cli-decode.c:1952)
  ==3687==    by 0x7E91C7: execute_command(char*, int) (top.c:615)
  ==3687==    by 0x6A422D: command_handler(char*) (event-top.c:583)
  ==3687==    by 0x6A45F2: command_line_handler(char*) (event-top.c:773)
  [...]

The problem is that if xrealloc decides it needs a new memory block,
it frees the previous block/pointer, and then text.reset() frees it
again.

gdb/ChangeLog:
2017-10-17  Pedro Alves  <palves@redhat.com>

	* xml-support.c (xml_fetch_content_from_file): Call
	unique_ptr::release() instead unique_ptr::get() when passing
	through xrealloc.
2017-10-17 12:41:00 +01:00
Yao Qi d3037ba6a3 Simplify regcache::xfer_part
Since xfer_part is already a class method, and only
{raw,cooked}_{read,write} are passed to it.  We can remove these two
arguments, but add a bool argument is_raw, indicating raw registers or
cooked registers are accessed.

gdb:

2017-10-17  Yao Qi  <yao.qi@linaro.org>

	* regcache.c (regcache::xfer_part): Remove parameters read and
	write, add parameter is_raw.  All callers are updated.
2017-10-17 12:29:26 +01:00
Yao Qi 7a7cdfa04b [GDBserver] Move aarch64-insn.o to arch/ and remove one Makefile rule
gdb/gdbserver:

2017-10-17  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in: Remove one rule.
	* configure.srv: Rename aarch64-insn.o with arch/aarch64-insn.o.
2017-10-17 12:12:04 +01:00
Yao Qi e675d1703f [GDBserver] Move arm-linux.o and arm-get-next-pcs.o to arch/
gdb/gdbserver:

2017-10-17  Yao Qi  <yao.qi@linaro.org>

	* configure.srv: Rename arm-linux.o with arch/arm-linux.o.
	Rename arm-get-next-pcs.o with arch/arm-get-next-pcs.o.
2017-10-17 12:12:04 +01:00
Yao Qi 7eb4e0f956 [GDBserver] Move arm.o to arch/arm.o
gdb/gdbserver:

2017-10-17  Yao Qi  <yao.qi@linaro.org>

	* configure.srv: Rename arm.o with arch/arm.o.
2017-10-17 12:12:04 +01:00
Yao Qi 60d6cfc99e [GDBserver] Replicate src dir in build dir
Similar to f38307f5 (Replicate src dir in build dir), this patch change
configure and Makefile to generate object files in arch/ directory.

gdb/gdbserver:

2017-10-17  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (CONFIG_SRC_SUBDIR): New variable.
	(clean): Remove .o files in CONFIG_SRC_SUBDIR.
	(distclean): Remove DEPDIR in CONFIG_SRC_SUBDIR.
	(arch-i386.o, arch-amd64.o): Remove rules.
	(arch/%.o): New rule.
	Update POSTCOMPILE and COMPILE.pre.
	* configure.ac: Invoke AC_CONFIG_COMMANDS.
	* configure: Re-generated.
	* configure.srv: Replace arch-i386.o with arch/i386.o.
	Replace arch-amd64.o with arch/amd64.o.
2017-10-17 12:12:04 +01:00
Alan Modra 0301ce1486 PR22306, Invalid free() in slurp_symtab()
PR 22306
	* aoutx.h (aout_get_external_symbols): Handle stringsize of zero,
	and error for any other size that doesn't cover the header word.
2017-10-17 16:47:44 +10:30
Alan Modra e6e2dfbdc1 Correct -z text and other -z documentation
-z text applies to all dynamic binaries, not just shared libraries.
A lot of the other options needed attention too.

	* ld.texinfo (-z): Combine negative options with corresponding
	positive option.  Sort the table.  Expand and correct "combreloc",
	"common", "common-page-size", "interpose", "loadfltr",
	"max-page-size", "muldefs", "nodefaultlib", "nodelete", "nodlopen",
	"nodump", "noextern-protected-data", "now", "origin", and "text".
2017-10-17 16:47:05 +10:30
Keith Seitz 83d5a34dd4 Add missing ChangeLog entries. 2017-10-16 22:19:55 -07:00