external/binutils.git
7 years agold: add an error in case of address space overflow.
Tristan Gingold [Fri, 10 Mar 2017 14:16:19 +0000 (15:16 +0100)]
ld: add an error in case of address space overflow.

ld/
* ldlang.c (lang_check_section_addresses): Check for address space
overflow.
* testsuite/ld-checks/checks.exp (overflow_check): New procedure
* testsuite/ld-checks/over.s: New test source.
* testsuite/ld-checks/over.d: New test.
* testsuite/ld-checks/over2.s: New test source.
* testsuite/ld-checks/over2.d: New test.

7 years agoPowerPC: incorrect library search order
Alexey Neyman [Mon, 13 Mar 2017 03:49:46 +0000 (20:49 -0700)]
PowerPC: incorrect library search order

First, need to match against just the CPU name, not the whole triplet.
Otherwise, the test picks up "*le-*" pattern from x86_64-apple-darwin
triplet.

Second, it should be testing for $target, not $host. Host may be
little endian by default, and the sysroot directory layout shouldn't
depend on whether it is built on LE or BE machine.

* emulparams/elf32ppccommon.sh (LIBPATH_SUFFIX): Set from target
cpu, not host.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 13 Mar 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 12 Mar 2017 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAdd sysroot for ld -rpath search
Alan Modra [Sat, 11 Mar 2017 13:07:02 +0000 (23:37 +1030)]
Add sysroot for ld -rpath search

* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Add
sysroot for -rpath search.

7 years agoRewrite add_sysroot
Alan Modra [Sat, 11 Mar 2017 12:27:29 +0000 (22:57 +1030)]
Rewrite add_sysroot

Relative paths shouldn't have the sysroot prefix added.  The patch
also makes some attempt at supporting DOS paths, and tidies code using
the new add_sysroot.

* emultempl/elf32.em (gld${EMULATION_NAME}_add_sysroot): Rewrite.
Only prefix absolute paths with sysroot.  Handle DOS paths.
(gld${EMULATION_NAME}_check_ld_elf_hints): Constify variable.
(gld${EMULATION_NAME}_check_ld_so_conf): Likewise.
(gld${EMULATION_NAME}_after_open): Short-circuit NULL path
searches.  Rename variable.  Simplify get_runpath search.

7 years agoRemove bogus ATTRIBUTE_UNUSED
Alan Modra [Sat, 11 Mar 2017 10:26:51 +0000 (20:56 +1030)]
Remove bogus ATTRIBUTE_UNUSED

* elf32-ppc.c: Remove ATTRIBUTE_UNUSED throughout when function
parameter is in fact used.  Whitespace fixes.
* elf64-ppc.c: Likewise.

7 years agoDon't use -rdynamic in ld test
Alan Modra [Sat, 11 Mar 2017 00:34:02 +0000 (11:04 +1030)]
Don't use -rdynamic in ld test

This gcc option isn't well supported, so use the actual linker option
we want to test.

* testsuite/ld-elf/shared.exp: Use -Wl,-export-dynamic rather
than -rdynamic.

7 years agoDon't run new orphan tests on i860 and i960
Alan Modra [Sat, 11 Mar 2017 00:21:56 +0000 (10:51 +1030)]
Don't run new orphan tests on i860 and i960

These targets use the generic ELF support, so don't handle orphans
well.  The patch also updates the orphan doco to reflect this fact,
and deletes some ELF details that don't really add anything.

* ld.texinfo (Orphan Sections): Mention that not all targets
handle orphans well.  Delete ELF details.
* testsuite/ld-elf/orphan-9.d: Don't run for i860 and i960.
* testsuite/ld-elf/orphan-10.d: Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 11 Mar 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoc++/8218: Destructors w/arguments.
Keith Seitz [Fri, 10 Mar 2017 18:32:09 +0000 (10:32 -0800)]
c++/8218: Destructors w/arguments.

For a long time now, c++/8218 has noted that GDB is printing argument types
for destructors:

(gdb) ptype A
type = class A {
  public:
    ~A(int);
}

This happens because cp_type_print_method_args doesn't ignore artificial
arguments.  [It ignores the first `this' pointer because it simply skips
the first argument for any non-static function.]

This patch fixes this:

(gdb) ptype  A
type = class A {
  public:
    ~A();
}

I've adjusted gdb.cp/templates.exp to account for this and added a new
passing regexp.

gdb/ChangeLog

PR c++/8218
* c-typeprint.c (cp_type_print_method_args): Skip artificial arguments.

gdb/testsuite/ChangeLog

PR c++/8128
* gdb.cp/templates.exp (test_ptype_of_templates): Remove argument
type from destructor regexps.
Add a branch which actually passes the test.
Adjust "ptype t5i" test names.

7 years agoMake objdump's --wide command line option affect its output of DWARF debug information.
Chia-Hao Lo [Fri, 10 Mar 2017 16:29:58 +0000 (16:29 +0000)]
Make objdump's --wide command line option affect its output of DWARF debug information.

PR binutils/21235
* objdump.c (main): Set do_wide with --wide.

7 years agoDocument that the .2byte and .4byte directives warn about overlarge values.
Nick Clifton [Fri, 10 Mar 2017 15:42:04 +0000 (15:42 +0000)]
Document that the .2byte and .4byte directives warn about overlarge values.

* doc/as.texinfo (2byte): Tidy up wording.  Add note that
overlarge values will produce a warning message and be trunacted.
(4byte): Likewise.

7 years agoAdd basic recognition of new EM_ ELF machine numbers.
Nick Clifton [Fri, 10 Mar 2017 10:50:34 +0000 (10:50 +0000)]
Add basic recognition of new EM_ ELF machine numbers.

include * elf/common.h (EM_LANAI): New machine number.
(EM_BPF): Likewise.
(EM_WEBASSEMBLY): Likewise.
Move low value, deprecated, numbers to their numerical
equivalents.

binutils * readelf.c (get_machine_name): Rearrange switch table in order of
increasing machine number.  Add missing entries.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 10 Mar 2017 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agold: Track changes to default region LMA even for empty sections
Andrew Burgess [Tue, 17 Jan 2017 19:13:29 +0000 (19:13 +0000)]
ld: Track changes to default region LMA even for empty sections

Given a linker script fragment like this:

   SECTIONS {
     . = 0x1000;
     .text   : AT(0x100) { *(.text)   }
     .data   : AT(0x200) { *(.data)   }
     .rodata : AT(0x300) { *(.rodata) }
   }

and an input file containing sections, '.text', '.data.1', and
'.rodata', then we'd expect the linker to place '.text' and '.rodata' in
the obvious way, and the '.data.1' orphan section would be located after
the '.data' section (assuming similar section properties).

Further, I believe that the expectation would be that the LMA for the
orphan '.data.1' section would start from 0x200 (as there is no '.data'
content).

However, right now, the LMA for '.data.1' would be 0x101, following on
from the '.text' section, this is because the change in LMA for the
'.data' section is not noticed by the linker, if there's no content in
the '.data' section.

What can be even more confusing to a user (though the cause is obvious
once you understand what's going on) is that adding some content to
'.data' will cause the orphan '.data.1' to switch to an LMA based off of
0x200.

This commit changes the behaviour so that an empty section that is in
the default lma region, and sets its lma, will adjust the lma of the
default region, this change will then be reflected in following sections
within the default lma memory region.

There's a new test to cover this issue that passes on a range of
targets, however, some targets generate additional sections, or have
stricter memory region size requirements that make it harder to come
up with a generic pass pattern, that still tests the required
features.  For now I've set the test to ignore these targets.

ld/ChangeLog:

* ldlang.c (lang_size_sections_1): Shortcut loop only after
tracking changes to the default regions LMA.
* testsuite/ld-elf/orphan-9.ld: Extend header comment.
* testsuite/ld-elf/orphan-10.d: New file.
* testsuite/ld-elf/orphan-10.s: New file.
* NEWS: Mention change in behaviour.

7 years agold: better handling of lma region for orphan sections
Andrew Burgess [Tue, 17 Jan 2017 19:12:54 +0000 (19:12 +0000)]
ld: better handling of lma region for orphan sections

When picking an lma_region for an orphan section we currently create a
new lang_output_section_statement_type and then populate this with the
orphan section.

The problem is that the lang_output_section_statement_type has a prev
pointer that links back to the previous output section.  For non-orphan
output sections, that are created in linker script order, the prev
pointer will point to the output section that appears previous in linker
script order, as you'd probably expect.

The problem is that orphan sections are placed after processing the
linker script, and so, in the case of an output section created for an
orphan input section, the prev pointer actually points to the last
output section created.

This causes some unexpected behaviour when the orphan section is not
placed after the last non-orphan section that was created.

For example, consider this linker script:

  MEMORY {
    TEXT   : ORIGIN = 0x200,  LENGTH = 0x10
    RODATA : ORIGIN = 0x400,  LENGTH = 0x10
  }

  SECTIONS {
    .text   :           {*(.text)    } AT>TEXT
    .data   : AT(0x300) { *(.data)   }
    .rodata :           { *(.rodata) } AT>RODATA
  }

If we are processing an orphan section '.data.1' and decide to place
this after '.data', then the output section created will have a prev
pointer that references the '.rodata' output section.  The result of
this is that '.data.1' will actually be assigned to the RODATA lma
region, which is probably not the expected behaviour.

The reason why '.data.1' is placed into the lma region of the '.rodata'
section is that lma region propagation is done at the time we create the
output section, based on the previous output section pointer, which is
really just a last-output-section-created pointer at that point in time,
though the prev point is fixed up later to reflect the true order of the
output sections.

The solution I propose in this commit is to move the propagation of lma
regions into a separate pass of the linker, rather than performing this
as part of the enter/exit of output sections during linker script
parsing.

During this later phase we have all of the output sections to hand, and
the prev/next points have been fixed up by this point to reflect the
actual placement ordering.

There's a new test to cover this issue that passes on a range of
targets, however, some targets generate additional sections, or have
stricter memory region size requirements that make it harder to come
up with a generic pass pattern, that still tests the required
features.  For now I've set the test to ignore these targets.

ld/ChangeLog:

* ldlang.c (lang_leave_output_section_statement): Move lma_region
logic to...
(lang_propagate_lma_regions): ...this new function.
(lang_process): Call new function.
* testsuite/ld-elf/orphan-9.d: New file.
* testsuite/ld-elf/orphan-9.ld: New file.
* testsuite/ld-elf/orphan-9.s: New file.
* NEWS: Mention change in behaviour.

7 years agold: Orphan section documentation
Andrew Burgess [Tue, 17 Jan 2017 18:08:17 +0000 (18:08 +0000)]
ld: Orphan section documentation

Make more explicit mention of the fact that orphan sections can cause a
new output section to be created.  Though this information is clearly
implied in the manual it might not be clear enough.

A user _might_ (incorrectly) think that orphan sections can only be
inserted into an existing output section.

ld/ChangeLog:

* ld.texinfo (Orphan Sections): Add more detail.

7 years agoX86: Add pseudo prefixes to control encoding
H.J. Lu [Thu, 9 Mar 2017 17:58:46 +0000 (09:58 -0800)]
X86: Add pseudo prefixes to control encoding

Many x86 instructions have more than one encodings.  Assembler picks
the default one, usually the shortest one.  Although the ".s", ".d8"
and ".d32" suffixes can be used to swap register operands or specify
displacement size, they aren't very flexible.  This patch adds pseudo
prefixes, {xxx}, to control instruction encoding.  The available
pseudo prefixes are {disp8}, {disp32}, {load}, {store}, {vex2}, {vex3}
and {evex}.  Pseudo prefixes are preferred over the ".s", ".d8" and
".d32" suffixes, which are deprecated.

gas/

* config/tc-i386.c (_i386_insn): Add dir_encoding and
vec_encoding.  Remove swap_operand and need_vrex.
(extra_symbol_chars): Add '}'.
(md_begin): Mark '}' with LEX_BEGIN_NAME.  Allow '}' in
mnemonic.
(build_vex_prefix): Don't use 2-byte VEX encoding with
{vex3}.  Check dir_encoding and load.
(parse_insn): Check pseudo prefixes.  Set dir_encoding.
(VEX_check_operands): Likewise.
(match_template): Check dir_encoding and load.
(parse_real_register): Set vec_encoding instead of need_vrex.
(parse_register): Likewise.
* doc/c-i386.texi: Document {disp8}, {disp32}, {load}, {store},
{vex2}, {vex3} and {evex}.  Remove ".s", ".d8" and ".d32"
* testsuite/gas/i386/i386.exp: Run pseudos and x86-64-pseudos.
* testsuite/gas/i386/pseudos.d: New file.
* testsuite/gas/i386/pseudos.s: Likewise.
* testsuite/gas/i386/x86-64-pseudos.d: Likewise.
* testsuite/gas/i386/x86-64-pseudos.s: Likewise.

opcodes/

* i386-gen.c (opcode_modifiers): Replace S with Load.
* i386-opc.h (S): Removed.
(Load): New.
(i386_opcode_modifier): Replace s with load.
* i386-opc.tbl: Add {disp8}, {disp32}, {swap}, {vex2}, {vex3}
and {evex}.  Replace S with Load.
* i386-tbl.h: Regenerated.

7 years agoFix compile time warnings about using possibly uninitialised variables in rs6000...
Sam Thursfield [Thu, 9 Mar 2017 15:58:39 +0000 (15:58 +0000)]
Fix compile time warnings about using possibly uninitialised variables in rs6000-core.c.

* rs6000-core.c (CORE_NEW): Simplify macro when
AIX_CORE_DUMPX_CORE and BFD64 are true to avoid compile warning.

7 years agoUse CpuCET on rdsspq
H.J. Lu [Thu, 9 Mar 2017 15:43:48 +0000 (07:43 -0800)]
Use CpuCET on rdsspq

* i386-opc.tbl: Use CpuCET on rdsspq.
* i386-tbl.h: Regenerated.

7 years agoUpdate -maltivec and -mvsx options to only enable their oldest instructions.
Peter Bergner [Thu, 9 Mar 2017 02:49:03 +0000 (20:49 -0600)]
Update -maltivec and -mvsx options to only enable their oldest instructions.

Currently, the -maltivec and -mvsx GAS options enable *all* of the altivec
and vsx instructions respecitively that have ever been added.  This is in
constract to GCC's -maltivec and -mvsx options, which only enable the oldest
(ie, first) set of altivec and vsx instructions.  This patch changes GAS to
mimic GCC's behaviour with respect to -maltivec and -mvsx and it solves a
problem with trying to assemble the lxvx instruction which is different
between POWER8 and POWER9.

opcodes/
* ppc-dis.c (ppc_opts) <altivec>: Do not use PPC_OPCODE_ALTIVEC2;
<vsx>: Do not use PPC_OPCODE_VSX3;

gas/
* testsuite/gas/ppc/altivec2.d (as): Use the -mpower8 option.
(objdump): Use the -Mpower8 option.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 9 Mar 2017 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAvoid unstable test message in gdb.base/step-over-exit.exp
Pedro Alves [Wed, 8 Mar 2017 22:05:36 +0000 (22:05 +0000)]
Avoid unstable test message in gdb.base/step-over-exit.exp

Currently diffing testrun results shows:

 -PASS: gdb.base/step-over-exit.exp: break *0x7ffff77e18c6 if main == 0
 +PASS: gdb.base/step-over-exit.exp: break *0x2aaaab0988c6 if main == 0

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

* gdb.base/step-over-exit.exp: Add explicit test message.

7 years agoAdd support for the new 'lnia' extended mnemonic.
Peter Bergner [Wed, 8 Mar 2017 20:00:42 +0000 (14:00 -0600)]
Add support for the new 'lnia' extended mnemonic.

opcodes/
* ppc-opc.c (powerpc_opcodes) <lnia>: New extended mnemonic.

gas/
* testsuite/gas/ppc/power9.d <lnia> New test.
* testsuite/gas/ppc/power9.s: Likewise.

7 years agoFix PR18360 - internal error when using "interrupt -a"
Pedro Alves [Wed, 8 Mar 2017 18:54:34 +0000 (18:54 +0000)]
Fix PR18360 - internal error when using "interrupt -a"

If you do "interrupt -a" just while some thread is stepping over a
breakpoint, gdb trips on an internal error.

The test added by this patch manages to trigger this consistently by
spawning a few threads that are constantly tripping on a conditional
breakpoint whose condition always evaluates to false.  With current
gdb, you get:

~~~
 interrupt -a
 .../src/gdb/inline-frame.c:343: internal-error: void skip_inline_frames(ptid_t): Assertion `find_inline_frame_state (ptid) == NULL' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n) FAIL: gdb.threads/interrupt-while-step-over.exp: displaced-stepping=on: iter=0: interrupt -a (GDB internal error)
[...]
 .../src/gdb/inline-frame.c:343: internal-error: void skip_inline_frames(ptid_t): Assertion `find_inline_frame_state (ptid) == NULL' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n) FAIL: gdb.threads/interrupt-while-step-over.exp: displaced-stepping=off: iter=0: wait for stops (GDB internal error)
~~~

The assertion triggers because we're processing a stop for a thread
that had already stopped before and thus had already its inline-frame
state filled in.

Calling handle_inferior_event_1 directly within a
"thread_stop_requested" observer is something that I've wanted to get
rid of before, for being fragile.  Nowadays, infrun is aware of
threads with pending events, so we can use that instead, and let the
normal fetch_inferior_event -> handle_inferior_event code path handle
the forced stop.

The change to finish_step_over is necessary because sometimes a thread
that was told to PTRACE_SINGLESTEP reports back a SIGSTOP instead of a
SIGTRAP (i.e., we tell it to single-step, and then interrupt it quick
enough that on the kernel side the thread dequeues the SIGTOP before
ever having had a chance of executing the instruction to be stepped).
SIGSTOP gets translated to a GDB_SIGNAL_0.  And then finish_step_over
would miss calling clear_step_over_info, and thus miss restarting the
other threads (which in this case of threads with pending events,
means setting their "resumed" flag, so their pending events can be
consumed).

And now that we always restart threads in finish_step_over, we no
longer need to do that in handle_signal_stop.

Tested on x86_64 Fedora 23, native and gdbserver.

gdb/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

PR gdb/18360
* infrun.c (start_step_over, do_target_resume, resume)
(restart_threads): Assert we're not resuming a thread that is
meant to be stopped.
(infrun_thread_stop_requested_callback): Delete.
(infrun_thread_stop_requested): If the thread is internally
stopped, queue a pending stop event and clear the thread's
inline-frame state.
(handle_stop_requested): New function.
(handle_syscall_event, handle_inferior_event_1): Use
handle_stop_requested.
(handle_stop_requested): New function.
(handle_signal_stop): Set the thread's stop_signal here instead of
at caller.
(finish_step_over): Clear step over info unconditionally.
(handle_signal_stop): If the user had interrupted the event
thread, consider the stop a random signal.
(handle_signal_stop) <signal arrived while stepping over
breakpoint>: Don't restart threads here.
(stop_waiting): Don't clear step-over info here.

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

PR gdb/18360
* gdb.threads/interrupt-while-step-over.c: New file.
* gdb.threads/interrupt-while-step-over.exp: New file.

7 years agogdb: Fix ATTRIBUTE_NONNULL usage
Pedro Alves [Wed, 8 Mar 2017 15:52:16 +0000 (15:52 +0000)]
gdb: Fix ATTRIBUTE_NONNULL usage

Should fix the build failure with Clang mentioned at
<https://sourceware.org/bugzilla/show_bug.cgi?id=21206#c2>:

 In file included from ../../binutils-gdb/gdb/dwarf2read.c:72:
 ../../binutils-gdb/gdb/common/gdb_unlinker.h:35:35: error: '__nonnull__' attribute is invalid for the implicit this argument
   unlinker (const char *filename) ATTRIBUTE_NONNULL (1)
   ^                  ~
 ../../binutils-gdb/gdb/../include/ansidecl.h:169:48: note: expanded from macro 'ATTRIBUTE_NONNULL'
 #  define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))

gdb/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

PR 21206
* common/gdb_unlinker.h (unlinker::unlinker): Attribute nonnull
goes to argument 2, not 1.

7 years agoProperly dump NT_GNU_PROPERTY_TYPE_0
H.J. Lu [Wed, 8 Mar 2017 15:44:04 +0000 (07:44 -0800)]
Properly dump NT_GNU_PROPERTY_TYPE_0

Property type and datasz are always 4 bytes for both 32-bit and 64-bit
objects.  Property values for GNU_PROPERTY_X86_ISA_1_USED and
GNU_PROPERTY_X86_ISA_1_NEEDED are 4 bytes for both i386 and x86-64
objects.  We should also check GNU_PROPERTY_LOPROC and
GNU_PROPERTY_LOUSER.

binutils/

PR binutils/21231
* readelf.c (decode_x86_isa): Change argument to unsigned int.
(print_gnu_property_note): Retrieve property type and datasz as
4-byte integer.  Consolidate property datasz check.  Check
GNU_PROPERTY_LOPROC and GNU_PROPERTY_LOUSER.
* testsuite/binutils-all/i386/pr21231a.d: New file.
* testsuite/binutils-all/i386/pr21231a.s: Likewise.
* testsuite/binutils-all/i386/pr21231b.d: Likewise.
* testsuite/binutils-all/i386/pr21231b.s: Likewise.
* testsuite/binutils-all/x86-64/pr21231a.d: Likewise.
* testsuite/binutils-all/x86-64/pr21231a.s: Likewise.
* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
* testsuite/binutils-all/x86-64/pr21231b.s: Likewise.

include/

PR binutils/21231
* elf/common.h (GNU_PROPERTY_LOPROC): New.
(GNU_PROPERTY_HIPROC): Likewise.
(GNU_PROPERTY_LOUSER): Likewise.
(GNU_PROPERTY_HIUSER): Likewise.

7 years agogdb.arch/amd64-entry-value-param*.exp: Make sure test messages are unique
Pedro Alves [Wed, 8 Mar 2017 14:05:41 +0000 (14:05 +0000)]
gdb.arch/amd64-entry-value-param*.exp: Make sure test messages are unique

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

* gdb.arch/amd64-entry-value-param-dwarf5.exp: Use with_test_prefix.
* gdb.arch/amd64-entry-value-param.exp: Use with_test_prefix.

7 years ago"gdb.arch/i386-pkru.exp: probe PKRU support" shouldn't FAIL if not supported
Pedro Alves [Wed, 8 Mar 2017 13:09:45 +0000 (13:09 +0000)]
"gdb.arch/i386-pkru.exp: probe PKRU support" shouldn't FAIL if not supported

Currently I get:

 (gdb) print have_pkru()
 $1 = 0
 (gdb) FAIL: gdb.arch/i386-pkru.exp: probe PKRU support
 UNSUPPORTED: gdb.arch/i386-pkru.exp: processor does not support protection key feature.

Probing suceeded, so that should be a PASS -> UNSUPPORTED.

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

* gdb.arch/i386-pkru.exp (probe PKRU support): Handle detecting
PKRU as not supported as a PASS.

7 years agogdb: Fix a few unstable test names
Pedro Alves [Wed, 8 Mar 2017 12:46:44 +0000 (12:46 +0000)]
gdb: Fix a few unstable test names

Avoid putting unstable path names in test messages, in order to avoid
spurious testrun result diffs like:

 [....]
 -PASS: gdb.base/break-fun-addr.exp: /home/pedro/gdb/test-build1/gdb/testsuite/outputs/gdb.base/break-fun-addr/break-fun-addr1: break *main
 +PASS: gdb.base/break-fun-addr.exp: /home/pedro/gdb/test-build2/gdb/testsuite/outputs/gdb.base/break-fun-addr/break-fun-addr1: break *main
 [....]

gdb/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

* gdb.base/break-fun-addr.exp: Use $testfile1/$testfile2 for test
prefix instead of $binfile1/$binfile2.
* gdb.btrace/gcore.exp: Use "core" instead of unstable path name
in test message.
* gdb.python/py-completion.exp: Use "load python file" as test
messages instead of unstable path names.

7 years agoFix PR 21218: GDB dumps core when escaping newline in multi-line command
Pedro Alves [Wed, 8 Mar 2017 11:41:35 +0000 (11:41 +0000)]
Fix PR 21218: GDB dumps core when escaping newline in multi-line command

With commit 3b12939dfc2399 ("Replace the sync_execution global with a
new enum prompt_state tristate"), GDB started aborting if you try
splitting an input line with a continuation char (backslash) while in
a multi-line command:

 (gdb) commands
 Type commands for breakpoint(s) 1, one per line.
 End with a line saying just "end".
 >print \

 (gdb) 1      # note "(gdb)" incorrectly printed here.
 >end

 readline: readline_callback_read_char() called with no handler!
 $

That abort is actually a symptom of an old problem introduced when
gdb_readline_wrapper was rewritten to use asynchronous readline, back
in 2007.  Note how the "(gdb)" prompt is printed above in the "(gdb)
1" line.  Clearly it shouldn't be there, but it already was before the
commit mentioned above.  Fixing that also fixes the readline abort
shown above.

The problem starts when command_line_input passes a NULL prompt to
gdb_readline_wrapper when it finds previous incomplete input due to a
backslash, trying to fetch more input without printing another ">"
secondary prompt.  That itself should not be a problem, because
passing NULL to gdb_readline_wrapper has the same meaning as passing a
pointer to empty string, since gdb_readline_wrapper exposes the same
interface as 'readline(char *)'.  However, gdb_readline_wrapper passes
the prompt argument directly to display_gdb_prompt, and for the
latter, a NULL prompt argument has a different meaning - it requests
printing the primary prompt.

Before commit 782a7b8ef9c096 (which rewrote gdb_readline_wrapper to
use asynchronous readline), GDB behaved like this:

 (gdb) commands
 [....]
 >print \
 1
 >end
 (gdb)

The above is what this commit restores GDB back to.

New test included.

gdb/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

PR cli/21218
* top.c (gdb_readline_wrapper): Avoid passing NULL to
display_gdb_prompt.
(command_line_input): Add comment.

gdb/testsuite/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>
    Jan Kratochvil  <jan.kratochvil@redhat.com>

PR cli/21218
* gdb.base/commands.exp (backslash_in_multi_line_command_test):
New proc.
(top level): Call it.

7 years ago[gdb, doc] Add missing escape character '@'
Jiong Wang [Wed, 8 Mar 2017 11:14:41 +0000 (11:14 +0000)]
[gdb, doc] Add missing escape character '@'

gdb/doc/
        * gdb.texinfo (Memory Protection Extensions): Add missing escape
character "@".

7 years agoFix PR tui/21216: TUI line breaks regression
Pedro Alves [Wed, 8 Mar 2017 00:14:59 +0000 (00:14 +0000)]
Fix PR tui/21216: TUI line breaks regression

Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") regressed the TUI's command window.
Newlines miss doing a "carriage return", resulting in output like:

~~~~~~~~~~~~~~~~~~
(gdb) helpList of classes of commands:

                                      aliases -- Aliases of other commands
                                                                          breakpoints -- Making program stop at certain points
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Before the commit mentioned above, the default ui_file->to_write
implementation had a hack that would defer into the ui_file->to_fputs
method.  The TUI's ui_file did not implement the to_write method, so
all writes would end up going to the ncurses window via tui_file_fputs
-> tui_puts.

After the commit above, the hack is gone, but the TUI's ui_file still
does not implement the ui_file::write method.  Since tui_file inherits
from stdio_file, writing to a tui_file ends up doing fwrite on the
FILE stream the TUI is "associated" with, via stdio_file::write,
instead of writing to the ncurses window.

The fix is to have tui_file override the "write" method.

New test included.

gdb/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

PR tui/21216
* tui/tui-file.c (tui_file::write): New.
* tui/tui-file.h (tui_file): Override "write".
* tui/tui-io.c (do_tui_putc, update_start_line): New functions,
factored out from ...
(tui_puts): ... here.
(tui_putc): Use them.
(tui_write): New function.
* tui/tui-io.h (tui_write): Declare.

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

PR tui/21216
* gdb.tui/tui-nl-filtered-output.exp: New file.

7 years agoMove TUI completion tests to gdb.tui/completion.exp
Pedro Alves [Wed, 8 Mar 2017 00:14:58 +0000 (00:14 +0000)]
Move TUI completion tests to gdb.tui/completion.exp

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

* gdb.base/completion.exp: Move TUI completion tests to ...
* gdb.tui/completion.exp: ... this new file.

7 years agoMove TUI testcases to new gdb/testsuite/gdb.tui/ directory
Pedro Alves [Wed, 8 Mar 2017 00:14:58 +0000 (00:14 +0000)]
Move TUI testcases to new gdb/testsuite/gdb.tui/ directory

Let's start putting TUI tests in their own dir.

gdb/testsuite/
2017-03-08  Pedro Alves  <palves@redhat.com>

* gdb.base/tui-disasm-long-lines.c,
gdb.base/tui-disasm-long-lines.exp, gdb.base/tui-layout.c,
gdb.base/tui-layout.exp: Move to ...
* gdb.tui/: ... this new directory.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 8 Mar 2017 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoShare gdb/environ.[ch] with gdbserver
Sergio Durigan Junior [Thu, 22 Dec 2016 14:20:00 +0000 (09:20 -0500)]
Share gdb/environ.[ch] with gdbserver

We will need access to the environment functions when we share
fork_inferior between GDB and gdbserver, therefore we simply make the
API on gdb/environ.[ch] available on common/.  No extra adjustments
are needed to make it compile on gdbserver.

gdb/ChangeLog:
2017-03-07  Sergio Durigan Junior  <sergiodj@redhat.com>

* Makefile.in (SFILES): Replace "environ.c" with
"common/environ.c".
(HFILES_NO_SRCDIR): Likewise, for "environ.h".
* environ.c: Include "common-defs.h" instead of "defs.h.  Moved
to...
* common/environ.c: ... here.
* environ.h: Moved to...
* common/environ.h: ... here.

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

* Makefile.in (SFILES): Add "common/environ.c".
(OBJS): Add "common/environ.h".

7 years agoGDB: Fix some null pointer dereferences due to disassembler-options patch.
Peter Bergner [Tue, 7 Mar 2017 15:49:10 +0000 (09:49 -0600)]
GDB: Fix some null pointer dereferences due to disassembler-options patch.

gdb/
* gdbarch.sh (pstring_ptr): New static function.
(gdbarch_disassembler_options): Use it.
(gdbarch_verify_disassembler_options): Print valid_disassembler_options,
not valid_disassembler_option->name.
* gdbarch.c: Regenerate.

7 years agoRemove use of the no longer needed -mminimal-toc option.
Peter Bergner [Tue, 7 Mar 2017 15:39:13 +0000 (09:39 -0600)]
Remove use of the no longer needed -mminimal-toc option.

* config/powerpc/ppc64-linux.mh (MH_CFLAGS): Delete.

7 years agoFix "layout reg" crash
Pedro Alves [Tue, 7 Mar 2017 12:44:58 +0000 (12:44 +0000)]
Fix "layout reg" crash

Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") introduced a problem when using "layout
regs", that leads gdb to crash when issuing:

./gdb ./a.out -ex 'layout regs' -ex start

From the backtrace, it's caused by this 'delete' on tui_restore_gdbout():

 (gdb) bt
 #0  0x00007ffff6b962b2 in free () from /lib64/libc.so.6
 #1  0x000000000059fa47 in tui_restore_gdbout (ui=0x22997b0) at ../../gdb/tui/tui-regs.c:714
 #2  0x0000000000619996 in do_my_cleanups (pmy_chain=pmy_chain@entry=0x1e08320 <cleanup_chain>, old_chain=old_chain@entry=0x235b4b0) at ../../gdb/common/cleanups.c:154
 #3  0x0000000000619b1d in do_cleanups (old_chain=old_chain@entry=0x235b4b0) at ../../gdb/common/cleanups.c:176
 #4  0x000000000059fb0d in tui_register_format (frame=frame@entry=0x22564e0, regnum=regnum@entry=0) at ../../gdb/tui/tui-regs.c:747
 #5  0x000000000059ffeb in tui_get_register (data=0x2434d18, changedp=0x0, regnum=0, frame=0x22564e0) at ../../gdb/tui/tui-regs.c:768
 #6  tui_show_register_group (refresh_values_only=<optimized out>, frame=0x22564e0, group=0x1e09250 <general_group>) at ../../gdb/tui/tui-regs.c:287
 #7  tui_show_registers (group=0x1e09250 <general_group>) at ../../gdb/tui/tui-regs.c:156
 #8  0x00000000005a07cf in tui_check_register_values (frame=frame@entry=0x22564e0) at ../../gdb/tui/tui-regs.c:496
 #9  0x00000000005a3e65 in tui_check_data_values (frame=frame@entry=0x22564e0) at ../../gdb/tui/tui-windata.c:232
 #10 0x000000000059cf65 in tui_refresh_frame_and_register_information (registers_too_p=1) at ../../gdb/tui/tui-hooks.c:156
 #11 0x00000000006d5c05 in generic_observer_notify (args=0x7fffffffdbe0, subject=<optimized out>) at ../../gdb/observer.c:167
 #12 observer_notify_normal_stop (bs=<optimized out>, print_frame=print_frame@entry=1) at ./observer.inc:61
 #13 0x00000000006a6409 in normal_stop () at ../../gdb/infrun.c:8364
 #14 0x00000000006af8f5 in fetch_inferior_event (client_data=<optimized out>) at ../../gdb/infrun.c:3990
 #15 0x000000000066f0fd in gdb_wait_for_event (block=block@entry=0) at ../../gdb/event-loop.c:859
 #16 0x000000000066f237 in gdb_do_one_event () at ../../gdb/event-loop.c:322
 #17 0x000000000066f386 in gdb_do_one_event () at ../../gdb/event-loop.c:353
 #18 0x00000000007411bc in wait_sync_command_done () at ../../gdb/top.c:570
 #19 0x0000000000741426 in maybe_wait_sync_command_done (was_sync=0) at ../../gdb/top.c:587
 #20 execute_command (p=<optimized out>, p@entry=0x7fffffffe43a "start", from_tty=from_tty@entry=1) at ../../gdb/top.c:676
 #21 0x00000000006c2048 in catch_command_errors (command=0x741200 <execute_command(char*, int)>, arg=0x7fffffffe43a "start", from_tty=1) at ../../gdb/main.c:376
 #22 0x00000000006c2b60 in captured_main_1 (context=0x7fffffffde70) at ../../gdb/main.c:1119
 #23 captured_main (data=0x7fffffffde70) at ../../gdb/main.c:1140
 #24 gdb_main (args=args@entry=0x7fffffffdf90) at ../../gdb/main.c:1158
 #25 0x0000000000408cf5 in main (argc=<optimized out>, argv=<optimized out>) at ../../gdb/gdb.c:32
 (gdb) f 1
 #1  0x000000000059fa47 in tui_restore_gdbout (ui=0x22997b0) at ../../gdb/tui/tui-regs.c:714
 714   delete gdb_stdout;

The problem is simply that the commit mentioned above made the ui_file
that gdb_stdout is temporarily set to be a stack-allocated
string_file, while before it used to be a heap-allocated ui_file.  The
fix is simply to remove the now-incorrect delete.

New test included, which exercises enabling all TUI layouts, with and
without execution.  (This particular crash only triggers with
execution.)

gdb/ChangeLog:
2017-03-07  Pedro Alves  <palves@redhat.com>

* tui/tui-regs.c (tui_restore_gdbout): Don't delete gdb_stdout.

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

* gdb.base/tui-layout.c: New file.
* gdb.base/tui-layout.exp: New file.

7 years agoRename gdb.base/tui-layout.exp -> gdb.base/tui-disasm-long-lines.exp
Pedro Alves [Tue, 7 Mar 2017 12:21:00 +0000 (12:21 +0000)]
Rename gdb.base/tui-layout.exp -> gdb.base/tui-disasm-long-lines.exp

To better reflect what the testcase is about, and to make room for a
different testcase.

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

* gdb.base/tui-layout.c: Rename to ...
* gdb.base/tui-disasm-long-lines.c: ... this.
* gdb.base/tui-layout.exp: Rename to ...
* gdb.base/tui-disasm-long-lines.exp: ... this.

7 years agoAdd describing intro comment to gdb.base/tui-layout.exp
Pedro Alves [Tue, 7 Mar 2017 12:11:45 +0000 (12:11 +0000)]
Add describing intro comment to gdb.base/tui-layout.exp

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

* gdb.base/tui-layout.exp: Add intro comment and fix typo.

7 years agoFix whitespace/typos in gdb/ChangeLog and gdb/testsuite/ChangeLog
Pedro Alves [Tue, 7 Mar 2017 13:51:33 +0000 (13:51 +0000)]
Fix whitespace/typos in gdb/ChangeLog and gdb/testsuite/ChangeLog

7 years agoamd64-mpx: initialize BND register before performing inferior calls.
Walfred Tedeschi [Tue, 7 Mar 2017 12:53:41 +0000 (13:53 +0100)]
amd64-mpx: initialize BND register before performing inferior calls.

This patch initializes the BND registers before executing the inferior
call.  BND registers can be in arbitrary values at the moment of the
inferior call.  In case the function being called uses as part of the
parameters BND register, e.g. when passing a pointer as parameter, the
current value of the register will be used.  This can cause boundary
violations that are not due to a real bug or even desired by the user.
In this sense the best to be done is set the BND registers to allow
access to the whole memory, i.e. initialized state, before pushing the
inferior call.

2017-03-07  Walfred Tedeschi <walfred.tedeschi@intel.com>

gdb/ChangeLog:

* i387-tdep.h (i387_reset_bnd_regs): Add function definition.
* i387-tdep.c (i387_reset_bnd_regs): Add function implementation.
* i386-tdep.c (i386_push_dummy_call): Call i387_reset_bnd_regs.
* amd64-tdep (amd64_push_dummy_call): Call i387_reset_bnd_regs.

gdb/testsuite/ChangeLog:

* i386-mpx-call.c: New file.
* i386-mpx-call.exp: New file.

gdb/doc/ChangeLog:

* Memory Protection Extensions: Add information about inferior
calls.

7 years agoCorrect @section placement for makeinfo 4.13
Alan Modra [Tue, 7 Mar 2017 09:09:32 +0000 (19:39 +1030)]
Correct @section placement for makeinfo 4.13

* doc/as.texinfo (2byte, 4byte, 8byte): Correct @section placement.

7 years agoDocument .Nbyte assembler directives
Alan Modra [Tue, 7 Mar 2017 06:16:36 +0000 (16:46 +1030)]
Document .Nbyte assembler directives

* doc/as.texinfo (2byte, 4byte, 8byte): Document.
* doc/c-arm.texi (2byte, 4byte, 8byte): Omit if ELF.

7 years agoFix ld uninitialized read of script ASSERT data structure
Alan Modra [Tue, 7 Mar 2017 01:50:00 +0000 (12:20 +1030)]
Fix ld uninitialized read of script ASSERT data structure

lang_assignment_statement serves both assignments and asserts.

* ldlang.c (open_input_bfds): Check that lang_assignment_statement
is not an assert before referencing defsym.

7 years agoPowerPC64 abort due to dynamic relocs on hidden undefweak
Alan Modra [Tue, 7 Mar 2017 00:34:19 +0000 (11:04 +1030)]
PowerPC64 abort due to dynamic relocs on hidden undefweak

ppc64_elf_relocate_section lacked a check which meant that it emitted
dynamic relocs against a hidden undefweak symbol for which no dynamic
relocs had been allocated.

PR 21224
PR 20519
* elf64-ppc.c (ppc64_elf_relocate_section): Add missing
dyn_relocs check.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 7 Mar 2017 00:00:39 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAdd support for Intel CET instructions
H.J. Lu [Mon, 6 Mar 2017 23:26:37 +0000 (15:26 -0800)]
Add support for Intel CET instructions

Support Intel Control-flow Enforcement Technology (CET) instructions:

https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf

gas/

* config/tc-i386.c (cpu_arch): Add .cet.
* doc/c-i386.texi: Document cet.
* testsuite/gas/i386/cet-intel.d: New file.
* testsuite/gas/i386/cet.d: Likewise.
* testsuite/gas/i386/cet.s: Likewise.
* testsuite/gas/i386/x86-64-cet-intel.d: Likewise.
* testsuite/gas/i386/x86-64-cet.d: Likewise.
* testsuite/gas/i386/x86-64-cet.s: Likewise.
* testsuite/gas/i386/i386.exp: Run Intel CET tests.

opcodes/

* i386-dis.c (REG_0F1E_MOD_3): New enum.
(MOD_0F1E_PREFIX_1): Likewise.
(MOD_0F38F5_PREFIX_2): Likewise.
(MOD_0F38F6_PREFIX_0): Likewise.
(RM_0F1E_MOD_3_REG_7): Likewise.
(PREFIX_MOD_0_0F01_REG_5): Likewise.
(PREFIX_MOD_3_0F01_REG_5_RM_1): Likewise.
(PREFIX_MOD_3_0F01_REG_5_RM_2): Likewise.
(PREFIX_0F1E): Likewise.
(PREFIX_MOD_0_0FAE_REG_5): Likewise.
(PREFIX_0F38F5): Likewise.
(dis386_twobyte): Use PREFIX_0F1E.
(reg_table): Add REG_0F1E_MOD_3.
(prefix_table): Add PREFIX_MOD_0_0F01_REG_5,
PREFIX_MOD_3_0F01_REG_5_RM_1, PREFIX_MOD_3_0F01_REG_5_RM_2,
PREFIX_0F1E, PREFIX_MOD_0_0FAE_REG_5 and PREFIX_0F38F5.  Update
PREFIX_0FAE_REG_6 and PREFIX_0F38F6.
(three_byte_table): Use PREFIX_0F38F5.
(mod_table): Use PREFIX_MOD_0_0F01_REG_5, PREFIX_MOD_0_0FAE_REG_5.
Add MOD_0F1E_PREFIX_1, MOD_0F38F5_PREFIX_2, MOD_0F38F6_PREFIX_0.
(rm_table): Add MOD_0F38F5_PREFIX_2, MOD_0F38F6_PREFIX_0,
RM_0F1E_MOD_3_REG_7.  Use PREFIX_MOD_3_0F01_REG_5_RM_1 and
PREFIX_MOD_3_0F01_REG_5_RM_2.
* i386-gen.c (cpu_flag_init): Add CPU_CET_FLAGS.
(cpu_flags): Add CpuCET.
* i386-opc.h (CpuCET): New enum.
(CpuUnused): Commented out.
(i386_cpu_flags): Add cpucet.
* i386-opc.tbl: Add Intel CET instructions.
* i386-init.h: Regenerated.
* i386-tbl.h: Likewise.

7 years agoUpdate x86-64-mpx-inval-2 test for COFF
H.J. Lu [Mon, 6 Mar 2017 23:00:52 +0000 (15:00 -0800)]
Update x86-64-mpx-inval-2 test for COFF

Assembler displays upper case hex numbers and we need to force a good
alignment to avoid matching NOPs at the end.

* testsuite/gas/i386/x86-64-mpx-inval-2.s: Force a good alignment.
* testsuite/gas/i386/x86-64-mpx-inval-2.l: Expect [0-9A-F]+.

7 years agoRemove const in xtensa-linux-nat.c:fetch_gregs
Simon Marchi [Mon, 6 Mar 2017 21:06:42 +0000 (16:06 -0500)]
Remove const in xtensa-linux-nat.c:fetch_gregs

Fixes:

/home/emaisin/src/binutils-gdb/gdb/xtensa-linux-nat.c: In function 'void fetch_gregs(regcache*, ptid_t, int)':
/home/emaisin/src/binutils-gdb/gdb/xtensa-linux-nat.c:178:23: error: uninitialized const 'regs' [-fpermissive]
   const gdb_gregset_t regs;
                       ^

gdb/ChangeLog:

* xtensa-linux-nat.c (fetch_gregs): Remove const.

7 years agoFix reading numeric values from GNU BUILD NOTEs.
Nick Clifton [Mon, 6 Mar 2017 17:21:04 +0000 (17:21 +0000)]
Fix reading numeric values from GNU BUILD NOTEs.

* readelf.c (print_gnu_build_attribute_name): Read byte values
from the name string as unsigned bytes.
(process_notes_at): Use memcpy to copy an unterminated name
string.

7 years agoDon't decode powerpc insns with invalid fields
Alan Modra [Mon, 6 Mar 2017 09:09:34 +0000 (19:39 +1030)]
Don't decode powerpc insns with invalid fields

Certain insns have restrictions on fields.  For example, the insn
mentioned in the PR, lqarx, must specify an even general purpose
register as its destination and that register cannot appear in
either of the base or index reg fields.  This holds even when the RA0
field is 0 (meaning a zero rather than r0).

PR 21124
* ppc-opc.c (extract_esync, extract_ls, extract_ral, extract_ram)
(extract_raq, extract_ras, extract_rbx): New functions.
(powerpc_operands): Use opposite corresponding insert function.
(Q_MASK): Define.
(powerpc_opcodes): Apply Q_MASK to all quad insns with even
register restriction.

7 years agodw2gencfi.c DWARF2_FDE_RELOC_SIZE
Alan Modra [Sun, 5 Mar 2017 12:55:16 +0000 (23:25 +1030)]
dw2gencfi.c DWARF2_FDE_RELOC_SIZE

Add asserts that reloc size matches encoding size, and tidy.

* dw2gencfi.c (encoding_size): Return unsigned int.
(emit_expr_encoded): Assert size matches reloc bitsize.
(output_fde): Use unsigned for offset_size and addr_size.  Set
addr_size earlier and use in place of constant 4 and uses of
DWARF2_FDE_RELOC_SIZE.  Assert it matches reloc bitsize.

7 years agogas/dw2gencfi.c formatting
Alan Modra [Sun, 5 Mar 2017 12:25:29 +0000 (22:55 +1030)]
gas/dw2gencfi.c formatting

* dw2gencfi.c: Wrap overlong lines.  Add parens for emacs
auto reformat.  Formatting and whitespace fixes.

7 years agobinutils: Fix warning on platforms that don't have asprintf
Sam Thursfield [Fri, 3 Mar 2017 14:14:35 +0000 (14:14 +0000)]
binutils: Fix warning on platforms that don't have asprintf

* configure.ac (AC_CHECK_DECLS): Add asprintf.
* config.in: Regenerate.
* configure: Regenerate.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 6 Mar 2017 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agogas: Emit name, comp_dir and producer strings in .debug_str.
Mark Wielaard [Sun, 5 Mar 2017 22:37:54 +0000 (23:37 +0100)]
gas: Emit name, comp_dir and producer strings in .debug_str.

Putting the name, comp_dir and producer strings in the .debug_str section
makes it possible to share them across CUs. This saves a small amount of
space (about ~20K on a glibc libc.so.6 build with debuginfo). And makes
it easier for tools like rpm debugedit to adjust the source paths when
generating separate debuginfo files.

gas/
       * dwarf2dbg.c (out_debug_abbrev): Use DW_FORM_strp instead of
       DW_FORM_string for DW_AT_name, DW_AT_comp_dir and DW_AT_producer.
       (out_debug_info): Accept symbols to name, comp_dir and producer
       in the .debug_str section and emit those offsets not full strings.
       (out_debug_str): New function that outputs the strings for name,
       comp_dir and producer in .debug_str and generates symbols to
       those strings.
       (out_debug_line): Create a .debug_str section if necessary and
       call out_debug_str before calling out_debug_info.
       * testsuite/gas/aarch64/dwarf.d: Add extra section symbol to
       expected output.

7 years agoAlign eh_frame FDEs according to their encoding
Alan Modra [Sun, 5 Mar 2017 04:19:54 +0000 (14:49 +1030)]
Align eh_frame FDEs according to their encoding

bfd/
* elf-bfd.h (struct eh_cie_fde): Add u.cie.per_encoding_aligned8.
* elf-eh-frame.c (size_of_output_cie_fde): Don't align here.
(next_cie_fde_offset): New function.
(_bfd_elf_parse_eh_frame): Set u.cie.per_encoding_aligned8.
(_bfd_elf_discard_section_eh_frame): Align zero terminator to
four bytes.  Align CIEs to four or eight bytes depending on
per_encoding_aligned8.  Align FDEs according to their encoding.
Pad last FDE to output section alignment.
(_bfd_elf_write_section_eh_frame): Adjust to suit.  Remove
assertion.
* elf64-ppc.c (glink_eh_frame_cie): Delete padding.
(ppc64_elf_size_stubs): Pad glink eh_frame as per elf-eh-frame.c.
(ppc64_elf_finish_dynamic_sections): Adjust to suit.
ld/
* testsuite/ld-elf/eh3.d: Adjust for eh_frame alignment change.
* testsuite/ld-elf/eh6.d: Likewise.
* testsuite/ld-alpha/tlsbin.dd: Likewise.
* testsuite/ld-alpha/tlsbin.td: Likewise.
* testsuite/ld-alpha/tlsbinr.dd: Likewise.
* testsuite/ld-alpha/tlspic.dd: Likewise.
* testsuite/ld-alpha/tlspic.rd: Likewise.
* testsuite/ld-alpha/tlspic.sd: Likewise.
* testsuite/ld-alpha/tlspic.td: Likewise.
* testsuite/ld-mips-elf/eh-frame1-n64.d: Likewise.
* testsuite/ld-mips-elf/eh-frame2-n64.d: Likewise.
* testsuite/ld-mips-elf/eh-frame3.d: Likewise.
* testsuite/ld-x86-64/pr20830a.d: Likewise.
* testsuite/ld-x86-64/pr21038a.d: Likewise.
* testsuite/ld-x86-64/pr21038b.d: Likewise.
* testsuite/ld-x86-64/pr21038c.d: Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 5 Mar 2017 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 4 Mar 2017 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFix umulh and smulh bugs. Fix bugs in last week's sumov.s testsuite.
Jim Wilson [Fri, 3 Mar 2017 21:10:45 +0000 (13:10 -0800)]
Fix umulh and smulh bugs.  Fix bugs in last week's sumov.s testsuite.

sim/aarch64/
* simulator.c (mul64hi): Shift carry left by 32.
(smulh): Change signum to negate.  If negate, invert result, and add
carry bit if low part of multiply result is zero.

sim/testsuite/sim/aarch64/
* sumov.s: Correct compare test values.
* sumulh.s: New.

7 years agoUse range-based for loop in remote_add_target_side_commands
Simon Marchi [Fri, 3 Mar 2017 17:58:24 +0000 (12:58 -0500)]
Use range-based for loop in remote_add_target_side_commands

gdb/ChangeLog:

* remote.c (remote_add_target_side_commands): Use range-based
for loop.

7 years agoFetch lazy value before calling val_print
Yao Qi [Fri, 3 Mar 2017 17:16:19 +0000 (17:16 +0000)]
Fetch lazy value before calling val_print

As reported in PR 21165,

(gdb) info locals^M
gv = /home/yao/SourceCode/gnu/gdb/git/gdb/value.c:372: internal-error: int value_bits_any_optimized_out(const value*, int, int): Assertion `!value->lazy' failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
Quit this debugging session? (y or n) FAIL: gdb.ada/info_locals_renaming.exp: info locals (GDB internal error)
Resyncing due to internal error.

This internal error is caused by e8b24d9 (Remove parameter valaddr from
la_val_print).  Commit e8b24d9 removes some calls to
value_contents_for_printing, but value_fetch_lazy is not called, so the
internal error above is triggered.  This patch adds value_fetch_lazy
call before val_print.

gdb:

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

PR gdb/21165
* ada-valprint.c (ada_val_print_ref): Call value_fetch_lazy if
value is lazy.
* valprint.c (common_val_print): Likewise.

7 years agoMake the linker fail if asked to create more than 1^16 ordinal values for PE targets.
Nick Clifton [Fri, 3 Mar 2017 11:35:03 +0000 (11:35 +0000)]
Make the linker fail if asked to create more than 1^16 ordinal values for PE targets.

PR 12969
* pe-dll.c (generate_edata): Fail if the input file(s) require too
many ordinals.

7 years agoFix thinko in previous changelog entry.
Nick Clifton [Fri, 3 Mar 2017 10:22:16 +0000 (10:22 +0000)]
Fix thinko in previous changelog entry.

PR ld/21212
* elf.c (rewrite_elf_program_header): Do not issue a warning for
empty segments which have a zero filesz, but a non-zero memsz.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 3 Mar 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoSupport merging build notes in sections without the SHF_GNU_BUILD_NOTE flag set.
Nick Clifton [Thu, 2 Mar 2017 17:10:20 +0000 (17:10 +0000)]
Support merging build notes in sections without the SHF_GNU_BUILD_NOTE flag set.

* objcopy.c (is_merged_note_section): Support build note sections
without the SHF_GNU_BUILD_NOTE section flag set.

7 years agoDisable warning message about a program header with no associated sections when that...
Nick Clifton [Thu, 2 Mar 2017 14:47:29 +0000 (14:47 +0000)]
Disable warning message about a program header with no associated sections when that header's file size is non-zero.

PR ld/21212
* elf.c (rewrite_elf_program_header): Do not issue a warning for
empty segments which have a non-zero filesz.

7 years agoFix snafu parsing GNU_BUILD_NOTEs on ARM and AArch64 architectures.
Nick Clifton [Thu, 2 Mar 2017 10:52:51 +0000 (10:52 +0000)]
Fix snafu parsing GNU_BUILD_NOTEs on ARM and AArch64 architectures.

* readelf.c (print_gnu_build_attribute_description): Use global
symbols for OPEN attributes if at all possible.

7 years agoNew debug_displays_assert
Jan Kratochvil [Thu, 2 Mar 2017 09:58:19 +0000 (10:58 +0100)]
New debug_displays_assert

binutils/
2017-03-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf.c (debug_displays_assert): New static assertion.

7 years agoFix dwarf_section_display_enum regression by DWARF-5
Jan Kratochvil [Thu, 2 Mar 2017 09:06:00 +0000 (10:06 +0100)]
Fix dwarf_section_display_enum regression by DWARF-5

binutils/
2017-03-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf.h (enum dwarf_section_display_enum): Add loclists and rnglists.

7 years agoGAS: Fix bogus "attempt to move .org backwards" relaxation errors
Maciej W. Rozycki [Thu, 2 Mar 2017 01:24:15 +0000 (01:24 +0000)]
GAS: Fix bogus "attempt to move .org backwards" relaxation errors

Fix a commit 6afe8e98a664 ("internal error for backwards .org"),
<https://www.sourceware.org/ml/binutils/2008-06/msg00212.html>,
GAS regression that caused legitimate code to fail assembly with an
"attempt to move .org backwards" error.

For example with the `mips-linux' target we get:

$ cat org.s
.set mips16
la $2, foo
.org 0x1000
.align 2
foo:
.half 0
$ as -o org.o org.s
org.s: Assembler messages:
org.s:3: Error: attempt to move .org backwards
$

where the location pointer is obviously not moved backwards with `.org'.

The cause is positive `stretch' in relaxation due to a PC-relative ADDIU
instruction (produced from the LA macro used) getting expanded from 2 to
4 bytes as `foo' is noticed to be out of range for the short encoding.
This in turn triggers logic in `relax_segment' which concludes in the
processing of an `rs_org' frag produced that the location pointer is
moved backwards while in fact only the amount to space forward to the
location requested has shrunk, resulting in a negative growth of the
frag.

Correct the bad logic then and instead verify that the fixed part of an
`rs_org' frag has not overrun the location requested, as per the comment
already included with the error message:

/* Growth may be negative, but variable part of frag
   cannot have fewer than 0 chars.  That is, we can't
   .org backwards.  */

which accurately describes the regression scenario.  Move the comment
ahead the conditional noted, for clarity.

Add generic and MIPS test cases for the `.org' pseudo-op, including the
test case discussed though not integrated with the offending commit in
particular, adjusted to work across all targets.

gas/
* write.c (relax_segment) <rs_org>: Only bail out if the fixed
part of the frag has overrun the location requested.

* testsuite/gas/all/org-1.d: New test.
* testsuite/gas/all/org-2.d: New test.
* testsuite/gas/all/org-3.d: New test.
* testsuite/gas/all/org-4.d: New test.
* testsuite/gas/all/org-5.d: New test.
* testsuite/gas/all/org-6.d: New test.
* testsuite/gas/all/org-1.l: New stderr output.
* testsuite/gas/all/org-2.l: New stderr output.
* testsuite/gas/all/org-3.l: New stderr output.
* testsuite/gas/all/org-1.s: New test source.
* testsuite/gas/all/org-2.s: New test source.
* testsuite/gas/all/org-3.s: New test source.
* testsuite/gas/all/org-4.s: New test source.
* testsuite/gas/all/org-5.s: New test source.
* testsuite/gas/all/org-6.s: New test source.
* testsuite/gas/all/gas.exp: Run the new tests.

* testsuite/gas/mips/org-1.d: New test.
* testsuite/gas/mips/org-2.d: New test.
* testsuite/gas/mips/org-3.d: New test.
* testsuite/gas/mips/org-4.d: New test.
* testsuite/gas/mips/org-5.d: New test.
* testsuite/gas/mips/org-6.d: New test.
* testsuite/gas/mips/org-7.d: New test.
* testsuite/gas/mips/org-8.d: New test.
* testsuite/gas/mips/org-9.d: New test.
* testsuite/gas/mips/org-10.d: New test.
* testsuite/gas/mips/org-11.d: New test.
* testsuite/gas/mips/org-12.d: New test.
* testsuite/gas/mips/org-1.l: New stderr output.
* testsuite/gas/mips/org-4.l: New stderr output.
* testsuite/gas/mips/org-5.l: New stderr output.
* testsuite/gas/mips/org-6.l: New stderr output.
* testsuite/gas/mips/org-10.l: New stderr output.
* testsuite/gas/mips/org-1.s: New test source.
* testsuite/gas/mips/org-2.s: New test source.
* testsuite/gas/mips/org-3.s: New test source.
* testsuite/gas/mips/org-4.s: New test source.
* testsuite/gas/mips/org-5.s: New test source.
* testsuite/gas/mips/org-6.s: New test source.
* testsuite/gas/mips/org-7.s: New test source.
* testsuite/gas/mips/org-8.s: New test source.
* testsuite/gas/mips/org-9.s: New test source.
* testsuite/gas/mips/org-10.s: New test source.
* testsuite/gas/mips/org-11.s: New test source.
* testsuite/gas/mips/org-12.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

7 years agoPowerPC VLE typo fix
Alan Modra [Wed, 1 Mar 2017 23:54:14 +0000 (10:24 +1030)]
PowerPC VLE typo fix

* elf32-ppc.c (ppc_elf_vle_split16): Correct insn mask typo.

7 years agoAvoid gcc-7 warning killing ld testcases
Alan Modra [Wed, 1 Mar 2017 23:53:42 +0000 (10:23 +1030)]
Avoid gcc-7 warning killing ld testcases

* testsuite/ld-elf/shared.exp: Pass -ansi when compiling new.cc
and dl3.cc.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 2 Mar 2017 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoSync libiberty sources with GCC mainline.
Nick Clifton [Wed, 1 Mar 2017 15:09:29 +0000 (15:09 +0000)]
Sync libiberty sources with GCC mainline.

Brings in:
  2017-01-18  Markus Trippelsdorf  <markus@trippelsdorf.de>

PR PR c++/70182
* cp-demangle.c (d_unqualified_name): Handle "on" for
operator names.
* testsuite/demangle-expected: Add tests.

 2017-01-18  Markus Trippelsdorf  <markus@trippelsdorf.de>

PR c++/77489
* cp-demangle.c (d_discriminator): Handle discriminator >= 10.
* testsuite/demangle-expected: Add tests for discriminator.

 2016-12-13  Jakub Jelinek  <jakub@redhat.com>

PR c++/78761
* cp-demangle.c (cplus_demangle_type): Demangle Dc as decltype(auto).
* testsuite/demangle-expected: Add test for decltype(auto).

7 years ago[AArch64] Document +rcpc weak release consistency extension
Szabolcs Nagy [Wed, 1 Mar 2017 14:51:13 +0000 (14:51 +0000)]
[AArch64] Document +rcpc weak release consistency extension

gas/
* doc/c-aarch64.texi (AArch64 Extensions): Document rcpc.

7 years agoAdd support for displaying and merging GNU_BUILD_NOTEs.
Nick Clifton [Wed, 1 Mar 2017 11:09:46 +0000 (11:09 +0000)]
Add support for displaying and merging GNU_BUILD_NOTEs.

include * elf/common.h (SHF_GNU_BUILD_NOTE): Define.
(NT_GNU_PROPERTY_TYPE_0): Define.
(NT_GNU_BUILD_ATTRIBUTE_OPEN): Define.
(NT_GNU_BUILD_ATTRIBUTE_FUN): Define.
(GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC): Define.
(GNU_BUILD_ATTRIBUTE_TYPE_STRING): Define.
(GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE): Define.
(GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE): Define.
(GNU_BUILD_ATTRIBUTE_VERSION): Define.
(GNU_BUILD_ATTRIBUTE_STACK_PROT): Define.
(GNU_BUILD_ATTRIBUTE_RELRO): Define.
(GNU_BUILD_ATTRIBUTE_STACK_SIZE): Define.
(GNU_BUILD_ATTRIBUTE_TOOL): Define.
(GNU_BUILD_ATTRIBUTE_ABI): Define.
(GNU_BUILD_ATTRIBUTE_PIC): Define.
(NOTE_GNU_PROPERTY_SECTION_NAME): Define.
(GNU_BUILD_ATTRS_SECTION_NAME): Define.
(GNU_PROPERTY_STACK_SIZE): Define.
(GNU_PROPERTY_NO_COPY_ON_PROTECTED): Define.
(GNU_PROPERTY_X86_ISA_1_USED): Define.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Define.
(GNU_PROPERTY_X86_ISA_1_486): Define.
(GNU_PROPERTY_X86_ISA_1_586): Define.
(GNU_PROPERTY_X86_ISA_1_686): Define.
(GNU_PROPERTY_X86_ISA_1_SSE): Define.
(GNU_PROPERTY_X86_ISA_1_SSE2): Define.
(GNU_PROPERTY_X86_ISA_1_SSE3): Define.
(GNU_PROPERTY_X86_ISA_1_SSSE3): Define.
(GNU_PROPERTY_X86_ISA_1_SSE4_1): Define.
(GNU_PROPERTY_X86_ISA_1_SSE4_2): Define.
(GNU_PROPERTY_X86_ISA_1_AVX): Define.
(GNU_PROPERTY_X86_ISA_1_AVX2): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512F): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512CD): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512ER): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512PF): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512VL): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512DQ): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512BW): Define.

binutils* readelf.c (get_note_type): Add support for GNU_BUILD_NOTEs.
(get_gnu_elf_note_type): Add support for GNU_PROPERTY_NOTEs.
(decode_x86_isa): New function.
(print_gnu_property_note): New function.
(print_gnu_note): Handle GNU_PROPERTY_NOTEs.
(print_gnu_build_attribute_description): New function.
(print_gnu_build_attribute_name): New function.
(process_note): Add support for GNU_BUILD_NOTEs.
* objcopy.c (--merge-notes): New command line option.
(copy_options): Add merge-notes.
(copy_usage): Likewise.
(is_merge_note_section): New function.
(merge_gnu_build_notes): New function.
(copy_object): Merge note sections if asked to do so.
(skip_section): Add skip_copy parameter.  Add support for skipping
merged note sections.
(copy_relocations_in_section): Update call to skip_section.
(copy_section): Likewise.
(copy_main): Add support for merge-notes option.
* doc/binutils.texi: Document the new option to objcopy.
* NEWS: Mention the new feature.
* testsuite/binutils-all/note-2-32.d: New test.  Checks note
merging on 32-bit targets.
* testsuite/binutils-all/note-2-32.s: New test source file.
* testsuite/binutils-all/note-2-64.d: New test.  Like note-2-32.d
but for 64-bit targets.
* testsuite/binutils-all/note-2-64.s: New test source file.
* testsuite/binutils-all/objcopy.exp: Run the new test.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 1 Mar 2017 00:01:00 +0000 (00:01 +0000)]
Automatic date update in version.in

7 years agoGDB: Add support for the new set/show disassembler-options commands.
Peter Bergner [Tue, 28 Feb 2017 18:32:07 +0000 (12:32 -0600)]
GDB: Add support for the new set/show disassembler-options commands.

This commit adds support to GDB so that it can modify the disassembler-options
value that is passed to the disassembler, similar to objdump's -M option.
Currently, the only supported targets are ARM, PowerPC and S/390, but
adding support for a new target(s) is not difficult.

include/
* dis-asm.h (disasm_options_t): New typedef.
(parse_arm_disassembler_option): Remove prototype.
(set_arm_regname_option): Likewise.
(get_arm_regnames): Likewise.
(get_arm_regname_num_options): Likewise.
(disassemble_init_s390): New prototype.
(disassembler_options_powerpc): Likewise.
(disassembler_options_arm): Likewise.
(disassembler_options_s390): Likewise.
(remove_whitespace_and_extra_commas): Likewise.
(disassembler_options_cmp): Likewise.
(next_disassembler_option): New inline function.
(FOR_EACH_DISASSEMBLER_OPTION): New macro.

opcodes/
* disassemble.c Include "safe-ctype.h".
(disassemble_init_for_target): Handle s390 init.
(remove_whitespace_and_extra_commas): New function.
(disassembler_options_cmp): Likewise.
* arm-dis.c: Include "libiberty.h".
(NUM_ELEM): Delete.
(regnames): Use long disassembler style names.
Add force-thumb and no-force-thumb options.
(NUM_ARM_REGNAMES): Rename from this...
(NUM_ARM_OPTIONS): ...to this.  Use ARRAY_SIZE.
(get_arm_regname_num_options): Delete.
(set_arm_regname_option): Likewise.
(get_arm_regnames): Likewise.
(parse_disassembler_options): Likewise.
(parse_arm_disassembler_option): Rename from this...
(parse_arm_disassembler_options): ...to this.  Make static.
Use new FOR_EACH_DISASSEMBLER_OPTION macro to scan over options.
(print_insn): Use parse_arm_disassembler_options.
(disassembler_options_arm): New function.
(print_arm_disassembler_options): Handle updated regnames.
* ppc-dis.c: Include "libiberty.h".
(ppc_opts): Add "32" and "64" entries.
(ppc_parse_cpu): Use ARRAY_SIZE and disassembler_options_cmp.
(powerpc_init_dialect): Add break to switch statement.
Use new FOR_EACH_DISASSEMBLER_OPTION macro.
(disassembler_options_powerpc): New function.
(print_ppc_disassembler_options): Use ARRAY_SIZE.
Remove printing of "32" and "64".
* s390-dis.c: Include "libiberty.h".
(init_flag): Remove unneeded variable.
(struct s390_options_t): New structure type.
(options): New structure.
(init_disasm): Rename from this...
(disassemble_init_s390): ...to this.  Add initializations for
current_arch_mask and option_use_insn_len_bits_p.  Remove init_flag.
(print_insn_s390): Delete call to init_disasm.
(disassembler_options_s390): New function.
(print_s390_disassembler_options): Print using information from
struct 'options'.
* po/opcodes.pot: Regenerate.

binutils/
* objdump.c (main): Use remove_whitespace_and_extra_commas.

gdb/
* NEWS: Mention new set/show disassembler-options commands.
* doc/gdb.texinfo: Document new set/show disassembler-options commands.
* disasm.c: Include "arch-utils.h", "gdbcmd.h" and "safe-ctype.h".
(prospective_options): New static variable.
(gdb_disassembler::gdb_disassembler): Initialize
m_di.disassembler_options.
(gdb_buffered_insn_length_init_dis): Initilize di->disassembler_options.
(get_disassembler_options): New function.
(set_disassembler_options): Likewise.
(set_disassembler_options_sfunc): Likewise.
(show_disassembler_options_sfunc): Likewise.
(disassembler_options_completer): Likewise.
(_initialize_disasm): Likewise.
* disasm.h (get_disassembler_options): New prototype.
(set_disassembler_options): Likewise.
* gdbarch.sh (gdbarch_disassembler_options): New variable.
(gdbarch_verify_disassembler_options): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Likewise.
* arm-tdep.c (num_disassembly_options): Delete.
(set_disassembly_style): Likewise.
(arm_disassembler_options): New static variable.
(set_disassembly_style_sfunc): Convert short style name into long
option name.  Call set_disassembler_options.
(show_disassembly_style_sfunc): New function.
(arm_gdbarch_init): Call set_gdbarch_disassembler_options and
set_gdbarch_verify_disassembler_options.
(_initialize_arm_tdep): Delete regnames variable and update callers.
(arm_disassembler_options): Initialize.
(disasm_options): New variable.
(num_disassembly_options): Rename from this...
(num_disassembly_styles): ...to this.  Compute by scanning through
disasm_options.
(valid_disassembly_styles): Initialize using disasm_options.
Remove calls to parse_arm_disassembler_option, get_arm_regnames and
set_arm_regname_option.
Pass show_disassembly_style_sfunc to the "disassembler" setshow command.
* rs6000-tdep.c (powerpc_disassembler_options): New static variable.
(rs6000_gdbarch_init): Call set_gdbarch_disassembler_options and
set_gdbarch_verify_disassembler_options.
* s390-tdep.c (s390_disassembler_options): New static variable.
(s390_gdbarch_init):all set_gdbarch_disassembler_options and
set_gdbarch_verify_disassembler_options.

gdb/testsuite/
* gdb.arch/powerpc-power.exp: Delete test.
* gdb.arch/powerpc-power.s: Likewise.
* gdb.disasm/disassembler-options.exp: New test.
* gdb.arch/powerpc-altivec.exp: Likewise.
* gdb.arch/powerpc-altivec.s: Likewise.
* gdb.arch/powerpc-altivec2.exp: Likewise.
* gdb.arch/powerpc-altivec2.s: Likewise.
* gdb.arch/powerpc-altivec3.exp: Likewise.
* gdb.arch/powerpc-altivec3.s: Likewise.
* gdb.arch/powerpc-power7.exp: Likewise.
* gdb.arch/powerpc-power7.s: Likewise.
* gdb.arch/powerpc-power8.exp: Likewise.
* gdb.arch/powerpc-power8.s: Likewise.
* gdb.arch/powerpc-power9.exp: Likewise.
* gdb.arch/powerpc-power9.s: Likewise.
* gdb.arch/powerpc-vsx.exp: Likewise.
* gdb.arch/powerpc-vsx.s: Likewise.
* gdb.arch/powerpc-vsx2.exp: Likewise.
* gdb.arch/powerpc-vsx2.s: Likewise.
* gdb.arch/powerpc-vsx3.exp: Likewise.
* gdb.arch/powerpc-vsx3.s: Likewise.
* gdb.arch/arm-disassembler-options.exp: Likewise.
* gdb.arch/powerpc-disassembler-options.exp: Likewise.
* gdb.arch/s390-disassembler-options.exp: Likewise.

7 years agoRevert "Add symbol called __nm_<name> to exported symbols created by dlltool."
Nick Clifton [Tue, 28 Feb 2017 16:54:16 +0000 (16:54 +0000)]
Revert "Add symbol called __nm_<name> to exported symbols created by dlltool."

This reverts commit 47612ae91c5f2de8960df1d96adf225d2455123f.

7 years agoPowerPC addpcis fix again
Alan Modra [Tue, 28 Feb 2017 13:12:29 +0000 (23:42 +1030)]
PowerPC addpcis fix again

In the last patch I said "The patch also fixes overflow checking".
In fact, there wasn't anything wrong with the previous code.  So,
revert that change.  The new checks are OK too, so this is just a
tidy.

* elf64-ppc.c (ppc64_elf_ha_reloc): Revert last change.
(ppc64_elf_relocate_section): Likewise.

7 years agox86: fix handling of 64-bit operand size VPCMPESTR{I,M}
Jan Beulich [Tue, 28 Feb 2017 09:53:35 +0000 (10:53 +0100)]
x86: fix handling of 64-bit operand size VPCMPESTR{I,M}

Just like REX.W affects operand size of the implicit rAX/rDX inputs to
PCMPESTR{I,M}, VEX.W does for VPCMPESTR{I,M}. Allow Q or L suffixes on
the instructions.

Similarly the disassembler needs to be adjusted to no longer require
VEX.W to be zero for the instructions to be valid, and to emit proper
suffixes.

Note, however, that this doesn't address the problem of there being no
way to control (at least) {,E}VEX.W for 32- or 16-bit code. Nor does it
address the problem of the many WIG instructions not getting properly
disassembled when VEX.W=1.

7 years agoNios2 dynobj handling fixes
Alan Modra [Tue, 28 Feb 2017 00:08:51 +0000 (10:38 +1030)]
Nios2 dynobj handling fixes

A number of places in elf32-nios.c created dynamic sections but didn't
set the hash table dynobj.  That meant we could have duplicate dynamic
sections connected to a number of bfds, so size_dynamic_sections
didn't properly discard or allocate contents.

Also, the entire set of dynamic sections was created in check_relocs
on seeing GOT relocs, when only .got related sections are needed,
probably done to hide segfaults later in finish_dynamic_sections.

The patch fixes these issues and makes the assembler emit errors when
nios2 lacks the necessary pc-relative relocs for subtraction
expressions, rather than silently generating bad code.
eg. ld-elf/merge.  I've also tidied uses of elf32_nios2_hash_table and
elf_hash_table.

bfd/
PR 20995
* elf32-nios2.c (nios2_elf32_relocate_section): Use htab
rather than elf32_nios2_hash_table or elf_hash_table.
(create_got_section): Likewise.
(nios2_elf32_finish_dynamic_symbol): Likewise.
(nios2_elf32_adjust_dynamic_symbol): Likewise.
(nios2_elf32_size_dynamic_sections): Likewise.
(nios2_elf32_check_relocs): Delete dynobj, sgot, and srelgot
vars.  Use htab equivalents directly instead.  Don't create
all dynamic sections on needing just the GOT.  Use a goto
rather than a fall-through with reloc test.  Ensure
htab->dynobj is set when making dynamic sreloc section.
(nios2_elf32_finish_dynamic_sections): Delete dynobj, use htab
equivalent directly instead.  Don't segfault on looking for
.dynamic when dynamic sections have not been created.  Don't
segfault on .got.plt being discarded.
(nios2_elf32_size_dynamic_sections): Delete plt and got vars.
Don't set "relocs" on .rela.plt.  Do handle .sbss.  Delete
fixme and another not so relevant comment.
(nios2_elf_add_symbol_hook): Delete dynobj var.  If not
already set, set hash table dynobj on creating .sbss.
gas/
* config/tc-nios2.h (TC_FORCE_RELOCATION_SUB_LOCAL): Define.
ld/
* testsuite/ld-elf/merge.d: xfail for nios.

7 years agoPowerPC addpcis fix
Alan Modra [Mon, 27 Feb 2017 22:02:36 +0000 (08:32 +1030)]
PowerPC addpcis fix

This came up because I was looking at ld/tmpdir/addpcis.o and noticed
the odd addends on REL16DX_HA.  They ought to both be -4.  The error
crept in due REL16DX_HA howto being pc-relative (as indeed it should
be), and code at gas/write.c:1001 after this comment
      /* Make it pc-relative.  If the back-end code has not
 selected a pc-relative reloc, cancel the adjustment
 we do later on all pc-relative relocs.  */
*not* cancelling the pc-relative adjustment.  So I've made a dummy
non-relative split reloc so that the generic code handles this, rather
than attempting to add hacks later in md_apply_fix which would not be
very robust.  Having the new internal reloc also makes it easy to
support

 addpcis rx,sym@ha

as an equivalent to

 addpcis rx,(sym-0f)@ha
0:

The patch also fixes overflow checking, which must test whether the
addi will overflow too since @l relocs don't have any overflow check.

Lastly, since I was poking at md_apply_fix, I arranged to have the
generic gas/write.c code emit errors for subtraction expressions where
we lack reloc support.

include/
* elf/ppc64.h (R_PPC64_16DX_HA): New.  Expand fake reloc comment.
* elf/ppc.h (R_PPC_16DX_HA): Likewise.
bfd/
* reloc.c (BFD_RELOC_PPC_16DX_HA): New.
* elf64-ppc.c (ppc64_elf_howto_raw <R_PPC64_16DX_HA>): New howto.
(ppc64_elf_reloc_type_lookup): Translate new bfd reloc.
(ppc64_elf_ha_reloc): Correct overflow test on REL16DX_HA.
(ppc64_elf_relocate_section): Likewise.
* elf32-ppc.c (ppc_elf_howto_raw <R_PPC_16DX_HA>): New howto.
(ppc_elf_reloc_type_lookup): Translate new bfd reloc.
(ppc_elf_check_relocs): Handle R_PPC_16DX_HA to pacify gcc.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
gas/
* config/tc-ppc.c (md_assemble): Use BFD_RELOC_PPC_16DX_HA for addpcis.
(md_apply_fix): Remove fx_subsy check.  Move code converting to
pcrel reloc earlier and handle BFD_RELOC_PPC_16DX_HA.  Remove code
emiiting errors on seeing fx_pcrel set on unexpected relocs, as
that is done now by the generic code via..
* config/tc-ppc.h (TC_FORCE_RELOCATION_SUB_LOCAL): ..this. Define.
(TC_VALIDATE_FIX_SUB): Define.
ld/
* testsuite/ld-powerpc/addpcis.d: Define ext1 and ext2 at
limits of addpcis range.

7 years agoDon't make dynamic .data.rel.ro SEC_READONLY
Alan Modra [Mon, 27 Feb 2017 21:36:02 +0000 (08:06 +1030)]
Don't make dynamic .data.rel.ro SEC_READONLY

I'd made this dynamic section read-only so a flag test distinguished
it from .dynbss, but like any other .data.rel.ro section it really
should be marked read-write.  (It is read-only after relocation, not
before.)  When using the standard linker scripts this usually doesn't
matter since the output section is among other read-write sections and
not page aligned.  However, it might matter in the extraordinary case
of the dynamic section being the only .data.rel.ro section with the
output section just happening to be page aligned and a multiple of a
page in size.  In that case the output section would be read-only, and
live it its own read-only PT_LOAD segment, which is incorrect.

* elflink.c (_bfd_elf_create_dynamic_sections): Don't make
dynamic .data.rel.ro read-only.
* elf32-arm.c (elf32_arm_finish_dynamic_symbol): Compare section
rather than section flags when deciding where copy reloc goes.
* elf32-cris.c (elf_cris_finish_dynamic_symbol): Likewise.
* elf32-hppa.c (elf32_hppa_finish_dynamic_symbol): Likewise.
* elf32-i386.c (elf_i386_finish_dynamic_symbol): Likewise.
* elf32-metag.c (elf_metag_finish_dynamic_symbol): Likewise.
* elf32-microblaze.c (microblaze_elf_finish_dynamic_symbol): Likewise.
* elf32-nios2.c (nios2_elf32_finish_dynamic_symbol): Likewise.
* elf32-or1k.c (or1k_elf_finish_dynamic_symbol): Likewise.
* elf32-ppc.c (ppc_elf_finish_dynamic_symbol): Likewise.
* elf32-s390.c (elf_s390_finish_dynamic_symbol): Likewise.
* elf32-tic6x.c (elf32_tic6x_finish_dynamic_symbol): Likewise.
* elf32-tilepro.c (tilepro_elf_finish_dynamic_symbol): Likewise.
* elf64-ppc.c (ppc64_elf_finish_dynamic_symbol): Likewise.
* elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise.
* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): Likewise.
* elfnn-riscv.c (riscv_elf_finish_dynamic_symbol): Likewise.
* elfxx-mips.c (_bfd_mips_vxworks_finish_dynamic_symbol): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): Likewise.
* elfxx-tilegx.c (tilegx_elf_finish_dynamic_symbol): Likewise.

7 years agoMIPS/BFD: Also handle `jalr $0, $25' with R_MIPS_JALR
Maciej W. Rozycki [Tue, 28 Feb 2017 00:14:08 +0000 (00:14 +0000)]
MIPS/BFD: Also handle `jalr $0, $25' with R_MIPS_JALR

Interpret the `jalr $0, $25' instruction encoding with an R_MIPS_JALR
relocation attached as an alias to `jr $25' and convert the jump to an
equivalent branch where possible, consequently covering the MIPSr6
architecture for the purpose of this optimization too.

bfd/
* elfxx-mips.c (mips_elf_perform_relocation): Also handle the
`jalr $0, $25' instruction encoding.

gas/
* testsuite/gas/mips/jalr4.s: Add `jalr $0, $25' instructions.
* testsuite/gas/mips/jalr4.d: Adjust accordingly.  Remove MIPSr6
encoding patterns.
* testsuite/gas/mips/jalr4-n64.d: Likewise.
* testsuite/gas/mips/mipsr6@jalr4.d: New test.
* testsuite/gas/mips/mipsr6@jalr4-n32.d: New test.
* testsuite/gas/mips/mipsr6@jalr4-n64.d: New test.

ld/
* testsuite/ld-mips-elf/jalr4.dd: Adjust for `jalr $0, $25'
instructions.
* testsuite/ld-mips-elf/jalr4-r6.dd: New test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 28 Feb 2017 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFix compilation with GCC 4.4.7.
Jan Kratochvil [Mon, 27 Feb 2017 22:22:53 +0000 (23:22 +0100)]
Fix compilation with GCC 4.4.7.

binutils/
2017-02-27  Jan Kratochvil  <jan.kratochvil@redhat.com>

Fix compilation with GCC 4.4.7.
* dwarf.c (display_loclists_list, display_debug_rnglists_list):
Initialize begin and end.

7 years agoRemove struct keyword from range-based for loop
Simon Marchi [Mon, 27 Feb 2017 19:09:34 +0000 (14:09 -0500)]
Remove struct keyword from range-based for loop

The previous patch introduced this error with recent-ish GCCs:

../../binutils-gdb/gdb/remote.c: In function ‘int remote_add_target_side_condition(gdbarch*, bp_target_info*, char*, char*)’:
../../binutils-gdb/gdb/remote.c:9668:8: error: types may not be defined in a for-range-declaration [-Werror]
   for (struct agent_expr *aexpr : bp_tgt->conditions)
        ^~~~~~

Removing the struct keyword fixes the error.

gdb/ChangeLog:

* remote.c (remote_add_target_side_condition): Remove "struct"
keyword from range-based for loop.

7 years agoUse range-based for loop in remote_add_target_side_condition
Simon Marchi [Mon, 27 Feb 2017 18:54:53 +0000 (13:54 -0500)]
Use range-based for loop in remote_add_target_side_condition

Using a range based for loop makes this code a bit more clean and
readable.

The comment above is clearly erroneous, so I've updated it.

gdb/ChangeLog:

* remote.c (remote_add_target_side_condition): Use range-based
for loop.  Update comment.

7 years agoFix array out of bound access
Yao Qi [Mon, 27 Feb 2017 17:27:17 +0000 (17:27 +0000)]
Fix array out of bound access

ASAN reports the following error,

(gdb) PASS: gdb.fortran/vla-ptr-info.exp: continue to breakpoint: pvla-associated
print &pvla^M
=================================================================^M
^[[1m^[[31m==14331==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000000ea569f at pc 0x0000008eb546 bp 0x7ffde0c1dc70 sp 0x7ffde0c1dc60^M
^[[1m^[[0m^[[1m^[[34mREAD of size 1 at 0x000000ea569f thread T0^[[1m^[[0m^M
    #0 0x8eb545 in f_print_type(type*, char const*, ui_file*, int, int, type_print_options const*) ../../binutils-gdb/gdb/f-typeprint.c:89^M
    #1 0xb611e2 in type_print(type*, char const*, ui_file*, int) ../../binutils-gdb/gdb/typeprint.c:365^M
    #2 0x7b3471 in c_value_print(value*, ui_file*, value_print_options const*) ../../binutils-gdb/gdb/c-valprint.c:650^M
    #3 0xb99517 in value_print(value*, ui_file*, value_print_options const*) ../../binutils-gdb/gdb/valprint.c:1233^M
    #4 0xa42be8 in print_formatted ../../binutils-gdb/gdb/printcmd.c:321^M
    #5 0xa46ac9 in print_value(value*, format_data const*) ../../binutils-gdb/gdb/printcmd.c:1233^M
    #6 0xa46d82 in print_command_1 ../../binutils-gdb/gdb/printcmd.c:1261^M
    #7 0xa46e3e in print_command ../../binutils-gdb/gdb/printcmd.c:1267

on this line of code

      demangled_args = varstring[strlen (varstring) - 1] == ')';

because varstring is an empty string and strlen () is 0, so "strlen () - 1"
is definitely out of the bound of "varstring",

(gdb) bt 10
    at /home/yao/SourceCode/gnu/gdb/git/gdb/f-typeprint.c:56
    at /home/yao/SourceCode/gnu/gdb/git/gdb/typeprint.c:365
    at /home/yao/SourceCode/gnu/gdb/git/gdb/c-valprint.c:650
    at /home/yao/SourceCode/gnu/gdb/git/gdb/valprint.c:1236

This patch adds a pre-check that varstring is empty or not.

gdb:

2017-02-27  Yao Qi  <yao.qi@linaro.org>

* f-typeprint.c (f_print_type): Check "varstring" is empty first.

7 years agoPlace read-only data in the text section on AVR Tiny targets.
Georg-Johann Lay [Mon, 27 Feb 2017 17:05:53 +0000 (17:05 +0000)]
Place read-only data in the text section on AVR Tiny targets.

PR target/20849
        * scripttempl/avrtiny.sc (__RODATA_PM_OFFSET__): New define.
        (.rodata): New section.
        (.data): Remove .rodata*.

7 years agoAdd symbol called __nm_<name> to exported symbols created by dlltool.
Rudy Y [Mon, 27 Feb 2017 15:02:52 +0000 (15:02 +0000)]
Add symbol called __nm_<name> to exported symbols created by dlltool.

PR 20881
* dlltool.c (secdata): Align .idata$6 on 2 byte boundary.
(make_one_lib_file): Export a symbol called __nm_<symbol> for use
with auto-importing.

7 years agoFix segfault in microblaze linker when garbage collection removes a symbol scheduled...
Nick Clifton [Mon, 27 Feb 2017 11:33:05 +0000 (11:33 +0000)]
Fix segfault in microblaze linker when garbage collection removes a symbol scheduled for a slot in the PLT.

PR ld/21180
* elf32-microblaze.c (microblaze_elf_finish_dynamic_symbol): Avoid
generating a seg-fault when encountering a symbol that has been
deleted by garbage collection.

7 years agoRemove MAX_REGISTER_SIZE from remote.c
Alan Hayward [Mon, 27 Feb 2017 09:58:35 +0000 (09:58 +0000)]
Remove MAX_REGISTER_SIZE from remote.c

gdb/
* regcache.c (regcache_raw_update): New function.
(regcache_raw_read): Move code to regcache_raw_update.
* regcache.h (regcache_raw_update): New declaration.
* remote.c (remote_prepare_to_store): Call regcache_raw_update.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 27 Feb 2017 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in