external/binutils.git
7 years agoFix possible bug when no args have been provided to the executable
Sergio Durigan Junior [Thu, 8 Jun 2017 20:58:25 +0000 (16:58 -0400)]
Fix possible bug when no args have been provided to the executable

Hi,

This bug is related to:

  <https://sourceware.org/ml/gdb-patches/2017-06/msg00216.html>

On stringify_argv, we have to check if args[0] is not NULL before
stringifying anything, otherwise we might do the wrong thing when
trimming the "ret" string in the end.  args[0] will be NULL when no
arguments are passed to the inferior that will be started.

Checked in as obvious.

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

* common/common-utils.c (stringify_argv): Check for "arg[0] !=
NULL".

7 years ago[ARC] Corrected conditions for dynamic sections creation.
Cupertino Miranda [Tue, 23 May 2017 11:36:33 +0000 (13:36 +0200)]
[ARC] Corrected conditions for dynamic sections creation.

Fixed conditions to create the dynamic sections.
Previously there would be times where the dynamic sections would not be created
although they were actually required for linking to work.

Issue found through OpenADK build, more precisely the ublicb testsuite package.

bfd/ChangeLog:

    Cupertino Miranda  <cmiranda@synopsys.com>

elf32-arc.c (elf_arc_check_relocs): Fixed conditions to generate
dynamic sections.

7 years ago[ARC] Fixed condition to generate TEXTREL.
Cupertino Miranda [Wed, 5 Apr 2017 21:22:07 +0000 (23:22 +0200)]
[ARC] Fixed condition to generate TEXTREL.

TEXTREL was being generated even when relocatable .o files had the .rela.text
section. Now it is limitted only to dynamic object files that still have them.
Nevertheless, our target aborts in those cases due to architecture limitations
where icache is not coherent with dcache, and to force this coherence expensive
kernel level support would be needed.

bfd/ChangeLog:

    Cupertino Miranda  <cmiranda@synopsys.com>

* elf32-arc.c (elf_arc_size_dynamic_sections): Changed condition to
require TEXTREL.

7 years ago[ARC] Fixed TLS for IE model.
Cupertino Miranda [Thu, 29 Dec 2016 16:10:01 +0000 (17:10 +0100)]
[ARC] Fixed TLS for IE model.

In the case of static relocation, the GOT entries are fixed at link time
and are set by the linker.
In order to compute the right TLS offset it is necessary to add TCB_SIZE
to the offset, just in case the dynamic linker is not expected to be
executed (static linked case).
This problem does appear in dynamic linked applications, as the dynamic
linker is adding this TCB_SIZE by operating the TCB block structure.

Problem revealed in GLIBC with static linking.

bfd/ChangeLog:

    Cupertino Miranda  <cmiranda@synopsys.com>

arc-got.h (relocate_fix_got_relocs_for_got_info): Added TCB_SIZE to
patched section contents for TLS IE reloc.
elf32-arc.c: Remove TCB_SIZE preprocessor macro.

Rebase to 0006

7 years ago[ARC] Add RELOC_FOR_GLOBAL_SYMBOL in ARC target code.
Cupertino Miranda [Wed, 30 Nov 2016 19:23:21 +0000 (20:23 +0100)]
[ARC] Add RELOC_FOR_GLOBAL_SYMBOL in ARC target code.

This miss was identified in the context of openssh building for ARC.

bfd/ChangeLog:

    Cupertino Miranda  <cmiranda@synopsys.com>

elf32-arc.c (elf_arc_relocate_section): Added "call" to
RELOC_FOR_GLOBAL_SYMBOL macro.

7 years ago[ARC] ARC_PC32 dynamic reloc incorrectly generated.
Cupertino Miranda [Wed, 30 Nov 2016 13:07:20 +0000 (14:07 +0100)]
[ARC] ARC_PC32 dynamic reloc incorrectly generated.

Fixed issue related to the generation of ARC_PC32 dynamic relocs when symbol
is dynamic but still defined in a non shared object.

bfd/ChangeLog:

    Cupertino Miranda  <cmiranda@synopsys.com>

elf32-arc.c (elf_arc_relocate_section): Small refactor and condition
changes.

7 years ago[ARC] Don't convert _DYNAMIC@ to _GLOBAL_OFFSET_TABLE_
Vineet Gupta [Mon, 30 May 2016 09:49:22 +0000 (15:19 +0530)]
[ARC] Don't convert _DYNAMIC@ to _GLOBAL_OFFSET_TABLE_

Historically the arc abi demanded that a GOT[0] should be referencible as
[pc+_DYNAMIC@gotpc].  Hence we convert a _DYNAMIC@gotpc to a GOTPC reference to
_GLOBAL_OFFSET_TABLE_.

This is no longer the case and uClibc and upcomming GNU libc don't expect this
to happen.

gas/ChangeLog:

    Vineet Gupta  <vgupta@synopsys.com>
    Cupertino Miranda  <cmiranda@synopsys.com>

* config/tc-arc.c (md_undefined_symbol): Changed.
* config/tc-arc.h (DYNAMIC_STRUCT_NAME): Removed.

7 years ago[ARC] Reassign the symbol got information to actual symbol when indirect.
Cupertino Miranda [Mon, 24 Oct 2016 20:19:48 +0000 (22:19 +0200)]
[ARC] Reassign the symbol got information to actual symbol when indirect.

GOT information would not be reassign to symbol when it became a indect
symbol.

bfd/ChangeLog:

    Cupertino Miranda  <cmiranda@synopsys.com>

* elf32-arc.c (elf_arc_relocate_section): Fixed reassign of indirect
symbols.

7 years ago[ARC] Disable warning on absolute relocs when symbol is local.
Cupertino Miranda [Mon, 24 Oct 2016 10:52:04 +0000 (12:52 +0200)]
[ARC] Disable warning on absolute relocs when symbol is local.

R_ARC_32 and R_ARC_32_ME cannot be generated as dynamic relocs.
However, a warning message and check_relocs was aborting when this type of
reloc was being resolved to a local symbol.
This is wrong as local symbols are resolvable at link time.

bfd/ChangeLog:

    Cupertino Miranda  <cmiranda@synopsys.com>

* elf32-arc.c (elf_arc_check_relocs): Added condition to disable
warning and "Bad value" for local symbols ARC_32 or ARC_32_ME relocs.

7 years ago[ARC] Avoid creating dynamic relocs when static linked is requested.
Cupertino Miranda [Wed, 7 Dec 2016 13:22:54 +0000 (14:22 +0100)]
[ARC] Avoid creating dynamic relocs when static linked is requested.

bfd/Changelog:

    Cupertino Miranda  <cmiranda@synopsys.com>

* elf32-arc.c (ADD_RELA): Changed to only work when dynamic object is
created.

7 years agoAdd MN10300_MAX_REGISTER_SIZE
Alan Hayward [Thu, 8 Jun 2017 15:05:24 +0000 (16:05 +0100)]
Add MN10300_MAX_REGISTER_SIZE

gdb/
* mn10300-tdep.c (MN10300_MAX_REGISTER_SIZE): Add.
(mn10300_extract_return_value): Use MN10300_MAX_REGISTER_SIZE.
(mn10300_push_dummy_call): Likewise.

7 years agoUpdate ff4ca5ac6a2e8 to the correct version.
Alan Hayward [Thu, 8 Jun 2017 14:57:12 +0000 (15:57 +0100)]
Update ff4ca5ac6a2e8 to the correct version.

gdb/
* mi/mi-main.c (register_changed_p): Use value_contents_eq.

7 years ago[bfd][arm] Don't assert on suspicious build attributes in input file
Richard Earnshaw [Thu, 8 Jun 2017 14:11:44 +0000 (15:11 +0100)]
[bfd][arm] Don't assert on suspicious build attributes in input file

It's generally a bad idea to use assertions to validate our idea of
what an input file looks like.  We need to be as liberal as possible
in what we accept with respect to standards and conservative with what
we produce.

Currently, if gcc is used to produce an assembler file which contains
only data, but the FPU is set to fpv4-sp-d16 and mfloat-abi=hard, then
the following attributes will be set in the output:

        .cpu arm7tdmi
        .eabi_attribute 27, 1   @ Tag_ABI_HardFP_use
        .eabi_attribute 28, 1   @ Tag_ABI_VFP_args
        .eabi_attribute 20, 1   @ Tag_ABI_FP_denormal
        .eabi_attribute 21, 1   @ Tag_ABI_FP_exceptions
        .eabi_attribute 23, 3   @ Tag_ABI_FP_number_model
        .eabi_attribute 24, 1   @ Tag_ABI_align8_needed
        .eabi_attribute 25, 1   @ Tag_ABI_align8_preserved
        .eabi_attribute 26, 2   @ Tag_ABI_enum_size
        .eabi_attribute 30, 6   @ Tag_ABI_optimization_goals
        .eabi_attribute 34, 0   @ Tag_CPU_unaligned_access
        .eabi_attribute 18, 4   @ Tag_ABI_PCS_wchar_t

There is then no .fpu directive to cause Tag_FP_arch to be set,
because there are no functions containing code in the object file.  If
this object file is assembled by hand, but without -mfpu on the
invocation of the assembler, then the build attributes produced will
trigger an assertion during linking.

Thinking about the build attributes, the combination of a
single-precision only implementation of no floating-point architecture
is still no floating-point architecture.  Hence the assertion on the
input BFD in the linker makes no real sense.

We should, however, be more conservative in what we generate, so I've
left the assertion on the output bfd in place; I don't think we can
trigger it with this change since we never merge the problematic tags
from a perversely generated input file.

* elf32-arm.c (elf32_arm_merge_eabi_attributes): Remove assertion
that the input bfd has Tag_FP_ARCH non-zero if Tag_ABI_HardFP_use
is non-zero.  Add clarifying comments.

7 years agoRemove MAX_REGISTER_SIZE from mi/mi-main.c
Alan Hayward [Thu, 8 Jun 2017 13:02:59 +0000 (14:02 +0100)]
Remove MAX_REGISTER_SIZE from mi/mi-main.c

gdb/
* mi/mi-main.c (register_changed_p): Use cooked_read_value.

7 years agox86: Dump local IFUNC functions in the map file
H.J. Lu [Thu, 8 Jun 2017 04:18:01 +0000 (21:18 -0700)]
x86: Dump local IFUNC functions in the map file

Dump local IFUNC functions in the map file when generating IRELATIVE
relocations if -Map is used.

bfd/

* elf32-i386.c (elf_i386_check_relocs): Set local IFUNC symbol
name.  Use local IFUNC symbol name string to report unsupported
non-PIC call to IFUNC function.
(elf_i386_relocate_section): Dump local IFUNC name with minfo
when generating R_386_IRELATIVE relocation.
(elf_i386_finish_dynamic_symbol): Likewise.
* elf_x86_64_check_relocs (elf_x86_64_check_relocs): Set local
IFUNC symbol name.
(elf_x86_64_relocate_section): Dump local IFUNC name with minfo
when generating R_X86_64_IRELATIVE relocation.
(elf_x86_64_finish_dynamic_symbol): Likewise.

ld/

* testsuite/ld-ifunc/ifunc-1-local-x86.d: Pass
"-Map tmpdir/ifunc-1-local-x86.map" to ld and check
ifunc-1-local-x86.map.
* testsuite/ld-ifunc/ifunc-1-x86.d: Pass
"-Map tmpdir/ifunc-1-x86.map" to ld and check ifunc-1-x86.map.
* testsuite/ld-ifunc/ifunc-1-local-x86.map: New file.
* testsuite/ld-ifunc/ifunc-1-x86.map: Likewise.

7 years agocl
H.J. Lu [Thu, 8 Jun 2017 10:48:04 +0000 (03:48 -0700)]
cl

7 years ago[AArch64] Allow COPY relocation elimination
Jiong Wang [Wed, 7 Jun 2017 11:05:39 +0000 (12:05 +0100)]
[AArch64] Allow COPY relocation elimination

  As discussed at the PR, this patch tries to avoid COPY relocation generation
and propagate the original relocation into runtime if it was relocating on
writable section.  The ELIMINATE_COPY_RELOCS has been set to true and it's
underlying infrastructure has been improved so that the COPY reloc elimination
at least working on absoluate relocations (ABS64) after this patch.

bfd/
        PR ld/21532
        * elfnn-aarch64.c (ELIMINATE_COPY_RELOCS): Set to 1.
        (elfNN_aarch64_final_link_relocate): Also propagate relocations to
        runtime for copy relocation elimination cases.
        (alias_readonly_dynrelocs): New function.
        (elfNN_aarch64_adjust_dynamic_symbol): Keep the dynamic relocs instead
        of generating copy relocation if it is not against read-only sections.
        (elfNN_aarch64_check_relocs): Likewise.

ld/
        * testsuite/ld-aarch64/copy-reloc-eliminate.d: New test.
        * testsuite/ld-aarch64/copy-reloc-exe-eliminate.s: New test source file.
        * testsuite/ld-aarch64/aarch64-elf.exp: Run new testcase.

7 years ago2017-06-07 Eric Christopher <echristo@gmail.com>
Eric Christopher [Thu, 8 Jun 2017 00:49:35 +0000 (17:49 -0700)]
2017-06-07  Eric Christopher  <echristo@gmail.com>

* aarch64.cc (maybe_apply_stub): Add debug logging for looking
up stubs to undefined symbols and early return rather than
fail to look them up.
(scan_reloc_for_stub): Add debug logging for no stub creation
for undefined symbols.

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

7 years agoImplement proper "startup-with-shell" support on gdbserver
Sergio Durigan Junior [Fri, 23 Dec 2016 03:14:02 +0000 (22:14 -0500)]
Implement proper "startup-with-shell" support on gdbserver

This patch implements the proper support for the "startup-with-shell"
feature on gdbserver.  A new packet is added, QStartupWithShell, and
it is sent on initialization.  If the host sends a
"QStartupWithShell:1", it means the inferior shall be started using a
shell.  If the host sends a "QStartupWithShell:0", it means the
inferior shall be started without using a shell.  Any other value is
considered an error.

There is no way to remotely set the shell that will be used by the
target to start the inferior.  In order to do that, the user must
start gdbserver while providing a shell via the $SHELL environment
variable.  The same is true for the host side.

The "set startup-with-shell" setting from the host side is used to
decide whether to start the remote inferior using a shell.  This same
setting is also used to decide whether to use a shell to start the
host inferior; this means that it is not really possible to start the
inferior using different mechanisms on target and host.

A documentation patch is included, along with a new testcase for the
feature.

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

* NEWS (Changes since GDB 8.0): Announce that GDBserver is now
able to start inferiors using a shell.
(New remote packets): Announce new packet "QStartupWithShell".
* remote.c: Add PACKET_QStartupWithShell.
(extended_remote_create_inferior): Handle new
PACKET_QStartupWithShell.
(remote_protocol_features) <QStartupWithShell>: New entry for
PACKET_QStartupWithShell.
(_initialize_remote): Call "add_packet_config_cmd" for
QStartupShell.

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

* server.c (handle_general_set): Handle new packet
"QStartupWithShell".
(handle_query): Add "QStartupWithShell" to the list of supported
packets.
(gdbserver_usage): Add help text explaining the
new "--startup-with-shell" and "--no-startup-with-shell" CLI
options.
(captured_main): Recognize and act upon the presence of the new
CLI options.

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

* gdb.base/startup-with-shell.c: New file.
* gdb.base/startup-with-shell.exp: Likewise.

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

* gdb.texinfo (Starting) <startup-with-shell>: Add @anchor.
(Connecting) <Remote Packet>: Add "startup-with-shell"
and "QStartupWithShell" to the table.
(Remote Protocol) <QStartupWithShell>: New item, explaining the
packet.

7 years agoShare fork_inferior et al with gdbserver
Sergio Durigan Junior [Fri, 23 Dec 2016 02:11:11 +0000 (21:11 -0500)]
Share fork_inferior et al with gdbserver

This is the most important (and the biggest, sorry) patch of the
series.  It moves fork_inferior from gdb/fork-child.c to
nat/fork-inferior.c and makes all the necessary adjustments to both
GDB and gdbserver to make sure everything works OK.

There is no "most important change" with this patch; all changes are
made in a progressive way, making sure that gdbserver had the
necessary features while not breaking GDB at the same time.

I decided to go ahead and implement a partial support for starting the
inferior with a shell on gdbserver, although the full feature comes in
the next patch.  The user won't have the option to disable the
startup-with-shell, and also won't be able to change which shell
gdbserver will use (other than setting the $SHELL environment
variable, that is).

Everything is working as expected, and no regressions were present
during the tests.

gdb/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
    Pedro Alves  <palves@redhat.com>

* Makefile.in (HFILES_NO_SRCDIR): Add "common/common-inferior.h"
and "nat/fork-inferior.h".
* common/common-inferior.h: New file, with contents from
"gdb/inferior.h".
* commom/common-utils.c: Include "common-utils.h".
(stringify_argv): New function.
* common/common-utils.h (stringify_argv): New prototype.
* configure.nat: Add "fork-inferior.o" as a dependency for
"*linux*", "fbsd*" and "nbsd*" hosts.
* corefile.c (get_exec_file): Update comment.
* darwin-nat.c (darwin_ptrace_him): Call "gdb_startup_inferior"
instead of "startup_inferior".
(darwin_create_inferior): Call "add_thread_silent" after
"fork_inferior".
* fork-child.c: Cleanup unnecessary includes.
(SHELL_FILE): Move to "common/common-fork-child.c".
(environ): Likewise.
(exec_wrapper): Initialize.
(get_exec_wrapper): New function.
(breakup_args): Move to "common/common-fork-child.c"; rename to
"breakup_args_for_exec".
(escape_bang_in_quoted_argument): Move to
"common/common-fork-child.c".
(saved_ui): New variable.
(prefork_hook): New function.
(postfork_hook): Likewise.
(postfork_child_hook): Likewise.
(gdb_startup_inferior): Likewise.
(fork_inferior): Move to "common/common-fork-child.c".  Update
function to support gdbserver.
(startup_inferior): Likewise.
* gdbcore.h (get_exec_file): Remove declaration.
* gnu-nat.c (gnu_create_inferior): Call "gdb_startup_inferior"
instead of "startup_inferior".  Call "add_thread_silent" after
"fork_inferior".
* inf-ptrace.c: Include "nat/fork-inferior.h" and "utils.h".
(inf_ptrace_create_inferior): Call "gdb_startup_inferior"
instead of "startup_inferior".  Call "add_thread_silent" after
"fork_inferior".
* inferior.h: Include "common-inferior.h".
(trace_start_error): Move to "common/common-utils.h".
(trace_start_error_with_name): Likewise.
(fork_inferior): Move prototype to "nat/fork-inferior.h".
(startup_inferior): Likewise.
(gdb_startup_inferior): New prototype.
* nat/fork-inferior.c: New file, with contents from "fork-child.c".
* nat/fork-inferior.h: New file.
* procfs.c (procfs_init_inferior): Call "gdb_startup_inferior"
instead of "startup_inferior".  Call "add_thread_silent" after
"fork_inferior".
* target.h (target_terminal_init): Move prototype to
"target/target.h".
(target_terminal_inferior): Likewise.
(target_terminal_ours): Likewise.
* target/target.h (target_terminal_init): New prototype, moved
from "target.h".
(target_terminal_inferior): Likewise.
(target_terminal_ours): Likewise.
* utils.c (gdb_flush_out_err): New function.

gdb/gdbserver/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
    Pedro Alves  <palves@redhat.com>

* Makefile.in (SFILES): Add "nat/fork-inferior.o".
* configure: Regenerate.
* configure.srv (srv_linux_obj): Add "fork-child.o" and
"fork-inferior.o".
(i[34567]86-*-lynxos*): Likewise.
(spu*-*-*): Likewise.
* fork-child.c: New file.
* linux-low.c: Include "common-inferior.h", "nat/fork-inferior.h"
and "environ.h".
(linux_ptrace_fun): New function.
(linux_create_inferior): Adjust function prototype to reflect
change on "target.h".  Adjust function code to use
"fork_inferior".
(linux_request_interrupt): Delete "signal_pid".
* lynx-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
(lynx_ptrace_fun): New function.
(lynx_create_inferior): Adjust function prototype to reflect
change on "target.h".  Adjust function code to use
"fork_inferior".
* nto-low.c (nto_create_inferior): Adjust function prototype and
code to reflect change on "target.h".  Update comments.
* server.c: Include "common-inferior.h", "nat/fork-inferior.h",
"common-terminal.h" and "environ.h".
(terminal_fd): Moved to fork-child.c.
(old_foreground_pgrp): Likewise.
(restore_old_foreground_pgrp): Likewise.
(last_status): Make it global.
(last_ptid): Likewise.
(our_environ): New variable.
(startup_with_shell): Likewise.
(program_name): Likewise.
(program_argv): Rename to...
(program_args): ...this.
(wrapper_argv): New variable.
(start_inferior): Delete function.
(get_exec_wrapper): New function.
(get_exec_file): Likewise.
(get_environ): Likewise.
(prefork_hook): Likewise.
(post_fork_inferior): Likewise.
(postfork_hook): Likewise.
(postfork_child_hook): Likewise.
(handle_v_run): Update code to deal with arguments coming from the
remote host.  Update calls from "start_inferior" to
"create_inferior".
(captured_main): Likewise.  Initialize environment variable.  Call
"have_job_control".
* server.h (post_fork_inferior): New prototype.
(get_environ): Likewise.
(last_status): Declare.
(last_ptid): Likewise.
(signal_pid): Likewise.
* spu-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
(spu_ptrace_fun): New function.
(spu_create_inferior): Adjust function prototype to reflect change
on "target.h".  Adjust function code to use "fork_inferior".
* target.c (target_terminal_init): New function.
(target_terminal_inferior): Likewise.
(target_terminal_ours): Likewise.
* target.h: Include <vector>.
(struct target_ops) <create_inferior>: Update prototype.
(create_inferior): Update macro.
* utils.c (gdb_flush_out_err): New function.
* win32-low.c (win32_create_inferior): Adjust function prototype
and code to reflect change on "target.h".

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

* gdb.server/non-existing-program.exp: Update regex in order to
reflect the fact that gdbserver is now using fork_inferior (with a
shell) to startup the inferior.

7 years agoShare parts of gdb/gdbthread.h with gdbserver
Sergio Durigan Junior [Thu, 22 Dec 2016 18:30:42 +0000 (13:30 -0500)]
Share parts of gdb/gdbthread.h with gdbserver

GDB and gdbserver now share 'switch_to_thread' because of
fork_inferior.  To make things clear, I created a new file name
common/common-gdbthread.h, and left the implementation specific to
each part.

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

* Makefile.in (HFILES_NO_SRCDIR): Add "common/common-gdbthread.h".
* common/common-gdbthread.h: New file, with parts from
"gdb/gdbthread.h".
* gdbthread.h: Include "common-gdbthread.h".
(switch_to_thread): Moved to "common/common-gdbthread.h".

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

* inferiors.c (switch_to_thread): New function.

7 years agoMove parts of inferior job control to common/
Sergio Durigan Junior [Thu, 22 Dec 2016 17:41:16 +0000 (12:41 -0500)]
Move parts of inferior job control to common/

This commit moves a few bits responsible for dealing with inferior job
control from GDB to common/, which makes them available to gdbserver.
This is necessary for the upcoming patches that will share
fork_inferior et al between GDB and gdbserver.

We move some parts of gdb/terminal.h to gdb/common/common-terminal.h,
especifically the code that checks terminal features and that are used
to set job_control accordingly.

After sharing parts of gdb/terminal.h, we also to share the two
functions on gdb/inflow.c that are going to be needed by the
fork_inferior rework.  They are 'gdb_setpgid' and the new
'have_job_control'.  I've also taken the opportunity to give a more
meaningful name to "inflow.c" on common/.  Now it is called
"job-control.c" (thanks Pedro for the suggestion).

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

* Makefile.in (SFILES): Add "common/job-control.c".
(HFILES_NO_SRCDIR): Add "common/job-control.h".
(COMMON_OBS): Add "job-control.o".
* common/job-control.c: New file, with contents from
"gdb/inflow.c".
* common/job-control.h: New file, with contents from "terminal.h".
* fork-child.c: Include "job-control.h".
* inflow.c: Include "job-control.h".
(gdb_setpgid): Move to "common/common-inflow.c".
(_initialize_inflow): Move setting of "job_control" to
"handle_job_control".
* terminal.h (job_control): Moved to "common/common-terminal.h".
(gdb_setpgid): Likewise.
* top.c: Include "job_control.h".
* utils.c: Likewise.
(job_control): Moved to "job-control.c".

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

* Makefile.in (SFILE): Add "common/job-control.c".
(OBS): Add "job-control.o".

7 years agoIntroduce compiled_regex, eliminate make_regfree_cleanup
Pedro Alves [Wed, 7 Jun 2017 13:21:40 +0000 (14:21 +0100)]
Introduce compiled_regex, eliminate make_regfree_cleanup

This patch replaces compile_rx_or_error and make_regfree_cleanup with
a class that wraps a regex_t.

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

* Makefile.in (SFILES): Add gdb_regex.c.
(COMMON_OBS): Add gdb_regex.o.
* ada-lang.c (ada_add_standard_exceptions)
(ada_add_exceptions_from_frame, name_matches_regex)
(ada_add_global_exceptions, ada_exceptions_list_1): Change regex
parameter type to compiled_regex.  Adjust.
(ada_exceptions_list): Use compiled_regex.
* break-catch-throw.c (exception_catchpoint::pattern): Now a
std::unique_ptr<compiled_regex>.
(exception_catchpoint::~exception_catchpoint): Remove regfree
call.
(check_status_exception_catchpoint): Adjust to use compiled_regex.
(handle_gnu_v3_exceptions): Adjust to use compiled_regex.
* breakpoint.c (solib_catchpoint::compiled): Now a
std::unique_ptr<compiled_regex>.
(solib_catchpoint::~solib_catchpoint): Remove regfree call.
(check_status_catch_solib): Adjust to use compiled_regex.
(add_solib_catchpoint): Adjust to use compiled_regex.
* cli/cli-cmds.c (apropos_command): Use compiled_regex.
* cli/cli-decode.c (apropos_cmd): Change regex parameter to
compiled_regex reference.  Adjust to use it.
* cli/cli-decode.h: Remove struct re_pattern_buffer forward
declaration.  Include "gdb_regex.h".
(apropos_cmd): Change regex parameter to compiled_regex reference.
* gdb_regex.c: New file.
* gdb_regex.h (make_regfree_cleanup, get_regcomp_error): Delete
declarations.
(class compiled_regex): New.
* linux-tdep.c: Include "common/gdb_optional.h".
(struct mapping_regexes): New, factored out from
mapping_is_anonymous_p, and adjusted to use compiled_regex.
(mapping_is_anonymous_p): Use mapping_regexes wrapped in a
gdb::optional and remove cleanups.  Adjust to compiled_regex.
* probe.c: Include "common/gdb_optional.h".
(collect_probes): Use compiled_regex and gdb::optional and remove
cleanups.
* skip.c: Include "common/gdb_optional.h".
(skiplist_entry::compiled_function_regexp): Now a
gdb::optional<compiled_regex>.
(skiplist_entry::compiled_function_regexp_is_valid): Delete field.
(free_skiplist_entry): Remove regfree call.
(compile_skip_regexp, skip_rfunction_p): Adjust to use
compiled_regex and gdb::optional.
* symtab.c: Include "common/gdb_optional.h".
(search_symbols): Use compiled_regex and gdb::optional.
* utils.c (do_regfree_cleanup, make_regfree_cleanup)
(get_regcomp_error, compile_rx_or_error): Delete.  Some bits moved
to gdb_regex.c.

7 years agoAdd support for AArch64 system register names IP0, IP1, FP and LR.
Michael Collison [Wed, 7 Jun 2017 12:34:34 +0000 (13:34 +0100)]
Add support for AArch64 system register names IP0, IP1, FP and LR.

* config/tc-aarch64.c (reg_entry_reg_names): Add IP0,
IP1, FP, and LR as register aliases of register 16, 17, 29
and 30 respectively.
* testsuite/gas/aarch64/diagnostic.l: Remove diagnostic
prohibiting register 'lr' which is now an alias.
* testsuite/gas/aarch64/diagnostic.s: Remove instruction
utilizing register 'lr' which is now an alias.

7 years agoRemove MAX_REGISTER_SIZE from regcache.c
Alan Hayward [Wed, 7 Jun 2017 09:16:46 +0000 (10:16 +0100)]
Remove MAX_REGISTER_SIZE from regcache.c

gdb/
* regcache.c (regcache::save): Avoid buffer use.
(regcache::dump): Likewise.

7 years agoRemove MAX_REGISTER_SIZE from sh(64)-tdep.c
Alan Hayward [Wed, 7 Jun 2017 09:06:10 +0000 (10:06 +0100)]
Remove MAX_REGISTER_SIZE from sh(64)-tdep.c

gdb/
* sh-tdep.c (sh_pseudo_register_read): Remove
MAX_REGISTER_SIZE.
(sh_pseudo_register_write): Likewise.
* sh64-tdep.c (sh64_pseudo_register_read): Likewise.
(sh64_pseudo_register_write): Likewise.

7 years agoRemove MAX_REGISTER_SIZE from aarch64-tdep.c
Alan Hayward [Wed, 7 Jun 2017 08:57:55 +0000 (09:57 +0100)]
Remove MAX_REGISTER_SIZE from aarch64-tdep.c

gdb/
* aarch64-tdep.c (aarch64_store_return_value): Use
V_REGISTER_SIZE.
(aarch64_pseudo_read_value): Likewise.
(aarch64_pseudo_write): Likewise.

7 years agoFix a number of pr21529 testcase failures
Alan Modra [Wed, 7 Jun 2017 05:52:58 +0000 (15:22 +0930)]
Fix a number of pr21529 testcase failures

Various targets fail this testcase due to ld not supporting binary output.

* testsuite/ld-unique/pr21529.d: xfail aarch64, arm, hppa, ia64,
nds32, and score.  Match any output.

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

7 years agobfd: support section groups with preceding SHF_GROUP sections
Jose E. Marchesi [Tue, 6 Jun 2017 18:19:06 +0000 (11:19 -0700)]
bfd: support section groups with preceding SHF_GROUP sections

GAS always places section groups (SHT_GROUP) before the rest of the
sections in the output file.  However, other assemblers may place
section groups after the group members.

This patch fixes handlign such situations, and removes some duplicated
logic.

bfd/ChangeLog:

2017-06-06  Jose E. Marchesi  <jose.marchesi@oracle.com>

* elf.c (setup_group): Make sure BFD sections are created for all
group sections in the input file when processing SHF_GROUP
sections.
(bfd_section_from_shdr): Avoid duplicating logic already
implemented in `setup_group'.

7 years agoRemove declaration of set_register_cache from regdef.h
Yao Qi [Tue, 6 Jun 2017 15:42:45 +0000 (16:42 +0100)]
Remove declaration of set_register_cache from regdef.h

Function set_register_cache was removed by 3aee891821f538cfb4e0a08a26196c70127f1474
([GDBserver] Multi-process + multi-arch), so this patch removes the
declaration too.

gdb:

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

* regformats/regdef.h (set_register_cache): Remove the
declaration.

7 years agoRemove a MAX_REGISTER_SIZE from frame.c
Alan Hayward [Tue, 6 Jun 2017 15:34:20 +0000 (16:34 +0100)]
Remove a MAX_REGISTER_SIZE from frame.c

gdb/
* frame.c (frame_unwind_register_signed): Use
frame_unwind_register_value.

7 years agoFix double free when running gdb.linespec/ls-errs.exp (PR breakpoints/21553)
Pedro Alves [Tue, 6 Jun 2017 14:53:59 +0000 (15:53 +0100)]
Fix double free when running gdb.linespec/ls-errs.exp (PR breakpoints/21553)

The problem is that b->extra_string is free'ed twice: Once in the
breakpoint's dtor, and another time via make_cleanup (xfree).

This patch gets rid of the cleanups, fixing the problem.

Tested on x86_64 GNU/Linux.

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

PR breakpoints/21553
* breakpoint.c (create_breakpoints_sal_default)
(init_breakpoint_sal, create_breakpoint_sal): Use
gdb::unique_xmalloc_ptr for string parameters.
(create_breakpoint): Constify 'extra_string' and 'cond_string'
parameters.  Replace cleanups with gdb::unique_xmalloc_ptr.
(base_breakpoint_create_breakpoints_sal)
(bkpt_create_breakpoints_sal, tracepoint_create_breakpoints_sal)
(strace_marker_create_breakpoints_sal)
(create_breakpoints_sal_default): Use gdb::unique_xmalloc_ptr for
string parameters.
* breakpoint.h (breakpoint_ops::create_breakpoints_sal): Use
gdb::unique_xmalloc_ptr for string parameters.
(create_breakpoint): Constify 'extra_string' and 'cond_string'
parameters.

7 years agoRemove uses of MAX_REGISTER_SIZE from alpha-tdep.c
Alan Hayward [Tue, 6 Jun 2017 14:45:08 +0000 (15:45 +0100)]
Remove uses of MAX_REGISTER_SIZE from alpha-tdep.c

gdb/
* alpha-tdep.c (alpha_register_to_value): Use
get_frame_register_value.
(alpha_value_to_register): Use ALPHA_REGISTER_SIZE.

7 years agoHandle printing information about PE format files which have 0 as the value of the...
Daniel Bonniot de Ruisselet [Tue, 6 Jun 2017 14:06:02 +0000 (15:06 +0100)]
Handle printing information about PE format files which have 0 as the value of the HInt Table in the import tables structure.

PR binutils/21546
* peXXigen.c (pe_print_idata): Use the address of the first thunk
if the hint address is zero.

7 years ago[Patch, ARM] Relax the restrictions on REG_SP under Thumb mode on ARMv8-A
Jiong Wang [Thu, 25 May 2017 09:40:07 +0000 (10:40 +0100)]
[Patch, ARM] Relax the restrictions on REG_SP under Thumb mode on ARMv8-A

  For Thumb mode, since ARMv8-A, REG_SP is allowed in most of the places in
Rd/Rt/Rt2 etc while it was disallowed before ARMv8-A, and was rejected through
the "reject_bad_reg" macro and several scattered checks.

  This patch only rejects REG_SP in "reject_bad_reg" and several related places
for legacy architectures before ARMv8-A. I have checked those affected instructions
, all of them qualify such relaxations.

  Testcases adjusted accordingly.
    * ld-sp-warn.d was written without .arch and without -march options passed.
      By default it assumes all architectures, so I deleted the REG_SP warning
      on ldrsb as it's supported on ARMv8-A.  There are actually quite a few
      seperate tests on other architectures, for example ld-sp-warn-v7.l etc.,
      so there the test for ldrsb on legacy architectures are still covered.
    * sp-pc-validations-bad-t has been extended to armv8-a.
    * strex-bad-t.d restricted on armv7-a.
    * Some new tests for REG_SP used as Rd/Rt etc added in sp-usage-thumb2-relax*.

gas/
* config/tc-arm.c (reject_bad_reg): Allow REG_SP on ARMv8-A.
(parse_operands): Allow REG_SP for OP_oRRnpcsp and OP_RRnpcsp on
ARMv8-A.
(do_co_reg): Allow REG_SP for Rd on ARMv8-A.
(do_t_add_sub): Likewise.
(do_t_mov_cmp): Likewise.
(do_t_tb): Likewise.
* testsuite/gas/arm/ld-sp-warn.l: Delete the warning on REG_SP as Rt for
ldrsb.
* testsuite/gas/arm/sp-pc-validations-bad-t-v8a.d: New test.
* testsuite/gas/arm/sp-pc-validations-bad-t-v8a.l: New test.
* testsuite/gas/arm/sp-pc-validations-bad-t.d: Specifies -march=armv7-a.
* testsuite/gas/arm/sp-pc-validations-bad-t.s: Remove ".arch armv7-a".
* testsuite/gas/arm/sp-usage-thumb2-relax-on-v7.d: New test.
* testsuite/gas/arm/sp-usage-thumb2-relax-on-v7.l: New test.
* testsuite/gas/arm/sp-usage-thumb2-relax-on-v8.d: New test.
* testsuite/gas/arm/sp-usage-thumb2-relax.s: New test.
* testsuite/gas/arm/strex-bad-t.d: Specifies -march=armv7-a.

7 years agoFix memory leaks in the sysinfo program.
Simon Marchi [Tue, 6 Jun 2017 13:52:31 +0000 (14:52 +0100)]
Fix memory leaks in the sysinfo program.

* sysinfo.y: Free memory allocated by token NAME.

7 years agoFix AArch64 in the same way as other targets updated in 8170f7693bc0a9442c0aa28019792...
James Clarke [Tue, 6 Jun 2017 13:30:47 +0000 (14:30 +0100)]
Fix AArch64 in the same way as other targets updated in 8170f7693bc0a9442c0aa280197925db92d48ca6.

PR ld/19579
* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): Check
ELF_COMMON_DEF_P for common symbols.

7 years agoAdd IA64_MAX_FP_REGISTER_SIZE
Alan Hayward [Tue, 6 Jun 2017 12:50:07 +0000 (13:50 +0100)]
Add IA64_MAX_FP_REGISTER_SIZE

gdb/
* ia64-tdep.c (IA64_MAX_FP_REGISTER_SIZE) Add.
(ia64_register_to_value): Use IA64_MAX_FP_REGISTER_SIZE.
(ia64_value_to_register): Likewise.
(ia64_extract_return_value): Likewise.
(ia64_store_return_value): Likewise.
(ia64_push_dummy_call): Likewise.

7 years agold: Fix spelling mistake in comment.
Andrew Burgess [Tue, 6 Jun 2017 09:15:27 +0000 (10:15 +0100)]
ld: Fix spelling mistake in comment.

ld/ChangeLog:

* ld.h (struct args_type): Fix typo in comment.

7 years agold: Allow section groups to be resolved as part of a relocatable link
Andrew Burgess [Wed, 22 Mar 2017 17:27:49 +0000 (17:27 +0000)]
ld: Allow section groups to be resolved as part of a relocatable link

This commit adds a new linker feature: the ability to resolve section
groups as part of a relocatable link.

Currently section groups are automatically resolved when performing a
final link, and are carried through when performing a relocatable link.
By carried through this means that one copy of each section group (from
all the copies that might be found in all the input files) is placed
into the output file.  Sections that are part of a section group will
not match input section specifiers within a linker script and are
forcibly kept as separate sections.

There is a slight resemblance between section groups and common
section.  Like section groups, common sections are carried through when
performing a relocatable link, and resolved (allocated actual space)
only at final link time.

However, with common sections there is an ability to force the linker to
allocate space for the common sections when performing a relocatable
link, there's currently no such ability for section groups.

This commit adds such a mechanism.  This new facility can be accessed in
two ways, first there's a command line switch --force-group-allocation,
second, there's a new linker script command FORCE_GROUP_ALLOCATION.  If
one of these is used when performing a relocatable link then the linker
will resolve the section groups as though it were performing a final
link, the section group will be deleted, and the members of the group
will be placed like normal input sections.  If there are multiple copies
of the group (from multiple input files) then only one copy of the group
members will be placed, the duplicate copies will be discarded.

Unlike common sections that have the --no-define-common command line
flag, and INHIBIT_COMMON_ALLOCATION linker script command there is no
way to prevent group resolution during a final link, this is because the
ELF gABI specifically prohibits the presence of SHT_GROUP sections in a
fully linked executable.  However, the code as written should make
adding such a feature trivial, setting the new resolve_section_groups
flag to false during a final link should work as you'd expect.

bfd/ChangeLog:

* elf.c (_bfd_elf_make_section_from_shdr): Don't initially mark
SEC_GROUP sections as SEC_EXCLUDE.
(bfd_elf_set_group_contents): Replace use of abort with an assert.
(assign_section_numbers): Use resolve_section_groups flag instead
of relocatable link type.
(_bfd_elf_init_private_section_data): Use resolve_section_groups
flag instead of checking the final_link flag for part of the
checks in here.  Fix white space as a result.
* elflink.c (elf_link_input_bfd): Use resolve_section_groups flag
instead of relocatable link type.
(bfd_elf_final_link): Likewise.

include/ChangeLog:

* bfdlink.h (struct bfd_link_info): Add new resolve_section_groups
flag.

ld/ChangeLog:

* ld.h (struct args_type): Add force_group_allocation field.
* ldgram.y: Add support for FORCE_GROUP_ALLOCATION.
* ldlex.h: Likewise.
* ldlex.l: Likewise.
* lexsup.c: Likewise.
* ldlang.c (unique_section_p): Check resolve_section_groups flag
not the relaxable link flag.
(lang_add_section): Discard section groups when we're resolving
groups.  Clear the SEC_LINK_ONCE flag if we're resolving section
groups.
* ldmain.c (main): Initialise resolve_section_groups flag in
link_info based on command line flags.
* testsuite/ld-elf/group11.d: New file.
* testsuite/ld-elf/group12.d: New file.
* testsuite/ld-elf/group12.ld: New file.
* NEWS: Mention new features.
* ld.texinfo (Options): Document --force-group-allocation.
(Miscellaneous Commands): Document FORCE_GROUP_ALLOCATION.

7 years agobfd: remove unused local variables in elf32-score, elf32-score7 and elfxx-mips
Jose E. Marchesi [Tue, 6 Jun 2017 07:33:20 +0000 (00:33 -0700)]
bfd: remove unused local variables in elf32-score, elf32-score7 and elfxx-mips

bfd/ChangeLog:

2017-06-06  Jose E. Marchesi  <jose.marchesi@oracle.com>

* elfxx-mips.c (_bfd_mips_elf_relocate_section): Remove unused
variable `bed'.
* elf32-score.c (score_elf_final_link_relocate): Likewise.
(s3_bfd_score_elf_check_relocs): Likewise.
* elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
(score_elf_final_link_relocate): Likewise.
(s7_bfd_score_elf_check_relocs): Likewise.

7 years agobfd: remove unused local variable in elflink.c:init_reloc_cookie_rels
Jose E. Marchesi [Tue, 6 Jun 2017 07:01:58 +0000 (00:01 -0700)]
bfd: remove unused local variable in elflink.c:init_reloc_cookie_rels

bfd/ChangeLog:

2017-06-06  Jose E. Marchesi  <jose.marchesi@oracle.com>

* elflink.c (init_reloc_cookie_rels): Remove unused variable
`bed'.

7 years agoELF/BFD: Hold the number of internal static relocs in `->reloc_count'
Maciej W. Rozycki [Tue, 6 Jun 2017 00:24:06 +0000 (01:24 +0100)]
ELF/BFD: Hold the number of internal static relocs in `->reloc_count'

Correct a commit e5713223cbc1 ("MIPS/BFD: For n64 hold the number of
internal relocs in `->reloc_count'") regression and change internal
relocation handling in the generic ELF BFD linker code such that, except
in the presence of R_SPARC_OLO10 relocations, a section's `reloc_count'
holds the number of internal rather than external relocations, making
the handling more consistent between GAS, which sets `->reloc_count'
with a call to `bfd_set_reloc', and LD, which sets `->reloc_count' as it
reads input sections.

The handling of dynamic relocations remains unchanged and they continue
holding the number of external relocations in `->reloc_count'; they are
also not converted to the internal form except in `elf_link_sort_relocs'
(which does not handle the general, i.e. non-n64-MIPS case of composed
relocations correctly as per the ELF gABI, though it does not seem to
matter for the targets we currently support).

The n64 MIPS backend is the only one with `int_rels_per_ext_rel' set to
non-one, and consequently the change is trivial for all the remaining
backends and targets.

bfd/
* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Subtract `count'
from `reloc_count' rather than decrementing it.
* elf.c (bfd_section_from_shdr): Multiply the adjustment to
`reloc_count' by `int_rels_per_ext_rel'.
* elf32-score.c (score_elf_final_link_relocate): Do not multiply
`reloc_count' by `int_rels_per_ext_rel' for last relocation
entry determination.
(s3_bfd_score_elf_check_relocs): Likewise.
* elf32-score7.c (score_elf_final_link_relocate): Likewise.
(s7_bfd_score_elf_relocate_section): Likewise.
(s7_bfd_score_elf_check_relocs): Likewise.
* elf64-mips.c (mips_elf64_get_reloc_upper_bound): Remove
prototype and function.
(mips_elf64_slurp_one_reloc_table): Do not update `reloc_count'.
(mips_elf64_slurp_reloc_table): Assert that `reloc_count' is
triple rather than once the sum of REL and RELA relocation entry
counts.
(bfd_elf64_get_reloc_upper_bound): Remove macro.
* elflink.c (_bfd_elf_link_read_relocs): Do not multiply
`reloc_count' by `int_rels_per_ext_rel' for internal relocation
storage allocation size determination.
(elf_link_input_bfd): Multiply `.ctors' and `.dtors' section's
size by `int_rels_per_ext_rel'.  Do not multiply `reloc_count'
by `int_rels_per_ext_rel' for last relocation entry
determination.
(bfd_elf_final_link): Do not multiply `reloc_count' by
`int_rels_per_ext_rel' for internal relocation storage
allocation size determination.
(init_reloc_cookie_rels): Do not multiply `reloc_count' by
`int_rels_per_ext_rel' for last relocation entry determination.
(elf_gc_smash_unused_vtentry_relocs): Likewise.
* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
(_bfd_mips_elf_relocate_section): Likewise.

7 years agoDrop arm support for falkor/qdf24xx targets, not present in released hardware.
Jim Wilson [Tue, 6 Jun 2017 00:25:02 +0000 (17:25 -0700)]
Drop arm support for falkor/qdf24xx targets, not present in released hardware.

gas/
* config/tc-arm.c (arm_cpus): Delete falkor and qdf24xx entries.
* doc/c-arm.texi (-mcpu): Likewise.

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

7 years agoAdd a testcase for PR ld/21529
H.J. Lu [Mon, 5 Jun 2017 21:54:12 +0000 (14:54 -0700)]
Add a testcase for PR ld/21529

PR ld/21529
* testsuite/ld-unique/pr21529.d: New file.
* testsuite/ld-unique/pr21529.s: Likewise.
* testsuite/ld-unique/unique.exp: Run *.d.

7 years agoPR21529, internal error in linker.c
Alan Modra [Mon, 5 Jun 2017 01:32:42 +0000 (11:02 +0930)]
PR21529, internal error in linker.c

PR 21529
* linker.c (_bfd_generic_link_output_symbols): Handle BSF_GNU_UNIQUE.

7 years agoFix --enable-new-dtags config support
Alan Modra [Mon, 5 Jun 2017 05:13:54 +0000 (14:43 +0930)]
Fix --enable-new-dtags config support

and testsuite when configured with --enable-new-dtags.

* ldmain.c (main): Correct setting of link_indo.new_dtags.
* testsuite/ld-elf/now-3.d: Pass --disable-new-dtags to ld
* testsuite/ld-elf/now-4.d: Likewise.
* testsuite/ld-elf/rpath-1.d: Likewise.
* testsuite/ld-elf/rpath-2.d: Likewise.

7 years agoIntroduce --enable-new-dtags configure option.
Slava Barinov [Sun, 4 Jun 2017 23:57:38 +0000 (09:27 +0930)]
Introduce --enable-new-dtags configure option.

This option switches on ld.bfd --enable-new-dtags by default.

* configure.ac: Add --enable-new-dtags option.
* ldmain.c: Set link_info.new_dtags to 1 if when --enable-new-dtags is
switched on.
* configure: Regenerate.
* config.in: Regenerate.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 5 Jun 2017 00:00:50 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoDocument the GDB 8.0 release in gdb/ChangeLog
Joel Brobecker [Sun, 4 Jun 2017 16:04:09 +0000 (09:04 -0700)]
Document the GDB 8.0 release in gdb/ChangeLog

gdb/ChangeLog:

GDB 8.0 released.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 4 Jun 2017 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agox86-linux-nat: Remove unused arch_lwp_info structure
Simon Marchi [Sat, 3 Jun 2017 20:06:55 +0000 (22:06 +0200)]
x86-linux-nat: Remove unused arch_lwp_info structure

The structure arch_lwp_info for x86 is not used, remove it.

gdb/ChangeLog:

* x86-linux-nat.c (struct arch_lwp_info): Remove.

7 years agolinux-nat: Remove unused parameter
Simon Marchi [Sat, 3 Jun 2017 19:24:00 +0000 (21:24 +0200)]
linux-nat: Remove unused parameter

The parameter "first" of linux_nat_post_attach_wait is unused, remove
it.

gdb/ChangeLog:

* linux-nat.c (linux_nat_post_attach_wait): Remove FIRST
parameter.
(linux_nat_attach): Adjust call to linux_nat_post_attach_wait.

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 3 Jun 2017 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agox86: Remove linker option: -z prefix-nop
H.J. Lu [Fri, 2 Jun 2017 21:49:37 +0000 (14:49 -0700)]
x86: Remove linker option: -z prefix-nop

Since it is incorrect to convert

bnd call *foo@GOTPCREL(%rip)

to

bnd nop
call foo

this patch removes the "-z prefix-nop" option from x86 linker.

* emulparams/call_nop.sh: Remove -z prefix-nop.
* ld.texinfo: Likewise.
* testsuite/ld-i386/call3c.d: Check for linker error.
* testsuite/ld-x86-64/call1c.d: Likewise.

7 years agoUse delete instead of xfree for gdb_timer
Simon Marchi [Fri, 2 Jun 2017 21:24:21 +0000 (23:24 +0200)]
Use delete instead of xfree for gdb_timer

gdb_timer objects are new'ed in create_timer, but xfree'd in
poll_timers.  Use delete instead.

gdb/ChangeLog:

* event-loop.c (poll_timers): Unallocate timer using delete
instead of xfree.

7 years agoC++ify breakpoint class hierarchy (destructors only)
Simon Marchi [Fri, 2 Jun 2017 21:16:21 +0000 (23:16 +0200)]
C++ify breakpoint class hierarchy (destructors only)

Breakpoints are currently in a limbo state between C and C++.  There is
a pseudo class hierarchy implemented using struct fields.  Taking
watchpoint as an example:

  struct watchpoint
  {
    /* The base class.  */
    struct breakpoint base;

    ...
  }

and it is instantianted with "new watchpoint ()".  When destroyed, a
destructor is first invoked through the breakpoint_ops, and then the
memory is freed by calling delete through a pointer to breakpoint.
Address sanitizer complains about this, for example, because we new and
delete the same memory using different types.

This patch takes the logical step of making breakpoint subclasses extend
the breakpoint class for real, and converts their destructors to actual
C++ destructors.

Regtested on the buildbot.

gdb/ChangeLog:

* breakpoint.h (struct breakpoint_ops) <dtor>: Remove.
(struct breakpoint) <~breakpoint>: New.
(struct watchpoint): Inherit from breakpoint.
<~watchpoint>: New.
<base>: Remove.
(struct tracepoint): Inherit from breakpoint.
<base>: Remove.
* breakpoint.c (longjmp_breakpoint_ops): Remove.
(struct longjmp_breakpoint): Inherit from breakpoint.
<~longjmp_breakpoint>: New.
<base>: Remove.
(new_breakpoint_from_type): Remove casts.
(watchpoint_in_thread_scope): Remove reference to base field.
(watchpoint_del_at_next_stop): Likewise.
(update_watchpoint): Likewise.
(watchpoint_check): Likewise.
(bpstat_check_watchpoint): Likewise.
(set_longjmp_breakpoint): Likewise.
(struct fork_catchpoint): Inherit from breakpoint.
<base>: Remove.
(struct solib_catchpoint): Inherit from breakpoint.
<~solib_catchpoint>: New.
<base>: Remove.
(dtor_catch_solib): Change to ...
(solib_catchpoint::~solib_catchpoint): ... this.
(breakpoint_hit_catch_solib): Remove reference to base field.
(add_solib_catchpoint): Likewise.
(create_fork_vfork_event_catchpoint): Likewise.
(struct exec_catchpoint): Inherit from breakpoint.
<~exec_catchpoint>: New.
<base>: Remove.
(dtor_catch_exec): Change to ...
(exec_catchpoint::~exec_catchpoint): ... this.
(dtor_watchpoint): Change to ...
(watchpoint::~watchpoint): ... this.
(watch_command_1): Remove reference to base field.
(catch_exec_command_1): Likewise.
(base_breakpoint_dtor): Change to ...
(breakpoint::~breakpoint): ... this.
(base_breakpoint_ops): Remove dtor field value.
(longjmp_bkpt_dtor): Change to ...
(longjmp_breakpoint::~longjmp_breakpoint): ... this.
(strace_marker_create_breakpoints_sal): Remove reference to base
field.
(delete_breakpoint): Don't manually call breakpoint destructor.
(create_tracepoint_from_upload): Remove reference to base field.
(trace_pass_set_count): Likewise.
(initialize_breakpoint_ops): Don't initialize
momentary_breakpoint_ops, don't set dtors.
* ada-lang.c (struct ada_catchpoint): Inherit from breakpoint.
<~ada_catchpoint>: New.
<base>: Remove.
(create_excep_cond_exprs): Remove reference to base field.
(dtor_exception): Change to ...
(ada_catchpoint::~ada_catchpoint): ... this.
(dtor_catch_exception): Remove.
(dtor_catch_exception_unhandled): Remove.
(dtor_catch_assert): Remove.
(create_ada_exception_catchpoint): Remove reference to base
field.
(initialize_ada_catchpoint_ops): Don't set dtors.
* break-catch-sig.c (struct signal_catchpoint): Inherit from
breakpoint.
<~signal_catchpoint>: New.
<base>: Remove.
(signal_catchpoint_dtor): Change to ...
(signal_catchpoint::~signal_catchpoint): ... this.
(create_signal_catchpoint): Remove reference to base field.
(initialize_signal_catchpoint_ops): Don't set dtor.
* break-catch-syscall.c (struct syscall_catchpoint): Inherit
from breakpoint.
<~syscall_catchpoint>: New.
<base>: Remove.
(dtor_catch_syscall): Change to ...
(syscall_catchpoint::~syscall_catchpoint): ... this.
(create_syscall_event_catchpoint): Remove reference to base
field.
(initialize_syscall_catchpoint_ops): Don't set dtor.
* break-catch-throw.c (struct exception_catchpoint): Inherit
from breakpoint.
<~exception_catchpoint>: New.
<base>: Remove.
(dtor_exception_catchpoint): Change to ...
(exception_catchpoint::~exception_catchpoint): ... this.
(handle_gnu_v3_exceptions): Remove reference to base field.
(initialize_throw_catchpoint_ops): Don't set dtor.
* ctf.c (ctf_get_traceframe_address): Remove reference to base
field.
* remote.c (remote_get_tracepoint_status): Likewise.
* tracefile-tfile.c (tfile_get_traceframe_address): Likewise.
* tracefile.c (tracefile_fetch_registers): Likewise.
* tracepoint.c (actions_command): Likewise.
(validate_actionline): Likewise.
(tfind_1): Likewise.
(get_traceframe_location): Likewise.
(find_matching_tracepoint_location): Likewise.
(parse_tracepoint_status): Likewise.
* mi/mi-cmd-break.c (mi_cmd_break_passcount): Likewise.

7 years agoCreate struct type for longjmp breakpoint
Simon Marchi [Fri, 2 Jun 2017 21:16:20 +0000 (23:16 +0200)]
Create struct type for longjmp breakpoint

The longjmp kind of breakpoint has a destructor, but doesn't have an
associated structure.  The next patch converts breakpoint destructors from
breakpoint_ops::dtor to actual destructors, but to do that it is needed
for longjmp_breakpoint to have a structure that will contain such
destructor.  This patch adds it.

According to initialize_breakpoint_ops, a longjmp breakpoint derives
from "momentary breakpoints", so eventually a momentary_breakpoint
struct/class should probably be created.  It's not necessary for the
destructor though, so a structure type for this abstract kind of
breakpoint can be added when we fully convert breakpoint ops into
methods of the breakpoint type hierarchy.

It is now necessary to instantiate different kinds of breakpoint objects
in set_raw_breakpoint_without_location based on bptype (sometimes a
breakpoint, sometimes a longjmp_breakpoint), so it now uses
new_breakpoint_from_type to do that.  I also changed set_raw_breakpoint
to use it, even though I don't think that it can ever receive a bptype
that actually requires it.  However, I think it's good if all breakpoint
object instantion is done in a single place.

gdb/ChangeLog:

* breakpoint.c (struct longjmp_breakpoint): New struct.
(is_tracepoint_type): Change return type to bool.
(is_longjmp_type): New function.
(new_breakpoint_from_type): Handle longjmp kinds of breakpoints.
(set_raw_breakpoint_without_location): Use
new_breakpoint_from_type.
(set_raw_breakpoint): Likewise.

7 years agoIntroduce and use new_breakpoint_from_type
Simon Marchi [Fri, 2 Jun 2017 21:16:19 +0000 (23:16 +0200)]
Introduce and use new_breakpoint_from_type

This is a small preparatory patch to factor out a snippet that appears
twice.  More kinds of breakpoints will need to be created based on
bptype, so I think it's a good idea to centralize the instantiation of
breakpoint objects.

gdb/ChangeLog:

* breakpoint.c (new_breakpoint_from_type): New function.
(create_breakpoint_sal): Use new_breakpoint_from_type and
unique_ptr.
(create_breakpoint): Likewise.

7 years agoCorrect check for endianness
Michael Eager [Fri, 2 Jun 2017 15:04:59 +0000 (08:04 -0700)]
Correct check for endianness

* interp.c: (target_big_endian): target endianess recognition fix.

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

7 years agoCorrect ChangeLog entry date.
John Baldwin [Thu, 1 Jun 2017 16:47:31 +0000 (09:47 -0700)]
Correct ChangeLog entry date.

7 years agoUse the ELF class to determine the word size for FreeBSD core notes.
John Baldwin [Thu, 1 Jun 2017 16:40:46 +0000 (09:40 -0700)]
Use the ELF class to determine the word size for FreeBSD core notes.

FreeBSD ELF cores contain data structures with that have two different
layouts: one for ILP32 platforms and a second for LP64 platforms.
Previously, the code used 'bits_per_word' from 'arch_info', but this
field is not a reliable indicator of the format for FreeBSD MIPS cores
in particular.

I had originally posted this patch back in November because process
cores for FreeBSD MIPS contained an e_flags value of 0 in the header
which resulted in a bfd_arch which always had 'bits_per_word' set to
32.  This permitted reading o32 cores, but not n64 cores.  The feedback
I received then was to try to change n64 cores to use a different
default bfd_arch that had a 64-bit 'bits_per_word' when e_flags was zero.
I submitted a patch to that effect but it was never approved.  Instead,
I changed FreeBSD's kernel and gcore commands to preserve the e_flags
field from an executable when generating process cores.  With a proper
e_flags field in process cores, n64 cores now use a 64-bit bfd_arch and
now work fine.  However, the change to include e_flags in the process
cores had the unintended side effect of breaking handling of o32
process cores.  Specifically, FreeBSD MIPS builds o32 with a default
MIPS architecture of 'mips3', thus FreeBSD process cores with a non-zero
e_flags match the 'mips3' bfd_arch which has 64 'bits_per_word'.

From this, it seems that 'bits_per_word' for FreeBSD MIPS is not likely
to ever be completely correct.  However, FreeBSD core dumps do
reliably set the ELF class to ELFCLASS32 for cores using ILP32 and
ELFCLASS64 for cores using LP64.  As such, I think my original patch of
using the ELF class instead of 'bits_per_word' is probably the simplest
and most reliable approach for detecting the note structure layout.

bfd/ChangeLog:

* elf.c (elfcore_grok_freebsd_psinfo): Use ELF header class to
determine structure sizes.
(elfcore_grok_freebsd_prstatus): Likewise.

7 years agoPPC64_OPT_LOCALENTRY
Alan Modra [Fri, 26 May 2017 00:32:29 +0000 (10:02 +0930)]
PPC64_OPT_LOCALENTRY

ELFv2 functions with localentry:0 are those with a single entry point,
ie. global entry == local entry, and that have no requirement on r2 or
r12, and guarantee r2 is unchanged on return.  Such an external
function can be called via the PLT without saving r2 or restoring it
on return, avoiding a common load-hit-store for small functions.   The
optimization is attractive.  The TOC pointer load-hit-store is a major
reason why calls to small functions that need no register saves, or
with shrink-wrap, no register saves on a fast path, are slow on
powerpc64le.

To be safe, this optimization needs ld.so support to check that the
run-time matches link-time function implementation.  If a function
in a shared library with st_other localentry non-zero is called
without saving and restoring r2, r2 will be trashed on return, leading
to segfaults.  For that reason the optimization does not happen for
weak functions since a weak definition is a fairly solid hint that the
function will likely be overridden.  I'm also not enabling the
optimization by default unless glibc-2.26 is detected, which should
have the ld.so checks implemented.

bfd/
* elf64-ppc.c (struct ppc_link_hash_table): Add has_plt_localentry0.
(ppc64_elf_merge_symbol_attribute): Merge localentry bits from
dynamic objects.
(is_elfv2_localentry0): New function.
(ppc64_elf_tls_setup): Default params->plt_localentry0.
(plt_stub_size): Adjust size for tls_get_addr_opt stub.
(build_tls_get_addr_stub): Use a simpler stub when r2 is not saved.
(ppc64_elf_size_stubs): Leave stub_type as ppc_stub_plt_call for
optimized localentry:0 stubs.
(ppc64_elf_build_stubs): Save r2 in ELFv2 __glink_PLTresolve.
(ppc64_elf_relocate_section): Leave nop unchanged for optimized
localentry:0 stubs.
(ppc64_elf_finish_dynamic_sections): Set PPC64_OPT_LOCALENTRY in
DT_PPC64_OPT.
* elf64-ppc.h (struct ppc64_elf_params): Add plt_localentry0.
include/
* elf/ppc64.h (PPC64_OPT_LOCALENTRY): Define.
ld/
* emultempl/ppc64elf.em (params): Init plt_localentry0 field.
(enum ppc64_opt): New, replacing OPTION_* defines.  Add
OPTION_PLT_LOCALENTRY, and OPTION_NO_PLT_LOCALENTRY.
(PARSE_AND_LIST_*): Support --plt-localentry and --no-plt-localentry.
* testsuite/ld-powerpc/elfv2so.d: Update.
* testsuite/ld-powerpc/powerpc.exp (TLS opt 5): Use --no-plt-localentry.
* testsuite/ld-powerpc/tlsopt5.d: Update.

7 years agoS/390: idte/ipte fixes
Andreas Krebbel [Thu, 1 Jun 2017 11:46:15 +0000 (13:46 +0200)]
S/390: idte/ipte fixes

Later CPU generations added optional operands to the ipte/idte
instructions.  I've added these with:
https://sourceware.org/ml/binutils/2017-05/msg00316.html ... but
supported the optional operands only with the specific hardware
levels.  However, it is more useful to have the optional operands
already in the first versions.  Of course they need to be zero there.

Regression-tested with on s390 and s390x.  Committed to mainline.

Bye,

-Andreas-

opcodes/ChangeLog:

2017-06-01  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.txt: Support the optional parameters with the first
versions of ipte/idte.

gas/ChangeLog:

2017-06-01  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* testsuite/gas/s390/esa-g5.d: Add ipte tests.
* testsuite/gas/s390/esa-g5.s: Likewise.
* testsuite/gas/s390/zarch-z196.d: Remove ipte tests.
* testsuite/gas/s390/zarch-z196.s: Likewise.
* testsuite/gas/s390/zarch-z990.d: Add idte tests.
* testsuite/gas/s390/zarch-z990.s: Likewise.
* testsuite/gas/s390/zarch-zEC12.d: Remove ipte/idte tests.
* testsuite/gas/s390/zarch-zEC12.s: Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 1 Jun 2017 00:00:46 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoRename "mem" related commmands
Simon Marchi [Wed, 31 May 2017 15:09:07 +0000 (17:09 +0200)]
Rename "mem" related commmands

Rename "mem" related commands, so that their naming is consistent with
the <command-name>_command pattern of naming functions that implement
commands.

gdb/ChangeLog:

* memattr.c (mem_info_command): Rename to ...
(info_mem_command): ... this.
(mem_enable_command): Rename to ...
(enable_mem_command): ... this.
(mem_disable_command): Rename to ...
(disable_mem_command): ... this.
(mem_delete_command): Rename to ...
(delete_mem_command): ... this.
(_initialize_mem): Adjust function names.

7 years agoPowerPC64 ld help quoting
Alan Modra [Wed, 31 May 2017 08:40:01 +0000 (18:10 +0930)]
PowerPC64 ld help quoting

* emultempl/ppc64elf.em (plt-static-chain help): Fix quoting.

7 years agobtrace: support decoder events
Markus Metzger [Mon, 21 Nov 2016 13:27:57 +0000 (14:27 +0100)]
btrace: support decoder events

Newer versions of libipt support instruction flow decoder events instead of
indicating those events with flags in struct pt_insn.  Add support for them in
GDB.

gdb/
* btrace.c (handle_pt_insn_events): New.
(ftrace_add_pt): Call handle_pt_insn_events.  Rename ERRCODE into
STATUS.  Split into this and ...
(handle_pt_insn_event_flags): ... this.

7 years agoconfig, btrace: check for pt_insn_event in libipt
Markus Metzger [Mon, 21 Nov 2016 10:46:15 +0000 (11:46 +0100)]
config, btrace: check for pt_insn_event in libipt

Version 2 of libipt adds an event system to instruction flow decoders and
deprecates indicating events via flags in struct pt_insn.  Add configuration
checks to determine which version we have.

gdb/
* configure.ac: Check for pt_insn_event, struct pt_insn.enabled,
and struct pt_insn.resynced.
* configure: Regenerated.
* config.in: Regenerated.

7 years agoAvoid compilation warning on MinGW in xstrndup
Eli Zaretskii [Wed, 31 May 2017 06:44:08 +0000 (09:44 +0300)]
Avoid compilation warning on MinGW in xstrndup

libiberty/ChangeLog:

2017-05-31  DJ Delorie  <dj@redhat.com>

* configure.ac (strnlen): Add to AC_CHECK_DECLS.
* configure: Likewise.
* config.in: Add HACE_DECL_STRNLEN.

7 years agoMake libiberty/waitpid.c compile without warnings on MinGW
Eli Zaretskii [Wed, 31 May 2017 06:37:48 +0000 (09:37 +0300)]
Make libiberty/waitpid.c compile without warnings on MinGW

libiberty/ChangeLog:

2017-05-31  Eli Zaretskii  <eliz@gnu.org>

* waitpid.c (wait) [__MINGW32__]: Define as a macro
that calls _cwait, so that this function works on MinGW.

7 years agoFix MinGW compilation warnings due to environ.h
Eli Zaretskii [Wed, 31 May 2017 06:35:07 +0000 (09:35 +0300)]
Fix MinGW compilation warnings due to environ.h

include/ChangeLog:

2017-05-31  Eli Zaretskii <eliz@gnu.org>

* environ.h: Add #ifndef guard.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 31 May 2017 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFix calculation of R_ARM_RHM_ALU_PREL_11_0 relocation when used with a SUB instruction.
Casey Smith [Tue, 30 May 2017 14:07:56 +0000 (15:07 +0100)]
Fix calculation of R_ARM_RHM_ALU_PREL_11_0 relocation when used with a SUB instruction.

PR ld/21523
* elf32-arm.c (elf32_arm_final_link_relocate): Install an absolute
value when processing the R_ARM_THM_ALU_PREL_11_0 reloc.

7 years ago[ARC] Allow CPU to be enforced via disassemble_info options
Anton Kolesov [Thu, 16 Mar 2017 12:21:31 +0000 (15:21 +0300)]
[ARC] Allow CPU to be enforced via disassemble_info options

Currently print_insn_arc relies on BFD mach and ELF private headers to
distinguish between various ARC architectures.  Sometimes those values are not
correct or available, mainly in the case of debugging targets without and ELF
file available.  Changing a BFD mach is not a problem for the debugger, because
this is a generic BFD field, and GDB, for example, already sets it according to
information provided in XML target description or specified via GDB 'set arch'
command.  However, things are more complicated for ELF private headers, since
it requires existing of an actual ELF file.  To workaround this problem this
patch allows CPU model to be specified via disassemble info options.  If CPU is
specified in options, then it will take a higher precedence than whatever might
be specified in ELF file.

This is mostly needed for ARC EM and ARC HS, because they have the same
"architecture" (mach) ARCv2 and differ in their private ELF headers.  Other ARC
architectures can be distinguished between each other purely via "mach" field.

Proposed disassemble option format is "cpu=<CPU>", where CPU can be any valid
ARC CPU name as supported by GAS.  Note that this creates a seeming redundancy
with objdump -m/--architecture option, however -mEM and -mHS still result in
"ARCv2" architecture internally, while -Mcpu={HS,EM} would have an actual
effect on disassembler.

opcodes/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* arc-dis.c (enforced_isa_mask): Declare.
(cpu_types): Likewise.
(parse_cpu_option): New function.
(parse_disassembler_options): Use it.
(print_insn_arc): Use enforced_isa_mask.
(print_arc_disassembler_options): Document new options.

binutils/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* doc/binutils.texi: Document new cpu=... disassembler options for ARC.

7 years ago[ARC] Add arc-cpu.def with processor definitions
Anton Kolesov [Fri, 7 Apr 2017 14:22:39 +0000 (17:22 +0300)]
[ARC] Add arc-cpu.def with processor definitions

This patch extracts ARC CPU definitions from gas/config/tc-arc.c (cpu_types)
into a separate file arc-cpu.def.  This will allow reuse of CPU type definition
in multiple places where it might be needed, for example in disassembler.  This
will help ensure that gas and disassembker use same option values for CPUs.

arc-cpu.def file relies on preprocessor macroses which are defined somewhere
else.  This for example multiple C files to include arc-cpu.def, but define
different macroses, therefore creating different structures.

include/ChangeLog:
yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* elf/arc-cpu.def: New file.

gas/ChangeLog:
yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* config/tc-arc.c (cpu_types): Include arc-cpu.def

Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
7 years ago[ARC] Implement compatible function for ARC BFD architectures
Anton Kolesov [Fri, 17 Mar 2017 15:37:42 +0000 (18:37 +0300)]
[ARC] Implement compatible function for ARC BFD architectures

The general rule for bfd_arch_info_type->compatible (A, B) is that if A and B
are compatible, then this function should return architecture that is more
"feature-rich", that is, can run both A and B.  ARCv2, EM and HS all has same
mach number, so bfd_default_compatible assumes they are the same, and returns
an A.  That causes issues with GDB, because GDB assumes that if machines are
compatible, then "compatible ()" always returns same machine regardless of
argument order.  As a result GDB gets confused because, for example,
compatible(ARCv2, EM) returns ARCv2, but compatible(EM, ARCv2) returns EM,
hence GDB is not sure if they are compatible and prints a warning.

bfd/ChangeLog:

yyyy-mm-dd  Anton Kolesov  Anton.Kolesov@synopsys.com

 cpu-arc.c (arc_compatible): New function.

7 years ago[ARC] Remove duplicate ARC600 entry
Anton Kolesov [Fri, 17 Mar 2017 13:43:31 +0000 (16:43 +0300)]
[ARC] Remove duplicate ARC600 entry

ARC600 is already defined as the head of the bfd_arch_arc.

bfd/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* cpu-arc.c (arch_info_struct): Remove duplicate ARC600 entry.

7 years agoAdd bfd_get_file_size to get archive element size
H.J. Lu [Tue, 30 May 2017 13:34:05 +0000 (06:34 -0700)]
Add bfd_get_file_size to get archive element size

We can't use stat() to get archive element size.  Add bfd_get_file_size
to get size for both normal files and archive elements.

bfd/

PR binutils/21519
* bfdio.c (bfd_get_file_size): New function.
* bfd-in2.h: Regenerated.

binutils/

PR binutils/21519
* objdump.c (dump_relocs_in_section): Replace get_file_size
with bfd_get_file_size to get archive element size.
* testsuite/binutils-all/objdump.exp (test_objdump_f): New
proc.
(test_objdump_h): Likewise.
(test_objdump_t): Likewise.
(test_objdump_r): Likewise.
(test_objdump_s): Likewise.
Add objdump tests on archive.

7 years agobtrace: Store function segments as objects.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Store function segments as objects.

7 years agobtrace: Remove bfun_s vector.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Remove bfun_s vector.

7 years agobtrace: Replace struct btrace_function::segment.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Replace struct btrace_function::segment.

This used to hold a pair of pointers to the previous and next function segment
that belong to this function call.  Replace with a pair of indices into the
vector of function segments.

7 years agobtrace: Remove struct btrace_function::flow.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Remove struct btrace_function::flow.

This used to hold a pair of pointers to the previous and next function segment
in execution flow order.  It is no longer necessary as the previous and next
function segments now are simply the previous and next elements in the vector
of function segments.

7 years agobtrace: Replace struct btrace_function::up.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Replace struct btrace_function::up.

This used to hold a function segment pointer.  Change it to hold an index into
the vector of function segments instead.

7 years agobtrace: Remove struct btrace_thread_info::{begin,end}.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Remove struct btrace_thread_info::{begin,end}.

These are no longer needed and might hold invalid addresses once we change the
vector of function segment pointers into a vector of function segment objects
where a reallocation of the vector changes the address of its elements.

7 years agobtrace: Remove constant arguments.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Remove constant arguments.

7 years agobtrace: Use function segment index in insn iterator.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Use function segment index in insn iterator.

Remove FUNCTION pointer in struct btrace_insn_iterator and use an index into
the list of function segments instead.

7 years agobtrace: Use function segment index in call iterator.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Use function segment index in call iterator.

Remove FUNCTION pointer in struct btrace_call_iterator and use an index into
the list of function segments instead.

7 years agobtrace: Add btinfo to instruction interator.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Add btinfo to instruction interator.

This will serve as the access path to the vector of function segments once
the FUNCTION pointer in struct btrace_insn_iterator is removed.

7 years agobtrace: Transfer ownership of pointers.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Transfer ownership of pointers.

Directly insert new btrace_function pointers into the vector and have the
vector own these pointers.  This allows us to later retrieve these objects by
their number directly after creation whereas at the moment we have to wait
until the vector is fully populated.

This requires to pull btrace_thread_info through different functions but
cleans up the code for freeing the trace.

7 years agobtrace: Use std::vector in struct btrace_thread_information.
Tim Wiederhake [Tue, 30 May 2017 10:47:37 +0000 (12:47 +0200)]
btrace: Use std::vector in struct btrace_thread_information.

7 years agoS/390: Fix indentation
Andreas Krebbel [Tue, 30 May 2017 10:04:10 +0000 (12:04 +0200)]
S/390: Fix indentation

gas/ChangeLog:

2017-05-30  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* config/tc-s390.c (md_gather_operands): Fix indentation.

7 years agoFix NEWS formatting in GDB 8.0 section
Simon Marchi [Tue, 30 May 2017 09:29:57 +0000 (11:29 +0200)]
Fix NEWS formatting in GDB 8.0 section

Change the GDB 8.0 section of the NEWS file to try to follow this order:

  * Functional changes
  * Added and removed configurations and targets
  * New commands
  * New options
  * MI changes

In particular, there were two "New commands" sections.

gdb/ChangeLog:

* NEWS (Changes in GDB 8.0): Remove extra empty line.  Move
"Removed targets and native configurations" up.  Merge duplicate
"New commands" sub-sections.  Add "New options" sub-sections.

7 years agogdb.base/watch-cond-infcall.exp: Don't run if target doesn't support infcalls
Simon Marchi [Tue, 30 May 2017 09:24:52 +0000 (11:24 +0200)]
gdb.base/watch-cond-infcall.exp: Don't run if target doesn't support infcalls

This test requires calling a function in the inferior, and therefore it
doesn't make sense to run it if the target doesn't support calling
functions from GDB.

gdb/testsuite/ChangeLog:

* gdb.base/watch-cond-infcall.exp: Don't run if target doesn't
support function calls from GDB.

7 years agoS/390: Fix instruction types of csdtr and csxtr
Andreas Krebbel [Mon, 29 May 2017 10:38:42 +0000 (12:38 +0200)]
S/390: Fix instruction types of csdtr and csxtr

opcodes/ChangeLog:

2017-05-30  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.c: Add new instruction types RRF_0URF and RRF_0UREFE.
* s390-opc.txt: Fix instruction typs of csdtr and csxtr.

gas/ChangeLog:

2017-05-30  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* testsuite/gas/s390/zarch-z9-ec.d: Adjust csdtr and csxtr.
* testsuite/gas/s390/zarch-z9-ec.s: Likewise.

7 years agoS/390: Add missing operand to tb instruction
Andreas Krebbel [Mon, 29 May 2017 10:38:11 +0000 (12:38 +0200)]
S/390: Add missing operand to tb instruction

gas/ChangeLog:

2017-05-30  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* testsuite/gas/s390/esa-g5.d: Add missing operand to tb
instruction.
* testsuite/gas/s390/esa-g5.s: Likewise.

opcodes/ChangeLog:

2017-05-30  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.txt: Add missing operand to tb instruction.