]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
7 years agosim: unify symbol table handling
Mike Frysinger [Fri, 22 Jan 2016 03:17:59 +0000 (22:17 -0500)] 
sim: unify symbol table handling

The common sim tracing code already handles loading and tracking of
symbols from the target program so that it can show symbol info in
trace/disassembly calls.  Once we touch up the trace code and add a
few API callbacks, ports don't need to do loading and searching of
symbol tables themselves anymore.

7 years ago[GDB] Fix builds broken by proc-service changes.
Matthew Wahab [Mon, 15 Aug 2016 12:09:04 +0000 (13:09 +0100)] 
[GDB] Fix builds broken by proc-service changes.

GLIBC BZ#20311 introduced a change to install proc_service.h so that gdb
didn't have to use the version it embeds in gdb_proc_service.h. The
embedded version is guarded by HAVE_PROC_SERVICE_H and
gdb_proc_service.h has a number other of includes and definitions, all
of which are uncondional except for an include for gregset.h. This is
only included if HAVE_PROC_SERIVCE_H is not defined.

This causes a build failure when cross compiling gdb with the latest
glibc because type definitions in gregset are used independently of
HAVE_PROC_SERIVCE_H. In particular, they are used in gdb_proc_service.h
when PRFPREGSET_T_BROKEN is set.

The error messages on the failure are
----
binutils-gdb/gdb/gdb_proc_service.h:173:9: error: ‘gdb_fpregset_t’ does
not name a type; did you mean ‘elf_fpregset_t’?
 typedef gdb_fpregset_t gdb_prfpregset_t;
         ^~~~~~~~~~~~~~
         elf_fpregset_t

binutils-gdb/gdb/gdb_proc_service.h:173:9: error: ‘gdb_fpregset_t’ does
not name a type; did you mean ‘elf_fpregset_t’?
 typedef gdb_fpregset_t gdb_prfpregset_t;
         ^~~~~~~~~~~~~~
         elf_fpregset_t

binutils-gdb/gdb/proc-service.c:218:15: error: ‘gdb_prfpregset_t’ does
not name a type; did you mean ‘gdb_fpregset_t’?
         const gdb_prfpregset_t *fpregset)
               ^~~~~~~~~~~~~~~~
               gdb_fpregset_t
----

This patch moves the include for gregset.h to before the code guarded by
HAVE_PROC_SERIVCE_H, so that it is always included. This is enough to
fix the build.

2016-08-15  Matthew Wahab  <matthew.wahab@arm.com>

PR gdb/20457
* gdb_proc_service.h: Add an include of gregset.h
        [!HAVE_PROC_SERVICE_H]: Remove the include of gregset.h.

7 years agoFix heap-buffer-overflow in explicit_location_lex_one
Yao Qi [Mon, 15 Aug 2016 11:28:56 +0000 (12:28 +0100)] 
Fix heap-buffer-overflow in explicit_location_lex_one

I build GDB with -fsanitize=address, and see the error in tests,

(gdb) PASS: gdb.linespec/ls-errs.exp: lang=C++: break 3 foo
break -line 3 foo^M
=================================================================^M
==4401==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000047487 at pc 0x819d8e bp 0x7fff4e4e6bb0 sp 0x7fff4e4e6ba8^M
READ of size 1 at 0x603000047487 thread T0^[[1m^[[0m^M
    #0 0x819d8d in explicit_location_lex_one /home/yao/SourceCode/gnu/gdb/git/gdb/location.c:502^M
    #1 0x81a185 in string_to_explicit_location(char const**, language_defn const*, int) /home/yao/SourceCode/gnu/gdb/git/gdb/location.c:556^M
    #2 0x81ac10 in string_to_event_location(char**, language_defn const*) /home/yao/SourceCode/gnu/gdb/git/gdb/location.c:687^

the code in question is:

>         /* Special case: C++ operator,.  */
>         if (language->la_language == language_cplus
>             && strncmp (*inp, "operator", 8)  <--- [1]
>             && (*inp)[9] == ',')
>           (*inp) += 9;
>         ++(*inp);

The error is caused by the access to (*inp)[9] if 9 is out of its bounds.
However [1] looks odd to me, because if strncmp returns true (non-zero),
the following check "(*inp)[9] == ','" makes no sense any more.  I
suspect it was a typo in the code we meant to "strncmp () == 0".  Another
problem in the code above is that if *inp is "operator,", we first
increment *inp by 9, and then increment it by one again, which is wrong
to me.  We should only increment *inp by 8 to skip "operator", and go
back to the loop header to decide where we stop.

gdb:

2016-08-15  Yao Qi  <yao.qi@linaro.org>

* location.c (explicit_location_lex_one): Compare the return
value of strncmp with zero.  Don't check (*inp)[9].  Increment
*inp by 8.

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

7 years agosim: m68hc11: standardize sim_cpu naming
Mike Frysinger [Sat, 13 Aug 2016 15:44:24 +0000 (08:44 -0700)] 
sim: m68hc11: standardize sim_cpu naming

We use "sim_cpu *cpu" in the sim code base, not "struct _sim_cpu" or
the name "proc", so clean up this sim to follow along.

7 years agosim: m68hc11: fix up various prototype related warnings
Mike Frysinger [Sat, 13 Aug 2016 08:41:57 +0000 (01:41 -0700)] 
sim: m68hc11: fix up various prototype related warnings

A few funcs are only used locally, so mark them static to avoid warnings
due to -Wmissing-prototypes.

Some funcs cast the return value wrong, so drop them (and let void * just
work by default).

Update some prototypes to be new style.

7 years agosim: cgen: constify mode_names
Mike Frysinger [Fri, 12 Aug 2016 14:11:26 +0000 (22:11 +0800)] 
sim: cgen: constify mode_names

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 14 Aug 2016 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agosim: cgen: drop unused argv/envp definitions
Mike Frysinger [Fri, 22 Jan 2016 02:04:18 +0000 (21:04 -0500)] 
sim: cgen: drop unused argv/envp definitions

The common argv/envp are used now by all ports, so drop this old
cgen fragment.

7 years agosim: bfin: split out common mach/model defines into arch.h [PR sim/20438]
Mike Frysinger [Mon, 8 Aug 2016 05:06:49 +0000 (13:06 +0800)] 
sim: bfin: split out common mach/model defines into arch.h [PR sim/20438]

The current machs.h mixes common enums with Blackfin-specific defines.
This causes us troubles with header inclusion order such that we can't
drop the old SIM_CPU typedef (which is duplicated in common code).  By
splitting the two up, we can unwind this dependency chain, and drop the
old typedef.  It also fixes building with older gcc versions.

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 13 Aug 2016 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoWarn if the sh_info field of a symbol table does not index the first non-local symbol...
Nick Clifton [Fri, 12 Aug 2016 19:36:20 +0000 (20:36 +0100)] 
Warn if the sh_info field of a symbol table does not index the first non-local symbol in the section.

* readelf.c (process_symbol_table): Generate a warning if a local
symbol is found at and offste greater than or equal to the sh_info
field of it's section header.

7 years agoPR gold/20462: Fix bogus layout on ARM with linker script using PHDRS clause
Roland McGrath [Fri, 12 Aug 2016 16:55:25 +0000 (09:55 -0700)] 
PR gold/20462: Fix bogus layout on ARM with linker script using PHDRS clause

gold/
PR gold/20462
* script-sections.cc (Script_sections::release_segments):
Reset this->segments_created_.

7 years ago[gold] Implement HIDDEN syntax in linker scripts
Roland McGrath [Fri, 12 Aug 2016 16:50:49 +0000 (09:50 -0700)] 
[gold] Implement HIDDEN syntax in linker scripts

gold/
* yyscript.y (HIDDEN): New %token.
(assignment): Handle HIDDEN(string = expr) syntax.
* script.cc (script_keyword_parsecodes): Add HIDDEN.

7 years agoCorrect .dynsym sh_info
Alan Modra [Fri, 12 Aug 2016 14:33:43 +0000 (00:03 +0930)] 
Correct .dynsym sh_info

bfd/
* elf-bfd.h (struct elf_link_hash_table): Add local_dynsymcount.
* elflink.c (_bfd_elf_link_renumber_dynsyms): Set local_dynsymcount.
(bfd_elf_final_link): Set .dynsym sh_info from local_dynsymcount.
ld/
* testsuite/ld-tic6x/shlib-1.rd: Correct expected .dynsym sh_info.
* testsuite/ld-tic6x/shlib-1b.rd: Likewise.
* testsuite/ld-tic6x/shlib-1r.rd: Likewise.
* testsuite/ld-tic6x/shlib-1rb.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1b.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1r.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise.
* testsuite/ld-tic6x/shlib-noindex.rd: Likewise.
* testsuite/ld-tic6x/static-app-1.rd: Likewise.
* testsuite/ld-tic6x/static-app-1b.rd: Likewise.
* testsuite/ld-tic6x/static-app-1r.rd: Likewise.
* testsuite/ld-tic6x/static-app-1rb.rd: Likewise.

7 years agoUndo the previous change to the aarch64 sim - exporting aarch64_step() - and instead...
Nick Clifton [Fri, 12 Aug 2016 10:35:32 +0000 (11:35 +0100)] 
Undo the previous change to the aarch64 sim - exporting aarch64_step() - and instead make aarch64_run correctly process sim events.

* simulator.c (aarch64_step): Revert pervious delta.
(aarch64_run): Call sim_events_tick after each
instruction is simulated, and if necessary call
sim_events_process.
* simulator.h: Revert previous delta.

7 years agoFix warning in gdb.base/signals-state-child.c
Yao Qi [Fri, 12 Aug 2016 10:02:04 +0000 (11:02 +0100)] 
Fix warning in gdb.base/signals-state-child.c

I see the following warning when running signals-state-child.exp.

gdb/testsuite/gdb.base/signals-state-child.c:77:4: warning: too many arguments for format [-Wformat-extra-args]
    fprintf (out, "sigaction={sa_handler=", i);
    ^

this patch is to remove the argument from fprintf.

gdb/testsuite:

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

* gdb.base/signals-state-child.c (main): Remove "i" from fprintf's
argument list.

7 years agoAdd undefined weak function tests
Alan Modra [Fri, 12 Aug 2016 04:37:40 +0000 (14:07 +0930)] 
Add undefined weak function tests

* testsuite/ld-undefined/weak-fundef.s: New.
* testsuite/ld-undefined/weak-undef.t: Don't specify filename.
* testsuite/ld-undefined/weak-undef.exp: Run new tests.  Rearrange
much of old code.  Use is_elf_format to select targets.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 12 Aug 2016 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoFix ERROR: target-cc does not exist
Alan Modra [Thu, 11 Aug 2016 14:12:05 +0000 (23:42 +0930)] 
Fix ERROR: target-cc does not exist

PR ld/20436
* testsuite/lib/ld-lib.exp (at_least_gcc_version): Don't ignore
remote_exec status.
(check_gcc_plugin_enabled): Likewise.

7 years agoExport the single step function from the AArch64 simulator.
Nick Clifton [Thu, 11 Aug 2016 14:04:40 +0000 (15:04 +0100)] 
Export the single step function from the AArch64 simulator.

* interp.c (sim_create_inferior): Allow for being called with a
NULL abfd parameter.  If a bfd is provided, initialise the sim
with that start address.
* simulator.c (HALT_NYI): Just print out the numeric value of the
instruction when not tracing.
(aarch64_step): Change from static to global.
* simulator.h: Add a prototype for aarch64_step().

7 years agoFix fallout from gdb/20413's fix (x32: linux_ptrace_test_ret_to_nx: Cannot PTRACE_PEE...
Pedro Alves [Thu, 11 Aug 2016 11:01:22 +0000 (12:01 +0100)] 
Fix fallout from gdb/20413's fix (x32: linux_ptrace_test_ret_to_nx: Cannot PTRACE_PEEKUSER)

Fixes, on NIOS GNU/Linux:

  In file included from
  /scratch/mbilal/nois-lite/src/gdb-trunk/gdb/gdbserver/../nat/linux-ptrace.c:26:0:
  /scratch/mbilal/nois-lite/src/gdb-trunk/gdb/gdbserver/../gregset.h:27:23:
  error: unknown type name 'gregset_t'
   #define GDB_GREGSET_T gregset_t
 ^

Fix this by including sys/procfs.h directly.  We shouldn't really be
including a gdb-only header in a gdb/nat/ file, anyway.  Whoops.

gdb/ChangeLog:
2016-08-11  Pedro Alves  <palves@redhat.com>

PR gdb/20413
* nat/linux-ptrace.c: Include <sys/procfs.h> instead of
"gregset.h".

7 years agoAvoid testsuite errors about missing compilers.
Nick Clifton [Thu, 11 Aug 2016 09:22:41 +0000 (10:22 +0100)] 
Avoid testsuite errors about missing compilers.

PR ld/20436
* testsuite/lib/ld-lib.exp (check_gcc_plugin_enabled): When not
testing remotely, check to see if target compiler is installed
before trying to run it.

7 years ago[AArch64] Reject -0.0 as an 8-bit FP immediate
Richard Sandiford [Thu, 11 Aug 2016 08:14:45 +0000 (09:14 +0100)] 
[AArch64] Reject -0.0 as an 8-bit FP immediate

parse_aarch64_imm_float was accepting -0.0 even though that's not
a valid immediate for any instruction.  The FPIMM0 caller rejected
it, but the FPIMM one would silently treat it as -2.0.

This patch rejects -0.0 and adds testcases to illegal.[sd].

Before the patch, the final error emitted for illegal.s was:

        Error: cannot do 16-byte relocation

which was matched by:

        [^:]*:569: Error: .*

The error was reported against the last line of the file rather than
the instruction that required the reloc.  Adding more instructions
meant that the line number also changed.

Reporting against the wrong line isn't good from a QoI perspective
but isn't what I'm trying to fix here.  Until it's fixed, I thought
it would be better to adjust the match to be against an end-of-file
comment rather than against whatever the last instruction happens to be.

gas/
* config/tc-aarch64.c (parse_aarch64_imm_float): Reject -0.0.
* testsuite/gas/aarch64/illegal.s, testsuite/gas/aarch64/illegal.l:
Add tests for -0.0.  Add an end-of-file comment.

7 years agoPowerPC64 ELFv1 undefined weak functions
Alan Modra [Thu, 11 Aug 2016 03:00:52 +0000 (12:30 +0930)] 
PowerPC64 ELFv1 undefined weak functions

Undefined weak functions, like __gmon_start__, were not being made
dynamic or emitting plt call code.  While the behaviour of undefined
weak symbols is not defined in the ELF standard, the intention on
powerpc64 was to make it possible to link without a definition of such
symbols and at run time behave the same as if a definition was found
at link time in a shared library.

* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Don't exit with
non_got_ref true in any case where we could have generated dynbss
copies but decide not to do so.

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

7 years agoPR ld/15428: MIPS/LD/testsuite: Un-KFAIL `__ehdr_start' test 2
Maciej W. Rozycki [Wed, 10 Aug 2016 23:52:06 +0000 (00:52 +0100)] 
PR ld/15428: MIPS/LD/testsuite: Un-KFAIL `__ehdr_start' test 2

Complement commit b75d42bce560 ("Fix mips segfault on GOT access of
absolute symbol") and unmark the `__ehdr_start' test 2 as known to fail
for the n32 and n64 ABIs, as with the change referred in place the
causing issue has been properly addressed and consequently the tests do
not fail anymore and neither are supposed to.

ld/
PR ld/15428
* testsuite/ld-mips-elf/mips-elf.exp: Un-KFAIL `__ehdr_start'
test 2.

7 years agoFix PR gdb/19187 (process record over a fork causes internal error)
Pedro Alves [Wed, 10 Aug 2016 22:03:29 +0000 (23:03 +0100)] 
Fix PR gdb/19187 (process record over a fork causes internal error)

Right after a fork is detected, we detach breakpoints from the child
(detach_breakpoints), which calls into target_remove_breakpoint with
inferior_ptid pointing at the child process, but leaves the breakpoint
marked inserted (in the parent).

The problem is that record-full.c always deletes all knowledge of the
breakpoint.  Then when we later really delete the breakpoint from the
parent, we fail the assertion, since the breakpoint is unexpectedly
not found in the record-full.c breakpoint table.

The fix is simply to not forget about the breakpoint if we're
detaching it from a fork child.

gdb/ChangeLog:
2016-08-10  Pedro Alves  <palves@redhat.com>

PR gdb/19187
* record-full.c (record_full_remove_breakpoint): Don't remove the
breakpoint from the record_full_breakpoints VEC if we're detaching
the breakpoint from a fork child.

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

PR gdb/19187
* gdb.reverse/waitpid-reverse.exp: Add comment and remove
setup_kfails.

7 years agoPlumb enum remove_bp_reason all the way to target_remove_breakpoint
Pedro Alves [Wed, 10 Aug 2016 22:03:29 +0000 (23:03 +0100)] 
Plumb enum remove_bp_reason all the way to target_remove_breakpoint

So the target knows whether we're detaching breakpoints.
Nothing uses the parameter in this patch yet.

gdb/ChangeLog:
2016-08-10  Pedro Alves  <palves@redhat.com>

PR gdb/19187
* break-catch-sig.c (signal_catchpoint_remove_location): Adjust
interface.
* break-catch-syscall.c (remove_catch_syscall):
* breakpoint.c (enum remove_bp_reason): Moved to breakpoint.h.
(remove_breakpoint_1): Pass 'reason' down.
(remove_catch_fork, remove_catch_vfork, remove_catch_solib)
(remove_catch_exec, remove_watchpoint, remove_masked_watchpoint)
(base_breakpoint_remove_location, bkpt_remove_location)
(bkpt_probe_remove_location, bkpt_probe_remove_location): Adjust
interface.
* breakpoint.h (enum remove_bp_reason): Moved here from
breakpoint.c.
(struct breakpoint_ops) <remove_location>: Add 'reason' parameter.
* corelow.c (core_remove_breakpoint): New function.
(init_core_ops): Install it as to_remove_breakpoint method.
* exec.c (exec_remove_breakpoint): New function.
(init_exec_ops): Install it as to_remove_breakpoint method.
* mem-break.c (memory_remove_breakpoint): Adjust interface.
* record-btrace.c (record_btrace_remove_breakpoint): Adjust
interface.
* record-full.c (record_full_remove_breakpoint)
(record_full_core_remove_breakpoint): Adjust interface.
* remote.c (remote_remove_breakpoint): Adjust interface.
* target-debug.h (target_debug_print_enum_remove_bp_reason): New
macro.
* target-delegates.c: Regenerate.
* target.c (target_remove_breakpoint): Add 'reason' parameter.
* target.h (struct target_ops) <to_remove_breakpoint>: Add
'reason' parameter.
(target_remove_breakpoint, memory_remove_breakpoint): Add 'reason'
parameter.

7 years agoIntroduce 'enum remove_bp_reason'
Pedro Alves [Wed, 10 Aug 2016 22:03:29 +0000 (23:03 +0100)] 
Introduce 'enum remove_bp_reason'

Makes the code more obvious.

gdb/ChangeLog:
2016-08-10  Pedro Alves  <palves@redhat.com>

PR gdb/19187
* breakpoint.c (insertion_state_t): Delete.
(enum remove_bp_reason): New.
(detach_breakpoints, remove_breakpoint_1, remove_breakpoint):
Adjust to use enum remove_bp_reason instead of insertion_state_t.

7 years agoSimplify remove_breakpoint interface
Pedro Alves [Wed, 10 Aug 2016 22:03:28 +0000 (23:03 +0100)] 
Simplify remove_breakpoint interface

All callers pass mark_uninserted, so there's no need for the 'is'
parameter.

gdb/ChangeLog:
2016-08-10  Pedro Alves  <palves@redhat.com>

PR gdb/19187
* breakpoint.c (remove_breakpoint): Remove 'is' parameter and
always pass mark_uninserted to remove_breakpoint_1.
(insert_breakpoint_locations, remove_breakpoints)
(remove_breakpoints_pid, update_global_location_list): Update
callers.

7 years agoMIPS/LD/testsuite: Verify microMIPS LA25 stub generation
Maciej W. Rozycki [Wed, 10 Aug 2016 21:10:30 +0000 (22:10 +0100)] 
MIPS/LD/testsuite: Verify microMIPS LA25 stub generation

Repeat `PIC and non-PIC test 1' checks for microMIPS LA25 stubs,
covering code generation and stub symbol annotation.

ld/
* testsuite/ld-mips-elf/pic-and-nonpic-1-micromips-rel.dd: New
test.
* testsuite/ld-mips-elf/pic-and-nonpic-1-micromips-rel.nd: New
test.
* testsuite/ld-mips-elf/pic-and-nonpic-1-micromips.dd: New test.
* testsuite/ld-mips-elf/pic-and-nonpic-1-micromips.nd: New test.
* testsuite/ld-mips-elf/pic-and-nonpic-1a-micromips.s: New test
source.
* testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s: New test
source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.

7 years agoMIPS/BFD: Actually produce short microMIPS LA25 stubs
Maciej W. Rozycki [Wed, 10 Aug 2016 19:44:03 +0000 (20:44 +0100)] 
MIPS/BFD: Actually produce short microMIPS LA25 stubs

For the case where a function which requires an LA25 stub is at the
beginning of a section we use a short sequence comprised of a LUI/ADDIU
instruction pair only and prepended to the associated function rather
than using a trailing jump to reach the function.  This works by
checking for the offset into section of the function symbol being 0.

This is however never the case for microMIPS function symbols, which
have the ISA bit set.  Consequently the short LA25 sequence is never
produced for microMIPS functions, like with the following example:

$ cat la25a.s
.abicalls

.global f1
.ent f1
f1:
.set noreorder
.cpload $25
.set reorder
.option pic0
jal f2
.option pic2
jr $31
.end f1

.global f2
.ent f2
f2:
jr $31
.end f2
$ cat la25b.s
.abicalls
.option pic0

.global __start
.ent __start
__start:
jal f1
jal f2
.end __start
$ as -mmicromips -32 -EB -o la25a.o la25a.s
$ as -mmicromips -32 -EB -o la25b.o la25b.s
$ ld -melf32btsmip -o la25 la25a.o la25b.o
$ objdump -d la25

la25:     file format elf32-tradbigmips

Disassembly of section .text:

004000d0 <.pic.f2>:
  4000d0: 41b9 0040  lui t9,0x40
  4000d4: d420 0083  j 400106 <f2>
  4000d8: 3339 0107  addiu t9,t9,263
  4000dc: 0000 0000  nop

004000e0 <.pic.f1>:
  4000e0: 41b9 0040  lui t9,0x40
  4000e4: d420 0078  j 4000f0 <f1>
  4000e8: 3339 00f1  addiu t9,t9,241
  4000ec: 0000 0000  nop

004000f0 <f1>:
  4000f0: 41bc 0002  lui gp,0x2
  4000f4: 339c 801f  addiu gp,gp,-32737
  4000f8: 033c e150  addu gp,gp,t9
  4000fc: f420 0083  jal 400106 <f2>
  400100: 0000 0000  nop
  400104: 45bf       jrc ra

00400106 <f2>:
  400106: 45bf       jrc ra
...

00400110 <__start>:
  400110: f420 0070  jal 4000e0 <.pic.f1>
  400114: 0000 0000  nop
  400118: f420 0068  jal 4000d0 <.pic.f2>
  40011c: 0000 0000  nop
$

where `.pic.f1' could omit the trailing jump and the filler NOP and just
fall through to `f1'.

Correct the problem by masking out the ISA bit from microMIPS functions,
which fixes the earlier example:

$ objdump -d la25

la25:     file format elf32-tradbigmips

Disassembly of section .text:

004000d0 <.pic.f2>:
  4000d0: 41b9 0040  lui t9,0x40
  4000d4: d420 0083  j 400106 <f2>
  4000d8: 3339 0107  addiu t9,t9,263
...

004000e8 <.pic.f1>:
  4000e8: 41b9 0040  lui t9,0x40
  4000ec: 3339 00f1  addiu t9,t9,241

004000f0 <f1>:
  4000f0: 41bc 0002  lui gp,0x2
  4000f4: 339c 801f  addiu gp,gp,-32737
  4000f8: 033c e150  addu gp,gp,t9
  4000fc: f420 0083  jal 400106 <f2>
  400100: 0000 0000  nop
  400104: 45bf       jrc ra

00400106 <f2>:
  400106: 45bf       jrc ra
...

00400110 <__start>:
  400110: f420 0074  jal 4000e8 <.pic.f1>
  400114: 0000 0000  nop
  400118: f420 0068  jal 4000d0 <.pic.f2>
  40011c: 0000 0000  nop
$

There is no need to do anything for MIPS16 functions, because if any
LA25 stub has been generated for such a function, then it is only
required for an associated call thunk only, which is regular MIPS code
and the address of which, with the ISA bit clear, is returned by
`mips_elf_get_la25_target'.

This problem has been there since the beginning of microMIPS support:

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").

bfd/
* elfxx-mips.c (mips_elf_add_la25_stub): Clear the ISA bit of
the stub address retrieved if associated with a microMIPS
function.

7 years agoMIPS/BFD: Add microMIPS annotation to LA25 stub symbols
Maciej W. Rozycki [Wed, 10 Aug 2016 19:03:02 +0000 (20:03 +0100)] 
MIPS/BFD: Add microMIPS annotation to LA25 stub symbols

Fix a problem with missing microMIPS symbol annotation with microMIPS
LA25 stub symbols.  The consequence of the issue is these symbols appear
in the symbol table as regular MIPS symbols with the ISA bit set, as
shown with the example below:

$ cat la25a.s
.abicalls

.global f1
.ent f1
f1:
.set noreorder
.cpload $25
.set reorder
.option pic0
jal f2
.option pic2
jr $31
.end f1

.global f2
.ent f2
f2:
jr $31
.end f2
$ cat la25b.s
.abicalls
.option pic0

.global __start
.ent __start
__start:
jal f1
jal f2
.end __start
$ as -mmicromips -32 -EB -o la25a.o la25a.s
$ as -mmicromips -32 -EB -o la25b.o la25b.s
$ ld -melf32btsmip -o la25 la25a.o la25b.o
$ readelf -s la25

Symbol table '.symtab' contains 18 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00400098     0 SECTION LOCAL  DEFAULT    1
     2: 004000b0     0 SECTION LOCAL  DEFAULT    2
     3: 004000d0     0 SECTION LOCAL  DEFAULT    3
     4: 00000000     0 SECTION LOCAL  DEFAULT    4
     5: 00000000     0 SECTION LOCAL  DEFAULT    5
     6: 00418110     0 NOTYPE  LOCAL  DEFAULT    3 _gp
     7: 004000e1    16 FUNC    LOCAL  DEFAULT    3 .pic.f1
     8: 004000d1    16 FUNC    LOCAL  DEFAULT    3 .pic.f2
     9: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fdata
    10: 00400110    16 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 __start
    11: 00400106     2 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f2
    12: 004000d0     0 NOTYPE  GLOBAL DEFAULT    3 _ftext
    13: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 __bss_start
    14: 004000f0    22 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f1
    15: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _edata
    16: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _end
    17: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fbss
$

where microMIPS annotation is missing for `.pic.f1' and `.pic.f2' even
though these stubs are associated with microMIPS functions `f1' and `f2'
respectively.

Add the missing annotation then, by copying it from the function symbol
an LA25 stub is associated with, correcting the example above:

$ readelf -s la25

Symbol table '.symtab' contains 18 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00400098     0 SECTION LOCAL  DEFAULT    1
     2: 004000b0     0 SECTION LOCAL  DEFAULT    2
     3: 004000d0     0 SECTION LOCAL  DEFAULT    3
     4: 00000000     0 SECTION LOCAL  DEFAULT    4
     5: 00000000     0 SECTION LOCAL  DEFAULT    5
     6: 00418110     0 NOTYPE  LOCAL  DEFAULT    3 _gp
     7: 004000e0    16 FUNC    LOCAL  DEFAULT [MICROMIPS]     3 .pic.f1
     8: 004000d0    16 FUNC    LOCAL  DEFAULT [MICROMIPS]     3 .pic.f2
     9: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fdata
    10: 00400110    16 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 __start
    11: 00400106     2 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f2
    12: 004000d0     0 NOTYPE  GLOBAL DEFAULT    3 _ftext
    13: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 __bss_start
    14: 004000f0    22 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f1
    15: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _edata
    16: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _end
    17: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fbss
$

This problem has been there since the beginning of microMIPS support:

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").

bfd/
* elfxx-mips.c (mips_elf_create_stub_symbol): For a microMIPS
stub also add STO_MICROMIPS annotation.

7 years agoMIPS/BFD: Set the ISA bit in microMIPS LA25 stub references
Maciej W. Rozycki [Wed, 10 Aug 2016 11:43:18 +0000 (12:43 +0100)] 
MIPS/BFD: Set the ISA bit in microMIPS LA25 stub references

Fix a linker regression introduced with commit 9d862524f6ae ("MIPS:
Verify the ISA mode and alignment of branch and jump targets") causing a
build failure in microMIPS glibc where the `zdump' tool fails to link:

.../timezone/zdump.o: In function `yeartot':
.../timezone/zdump.c:758:(.text+0x62): Jump to a non-instruction-aligned address
.../timezone/zdump.c:758:(.text+0x76): Jump to a non-instruction-aligned address
.../timezone/zdump.c:768:(.text+0x112): Jump to a non-instruction-aligned address
.../timezone/zdump.c:774:(.text+0x1b8): Jump to a non-instruction-aligned address
.../timezone/zdump.c:774:(.text+0x1cc): Jump to a non-instruction-aligned address
collect2: error: ld returned 1 exit status
make[2]: *** [.../timezone/zdump] Error 1

The cause of the failure is the stricter check introduced with the said
change for jump and branch targets tripping on the address of microMIPS
LA25 stubs.  Despite being microMIPS code these stubs do not have the
ISA bit set throughout the relocation calculation process, because they
have their address set to the memory offset into the stub section they
are placed in.

The `mips_elf_la25_stub' structure does not carry ISA mode information,
but there is no need to extend it, because the ISA mode can be inferred
from the original symbol, which will have STO_MICROMIPS annotation, so
use that instead to set the ISA bit appropriately.  Also only LA25 stubs
associated with microMIPS symbols need to have the ISA bit set, because
other LA25 stubs are made with regular MIPS code, even if associated
with a MIPS16 symbol (in which case they are needed by a call thunk only
rather than the MIPS16 function proper).

bfd/
* elfxx-mips.c (mips_elf_calculate_relocation): Set the ISA bit
in microMIPS LA25 stub references.

7 years agoSupport setting thread names (MS-Windows)
Руслан Ижбулатов [Wed, 10 Aug 2016 18:22:45 +0000 (19:22 +0100)] 
Support setting thread names (MS-Windows)

This is done by catching an exception number 0x406d1388 (it has no
documented name, though MSDN dubs it "MS_VC_EXCEPTION" in one code
example), which is thrown by the program.  The exception record
contains an ID of a thread and a name to give it.

This requires rolling back some changes in handle_exception(), which
now again returns more than two distinct values.  The new
HANDLE_EXCEPTION_IGNORED value means that gdb should just continue,
without returning the thread ID up the stack (which would result in
further handling of the exception, which is not what we want).

gdb/ChangeLog:
2016-08-10  Руслан Ижбулатов  <lrn1986@gmail.com>
    Pedro Alves  <palves@redhat.com>

* windows-nat.c (MS_VC_EXCEPTION): New define.
(handle_exception_result): New enum.
(windows_delete_thread): Free the thread's name.
(handle_exception): Handle MS_VC_EXCEPTION.
(get_windows_debug_event): Handle HANDLE_EXCEPTION_IGNORED.
(windows_thread_name): New function.
(windows_target): Install it as to_thread_name method.
* NEWS: Mention the thread naming support on MS-Windows.

7 years agoFix extraneous complaints about missing expected TLS relocation.
Cary Coutant [Wed, 10 Aug 2016 17:57:42 +0000 (10:57 -0700)] 
Fix extraneous complaints about missing expected TLS relocation.

With some versions of gas, the call to tls_get_addr uses a GOTPCREL
relocation instead of a GOTPCRELX relocation. We should allow for that
when skip_call_tls_get_addr_ is true. We should also build the test
objects with the in-tree assembler.

This patch also fixes some cascading error messages caused by not
resetting the skip_call_tls_get_addr_ flag after printing the error.

gold/
PR gold/20216
* x86_64.cc (Target_x86_64::Relocate::relocate): Add check for
R_X86_64_GOTPCREL. Reset skip_call_tls_get_addr_ after printing
error message.
* testsuite/Makefile.am (pr20216_gd.o): Add -Bgcctestdir/.
(pr20216_ld.o): Likewise.
* testsuite/Makefile.in: Regenerate.

7 years agoFix potential crashes when Target::make_symbol() returns NULL.
James Clarke [Wed, 10 Aug 2016 16:58:01 +0000 (09:58 -0700)] 
Fix potential crashes when Target::make_symbol() returns NULL.

2016-08-10  James Clarke  <jrtc27@jrtc27.com>

gold/
PR gold/20443
* symtab.cc (Symbol_table::add_from_relobj): Handle NULL symbols,
which will be present for STT_SPARC_REGISTER.
(Symbol_table::add_from_pluginobj): Likewise.
(Symbol_table::add_from_dynobj): Likewise.
(Symbol_table::add_from_incrobj): Removed dead code.

7 years agoFix improper handling of R_SPARC_GOTDATA_OP_LOX10 relocation.
James Clarke [Wed, 10 Aug 2016 16:47:45 +0000 (09:47 -0700)] 
Fix improper handling of R_SPARC_GOTDATA_OP_LOX10 relocation.

The fall-through in Target_sparc::Relocate::relocate for
R_SPARC_GOTDATA_OP_LOX10 is currently R_SPARC_GOT13, but should
clearly be R_SPARC_GOT10. GCC has been seen to emit a sethi/xor
rather than a sethi/or sequence to load a 32-bit immediate, but
if R_SPARC_GOT13 is used then bits 10-12 get zeroed out as both
the sethi and xor immediates contain them.

gold/
PR gold/20442
* sparc.cc (Target_sparc::Relocate::relocate): R_SPARC_GOTDATA_OP_LOX10
should fall back on R_SPARC_GOT10, not R_SPARC_GOT13.

7 years agoAdd support for R_SPARC_32 relocation.
James Clarke [Wed, 10 Aug 2016 16:42:39 +0000 (09:42 -0700)] 
Add support for R_SPARC_32 relocation.

gold/
PR gold/20441
* sparc.cc (Target_sparc::Scan::check_non_pic): Allow R_SPARC_32 on
sparc64.

7 years agoQuiet ARI gettext checks
Pedro Alves [Wed, 10 Aug 2016 15:06:57 +0000 (16:06 +0100)] 
Quiet ARI gettext checks

The ARI complains about this new file:

 common/signals-state-save-restore.c:46: warning: gettext: All messages should be marked up with _.
 common/signals-state-save-restore.c:59: warning: gettext: All messages should be marked up with _.
 common/signals-state-save-restore.c:87: warning: gettext: All messages should be marked up with _.
 common/signals-state-save-restore.c:92: warning: gettext: All messages should be marked up with _.

Since these are untranslatable strings, use () instead of _().

gdb/ChangeLog:
2016-08-10  Pedro Alves  <palves@redhat.com>

* common/signals-state-save-restore.c
(save_original_signals_state, restore_original_signals_state):
Wrap perror_with_name arguments with '()'.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 10 Aug 2016 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoSkip LTO tests for --disable-plugin
H.J. Lu [Tue, 9 Aug 2016 23:41:12 +0000 (16:41 -0700)] 
Skip LTO tests for --disable-plugin

Don't run LTO tests if compiler is configured with --disable-plugin.

PR ld/20436
* testsuite/lib/ld-lib.exp (check_gcc_plugin_enabled): New
proc.
(check_lto_available): Return 0 if check_gcc_plugin_enabled
returns 0.
(check_lto_fat_available): Likewise.
(check_lto_shared_available): Likewise.

7 years agoFix PR gdb/20418 - Problems with synchronous commands and new-ui
Pedro Alves [Tue, 9 Aug 2016 21:45:40 +0000 (22:45 +0100)] 
Fix PR gdb/20418 - Problems with synchronous commands and new-ui

When executing commands on a secondary UI running the MI interpreter,
some commands that should be synchronous are not.  MI incorrectly
continues processing input right after the synchronous command is
sent, before the target stops.

The problem happens when we emit MI async events (=library-loaded,
etc.), and we go about restoring the previous terminal state, we end
up calling target_terminal_ours, which incorrectly always installs the
current UI's input_fd in the event loop...  That is, code like this:

   old_chain = make_cleanup_restore_target_terminal ();
   target_terminal_ours_for_output ();

   fprintf_unfiltered (mi->event_channel, "library-loaded");

...

   do_cleanups (old_chain);

The fix is to move the add_file_handler/delete_file_handler calls out
of target_terminal_$foo, making these completely no-ops unless called
with the main UI as current UI.

gdb/ChangeLog:
2016-08-09  Pedro Alves  <palves@redhat.com>

PR gdb/20418
* event-top.c (ui_register_input_event_handler)
(ui_unregister_input_event_handler): New functions.
(async_enable_stdin): Register input in the event loop.
(async_disable_stdin): Unregister input from the event loop.
(gdb_setup_readline): Register input in the event loop.
* infrun.c (check_curr_ui_sync_execution_done): Register input in
the event loop.
* target.c (target_terminal_inferior): Don't unregister input from
the event loop.
(target_terminal_ours): Don't register input in the event loop.
* target.h (target_terminal_inferior)
(target_terminal_ours_for_output, target_terminal_ours): Update
comments.
* top.h (ui_register_input_event_handler)
(ui_unregister_input_event_handler): New declarations.
* utils.c (ui_unregister_input_event_handler_cleanup)
(prepare_to_handle_input): New functions.
(defaulted_query, prompt_for_continue): Use
prepare_to_handle_input.

gdb/testsuite/ChangeLog:
2016-08-09  Pedro Alves  <palves@redhat.com>
    Simon Marchi  <simon.marchi@ericsson.com>

PR gdb/20418
* gdb.mi/new-ui-mi-sync.c, gdb.mi/new-ui-mi-sync.exp: New files.
* lib/mi-support.exp (mi_expect_interrupt): Remove anchors.

7 years agoFix PR mi/20431 - Missing MI prompts after sync execution MI command (-exec-continue...
Pedro Alves [Tue, 9 Aug 2016 21:45:39 +0000 (22:45 +0100)] 
Fix PR mi/20431 - Missing MI prompts after sync execution MI command (-exec-continue, etc.) errors

gdb 7.11 introduced an MI regression: a failing MI sync execution
command misses printing the MI prompt, and then all subsequent command
miss it too:

 $ gdb-7.11.1 -i=mi
 [...]
 p 1
 &"p 1\n"
 ~"$1 = 1"
 ~"\n"
 ^done
 (gdb)                                        <<< prompted ok
 -exec-continue
 ^error,msg="The program is not being run."   <<< missing prompt after this
 print 1
 &"print 1\n"
 ~"$2 = 1"
 ~"\n"
 ^done                                        <<< missing prompt after this

gdb 7.10.1 behaved correctly, even with "set mi-async on":

 -exec-continue
 ^error,msg="The program is not being run."
 (gdb)                                        <<< prompted ok

etc.

Bisecting points at:

  commit 0b333c5e7d6c
  Author: Pedro Alves <palves@redhat.com>
  Date:   Wed Sep 9 18:23:23 2015 +0100

      Merge async and sync code paths some more
  [...]

The problem is that when an exception is thrown, we leave the prompt
state set to PROMPT_BLOCKED, and then mi_execute_command_input_handler
doesn't print the prompt.  It used to work because before that patch,
we happened to skip disabling stdin if the current target didn't do
async (which it never does before execution).

I was surprised to find that this bug isn't caught by the testsuite,
so I made a thorough test that tests all combinations of pairs of:

 - a failing synchronous execution command
 - a failing non-execution command
 - a non-failing command

gdb/ChangeLog:
2016-08-09  Pedro Alves  <palves@redhat.com>

PR mi/20431
* mi/mi-main.c (mi_execute_command): Enable input and set prompt
state to PROMPT_NEEDED.

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

PR mi/20431
* gdb.mi/mi-cmd-error.exp: New file.

7 years agoFix PR gdb/18653: gdb disturbs inferior's inherited signal dispositions
Pedro Alves [Tue, 9 Aug 2016 19:16:20 +0000 (20:16 +0100)] 
Fix PR gdb/18653: gdb disturbs inferior's inherited signal dispositions

gdb's (or gdbserver's) own signal handling should not interfere with
the signal dispositions their spawned children inherit.  However, it
currently does.  For example, some paths in gdb cause SIGPIPE to be
set to SIG_IGN, and as consequence, the child starts with SIGPIPE to
set to SIG_IGN too, even though gdb was started with SIGPIPE set to
SIG_DFL.

This is because the exec family of functions does not reset the signal
disposition of signals that are set to SIG_IGN:

  http://pubs.opengroup.org/onlinepubs/7908799/xsh/execve.html

  Signals set to the default action (SIG_DFL) in the calling process
  image are set to the default action in the new process
  image. Signals set to be ignored (SIG_IGN) by the calling process
  image are set to be ignored by the new process image. Signals set to
  be caught by the calling process image are set to the default action
  in the new process image (see <signal.h>).

And neither does it reset signal masks or flags.

In order to be transparent, when spawning new child processes to debug
(with "run", etc.), reset signal actions and mask back to what was
originally inherited from gdb/gdbserver's parent, just before execing
the target program to debug.

gdb/ChangeLog:
2016-08-09  Pedro Alves  <palves@redhat.com>

PR gdb/18653
* Makefile.in (SFILES): Add
common/signals-state-save-restore.c.
(HFILES_NO_SRCDIR): Add common/signals-state-save-restore.h.
(COMMON_OBS): Add signals-state-save-restore.o.
(signals-state-save-restore.o): New rule.
* configure: Regenerate.
* fork-child.c: Include "signals-state-save-restore.h".
(fork_inferior): Call restore_original_signals_state.
* main.c: Include "signals-state-save-restore.h".
(captured_main): Call save_original_signals_state.
* common/common.m4: Add sigaction to AC_CHECK_FUNCS checks.
* common/signals-state-save-restore.c: New file.
* common/signals-state-save-restore.h: New file.

gdb/gdbserver/ChangeLog:
2016-08-09  Pedro Alves  <palves@redhat.com>

PR gdb/18653
* Makefile.in (OBS): Add signals-state-save-restore.o.
(signals-state-save-restore.o): New rule.
* config.in: Regenerate.
* configure: Regenerate.
* linux-low.c: Include "signals-state-save-restore.h".
(linux_create_inferior): Call
restore_original_signals_state.
* server.c: Include "dispositions-save-restore.h".
(captured_main): Call save_original_signals_state.

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

PR gdb/18653
* gdb.base/signals-state-child.c: New file.
* gdb.base/signals-state-child.exp: New file.
* gdb.gdb/selftest.exp (do_steps_and_nexts): Add new pattern.

7 years agoSupport -pie for arm*-eabi targets.
Roland McGrath [Tue, 9 Aug 2016 19:09:17 +0000 (12:09 -0700)] 
Support -pie for arm*-eabi targets.

ld/
* emulparams/armelf.sh (GENERATE_PIE_SCRIPT): Set to yes.

7 years agoCorrect the calculation of the use_counts of merged .got entries.
Jiaming Wei [Tue, 9 Aug 2016 15:18:42 +0000 (16:18 +0100)] 
Correct the calculation of the use_counts of merged .got entries.

* elf64-alpha.c (elf64_alpha_copy_indirect_symbol): Fix thinko
adjusting the use_count of merged .got entries.

7 years agoFix PR gdb/20295: GDB segfaults printing bitfield member of optimized out value
Pedro Alves [Tue, 9 Aug 2016 11:04:48 +0000 (12:04 +0100)] 
Fix PR gdb/20295: GDB segfaults printing bitfield member of optimized out value

With something like:

  struct A { int bitfield:4; } var;

If 'var' ends up wholly-optimized out, printing 'var.bitfield' crashes
gdb here:

 (top-gdb) bt
 #0  0x000000000058b89f in extract_unsigned_integer (addr=0x2 <error: Cannot access memory at address 0x2>, len=2, byte_order=BFD_ENDIAN_LITTLE)
     at /home/pedro/gdb/mygit/src/gdb/findvar.c:109
 #1  0x00000000005a187a in unpack_bits_as_long (field_type=0x16cff70, valaddr=0x0, bitpos=16, bitsize=12) at /home/pedro/gdb/mygit/src/gdb/value.c:3347
 #2  0x00000000005a1b9d in unpack_value_bitfield (dest_val=0x1b5d9d0, bitpos=16, bitsize=12, valaddr=0x0, embedded_offset=0, val=0x1b5d8d0)
     at /home/pedro/gdb/mygit/src/gdb/value.c:3441
 #3  0x00000000005a2a5f in value_fetch_lazy (val=0x1b5d9d0) at /home/pedro/gdb/mygit/src/gdb/value.c:3958
 #4  0x00000000005a10a7 in value_primitive_field (arg1=0x1b5d8d0, offset=0, fieldno=0, arg_type=0x16d04c0) at /home/pedro/gdb/mygit/src/gdb/value.c:3161
 #5  0x00000000005b01e5 in do_search_struct_field (name=0x1727c60 "bitfield", arg1=0x1b5d8d0, offset=0, type=0x16d04c0, looking_for_baseclass=0, result_ptr=0x7fffffffcaf8,
 [...]

unpack_value_bitfield is already optimized-out/unavailable -aware:

   (...) VALADDR points to the contents of VAL.  If the VAL's contents
   required to extract the bitfield from are unavailable/optimized
   out, DEST_VAL is correspondingly marked unavailable/optimized out.

however, it is not considering the case of the value having no
contents buffer at all, as can happen through
allocate_optimized_out_value.

gdb/ChangeLog:
2016-08-09  Pedro Alves  <palves@redhat.com>

* value.c (unpack_value_bitfield): Skip unpacking if the parent
has no contents buffer to begin with.

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

* gdb.dwarf2/bitfield-parent-optimized-out.exp: New file.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 9 Aug 2016 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoRegenerate some target description files
Pedro Alves [Mon, 8 Aug 2016 14:09:46 +0000 (15:09 +0100)] 
Regenerate some target description files

I regenerated all target description .c files from scratch, and got
this spurious diff.

It's a simple mid-air collision - these files were clearly generated
before commit 73b4f516a037 ("maint_print_c_tdesc_cmd: Use type for
TYPE_CODE_FLAGS instead of field_type."), which did the global
s/field_type/type/, and pushed to master afterwards.

gdb/features/ChangeLog:
2016-08-08  Pedro Alves  <palves@redhat.com>

* features/i386/amd64-avx-mpx-linux.c: Regenerate.
* features/i386/amd64-avx-mpx.c: Regenerate.
* features/i386/i386-avx-mpx-linux.c: Regenerate.
* features/i386/i386-avx-mpx.c: Regenerate.

7 years agoFix seg-faults when running readelf on fuzzed binaries.
Nick Clifton [Mon, 8 Aug 2016 12:20:04 +0000 (13:20 +0100)] 
Fix seg-faults when running readelf on fuzzed binaries.

PR binutils/20440
* dwarf.c (display_debug_lines_decoded): Add checks for running
off the end of the section when populating the directory table and
file table.
(frame_display_row): Set max_regs equal to ncols.
(load_specific_debug_section): If the section is compressed, but
it is not big enough to hold a compression header then warn and
return 0.

7 years agoFix memory leaks in chew program.
Nick Clifton [Mon, 8 Aug 2016 11:19:29 +0000 (12:19 +0100)] 
Fix memory leaks in chew program.

* doc/chew.c (delete_string): Only free the string buffer if it is
there.  Mark the buffer as NULL after freeing.
(drop): Free the dropped string.
(free_words): New function: Frees the memory allocated to the
dictionary.
(add_instrinsic): Duplicate the name string, so that it can be
freed later on.
(compile): Free unused words.
(main): Free the dictionary and top level string buffers at the
end.

7 years agoFix seg-fault in DWARF dumper when given a corrupt binary containing illegal director...
Nick Clifton [Mon, 8 Aug 2016 08:34:32 +0000 (09:34 +0100)] 
Fix seg-fault in DWARF dumper when given a corrupt binary containing illegal directory and file table indicies.

PR binutils/20439
* dwarf.c (display_debug_lines_decoded): Check directory and file
indicies before using them to access directory and file tables.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 8 Aug 2016 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

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

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

7 years agoRemove unused cli_command_loop declaration
Simon Marchi [Fri, 5 Aug 2016 20:26:18 +0000 (16:26 -0400)] 
Remove unused cli_command_loop declaration

This declaration is not used anymore.

gdb/ChangeLog:

* event-top.h (cli_command_loop): Remove.

7 years agoAdd missing ChangLog enrtry
H.J. Lu [Fri, 5 Aug 2016 20:15:16 +0000 (13:15 -0700)] 
Add missing ChangLog enrtry

7 years agoFix PR remote/20398: File-IO write always outputs "Quit"
Pedro Alves [Fri, 5 Aug 2016 18:54:11 +0000 (19:54 +0100)] 
Fix PR remote/20398: File-IO write always outputs "Quit"

Commit bb7c96deb1a1 ("gdb/remote-fileio.c: Eliminate custom SIGINT
signal handler") regressed the File-IO support.

Failed output:

  (gdb) target remote :8888
  Remote debugging using :8888
  0x00008098 in _start ()
  (gdb) c
  Continuing.
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  [Inferior 1 (Remote target) exited normally]

Expected output:

  (gdb) target remote :8888
  Remote debugging using :8888
  0x00008098 in _start ()
  (gdb) c
  Continuing.
  i: 0
  i: 1
  i: 2
  i: 3
  i: 4
  i: 5
  i: 6
  i: 7
  i: 8
  i: 9
  [Inferior 1 (Remote target) exited normally]

The problem that the new File-IO quit handler forgets to check the
quit flag before calling throwing a quit.

gdb/ChangeLog:
2016-08-05  Pedro Alves  <palves@redhat.com>

PR remote/20398
* remote-fileio.c (remote_fileio_quit_handler): Check the quit
flag before calling quit.

7 years agogdb/NEWS: Mention that C++ is now the default
Pedro Alves [Fri, 5 Aug 2016 16:09:31 +0000 (17:09 +0100)] 
gdb/NEWS: Mention that C++ is now the default

gdb/ChangeLog:
2016-08-05  Pedro Alves  <palves@redhat.com>

* NEWS: Mention that GDB and GDBserver build with a C++ compiler
by default.

7 years agogdb/configure --help: suggest --disable-build-with-cxx instead of --enable...
Pedro Alves [Fri, 5 Aug 2016 15:54:29 +0000 (16:54 +0100)] 
gdb/configure --help: suggest --disable-build-with-cxx instead of --enable...

We build by default with a C++ compiler, but "configure --help" still
says "--enable-build-with-cxx", which hints that it is by default
disabled.  Update the --help text.

gdb/ChangeLog:
2016-08-05  Pedro Alves  <palves@redhat.com>

* build-with-cxx.m4: Change help string to be in terms of
--disable-build-with-cxx.
* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2016-08-05  Pedro Alves  <palves@redhat.com>

* configure: Regenerate.

7 years agoEnsure ARM VPUSH and VPOP instructions do not affect more than 16 registers.
Nick Clifton [Fri, 5 Aug 2016 10:26:13 +0000 (11:26 +0100)] 
Ensure ARM VPUSH and VPOP instructions do not affect more than 16 registers.

PR gas/20429
* config/tc-arm.c (do_vfp_nsyn_push): Check that no more than 16
registers are pushed.
(do_vfp_nsyn_pop): Check that no more than 16 registers are
popped.
* testsuite/gas/arm/pr20429.s: New test.
* testsuite/gas/arm/pr20429.d: New test driver.
* testsuite/gas/arm/pr20429.1: Expected error output.

7 years agoFix the generation of alignment frags in code sections for AArch64.
Nick Clifton [Fri, 5 Aug 2016 09:37:57 +0000 (10:37 +0100)] 
Fix the generation of alignment frags in code sections for AArch64.

PR gas/20364
* config/tc-aarch64.c (s_ltorg): Change the mapping state after
aligning the frag.
(aarch64_init): Treat rs_align frags in code sections as
containing code, not data.
* testsuite/gas/aarch64/pr20364.s: New test.
* testsuite/gas/aarch64/pr20364.d: New test driver.

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

7 years ago2016-08-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
Thomas Preud'homme [Thu, 4 Aug 2016 14:54:57 +0000 (15:54 +0100)] 
2016-08-04  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
* bfd-in.h (bfd_elf32_arm_set_target_relocs): Add one parameter.
* bfd-in2.h: Regenerate.
* elf32-arm.c (struct elf32_arm_link_hash_table): Declare new
cmse_implib field.
(bfd_elf32_arm_set_target_relocs): Add new parameter to initialize
cmse_implib field in struct elf32_arm_link_hash_table.
(elf32_arm_filter_cmse_symbols): New function.
(elf32_arm_filter_implib_symbols): Likewise.
(elf_backend_filter_implib_symbols): Define to
elf32_arm_filter_implib_symbols.

ld/
* emultempl/armelf.em (cmse_implib): Declare and define this new
static variable.
(arm_elf_create_output_section_statements): Add new cmse_implib
parameter.
(OPTION_CMSE_IMPLIB): Define macro.
(PARSE_AND_LIST_LONGOPTS): Add entry for new --cmse-implib switch.
(PARSE_AND_LIST_OPTIONS): Likewise.
(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_CMSE_IMPLIB case.
* ld.texinfo (--cmse-implib): Document new option.
* testsuite/ld-arm/arm-elf.exp
(Secure gateway import library generation): New test.
(Secure gateway import library generation: errors): Likewise.
* testsuite/ld-arm/cmse-implib.s: New file.
* testsuite/ld-arm/cmse-implib-errors.out: Likewise.
* testsuite/ld-arm/cmse-implib.rd: Likewise.

7 years ago2016-08-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
Thomas Preud'homme [Thu, 4 Aug 2016 14:36:52 +0000 (15:36 +0100)] 
2016-08-04  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
* elf32-arm.c (CMSE_PREFIX): Define macro.
(elf32_arm_stub_cmse_branch_thumb_only): Define stub sequence.
(cmse_branch_thumb_only): Declare stub.
(struct elf32_arm_link_hash_table): Define cmse_stub_sec field.
(elf32_arm_get_plt_info): Add globals parameter.  Use it to return
FALSE if there is no PLT.
(arm_type_of_stub): Adapt to new elf32_arm_get_plt_info signature.
(elf32_arm_final_link_relocate): Likewise.
(elf32_arm_gc_sweep_hook): Likewise.
(elf32_arm_gc_mark_extra_sections): Mark sections holding ARMv8-M
secure entry functions.
(arm_stub_is_thumb): Add case for arm_stub_cmse_branch_thumb_only.
(arm_dedicated_stub_output_section_required): Change to a switch case
and add a case for arm_stub_cmse_branch_thumb_only.
(arm_dedicated_stub_output_section_required_alignment): Likewise.
(arm_stub_dedicated_output_section_name): Likewise.
(arm_stub_dedicated_input_section_ptr): Likewise and remove
ATTRIBUTE_UNUSED for htab parameter.
(arm_stub_required_alignment): Likewise.
(arm_stub_sym_claimed): Likewise.
(arm_dedicated_stub_section_padding): Likewise.
(cmse_scan): New function.
(elf32_arm_size_stubs): Call cmse_scan for ARM M profile targets.
Set stub_changed to TRUE if such veneers were created.
(elf32_arm_swap_symbol_in): Add detection code for CMSE special
symbols.

include/
* arm.h (ARM_GET_SYM_CMSE_SPCL): Define macro.
(ARM_SET_SYM_CMSE_SPCL): Likewise.

ld/
* ld.texinfo (Placement of SG veneers): New concept entry.
* testsuite/ld-arm/arm-elf.exp
(Secure gateway veneers: no .gnu.sgstubs section): New test.
(Secure gateway veneers: wrong entry functions): Likewise.
(Secure gateway veneers (ARMv8-M Baseline)): Likewise.
(Secure gateway veneers (ARMv8-M Mainline)): Likewise.
* testsuite/ld-arm/cmse-veneers.s: New file.
* testsuite/ld-arm/cmse-veneers.d: Likewise.
* testsuite/ld-arm/cmse-veneers.rd: Likewise.
* testsuite/ld-arm/cmse-veneers.sd: Likewise.
* testsuite/ld-arm/cmse-veneers-no-gnu_sgstubs.out: Likewise.
* testsuite/ld-arm/cmse-veneers-wrong-entryfct.out: Likewise.

7 years agoFix generation of relocs for 32-bit Sparc Solaris targets.
Stefan Trleman [Thu, 4 Aug 2016 13:57:23 +0000 (14:57 +0100)] 
Fix generation of relocs for 32-bit Sparc Solaris targets.

PR gas/20427
* config/tc-sparc.c (cons_fix_new_sparc): Prevent the generation
of 64-bit relocation types when assembling for a 32-bit Solaris
target.

7 years agoDetermine target description for native aarch64
Yao Qi [Thu, 4 Aug 2016 10:37:57 +0000 (11:37 +0100)] 
Determine target description for native aarch64

I find the following test fail when I test native aarch64 gdb with
arm program,

(gdb) PASS: gdb.base/attach-pie-noexec.exp: attach
set architecture arm^M
warning: Selected architecture arm is not compatible with reported target architecture aarch64^M
Architecture `arm' not recognized.^M
The target architecture is set automatically (currently aarch64)^M
(gdb) FAIL: gdb.base/attach-pie-noexec.exp: set architecture arm

GDB thinks the target is aarch64, but it isn't.  Nowadays, we are
using some entries AT_PHENT and AT_HWCAP in auxv to determine whether
the process is a 32-bit arm one or 64-bit aarch64 one, and get the
right gdbarch.  However, in the process of parsing auxv (in
inf_ptrace_auxv_parse), the size of int and data pointer of
target_gdbarch is used.  If debug program exists (in most of cases),
target_gdbarch is already set according to the debug program, which
is arm in my case.  Then, GDB can parse auxv successfully.  However,
in gdb.base/attach-pie-noexec.exp, the debug program is removed,
target_gdbarch is aarch64 when GDB parse auxv, so GDB can't parse
it successfully.

Instead of using auxv, we check the return value of ptrace NT_ARM_VFP.
If the program is an arm process, NT_ARM_VFP is OK, otherwise, error
is returned.

Additionally, we only return tdesc_arm_with_neon for arm process,
because neon is mandatory on ARMv8.

gdb:

2016-08-04  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (tdesc_arm_with_vfpv3): Remove the
declaration.
(aarch64_linux_read_description): Remove code on getting
auxv and select target description on it.  Select target
description by the result of NT_ARM_VFP ptrace request.

7 years agoQuiet ptrace error ESRCH in regsets_fetch_inferior_registers
Yao Qi [Thu, 4 Aug 2016 09:44:18 +0000 (10:44 +0100)] 
Quiet ptrace error ESRCH in regsets_fetch_inferior_registers

When I run process-dies-while-detaching.exp with GDBserver, I see many
warnings printed by GDBserver,

ptrace(regsets_fetch_inferior_registers) PID=26183: No such process
ptrace(regsets_fetch_inferior_registers) PID=26183: No such process
ptrace(regsets_fetch_inferior_registers) PID=26184: No such process
ptrace(regsets_fetch_inferior_registers) PID=26184: No such process

regsets_fetch_inferior_registers is called when GDBserver resumes each
lwp.

 #2  0x0000000000428260 in regsets_fetch_inferior_registers (regsets_info=0x4690d0 <aarch64_regsets_info>, regcache=0x31832020)
    at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:5412
 #3  0x00000000004070e8 in get_thread_regcache (thread=0x31832940, fetch=fetch@entry=1) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/regcache.c:58
 #4  0x0000000000429c40 in linux_resume_one_lwp_throw (info=<optimized out>, signal=0, step=0, lwp=0x31832830)
    at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4463
 #5  linux_resume_one_lwp (lwp=0x31832830, step=<optimized out>, signal=<optimized out>, info=<optimized out>)
    at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4573

The is the case that threads are disappeared when GDB/GDBserver resumes
them.  We check errno for ESRCH, and don't print error messages, like
what we are doing in regsets_store_inferior_registers.

gdb/gdbserver:

2016-08-04  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (regsets_fetch_inferior_registers): Check
errno is ESRCH or not.

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

7 years agoPR python/18565 - make Frame.function work for inline frames
Tom Tromey [Mon, 13 Jun 2016 02:45:29 +0000 (20:45 -0600)] 
PR python/18565 - make Frame.function work for inline frames

PR python/18565 notes that calling frame filters don't work properly for
inlined functions.  This happens because Frame.function on an inline
frame will yield the wrong result.  This patch changes this code to use
find_frame_funname instead, which handles inline frames properly.

Built and regtested on x86-64 Fedora 24.

2016-08-03  Tom Tromey  <tom@tromey.com>

PR python/18565:
* python/py-frame.c (frapy_function): Use find_frame_funname.

2016-08-03  Tom Tromey  <tom@tromey.com>

PR python/18565:
* gdb.python/py-frame-inline.exp: Add Frame.function test.

7 years agoAvoid potential memory leak in find_frame_funname
Tom Tromey [Wed, 3 Aug 2016 14:27:56 +0000 (08:27 -0600)] 
Avoid potential memory leak in find_frame_funname

The PR 18565 thread pointed out that, if cp_remove_params can throw
(we aren't quite sure), then find_frame_funname could leak some
memory.  This patch avoids any potential issue by rearranging some
code in find_frame_funname.

Built and regtested on x86-64 Fedora 24.

2016-08-03  Tom Tromey  <tom@tromey.com>

* stack.c (find_frame_funname): Avoid any possible leak in case
cp_remove_params can throw.

7 years agoUpdate NEWS to mention Python breakpoint events
Tom Tromey [Tue, 2 Aug 2016 22:52:59 +0000 (16:52 -0600)] 
Update NEWS to mention Python breakpoint events

An earlier patch added three new breakpoint-related events to the
Python API.  However, at that time, I forgot to update NEWS.  This
patch supplies the missing entry.

2016-08-03  Tom Tromey  <tom@tromey.com>

* NEWS: Mention new Python breakpoint events.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 3 Aug 2016 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoAdd myself as Rust maintainer
Tom Tromey [Tue, 2 Aug 2016 22:58:37 +0000 (16:58 -0600)] 
Add myself as Rust maintainer

A while ago, Pedro announced that I would be the Rust maintainer for
gdb.  However, I neglected to update the MAINTAINERS file until now.

2016-08-02  Tom Tromey  <tom@tromey.com>

* MAINTAINERS (Core): Add self as Rust maintainer.

7 years ago[GDBserver] Remove td_ta_event_addr td_ta_set_event and td_ta_event_getmsg
Yao Qi [Tue, 2 Aug 2016 15:04:09 +0000 (16:04 +0100)] 
[GDBserver] Remove td_ta_event_addr td_ta_set_event and td_ta_event_getmsg

As a result of this commit,

  9b4c5f878ff39e04127a1ad95f6b3832afe6d278
  (Remove support for thread events without PTRACE_EVENT_CLONE in GDBServer.)

the last usage of td_ta_event_addr td_ta_set_event and
td_ta_event_getmsg were removed.  They are no longer used.  This patch
is to remove them.

gdb/gdbserver:

2016-08-02  Yao Qi  <yao.qi@linaro.org>

* thread-db.c (struct thread_db) <td_ta_event_getmsg_p>: Remove.
<td_ta_set_event_p, td_ta_event_addr_p>: Remove.
(thread_db_load_search): Update.
(try_thread_db_load_1): Don't look for td_ta_event_addr,
td_ta_set_event and td_ta_event_getmsg.

7 years agoPowerPC64 ld segfault with code in non-executable sections
Alan Modra [Tue, 2 Aug 2016 13:58:47 +0000 (23:28 +0930)] 
PowerPC64 ld segfault with code in non-executable sections

PR ld/20428
* elf64-ppc.c (ppc_get_stub_entry): Don't segfault on NULL group.

7 years agoSynchronize libiberty sources with FSF GCC mainline version.
Nick Clifton [Tue, 2 Aug 2016 12:26:28 +0000 (13:26 +0100)] 
Synchronize libiberty sources with FSF GCC mainline version.

include * libiberty.h (MAX_ALLOCA_SIZE): New macro.

libiberty * make-relative-prefix.c (make_relative_prefix_1): Fall back to
malloc if alloca argument is greater than MAX_ALLOCA_SIZE.

* cp-demangle.c (cplus_demangle_operators): Add f[lrLR].
(d_expression_1): Handle them.
(d_maybe_print_fold_expression): New.
(d_print_comp_inner): Use it.
(d_index_template_argument): Handle negative index.

* cp-demangle.c (cplus_demangle_operators): Add sP and sZ.
(d_print_comp_inner): Handle them.
(d_template_args_1): Split out from d_template_args.
(d_args_length): New.

PR c++/70926
* cplus-dem.c: Handle large values and overflow when demangling
length variables.
(demangle_template_value_parm): Read only until end of mangled string.
(do_hpacc_template_literal): Likewise.
(do_type): Handle overflow when demangling array indices.

* cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length
  VLAs.

PR c++/70498
* cp-demangle.c (d_expression_1): Formatting fix.

* cplus-dem.c (enum type_kind_t): Add tk_rvalue_reference
constant.
(demangle_template_value_parm): Handle tk_rvalue_reference
type kind.
(do_type): Support 'O' type id (rvalue references).

* testsuite/demangle-expected: Add tests.

PR c++/70498
* cp-demangle.c: Parse numbers as integer instead of long to avoid
overflow after sanity checks. Include <limits.h> if available.
(INT_MAX): Define if necessary.
(d_make_template_param): Takes integer argument instead of long.
(d_make_function_param): Likewise.
(d_append_num): Likewise.
(d_identifier): Likewise.
(d_number): Parse as and return integer.
(d_compact_number): Handle overflow.
(d_source_name): Change variable type to integer for parsed number.
(d_java_resource): Likewise.
(d_special_name): Likewise.
(d_discriminator): Likewise.
(d_unnamed_type): Likewise.
* testsuite/demangle-expected: Add regression test cases.

* configure: Remove SH5 support.

PR c++/69687
* cplus-dem.c: Include <limits.h> if available.
(INT_MAX): Define if necessary.
(remember_type, remember_Ktype, register_Btype, string_need):
Abort if we detect cases where we the size of the allocation would
overflow.

PR c++/70492
* cplus-dem.c (gnu_special): Handle case where consume_count returns
-1.

PR c++/67394
PR c++/70481
* cplus-dem.c (squangle_mop_up): Zero bsize/ksize after freeing
btypevec/ktypevec.
* testsuite/demangle-expected: Add coverage tests.

7 years agoFix SH GOT allocation in the presence of linker garbage collection.
Nick Clifton [Tue, 2 Aug 2016 10:56:55 +0000 (11:56 +0100)] 
Fix SH GOT allocation in the presence of linker garbage collection.

PR ld/17739
ld * emulparams/shelf.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Define with
valye 'yes'.
* emulparams/shelf32.sh: Likewise.
* emulparams/shelf32.sh: Likewise.
* emulparams/shelf_nto.sh: Likewise.
* emulparams/shelf_nto.sh: Likewise.
* emulparams/shelf_vxworks.sh: Likewise.
* emulparams/shelf_vxworks.sh: Likewise.
* emulparams/shlelf32_linux.sh: Likewise.
* emulparams/shlelf32_linux.sh: Likewise.
* emulparams/shlelf_linux.sh: Likewise.
* emulparams/shlelf_linux.sh: Likewise.
* emulparams/shlelf_nto.sh: Likewise.
* emulparams/shlelf_nto.sh: Likewise.

bfd * elf32-sh.c (sh_elf_gc_sweep_hook): Delete.
(elf_backend_sweep_hook): Delete.

7 years agoAvoid compile time warning when building on 32-bit host.
Nick Clifton [Tue, 2 Aug 2016 10:06:28 +0000 (11:06 +0100)] 
Avoid compile time warning when building on 32-bit host.

PR binutils/17512
* resbin.c (bin_to_res_version): Cast variables to correct type
for printing in error message.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 2 Aug 2016 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years ago Fix some PowerPC VLE BFD issues and add some PowerPC VLE instructions.
Andrew Jenner [Mon, 1 Aug 2016 16:42:31 +0000 (09:42 -0700)] 
    Fix some PowerPC VLE BFD issues and add some PowerPC VLE instructions.

        bfd/
        * elf32-ppc.c (is_branch_reloc): Recognise VLE branch relocations.
        (ppc_elf_howto_raw): Fix dst_mask of R_PPC_VLE_REL15.
        (ppc_elf_vle_split16): Clear field before inserting.

        opcodes/
        * ppc-opc.c (vle_opcodes): Alias 'e_cmpwi' to 'e_cmpi' and
        'e_cmplwi' to 'e_cmpli' instead.
        (OPVUPRT, OPVUPRT_MASK): Define.
        (powerpc_opcodes): Add E200Z4 insns.
        (vle_opcodes): Add context save/restore insns.

        include/
        * opcode/ppc.h (PPC_OPCODE_E200Z4): New define.

7 years agoUpdate NEWS post GDB 7.12 branch creation.
Joel Brobecker [Mon, 1 Aug 2016 15:28:26 +0000 (08:28 -0700)] 
Update NEWS post GDB 7.12 branch creation.

gdb/ChangeLog:

* NEWS: Create a new section for the next release branch.
Rename the section of the current branch, now that it has
been cut.

7 years agoBump version to 7.12.50.DATE-git.
Joel Brobecker [Mon, 1 Aug 2016 15:23:20 +0000 (08:23 -0700)] 
Bump version to 7.12.50.DATE-git.

Now that the GDB 7.12 branch has been created, we can
bump the version number.

gdb/ChangeLog:

GDB 7.12 branch created (41bfcd638a4e0e48b96ce4de2845372dea481322):
* version.in: Bump version to 7.12.50.DATE-git.

7 years agoSwap "single-process" and "multi-process" in process-dies-while-detaching.exp gdb-7.12-branchpoint
Yao Qi [Thu, 28 Jul 2016 13:37:02 +0000 (14:37 +0100)] 
Swap "single-process" and "multi-process" in process-dies-while-detaching.exp

"single-process" and "multi-process" are used in the test message of
process-dies-while-detaching.exp, but they are misplaced due to

    set mode [expr {$multi_process ? "single-process" : "multi-process"}]

This patch is to swap them.

gdb/testsuite:

2016-08-01  Yao Qi  <yao.qi@linaro.org>

* gdb.threads/process-dies-while-detaching.exp (do_test): Set
variable mode to "multi-process" if $multi_process is 1, otherwise
set it to "single-process".

7 years agoUpdate Swedish translation in bfd directory.
Nick Clifton [Mon, 1 Aug 2016 08:59:04 +0000 (09:59 +0100)] 
Update Swedish translation in bfd directory.

7 years agoTweak gdb.cp tests for aarch32
Yao Qi [Mon, 1 Aug 2016 08:18:02 +0000 (09:18 +0100)] 
Tweak gdb.cp tests for aarch32

There are some gdb.cp/ tests fails if the program is compiled for arm
32-bit but GDB/GDBserver is aarch64 64-bit program, because target triplet
doesn't match "arm*-*-*".  Instead, we can use is_aarch32_target.

gdb/testsuite:

2016-08-01  Yao Qi  <yao.qi@linaro.org>

* gdb.cp/anon-struct.exp: Check is_aarch32_target.
* gdb.cp/cpexprs.exp: Likewise.
* gdb.cp/m-static.exp: Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 1 Aug 2016 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

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

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

7 years agogas: avoid spurious failures in non-ELF targets in the SPARC testsuite.
Jose E. Marchesi [Wed, 27 Jul 2016 13:59:16 +0000 (06:59 -0700)] 
gas: avoid spurious failures in non-ELF targets in the SPARC testsuite.

Many of the existing sparc tests fail in non-ELF targets (coff and
a.out) due to spurious differences in the expected results:

- Unlike ELF, a.out text sections are aligned to 2**3 and padded
  accordingly.  The padding instruction is a `nop' (01 00 00 00).

- Likewise, coff text sections are also aligned to 2**3 and padded
  accordingly.  However, the padding instruction in these targets is an
  `illtrap 0' (00 00 00 00).

- Unlike ELF, a.out and coff binaries don't contain hardware
  capabilities bits that could be used by BFD to determine the opcodes
  architecture corresponding to the instructions encoded in the
  objects (v9, v9a, v9b, v9c, etc).  Consequently, in both a.out and
  coff tests we would need to pass proper `-m sparc:vXXX' options when
  invoking objdump before comparing results.

In order to fix these issues, the most obvious solution would be to have
three variants of .d files per impacted test.  For example, for save.d
we would have: save-elf.d, save-aout.d and save-coff.d.  Using the
`#source' directive, a single save.s file would provide the input for
all of them.  However, this approach has the following problems:

- The #target and #notarget .d directives are very limited: they use
  globs instead of regular expressions, and thus it is not possible (or
  too messy) to use them to discriminate between elf, coff and a.out
  sparc targets.

- It adds little or no value to have variants of all these tests for all
  the target types, and it would be a burden to maintain them.  Actually
  the features tested in the spuriously failing tests (relatively modern
  sparc instructions, registers and asis) are not really found in
  running coff or a.out sparc systems.

This patch changes sparc.exp so it will run these tests only in
ELF-targets, using the more standard `is_elf_format' from
binutils-common.exp instead of the ad-hoc (and less convenient, as it
must be called before _every_ single elf-only test) sparc_elf_setup.

Incidentally, the patch also fixes the #name entry for save-args.d.

Tested in sparc*-*-linux-gnu, sparc-aout and sparc-coff targets.

gas/ChangeLog:

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

* testsuite/gas/sparc/sparc.exp: Use is_elf_format to discriminate
ELF targets.
Run natural, natural-32, pr4587, ticc-imm-reg, v8-movwr-imm,
pause, save-args, cbcond, cfr, crypto edge, flush, hpcvis3, ima,
ld_st_fsr, ldtw_sttw, ldd_std, ldx_stx, ldx_efsr, mwait, mcdper,
sparc5vis4, xcrypto, v9branch1 and imm-plus-rreg only in ELF
targets.
(sparc_elf_setup): Delete.
* testsuite/gas/sparc/save-args.d: Fix a copy-paste typo in the
test's #name entry.

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

7 years agoFix decoding of Windows resources.
Nick Clifton [Thu, 28 Jul 2016 14:37:16 +0000 (15:37 +0100)] 
Fix decoding of Windows resources.

PR binutils/17512
* rescoff.c (read_coff_res_dir): Fix detection of buffer overrun.
* resbin.c (bin_to_res_version): Allow for the padded length of a
version block to be longer than the recorded length.  Skip padding
bytes.

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

7 years agoMIPS/GAS: Implement microMIPS branch/jump compaction
Maciej W. Rozycki [Wed, 27 Jul 2016 16:27:55 +0000 (17:27 +0100)] 
MIPS/GAS: Implement microMIPS branch/jump compaction

Convert microMIPS branches and jumps whose delay slot would be filled by
a generated NOP instruction to the corresponding compact form where one
exists, in a manner similar to MIPS16 JR->JRC and JALR->JALRC swap.

Do so even where the transformation switches from a 16-bit to a 32-bit
branch encoding for no benefit in code size reduction, as this is still
advantageous.  This is because a branch/NOP pair takes 2 pipeline slots
or a 2-cycle completion latency except in superscalar implementations.
Whereas a compact branch may or may not stall on its target fetch, so it
will at most have a 2-cycle completion latency and may have only 1 even
in scalar implementations, and in superscalar implementations it is
expected to have no worse latency as a branch/NOP pair has.  Also it
won't stall and therefore take the extra latency cycle in the not-taken
case.

Technically this is the same as MIPS16 compaction: for the qualifying
instruction encodings the APPEND_ADD_COMPACT machine code generation
method is selected where APPEND_ADD_WITH_NOP otherwise would and tells
the code generator in `append_insn' to convert the regular form of an
instruction to its corresponding compact form.  For this the opcode is
tweaked as necessary and the microMIPS opcode table is scanned for the
matching updated instruction.  A non-$0 `rt' operand to BEQ and BNE
instructions is moved to the `rs' operand field of BEQZC and BNEZC
encodings as required.

Unlike with MIPS16 compaction however we need to handle out-of-distance
branch relaxation as well.  We do this by deferring the generation of
any delay-slot NOP required to relaxation made in `md_convert_frag', by
converting the APPEND_ADD_WITH_NOP machine code generation to APPEND_ADD
where a relaxed instruction is recorded.  Relaxation then, depending on
actual code produced, chooses between either using a compact branch or
jump encoding and emitting the NOP outstanding if no compact encoding is
possible.

For code simplicity's sake the relaxation pass is retained even if the
principle of preferring a compact encoding to a 16-bit branch/NOP pair
means, in the absence of out-of-range branch relaxation, that a single
compact branch machine code instruction will eventually be produced from
a given assembly source instruction.

gas/
* config/tc-mips.c (RELAX_MICROMIPS_ENCODE): Add `nods' flag.
(RELAX_MICROMIPS_RELAX32, RELAX_MICROMIPS_TOOFAR16)
(RELAX_MICROMIPS_MARK_TOOFAR16, RELAX_MICROMIPS_CLEAR_TOOFAR16)
(RELAX_MICROMIPS_TOOFAR32, RELAX_MICROMIPS_MARK_TOOFAR32)
(RELAX_MICROMIPS_CLEAR_TOOFAR32): Shift bits.
(get_append_method): Also return APPEND_ADD_COMPACT for
microMIPS instructions.
(find_altered_mips16_opcode): Exclude macros from matching.
Factor code out...
(find_altered_opcode): ... to this new function.
(find_altered_micromips_opcode): New function.
(frag_branch_delay_slot_size): Likewise.
(append_insn): Handle microMIPS branch/jump compaction.
(macro_start): Likewise.
(relaxed_micromips_32bit_branch_length): Likewise.
(md_convert_frag): Likewise.
* testsuite/gas/mips/micromips.s: Add conditional explicit NOPs
for delay slot filling.
* testsuite/gas/mips/micromips-b16.s: Add explicit NOPs for
delay slot filling.
* testsuite/gas/mips/micromips-size-1.s: Likewise.
* testsuite/gas/mips/micromips.l: Adjust line numbers.
* testsuite/gas/mips/micromips-warn.l: Likewise.
* testsuite/gas/mips/micromips-size-1.l: Likewise.
* testsuite/gas/mips/micromips.d: Adjust padding.
* testsuite/gas/mips/micromips-trap.d: Likewise.
* testsuite/gas/mips/micromips-insn32.d: Likewise.
* testsuite/gas/mips/micromips-noinsn32.d: Likewise.
* testsuite/gas/mips/micromips@beq.d: Update patterns for
branch/jump compaction.
* testsuite/gas/mips/micromips@bge.d: Likewise.
* testsuite/gas/mips/micromips@bgeu.d: Likewise.
* testsuite/gas/mips/micromips@blt.d: Likewise.
* testsuite/gas/mips/micromips@bltu.d: Likewise.
* testsuite/gas/mips/micromips@branch-misc-4.d: Likewise.
* testsuite/gas/mips/micromips@branch-misc-4-64.d: Likewise.
* testsuite/gas/mips/micromips@branch-misc-5.d: Likewise.
* testsuite/gas/mips/micromips@branch-misc-5pic.d: Likewise.
* testsuite/gas/mips/micromips@branch-misc-5-64.d: Likewise.
* testsuite/gas/mips/micromips@branch-misc-5pic-64.d: Likewise.
* testsuite/gas/mips/micromips@jal-svr4pic-local.d: Likewise.
* testsuite/gas/mips/micromips@jal-svr4pic-local-n32.d:
Likewise.
* testsuite/gas/mips/micromips@jal-svr4pic-local-n64.d:
Likewise.
* testsuite/gas/mips/micromips@loc-swap.d: Likewise.
* testsuite/gas/mips/micromips@loc-swap-dis.d: Likewise.
* testsuite/gas/mips/micromips@relax.d: Likewise.
* testsuite/gas/mips/micromips@relax-at.d: Likewise.
* testsuite/gas/mips/micromips@relax-swap3.d: Likewise.
* testsuite/gas/mips/branch-extern-2.d: Likewise.
* testsuite/gas/mips/branch-extern-4.d: Likewise.
* testsuite/gas/mips/branch-section-2.d: Likewise.
* testsuite/gas/mips/branch-section-4.d: Likewise.
* testsuite/gas/mips/branch-weak-2.d: Likewise.
* testsuite/gas/mips/branch-weak-5.d: Likewise.
* testsuite/gas/mips/micromips-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.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/micromips-compact.d: New test.
* testsuite/gas/mips/mips.exp: Run the new test.

ld/
* testsuite/ld-mips-elf/micromips-branch-absolute.d: Update
patterns for branch compaction.
* testsuite/ld-mips-elf/micromips-branch-absolute-addend.d:
Likewise.

opcodes/
* micromips-opc.c (micromips_opcodes): Reorder "bc" next to "b",
"beqzc" next to "beq", "bnezc" next to "bne" and "jrc" next to
"j".

7 years agoBegin implementing ARC NPS-400 Accelerator instructions
Graham Markall [Wed, 27 Jul 2016 14:57:18 +0000 (15:57 +0100)] 
Begin implementing ARC NPS-400 Accelerator instructions

opcodes * arc-nps400-tbl.h: Change block comments to GNU format.
        * arc-dis.c: Add new globals addrtypenames,
        addrtypenames_max, and addtypeunknown.
        (get_addrtype): New function.
        (print_insn_arc): Print colons and address types when
        required.
        * arc-opc.c: Add MAKE_INSERT_NPS_ADDRTYPE macro and use to
        define insert and extract functions for all address types.
        (arc_operands): Add operands for colon and all address
        types.
        * arc-nps-400-tbl.h: Add NPS-400 BMU instructions to opcode table.
        * arc-opc.c: Add NPS_BD_TYPE and NPS_BMU_NUM operands,
        insert_nps_bd_num_buff and extract_nps_bd_num_buff functions.
        * arc-nps-400-tbl.h: Add NPS-400 PMU instructions to opcode table.
        * arc-opc.c: Add NPS_PMU_NXT_DST and NPS_PMU_NUM_JOB operands,
        insert_nps_pmu_num_job and extract_nps_pmu_num_job functions.

include * opcode/arc.h: Add ARC_OPERAND_ADDRTYPE,
        ARC_OPERAND_COLON. Add the arc_nps_address_type enum and
        ARC_NUM_ADDRTYPES.
        * opcode/arc.h: Add BMU to insn_class_t enum.
        * opcode/arc.h: Add PMU to insn_class_t enum.

gas     * config/tc-arc.c: Add new global arc_addrtype_hash.
        Define O_colon and O_addrtype.
        (debug_exp): Add O_colon and O_addrtype.
        (tokenize_arguments): Handle colon and address type
        tokens.
        (declare_addrtype): New function.
        (md_begin): Initialise arc_addrtype_hash.
        (arc_parse_name): Add lookup of address types.
(assemble_insn): Handle colons and address types by
        ignoring them.
        * testsuite/gas/arc/nps400-8.s: New file.
        * testsuite/gas/arc/nps400-8.d: New file.
        * testsuite/gas/arc/nps400-8.s: Add PMU instruction tests.
        * testsuite/gas/arc/nps400-8.d: Add expected PMU
        instruction output.

7 years agoRestrict linker garbage collection personality test to cfi enabled targets.
Nick Clifton [Wed, 27 Jul 2016 11:01:09 +0000 (12:01 +0100)] 
Restrict linker garbage collection personality test to cfi enabled targets.

* testsuite/ld-gc/personality.d: Use "target cfi" to restrict the
test to targets which support cfi.

7 years agoFix seg-fault when running garbage collection on coff binaries.
Nick Clifton [Wed, 27 Jul 2016 09:49:32 +0000 (10:49 +0100)] 
Fix seg-fault when running garbage collection on coff binaries.

PR ld/20401
* coffgen.c (fini_reloc_cookie_rels): Check for the extistence
of the coff_section_data before using it.

7 years agoFix warning in ldbuildid.c mingw32 code
Igor Kudrin [Wed, 27 Jul 2016 09:31:34 +0000 (19:01 +0930)] 
Fix warning in ldbuildid.c mingw32 code

* ldbuildid.c (generate_build_id): Warning fix.