binutils-gdb.git
8 years agoRemove unused variable in gdb/varobj.c when built without Python support
Pedro Alves [Thu, 21 Jul 2016 14:29:58 +0000 (15:29 +0100)]
Remove unused variable in gdb/varobj.c when built without Python support

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

* varobj.c (varobj_value_get_print_value): Move "gdbarch" to block
scope that uses it.

8 years agoFix cast to 'gdb_breakpoint *'
Yao Qi [Thu, 21 Jul 2016 13:34:07 +0000 (14:34 +0100)]
Fix cast to 'gdb_breakpoint *'

c-mode buildbot catches a build problem,

gcc -g -O2    -I. -I../../../binutils-gdb/gdb/gdbserver -I../../../binutils-gdb/gdb/gdbserver/../common -I../../../binutils-gdb/gdb/gdbserver/../regformats -I../../../binutils-gdb/gdb/gdbserver/.. -I../../../binutils-gdb/gdb/gdbserver/../../include -I../../../binutils-gdb/gdb/gdbserver/../gnulib/import -Ibuild-gnulib-gdbserver/import  -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wpointer-sign -Wmissing-prototypes -Wdeclaration-after-statement -Wmissing-parameter-type -Wold-style-declaration -Wold-style-definition -Wformat-nonliteral -Wno-missing-prototypes -Werror -DGDBSERVER -c -o hostio.o -MT hostio.o -MMD -MP -MF .deps/hostio.Tpo ../../../binutils-gdb/gdb/gdbserver/hostio.c
../../../binutils-gdb/gdb/gdbserver/mem-break.c: In function find_gdb_breakpoint:
../../../binutils-gdb/gdb/gdbserver/mem-break.c:996:15: error: gdb_breakpoint undeclared (first use in this function)
       return (gdb_breakpoint *) bp;

we should use 'struct gdb_breakpoint' rather than 'gdb_breakpoint'.
Patch below fixes this.

gdb/gdbserver:

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

* mem-break.c (find_gdb_breakpoint): Cast bp to
'struct gdb_breakpoint *' rather than 'gdb_breakpoint *'.

8 years agoSupport vCont s and S actions with software single step
Yao Qi [Thu, 21 Jul 2016 11:12:18 +0000 (12:12 +0100)]
Support vCont s and S actions with software single step

GDBserver with software single step should be able to claim supporting
vCont s and S actions, so that GDB knows the remote target can do
single step.  It doesn't matter to GDB that the single step in the
remote target is done via hardware or software.

gdb/gdbserver:

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

* server.c (handle_v_requests): Support s and S actions
if target_supports_software_single_step return true.

8 years agoUse reinsert_breakpoint for vCont;s
Yao Qi [Thu, 21 Jul 2016 11:12:18 +0000 (12:12 +0100)]
Use reinsert_breakpoint for vCont;s

This patch is to teach GDBserver using software single step to handle
vCont;s.  Simply speaking, if the thread's resume request is resume_step,
install reinsert breakpoint at the next pcs when GDBserver is about to
resume threads.  These reinsert breakpoints of a thread are removed,
when GDBserver gets an event from that thread and reports it back to
GDB.

gdb/gdbserver:

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

* linux-low.c (resume_stopped_resumed_lwps): If resume request
is resume_step, call maybe_hw_step.
(linux_wait_1): Stop all threads, remove reinsert breakpoints,
and unstop them.
(linux_resume_one_lwp_throw): Don't assert the thread has reinsert
breakpoints or not.
(proceed_one_lwp): If resume request is resume_step, install
reinsert breakpoints and call maybe_hw_step.

8 years agoEnqueue signal even when resuming threads
Yao Qi [Thu, 21 Jul 2016 11:12:18 +0000 (12:12 +0100)]
Enqueue signal even when resuming threads

Nowadays, we only enqueue signal when we leave thread pending in
linux_resume_one_thread.  If lwp->resume->sig isn't zero (GDB wants
to resume with signal), we pass lwp->resume->sig to
linux_resume_one_lwp.

In order to reduce the difference between resuming thread with signal
and proceeding thread with signal, when we resume thread, we can
enqueue signal too, and proceed thread.  The signal will be consumed in
linux_resume_one_lwp_throw from lwp->pending_signals.

gdb/gdbserver:

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

* linux-low.c (proceed_one_lwp): Declare.
(linux_resume_one_thread): Remove local variable 'step'.
Lift code enqueue signal.  Call proceed_one_lwp instead of
linux_resume_one_lwp.

8 years agoUse enqueue_pending_signal in linux_resume_one_thread
Yao Qi [Thu, 21 Jul 2016 11:12:18 +0000 (12:12 +0100)]
Use enqueue_pending_signal in linux_resume_one_thread

gdb/gdbserver:

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

* linux-low.c (linux_resume_one_thread): Call
enqueue_pending_signal.

8 years agoSwitch current_thread to lwp's thread in install_software_single_step_breakpoints
Yao Qi [Thu, 21 Jul 2016 11:12:18 +0000 (12:12 +0100)]
Switch current_thread to lwp's thread in install_software_single_step_breakpoints

install_software_single_step_breakpoints has parameter lwp, but still
need to switch to current_thread.  In order to simplify its caller,
we do the current_thread save/restore inside install_software_single_step_breakpoints.

gdb/gdbserver:

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

* gdbthread.h (make_cleanup_restore_current_thread): Declare.
* inferiors.c (do_restore_current_thread_cleanup): New function.
(make_cleanup_restore_current_thread): Likewise.
* linux-low.c (install_software_single_step_breakpoints): Call
make_cleanup_restore_current_thread.  Switch current_thread to
thread.

8 years agoMake reinsert_breakpoint thread specific
Yao Qi [Thu, 21 Jul 2016 11:12:18 +0000 (12:12 +0100)]
Make reinsert_breakpoint thread specific

This patch makes reinsert_breakpoint thread specific, which means we
insert and remove reinsert_breakpoint breakpoints for a specific
thread.  This motivation of this change is that I'll use
reinsert_breakpoint for vCont;s on software single step target, so that
GDBserver may insert one reinsert_breakpoint for one thread doing
step-over, and insert one reinsert_breakpoint for another thread doing
vCont;s.  After the operation of one thread is finished, GDBserver must
remove reinsert_breakpoint for that thread only.

On the other hand, reinsert_breakpoint is used for step-over nowadays.
GDBserver inserts reinsert_breakpoint, and wait only from the thread
doing step-over.  After the step-over is done, GDBserver removes the
reinsert_breakpoint.  If there is still any threads need step-over, do
the same again until all threads are finished step-over.  In other words,
reinsert_breakpoint is globally thread specific, but in an implicit way.
It is natural to make it explicitly thread specific.

gdb/gdbserver:

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

* mem-break.c (struct reinsert_breakpoint) <ptid>: New field.
(set_reinsert_breakpoint): New parameter ptid.  Callers updated.
(clone_one_breakpoint): Likewise.
(delete_reinsert_breakpoints): Change parameter to thread.
Callers updated.
(has_reinsert_breakpoints): Likewise.
(uninsert_reinsert_breakpoints): Likewise.
(reinsert_reinsert_breakpoints): Likewise.
* mem-break.h (set_reinsert_breakpoint): Update declaration.
(delete_reinsert_breakpoints): Likewise.
(reinsert_reinsert_breakpoints): Likewise.
(uninsert_reinsert_breakpoints): Likewise.
(has_reinsert_breakpoints): Likewise.

8 years agoRefactor clone_all_breakpoints
Yao Qi [Thu, 21 Jul 2016 11:12:18 +0000 (12:12 +0100)]
Refactor clone_all_breakpoints

This patch is to change the interface of clone_all_breakpoints, from
lists of breakpoints and raw_breakpoints to child thread and parent
thread.  I choose child thread to pass because we need the ptid of
the child thread in the following patch.

gdb/gdbserver:

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

* inferiors.c (get_thread_process): Make parameter const.
* inferiors.h (get_thread_process): Update declaration.
* mem-break.c (clone_all_breakpoints): Remove all parameters.
Add new parameters child_thread and parent_thread.  Callers
updated.
* mem-break.h (clone_all_breakpoints): Update declaration.

8 years agoCreate sub classes of 'struct breakpoint'
Yao Qi [Thu, 21 Jul 2016 11:12:17 +0000 (12:12 +0100)]
Create sub classes of 'struct breakpoint'

Nowadays, there are three types of breakpoint in GDBserver,

 - gdb breakpoints,
 - reinsert breakpoints, used for software single step,
 - other breakpoints, used for tracepoint,

but we only have one 'struct breakpoint' for all of them.  Some fields
are only useful to one type of breakpoint.  For example, cond_list
and command_list are only used by gdb breakpoints, while handler is
only used by other breakpoints.

This patch changes 'struct breakpoint' to a base class, which has fields
needed by all breakpoint types, also add three sub-classes to
'struct breakpoint' to these three types of breakpoints.

gdb/gdbserver:

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

* mem-break.c (struct breakpoint) <cond_list>: Remove.
<command_list, handler>: Remove.
(struct gdb_breakpoint): New.
(struct other_breakpoint): New.
(struct reinsert_breakpoint): New.
(is_gdb_breakpoint): New function.
(any_persistent_commands): Update command_list if
is_gdb_breakpoint returns true.
(set_breakpoint): Create breakpoints according to their types.
(find_gdb_breakpoint): Return 'struct gdb_breakpoint *'.
(set_gdb_breakpoint_1): Likewise.
(set_gdb_breakpoint): Likewise.
(clear_breakpoint_conditions): Change parameter type to
'struct gdb_breakpoint *'.
(clear_breakpoint_commands): Likewise.
(clear_breakpoint_conditions_and_commands): Likewise.
(add_condition_to_breakpoint): Likewise.
(add_breakpoint_condition): Likewise.
(add_commands_to_breakpoint): Likewise.
(check_breakpoints): Check other_breakpoint.
(clone_one_breakpoint): Clone breakpopint according to its type.
* mem-break.h (struct gdb_breakpoint): Declare.
(set_gdb_breakpoint): Update declaration.
(clear_breakpoint_conditions_and_commands): Likewise.
(add_breakpoint_condition): Likewise.
(add_breakpoint_commands): Likewise.
* server.c (process_point_options): Change parameter type to
'struct gdb_breakpoint *'.

8 years agoPass breakpoint type in set_breakpoint_at
Yao Qi [Thu, 21 Jul 2016 11:12:17 +0000 (12:12 +0100)]
Pass breakpoint type in set_breakpoint_at

Nowadays, set_breakpoint_at creates breakpoint of type
other_breakpoint, but we also use set_breakpoint_at
in set_reinsert_breakpoint to create breakpoint, so that
we have to overwrite the breakpoint type like this,

  bp = set_breakpoint_at (stop_at, NULL);
  bp->type = reinsert_breakpoint;

which looks not very good.  This patch changes set_breakpoint_at
to receive breakpoint type.  Since set_breakpoint_at is
used in many places, I rename it to set_breakpoint_type_at, and wrap
it with set_breakpoint_at, and pass other_breakpoint.  In this way,
we can call set_breakpoint_type_at with reinsert_breakpoint in
set_reinsert_breakpoint too, and code looks cleaner.

gdb/gdbserver:

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

* mem-break.c (set_breakpoint_at): Rename it to ...
(set_breakpoint_type_at): ... it.
(set_breakpoint_at): Call set_breakpoint_type_at.
(set_reinsert_breakpoint): Call set_breakpoint_type_at.
* mem-break.h (set_breakpoint_at): Update comments.

8 years agoSkip gdb.server/ tests if lack of XML support
Yao Qi [Thu, 21 Jul 2016 08:22:29 +0000 (09:22 +0100)]
Skip gdb.server/ tests if lack of XML support

I recently see some gdb.server/*.exp fails in my native gdb testing,
in which libexpat isn't available, so GDB isn't able to parse xml file.
It causes gdb.server/ tests fails because GDB can't get registers
correctly from GDBserver.

(gdb) PASS: gdb.server/connect-without-multi-process.exp: multiprocess=off: break main
target remote localhost:2352^M
Remote debugging using localhost:2352^M
warning: Can not parse XML target description; XML support was disabled at compile time^M
Reading /lib/ld-linux-armhf.so.3 from remote target...^M
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.^M
Reading /lib/ld-linux-armhf.so.3 from remote target...^M
Reading symbols from target:/lib/ld-linux-armhf.so.3...Reading /lib/ld-2.17.so.debug from remote target...^M
Reading /lib/.debug/ld-2.17.so.debug from remote target...^M
(no debugging symbols found)...done.^M
Remote 'g' packet reply is too long: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000efffbe00000000808d0f4d100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000^
0x4d0f8d80 in _start () from target:/lib/ld-linux-armhf.so.3^M

Without XML support in GDB, it can't parse xml sent by GDBserver, and has
to fall back to the oldest arch.  However, GDBserver doesn't know this
(IMO, this is a defect in RSP), and still choose the right target
description to create regcache and 'g' packet.  If the port only has
one target description or coincidentally two sides choose the same
target description, there is no such issue.  Otherwise, GDB is broken
on read registers.

This patch is to skip gdbserver tests if XML is not support and the
target has multiple target descriptions.

gdb/testsuite:

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

* lib/gdbserver-support.exp (skip_gdbserver_tests): Return 1
if gdb_skip_xml_test is true on some targets.

8 years agoFix typo fsqrt -> sqrtf.
Nick Clifton [Thu, 21 Jul 2016 08:23:16 +0000 (09:23 +0100)]
Fix typo fsqrt -> sqrtf.

8 years agooops - forgot to include binutils.texi in the previous delta.
Nick Clifton [Thu, 21 Jul 2016 08:20:10 +0000 (09:20 +0100)]
oops - forgot to include binutils.texi in the previous delta.

8 years agoUse fsqrt() to calculate float (rather than double) square root.
Nick Clifton [Thu, 21 Jul 2016 08:17:54 +0000 (09:17 +0100)]
Use fsqrt() to calculate float (rather than double) square root.

* simulator.c (fsqrts): Use fsqrt rather than sqrt.

8 years agoFix fail in gdb.server/solib-list.exp
Yao Qi [Thu, 21 Jul 2016 08:15:21 +0000 (09:15 +0100)]
Fix fail in gdb.server/solib-list.exp

If I run single test solib-list.exp, it is OK.  If I run two, as below,
there are fails,

$ make check RUNTESTFLAGS="server-run.exp solib-list.exp"
FAIL: gdb.server/solib-list.exp: non-stop 0: continue (the program exited)
FAIL: gdb.server/solib-list.exp: non-stop 0: p libvar
FAIL: gdb.server/solib-list.exp: non-stop 1: continue (the program exited)
FAIL: gdb.server/solib-list.exp: non-stop 1: p libvar

in gdb.log,

/scratch/yao/gdb/build-git/x86_64/gdb/testsuite/../../gdb/gdbserver/gdbserver --once :2347 /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/outputs/gdb.server/server-run/server-run /lib64/ld-linux-x86-64.so.2 /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/outputs/gdb.server/solib-list/solib-list

server-run is spawned, which is wrong.  If I only run solib-list.exp, ld-linux
is spawned, which is right.

/scratch/yao/gdb/build-git/x86_64/gdb/testsuite/../../gdb/gdbserver/gdbserver --once :2346 /lib64/ld-linux-x86-64.so.2 /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/outputs/gdb.server/solib-list/solib-list

in test, we spawn gdbserver this way,

    # Note we pass ${interp_system}, the program gdbserver spawns, as
    # argument here, instead of using gdb_load, because we don't want
    # to download the interpreter to the target (it's already there)
    # or to the test output directory.
    set res [gdbserver_spawn "${interp_system} ${remote_binfile}"]

in gdbserver_spawn -> gdbserver_download_current_prog, if
last_loaded_file is set (when you run multiple tests), it is
returned.

This patch is to unset last_loaded_file in solib-list.exp.

gdb/testsuite:

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

* gdb.server/solib-list.exp: Unset last_loaded_file.

8 years agoUse variable args in run_ld_link_exec_tests
Alan Modra [Thu, 21 Jul 2016 00:06:37 +0000 (09:36 +0930)]
Use variable args in run_ld_link_exec_tests

If the last parameter of a tcl function is "args" then it can take
zero or more arguments.  Make use of this language feature in
run_ld_link_exec_tests.

* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Replace
"targets_to_xfail" parameter with "args".
* testsuite/ld-elf/compress.exp: Remove empty list of xfails on
all calls to run_ld_link_exec_tests.
* testsuite/ld-elf/dwarf.exp: Likewise.
* testsuite/ld-elf/indirect.exp: Likewise.
* testsuite/ld-elf/wrap.exp: Likewise.
* testsuite/ld-i386/i386.exp: Likewise.
* testsuite/ld-i386/no-plt.exp: Likewise.
* testsuite/ld-i386/tls.exp: Likewise.
* testsuite/ld-ifunc/ifunc.exp: Likewise.
* testsuite/ld-pie/pie.exp: Likewise.
* testsuite/ld-plugin/lto.exp: Likewise.
* testsuite/ld-size/size.exp: Likewise.
* testsuite/ld-x86-64/mpx.exp: Likewise.
* testsuite/ld-x86-64/no-plt.exp: Likewise.
* testsuite/ld-x86-64/tls.exp: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-elf/elf.exp: Likewise.  Reorder args when providing
xfails and simplify lists.
* testsuite/ld-elf/shared.exp: Likewise.

8 years agoFix implib test failures
Alan Modra [Wed, 20 Jul 2016 05:36:49 +0000 (15:06 +0930)]
Fix implib test failures

bfd/
* elf.c (_bfd_elf_filter_global_symbols): Skip local symbols.
(swap_out_syms): Return an error when not finding ELF output
section rather than asserting.
* elflink.c (elf_output_implib): Call bfd_set_error on no symbols.
ld/
* testsuite/lib/ld-lib.exp (run_ld_link_tests): Add optional
parameter to pass list of xfails.
* testsuite/ld-elf/elf.exp: Add xfails for implib tests.  Tidy
implib test formatting.  Don't set .data start address.
* testsuite/ld-elf/implib.s: Remove first .bss directive and
replace second one with equivalent .section directive.
* testsuite/ld-elf/empty-implib.out: Add expected final error.
* testsuite/ld-elf/implib.rd: Update.

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

8 years agoUse a real vfork done event on FreeBSD when available.
John Baldwin [Sat, 16 Jul 2016 17:14:08 +0000 (10:14 -0700)]
Use a real vfork done event on FreeBSD when available.

FreeBSD 12 recently added a new ptrace event to indicate when the vfork
parent resumes after the child process stops sharing the address space.
Use this event to report a proper TARGET_WAITKIND_VFORK_DONE rather than
faking a vfork done event after a delay.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_enable_proc_events): Enable "PTRACE_VFORK"
events.
(fbsd_pending_vfork_done): Only define if "PTRACE_VFORK" is not
defined.
(fbsd_add_vfork_done): Likewise.
(fbsd_is_vfork_done_pending): Likewise.
(fbsd_next_vfork_done): Likewise.
(fbsd_resume): Only ignore pending vfork done events if
"PTRACE_VFORK" is not defined.
(fbsd_wait): Only look for pending vfork done events if
"PTRACE_VFORK" is not defined.
[PTRACE_VFORK]: Handle "PL_FLAG_VFORKED" and "PL_FLAG_VFORK_DONE"
events.
(fbsd_follow_fork): Only fake a vfork done event if "PTRACE_VFORK"
is not defined.

8 years agoEnable ptrace events on new child processes.
John Baldwin [Sat, 16 Jul 2016 00:01:21 +0000 (17:01 -0700)]
Enable ptrace events on new child processes.

New child processes on FreeBSD do not inherit optional ptrace events
such as fork and LWP events from the parent process.  Instead,
explicitly enable events on new children when reporting a fork
event.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_wait): Use "fbsd_enable_proc_events" on
new child processes.

8 years agoConsolidate code to enable optional FreeBSD native target event reporting.
John Baldwin [Fri, 15 Jul 2016 21:03:10 +0000 (14:03 -0700)]
Consolidate code to enable optional FreeBSD native target event reporting.

Add a new function to enable optional event reporting for FreeBSD native
targets.  Specifically, use this to enable fork and LWP events.
The bodies of fbsd_enable_follow_fork and fbsd_enable_lwp_events have been
subsumed into the new function.  In addition, use the PT_GET_EVENT_MASK
and PT_EVENT_SET_MASK requests added in FreeBSD 12 when present to enable
these events.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_enable_lwp_events): Remove function.
(fbsd_enable_proc_events): New function.
(fbsd_enable_follow_fork): Remove function.
(fbsd_post_startup_inferior): Use "fbsd_enable_proc_events".
(fbsd_post_attach): Likewise.

8 years agoAdd support to the ARC disassembler for selecting instruction classes.
Claudiu Zissulescu [Wed, 20 Jul 2016 16:08:07 +0000 (17:08 +0100)]
Add support to the ARC disassembler for selecting instruction classes.

gas * testsuite/gas/arc/dsp.d: New file.
* testsuite/gas/arc/dsp.s: Likewise.
* testsuite/gas/arc/fpu.d: Likewise.
* testsuite/gas/arc/fpu.s: Likewise.
* testsuite/gas/arc/ext2op.d: Add specific disassembler option.
* testsuite/gas/arc/ext3op.d: Likewise.
* testsuite/gas/arc/tdpfp.d: Likewise.
* testsuite/gas/arc/tfpuda.d: Likewise.

opcodes * arc-dis.c (skipclass): New structure.
(decodelist): New variable.
(is_compatible_p): New function.
(new_element): Likewise.
(skip_class_p): Likewise.
(find_format_from_table): Use skip_class_p function.
(find_format): Decode first the extension instructions.
(print_insn_arc): Select either ARCEM or ARCHS based on elf
e_flags.
(parse_option): New function.
(parse_disassembler_options): Likewise.
(print_arc_disassembler_options): Likewise.
(print_insn_arc): Use parse_disassembler_options function.  Proper
select ARCv2 cpu variant.
* disassemble.c (disassembler_usage): Add ARC disassembler
options.

binutils* doc/binutils.texi (objdump): Add ARC disassembler options.
* testsuite/binutils-all/arc/dsp.s: New file.
* testsuite/binutils-all/arc/objdump.exp: Likewise.

include * dis-asm.h: Declare print_arc_disassembler_options.

8 years agoHandle version 1a of FreeBSD's NT_PRSINFO.
John Baldwin [Tue, 5 Jul 2016 02:19:48 +0000 (19:19 -0700)]
Handle version 1a of FreeBSD's NT_PRSINFO.

Version 1a adds a pr_pid member containing the process ID of the
terminating process.  The presence of pr_pid is inferred from the
note's size.

bfd/ChangeLog:

* elf.c (elfcore_grok_freebsd_psinfo): Check for minimum note size
and handle pr_pid if present.

8 years agoCheck p_paddr for program header space
H.J. Lu [Wed, 20 Jul 2016 14:50:42 +0000 (07:50 -0700)]
Check p_paddr for program header space

Issue an error if p_paddr becomes invalid when allocating space for
program headers.

PR ld/20376
* elf.c (assign_file_positions_for_load_sections): Also check
p_paddr for program header space.

8 years agotestsuite: Fix gdb.gdb/selftest.exp for C++-O2-g-built GDB
Jan Kratochvil [Wed, 20 Jul 2016 14:26:44 +0000 (16:26 +0200)]
testsuite: Fix gdb.gdb/selftest.exp for C++-O2-g-built GDB

tested on Fedora 24 x86_64 after:
        ./configure; make
That is: CFLAGS='-g -O2' CXXFLAGS='-g -O2'

FAIL: gdb.gdb/selftest.exp: unknown source line
FAIL: gdb.gdb/selftest.exp: step into xmalloc call

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

* gdb.gdb/selftest.exp (do_steps_and_nexts): Add "next over TRY" and
"step into captured_main (args)".

8 years agotestsuite: Fix gdb.btrace/tailcall-only.exp errors on x86_64-m32
Jan Kratochvil [Wed, 20 Jul 2016 14:20:48 +0000 (16:20 +0200)]
testsuite: Fix gdb.btrace/tailcall-only.exp errors on x86_64-m32

$ runtest 'CC_FOR_TARGET=gcc -m32' gdb.btrace/tailcall-only.exp
Running ./gdb.btrace/tailcall-only.exp ...
gdb compile failed, tailcall-only.c: Assembler messages:
tailcall-only.c:142: Error: cannot represent relocation type BFD_RELOC_64
[...]
tailcall-only.c:425: Error: cannot represent relocation type BFD_RELOC_64

It works for the other x86 arch combinations:

On Mon, 11 Apr 2016 08:44:23 +0200, Metzger, Markus T wrote:
I'm setting the target triplet to "i686-unknown-linux" in my m32 configuration.
Like this:

set target_triplet "i686-unknown-linux"
set_board_info cflags "-m32"
set_board_info cppflags "-m32"

On Wed, 20 Jul 2016 16:02:20 +0200, Pedro Alves wrote:
There's no reason you should _not_ set it.

But, multilib-style testing with --target_board=unix\{-m64,-m32\} etc.
should work _too_, IMO.

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

* gdb.btrace/tailcall-only.exp: Use is_lp64_target check.

8 years agotestsuite patch: Skip py-unwind.exp on x86_64 -m32
Jan Kratochvil [Wed, 20 Jul 2016 14:17:04 +0000 (16:17 +0200)]
testsuite patch: Skip py-unwind.exp on x86_64 -m32

(gdb) source /home/jkratoch/redhat/gdb-clean/gdb/testsuite/outputs/gdb.python/py-unwind/py-unwind.py^M
Python script imported^M
Python Exception <type 'exceptions.ValueError'> Bad register: ^M
(gdb) FAIL: gdb.python/py-unwind.exp: import python scripts

class TestUnwinder(Unwinder):
    AMD64_RBP = 6
    AMD64_RSP = 7
    AMD64_RIP = 16

On Tue, 19 Jul 2016 12:06:09 +0200, Yao Qi wrote:
py-unwind.exp does nothing on arch specific thing, so py-unwind.exp shouldn't
be aware of the arch difference, but py-unwind.py should.

On Tue, 19 Jul 2016 20:04:33 +0200, Pedro Alves wrote:
How about we handle this in the .exp file for now and leave something
more complicated for when the test is first ported to some other
arch.  WDYT?

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

* gdb.python/py-unwind.exp: Test also ![is_lp64_target].

8 years agoMIPS/GAS: Remove erroneous ELF relocation references
Maciej W. Rozycki [Wed, 20 Jul 2016 11:11:52 +0000 (12:11 +0100)]
MIPS/GAS: Remove erroneous ELF relocation references

Remove R_MIPS_PC26_S2 and R_MIPS_PC21_S2 relocation references that went
into `mips_force_relocation' with commit 9d862524f6ae ("MIPS: Verify the
ISA mode and alignment of branch and jump targets") by mistake.  Their
BFD_RELOC_MIPS_26_PCREL_S2 and BFD_RELOC_MIPS_21_PCREL_S2 equivalents
are already handled there.

gas/
* config/tc-mips.c (mips_force_relocation): Remove
R_MIPS_PC26_S2 and R_MIPS_PC21_S2.

8 years agoUpdate documentation to reflect that the symbol localization options of objcopy do...
Nick Clifton [Wed, 20 Jul 2016 08:41:10 +0000 (09:41 +0100)]
Update documentation to reflect that the symbol localization options of objcopy do not affect unique symbols.

* doc/binutils.texi (objcopy): Note that the localize symbol
options do not affect unique symbols.

8 years agoEnable the configuration of GDB for the NDS32 target.
Yan-Ting Lin [Wed, 20 Jul 2016 08:06:39 +0000 (09:06 +0100)]
Enable the configuration of GDB for the NDS32 target.

    * configure.ac (nds32*-*-*): Remove entry to enable gdb.
    * configure: Regenerated.

8 years agoEarly expression evaluation
Alan Modra [Wed, 20 Jul 2016 00:14:46 +0000 (09:44 +0930)]
Early expression evaluation

Folding a constant expression early can lead to loss of tokens, eg.
ABSOLUTE, that are significant in ld's horrible context sensitive
expression evaluation.  Also, MAXPAGESIZE and other "constants" may
not have taken values specified on the command line, leading to the
wrong value being cached.

* ldexp.c (exp_unop, exp_binop, exp_trinop, exp_nameop): Don't
fold expression.
* testsuite/ld-elf/maxpage3b.d: Expect correct maxpagesize.

8 years agoMark some more powerpc relocs as not handled by generic linker
Alan Modra [Wed, 20 Jul 2016 01:03:14 +0000 (10:33 +0930)]
Mark some more powerpc relocs as not handled by generic linker

* elf64-ppc.c (ppc64_elf_howto_raw <R_PPC64_PLTREL32>): Put
ppc64_elf_unhandled_reloc for special_function.
* elf32-ppc.c (ppc_elf_howto_raw): Similarly for lots of relocs.

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

8 years agoSupport -pie for aarch64*-elf targets.
Roland McGrath [Tue, 19 Jul 2016 17:19:06 +0000 (10:19 -0700)]
Support -pie for aarch64*-elf targets.

ld/
* emulparams/aarch64elf.sh (GENERATE_PIE_SCRIPT): Set to yes.
* emulparams/aarch64elf32.sh: Likewise.

8 years agoBuild gdb.opt/inline-*.exp tests at -O0, rely on __attribute__((always_inline))
Pedro Alves [Tue, 19 Jul 2016 16:51:05 +0000 (17:51 +0100)]
Build gdb.opt/inline-*.exp tests at -O0, rely on __attribute__((always_inline))

A test recently added to gdb.opt/inline-cmds.exp fails for
arm-none-eabi targets because -O2 leads to instructions to be
reordered widely.

I guess it might have made sense years ago to enable optimization in
these tests, but I fail to see the need for that nowadays.

Using -O0 while relying on __attribute__((always_inline)), which is
already used in the tests [1] [2], avoids this sort of trouble, while
still exercising the inlining-related use cases that are the focus of
these tests.

I think that nowadays we can safely assume that all compilers we care
about support __attribute__((always_inline)) or similar.

[1] - Except one spot that missed it.

[2] - Note that the .exp files make sure the frames that should have
      been inlined are indeed inlined, with "info frame".

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

* gdb.opt/inline-break.exp: Remove optimize=-O2.
* gdb.opt/inline-bt.exp: Likewise.
* gdb.opt/inline-cmds.exp: Remove optimize=-O2 and add
additional_flags=-Winline.
* gdb.opt/inline-locals.exp: Likewise.
* gdb.opt/inline-markers.c (ATTR): Define.
(inlined_fn): Use it.

8 years agoMIPS: Convert cross-mode BAL to JALX
Maciej W. Rozycki [Tue, 19 Jul 2016 15:19:19 +0000 (16:19 +0100)]
MIPS: Convert cross-mode BAL to JALX

Convert cross-mode regular MIPS and microMIPS BAL instructions to JALX,
similarly to how JAL instructions are converted.

bfd/
* elfxx-mips.c (mips_elf_perform_relocation): Convert cross-mode
BAL to JALX.
(_bfd_mips_elf_relocate_section) <bfd_reloc_outofrange>: Add a
corresponding error message.

gas/
* config/tc-mips.c (mips_force_relocation, mips_fix_adjustable):
Adjust comments for BAL to JALX linker conversion.
(fix_bad_cross_mode_branch_p): Accept cross-mode BAL.
* testsuite/gas/mips/unaligned-branch-1.l: Update error messages
expected.
* testsuite/gas/mips/unaligned-branch-micromips-1.l: Likewise.
* testsuite/gas/mips/branch-local-4.d: New test.
* testsuite/gas/mips/branch-local-n32-4.d: New test.
* testsuite/gas/mips/branch-local-n64-4.d: New test.
* testsuite/gas/mips/branch-addend.d: New test.
* testsuite/gas/mips/branch-addend-n32.d: New test.
* testsuite/gas/mips/branch-addend-n64.d: New test.
* testsuite/gas/mips/branch-local-4.s: New test source.
* testsuite/gas/mips/branch-addend.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

ld/
* testsuite/ld-mips-elf/unaligned-branch-2.d: Update error
messages expected.
* testsuite/ld-mips-elf/unaligned-branch-r6-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-mips16.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-micromips.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-addend.d: New test.
* testsuite/ld-mips-elf/bal-jalx-local.d: New test.
* testsuite/ld-mips-elf/bal-jalx-pic.d: New test.
* testsuite/ld-mips-elf/bal-jalx-addend-n32.d: New test.
* testsuite/ld-mips-elf/bal-jalx-local-n32.d: New test.
* testsuite/ld-mips-elf/bal-jalx-pic-n32.d: New test.
* testsuite/ld-mips-elf/bal-jalx-addend-n64.d: New test.
* testsuite/ld-mips-elf/bal-jalx-local-n64.d: New test.
* testsuite/ld-mips-elf/bal-jalx-pic-n64.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-2.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-3.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-addend-2.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-addend-3.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-2.s: New test source.
* testsuite/ld-mips-elf/unaligned-jalx-3.s: New test source.
* testsuite/ld-mips-elf/unaligned-jalx-addend-2.s: New test
source.
* testsuite/ld-mips-elf/unaligned-jalx-addend-3.s: New test
source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.

8 years agoMIPS: Verify the ISA mode and alignment of branch and jump targets
Maciej W. Rozycki [Tue, 19 Jul 2016 12:59:28 +0000 (13:59 +0100)]
MIPS: Verify the ISA mode and alignment of branch and jump targets

Verify that the ISA mode of branch targets is the same as the referring
relocation, so that an attempt to produce a branch between instructions
encoded in different ISA modes each causes an error rather than silently
producing non-functional code.  Make sure that no symbol or addend bits
are silently truncated: terminate with an error if the relocation value
calculated cannot be encoded in the relocatable field of a branch; for
REL targets also applying to any intermediate addend.

Also make jump target's alignment verification consistent with that for
branches.

This change will require an update to some obscure handcoded assembly
sources which make branches to labels placed at data objects, however
for microMIPS code only.  These labels will have to be updated with the
`.insn' directive for containing code to assemble and link successfully.
Such code is broken as any such labels have always been required by the
microMIPS architecture specification[1][2] to be annotated this way for
correct interpretation, and with our old code missing `.insn' directives
caused labels to present different semantics depending on whether they
were referred with branch (ISA bit ignored) or other relocations (ISA
bit respected).

Enforcing these checks however will ensure errors in building software,
like mixed regular MIPS and microMIPS code links with branches between,
will be diagnosed at the build time rather than causing odd run-time
errors such as intermittent crashes.  It will also let cross-mode BAL
instructions be converted to JALX instructions, with a separate change.

References:

[1] "MIPS Architecture for Programmers, Volume II-B: The microMIPS32
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00582,
    Revision 5.04, January 15, 2014, Section 7.1 "Assembly-Level
    Compatibility", p. 533

[2] "MIPS Architecture for Programmers, Volume II-B: The microMIPS64
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00594,
    Revision 5.04, January 15, 2014, Section 8.1 "Assembly-Level
    Compatibility", p. 623

bfd/
* elfxx-mips.c (b_reloc_p): Add R_MICROMIPS_PC16_S1,
R_MICROMIPS_PC10_S1 and R_MICROMIPS_PC7_S1.
(branch_reloc_p): New function.
(mips_elf_calculate_relocation): Handle ISA mode determination
for relocations against section symbols, against absolute
symbols and absolute relocations.  Also set `*cross_mode_jump_p'
for branches.
<R_MIPS16_26, R_MIPS_26, R_MICROMIPS_26_S1>: Suppress alignment
checks for weak undefined symbols.  Also check target alignment
within the same ISA mode.
<R_MIPS_PC16, R_MIPS_GNU_REL16_S2>: Handle cross-mode branches
in the alignment check.
<R_MICROMIPS_PC7_S1>: Add an alignment check.
<R_MICROMIPS_PC10_S1>: Likewise.
<R_MICROMIPS_PC16_S1>: Likewise.
(mips_elf_perform_relocation): Report a failure for unsupported
same-mode JALX instructions and cross-mode branches.
(_bfd_mips_elf_relocate_section) <bfd_reloc_outofrange>: Add
error messages for jumps to misaligned addresses.

gas/
* config/tc-mips.c (mips_force_relocation): Also retain branch
relocations against MIPS16 and microMIPS symbols.
(fix_bad_cross_mode_jump_p): New function.
(fix_bad_same_mode_jalx_p): Likewise.
(fix_bad_misaligned_jump_p): Likewise.
(fix_bad_cross_mode_branch_p): Likewise.
(fix_bad_misaligned_branch_p): Likewise.
(fix_validate_branch): Likewise.
(md_apply_fix) <BFD_RELOC_MIPS_JMP, BFD_RELOC_MIPS16_JMP>
<BFD_RELOC_MICROMIPS_JMP>: Separate from BFD_RELOC_MIPS_SHIFT5,
etc.  Verify the ISA mode and alignment of the jump target.
<BFD_RELOC_MIPS_21_PCREL_S2>: Replace the inline alignment check
with a call to `fix_validate_branch'.
<BFD_RELOC_MIPS_26_PCREL_S2>: Likewise.
<BFD_RELOC_16_PCREL_S2>: Likewise.
<BFD_RELOC_MICROMIPS_7_PCREL_S1, BFD_RELOC_MICROMIPS_10_PCREL_S1>
<BFD_RELOC_MICROMIPS_16_PCREL_S1>: Retain the original addend.
Verify the ISA mode and alignment of the branch target.
(md_convert_frag): Verify the ISA mode and alignment of resolved
MIPS16 branch targets.
* testsuite/gas/mips/branch-misc-1.s: Annotate non-instruction
branch targets with `.insn'.
* testsuite/gas/mips/branch-misc-5.s: Likewise.
* testsuite/gas/mips/micromips@branch-misc-5-64.d: Update
accordingly.
* testsuite/gas/mips/micromips@branch-misc-5pic-64.d: Likewise.
* testsuite/gas/mips/micromips-branch-relax.s: Annotate
non-instruction branch target with `.insn'.
* testsuite/gas/mips/micromips.s: Replace microMIPS JALX targets
with external symbols.
* testsuite/gas/mips/micromips-insn32.d: Update accordingly.
* testsuite/gas/mips/micromips-noinsn32.d: Likewise.
* testsuite/gas/mips/micromips-trap.d: Likewise.
* testsuite/gas/mips/micromips.d: Likewise.
* testsuite/gas/mips/mips16.s: Annotate non-instruction branch
targets with `.insn'.
* testsuite/gas/mips/mips16.d: Update accordingly.
* testsuite/gas/mips/mips16-64.d: Likewise.
* testsuite/gas/mips/mips16-dwarf2.s: Annotate non-instruction
branch target with `.insn'.
* testsuite/gas/mips/relax-swap3.s: Likewise.
* testsuite/gas/mips/branch-local-2.l: New list test.
* testsuite/gas/mips/branch-local-3.l: New list test.
* testsuite/gas/mips/branch-local-n32-2.l: New list test.
* testsuite/gas/mips/branch-local-n32-3.l: New list test.
* testsuite/gas/mips/branch-local-n64-2.l: New list test.
* testsuite/gas/mips/branch-local-n64-3.l: New list test.
* testsuite/gas/mips/unaligned-jump-1.l: New list test.
* testsuite/gas/mips/unaligned-jump-2.l: New list test.
* testsuite/gas/mips/unaligned-jump-3.d: New test.
* testsuite/gas/mips/unaligned-jump-mips16-1.l: New list test.
* testsuite/gas/mips/unaligned-jump-mips16-2.l: New list test.
* testsuite/gas/mips/unaligned-jump-mips16-3.d: New test.
* testsuite/gas/mips/unaligned-jump-micromips-1.l: New list
test.
* testsuite/gas/mips/unaligned-jump-micromips-2.l: New list
test.
* testsuite/gas/mips/unaligned-jump-micromips-3.d: New test.
* testsuite/gas/mips/unaligned-branch-1.l: New list test.
* testsuite/gas/mips/unaligned-branch-2.l: New list test.
* testsuite/gas/mips/unaligned-branch-3.d: New test.
* testsuite/gas/mips/unaligned-branch-r6-1.l: New list test.
* testsuite/gas/mips/unaligned-branch-r6-2.l: New list test.
* testsuite/gas/mips/unaligned-branch-r6-3.l: New list test.
* testsuite/gas/mips/unaligned-branch-r6-4.l: New list test.
* testsuite/gas/mips/unaligned-branch-r6-5.d: New test.
* testsuite/gas/mips/unaligned-branch-r6-6.d: New test.
* testsuite/gas/mips/unaligned-branch-mips16-1.l: New list test.
* testsuite/gas/mips/unaligned-branch-mips16-2.l: New list test.
* testsuite/gas/mips/unaligned-branch-mips16-3.d: New test.
* testsuite/gas/mips/unaligned-branch-micromips-1.l: New list
test.
* testsuite/gas/mips/unaligned-branch-micromips-2.l: New list
test.
* testsuite/gas/mips/unaligned-branch-micromips-3.d: New test.
* testsuite/gas/mips/branch-local-2.s: New test source.
* testsuite/gas/mips/branch-local-3.s: New test source.
* testsuite/gas/mips/branch-local-n32-2.s: New test source.
* testsuite/gas/mips/branch-local-n32-3.s: New test source.
* testsuite/gas/mips/branch-local-n64-2.s: New test source.
* testsuite/gas/mips/branch-local-n64-3.s: New test source.
* testsuite/gas/mips/unaligned-jump-1.s: New test source.
* testsuite/gas/mips/unaligned-jump-2.s: New test source.
* testsuite/gas/mips/unaligned-jump-mips16-1.s: New test source.
* testsuite/gas/mips/unaligned-jump-mips16-2.s: New test source.
* testsuite/gas/mips/unaligned-jump-micromips-1.s: New test
source.
* testsuite/gas/mips/unaligned-jump-micromips-2.s: New test
source.
* testsuite/gas/mips/unaligned-branch-1.s: New test source.
* testsuite/gas/mips/unaligned-branch-2.s: New test source.
* testsuite/gas/mips/unaligned-branch-r6-1.s: New test source.
* testsuite/gas/mips/unaligned-branch-r6-2.s: New test source.
* testsuite/gas/mips/unaligned-branch-r6-3.s: New test source.
* testsuite/gas/mips/unaligned-branch-r6-4.s: New test source.
* testsuite/gas/mips/unaligned-branch-mips16-1.s: New test
source.
* testsuite/gas/mips/unaligned-branch-mips16-2.s: New test
source.
* testsuite/gas/mips/unaligned-branch-micromips-1.s: New test
source.
* testsuite/gas/mips/unaligned-branch-micromips-2.s: New test
source.
* testsuite/gas/mips/mips.exp: Run the new tests.

ld/
* testsuite/ld-mips-elf/unaligned-jalx-1.d: Update error message
expected.
* testsuite/ld-mips-elf/unaligned-jalx-addend-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-1.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-1.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d: Likewise.
* testsuite/ld-mips-elf/undefweak-overflow.s: Add jumps,
microMIPS BAL and MIPS16 instructions.
* testsuite/ld-mips-elf/undefweak-overflow.d: Update
accordingly.
* testsuite/ld-mips-elf/unaligned-branch-2.d: New test.
* testsuite/ld-mips-elf/unaligned-branch-r6-1.d: New test.
* testsuite/ld-mips-elf/unaligned-branch-r6-2.d: New test.
* testsuite/ld-mips-elf/unaligned-branch-mips16.d: New test.
* testsuite/ld-mips-elf/unaligned-branch-micromips.d: New test.
* testsuite/ld-mips-elf/unaligned-jump-mips16.d: New test.
* testsuite/ld-mips-elf/unaligned-jump-micromips.d: New test.
* testsuite/ld-mips-elf/unaligned-jump.d: New test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.

8 years agomake the type of nds32_pseudo_opcode::pseudo_val unsigned
Trevor Saunders [Sat, 21 May 2016 08:39:05 +0000 (04:39 -0400)]
make the type of nds32_pseudo_opcode::pseudo_val  unsigned

It can be initialized with values greater than 0x80000000, which don't fit in a
signed int.  Further it appears to be used as a set of bit flags where unsigned
int is more typical.

gas/ChangeLog:

2016-07-19  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* config/tc-nds32.c (struct nds32_pseudo_opcode): Make pseudo_val
unsigned int.
(do_pseudo_b): Adjust.
(do_pseudo_bal): Likewise.
(do_pseudo_bge): Likewise.
(do_pseudo_bges): Likewise.
(do_pseudo_bgt): Likewise.
(do_pseudo_bgts): Likewise.
(do_pseudo_ble): Likewise.
(do_pseudo_bles): Likewise.
(do_pseudo_blt): Likewise.
(do_pseudo_blts): Likewise.
(do_pseudo_br): Likewise.
(do_pseudo_bral): Likewise.
(do_pseudo_la): Likewise.
(do_pseudo_li): Likewise.
(do_pseudo_ls_bhw): Likewise.
(do_pseudo_ls_bhwp): Likewise.
(do_pseudo_ls_bhwpc): Likewise.
(do_pseudo_ls_bhwi): Likewise.
(do_pseudo_move): Likewise.
(do_pseudo_neg): Likewise.
(do_pseudo_not): Likewise.
(do_pseudo_pushpopm): Likewise.
(do_pseudo_pushpop): Likewise.
(do_pseudo_v3push): Likewise.
(do_pseudo_v3pop): Likewise.
(do_pseudo_pushpop_stack): Likewise.
(do_pseudo_push_bhwd): Likewise.
(do_pseudo_pop_bhwd): Likewise.
(do_pseudo_pusha): Likewise.
(do_pseudo_pushi): Likewise.

8 years agosparc: make a field type bfd_reloc_code_real_type
Trevor Saunders [Mon, 27 Jun 2016 11:38:33 +0000 (07:38 -0400)]
sparc: make a field type bfd_reloc_code_real_type

gas/ChangeLog:

2016-07-19  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* config/tc-sparc.c (struct pop_entry): Make the type of reloc
bfd_reloc_code_real_type.

8 years agosparc: remove a sentinal
Trevor Saunders [Mon, 27 Jun 2016 11:38:14 +0000 (07:38 -0400)]
sparc: remove a sentinal

gas/ChangeLog:

2016-07-19  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* config/tc-sparc.c (pop_table): Remove sentinel.
(NUM_PERC_ENTRIES): Use ARRAY_SIZE on pop_table.
(md_begin): Adjust.

8 years agotc-z8k.c: make some argument types bfd_reloc_code_real_type
Trevor Saunders [Mon, 18 Jul 2016 08:07:26 +0000 (04:07 -0400)]
tc-z8k.c: make some argument types bfd_reloc_code_real_type

gas/ChangeLog:

2016-07-19  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* config/tc-z8k.c (newfix): Make type of type argument
bfd_reloc_code_real_type.
(apply_fix): Likewise.

8 years agoUse do_self_tests in selftest.exp
Yao Qi [Tue, 19 Jul 2016 09:42:08 +0000 (10:42 +0100)]
Use do_self_tests in selftest.exp

This patch uses do_self_tests to simplify selftest.exp.  It doesn't
change the tests except the order,

-PASS: gdb.gdb/selftest.exp: Disassemble main
 PASS: gdb.gdb/selftest.exp: breakpoint in captured_main
+PASS: gdb.gdb/selftest.exp: run until breakpoint at captured_main
+PASS: gdb.gdb/selftest.exp: Disassemble main
 PASS: gdb.gdb/selftest.exp: set interrupt character in test_with_self
 PASS: gdb.gdb/selftest.exp: set listsize to 1
-PASS: gdb.gdb/selftest.exp: run until breakpoint at captured_main

gdb/testsuite:

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

* gdb.gdb/selftest.exp: Remove checks on is_remote and isnative.
(test_with_self): Remove some code.  Remove argument executable.
(top-level): Use do_self_tests.

8 years agold: Restore file offset after a plugin fails to claim a file
Andrew Burgess [Mon, 18 Jul 2016 20:00:00 +0000 (21:00 +0100)]
ld: Restore file offset after a plugin fails to claim a file

When using the plugin interface to claim an input file the claim method
from (possible) many plugins can be called on an input file.  If these
claim methods read content from the input file then the file offset
stored in the underlying file descriptor will change.

As we share a file descriptor between the plugin interface (created with
dup in ld/plugin.c:plugin_object_p) and the input bfd object, then any
changes to the file offset in the file descriptor will effect the bfd
object.  Also, as the changes to the file offset did not originate from
calls through the bfd interface, but instead came from the plugin
directly, then the bfd will not be aware that the file offset has
changed.  This is a problem as the bfd library caches the file offset.
If the plugin decides not to claim an input file then, currently, we
leave the bfd in a state where the actual file offset is out of sync
with the cached file offset.

This problem came to light after a recent commit
7d0b9ebc1e0079271a7c7737b53bc026525eab64 (Don't include libbfd.h outside
of bfd, part 6) however, I don't believe that commit actual introduces
the bug, it just exposed the existing issue.

This commit solves the problem by backing up and restoring the file
offset for the file descriptor of the input file.  The restore is only
done if the plugin does not claim the input file, as it is in this case
that the bfd library might be used again to try and identify the
unclaimed file.

ld/ChangeLog:

* plugin.c (plugin_call_claim_file): Restore the file offset after
an unsuccessful attempt to claim a file.
* testplug.c (bytes_to_read_before_claim): New global.
(record_read_length): New function, sets new global
bytes_to_read_before_claim.
(parse_option): Handle 'read:<NUMBER>' option.
(onclaim_file): Read file content before checking for claim.
* testsuite/ld-plugin/plugin-30.d: New file.
* testsuite/ld-plugin/plugin.exp: Add new test.

8 years ago Update PC when simulate break instruction.
Denis Chertykov [Tue, 19 Jul 2016 06:47:23 +0000 (09:47 +0300)]
Update PC when simulate break instruction.

PR target/ 19401
* avr/interp.c (step_once): Pass break instruction address to
sim_engine_halt function which writes that to PC. Remove code that
follows that function call as it is unreachable.

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

8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 18 Jul 2016 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoAutomatic date update in version.in
GDB Administrator [Sun, 17 Jul 2016 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoDon't include libbfd.h outside of bfd, part 6
Alan Modra [Sat, 16 Jul 2016 04:02:16 +0000 (13:32 +0930)]
Don't include libbfd.h outside of bfd, part 6

Some messing with plugin code in order to not need arelt_size in
ld code.  File descriptor handling in ld/plugin.c is tidied too,
simply duping the open fd rather than opening the file again.

bfd/
* elflink.c: Include plugin-api.h.
* plugin.c (bfd_plugin_open_input): New function, extracted from..
(try_claim): ..here.
* plugin.h: Don't include bfd.h.
(bfd_plugin_open_input): Declare.
binutils/
* ar.c: Include plugin-api.h.
* nm.c: Likewise.
ld/
* plugin.c: Don't include libbfd.h.  Include plugin-api.h
before bfd/plugin.h.
(plugin_object_p): Use bfd_plugin_open_input.

8 years agoDon't include libbfd.h outside of bfd, part 5
Alan Modra [Sat, 16 Jul 2016 04:00:41 +0000 (13:30 +0930)]
Don't include libbfd.h outside of bfd, part 5

A rewrite of the code in bucomm.c supporting objdump -i, to use
bfd_iterate_over_targets rather than accessing bfd_target_vector
directly.  Calculates widest arch string rather than using an
out of date constant.  Stashes info from the first display of valid
target/arch combinations for use in second tabular display.

binutils/
* bucomm.c: Don't include libbfd.h.
(endian_string, display_target_list): Delete forward declaration.
(display_info_table, display_target_tables): Likewise.
(LONGEST_ARCH): Delete.
(struct display_target): New.
(do_display_target): New function.
(display_target_list, display_info): Rewrite functions.
(display_info_table): Delete.
(do_info_size, do_info_header, do_info_row): New functions.

8 years agoDon't include libbfd.h outside of bfd, part 4
Alan Modra [Sat, 16 Jul 2016 03:59:35 +0000 (13:29 +0930)]
Don't include libbfd.h outside of bfd, part 4

Not much to see here, just renaming a function.

bfd/
* targets.c (bfd_seach_for_target): Rename to..
(bfd_iterate_over_targets): ..this.  Rewrite doc.
* bfd-in2.h: Regenerate.
ld/
* ldlang.c (open_output): Replace bfd_search_for_target with
bfd_iterate_over_targets.  Localize vars.

8 years agoDon't include libbfd.h outside of bfd, part 3
Alan Modra [Sat, 16 Jul 2016 03:58:30 +0000 (13:28 +0930)]
Don't include libbfd.h outside of bfd, part 3

Fix od-macho.c to use a leb128 function from binutils/dwarf.c rather
than one from bfd/libbfd.c.

binutils/
* elfcomm.h (HOST_WIDEST_INT): Move to..
* sysdep.h: ..here.
* od-macho.c: Don't include libbfd.h.  Do include dwarf.h
(dump_dyld_info_rebase): Use read_leb128 rather than
read_unsigned_leb128.
(dump_dyld_info_bind, dump_dyld_info_export_1): Likewise.
(dump_segment_split_info): Likewise.
(dump_dyld_info): Rename vars to avoid shadowing dwarf.h enums.
(dump_load_command): Likewise.

8 years agoDon't include libbfd.h outside of bfd, part 2
Alan Modra [Sat, 16 Jul 2016 03:57:30 +0000 (13:27 +0930)]
Don't include libbfd.h outside of bfd, part 2

Make bfd_default_set_arch_mach available to a bunch of gas backend
files.

bfd/
* archures.c (bfd_default_set_arch_mach): Make available in bfd.h.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
gas/
* config/tc-epiphany.c: Don't include libbfd.h.
* config/tc-frv.c: Likewise.
* config/tc-ip2k.c: Likewise.
* config/tc-iq2000.c: Likewise.
* config/tc-m32c.c: Likewise.
* config/tc-mep.c: Likewise.
* config/tc-mt.c: Likewise.
* config/tc-nios2.c: Likewise.

8 years agoDon't include libbfd.h outside of bfd, part 1
Alan Modra [Sat, 16 Jul 2016 03:55:11 +0000 (13:25 +0930)]
Don't include libbfd.h outside of bfd, part 1

Make BFD_ALIGN available to objcopy.  Fix assertions.  Don't use
bfd_log2 in ppc32elf.em or bfd_malloc in xtensaelf.em and bucomm.c.

bfd/
* libbfd-in.h (BFD_ALIGN): Move to..
* bfd-in.h: ..here.
* elf32-ppc.h (struct ppc_elf_params): Add pagesize.
* elf32-ppc.c (default_params): Adjust init.
(ppc_elf_link_params): Set pagesize_p2.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
binutils/
* ar.c: Don't include libbfd.h.
* objcopy.c: Likewise.
* bucomm.c (bfd_get_archive_filename): Use xmalloc rather than
bfd_malloc.
gas/
* config/bfin-parse.y: Don't include libbfd.h.
* config/tc-bfin.c: Likewise.
* config/tc-rl78.c: Likewise.
* config/tc-rx.c: Likewise.
* config/tc-metag.c: Likewise.
(create_dspreg_htabs, create_scond_htab): Use gas_assert not BFD_ASSERT.
* Makefile.am: Update dependencies.
* Makefile.in: Regenerate.
ld/
* ldlang.c: Don't include libbfd.h.
* emultempl/nds32elf.em: Likewise.
* emultempl/ppc64elf.em: Likewise.
* emultempl/ppc32elf.em: Likewise.
(pagesize): Delete.
(params): Update init.
(ppc_after_open_output): Use params.pagesize.  Don't call bfd_log2.
(PARSE_AND_LIST_ARGS_CASES): Use params.pagesize.
* emultempl/sh64elf.em: Don't include libbfd.h.
(after_allocation): Use ASSERT, not BFD_ASSERT.
* emultempl/xtensaelf.em: Don't include libbfd.h.
(replace_insn_sec_with_prop_sec): Use xmalloc, not bfd_malloc.
* Makefile.am: Update dependencies.
* Makefile.in: Regenerate.

8 years agoAutomatic date update in version.in
GDB Administrator [Sat, 16 Jul 2016 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoGDB testsuite: Escape paths used in regular expressions
Don Breazeal [Fri, 15 Jul 2016 18:19:19 +0000 (11:19 -0700)]
GDB testsuite: Escape paths used in regular expressions

This patch fixes problems with a few GDB testsuites when executing in a
path that contains special characters (e.g. "++").  When such paths are
used as a regular expression, the regular expression parser will choke
and cause the tests to fail.  This patch uses string_to_regexp to
escape strings that will be used as regular expressions, in order to
sanitize path names used in expect scripts.

2016-07-15  Zachary Welch  <zwelch@codesourcery.com>
    Don Breazeal <donb@codesourcery.com>

gdb/testsuite/ChangeLog:
* gdb.base/maint.exp: Escape paths used in regular expressions.
* gdb.stabs/weird.exp: Likewise.

8 years agoAdd support for creating ELF import libraries
Thomas Preud'homme [Fri, 15 Jul 2016 16:49:08 +0000 (17:49 +0100)]
Add support for creating ELF import libraries

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

bfd/
* elf-bfd.h (elf_backend_filter_implib_symbols): Declare backend hook.
(_bfd_elf_filter_global_symbols): Declare.
* elf.c (_bfd_elf_filter_global_symbols): New function.
* elflink.c (elf_filter_global_symbols): Likewise.
(elf_output_implib): Likewise.
(bfd_elf_final_link): Call above function, failing if it does.
* elfxx-target.h (elf_backend_filter_implib_symbols): Define macro and
default it to NULL.
(elf_backend_copy_indirect_symbol): Fix spacing.
(elf_backend_hide_symbol): Likewise.
(elfNN_bed): Initialize elf_backend_filter_implib_symbols backend hook.

include/
* bfdlink.h (struct bfd_link_info): Declare new ldscript_def and
out_implib_bfd fields.

2016-07-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>
    Nick Clifton  <nickc@redhat.com>

ld/
* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Open import
library file for writing and initialize implib_bfd field of link_info
structure.
* emultempl/pe.em (pe_implib_filename): Remove variable declaration.
(OPTION_IMPLIB_FILENAME): Remove macro definition.
(gld${EMULATION_NAME}_add_options): Remove --out-implib option.
(gld_${EMULATION_NAME}_list_options): Likewise.
(gld${EMULATION_NAME}_handle_option): Likewise.
(gld_${EMULATION_NAME}_finish): Use command_line.out_implib_filename
instead of pe_implib_filename.
* emultempl/pep.em (pep_implib_filename): Remove variable declaration.
(OPTION_IMPLIB_FILENAME): Remove enumerator.
(gld${EMULATION_NAME}_add_options): Remove --out-implib option.
(gld_${EMULATION_NAME}_list_options): Likewise.
(gld${EMULATION_NAME}_handle_option): Likewise.
(gld_${EMULATION_NAME}_finish): Use command_line.out_implib_filename
instead of pep_implib_filename.
* ld.h (args_type): Declare new out_implib_filename field.
* ld.texinfo (--out-implib): Move documentation to arch-independent
part and rephrase to apply to ELF targets.
* ldexp.c (exp_fold_tree_1): Set ldscript_def field to 1 for symbols
defined in linker scripts.
* ldlex.h (enum option_values): Declare new OPTION_OUT_IMPLIB
enumerator.
* lexsup.c (ld_options): Add entry for new --out-implib switch.
(parse_args): Handle OPTION_OUT_IMPLIB case.
* testsuite/ld-elf/elf.exp (Generate empty import library): New test.
(Generate import library): Likewise.
* testsuite/ld-elf/implib.s: Likewise.
* testsuite/ld-elf/implib.rd: New file.
* testsuite/ld-elf/empty-implib.out: Likewise

8 years agoPass SIGLIBRT directly to child processes.
John Baldwin [Sun, 3 Jul 2016 18:56:21 +0000 (11:56 -0700)]
Pass SIGLIBRT directly to child processes.

FreeBSD's librt uses SIGLIBRT as an internal signal to implement
SIGEV_THREAD sigevent notifications.  Similar to SIGLWP or SIGCANCEL
this signal should be passed through to child processes by default.

include/ChangeLog:

* signals.def: Add GDB_SIGNAL_LIBRT.

gdb/ChangeLog:

* common/signals.c (gdb_signal_from_host): Handle SIGLIBRT.
(do_gdb_signal_to_host): Likewise.
* infrun.c (_initialize_infrun): Pass GDB_SIGNAL_LIBRT through to
programs.
* proc-events.c (signal_table): Add entry for SIGLIBRT.

8 years agoTidy up debugging in the ARC port of the BFD library.
Nick Clifton [Fri, 15 Jul 2016 11:00:03 +0000 (12:00 +0100)]
Tidy up debugging in the ARC port of the BFD library.

bfd * elf32-arc.c (PR_DEBUG): Delete.
Fix printing of debug information.  Fix formatting of debug
statements.
(debug_arc_reloc): Handle symbols that are not from an input file.
(arc_do_relocation): Remove excessive exclamation points.
(elf_arc_relocate_section): Print an informative message if the
relocation fails, even if debugging is not enabled.
* arc-got.h: Fix formatting.  Fix printing of debug information.
(new_got_entry_to_list): Use xmalloc.
* config.bfd: use the big-endian arc vector as the default vector
for big-endian arc targets.

ld * testsuite/ld-arc/arc.exp: Always run the sda-relocs test in
little endian mode.

8 years agoUse address sized relocs in remove-relocs-01.s
Alan Modra [Fri, 15 Jul 2016 07:03:53 +0000 (16:33 +0930)]
Use address sized relocs in remove-relocs-01.s

Fixes failures on alpha, ia64, mcore, metag, moxie, and pj due to lack
of 16-bit relocs.

* testsuite/binutils-all/remove-relocs-01.s: Use .dc.a, not .word.

8 years agoCOFF buffer overflow in mark_relocs
Alan Modra [Fri, 15 Jul 2016 07:32:00 +0000 (17:02 +0930)]
COFF buffer overflow in mark_relocs

* cofflink.c (mark_relocs): Exclude relocs with -1 r_symndx
from marking sym_indices.

8 years agoAutomatic date update in version.in
GDB Administrator [Fri, 15 Jul 2016 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoMIPS/GAS: Don't convert PC-relative REL relocs against absolute symbols
Maciej W. Rozycki [Tue, 12 Jul 2016 00:31:29 +0000 (01:31 +0100)]
MIPS/GAS: Don't convert PC-relative REL relocs against absolute symbols

Don't convert PC-relative REL relocations against absolute symbols to
section-relative references and retain the original symbol reference
instead.  Offsets into the absolute section may overflow the limited
range of their in-place addend field, causing an assembly error, e.g.:

$ cat test.s
.text
.globl foo
.ent foo
foo:
b bar
.end foo

.set bar, 0x12345678
$ as -EB -32 -o test.o test.s
test.s: Assembler messages:
test.s:3: Error: relocation overflow
$

With the original reference retained the source can now be assembled and
linked successfully:

$ as -EB -32 -o test.o test.s
$ objdump -dr test.o

test.o:     file format elf32-tradbigmips

Disassembly of section .text:

00000000 <foo>:
   0: 1000ffff  b 0 <foo>
0: R_MIPS_PC16 bar
   4: 00000000  nop
...
$ ld -melf32btsmip -Ttext 0x12340000 -e foo -o test test.o
$ objdump -dr test

test:     file format elf32-tradbigmips

Disassembly of section .text:

12340000 <foo>:
12340000: 1000159d  b 12345678 <bar>
12340004: 00000000  nop
...
$

For simplicity always retain the original symbol reference, even if it
would indeed fit.

Making TC_FORCE_RELOCATION_ABS separate from TC_FORCE_RELOCATION causes
R_MICROMIPS_PC7_S1, R_MICROMIPS_PC10_S1 and R_MICROMIPS_PC16_S1 branch
relocations against absolute symbols to be converted on RELA targets to
section-relative references.  This is an intended effect of this change.
Absolute symbols carry no ISA annotation in their `st_other' field and
their value is not going to change with linker relaxation, so it is safe
to discard the original reference and keep the calculated final symbol
value only in the relocation's addend.

Similarly R6 R_MIPS_PCHI16 and R_MIPS_PCLO16 relocations referring
absolute symbols can be safely converted even on REL targets, as there
the in-place addend of these relocations covers the entire 32-bit
address space so it can hold the calculated final symbol value, and
likewise the value referred won't be affected by any linker relaxation.

Add a set of suitable test cases and enable REL linker tests which now
work and were previously used as dump patterns for RELA tests only.

gas/
* config/tc-mips.h (TC_FORCE_RELOCATION_ABS): New macro.
(mips_force_relocation_abs): New prototype.
* config/tc-mips.c (mips_force_relocation_abs): New function.
* testsuite/gas/mips/branch-absolute.d: Adjust dump patterns.
* testsuite/gas/mips/mips16-branch-absolute.d: Likewise.
* testsuite/gas/mips/micromips-branch-absolute-n32.d: Likewise.
* testsuite/gas/mips/micromips-branch-absolute-n64.d: Likewise.
* testsuite/gas/mips/micromips-branch-absolute-addend-n32.d:
Likewise.
* testsuite/gas/mips/micromips-branch-absolute-addend-n64.d:
Likewise.
* testsuite/gas/mips/branch-absolute-addend.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-addend.d: New test.
* testsuite/gas/mips/micromips-branch-absolute-addend.d: New
test.
* testsuite/gas/mips/mips.exp: Run the new tests.

ld/
* testsuite/ld-mips-elf/mips-elf.exp: Run
`branch-absolute-addend', `mips16-branch-absolute',
`mips16-branch-absolute-addend' and
`micromips-branch-absolute-addend'.

8 years agoMIPS/GAS: Keep the ISA bit in the addend of branch relocations
Maciej W. Rozycki [Tue, 12 Jul 2016 00:30:48 +0000 (01:30 +0100)]
MIPS/GAS: Keep the ISA bit in the addend of branch relocations

Correct a problem with the ISA bit being stripped from the addend of
compressed branch relocations, affecting RELA targets.  It has been
there since microMIPS support has been added, with:

commit df58fc944dbc6d5efd8d3826241b64b6af22f447
Author: Richard Sandiford <rdsandiford@googlemail.com>
Date:   Sun Jul 24 14:20:15 2011 +0000

<https://sourceware.org/ml/binutils/2011-07/msg00198.html>, ("MIPS:
microMIPS ASE support") and R_MICROMIPS_PC7_S1, R_MICROMIPS_PC10_S1 and
R_MICROMIPS_PC16_S1 relocations originally affected, and the
R_MIPS16_PC16_S1 relocation recently added with commit c9775dde3277
("MIPS16: Add R_MIPS16_PC16_S1 branch relocation support") actually
triggering a linker error, due to its heightened processing strictness
level:

$ cat test.s
.text
.set mips16
foo:
b bar

.set bar, 0x1235
.align 4, 0
$ as -EB -n32 -o test.o test.s
$ objdump -dr test.o

test.o:     file format elf32-ntradbigmips

Disassembly of section .text:

00000000 <foo>:
   0: f000 1000  b 4 <foo+0x4>
0: R_MIPS16_PC16_S1 *ABS*+0x1230
...
$ ld -melf32btsmipn32 -Ttext 0 -e 0 -o test test.o
test.o: In function `foo':
(.text+0x0): Branch to a non-instruction-aligned address
$

This is because the ISA bit of the branch target does not match the ISA
bit of the referring branch, hardwired to 1 of course.

Retain the ISA bit then, so that the linker knows this is really MIPS16
code referred:

$ objdump -dr fixed.o

fixed.o:     file format elf32-ntradbigmips

Disassembly of section .text:

00000000 <foo>:
   0: f000 1000  b 4 <foo+0x4>
0: R_MIPS16_PC16_S1 *ABS*+0x1231
...
$ ld -melf32btsmipn32 -Ttext 0 -e 0 -o fixed fixed.o
$

Add a set of MIPS16 tests to cover the relevant cases, excluding linker
tests though which would overflow the in-place addend on REL targets and
use them as dump patterns for RELA targets only.

gas/
* config/tc-mips.c (md_apply_fix) <BFD_RELOC_MIPS16_16_PCREL_S1>
<BFD_RELOC_MICROMIPS_7_PCREL_S1, BFD_RELOC_MICROMIPS_10_PCREL_S1>
<BFD_RELOC_MICROMIPS_16_PCREL_S1>: Keep the ISA bit in the
addend calculated.
* testsuite/gas/mips/mips16-branch-absolute.s: Set the ISA bit
in `bar', export `foo'.
* testsuite/gas/mips/mips16-branch-absolute.d: Adjust
accordingly.
* testsuite/gas/mips/mips16-branch-absolute-n32.d: Likewise.
* testsuite/gas/mips/mips16-branch-absolute-n64.d: Likewise.
* testsuite/gas/mips/mips16-branch-absolute-addend-n32.d:
Likewise.
* testsuite/gas/mips/mips16-branch-absolute-addend-n64.d:
Likewise.

ld/
* testsuite/ld-mips-elf/mips16-branch-absolute.d: New test.
* testsuite/ld-mips-elf/mips16-branch-absolute-n32.d: New test.
* testsuite/ld-mips-elf/mips16-branch-absolute-n64.d: New test.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend.d: New
test.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n32.d: New
test.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n64.d: New
test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests, except
from `mips16-branch-absolute' and
`mips16-branch-absolute-addend', referred indirectly only.

8 years agoBFD: Let targets handle relocations against absolute symbols
Maciej W. Rozycki [Tue, 12 Jul 2016 00:30:01 +0000 (01:30 +0100)]
BFD: Let targets handle relocations against absolute symbols

Fix a generic BFD issue with relocations against absolute symbols, which
are installed without using any individual relocation handler provided
by the backend.  This causes any absolute section's addend to be lost on
REL targets such as o32 MIPS, and also relocation-specific calculation
adjustments are not made.

As an example assembling this program:

$ cat test.s
.text
foo:
b bar
b baz

.set bar, 0x1234
$ as -EB -32 -o test-o32.o test.s
$ as -EB -n32 -o test-n32.o test.s

produces this binary code:

$ objdump -dr test-o32.o test-n32.o

test-o32.o:     file format elf32-tradbigmips

Disassembly of section .text:

00000000 <foo>:
   0: 10000000  b 4 <foo+0x4>
0: R_MIPS_PC16 *ABS*
   4: 00000000  nop
   8: 1000ffff  b 8 <foo+0x8>
8: R_MIPS_PC16 baz
   c: 00000000  nop

test-n32.o:     file format elf32-ntradbigmips

Disassembly of section .text:

00000000 <foo>:
   0: 10000000  b 4 <foo+0x4>
0: R_MIPS_PC16 *ABS*+0x1230
   4: 00000000  nop
   8: 10000000  b c <foo+0xc>
8: R_MIPS_PC16 baz-0x4
   c: 00000000  nop
$

where it is clearly visible in `test-o32.o', which uses REL relocations,
that the absolute section's addend equivalent to the value of `bar' -- a
reference to which cannot be fully resolved at the assembly time,
because the reference is PC-relative -- has been lost, as has been the
relocation-specific adjustment of -4, required to take into account the
PC+4-relative calculation made by hardware with branches and seen in the
external symbol reference to `baz' as the `ffff' addend encoded in the
instruction word.  In `test-n32.o', which uses RELA relocations, the
absolute section's addend has been correctly retained.

Give precedence then in `bfd_perform_relocation' and
`bfd_install_relocation' to any individual relocation handler the
backend selected may have provided, while still resorting to the generic
calculation otherwise.  This retains the semantics which we've had since
forever or before the beginning of our repository history, and is at the
very least compatible with `bfd_elf_generic_reloc' being used as the
handler.

Retain the `bfd_is_und_section' check unchanged at the beginning of
`bfd_perform_relocation' since this does not affect the semantics of the
function.  The check returns the same `bfd_reloc_undefined' code the
check for a null `howto' does, so swapping the two does not matter.
Also the check is is mutually exclusive with the `bfd_is_abs_section'
check, since a section cannot be absolute and undefined both at once, so
swapping the two does not matter either.

With this change applied the program quoted above now has the in-place
addend correctly calculated and installed in the field being relocated:

$ objdump -dr fixed-o32.o

fixed-o32.o:     file format elf32-tradbigmips

Disassembly of section .text:

00000000 <foo>:
   0: 1000048c  b 1234 <bar>
0: R_MIPS_PC16 *ABS*
   4: 00000000  nop
   8: 1000ffff  b 8 <foo+0x8>
8: R_MIPS_PC16 baz
   c: 00000000  nop
$

Add a set of MIPS tests to cover the relevant cases, including absolute
symbols with addends, and verifying that PC-relative relocations against
symbols concerned resolve to the same value in the final link regardless
of whether the REL or the RELA relocation form is used.  Exclude linker
tests though which would overflow the in-place addend on REL targets and
use them as dump patterns for RELA targets only.

bfd/
* reloc.c (bfd_perform_relocation): Try the `howto' handler
first with relocations against absolute symbols.
(bfd_install_relocation): Likewise.

gas/
* testsuite/gas/mips/mips16-branch-absolute.d: Update patterns.
* testsuite/gas/mips/branch-absolute.d: New test.
* testsuite/gas/mips/branch-absolute-n32.d: New test.
* testsuite/gas/mips/branch-absolute-n64.d: New test.
* testsuite/gas/mips/branch-absolute-addend-n32.d: New test.
* testsuite/gas/mips/branch-absolute-addend-n64.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-n32.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-n64.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-addend-n32.d: New
test.
* testsuite/gas/mips/mips16-branch-absolute-addend-n64.d: New
test.
* testsuite/gas/mips/micromips-branch-absolute.d: New test.
* testsuite/gas/mips/micromips-branch-absolute-n32.d: New test.
* testsuite/gas/mips/micromips-branch-absolute-n64.d: New test.
* testsuite/gas/mips/micromips-branch-absolute-addend-n32.d: New
test.
* testsuite/gas/mips/micromips-branch-absolute-addend-n64.d: New
test.
* testsuite/gas/mips/branch-absolute.s: New test source.
* testsuite/gas/mips/branch-absolute-addend.s: New test source.
* testsuite/gas/mips/mips16-branch-absolute-addend.s: New test
source.
* testsuite/gas/mips/micromips-branch-absolute.s: New test
source.
* testsuite/gas/mips/micromips-branch-absolute-addend.s: New
test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

ld/
* testsuite/ld-mips-elf/branch-absolute.d: New test.
* testsuite/ld-mips-elf/branch-absolute-n32.d: New test.
* testsuite/ld-mips-elf/branch-absolute-n64.d: New test.
* testsuite/ld-mips-elf/branch-absolute-addend.d: New test.
* testsuite/ld-mips-elf/branch-absolute-addend-n32.d: New test.
* testsuite/ld-mips-elf/branch-absolute-addend-n64.d: New test.
* testsuite/ld-mips-elf/micromips-branch-absolute.d: New test.
* testsuite/ld-mips-elf/micromips-branch-absolute-n32.d: New
test.
* testsuite/ld-mips-elf/micromips-branch-absolute-n64.d: New
test.
* testsuite/ld-mips-elf/micromips-branch-absolute-addend.d: New
test.
* testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d:
New test.
* testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d:
New test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests, except
from `branch-absolute-addend' and
`micromips-branch-absolute-addend', referred indirectly only.

8 years agoAdd missing newline to py-breakpoint.c
Tom Tromey [Thu, 14 Jul 2016 17:50:55 +0000 (11:50 -0600)]
Add missing newline to py-breakpoint.c

In https://sourceware.org/ml/gdb-patches/2016-07/msg00152.html,
Yao noted that a patch of mine was missing a newline.

I thought I had fixed this but when looking today I realized it was
not fixed.  This patch adds it.

I'm checking this in as obvious.

2016-07-14  Tom Tromey  <tom@tromey.com>

* python/py-breakpoint.c (gdbpy_breakpoint_deleted): Add missing
newline.

8 years agoRemove unused variables
Tom Tromey [Mon, 6 Jun 2016 20:18:30 +0000 (14:18 -0600)]
Remove unused variables

This patch removes set-but-unused variables.  This holds all the
removals I consider to be simple and relatively uncontroversial.

2016-07-14  Tom Tromey  <tom@tromey.com>

* mips-tdep.c (micromips_scan_prologue): Remove "frame_addr".
(mips_o32_push_dummy_call): Remove "stack_used_p".
* aarch64-tdep.c (aarch64_record_data_proc_imm): Remove
"insn_bit28".
* rust-lang.c (rust_print_type): Remove "len".
* rust-exp.y (super_name): Remove "current_len".
* python/py-framefilter.c (py_print_type): Remove "type".
* mdebugread.c (parse_partial_symbols): Remove
"past_first_source_file".
<N_SO>: Remove "valu", "first_so_symnum", "prev_textlow_not_set".
* m2-valprint.c (m2_print_unbounded_array): Remove
"content_type".
(m2_val_print): Remove "i".
* linespec.c (unexpected_linespec_error): Remove "cleanup".
* f-valprint.c (f_val_print): Remove "i".
* elfread.c (elf_symtab_read): Remove "offset".
* dwarf2-frame.c (dwarf2_fetch_cfa_info): Remove "addr_size".
* jit.c (jit_dealloc_cache): Remove "i" and "frame_arch".

8 years agoRemove some variables but call functions for side effects
Tom Tromey [Mon, 6 Jun 2016 20:18:23 +0000 (14:18 -0600)]
Remove some variables but call functions for side effects

This patch consolidates the (possibly-questionable) spots where we
remove a declaration but continue to call some function for side
effects.  In a couple of cases it wasn't entirely clear to me that
this mattered; and in some other cases it might be more aesthetically
pleasing to use ATTRIBUTE_UNUSED.  So, I broke this out into a
separate patch for simpler review.

2016-07-14  Tom Tromey  <tom@tromey.com>

* arch-utils.c (default_skip_permanent_breakpoint): Remove
"bp_insn".
* disasm.c (do_assembly_only): Remove "num_displayed".
* dwarf2read.c (read_abbrev_offset): Remove "length".
(dwarf_decode_macro_bytes) <DW_MACINFO_vendor_ext>: Remove
"constant".
* m32c-tdep.c (make_regs): Remove "r2hl", "r3hl", and "intbhl".
* microblaze-tdep.c (microblaze_frame_cache): Remove "func".
* tracefile.c (trace_save): Remove "status".

8 years agoRemove some unused overlay code
Tom Tromey [Mon, 6 Jun 2016 19:45:59 +0000 (13:45 -0600)]
Remove some unused overlay code

This patch removes some unneeded initializations in overlay code in
symfile.c.  It also deletes some old commented-out code.

2016-07-14  Tom Tromey  <tom@tromey.com>

* symfile.c (simple_overlay_update_1): Remove initialization
of "size", and commented-out code.
(simple_overlay_update): Likewise.

8 years agoUse getcurx in curses code
Tom Tromey [Tue, 28 Jun 2016 20:25:49 +0000 (14:25 -0600)]
Use getcurx in curses code

As suggested by Pedro, this changes a few spots to use getcurx, rather
than getyx.  This avoids some unused variable warnings.

2016-07-14  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.c (tui_show_source_line): Use getcurx.
* tui/tui-io.c (tui_puts): Use getcurx.
(tui_redisplay_readline): Likewise.

8 years agoAdd one use of ATTRIBUTE_UNUSED
Tom Tromey [Mon, 6 Jun 2016 19:43:50 +0000 (13:43 -0600)]
Add one use of ATTRIBUTE_UNUSED

One spot needed ATTRIBUTE_UNUSED to cope with the new warnings.

The case in inflow.c is just a mass of ifdefs; and while the only use
of "result" is guarded by "#if 0", I thought it simplest to leave it
all in place.

2016-07-14  Tom Tromey  <tom@tromey.com>

* inflow.c (child_terminal_ours_1): Use ATTRIBUTE_UNUSED.

8 years agoChange reopen_exec_file to check result of stat
Tom Tromey [Mon, 6 Jun 2016 19:01:52 +0000 (13:01 -0600)]
Change reopen_exec_file to check result of stat

This seems to be a real bug found by -Wunused-but-set-variable.  If
"stat" fails for some reason, gdb would use the uninitialized "st".

2016-07-14  Tom Tromey  <tom@tromey.com>

* corefile.c (reopen_exec_file): Only examine st.st_mtime if stat
succeeded.

8 years agoobjcopy/strip: Add option --remove-relocations=SECTIONPATTERN
Andrew Burgess [Fri, 21 Aug 2015 19:08:26 +0000 (20:08 +0100)]
objcopy/strip: Add option --remove-relocations=SECTIONPATTERN

The objcopy and strip tools make use of the bfd library to manipulate
the state of the input file (to produce an output file).  Within the
input file (for ELF at least), relocations are held within a section,
and so, if the user wanted to remove the relocations, but keep the
section to which the relocations would have been applied, it is tempting
to think that specifying the name of a relocation section to objcopy's
--remove-section option might do what you want, for example:

   objcopy --remove-section=.rela.text input.elf output.elf

However, this does not work.  The reason is that when the input file is
loaded, relocations are not managed as sections, but are, instead,
loaded as data associated with the section to which the relocations
would be applied.  In our example above the relocations in '.rela.text'
are held as data on the section '.text' once 'input.elf' is loaded.

One task that objcopy and strip do is copy the relocations from the
input file to the output file if the section is also being copied from
the input file to the output file.

This commit adds a new command line option for objcopy and strip,
--remove-relocations, which can be used to remove the relocations, while
keeping the section that the relocations would have been applied to, for
example:

    objcopy --remove-relocations=.text input.elf output.elf

in this case the section '.text' will appear in both 'input.elf' and
'output.elf', but any relocations in 'input.elf' that apply to '.text'
will not be present in 'output.elf'.

I have also added a special case to the handling of --remove-section
that spots if a user tries to remove a relocation section (currently
this is done by spotting the '.rela.' or '.rel.' prefix) and forwards
the request to --remove-relocations.

As with --remove-section and --only-section the --remove-relocations
option supports the '!' prefix on the section-patterns it takes to allow
for sections to be specifically not matched.

There are tests for all the new functionality.

binutils/ChangeLog:

* doc/binutils.texi (objcopy): Document 'remove-relocations'.
(strip): Likewise.
* objcopy.c (SECTION_CONTEXT_REMOVE_RELOCS): Define.
(enum command_line_switch): Add 'OPTION_REMOVE_RELOCS'.
(struct option strip_options): Add 'remove-relocations'.
(struct option copy_options): Likewise.
(copy_usage): Likewise.
(strip_usage): Likewise.
(handle_remove_relocations_option): New function.
(discard_relocations): New function.
(handle_remove_section_option): New function.
(copy_relocations_in_section): Use discard_relocations.
(strip_main): Use handle_remove_section_option for
'remove-section', and handle 'remove-relocations' option.
(copy_main): Likewise.
* testsuite/binutils-all/objcopy.exp: Run new tests.
* testsuite/binutils-all/remove-relocs-01.d: New file.
* testsuite/binutils-all/remove-relocs-01.s: New file.
* testsuite/binutils-all/remove-relocs-02.d: New file.
* testsuite/binutils-all/remove-relocs-03.d: New file.
* testsuite/binutils-all/remove-relocs-04.d: New file.
* testsuite/binutils-all/remove-relocs-05.d: New file.
* testsuite/binutils-all/remove-relocs-06.d: New file.

8 years agoobjcopy/strip: Allow section patterns starting with '!'.
Andrew Burgess [Mon, 24 Aug 2015 12:02:39 +0000 (13:02 +0100)]
objcopy/strip: Allow section patterns starting with '!'.

For symbol matching, prefixing a pattern with '!' will indicate a
non-matching pattern, however, this is not the case for section
patterns.  As a result it is not possible to say "apply this action to
all sections except ...".

With this commit the objcopy and strip tools now support '!' prefix for
section patterns, so we can say:

  objcopy --remove-section="*" --remove-section="!.text*"

Which will remove all sections, except those matching the pattern
'.text*'.

binutils/ChangeLog:

* objcopy.c (find_section_list): Handle section patterns starting
with '!' being a non-matching pattern.
* doc/binutils.texi (objcopy): Give example of using '!' with
--remove-section and --only-section.
(strip): Give example of using '!' with --remove-section.
* testsuite/binutils-all/data-sections.s: New file.
* testsuite/binutils-all/only-section-01.d: New file.
* testsuite/binutils-all/remove-section-01.d: New file.
* testsuite/binutils-all/objcopy.exp: Run new tests.
* NEWS: Mention new feature.

8 years agoSmall improvements to the ARM simulator to cope with illegal binaries.
Nick Clifton [Thu, 14 Jul 2016 09:38:07 +0000 (10:38 +0100)]
Small improvements to the ARM simulator to cope with illegal binaries.

* armemu.c (Multiply64): Only issue error messages about invalid
arguments if debugging is enabled.
* armos.c (ARMul_OSHandleSWI): Ignore invalid flags.

8 years ago[ARC] Fix/improve small data support.
Claudiu Zissulescu [Fri, 8 Jul 2016 09:55:49 +0000 (11:55 +0200)]
[ARC] Fix/improve small data support.

The R_ARC_SDA32 is wrongly described as a ME relocation, fix it.  Offset the
__SDATA_BEGIN__ to take advantage of the signed 9-bit field of the
load/store instructions.

include/
2016-07-08  Claudiu Zissulescu  <claziss@synopsys.com>

* elf/arc-reloc.def (ARC_SDA32): Don't use ME transformation.

ld/
2016-07-08  Claudiu Zissulescu  <claziss@synopsys.com>

* emulparams/arcelf.sh (SDATA_START_SYMBOLS): Add offset.
* testsuite/ld-arc/sda-relocs.dd: New file.
* testsuite/ld-arc/sda-relocs.ld: Likewise.
* testsuite/ld-arc/sda-relocs.rd: Likewise.
* testsuite/ld-arc/sda-relocs.s: Likewise.
* testsuite/ld-arc/arc.exp: Add SDA tests.

8 years agoAutomatic date update in version.in
GDB Administrator [Thu, 14 Jul 2016 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoPR python/15620, PR python/18620 - breakpoint events in Python
Tom Tromey [Tue, 5 May 2015 03:49:11 +0000 (21:49 -0600)]
PR python/15620, PR python/18620 - breakpoint events in Python

This patch adds some breakpoint events to Python.  In particular,
there is a creation event that is emitted when a breakpoint is
created; a modification event that is emitted when a breakpoint
changes somehow; and a deletion event that is emitted when a
breakpoint is deleted.

In this patch, the event's payload is the breakpoint itself.  I
considered making a new event type to hold the breakpoint, but I
didn't see a need.  Still, I thought I would mention this as a spot
where some other choice is possible.

Built and regtested on x86-64 Fedora 23.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR python/15620, PR python/18620:
* python/py-evts.c (gdbpy_initialize_py_events): Call
add_new_registry for new events.
* python/py-events.h (events_object) <breakpoint_created,
breakpoint_deleted, breakpoint_modified>: New fields.
* python/py-breakpoint.c (gdbpy_breakpoint_created): Emit the
breakpoint changed event.
(gdbpy_breakpoint_deleted): Emit the breakpoint deleted event.
(gdbpy_breakpoint_modified): New function.
(gdbpy_initialize_breakpoints): Attach to the breakpoint modified
observer.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR python/15620, PR python/18620:
* python.texi (Events In Python): Document new breakpoint events.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR python/15620, PR python/18620:
* gdb.python/py-breakpoint.exp (connect_event, check_last_event)
(test_bkpt_events): New procs.

8 years agoPR python/17698 - add Breakpoint.pending
Tom Tromey [Thu, 19 May 2016 21:51:00 +0000 (15:51 -0600)]
PR python/17698 - add Breakpoint.pending

This patch adds a "pending" attribute to gdb.Breakpoint.

Built and regtested on x86-64 Fedora 23.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR python/17698:
* NEWS: Update.
* python/py-breakpoint.c (bppy_get_pending): New function.
(breakpoint_object_getset): Add entry for "pending".
* breakpoint.h (pending_breakpoint_p): Declare.
* breakpoint.c (pending_breakpoint_p): New function.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR python/17698:
* python.texi (Breakpoints In Python): Document
Breakpoint.pending.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR python/17698:
* gdb.python/py-breakpoint.exp (test_bkpt_basic): Add "pending"
test.
(test_watchpoints): Likewise.
(test_bkpt_pending): New proc.

8 years agouse user_breakpoint_p in python code
Tom Tromey [Thu, 19 May 2016 21:52:52 +0000 (15:52 -0600)]
use user_breakpoint_p in python code

I noticed that bppy_get_visibility and gdbpy_breakpoint_created
implemented their own visibility checks, but subtly different from
user_breakpoint_p.  I think the latter is more correct, and so changed
the Python code to use it.

I suspect there isn't a decent way to test this, so no new test.

Built and regtested on x86-64 Fedora 23.

2016-07-13  Tom Tromey  <tom@tromey.com>

* python/py-breakpoint.c (bppy_get_visibility)
(gdbpy_breakpoint_created): Use user_breakpoint_p.

8 years agoRearrange Python breakpoint node in documentation
Tom Tromey [Thu, 19 May 2016 21:40:54 +0000 (15:40 -0600)]
Rearrange Python breakpoint node in documentation

I noticed that the Python breakpoint documentation was ordered a bit
oddly.  It documented the constructor; then the stop method; then the
watchpoint constants (used for the constructor); then various other
methods and attributes; then the other constants used by the
constructor; and then finally some more methods and attributes.

This patch rearranges the node a little to move the constants to just
after the constructor and before the other methods and attributes.

2016-07-13  Tom Tromey  <tom@tromey.com>

* python.texi (Breakpoints In Python): Move table of types and
table of watchpoint types earlier in node.

8 years agoFix PR cli/18053
Tom Tromey [Mon, 2 Mar 2015 03:33:00 +0000 (20:33 -0700)]
Fix PR cli/18053

PR cli/18053 concerns a couple of minor bugs in the JIT debuginfo
support.  First, jit-reader-load should use filename completion and
support tilde expansion.  Second, the help for jit-reader-unload is
incorrect.  While working on this I also realized that
jit-reader-unload should use the no-op completer, so I've included
that as well.

Built and regtested on x86-64 Fedora 23.  A completer test for
jit-reader-load is included, but not a tilde-expansion test, as I
couldn't think of a reliable way to test that.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR cli/18053:
* jit.c (jit_reader_load_command): Use tilde_expand.
(_initialize_jit): Fix help for jit-reader-unload.  Set completer
for new commands.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR cli/18053:
* gdb.base/jit-so.exp (one_jit_test): Add jit-reader-load
completion test.

8 years agoMIPS/opcodes: Address issues with NAL disassembly
Maciej W. Rozycki [Fri, 8 Jul 2016 15:07:39 +0000 (16:07 +0100)]
MIPS/opcodes: Address issues with NAL disassembly

Address issues with the disassembly of the NAL assembly idiom and R6
instruction introduced with commit 7361da2c952e ("Add support for MIPS
R6.") and then further tweaked with commit b9121b573e2e ("Add in a JALRC
alias and fix the NAL instruction.").  As from R6 this instruction has
replaced the encoding of `bltzal $0, . + 4' as the solely supported form
of the former BLTZAL instruction for the regular MIPS ISA.

The instruction is marked as an alias only in our regular MIPS opcode
table, making it fail to disassemble in R6 code if the `no-aliases'
machine option has been passed to `objdump':

$ cat test.s
.text
foo:
nal
$ as -mips64r6 -o test.o test.s
$ objdump -dr --prefix-addresses --show-raw-insn -M no-aliases test.o

nal.o:     file format elf32-tradbigmips

Disassembly of section .text:
00000000 <foo> 04100000  0x4100000
...
$

This is because the `bltzal' entry has been marked as pre-R6 only in the
opcode table and there is no other opcode pattern to match.

Additionally the changes referred made NAL replace the equivalent
`bltzal $0, . + 4' instruction in disassembly, unless the `no-aliases'
machine option has been used, in legacy code.  Seeing NAL, especially in
its updated form lacking the branch target argument, in the disassembly
of such code may be confusing to people.  This is because unlike with
EHB only used in R2 and newer code -- the machine encoding of which we
anyway always disassemble to its corresponding current architecture's
mnemonic rather than its legacy meaning of `sll $0, $0, 3' -- BLTZAL has
been indeed used in legacy code.  Even though `bltzal $0, . + 8' and its
machine code encoding (0x04100001) -- which is not equivalent to NAL and
still disassembles as BLTZAL -- has been the predominant form as opposed
to NAL's `bltzal $0, . + 4' (0x04100000), it makes sense to always keep
the old form in disassembly, while still accepting `nal' in assembly.

Remove the alias marking then from the the `nal' instruction pattern,
making it always match for R6 code, even with the `no-aliases' option.
And move the entry beyond the `bltzal' entry, making the latter one take
precedence for legacy binary code, while letting the former still match
any `nal' mnemonic in source code assembled for a legacy target.

Add a suitable test case to the GAS test suite.  While the change
affects the disassembler more than the assembler, so placing the test
case in the binutils test suite might be more appropriate, the intent is
also to verify that `nal' is still accepted by GAS for legacy targets,
plus we have test infrastructure available in the GAS test suite for
automatic multiple ISA level testing, which we lack from the binutils
framework.

opcodes/
* mips-opc.c (mips_builtin_opcodes): Remove the INSN2_ALIAS
annotation from the "nal" entry and reorder it beyond "bltzal".

gas/
* testsuite/gas/mips/nal-1.d: New test.
* testsuite/gas/mips/mipsr6@nal-1.d: New test.
* testsuite/gas/mips/nal-2.d: New test.
* testsuite/gas/mips/mipsr6@nal-2.d: New test.
* testsuite/gas/mips/nal.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

8 years agoMIPS/GAS: Remove extraneous `install_insn' call from `append_insn' (CL)
Maciej W. Rozycki [Wed, 13 Jul 2016 16:31:17 +0000 (17:31 +0100)]
MIPS/GAS: Remove extraneous `install_insn' call from `append_insn' (CL)

Add missing ChangeLog entry for commit b8bca85b334b ("MIPS/GAS: Remove
extraneous `install_insn' call from `append_insn'").

8 years agoopcodes,gas: support for the ldtxa SPARC instructions.
Jose E. Marchesi [Wed, 13 Jul 2016 08:42:28 +0000 (01:42 -0700)]
opcodes,gas: support for the ldtxa SPARC instructions.

This patch adds support for the LDTXA instructions, along with the
corresponding ASIs.  Tests for GAS are included.

opcodes/ChangeLog:

2016-07-12  Jose E. Marchesi  <jose.marchesi@oracle.com>

* sparc-opc.c (ldtxa): New macro.
(sparc_opcodes): Use the macro defined above to add entries for
the LDTXA instructions.
(asi_table): Add the ASI_TWINX_* asis used in the LDTXA
instruction.

gas/ChangeLog:

2016-07-12  Jose E. Marchesi  <jose.marchesi@oracle.com>

* testsuite/gas/sparc/ldtxa.s: New file.
* testsuite/gas/sparc/ldtxa.d: Likewise.
* testsuite/gas/sparc/sparc.exp: Execute the ldtxa test.

8 years ago[ppc64] Fix for function descriptors
Jan Kratochvil [Wed, 13 Jul 2016 11:58:19 +0000 (13:58 +0200)]
[ppc64] Fix for function descriptors

Marin Cermak has found various testcases (or one of them) of GDB FAIL on
ppc64.

https://sourceware.org/bugzilla/show_bug.cgi?id=20328

.o contained only the function descriptor address.

The DWARF as produced by Tcl Dwarf::assemble:
 <1><27>: Abbrev Number: 4 (DW_TAG_subprogram)
    <28>   DW_AT_name        : main
    <2d>   DW_AT_external    : 1
    <2e>   DW_AT_low_pc      : 0x1001ff98
    <36>   DW_AT_high_pc     : 0x1002ff98
 <2><3e>: Abbrev Number: 5 (DW_TAG_lexical_block)

Runtime info:
$2 = {<text variable, no debug info>} 0x10000674 <.main>
$3 = {void ()} 0x1001ff98 <main>

On Tue, 12 Jul 2016 15:22:49 +0200, Ulrich Weigand wrote:
Well, most of the gdb.dwarf2 test cases simply use explicitly placed labels
for the DW_AT_low_pc / DW_AT_high_pc attributes.

See e.g. dw2-unresolved-main.c:

asm (".globl cu_text_start");
asm ("cu_text_start:");

On Wed, 13 Jul 2016 10:54:00 +0200, Jan Kratochvil wrote:
Now I see I should not do that because:

lib/dwarf.exp:
proc function_range { func src } {

So I am providing this patch.

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

* gdb.dwarf2/atomic-type.exp: Use function_range for low_pc and high_pc.
* gdb.dwarf2/atomic.c (f): Rename f_end_lbl to f_label.
* gdb.dwarf2/dw2-bad-mips-linkage-name.c (f): Rename f_end_lbl to
f_label.
(g): Rename g_end_lbl to g_label.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp: Use function_range for
low_pc and high_pc.
* gdb.dwarf2/dw2-lexical-block-bare.exp: Likewise.

8 years agoAutomatic date update in version.in
GDB Administrator [Wed, 13 Jul 2016 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoAlign x86-64 .got/.got.plt sections to 8 bytes
H.J. Lu [Tue, 12 Jul 2016 22:33:47 +0000 (15:33 -0700)]
Align x86-64 .got/.got.plt sections to 8 bytes

Align x86-64 .got and .got.plt sections to their entry size.

* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Align
.got/.got.plt sections to 8 bytes.

8 years agoPR python/19293 - invalidate frame cache when unwinders change
Tom Tromey [Thu, 9 Jun 2016 21:20:09 +0000 (15:20 -0600)]
PR python/19293 - invalidate frame cache when unwinders change

PR python/19293 notes that when a Python unwinder is disabled, the
frame cache is not invalidated.  This means that disabling an unwinder
doesn't have any immediate effect -- but in my experience it's often
the case that I want to enable or disable an unwinder in order to see
what happens.

This patch adds a new gdb.invalidate_cached_frames function and
arranges for the relevant bits of library code to call it.  I've only
partially documented this function, considering a warning sufficient
without going into all the reasons ordinary code should not call it.
The name of the new function was taken from a comment in frame.h next
to reinit_frame_cache.

No new test as I think the updates to the existing test are sufficient
to show that the code is working as intended.

Built and regtested on x86-64 Fedora 23.

2016-07-12  Tom Tromey  <tom@tromey.com>

PR python/19293:
* python/lib/gdb/command/unwinders.py (do_enable_unwinder): Call
gdb.invalidate_cached_frames.
* python/lib/gdb/unwinder.py (register_unwinder): Call
gdb.invalidate_cached_frames.
* python/python.c (gdbpy_invalidate_cached_frames): New function.
(python_GdbMethods): Add entry for invalidate_cached_frames.

2016-07-12  Tom Tromey  <tom@tromey.com>

PR python/19293:
* python.texi (Frames In Python): Document
gdb.invalidate_cached_frames.

2016-07-12  Tom Tromey  <tom@tromey.com>

PR python/19293:
* gdb.python/py-unwind-maint.exp: Update tests.

8 years agoSecond fix for grammar in error message.
Nick Clifton [Tue, 12 Jul 2016 14:46:02 +0000 (15:46 +0100)]
Second fix for grammar in error message.

* binary.c (binary_set_section_contents): Second grammar fix.

8 years agoMatch the selftest output when captured_main is inlined
Yao Qi [Tue, 12 Jul 2016 14:39:34 +0000 (15:39 +0100)]
Match the selftest output when captured_main is inlined

In gdb.gdb/observer.exp, I see the following fail,

(gdb) break captured_main^M
Breakpoint 1 at 0x57e409: file ../../binutils-gdb/gdb/main.c, line 492.^M
(gdb) PASS: gdb.gdb/observer.exp: breakpoint in captured_main
run -nw -nx -data-directory /home/yao.qi/SourceCode/gnu/build/gdb/testsuite/../data-directory^M
Starting program: /home/yao.qi/SourceCode/gnu/build/gdb/testsuite/outputs/gdb.gdb/observer/xgdb -nw -nx -data-directory /home/yao.qi/SourceCode/gnu/build/gdb/testsuite/../data-directory^M
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".^M
^M
Breakpoint 1, gdb_main (args=args@entry=0x7fffffffdca0) at ../../binutils-gdb/gdb/main.c:1157^M
1157          captured_main (args);^M
(gdb) FAIL: gdb.gdb/observer.exp: run until breakpoint at captured_main

looks the test sets breakpoint on captured_main, and expects program
stops at captured_main.  However, program stops at the place where
captured_main is called, because captured_main is inlined,

 <1><8519e3>: Abbrev Number: 58 (DW_TAG_subprogram)
    <8519e4>   DW_AT_name        : (indirect string, offset: 0x880d3): captured_main
    <8519e8>   DW_AT_decl_file   : 1
    <8519e9>   DW_AT_decl_line   : 444
    <8519eb>   DW_AT_type        : <0x846e48>
    <8519ef>   DW_AT_inline      : 1    (inlined)
    <8519f0>   DW_AT_sibling     : <0x851c01>

The test passes if I build GDB with '-O0 -g3', because captured_main
isn't inlined.  This patch is to match the output when captured_main
is inlined.

gdb/testsuite:

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

* lib/selftest-support.exp (selftest_setup): Match the output
when captured_main is inlined.

8 years agoAdd type casts to allow C++ compile.
Chung-Lin Tang [Tue, 12 Jul 2016 13:02:14 +0000 (06:02 -0700)]
Add type casts to allow C++ compile.

gdb/gdbserver/
* linux-nios2-low.c (nios2_fill_gregset): Add type cast
to buf parameter.
(nios2_store_gregset): Likewise.

8 years agoFix grammar in error message.
Douglas B Rupp [Tue, 12 Jul 2016 10:05:13 +0000 (11:05 +0100)]
Fix grammar in error message.

* binary.c (binary_set_section_contents): Fix grammar in warning
message.

8 years agoAutomatic date update in version.in
GDB Administrator [Tue, 12 Jul 2016 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years ago[ARC] Update test.
Claudiu Zissulescu [Mon, 11 Jul 2016 13:41:23 +0000 (15:41 +0200)]
[ARC] Update test.

ld/
2016-07-11  Claudiu Zissulescu  <claziss@synopsys.com>

* testsuite/ld-arc/nps-1b.err: Update test to handle more
verbosity.

8 years agoTLS: DTPOFF can accept offsets, stored into addendum. Remove the need of base
Claudiu Zissulescu [Thu, 30 Jun 2016 13:11:57 +0000 (15:11 +0200)]
TLS: DTPOFF can accept offsets, stored into addendum. Remove the need of base

gas/ChangeLog:

2016-07-05  Claudiu Zissulescu  <claziss@synopsys.com>

  * config/tc-arc.c (arc_reloc_op_tag): Allow complex ops for dtpoff.
  (tc_gen_reloc): Remove passing DTPOFF base info into reloc addendum as it is
  no longer needed.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
8 years agoEnable relocation overflow messages by default.
Cupertino Miranda [Thu, 23 Jun 2016 09:38:30 +0000 (11:38 +0200)]
Enable relocation overflow messages by default.

bfd/ChangeLog:

2016-06-23  Cupertino Miranda  <cmiranda@synopsys.com>
        elf32-arc.c: made PR_DEBUG always defined.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
8 years agoFixes done to TLS.
Cupertino Miranda [Tue, 14 Jun 2016 20:55:44 +0000 (22:55 +0200)]
Fixes done to TLS.

TLS relocations did not support multiple TLS modes for the same
symbol in a single object file.
Refactored how GOT and TLS is implemented. Removed code duplications between
local and global symbols conditioning.

bfd/ChangeLog:

2016-06-14  Cupertino Miranda  <cmiranda@synopsys.com>
  * arc-got.h: Moved got related structures from elf32-arc.c to
    this file. More precisely, tls_type_e, tls_got_entries, got_entry.
  * (arc_get_local_got_ents,
     got_entry_for_type,
     new_got_entry_to_list,
     tls_type_for_reloc,
     symbol_has_entry_of_type,
     get_got_entry_list_for_symbol,
     arc_got_entry_type_for_reloc,
     ADD_SYMBOL_REF_SEC_AND_RELOC,
     arc_fill_got_info_for_reloc,
     relocate_fix_got_relocs_for_got_info,
     create_got_dynrelocs_for_single_entry,
     create_got_dynrelocs_for_got_info): Added to file.
  * elf32-arc.c: Removed GOT & TLS related structs and functions to
                     arc-got.h.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 11 Jul 2016 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoAutomatic date update in version.in
GDB Administrator [Sun, 10 Jul 2016 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in