]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
7 years agobtrace: record stop moves to the end of the trace users/mmetzger/record-goto-mi
Markus Metzger [Fri, 10 Jun 2016 09:24:21 +0000 (11:24 +0200)] 
btrace: record stop moves to the end of the trace

With the btrace record target the "record stop" command implicitly moves all
traced threads to the end of their respective history.  Unlike record full,
record btrace does not trace data and is therefore not able to resume debugging
at the current replay position.

We forgot to actually change the replay position before disabling tracing.  This
resulted in STOP_PC remaining at its old position if the current thread had been
replaying, which, in turn, resulted in GDB commands such as list or backtrace
using the wrong context.

Fix it by moving the selected thread to the end of its recorded history.
Together with the preceding patches, this will result in a front-end
notification for the selected thread if it had been replaying.  Stop replaying
other threads silently, i.e. without a front-end notification.

If the selected thread isn't replaying, notify front-ends without printing the
(unchanged) frame.  This results in a *stopped MI notification without any
thread information.

In non-stop mode, move all replaying threads to the end of their respective
histories.  This will result in a front-end notification and in the updated
location to be printed for each replaying thread.  We prefix the output with
the thread number like this:

    (gdb) record stop
    Thread 1 (Thread 0x7ffff7fcc740 (LWP 66711)) stopped replaying.
    test (arg=0x0) at gdb.btrace/multi-thread-step.c:34
    34        global = 42; /* bp.2 */
    Thread 2 (Thread 0x7ffff74fb700 (LWP 66716)) stopped replaying.
    test (arg=0x0) at gdb.btrace/multi-thread-step.c:34
    34        global = 42; /* bp.2 */
    Process record is stopped and all execution logs are deleted.

Thanks to Marc Khouzam <marc.khouzam@ericsson.com> for reporting this.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
gdb/
* record-btrace.c (record_btrace_set_replay)
(record_btrace_stop_replaying): New declaration.
(record_btrace_stop_recording): Call record_btrace_set_replay,
record_btrace_stop_replaying, and observer_notify_normal_stop.

testsuite/
* gdb.btrace/non-stop.exp: Test "record stop".
* gdb.btrace/non-stop.c (test): Add statement to break at.
* gdb.btrace/stop.exp: New.

Change-Id: I10565a8e4f8bc3c63f79c3ef6595e9f84e3d8100

7 years agobtrace-btrace: signal record-goto stop
Markus Metzger [Fri, 10 Jun 2016 12:13:02 +0000 (14:13 +0200)] 
btrace-btrace: signal record-goto stop

When changing a thread's replay position, call record_signal_goto_stop instead
of printing the source location directly.  This will signal the stop to
front-ends and have them print the source location.

We update the STOP_PC if the change affects the selected thread.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
gdb/
* record-btrace.c (record_btrace_set_replay): Check ptid before updating
STOP_PC.  Call record_signal_goto_stop.

Change-Id: If2cb2b9572396a2e5475d6611c7e9f79547c6f61

7 years agorecord-full: signal record-goto stop
Markus Metzger [Mon, 13 Jun 2016 08:50:26 +0000 (10:50 +0200)] 
record-full: signal record-goto stop

When changing the replay position call record_signal_goto_stop instead of
printing the new source location directly.  This will signal the stop to
front-ends and have them print the source location.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
gdb/
* record-full.c (record_full_goto_entry): Call record_signal_goto_stop.

testsuite/
* gdb.mi/mi-reverse.exp: Test record goto begin/end.

Change-Id: Ibae2736eb0cd3c70ba7d99d18836575eb0d23f33

7 years agomi, testsuite: add another EXTRA option to mi_expect_stop
Markus Metzger [Mon, 13 Jun 2016 13:36:31 +0000 (15:36 +0200)] 
mi, testsuite: add another EXTRA option to mi_expect_stop

Allow the EXTRA argument of mi_expect_stop to contain a third pattern that must
occur directly before the GDB prompt at the end of the output.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
testsuite/
* lib/mi-support.exp (mi_expect_stop): Add third EXTRA field.

Change-Id: I7b492b72619265ea81200935adf22d94bb086806

7 years agorecord: signal a record goto stop to front-ends
Markus Metzger [Fri, 10 Jun 2016 12:07:22 +0000 (14:07 +0200)] 
record: signal a record goto stop to front-ends

The "record goto" command does not indicate the stop to front-ends.  Instead,
it prints the new location directly.

Add a function to signal a normal stop to observers and have them print the new
location.  This function temporarily switches to the stopped thread.

We use the TARGET_WAITKIND_NO_RESUMED wait status for this purpose.  This should
result in a stop notification without giving a stop reason.  We could also
invent a new wait status but this doesn't seem necessary at this point.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
gdb/
* record.h (record_signal_goto_stop): New.
* record.c (record_signal_goto_stop): New.

Change-Id: I0b196be68779f9e81abca78df5bc39e917023581

7 years agoinfrun: export clear_proceed_status_thread
Markus Metzger [Mon, 13 Jun 2016 11:27:55 +0000 (13:27 +0200)] 
infrun: export clear_proceed_status_thread

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
gdb/
* infrun.h (clear_proceed_status_thread): New.
* infrun.c (clear_proceed_status_thread): Export.

Change-Id: I23e762997359b9769856450e89626707bad1365e

7 years agorecord: do not allow record goto on a running thread
Markus Metzger [Fri, 10 Jun 2016 12:49:50 +0000 (14:49 +0200)] 
record: do not allow record goto on a running thread

We can't start replaying if the selected thread is currently running.  Throw an
error in this case.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
gdb/
* record.c: Include gdbthread.h
(require_not_running): New.
(record_goto, cmd_record_goto_begin, cmd_record_goto_end): Call
require_not_running.

Change-Id: I15888d668b6011217337cf3a63d3618fb044c023

7 years agobtrace: check if we're replaying when setting the replay position to the end
Markus Metzger [Fri, 10 Jun 2016 09:18:08 +0000 (11:18 +0200)] 
btrace: check if we're replaying when setting the replay position to the end

When setting the replay position to the end there is nothing to do if we are
not replaying.  Check that and return immediately.

This avoids printing the current location if we're already at the end.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
gdb/
* record-btrace.c (record_btrace_set_replay): Check if replaying.

testsuite/
* gdb.btrace/record_goto.exp: Test "record goto end" twice.

Change-Id: I4878892408bab293261bbea40d6af28440ff3ec5

7 years agoAllow subscripting raw pointers
Manish Goregaokar [Wed, 6 Jul 2016 05:25:10 +0000 (10:55 +0530)] 
Allow subscripting raw pointers

This will be useful for dealing with vectors; regardless of our final solution
for the Index trait.

2016-07-06  Manish Goregaokar  <manish@mozilla.com>

gdb/ChangeLog:
    * rust-lang.c (rust_subscript): Allow subscripting pointers

gdb/testsuite/ChangeLog:
    * simple.rs: Add test for raw pointer subscripting
    * simple.exp: Add test expectations

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 6 Jul 2016 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoAdd -flto to PR ld/20321 test
H.J. Lu [Tue, 5 Jul 2016 14:35:52 +0000 (07:35 -0700)] 
Add -flto to PR ld/20321 test

Before GCC 4.9, -flto is required for final LTO link.  Add -flto to PR
ld/20321 test to support older versions of GCC.

* testsuite/ld-plugin/lto.exp: Add -flto to PR ld/20321 test.

7 years agoFix fail in gdb.mi/mi-reverse.exp
Yao Qi [Tue, 5 Jul 2016 13:46:21 +0000 (14:46 +0100)] 
Fix fail in gdb.mi/mi-reverse.exp

Commit 38b022b4452f996fb5a8598f80d850b594621bcf adds "method" and
"format" fields in =record-started, but doesn't update test case
gdb.mi/mi-reverse.exp, so it causes the fail like this,

PASS: gdb.mi/mi-reverse.exp: mi runto main
Expecting: ^(-interpreter-exec console record[^M
]+)?(=record-started,thread-group="i1"^M
\^done[^M
]+[(]gdb[)] ^M
[ ]*)
-interpreter-exec console record^M
=record-started,thread-group="i1",method="full"^M
^done^M
(gdb) ^M
FAIL: gdb.mi/mi-reverse.exp: Turn on process record

and regression was found by buildbot too
https://sourceware.org/ml/gdb-testers/2016-q2/msg04492.html

gdb/testsuite:

2016-07-05  Yao Qi  <yao.qi@linaro.org>

* gdb.mi/mi-reverse.exp: Match =record-started output.

7 years ago[ARM] Purecode compatible long branch veneer for M-profile targets with MOVW.
Andre Vieria [Tue, 5 Jul 2016 10:39:06 +0000 (11:39 +0100)] 
[ARM] Purecode compatible long branch veneer for M-profile targets with MOVW.

2016-07-05  Andre Vieria  <andre.simoesdiasvieira@arm.com>

* elf32-arm.c (THUMB32_MOVT): New veneer macro.
(THUMB32_MOVW): Likewise.
(elf32_arm_stub_long_branch_thumb2_only_pure): New.
(DEF_STUBS): Define long_branch_thumb2_only_pure.
(arm_stub_is_thumb): Add new veneer stub.
(arm_type_of_stub): Use new veneer.
(arm_stub_required_alignment): Add new veneer.

2016-07-05  Andre Vieria  <andre.simoesdiasvieira@arm.com>

* testsuite/ld-arm/farcall-thumb2-purecode.d: New test result.
* testsuite/ld-arm/farcall-thumb2-purecode.s: New test.
* testsuite/ld-arm/arm-elf.exp: Run it.

7 years ago[ARM] Change noread to purecode.
Andre Vieria [Tue, 5 Jul 2016 10:28:46 +0000 (11:28 +0100)] 
[ARM] Change noread to purecode.

bfd/ChangeLog
2016-07-05  Andre Vieria  <andre.simoesdiasvieira@arm.com>

        * bfd-in2.h (SEC_ELF_NOREAD): Rename to ...
          (SEC_ELF_PURECODE): ... this.
        * elf32-arm.c (elf32_arm_post_process_headers): Rename SEC_ELF_NOREAD
          to SEC_ELF_NOREAD.
          (elf32_arm_fake_sections): Likewise.
          (elf_32_arm_section_flags): Likewise.
          (elf_32_arm_lookup_section_flags): Likewise.
        * section.c (SEC_ELF_NOREAD): Rename to ...
          (SEC_ELF_PURECODE): ... this.

binutils/ChangeLog
2016-07-05  Andre Vieria  <andre.simoesdiasvieira@arm.com>

        * objdump.c (dump_section_header): Rename SEC_ELF_NOREAD
          to SEC_ELF_NOREAD.
        * readelf.c (get_elf_section_flags): Rename ARM_NOREAD to
          ARM_PURECODE and SHF_ARM_NOREAD to SHF_ARM_PURECODE.
          (process_section_headers): Rename noread to purecode.

        * section.c (SEC_ELF_NOREAD): Rename to ...
          (SEC_ELF_PURECODE): ... this.

include/ChangeLog
2016-07-05  Andre Vieria  <andre.simoesdiasvieira@arm.com>

        * elf/arm.h (SHF_ARM_NOREAD): Rename to ...
          (SHF_ARM_PURECODE): ... this.

ld/ChangeLog
2016-07-05  Andre Vieria  <andre.simoesdiasvieira@arm.com>

        * testsuite/ld-arm/arm_noread.ld: Renamed to ...
          testsuite/ld-arm/arm_purecode.ld: ... this, and replaced
          all noread's by purecode.

7 years agold: track linker-definedness of symbols
Jan Beulich [Tue, 5 Jul 2016 09:36:08 +0000 (11:36 +0200)] 
ld: track linker-definedness of symbols

Keep "lineno" as zero while not processing any script, and use it being
zero to set the "linker_def" field to true.

7 years agox86: fix register check in check_qword_reg()
Jan Beulich [Tue, 5 Jul 2016 09:14:51 +0000 (11:14 +0200)] 
x86: fix register check in check_qword_reg()

A missing 'r' (or wrong 'e') register prefix needs to be complained
about if the template allows for a 64-bit register, not a 32-bit one.
I assume this was a copy-and-paste type of mistake
(from check_long_reg()).

7 years agobabeltrace compilation regression
Jan Kratochvil [Tue, 5 Jul 2016 08:47:18 +0000 (10:47 +0200)] 
babeltrace compilation regression

Since:
commit 2d681be471cf8aff8f296cb7713c39e9aa4fc2bb
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
Date:   Wed Apr 27 15:52:16 2016 +0200
    Avoid non-C++-enabled babeltrace versions
tested with:
libbabeltrace-devel-1.2.4-4.fc24.x86_64
libbabeltrace-devel-1.4.0-2.fc25.x86_64
it can no longer build due to:
configure:16435: gcc -o conftest -m64 -g3 -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -fno-diagno
stics-show-caret  -Werror  -static-libstdc++ -static-libgcc  conftest.c -ldl -ldl -lncurses -lm -ldl  -lbabeltrace -lbabeltrace-ctf >&5
conftest.c: In function 'main':
conftest.c:208:7: error: 'pos' is a pointer; did you mean to use '->'?

gdb/ChangeLog
2016-07-05  Jan Kratochvil  <jan.kratochvil@redhat.com>

* configure: Regenerate.
* configure.ac (HAVE_LIBBABELTRACE): Fix pos variable dereference.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 5 Jul 2016 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoWarn and return for duplicated plugin
H.J. Lu [Mon, 4 Jul 2016 15:55:04 +0000 (08:55 -0700)] 
Warn and return for duplicated plugin

If a plugin has been loaded already, we should warn and return, instead
of adding it on the plugin list.

PR ld/20321
* plugin.c (plugin_opt_plugin): Warn and return if plugin has
been loaded already.
* testsuite/ld-plugin/lto.exp: Run PR ld/20321 test.
* testsuite/ld-plugin/pr20321.c: New file.

7 years agoAllow the flash and ram memory region sizes to be specified in the default FT32 linke...
Nick Clifton [Mon, 4 Jul 2016 14:44:10 +0000 (15:44 +0100)] 
Allow the flash and ram memory region sizes to be specified in the default FT32 linker script.

* scripttempl/ft32.sc (__PMSIZE_): If not defined, set to 256K.
(__RAMSIZE): If not defined, set to 64K.
(MEMORY): Set the flash region size to __PMSIZE and the ram region
size to __RAMSIZE.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 4 Jul 2016 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 3 Jul 2016 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoMIPS/GAS/testsuite: Remove remnants of a.out/ECOFF support
Maciej W. Rozycki [Sat, 2 Jul 2016 22:39:18 +0000 (23:39 +0100)] 
MIPS/GAS/testsuite: Remove remnants of a.out/ECOFF support

Complement:

commit 16e5e222b6eae6f110ea72bf627585c095a453a8
Author: Richard Sandiford <rdsandiford@googlemail.com>
Date:   Sat Jun 22 16:57:42 2013 +0000

<https://sourceware.org/ml/binutils/2013-06/msg00195.html>, ("Make
gas/mips/mips.exp ELF-only"), and remove the remaining stale ECOFF test
dumps and pieces of a.out/ECOFF support in relocation match patterns.

gas/
* testsuite/gas/mips/ecoff@ld.d: Remove test.
* testsuite/gas/mips/ecoff@ld-forward.d: Remove test.
* testsuite/gas/mips/ecoff@ld-zero-3.d: Remove test.
* testsuite/gas/mips/ecoff@sd.d: Remove test.
* testsuite/gas/mips/ecoff@sd-forward.d: Remove test.
* testsuite/gas/mips/beq.d: Remove a.out and ECOFF support from
reloc patterns.
* testsuite/gas/mips/mipsr6@beq.d: Likewise.
* testsuite/gas/mips/bge.d: Likewise.
* testsuite/gas/mips/mipsr6@bge.d: Likewise.
* testsuite/gas/mips/bgeu.d: Likewise.
* testsuite/gas/mips/mipsr6@bgeu.d: Likewise.
* testsuite/gas/mips/blt.d: Likewise.
* testsuite/gas/mips/mipsr6@blt.d: Likewise.
* testsuite/gas/mips/bltu.d: Likewise.
* testsuite/gas/mips/mipsr6@bltu.d: Likewise.
* testsuite/gas/mips/branch-likely.d: Likewise.
* testsuite/gas/mips/la.d: Likewise.
* testsuite/gas/mips/lb.d: Likewise.
* testsuite/gas/mips/lifloat.d: Likewise.
* testsuite/gas/mips/sb.d: Likewise.
* testsuite/gas/mips/uld.d: Likewise.
* testsuite/gas/mips/ulh.d: Likewise.
* testsuite/gas/mips/ulw.d: Likewise.
* testsuite/gas/mips/usd.d: Likewise.
* testsuite/gas/mips/ush.d: Likewise.
* testsuite/gas/mips/usw.d: Likewise.

7 years agoMIPS/LD/testsuite: Resurrect `branch-misc-2' test
Maciej W. Rozycki [Sat, 2 Jul 2016 22:14:20 +0000 (23:14 +0100)] 
MIPS/LD/testsuite: Resurrect `branch-misc-2' test

Revert:

commit c9c1e416d7dd1a35bd7c1a96d034dca1d5071cd1
Author: Alexandre Oliva <aoliva@redhat.com>
Date:   Thu Dec 12 04:39:44 2002 +0000

<https://sourceware.org/ml/binutils/2002-11/msg00657.html>, ("mips:
branches to external labels are broken"), complementing:

commit bad36eacdad37042c4efb1c5fbf48476b47de82b
Author: Daniel Jacobowitz <drow@false.org>
Date:   Wed Nov 23 14:04:18 2005 +0000

<https://sourceware.org/ml/binutils/2005-11/msg00324.html>,
("R_MIPS_PC16, again").

ld/
* testsuite/ld-mips-elf/branch-misc-2.d: New test.
* testsuite/ld-mips-elf/mips-elf.exp: Run it.

7 years agoMIPS/GAS/testsuite: Split `branch-misc-2' tests into two
Maciej W. Rozycki [Sat, 2 Jul 2016 22:09:06 +0000 (23:09 +0100)] 
MIPS/GAS/testsuite: Split `branch-misc-2' tests into two

Move `branch-misc-2' tests for non locally-defined-global symbols into
separate files.  These tests have been introduced with:

commit 6f171daac941741e5fa904f6e462adb75a595495
Author: Alexandre Oliva <aoliva@redhat.com>
Date:   Thu Dec 12 04:40:22 2002 +0000

<https://sourceware.org/ml/binutils/2002-11/msg00631.html>, ("mips:
branches to external labels are broken"), and:

commit d17b874b6c14caa2f2ed1b5544a48de9f39a1a65
Author: Alexandre Oliva <aoliva@redhat.com>
Date:   Wed Mar 12 23:07:22 2003 +0000

<https://sourceware.org/ml/binutils/2003-03/msg00136.html>, ("On
resolving the MIPS gas branch reloc issue"), while the test case served
a different purpose.  With the original intent of the test case brought
back with:

commit bad36eacdad37042c4efb1c5fbf48476b47de82b
Author: Daniel Jacobowitz <drow@false.org>
Date:   Wed Nov 23 14:04:18 2005 +0000

<https://sourceware.org/ml/binutils/2005-11/msg00324.html>,
("R_MIPS_PC16, again"), these stand in the way for linker testing.

gas/
* testsuite/gas/mips/branch-misc-2.s: Move non
locally-defined-global symbol tests...
* testsuite/gas/mips/branch-misc-5.s: ... to this new test.
* testsuite/gas/mips/branch-misc-2.d: Update accordingly.
* testsuite/gas/mips/branch-misc-2-64.d: Likewise.
* testsuite/gas/mips/branch-misc-2pic.d: Likewise.
* testsuite/gas/mips/branch-misc-2pic-64.d: Likewise.
* testsuite/gas/mips/mipsr6@branch-misc-2-64.d: Likewise.
* testsuite/gas/mips/mipsr6@branch-misc-2pic-64.d: Likewise.
* testsuite/gas/mips/micromips@branch-misc-2.d: Likewise.
* testsuite/gas/mips/micromips@branch-misc-2-64.d: Likewise.
* testsuite/gas/mips/micromips@branch-misc-2pic.d: Likewise.
* testsuite/gas/mips/micromips@branch-misc-2pic-64.d: Likewise.
* testsuite/gas/mips/branch-misc-5.d: New test.
* testsuite/gas/mips/branch-misc-5pic.d: New test.
* testsuite/gas/mips/branch-misc-5-64.d: New test.
* testsuite/gas/mips/branch-misc-5pic-64.d: New test.
* testsuite/gas/mips/mipsr6@branch-misc-5-64.d: New test.
* testsuite/gas/mips/mipsr6@branch-misc-5pic-64.d: New test.
* testsuite/gas/mips/micromips@branch-misc-5.d: New test.
* testsuite/gas/mips/micromips@branch-misc-5pic.d: New test.
* testsuite/gas/mips/micromips@branch-misc-5-64.d: New test.
* testsuite/gas/mips/micromips@branch-misc-5pic-64.d: New test.
* testsuite/gas/mips/mips.exp: Run the new tests.

7 years agoMIPS/GAS/testsuite: Reenable disabled external BEQ tests
Maciej W. Rozycki [Sat, 2 Jul 2016 21:19:15 +0000 (22:19 +0100)] 
MIPS/GAS/testsuite: Reenable disabled external BEQ tests

Complement:

commit bad36eacdad37042c4efb1c5fbf48476b47de82b
Author: Daniel Jacobowitz <drow@false.org>
Date:   Wed Nov 23 14:04:18 2005 +0000

<https://sourceware.org/ml/binutils/2005-11/msg00324.html>,
("R_MIPS_PC16, again"), and reenable external BEQ tests, the remaining
subset missed from the set of branch tests previously disabled with:

commit 6f171daac941741e5fa904f6e462adb75a595495
Author: Alexandre Oliva <aoliva@redhat.com>
Date:   Thu Dec 12 04:40:22 2002 +0000

<https://sourceware.org/ml/binutils/2002-11/msg00631.html>, ("mips:
branches to external labels are broken").

gas/
* testsuite/gas/mips/beq.s: Uncomment branches to undefined
symbols.
* testsuite/gas/mips/beq.d: Update accordingly.
* testsuite/gas/mips/mipsr6@beq.d: Likewise.
* testsuite/gas/mips/micromips@beq.d: Likewise.

7 years agoMIPS/GAS/testsuite: Restrict 64-bit `branch-mips' tests to NewABI targets
Maciej W. Rozycki [Sat, 2 Jul 2016 21:14:27 +0000 (22:14 +0100)] 
MIPS/GAS/testsuite: Restrict 64-bit `branch-mips' tests to NewABI targets

... removing numerous `mips-sgi-irix5' failures.

gas/
* testsuite/gas/mips/mips.exp: Restrict 64-bit `branch-mips'
tests to NewABI targets.

7 years agoMIPS/GAS/testsuite: Group `branch-misc' tests together
Maciej W. Rozycki [Sat, 2 Jul 2016 21:04:41 +0000 (22:04 +0100)] 
MIPS/GAS/testsuite: Group `branch-misc' tests together

gas/
* testsuite/gas/mips/mips.exp: Group `branch-misc' tests
together.

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 2 Jul 2016 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoOptimize memory_xfer_partial for remote
Don Breazeal [Fri, 1 Jul 2016 18:13:48 +0000 (11:13 -0700)] 
Optimize memory_xfer_partial for remote

Some analysis we did here showed that increasing the cap on the
transfer size in target.c:memory_xfer_partial could give 20% or more
improvement in remote load across JTAG.  Transfer sizes were capped
to 4K bytes because of performance problems encountered with the
restore command, documented here:

https://sourceware.org/ml/gdb-patches/2013-07/msg00611.html

and in commit 67c059c29e1f ("Improve performance of large restore
commands").

The 4K cap was introduced because in a case where the restore command
requested a 100MB transfer, memory_xfer_partial would repeatedy
allocate and copy an entire 100MB buffer in order to properly handle
breakpoint shadow instructions, even though memory_xfer_partial would
actually only write a small portion of the buffer contents.

A couple of alternative solutions were suggested:
* change the algorithm for handling the breakpoint shadow instructions
* throttle the transfer size up or down based on the previous actual
  transfer size

I tried implementing the throttling approach, and my implementation
reduced the performance in some cases.

This patch implements a new target function that returns that target's
limit on memory transfer size.  It defaults to ULONGEST_MAX bytes,
because for native targets there is no marshaling and thus no limit is
needed.  For remote targets it uses get_memory_write_packet_size.

gdb/ChangeLog:

* remote.c (remote_get_memory_xfer_limit): New function.
* target-delegates.c: Regenerate.
* target.c (memory_xfer_partial): Call
target_ops.to_get_memory_xfer_limit.
* target.h (struct target_ops)
<to_get_memory_xfer_limit>: New member.

7 years ago[AArch64] Fix +nofp16 handling
Szabolcs Nagy [Fri, 1 Jul 2016 15:20:50 +0000 (16:20 +0100)] 
[AArch64] Fix +nofp16 handling

Feature flag handling was not perfect, +nofp16 disabled fp
instructions too.

New feature flag macros were added to check features with multiple
bits set (matters for FP_F16 and SIMD_F16 opcode feature tests).
The unused AARCH64_OPCODE_HAS_FEATURE was removed, all checks should
use one of the AARCH64_CPU_HAS_* macros.  AARCH64_CPU_HAS_FEATURE
now checks all feature bits.

The aarch64_features table now contains the dependencies as
a separate field (so when the feature is enabled all dependencies
are enabled and when it is disabled everything that depends on it
is disabled).

Note that armv8-a+foo+nofoo is not equivalent to armv8-a if
+foo turns on dependent features that nofoo does not turn off.

gas/
* config/tc-aarch64.c (struct aarch64_option_cpu_value_table): Add
require field.
(aarch64_features): Initialize require fields.
(aarch64_parse_features): Handle dependencies.
(aarch64_feature_enable_set, aarch64_feature_disable_set): New.
(md_assemble): Use AARCH64_CPU_HAS_ALL_FEATURES.
* testsuite/gas/aarch64/illegal-nofp16.s: New.
* testsuite/gas/aarch64/illegal-nofp16.l: New.
* testsuite/gas/aarch64/illegal-nofp16.d: New.

include/
* opcode/aarch64.h (AARCH64_CPU_HAS_ALL_FEATURES): New.
(AARCH64_CPU_HAS_ANY_FEATURES): New.
(AARCH64_CPU_HAS_FEATURE): Define as AARCH64_CPU_HAS_ALL_FEATURES.
(AARCH64_OPCODE_HAS_FEATURE): Remove.

7 years agoFake VFORK_DONE events when following only the parent after a vfork.
John Baldwin [Sat, 25 Jun 2016 04:00:04 +0000 (21:00 -0700)] 
Fake VFORK_DONE events when following only the parent after a vfork.

FreeBSD does not currently report a ptrace event for a parent process
after it resumes due to the child exiting the shared memory region after
a vfork.  Take the same approach used in linux-nat.c in this case of
sleeping for a while and then reporting a fake VFORK_DONE event.

gdb/ChangeLog:

* fbsd-nat.c (struct fbsd_fork_child_info): Rename to ...
(struct fbsd_fork_info): ... this.
(struct fbsd_fork_info) <child>: Rename to ...
(struct fbsd_fork_info) <ptid>: ... this.
(fbsd_pending_children): Update type.
(fbsd_remember_child): Update type and field name.
(fbsd_is_child_pending): Likewise.
(fbsd_pending_vfork_done): New variable.
(fbsd_is_vfork_done_pending): New function.
(fbsd_next_vfork_done): New function.
(fbsd_resume): Don't resume processes with a pending vfork done
event.
(fbsd_wait): Report pending vfork done events.
(fbsd_follow_fork): Delay and record a pending vfork done event
for a vfork parent when detaching the child.

7 years agoMove fbsd_resume and related functions below fork following helper code.
John Baldwin [Sat, 25 Jun 2016 04:06:36 +0000 (21:06 -0700)] 
Move fbsd_resume and related functions below fork following helper code.

gdb/ChangeLog:

* fbsd-nat.c (super_resume): Move earlier next to "super_wait".
(resume_one_thread_cb): Move below fork following helper code.
(resume_all_threads_cb): Likewise.
(fbsd_resume): Likewise.

7 years agoHonor detach-on-fork on FreeBSD.
John Baldwin [Sat, 25 Jun 2016 01:24:21 +0000 (18:24 -0700)] 
Honor detach-on-fork on FreeBSD.

Only detach from the new child process in the follow fork callback
if detach_fork is true.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_follow_fork): Only detach child if
"detach_fork" is true.

7 years agoFix Thumb-2 BL detection
Thomas Preud'homme [Fri, 1 Jul 2016 15:13:25 +0000 (16:13 +0100)] 
Fix Thumb-2 BL detection

2016-07-01  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
* elf32-arm.c (using_thumb2_bl): New function.
(arm_type_of_stub): Declare thumb2 variable together and change type
to bfd_boolean.  Use using_thumb2_bl () to determine whether
THM_MAX_FWD_BRANCH_OFFSET or THM2_MAX_FWD_BRANCH_OFFSET should be
checked for BL range.
(elf32_arm_final_link_relocate): Use using_thumb2_bl () to determine
the bit size of BL offset.

ld/
* testsuite/ld-arm/arm-elf.exp (Thumb-2 BL): Assemble for ARMv7.
(Thumb-2 BL on ARMv6-M): New testcase.
* testsuite/ld-arm/thumb2-bl.d: Do not try to match testcase filename.
* testsuite/ld-arm/thumb2-bl.s: Do not select architecture.

7 years agoSet debug registers on all threads belonging to the current inferior.
John Baldwin [Tue, 28 Jun 2016 00:44:58 +0000 (17:44 -0700)] 
Set debug registers on all threads belonging to the current inferior.

gdb/ChangeLog:

* x86bsd-nat.c: Include 'gdbthread.h'.
(x86bsd_dr_set): Set debug registers on all threads belonging to
the current inferior.

7 years agoConsolidate x86 debug register code for BSD native targets.
John Baldwin [Mon, 27 Jun 2016 20:19:09 +0000 (13:19 -0700)] 
Consolidate x86 debug register code for BSD native targets.

Move the debug register support code from amd64bsd-nat.c and
i386bsd-nat.c into a shared x86bsd-nat.c.

Instead of setting up x86_dr_low in amd64fbsd-nat.c and
i386fbsd-nat.c, add a x86bsd_target function that creates a new target
that inherits from inf_ptrace and sets up x86 debug registers if
supported.  In addition to initializing x86_dr_low, the x86bsd target
installs a custom mourn_inferior target operation to clean up the
x86 debug register state.  Previously this was only done on amd64.
Now it will be done for both i386 and amd64.  The i386bsd_target and
amd64bsd_target functions create targets that inherit from x86bsd
rather than inf_ptrace.

gdb/ChangeLog:

* Makefile.in [HFILES_NO_SRCDIR]: Replace 'amd64bsd-nat.h' with
'x86bsd-nat.h'.
* amd64bsd-nat.c: Include 'x86bsd-nat.h' instead of
'amd64bsd-nat.h'.
(amd64bsd_xsave_len): Rename and move to x86bsd-nat.c.
(amd64bsd_fetch_inferior_registers): Replace 'amd64bsd_xsave_len'
with 'x86bsd_xsave_len'.
(amd64bsd_store_inferior_registers): Likewise.
(amd64bsd_target): Inherit from x86bsd_target.
(amd64bsd_dr_get): Rename and move to x86bsd-nat.c.
(amd64bsd_dr_set): Likewise.
(amd64bsd_dr_set_control): Likewise.
(amd64bsd_dr_set_addr): Likewise.
(amd64bsd_dr_get_addr): Likewise.
(amd64bsd_dr_get_status): Likewise.
(amd64bsd_dr_get_control): Likewise.
* amd64fbsd-nat.c: Include 'x86bsd-nat.h' instead of
'amd64bsd-nat.h'.
(super_mourn_inferior): Move to x86bsd-nat.c.
(amd64fbsd_mourn_inferior): Rename and move to x86bsd-nat.c.
(amd64fbsd_read_description): Replace 'amd64bsd_xsave_len' with
'x86bsd_xsave_len'.
(_initialize_amd64fbsd_nat): Remove x86 watchpoint setup and
mourn_inferior' target op.
* config/i386/fbsd.mh (NATDEPFILES): Add x86bsd-nat.o.
* config/i386/fbsd64.mh: Likewise.
* config/i386/nbsd64.mh: Likewise.
* config/i386/nbsdelf.mh: Likewise.
* config/i386/obsd.mh: Likewise.
* config/i386/obsd64.mh: Likewise.
* i386bsd-nat.c: Include 'x86bsd-nat.h'.
(i386bsd_xsave_len): Rename and move to x86bsd-nat.c.
(i386bsd_fetch_inferior_registers): Replace 'i386bsd_xsave_len'
with 'x86bsd_xsave_len'.
(i386bsd_store_inferior_registers): Likewise.
(i386bsd_target): Inherit from x86bsd_target.
(i386bsd_dr_get): Rename and move to x86bsd-nat.c.
(i386bsd_dr_set): Likewise.
(i386bsd_dr_set_control): Likewise.
(i386bsd_dr_set_addr): Likewise.
(i386bsd_dr_get_addr): Likewise.
(i386bsd_dr_get_status): Likewise.
(i386bsd_dr_get_control): Likewise.
* i386bsd-nat.h (i386bsd_xsave_len): Remove.
(i386bsd_dr_set_control): Remove.
(i386bsd_dr_set_addr): Remove.
(i386bsd_dr_get_addr): Remove.
(i386bsd_dr_get_status): Remove.
(i386bsd_dr_get_control): Remove.
* i386fbsd-nat.c: Include 'x86bsd-nat.h'.
(i386fbsd_read_description): Replace 'i386bsd_xsave_len' with
'x86bsd_xsave_len'.
(_initialize_i386fbsd_nat): Remove x86 watchpoint setup and
mourn_inferior' target op.
* x86bsd-nat.c: New file.
* x86bsd-nat.h: New file.

7 years agoFix potential buffer overflows with sprintf and very large integer values.
Nick Clifton [Fri, 1 Jul 2016 11:35:01 +0000 (12:35 +0100)] 
Fix potential buffer overflows with sprintf and very large integer values.

binutuils* prdbg.c (pr_enum_type): Use a buffer big enough to hold an
extremely large decimal value.
(pr_range_type): Likewise.
(pr_array_type): Likewise.
(pr_struct_field): Likewise.
(pr_class_baseclass): Likewise.
(pr_class_method_variant): Likewise.
(pr_tag_type): Likewise.
(pr_int_constant): Likewise.
(pr_typed_constant): Likewise.
(pr_variable): Likewise.
(pr_function_parameter): Likewise.
(pr_start_block): Likewise.
(pr_lineno): Likewise.
(pr_end_block): Likewise.
(tg_enum_type): Likewise.
(tg_int_constant): Likewise.
(tg_typed_constant): Likewise.
(tg_start_block): Likewise.

gas * macro.c (macro_expand_body): Use a buffer big enough to hold an
extremely large integer.

7 years agoExtend JIT-reader test and fix GDB problems that exposes
Pedro Alves [Fri, 1 Jul 2016 10:56:39 +0000 (11:56 +0100)] 
Extend JIT-reader test and fix GDB problems that exposes

The jit-reader.exp test isn't really exercising the jit-reader's
unwinder API at all.  This commit address that, and then fixes GDB
problems exposed.

- The custom JIT reader provided for the jit-reader.exp testcase
  always rejects the jitted function's frame...

  This is because the custom JIT reader in the testcase never ever
  sets state->code_begin/end, so the bounds check in
  gdb.base/jitreader.c:unwind_frame:

   if (this_ip >= state->code_end || this_ip < state->code_begin)
     return GDB_FAIL;

  tends to fail, unless you're "lucky" (because it references
  uninitialized data).

  The result is that GDB is always actually using a built-in unwinder
  for the jitted function.

- The provided unwinder doesn't do anything that GDB's built-in
  unwinder can't do.

  IOW, we can't really tell whether the JIT reader's unwinder is
  working or not.

  I fixed that by making the jitted function mangle its own stack
  pointer with a xor, and then teaching the jit unwinder to demangle
  it back (another xor).  So now "backtrace" with GDB's built-in
  unwinder fails while with the jit unwinder, it succeeds.

- GDB crashes after unloading the JIT reader, and flushing frames...

  I made the testcase use the "flushregs" command after unloading the
  JIT reader, to force the JIT frames to be flushed.  However, that
  crashes GDB...

  When reinit_frame_cache tears down a frame's cache, it calls its
  unwinder's dealloc_cache method, which for JIT frames ends up in
  jit.c:jit_dealloc_cache.  This function calls each of the frame's
  gdb_reg_value's "free" pointer:

   for (i = 0; i < gdbarch_num_regs (frame_arch); i++)
     if (priv_data->registers[i] && priv_data->registers[i]->free)
       priv_data->registers[i]->free (priv_data->registers[i]);

  and the problem is these gdb_reg_value instances have been returned
  by the JIT reader that has been already unloaded, and their "free"
  function pointers likely point to functions in the DSO that has
  already been unloaded...

  A fix for that could be to call reinit_frame_cache in
  jit_reader_unload_command _before_ unloading the jit reader DSO so
  that the jit reader is given a chance to clean up the gdb_reg_values
  before it is unloaded.  However, the fix for the point below makes
  this unnecessary, because it stops jit.c from keeping around
  gdb_reg_values in the first place.

- However, it still makes sense to clear the frame cache when loading
  or unloading a JIT unwinder.

  This makes testing a JIT unwinder a bit simpler.

- Not only the frame cache actually -- gdb is not unloading the
  jit-registered objfiles when the JIT reader is unloaded, and not
  loading the already-registered descriptors when a JIT reader is
  loaded.

  The new test exercises unloading the jit reader, loading it back
  again, and then making sure the JIT reader's unwinder works again.
  Without the unload/re-load of already-read descriptors, the newly
  loaded JIT would have no idea where the new function is, because
  it's stored at symbol read time.

- I added a couple "info frame" calls to the test, and that
  crashes GDB...

  The problem is that jit_frame_prev_register assumes it'll only be
  called for raw registers, so when it gets a pseudo register number,
  the "priv->registers[reg]" access is really an out-of-bounds access.

  To fix that, I made jit_frame_prev_register use
  gdbarch_pseudo_register_read_value for reading the pseudo-registers.
  However, that works with a regcache and we don't have one.  To fix
  that, I made the JIT unwinder store a regcache in its cache instead
  of an array of gdb_reg_value pointers.

gdb/ChangeLog:
2016-07-01  Pedro Alves  <palves@redhat.com>
    Tom Tromey  <tom@tromey.com>

* jit.c (jit_reader_load_command): Call reinit_frame_cache and
jit_inferior_created_hook.
(jit_reader_unload_command): Call reinit_frame_cache and
jit_inferior_exit_hook.
* jit.c (struct jit_unwind_private) <registers>: Delete field.
<regcache>: New field.
(jit_unwind_reg_set_impl): Set the register's value in the
regcache.  Free the passed-in gdb_reg_value.
(jit_dealloc_cache): Adjust to free the regcache.
(jit_frame_sniffer): Allocate a regcache instead of an array of
gdb_reg_value pointers.
(jit_frame_this_id): Adjust.
(jit_frame_prev_register): Read raw registers off of the regcache
instead of from the gdb_reg_value pointer array.  Use
gdbarch_pseudo_register_read_value to read pseudo registers.
* regcache.c (regcache_raw_set_cached_value): New function,
factored out from ...
(regcache_raw_write): ... here.
* regcache.h (regcache_raw_set_cached_value): Declare.

gdb/testsuite/ChangeLog:
2016-07-01  Pedro Alves  <palves@redhat.com>

* gdb.base/jit-reader.exp (info_registers_current_frame): New
procedure.
(jit_reader_test): Test the jit reader's unwinder.
* gdb.base/jithost.c (jit_function_00_code): New global.
(main): Use memcpy to fill in the mmapped code, instead of poking
bytes manually here.
* gdb.base/jitreader.c (enum register_mapping) <AMD64_RBP>: New
value.
(read_debug_info): Save the function's range.
(read_sp): New function.
(unwind_frame): Use it.  Also unwind RBP.
(get_frame_id): Use read_sp.
(gdb_init_reader): Use calloc instead of malloc.
* lib/gdb.exp (get_hexadecimal_valueof): Add optional 'test'
parameter.  Use gdb_test_multiple.

7 years agoFix failure to detach if process exits while detaching on Linux
Pedro Alves [Fri, 1 Jul 2016 10:16:33 +0000 (11:16 +0100)] 
Fix failure to detach if process exits while detaching on Linux

This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.

On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH.  Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them.  Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".

This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.

New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.

Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}

Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:

 (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
 continue
 Continuing.
 Warning:
 Could not insert hardware watchpoint 3.
 Could not insert hardware breakpoints:
 You may have requested too many hardware breakpoints/watchpoints.

 Command aborted.
 (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue

gdb/gdbserver/ChangeLog:
2016-07-01  Pedro Alves  <palves@redhat.com>
    Antoine Tremblay  <antoine.tremblay@ericsson.com>

* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void.  Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.

gdb/ChangeLog:
2016-07-01  Pedro Alves  <palves@redhat.com>
    Antoine Tremblay  <antoine.tremblay@ericsson.com>

* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.

gdb/testsuite/ChangeLog:
2016-07-01  Pedro Alves  <palves@redhat.com>
    Antoine Tremblay  <antoine.tremblay@ericsson.com>

* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.

7 years agoForget watchpoint locations when inferior exits or is killed/detached
Pedro Alves [Fri, 1 Jul 2016 10:16:32 +0000 (11:16 +0100)] 
Forget watchpoint locations when inferior exits or is killed/detached

If you have two inferiors (or more), set watchpoints in one of the
inferiors, and then that inferior exits, until you manually delete the
watchpoint (or something forces a breakpoint re-set), you can't resume
the other inferior.

This is exercised by the test added by this commit.  Without the GDB
fix, this test fails like this:

 FAIL: gdb.multi/watchpoint-multi-exit.exp: dispose=kill: continue to marker in inferior 1
 FAIL: gdb.multi/watchpoint-multi-exit.exp: dispose=detach: continue to marker in inferior 1
 FAIL: gdb.multi/watchpoint-multi-exit.exp: dispose=exit: continue to marker in inferior 1

and gdb.log shows (in all three cases):

 (gdb) continue
 Continuing.
 Warning:
 Could not insert hardware watchpoint 2.
 Could not insert hardware breakpoints:
 You may have requested too many hardware breakpoints/watchpoints.

 Command aborted.
 (gdb) FAIL: gdb.multi/watchpoint-multi-exit.exp: dispose=kill: continue to marker in inferior 1

The problem is that GDB doesn't forget about the locations of
watchpoints set in the inferior that is now dead.  When we try to
continue the inferior that is still alive, we reach
insert_breakpoint_locations, which has the the loop that triggers the
error:

  /* If we failed to insert all locations of a watchpoint, remove
     them, as half-inserted watchpoint is of limited use.  */

That loop finds locations that are not marked inserted, but which
according to should_be_inserted should have been inserted, and so
errors out.

gdb/ChangeLog:
2016-07-01  Pedro Alves  <palves@redhat.com>

* breakpoint.c (breakpoint_init_inferior): Discard watchpoint
locations.
* infcmd.c (detach_command): Call breakpoint_init_inferior.

gdb/testsuite/ChangeLog:
2016-07-01  Pedro Alves  <palves@redhat.com>

* gdb.multi/watchpoint-multi-exit.c: New file.
* gdb.multi/watchpoint-multi-exit.exp: New file.

7 years agoFactor out "Detaching from program" message printing
Pedro Alves [Fri, 1 Jul 2016 10:16:32 +0000 (11:16 +0100)] 
Factor out "Detaching from program" message printing

Several targets have a copy of the same code that prints

 "Detaching from program ..."

in their target_detach implementation.  Factor that out to a common
function.

(For now, I left the couple targets that print this a bit differently
alone.  Maybe this could be further pulled out into infcmd.c.  If we
did that, and those targets want to continue printing differently,
this new function could be converted to a target method.)

gdb/ChangeLog:
2016-07-01  Pedro Alves  <palves@redhat.com>

* darwin-nat.c (darwin_detach): Use target_announce_detach.
* inf-ptrace.c (inf_ptrace_detach): Likewise.
* nto-procfs.c (procfs_detach): Likewise.
* remote.c (remote_detach_1): Likewise.
* target.c (target_announce_detach): New function.
* target.h (target_announce_detach): New declaration.

7 years agoFix formatting of some previous gdb/testsuite/ChangeLog entries
Pedro Alves [Fri, 1 Jul 2016 10:24:21 +0000 (11:24 +0100)] 
Fix formatting of some previous gdb/testsuite/ChangeLog entries

7 years agoFix formatting of some previous gdb/ChangeLog entries
Pedro Alves [Fri, 1 Jul 2016 10:17:58 +0000 (11:17 +0100)] 
Fix formatting of some previous gdb/ChangeLog entries

7 years agoExpect the objcopy without global symbols test to fail for ARM and AArch64 targets.
Nick Clifton [Fri, 1 Jul 2016 09:32:45 +0000 (10:32 +0100)] 
Expect the objcopy without global symbols test to fail for ARM and AArch64 targets.

* testsuite/binutils-all/objcopy.exp
(objcopy_test_without_global_symbol): Expect this test to fail on
the AArch64 and ARM targets, since they preserve their mapping
symbols.

7 years agox86-64/MPX: relax no-RIP-relative-addressing testcase
Jan Beulich [Fri, 1 Jul 2016 09:17:30 +0000 (11:17 +0200)] 
x86-64/MPX: relax no-RIP-relative-addressing testcase

... for COFF targets.

7 years agoAdd marker for 2.27 branch.
Tristan Gingold [Fri, 1 Jul 2016 08:57:46 +0000 (10:57 +0200)] 
Add marker for 2.27 branch.

binutils/
2016-07-01  Tristan Gingold  <gingold@adacore.com>

* NEWS: Add marker for 2.27.

gas/
2016-07-01  Tristan Gingold  <gingold@adacore.com>

* NEWS: Add marker for 2.27.

ld/
2016-07-01  Tristan Gingold  <gingold@adacore.com>

* NEWS: Add marker for 2.27.

7 years agoFix mis-placement in binutils.texi
Tristan Gingold [Wed, 29 Jun 2016 10:09:06 +0000 (12:09 +0200)] 
Fix mis-placement in binutils.texi

binutils/
* doc/binutils.texi (objdump): Fix mis-placement.

7 years agox86-64/MPX: bndmk, bndldx, and bndstx don't allow RIP-relative addressing
Jan Beulich [Fri, 1 Jul 2016 07:07:15 +0000 (09:07 +0200)] 
x86-64/MPX: bndmk, bndldx, and bndstx don't allow RIP-relative addressing

Additionally warn about scaling factors other than 1 for the latter
two, as those get ignored by the hardware.

7 years agox86/MPX: fix address size handling
Jan Beulich [Fri, 1 Jul 2016 07:06:16 +0000 (09:06 +0200)] 
x86/MPX: fix address size handling

While address overrides are ignored in 64-bit mode (and hence shouldn't
really result in an error, but upon v1 converting this to a warning I
was told otherwise), trying to use 16-bit addressing is documented to
result in #UD, and hence the assembler should reject the attempt. (The
added test case at once also checks that bndc{l,n,u} won't accept
16-bit register operands.)

7 years agox86/Intel: don't accept bogus instructions
Jan Beulich [Fri, 1 Jul 2016 07:03:02 +0000 (09:03 +0200)] 
x86/Intel: don't accept bogus instructions

... due to their last byte looking like a suffix, when after its
stripping a matching instruction can be found. Since memory operand
size specifiers in Intel mode get converted into suffix representation
internally, we need to keep track of the actual mnemonic suffix which
may have got trimmed off, and check its validity while looking for a
matching template. I tripper over this quite some time again after
support for AMD's SSE5 instructions got removed, as at that point some
of the SSE5 mnemonics, other than expected, didn't fail to assemble.
But the problem affects many more instructions, namely (almost) all
MMX, SSE, and AVX ones as it looks. I don't think it makes sense to
add a testcase covering all of them, nor do I think it makes sense to
pick out some random examples for a new test case.

7 years agox86: allow suffix-less movzw and 64-bit movzb
Jan Beulich [Fri, 1 Jul 2016 07:01:41 +0000 (09:01 +0200)] 
x86: allow suffix-less movzw and 64-bit movzb

... just like is already the case for 16- and 32-bit movzb: I can't see
why omitting suffixes on this (and movs{b,w,l}) is not allowed, when it
is allowed for all other instructions where the suffix is redundant
with (one of) the operands.

7 years agox86: remove stray instruction attributes
Jan Beulich [Fri, 1 Jul 2016 06:57:21 +0000 (08:57 +0200)] 
x86: remove stray instruction attributes

- with Cpu64 Disp16 makes no sense for memory operands
- with CpuNo64 Disp32S makes no sense
- non-64-bit lgdt doesn't allow 10-byte operands

7 years agox86/Intel: fix operand checking for MOVSD
Jan Beulich [Fri, 1 Jul 2016 06:56:13 +0000 (08:56 +0200)] 
x86/Intel: fix operand checking for MOVSD

The dual purpose mnemonic (string move vs scalar double move) breaks
the assumption that the isstring flag would be set on both the first
and last entry in the current set of templates, which results in bogus
or missing diagnostics for the string move variant of the mnemonic.
Short of mostly rewriting i386_index_check() and its interaction with
the rest of the code, simply shrink the template set to just string
instructions when encountering the second memory operand, and run
i386_index_check() a second time for the first memory operand after
that reduction.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 1 Jul 2016 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoMIPS/GAS: Fix a comment typo in `get_append_method'
Maciej W. Rozycki [Thu, 30 Jun 2016 20:49:54 +0000 (21:49 +0100)] 
MIPS/GAS: Fix a comment typo in `get_append_method'

gas/
* config/tc-mips.c (get_append_method): Fix a comment typo.

7 years agoChangeLog entry for the --with-cpu patch for ARC configuration.
Andrew Burgess [Thu, 30 Jun 2016 15:53:20 +0000 (16:53 +0100)] 
ChangeLog entry for the --with-cpu patch for ARC configuration.

7 years agoFix typo in comment
Yao Qi [Thu, 30 Jun 2016 15:03:07 +0000 (16:03 +0100)] 
Fix typo in comment

This patch fixes the typo "uf" in the comment.  I'll push it in as the
change is obvious.

2016-06-30  Yao Qi  <yao.qi@linaro.org>

* arm-dis.c (print_insn): Fix typo in comment.

7 years agoMIPS16/GAS: Fix delay slot filling across frags
Matthew Fortune [Thu, 30 Jun 2016 14:02:20 +0000 (15:02 +0100)] 
MIPS16/GAS: Fix delay slot filling across frags

Fix an assertion failure like:

test.s: Assembler messages:
test.s:3: Internal error!
Assertion failure in append_insn at .../gas/config/tc-mips.c:7523.
Please report this bug.

triggered by assembling MIPS16 code like:

hello:
addiu $4, $4, 4
jr $31

with the generation of a listing file enabled, e.g.:

$ as -mips16 -O2 -aln=test.lst

The cause of the problem is the lack of support for moving instructions
across frags in MIPS16 jump swapping, which triggers more easily with
listing enabled as in that case every instruction gets placed in its own
frag.  It would trigger even with listing disabled though if the
instruction to swap a MIPS16 jump with was unfortunately enough placed
as last in a frag that became full.

This scenario is already handled correctly with branch swapping in
regular MIPS and microMIPS code, so reuse it for MIPS16 code as well,
and now that all MIPS16 handling has become the same as the regular MIPS
and microMIPS cases remove MIPS16 special casing altogether.

This effectively complements:

commit 464ab0e55ade01d2bb0b4fa45c429af7a2f85a26
Author: Maciej W. Rozycki <macro@linux-mips.org>
Date:   Mon Aug 6 20:33:00 2012 +0000

<https://sourceware.org/ml/binutils/2012-08/msg00043.html>, ("MIPS/GAS:
Correct microMIPS branch swapping assertion") for the MIPS16 case.

The assertion itself was introduced with:

commit 1e91584932efd70020c8c98037d0cb93a0552a20
Author: Richard Sandiford <rdsandiford@googlemail.com>
Date:   Wed Mar 9 09:17:02 2005 +0000

<https://sourceware.org/ml/binutils/2005-03/msg00217.html>, ("Rework
MIPS nop-insertion code, add -mfix-vr4130 [5/11]"), but its introduction
merely noted our existing lack of support for MIPS16 jump swapping
across frags.

gas/
* config/tc-mips.c (append_insn) <APPEND_SWAP>: Do not special
case MIPS16 handling.
* testsuite/gas/mips/branch-swap-3.d: New test.
* testsuite/gas/mips/branch-swap-4.d: New test.
* testsuite/gas/mips/mips16@branch-swap-3.d: New test.
* testsuite/gas/mips/mips16@branch-swap-4.d: New test.
* testsuite/gas/mips/micromips@branch-swap-3.d: New test.
* testsuite/gas/mips/micromips@branch-swap-4.d: New test.
* testsuite/gas/mips/branch-swap-3.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

7 years agoMIPS/GAS: Simplify non-MIPS16 branch swapping sequence
Maciej W. Rozycki [Thu, 30 Jun 2016 11:46:47 +0000 (12:46 +0100)] 
MIPS/GAS: Simplify non-MIPS16 branch swapping sequence

Simplify non-MIPS16 branch swapping by copying the MIPS16 variant, which
sets the new position for the current instruction first and reduces the
calculation of the new position of the previous instruction.  Also refer
to previous instruction's frag and position via `delay' for consistency.

Reintroduce an explanatory comment, updated, previously removed with:

commit 1e91584932efd70020c8c98037d0cb93a0552a20
Author: Richard Sandiford <rdsandiford@googlemail.com>
Date:   Wed Mar 9 09:17:02 2005 +0000

<https://sourceware.org/ml/binutils/2005-03/msg00217.html>, ("Rework
MIPS nop-insertion code, add -mfix-vr4130 [5/11]").

gas/
* config/tc-mips.c (append_insn): Simplify non-MIPS16 branch
swapping sequence.

7 years agoPR gas/20312: Do not pad sections to alignment on failed assembly
Maciej W. Rozycki [Wed, 29 Jun 2016 00:38:50 +0000 (01:38 +0100)] 
PR gas/20312: Do not pad sections to alignment on failed assembly

Correct a regression from commit 85024cd8bcb9 ("Run write_object_file
after errors") causing unsuccessful assembly, which may be due to any
reason, such as supplying a valid source like this:

.text
.byte 0
.err

to terminate with an assertion failure like:

test.s: Assembler messages:
test.s:3: Error: .err encountered
../as-new: BFD (GNU Binutils) 2.24.51.20140628 internal error, aborting at .../gas/write.c line 608 in size_seg
../as-new: Please report this bug.

on targets whose default text section alignment is above 0, typically
RISC machines.

This is due to an attempt to set last text section's frag alignment to
0, requested from `subsegs_finish_section' where `frag_align_code
(alignment, 0)' is called with `alignment' set to 0 rather than the
section alignment if `had_errors' has returned true.  The call to
`subsegs_finish_section' is made from `subsegs_finish' from
`write_object_file' at unsuccessful completion, which previously wasn't
made.

Always set last section's frag alignment from the section alignment
then, forcing no section padding instead if completing unsuccessfully,
so that in that case alignment padding is still suppressed from any
listing generated, fixing assertion failures for these targets:

alpha-linuxecoff  -FAIL: all pr20312
arm-aout  -FAIL: all pr20312
mips-freebsd  -FAIL: all pr20312
mips-img-linux  -FAIL: all pr20312
mips-linux  -FAIL: all pr20312
mips-mti-linux  -FAIL: all pr20312
mips-netbsd  -FAIL: all pr20312
mips-sgi-irix5  -FAIL: all pr20312
mips-sgi-irix6  -FAIL: all pr20312
mips-vxworks  -FAIL: all pr20312
mips64-freebsd  -FAIL: all pr20312
mips64-img-linux  -FAIL: all pr20312
mips64-linux  -FAIL: all pr20312
mips64-mti-linux  -FAIL: all pr20312
mips64-openbsd  -FAIL: all pr20312
mips64el-freebsd  -FAIL: all pr20312
mips64el-img-linux  -FAIL: all pr20312
mips64el-linux  -FAIL: all pr20312
mips64el-mti-linux  -FAIL: all pr20312
mips64el-openbsd  -FAIL: all pr20312
mipsel-freebsd  -FAIL: all pr20312
mipsel-img-linux  -FAIL: all pr20312
mipsel-linux  -FAIL: all pr20312
mipsel-mti-linux  -FAIL: all pr20312
mipsel-netbsd  -FAIL: all pr20312
mipsel-vxworks  -FAIL: all pr20312
mipsisa32-linux  -FAIL: all pr20312
mipsisa32el-linux  -FAIL: all pr20312
mipsisa64-linux  -FAIL: all pr20312
mipsisa64el-linux  -FAIL: all pr20312
sh-pe  -FAIL: all pr20312
sparc-aout  -FAIL: all pr20312

gas/
PR gas/20312
* write.c (subsegs_finish_section): Force no section padding to
alignment on failed assembly, always set last frag's alignment
from section.
* testsuite/gas/all/pr20312.l: New list test.
* testsuite/gas/all/pr20312.s: New test source.
* testsuite/gas/all/gas.exp: Run the new test

7 years agoFix gdbserver/MI testing regression
Pedro Alves [Thu, 30 Jun 2016 10:55:22 +0000 (11:55 +0100)] 
Fix gdbserver/MI testing regression

Commit 51f77c3704a6 ("Add testing infrastruture bits for running with
MI on a separate UI") broke MI testing with native-gdbserver:

 $ make check RUNTESTFLAGS="--target_board=native-gdbserver mi-var-child.exp"
 ...
 Running .../src/binutils-gdb/gdb/testsuite/gdb.mi/mi-var-child.exp ...
 can't unset "inferior_spawn_id": no such variable
     while executing
 "unset inferior_spawn_id"
     (procedure "close_gdbserver" line 20)
     invoked from within
 "close_gdbserver"
 ...

When testing with gdbserver, gdb_exit is overridden with a special
version that calls close_gdbserver, which clears inferior_spawn_id.
The problem is that the commit mentioned above made
gdb_exit/mi_gdb_exit clear inferior_spawn_id too, and clearing a
non-existing variable is a tcl error.

Since gdb_exit/mi_gdb_exit always clears inferior_spawn_id now, the
fix is simply to stop clearing it in close_gdbserver.

gdb/testsuite/
2016-06-30  Pedro Alves  <palves@redhat.com>

* lib/gdbserver-support.exp (close_gdbserver, gdb_exit): Don't
unset inferior_spawn_id.

7 years agoMake testing gdb with FORCE_SEPARATE_MI_TTY=1 actually work
Pedro Alves [Thu, 30 Jun 2016 10:55:21 +0000 (11:55 +0100)] 
Make testing gdb with FORCE_SEPARATE_MI_TTY=1 actually work

Runing the whole gdb testsuite with MI on a separate tty, with:

  make check RUNTESTFLAGS="FORCE_SEPARATE_MI_TTY=1"

Doesn't actually work because commit 51f77c3704a6 ("Add testing
infrastruture bits for running with MI on a separate UI") included a
last-minute rename typo, now fixed with this commit.

gdb/testsuite/ChangeLog:
2016-06-30  Pedro Alves  <palves@redhat.com>

* lib/mi-support.exp (default_mi_gdb_start): Declare global
FORCE_SEPARATE_MI_TTY, not SEPARATE_MI_TTY.

7 years agoAllow ARC target to be configured with --with-cpu=<cpu-name>.
Andrew Burgess [Thu, 30 Jun 2016 10:14:41 +0000 (11:14 +0100)] 
Allow ARC target to be configured with --with-cpu=<cpu-name>.

gas * config.in (TARGET_WITH_CPU): Undefine.
* configure.ac: Add --with-cpu support, and define in config.h.
* configure: Regenerate.
* config/tc-arc.c: Use TARGET_WITH_CPU to select default CPU.
* NEWS: Mention new configure option.

7 years ago[ARM][GAS] ARMv8.2 should enable ARMv8.1 NEON instructions.
Matthew Wahab [Thu, 30 Jun 2016 09:46:51 +0000 (10:46 +0100)] 
[ARM][GAS] ARMv8.2 should enable ARMv8.1 NEON instructions.

GAS fails to recognize march=armv8.2-a as a superset of march=armv8.1-a
when assembling NEON instructions. The patch corrects this, making
-march=armv8.2-a -mfpu=neon-fp-armv8 enable the NEON intructions
introduced with ARMv8.1-A.

include/
2016-06-30  Matthew Wahab  <matthew.wahab@arm.com>

* opcode/arm.h (ARM_ARCH_V8_2a): Add FPU_NEON_EXT_RDMA to the set
of enabled FPU features.

gas/
2016-06-30  Matthew Wahab  <matthew.wahab@arm.com>

* testsuite/gas/arm/armv8_2+rdma.d: New.

7 years agoAdd support for simulating big-endian AArch64 binaries.
Jim Wilson [Thu, 30 Jun 2016 08:10:41 +0000 (09:10 +0100)] 
Add support for simulating big-endian AArch64 binaries.

* cpustate.h: Include config.h.
(union GRegisterValue): Add WORDS_BIGENDIAN check.  For big endian code
use anonymous structs to align members.
* simulator.c (aarch64_step): Use sim_core_read_buffer and
endian_le2h_4 to read instruction from pc.

7 years agoFix gold testsuite failure with GCC 6.
Cary Coutant [Thu, 30 Jun 2016 06:24:35 +0000 (23:24 -0700)] 
Fix gold testsuite failure with GCC 6.

With GCC 6 when not using -static-libstdc++, the operator delete(void*)
function is defined in the shared C++ support library, rather than in
the main program. The test script is too aggressive in checking for
this symbol's presence among the exported symbols. This patch removes
the check for that symbol.

gold/
PR gold/20310
* testsuite/dynamic_list.sh: Remove check for _ZdlPv.

7 years agoUpdate "make clean" in gold/testsuite.
Cary Coutant [Thu, 30 Jun 2016 06:16:24 +0000 (23:16 -0700)] 
Update "make clean" in gold/testsuite.

gold/
* testsuite/Makefile.am (MOSTLYCLEANFILES): Add eh_test_2.
* testsuite/Makefile.in: Regenerate.

7 years ago[GOLD] Pass -Wl,-z to gcc, not plain -z
Alan Modra [Wed, 29 Jun 2016 09:07:27 +0000 (18:37 +0930)] 
[GOLD] Pass -Wl,-z to gcc, not plain -z

* testsuite/Makefile.am (memory_test, memory_test_2): Pass
-Wl,-z to gcc, not plain -z.
* testsuite/Makefile.in: Regenerate.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 30 Jun 2016 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoAdd copyright header in gdb.base/return.c
Yao Qi [Wed, 29 Jun 2016 16:33:19 +0000 (17:33 +0100)] 
Add copyright header in gdb.base/return.c

gdb/testsuite:

2016-06-29  Yao Qi  <yao.qi@linaro.org>

* gdb.base/return.c: Add copyright header.

7 years agoDefault to --enable-compressed-debug-sections=gas for Linux/x86
H.J. Lu [Wed, 29 Jun 2016 16:29:39 +0000 (09:29 -0700)] 
Default to --enable-compressed-debug-sections=gas for Linux/x86

--enable-compressed-debug-sections=gas added to binutils 2.26.  Make it
default for Linux/x86 targets in 2.27.

* NEWS: Mention --enable-compressed-debug-sections=gas is the
default for Linux/x86 targets.
* configure.tgt (ac_default_compressed_debug_sections): Default
to yes for Linux/x86 targets.

7 years agoFix PR python/20129 - use of non-existing variable
Tom Tromey [Mon, 6 Jun 2016 17:21:15 +0000 (11:21 -0600)] 
Fix PR python/20129 - use of non-existing variable

PR python/20129 concerns the error message one gets from a command
like "disable frame-filter global NoSuchFilter".  Currently this
throws a second, unexpected, exception due to the use of a
non-existing variable named "name".

This patch adds regression tests and fixes a couple of spots to use
the correct variable name.

Built and regtested on x86-64 Fedora 23.

2016-06-29  Tom Tromey  <tom@tromey.com>

PR python/20129:
* python/lib/gdb/command/frame_filters.py (_do_enable_frame_filter)
(SetFrameFilterPriority._set_filter_priority): Use "frame_filter",
not "name".

2016-06-29  Tom Tromey  <tom@tromey.com>

PR python/20129:
* gdb.python/py-framefilter.exp: Add tests for setting priority
and disabling of non-existent frame filter.

7 years agoPR gdb/17210 - fix possible memory leak in read_memory_robust
Tom Tromey [Thu, 9 Jun 2016 15:46:53 +0000 (09:46 -0600)] 
PR gdb/17210 - fix possible memory leak in read_memory_robust

PR gdb/17210 concerns a possible memory leak in read_memory_robust.
The bug can happen because read_memory_robust allocates memory, does
not install any cleanups, and invokes QUIT.  Similarly, target_read
calls QUIT, so it too can potentially throw.

The fix is to install cleanups to guard the allocated memory.

Built and regtested on x86-64 Fedora 23.  I couldn't think of a way to
test this, so no new test; and of course this means it should have
more careful review.

2016-06-29  Tom Tromey  <tom@tromey.com>

PR gdb/17210:
* target.c (free_memory_read_result_vector): Take a pointer to the
VEC as an argument.
(read_memory_robust): Install a cleanup for "result".
* mi/mi-main.c (mi_cmd_data_read_memory_bytes): Update.

7 years agogold: Support 386 TLS code sequences without PLT
H.J. Lu [Wed, 29 Jun 2016 15:38:43 +0000 (08:38 -0700)] 
gold: Support 386 TLS code sequences without PLT

There are extensions to 386 psABI:

https://groups.google.com/forum/#!topic/ia32-abi/awsRSvJOJfs

to call tls_get_addr via GOT:

call *___tls_get_addr@GOT(%reg)

where EBX register isn't required as GOT base.

Since direct call is 4-byte long and indirect call, is 5-byte long, the
extra one byte must be handled properly.

For general dynamic model, 7-byte lea instruction before call
instruction is replaced by 6-byte one to make room for indirect call.
For local dynamic model, we simply use 5-byte indirect call.

TLS linker optimization is updated to recognize new instruction
patterns.  For local dynamic model to local exec model transition,
we generate a 6-byte lea instruction as nop, instead of a 1-byte nop
plus a 4-byte lea instruction.

PR gold/20308
* i386.cc (Target_i386::Relocate::relocate): Allow
R_386_GOT32X relocation against ___tls_get_addr.
(Target_i386::Relocate::tls_gd_to_ie): Support indirect
call to __tls_get_addr.
(Target_i386::Relocate::tls_gd_to_le): Likewise.
(Target_i386::Relocate::tls_ld_to_le): Likewise.
* testsuite/Makefile.am (check_PROGRAMS): Add pr20308a_test,
pr20308b_test, pr20308c_test, pr20308d_test, pr20308e_test.
(pr20308a_test_SOURCES): New.
(pr20308a_test_DEPENDENCIES): Likewise.
(pr20308a_test_CFLAGS): Likewise.
(pr20308a_test_LDFLAGS): Likewise.
(pr20308a_test_LDADD): Likewise.
(pr20308b_test_SOURCES): Likewise.
(pr20308b_test_DEPENDENCIES): Likewise.
(pr20308b_test_CFLAGS): Likewise.
(pr20308b_test_LDFLAGS): Likewise.
(pr20308b_test_LDADD): Likewise.
(pr20308c_test_SOURCES): Likewise.
(pr20308c_test_DEPENDENCIES): Likewise.
(pr20308c_test_CFLAGS): Likewise.
(pr20308c_test_LDFLAGS): Likewise.
(pr20308c_test_LDADD): Likewise.
(pr20308d_test_SOURCES): Likewise.
(pr20308d_test_DEPENDENCIES): Likewise.
(pr20308d_test_CFLAGS): Likewise.
(pr20308d_test_LDFLAGS): Likewise.
(pr20308d_test_LDADD): Likewise.
(pr20308e_test_SOURCES): Likewise.
(pr20308e_test_DEPENDENCIES): Likewise.
(pr20308e_test_CFLAGS): Likewise.
(pr20308e_test_LDFLAGS): Likewise.
(pr20308e_test_LDADD): Likewise.
(pr20308a.so): Likewise.
(pr20308b.so): Likewise.
(pr20308_gd.o): Likewise.
(pr20308_ld.o): Likewise.
(MOSTLYCLEANFILES): Add pr20308a.so pr20308b.so.
* testsuite/Makefile.in: Regenerated.
* testsuite/pr20308_def.c: New file.
* testsuite/pr20308_gd.S: Likewise.
* testsuite/pr20308_ld.S: Likewise.
* testsuite/pr20308_main.c: Likewise.

7 years agogold: Support x86-64 TLS code sequences without PLT
H.J. Lu [Wed, 29 Jun 2016 15:37:30 +0000 (08:37 -0700)] 
gold: Support x86-64 TLS code sequences without PLT

There are extensions to x86-64 psABI:

https://groups.google.com/forum/#!topic/x86-64-abi/de5_KnLHxtI

to call tls_get_addr via GOT:

call *__tls_get_addr@GOTPCREL(%rip)

Since direct call is 4-byte long and indirect call, is 5-byte long, the
extra one byte must be handled properly.

For general dynamic model, one 0x66 prefix before call instruction is
removed to make room for indirect call.  For local dynamic model, we
simply use 5-byte indirect call.

TLS linker optimization is updated to recognize new instruction
patterns.  For local dynamic model to local exec model transition, we
generate 4 0x66 prefixes, instead of 3, before mov instruction in 64-bit
and generate a 5-byte nop, instead of 4-byte, before mov instruction in
32-bit.

PR gold/20216
* configure.ac (DEFAULT_TARGET_X86_64_OR_X32): New
AM_CONDITIONAL.
* configure: Regenerated.
* x86_64.cc (Target_x86_64<size>::Relocate::relocate): Allow
R_X86_64_GOTPCRELX relocation against __tls_get_addr.
(Target_x86_64<size>::Relocate::tls_gd_to_ie): Support indirect
call to __tls_get_addr.
(Target_x86_64<size>::Relocate::tls_gd_to_le): Likewise.
(Target_x86_64<size>::Relocate::tls_ld_to_le): Likewise.
* testsuite/Makefile.am (check_PROGRAMS): Add pr20216a_test,
pr20216b_test, pr20216c_test, pr20216d_test, pr20216e_test.
(pr20216a_test_SOURCES): New.
(pr20216a_test_DEPENDENCIES): Likewise.
(pr20216a_test_CFLAGS): Likewise.
(pr20216a_test_LDFLAGS): Likewise.
(pr20216a_test_LDADD): Likewise.
(pr20216b_test_SOURCES): Likewise.
(pr20216b_test_DEPENDENCIES): Likewise.
(pr20216b_test_CFLAGS): Likewise.
(pr20216b_test_LDFLAGS): Likewise.
(pr20216b_test_LDADD): Likewise.
(pr20216c_test_SOURCES): Likewise.
(pr20216c_test_DEPENDENCIES): Likewise.
(pr20216c_test_CFLAGS): Likewise.
(pr20216c_test_LDFLAGS): Likewise.
(pr20216c_test_LDADD): Likewise.
(pr20216d_test_SOURCES): Likewise.
(pr20216d_test_DEPENDENCIES): Likewise.
(pr20216d_test_CFLAGS): Likewise.
(pr20216d_test_LDFLAGS): Likewise.
(pr20216d_test_LDADD): Likewise.
(pr20216e_test_SOURCES): Likewise.
(pr20216e_test_DEPENDENCIES): Likewise.
(pr20216e_test_CFLAGS): Likewise.
(pr20216e_test_LDFLAGS): Likewise.
(pr20216e_test_LDADD): Likewise.
(pr20216a.so): Likewise.
(pr20216b.so): Likewise.
(pr20216_gd.o): Likewise.
(pr20216_ld.o): Likewise.
(MOSTLYCLEANFILES): Add pr20216a.so pr20216b.so.
* testsuite/Makefile.in: Regenerated.
* testsuite/pr20216_def.c: New file.
* testsuite/pr20216_gd.S: Likewise.
* testsuite/pr20216_ld.S: Likewise.
* testsuite/pr20216_main.c: Likewise.

7 years agoInitialize strtok_r's saveptr to NULL
Manish Goregaokar [Wed, 29 Jun 2016 11:39:43 +0000 (17:09 +0530)] 
Initialize strtok_r's saveptr to NULL

Building gdb with --enable-build-with-cxx=no trips on a warning:

 ../../binutils-gdb/gdb/rust-lang.c:173:15: error: saveptr may be used
 uninitialized in this function [-Werror=maybe-uninitialized]
     ret.name = concat (TYPE_NAME (type), "::", token, (char *) NULL);

The problem is that gcc doesn't understand that "tail" can never be
NULL in the call to strtok_r:

      name = xstrdup (TYPE_FIELD_NAME (type, 0));
      cleanup = make_cleanup (xfree, name);
      tail = name + strlen (RUST_ENUM_PREFIX);
...
      for (token = strtok_r (tail, "$", &saveptr);

Fix this by always initializing saveptr.

2016-06-29  Manish Goregaokar  <manish@mozilla.com>

gdb/ChangeLog:
    * rust-lang.c (rust_get_disr_info): Initialize saveptr to NULL.

7 years agoSet unknown_syscall differently on arm linux
Yao Qi [Wed, 29 Jun 2016 13:51:41 +0000 (14:51 +0100)] 
Set unknown_syscall differently on arm linux

Currently, we use 123456789 as unknown or illegal syscall number, and
expect program return ENOSYS.  Although 123456789 is an illegal syscall
number on arm linux, kernel sends SIGILL rather than returns -ENOSYS.
However, arm linux kernel returns -ENOSYS if syscall number is within
0xf0001..0xf07ff, so we can use 0xf07ff for unknown_syscall in test.

gdb/testsuite:

2016-06-29  Yao Qi  <yao.qi@linaro.org>

* gdb.base/catch-syscall.c [__arm__]: Set unknown_syscall to
0x0f07ff.

7 years agosparc: make SPARC_OPCODE_ARCH_MAX part of its enum
Trevor Saunders [Fri, 27 May 2016 08:52:45 +0000 (04:52 -0400)] 
sparc: make SPARC_OPCODE_ARCH_MAX part of its enum

include/ChangeLog:

2016-06-29  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* opcode/sparc.h (enum sparc_opcode_arch_val): Move
SPARC_OPCODE_ARCH_MAX into the enum.

7 years agoUse strtok_r instead of strsep in rust_get_disr_info
Manish Goregaokar [Wed, 29 Jun 2016 10:12:28 +0000 (15:42 +0530)] 
Use strtok_r instead of strsep in rust_get_disr_info

strsep doesn't exist on Windows.

2016-06-29  Manish Goregaokar  <manish@mozilla.com>

gdb/ChangeLog:
    * rust-lang.c (rust_get_disr_info): Use strtok_r instead of strsep.

7 years agoPreserve all mapping symbols in ARM and AArch64 object files.
Nick Clifton [Wed, 29 Jun 2016 10:17:40 +0000 (11:17 +0100)] 
Preserve all mapping symbols in ARM and AArch64 object files.

bfd * elfnn-aarch64.c (is_aarch64_mapping_symbol): New function.
Returns TRUE for AArch64 mapping symbols.
(elfNN_aarch64_backend_symbol_processing): New function.  Marks
mapping symbols as precious in object files so that they will not
be stripped.
(elf_backend_symbol_processing): Define.

* elf32-arm.c (is_arm_mapping_symbol): New function.  Returns TRUE
for ARM mapping symbols.
(elf32_arm_backend_symbol_processing): Make use of the new function.

7 years agoCorrect fix for typo
Nick Clifton [Wed, 29 Jun 2016 08:09:03 +0000 (09:09 +0100)] 
Correct fix for typo

7 years agoFix typo
Nick Clifton [Wed, 29 Jun 2016 08:06:55 +0000 (09:06 +0100)] 
Fix typo

7 years agoGAS: Fix `abort' expansion in write.c
Maciej W. Rozycki [Tue, 28 Jun 2016 16:33:38 +0000 (17:33 +0100)] 
GAS: Fix `abort' expansion in write.c

Remove an internal diagnostic regression introduced with the inclusion of
"libbfd.h" from write.c, added with:

commit e7ff5c732e7b95aafccd0910ea1a5cb8251a1033
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Feb 16 03:40:17 2007 +0000

That change made "libbfd.h" override the `abort' definition provided by
"as.h" earlier on, making the message produced by any calls reached from
write.c, which is a part of the GAS proper, look like they came from
BFD, e.g.:

.../gas/testsuite/gas/elf/type.s: Assembler messages:
.../gas/testsuite/gas/elf/type.s:30: Error: symbol type "gnu_unique_object" is supported only by GNU targets
../as-new: BFD (GNU Binutils) 2.26.51.20160628 internal error, aborting at .../gas/write.c:608 in size_seg

../as-new: Please report this bug.

vs:

.../gas/testsuite/gas/elf/type.s: Assembler messages:
.../gas/testsuite/gas/elf/type.s:30: Error: symbol type "gnu_unique_object" is supported only by GNU targets
.../gas/testsuite/gas/elf/type.s: Internal error, aborting at .../gas/write.c:602 in size_seg
Please report this bug.

With the removal of "libbfd.h" restore the latter message format.

gas/
* write.c: Remove "libbfd.h" inclusion.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 29 Jun 2016 00:00:26 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years ago[GOLD] Modify script_test_12
Alan Modra [Tue, 28 Jun 2016 22:30:58 +0000 (08:00 +0930)] 
[GOLD] Modify script_test_12

Changes necessary to make this test pass on powerpc64.

* script_test_12.t: Delete .plt, specify 64k page size.
* script_test_12i.t: Likewise.

7 years ago[GOLD] alignment test
Alan Modra [Tue, 28 Jun 2016 22:30:15 +0000 (08:00 +0930)] 
[GOLD] alignment test

PowerPC gcc aligns char arrays to a word which results in the test
failing since it expects a char alignment.  As the test already uses
gcc attributes to assign variables to sections, we may as well use an
attribute to align too.

* testsuite/plugin_layout_with_alignment.c: Explicitly align all
variables.

7 years ago[GOLD] Disable copy_test_protected on powerpc
Alan Modra [Tue, 28 Jun 2016 22:29:34 +0000 (07:59 +0930)] 
[GOLD] Disable copy_test_protected on powerpc

A target like powerpc64 that is PIC by default doesn't need copy relocs.

* testsuite/Makefile.am (copy_test_protected): Disable for powerpc.
* testsuite/Makefile.in: Regenerate.

7 years agoFix execute permission on gold/testsuite/script_test_14.sh.
Cary Coutant [Tue, 28 Jun 2016 22:44:22 +0000 (15:44 -0700)] 
Fix execute permission on gold/testsuite/script_test_14.sh.

7 years agoImplement the R_AARCH64_NONE relocation.
Igor Kudrin [Tue, 28 Jun 2016 22:43:43 +0000 (15:43 -0700)] 
Implement the R_AARCH64_NONE relocation.

According to "ELF for the ARM(r) 64-bit Architecture (AArch64)",
this relocation can be used "to prevent removal of sections that
might otherwise appear to be unused."

gold/
* aarch64-reloc.def (NONE): New relocation.
* aarch64.cc (Target_aarch64::Scan::local): Handle R_AARCH64_NONE.
(Target_aarch64::Scan::global): Likewise.
* testsuite/Makefile.am (aarch64_reloc_none): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/aarch64_reloc_none.s: New test source file.
* testsuite/aarch64_reloc_none.sh: New test script.

7 years agoConvert indirect calls to direct when possible.
Sriraman Tallam [Tue, 28 Jun 2016 22:42:33 +0000 (15:42 -0700)] 
Convert indirect calls to direct when possible.

Please see patch discussion:
https://www.sourceware.org/ml/binutils/2016-05/msg00322.html

2016-06-28  Sriraman Tallam  <tmsriram@google.com>

* x86_64.cc (Lazy_view): New class.
(can_convert_mov_to_lea): Templatize function.  Make the function
check for appropriate relocation types and use the view parameter
to get section contents.
(can_convert_callq_to_direct): New function.
(Target_x86_64<size>::Scan::global): Refactor.
(Target_x86_64<size>::Relocate::relocate): Refactor. Change any indirect
call via GOT that can be converted.
* testsuite/Makefile.am (x86_64_indirect_call_to_direct.sh): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/x86_64_indirect_call_to_direct1.s: New file.
* testsuite/x86_64_indirect_jump_to_direct1.s: New file.

7 years agoImplement SORT_BY_INIT_PRIORITY.
Igor Kudrin [Tue, 28 Jun 2016 22:34:11 +0000 (15:34 -0700)] 
Implement SORT_BY_INIT_PRIORITY.

2016-06-28  Igor Kudrin  <ikudrin@accesssoftek.com>

gold/
PR gold/18098
* script-c.h (Sort_wildcard): Add SORT_WILDCARD_BY_INIT_PRIORITY.
* script-sections.cc (Input_section_sorter::get_init_priority): New method.
(Input_section_sorter::operator()): Handle SORT_WILDCARD_BY_INIT_PRIORITY.
(Output_section_element_input::print): Likewise.
* script.cc (script_keyword_parsecodes): Add entry SORT_BY_INIT_PRIORITY.
* yyscript.y (SORT_BY_INIT_PRIORITY): New token.
(wildcard_section): Handle SORT_BY_INIT_PRIORITY.

* testsuite/Makefile.am (script_test_14): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/script_test_14.s: New test source file.
* testsuite/script_test_14.sh: New test script.
* testsuite/script_test_14.t: New test linker script.

7 years agoImplement SORT_BY_INIT_PRIORITY.
Igor Kudrin [Tue, 28 Jun 2016 20:56:05 +0000 (13:56 -0700)] 
Implement SORT_BY_INIT_PRIORITY.

2016-06-28  Igor Kudrin  <ikudrin@accesssoftek.com>

gold/
PR gold/18098
* script-c.h (Sort_wildcard): Add SORT_WILDCARD_BY_INIT_PRIORITY.
* script-sections.cc (Input_section_sorter::get_init_priority): New method.
(Input_section_sorter::operator()): Handle SORT_WILDCARD_BY_INIT_PRIORITY.
(Output_section_element_input::print): Likewise.
* script.cc (script_keyword_parsecodes): Add entry SORT_BY_INIT_PRIORITY.
* yyscript.y (SORT_BY_INIT_PRIORITY): New token.
(wildcard_section): Handle SORT_BY_INIT_PRIORITY.

* testsuite/Makefile.am (script_test_14): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/script_test_14.s: New test source file.
* testsuite/script_test_14.sh: New test script.
* testsuite/script_test_14.t: New test linker script.

7 years ago[TILEPro] Don't build gdb
Walter Lee [Tue, 28 Jun 2016 18:15:32 +0000 (14:15 -0400)] 
[TILEPro] Don't build gdb

In configure.ac, add gdb to noconfigdirs for TILEPro.

       * configure.ac (tilepro-*-*): Add gdb to noconfigdirs.
       * configure: Regenerate.

7 years ago[AArch64] Use int64_t for address offset
Yao Qi [Tue, 28 Jun 2016 16:24:25 +0000 (17:24 +0100)] 
[AArch64] Use int64_t for address offset

In AArch64 displaced stepping and fast tracepoint, GDB/GDBserver needs
to check whether the offset can fit in the range.  We are using int32_t
for offset, it is sufficient to get an offset from an instruction, but
it is not enough to get an offset from two addresses.  For example,
we have a BL in shared lib which is at 0x0000002000040774, and the
scratch pad for displaced stepping is at 0x400698.  The offset can't
fit in 28 bit imm.  However, since we are using int32_t for offset, GDB
thinks the offset can fit it, and generate the B instruction with wrong
offset.

It fixes the following fail,

-FAIL: gdb.base/dso2dso.exp: next over call to sub2

gdb:

2016-06-28  Yao Qi  <yao.qi@linaro.org>

* aarch64-tdep.c (aarch64_displaced_step_b): Use int64_t for
variable new_offset.

gdb/gdbserver:

2016-06-28  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_ftrace_insn_reloc_b): Use int64_t
for variable new_offset.
(aarch64_ftrace_insn_reloc_b_cond): Likewise.
(aarch64_ftrace_insn_reloc_cb): Likewise.
(aarch64_ftrace_insn_reloc_tb): Likewise.
(aarch64_install_fast_tracepoint_jump_pad): Likewise.  Use
PRIx64 instead of PRIx32.

7 years agoFix typo in previous commit
Nick Clifton [Tue, 28 Jun 2016 16:03:11 +0000 (17:03 +0100)] 
Fix typo in previous commit

7 years agoSkip version check for unreferenced and undefined symbol
H.J. Lu [Tue, 28 Jun 2016 15:08:04 +0000 (08:08 -0700)] 
Skip version check for unreferenced and undefined symbol

No need to check version if symbol is unreferenced and undefined.

bfd/

PR ld/20306
* elflink.c (elf_link_check_versioned_symbol): Return false
for unreferenced undefined symbol.

ld/testsuite/

* testsuite/ld-gc/gc.exp: Run pr20306 test.
* ld-gc/pr20306.c: New file.
* ld-gc/pr20306.d: Likewise.

7 years agoFix more linker testsuite failures.
Nick Clifton [Tue, 28 Jun 2016 14:55:22 +0000 (15:55 +0100)] 
Fix more linker testsuite failures.

bfin * elf32-bfin.c (bfin_adjust_dynamic_symbol): Fail if a COPY reloc
is needed.

ld * testsuite/ld-elf/comm-data.exp: Expect comm-data2 test to fail
for bfin.
* testsuite/ld-elf/elf.exp: Expect pr14170 and symbolic function
tests to fail for bfin.
* testsuite/ld-elf/endsym.d: Expect to fail with cr16, crx, dlx,
nds32 and visium.
* testsuite/ld-elf/var1.d: Expect to fail with d30v, dlx, ft32 and
microblaze.
* testsuite/ld-pe/pe.exp: Expect foreign symbol test to fail for
mcore-pe.

7 years agoRelax previous restriction on running binutils ar tests for Alpha targets, allowing...
Nick Clifton [Tue, 28 Jun 2016 13:05:34 +0000 (14:05 +0100)] 
Relax previous restriction on running binutils ar tests for Alpha targets, allowing the tests to be run for ELF variants.

* testsuite/binutils-all/ar.exp: Relax previous restriction on
Alpha targets.  Allow ELF based Alpha targets.

7 years agoUse `supports_gnu_unique' with the `unique_symbol' and `type' tests
Maciej W. Rozycki [Tue, 28 Jun 2016 12:21:36 +0000 (13:21 +0100)] 
Use `supports_gnu_unique' with the `unique_symbol' and `type' tests

Complement commit a43942db49b0 ("LD/ELF: Unify STB_GNU_UNIQUE handling")
and use `supports_gnu_unique' with the `unique_symbol' and `type' tests,
fixing failures like:

.../binutils/testsuite/binutils-all/unique.s: Assembler messages:
.../binutils/testsuite/binutils-all/unique.s:2: Error: symbol type "gnu_unique_object" is supported only by GNU targets

ERROR: .../binutils/testsuite/binutils-all/unique.s: assembly failed
UNRESOLVED: ar unique symbol in archive
.../binutils/ar -s -r -c tmpdir/artest.a tmpdir/unique.o
Executing on host: .../binutils/ar -s -r -c tmpdir/artest.a tmpdir/unique.o   (timeout = 300)
.../binutils/ar: tmpdir/unique.o: No such file or directory

FAIL: ar unique symbol in archive

and:

.../gas/testsuite/gas/elf/type.s: Assembler messages:
.../gas/testsuite/gas/elf/type.s:30: Error: symbol type "gnu_unique_object" is supported only by GNU targets
../as-new: BFD (GNU Binutils) 2.26.51.20160628 internal error, aborting at .../gas/write.c:608 in size_seg

../as-new: Please report this bug.

.../gas/testsuite/../../binutils/readelf -s dump.o | grep "1 *\[FIONTCU\]" > dump.out
Executing on host: sh -c {.../gas/testsuite/../../binutils/readelf -s dump.o >readelf.out 2>gas.stderr}  /dev/null  (timeout = 300)
readelf: Error: dump.o: Failed to read file's magic number
FAIL: elf type list

on MIPS/FreeBSD targets:

mips-freebsd  -FAIL: ar unique symbol in archive
mips-freebsd  -FAIL: elf type list
mips64-freebsd  -FAIL: ar unique symbol in archive
mips64-freebsd  -FAIL: elf type list
mips64el-freebsd  -FAIL: ar unique symbol in archive
mips64el-freebsd  -FAIL: elf type list
mipsel-freebsd  -FAIL: ar unique symbol in archive
mipsel-freebsd  -FAIL: elf type list

binutils/
* testsuite/binutils-all/ar.exp: Use `supports_gnu_unique' with
the `unique_symbol' test.

gas/
* testsuite/gas/elf/elf.exp: Use `supports_gnu_unique' with the
`type' test.