binutils-gdb.git
6 years agoAdd the Netronome Flow Processor as a build target to the top-level configure.ac...
Francois H. Theron [Tue, 1 May 2018 15:23:21 +0000 (16:23 +0100)]
Add the Netronome Flow Processor as a build target to the top-level configure.ac file.

* configure.ac: Added "nfp" target.
* configure: Regenerate.

6 years agorust: Fix null deref when casting (PR 23124)
Dan Robertson [Sat, 28 Apr 2018 03:18:00 +0000 (03:18 +0000)]
rust: Fix null deref when casting (PR 23124)

Fix a null dereference when casting a value to a unit type.

ChangeLog
2018-04-28  Dan Robertson  <danlrobertson89@gmail.com>

PR rust/23124
* gdb/rust-exp.y (convert_params_to_types): Ensure that the params
pointer is not null before dereferencing it.

testsuite/ChangeLog
2018-04-28  Dan Robertson  <danlrobertson89@gmail.com>

PR rust/23124
* gdb.rust/expr.exp: Test that the unit type is correctly parsed
when casting.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 1 May 2018 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years ago[Ada/ravenscar] error during "continue" after task/thread switch
Joel Brobecker [Mon, 30 Apr 2018 22:05:42 +0000 (17:05 -0500)]
[Ada/ravenscar] error during "continue" after task/thread switch

When debugging a program using the Ada ravenscar profile, resuming
a program's execution after having switched to a different task
sometimes yields the following error:

     (gdb) cont
     Continuing.
     Cannot execute this command while the target is running.
     Use the "interrupt" command to stop the target
     and then try again.

In short, the Ravenscar profile is a standardized subset of Ada which
allows tasking (often mapped to threads). We often use it on baremetal
targets where there is no OS support. Thread support is implemented
as a thread target_ops layer. It sits on top of the "remote" layer,
so we can do thread debugging against baremetal targets to which GDB
is connected via "target remote".

What happens, when the user request the program to resume execution,
is the following:

  - the ravenscar-thread target_ops layer gets the order to resume
    the program's execution. The current thread is not the active
    thread in the inferior, and the "remote" layer doesn't know
    about that thread anyway. So what we do is (see ravenscar_resume):

       + switch inferior_ptid to the ptid of the actually active thread;
       + ask the layer beneath us to actually do the resume.

  - Once that's done, the resuming itself is done. But execute_command
    (in top.c) actually does a bit more. More precisely, it unconditionally
    checks to see if the language may no longer be matching the current
    frame:

        check_frame_language_change ();

The problem, here, is that we haven't received the "stop" event
from the inferior, yet. This part will be handled by the event loop,
which is done later. So, checking for the language-change here
doesn't make sense, since we don't really have a frame. In our
case, the error comes from the fact that we end up trying to read
the registers, which causes the error while the remote protocol
is waiting for the event showing the inferior stopped.

This apparently used to work, but it is believed that this was only
accidental. In other words, we had enough information already cached
within GDB that we were able to perform the entire call to
check_frame_language_change without actually querying the target.
On PowerPC targets, this started to fail as a side-effect of a minor
change in the way we get to the regcache during the handling of
software-single-step (which seems fine).

This patch fixes the issue by only calling check_frame_language_change
in cases the inferior isn't running. Otherwise, it skips it, knowing
that the event loop should eventually get to it.

gdb/ChangeLog:

        * top.c (execute_command): Do not call check_frame_language_change
        if the inferior is running.

Tested on x86_64-linux, no regression. Also tested on aarch64-elf,
arm-elf, leon3-elf, and ppc-elf, but using AdaCore's testsuite.

6 years agoRemove a use of is_mi_like_p from darwin-nat-info.c
Tom Tromey [Mon, 30 Apr 2018 02:53:38 +0000 (20:53 -0600)]
Remove a use of is_mi_like_p from darwin-nat-info.c

This removes a use of is_mi_like_p from darwin-nat-info.c.
This is not needed because MI already ignores ui_out::text.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* darwin-nat-info.c (darwin_debug_regions_recurse): Remove use of
is_mi_like_p.

6 years agoRemove some is_mi_like_p from breakpoint code
Tom Tromey [Mon, 30 Apr 2018 02:52:26 +0000 (20:52 -0600)]
Remove some is_mi_like_p from breakpoint code

This removes some uses of is_mi_like_p from the breakpoint code.  The
break-catch-throw.c change brings it into line with what other
breakpoint classes do.  The other changes simply replace printf calls
with ui_out::text or ui_out::message calls.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* breakpoint.c (mention): Remove use of is_mi_like_p.
(print_mention_ranged_breakpoint): Likewise.
* break-catch-throw.c (print_it_exception_catchpoint): Remove use
of is_mi_like_p.

6 years agoRemove a use of is_mi_like_p from tracepoint.c
Tom Tromey [Mon, 30 Apr 2018 02:50:43 +0000 (20:50 -0600)]
Remove a use of is_mi_like_p from tracepoint.c

This removes a use of is_mi_like_p and changes a printf_filtered into
a call to ui_out::text.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* tracepoint.c (tvariables_info_1): Remove use of is_mi_like_p.

6 years agoRemove some uses of is_mi_like_p from spu-tdep.c
Tom Tromey [Sun, 29 Apr 2018 04:39:08 +0000 (22:39 -0600)]
Remove some uses of is_mi_like_p from spu-tdep.c

There were a few spots in spu-tdep.c where a use of is_mi_like_p was
not needed.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* spu-tdep.c (info_spu_mailbox_list, info_spu_dma_cmdlist)
(info_spu_event_command): Remove some uses of is_mi_like_p.

6 years agoRemove some uses of is_mi_like_p from py-framefilter.c
Tom Tromey [Sun, 29 Apr 2018 04:30:08 +0000 (22:30 -0600)]
Remove some uses of is_mi_like_p from py-framefilter.c

Some uses of is_mi_like_p in py-framefilter.c were not needed.  In
general a call to ui_out::text, ui_out::message, or ui_out::spaces
does not need to be guarded -- these are already ignored by MI.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* python/py-framefilter.c (py_print_single_arg)
(enumerate_locals, py_print_args, py_print_frame): Remove some
uses of is_mi_like_p.

6 years agoMake do_is_mi_like_p const.
Tom Tromey [Tue, 24 Apr 2018 02:52:36 +0000 (20:52 -0600)]
Make do_is_mi_like_p const.

This changes ui_out to make is_mi_like_p and do_is_mi_like_p "const".

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* ui-out.c: Update.
* cli-out.h (cli_ui_out::do_is_mi_like_p): Update.
* ui-out.h (ui_out::is_mi_like_p): Now const.
(ui_out::do_is_mi_like_p): Now const.
* mi/mi-out.h (mi_ui_out::do_is_mi_like_p): Update.

6 years agoChange Python code to use new_reference
Tom Tromey [Mon, 30 Apr 2018 03:09:02 +0000 (21:09 -0600)]
Change Python code to use new_reference

This changes a few spots in the Python code to use new_reference
rather than the manual incref+constructor that was previously being
done.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* varobj.c (varobj_set_visualizer): Use new_reference.
* python/python.c (gdbpy_decode_line): Use new_reference.
* python/py-cmd.c (cmdpy_function, cmdpy_completer_helper): Use
new_reference.

6 years agoUse new_reference for struct value
Tom Tromey [Mon, 30 Apr 2018 03:07:03 +0000 (21:07 -0600)]
Use new_reference for struct value

value_incref returned its argument just as a convenience, which in the
end turned out to only be used in precisely the cases where
new_reference helps.  So, this patch changes value_incref to return
void and changes some value-using code to use new_reference.

I also noticed that the comments for value_incref and value_decref
were swapped, so this patch fixes those.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* varobj.c (install_new_value): Use new_reference.
* value.h (value_incref): Return void.  Swap intro comment with
value_decref.
* value.c (set_value_parent): Use new_reference.
(value_incref): Return void.  Update intro comment.
(release_value): Use new_reference.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Use new_reference.

6 years agoRemove new_bfd_ref
Tom Tromey [Mon, 30 Apr 2018 03:02:19 +0000 (21:02 -0600)]
Remove new_bfd_ref

For gdb_bfd_ref_ptr, gdb already had a convenience function like the
new gdb_ref_ptr::new_reference -- called new_bfd_ref.  This patch
removes it in favor of the new common function.

While doing this I also noticed that the comment for gdb_bfd_open was
incorrect (in a way related to reference counting), so this patch
updates the comment as well.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* symfile-mem.c (symbol_file_add_from_memory): Use new_reference.
* gdb_bfd.h (new_bfd_ref): Remove.
(gdb_bfd_open): Update comment.
* gdb_bfd.c (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
(gdb_bfd_openw, gdb_bfd_openr_iovec, gdb_bfd_record_inclusion)
(gdb_bfd_fdopenr): Use new_reference.
* exec.c (exec_file_attach): Use new_reference.

6 years agoIntroduce ref_ptr::new_reference
Tom Tromey [Mon, 30 Apr 2018 02:59:21 +0000 (20:59 -0600)]
Introduce ref_ptr::new_reference

I noticed a common pattern with gdb::ref_ptr, where callers would
"incref" and then create a new wrapper object, like:

    Py_INCREF (obj);
    gdbpy_ref<> ref (obj);

The ref_ptr constructor intentionally does not acquire a new
reference, but it seemed to me that it would be reasonable to add a
static member function that does so.

In this patch I chose to call the function "new_reference".  I
considered "acquire_reference" as well, but "new" seemed less
ambiguous than "acquire" to me.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* common/gdb_ref_ptr.h (ref_ptr::new_reference): New static
method.

6 years agoRemove long_long_align_bit gdbarch attribute
Tom Tromey [Mon, 23 Apr 2018 19:41:27 +0000 (13:41 -0600)]
Remove long_long_align_bit gdbarch attribute

This removes the long_long_align_bit gdbarch attribute in favor of
type_align.  This uncovered two possible issues.

First, arc-tdep.c claimed that long long alignment was 32 bits, but as
discussed on the list, ARC has a maximum alignment of 32 bits, so I've
added an arc_type_align function to account for this.

Second, jit.c, the sole user of long_long_align_bit, was confusing
"long long" with uint64_t.  The relevant structure is defined in the
JIT API part of the manual as:

     struct jit_code_entry
     {
       struct jit_code_entry *next_entry;
       struct jit_code_entry *prev_entry;
       const char *symfile_addr;
       uint64_t symfile_size;
     };

I've changed this code to use uint64_t.

2018-04-30  Tom Tromey  <tom@tromey.com>

* jit.c (jit_read_code_entry): Use type_align.
* i386-tdep.c (i386_gdbarch_init): Don't call
set_gdbarch_long_long_align_bit.
* gdbarch.sh: Remove long_long_align_bit.
* gdbarch.c, gdbarch.h: Rebuild.
* arc-tdep.c (arc_type_align): New function.
(arc_gdbarch_init): Use arc_type_align.  Don't call
set_gdbarch_long_long_align_bit.

6 years agoRemove rust_type_alignment
Tom Tromey [Mon, 23 Apr 2018 19:23:02 +0000 (13:23 -0600)]
Remove rust_type_alignment

rust_type_alignment is not needed now that gdb has type alignment
code.  So, this removes it.

2018-04-30  Tom Tromey  <tom@tromey.com>

* rust-lang.c (rust_type_alignment): Remove.
(rust_composite_type): Use type_align.

6 years agoExpose type alignment on gdb.Type
Tom Tromey [Fri, 20 Apr 2018 21:43:56 +0000 (15:43 -0600)]
Expose type alignment on gdb.Type

This adds an "alignof" attribute to gdb.Type in the Python API.

2018-04-30  Tom Tromey  <tom@tromey.com>

* NEWS: Mention Type.align.
* python/py-type.c (typy_get_alignof): New function.
(type_object_getset): Add "alignof".

2018-04-30  Tom Tromey  <tom@tromey.com>

* python.texi (Types In Python): Document Type.align.

2018-04-30  Tom Tromey  <tom@tromey.com>

* gdb.python/py-type.exp: Check align attribute.
* gdb.python/py-type.c: New "aligncheck" global.

6 years agoHandle alignof and _Alignof
Tom Tromey [Fri, 20 Apr 2018 19:40:29 +0000 (13:40 -0600)]
Handle alignof and _Alignof

This adds alignof and _Alignof to the C/C++ expression parser, and
adds new tests to test the features.  The tests are written to try to
ensure that gdb's knowledge of alignment rules stays in sync with the
compiler's.

2018-04-30  Tom Tromey  <tom@tromey.com>

PR exp/17095:
* NEWS: Update.
* std-operator.def (UNOP_ALIGNOF): New operator.
* expprint.c (dump_subexp_body_standard) <case UNOP_ALIGNOF>:
New.
* eval.c (evaluate_subexp_standard) <case UNOP_ALIGNOF>: New.
* c-lang.c (c_op_print_tab): Add alignof.
* c-exp.y (ALIGNOF): New token.
(exp): Add "ALIGNOF" production.
(ident_tokens): Add _Alignof and alignof.

2018-04-30  Tom Tromey  <tom@tromey.com>

PR exp/17095:
* gdb.dwarf2/dw2-align.exp: New file.
* gdb.cp/align.exp: New file.
* gdb.base/align.exp: New file.
* lib/gdb.exp (gdb_int128_helper): New proc.
(has_int128_c, has_int128_cxx): New caching procs.

6 years agoAdd initial type alignment support
Tom Tromey [Fri, 20 Apr 2018 17:50:09 +0000 (11:50 -0600)]
Add initial type alignment support

This adds some basic type alignment support to gdb.  It changes struct
type to store the alignment, and updates dwarf2read.c to handle
DW_AT_alignment.  It also adds a new gdbarch method and updates
i386-tdep.c.

None of this new functionality is used anywhere yet, so tests will
wait until the next patch.

2018-04-30  Tom Tromey  <tom@tromey.com>

* i386-tdep.c (i386_type_align): New function.
(i386_gdbarch_init): Update.
* gdbarch.sh (type_align): New method.
* gdbarch.c, gdbarch.h: Rebuild.
* arch-utils.h (default_type_align): Declare.
* arch-utils.c (default_type_align): New function.
* gdbtypes.h (TYPE_ALIGN_BITS): New define.
(struct type) <align_log2>: New field.
<instance_flags>: Now a bitfield.
(TYPE_RAW_ALIGN): New macro.
(type_align, type_raw_align, set_type_align): Declare.
* gdbtypes.c (type_align, type_raw_align, set_type_align): New
functions.
* dwarf2read.c (quirk_rust_enum): Set type alignment.
(get_alignment, maybe_set_alignment): New functions.
(read_structure_type, read_enumeration_type, read_array_type)
(read_set_type, read_tag_pointer_type, read_tag_reference_type)
(read_subrange_type, read_base_type): Set type alignment.

6 years agoThis patch adds support to objdump for disassembly of NFP (Netronome Flow Processor...
Francois H. Theron [Mon, 30 Apr 2018 16:02:59 +0000 (17:02 +0100)]
This patch adds support to objdump for disassembly of NFP (Netronome Flow Processor) ELF files (.nffw) as well as some basic readelf support.

bfd * Makefile.am: Added NFP files to build.
* archures.c: Added bfd_arch_nfp
* config.bfd: Added NFP support.
* configure.ac: Added NFP support.
* cpu-nfp.c: New, for NFP support.
* elf-bfd.h: Added elf_section_info()
* elf64-nfp.c: New, for NFP support.
* po/SRC-POTFILES.in: Added NFP source files.
* targets.c: Added nfp_elf64_vec
* bfd-in2.h: Regenerate.
* Makefile.in: Regenerate.
* configure: Regenerate.

binutils* readelf.c: Very basic support for EM_NFP and its section types.
* testsuite/binutils-all/nfp: New directory.
* testsuite/binutils-all/nfp/objdump.exp: New file.  Run new
tests.
* testsuite/binutils-all/nfp/test2_ctx8.d: New file.
* testsuite/binutils-all/nfp/test2_no-pc_ctx4.d: New file.
* testsuite/binutils-all/nfp/test1.d: New file.
* testsuite/binutils-all/nfp/nfp6000.nffw: New file.
* testsuite/binutils-all/nfp/test2_nfp6000.nffw: New file.
* NEWS: Mention the new support.

include * dis-asm.h: Added print_nfp_disassembler_options prototype.
* elf/common.h: Added EM_NFP, officially assigned. See Google Group
Generic System V Application Binary Interface.
* elf/nfp.h: New, for NFP support.
* opcode/nfp.h: New, for NFP support.

opcodes Makefile.am: Added nfp-dis.c.
configure.ac: Added bfd_nfp_arch.
disassemble.h: Added print_insn_nfp prototype.
disassemble.c: Added ARCH_nfp and call to print_insn_nfp
nfp-dis.c: New, for NFP support.
po/POTFILES.in: Added nfp-dis.c to the list.
Makefile.in: Regenerate.
configure: Regenerate.

6 years agoUse bool in read_index_from_section
Simon Marchi [Mon, 30 Apr 2018 15:06:57 +0000 (11:06 -0400)]
Use bool in read_index_from_section

gdb/ChangeLog:

* dwarf2read.c (read_index_from_section): Use bool.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 30 Apr 2018 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoproc-events.c: fix compilation on Solaris
Fabian Groffen [Sun, 29 Apr 2018 16:04:54 +0000 (12:04 -0400)]
proc-events.c: fix compilation on Solaris

This patch adds a guard around the usage of SYS_uuidsys, which is
not available on (at least) Solaris 10 and OpenIndiana.

gdb/ChangeLog:

PR gdb/22950
* proc-events.c (init_syscall_table): Guard usage os SYS_uuidsys
with #ifdef.

6 years agoFix race when building ada-lex.c
John Reiser [Sun, 29 Apr 2018 15:57:38 +0000 (11:57 -0400)]
Fix race when building ada-lex.c

Prevent a race when building ada-lex.c, and any target of rules .c:.l or
.c:.y.  The target should be written only at the last step, else SIGINT
(^C) can leave an inconsistent state.  Being .PRECIOUS makes it even
worse.

gdb/ChangeLog:

PR build/22873
* gdb/Makefile.in: (.c:.l, .c:.y): Write the target only in the
last step, and do it atomically.

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 29 Apr 2018 00:01:17 +0000 (00:01 +0000)]
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 28 Apr 2018 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoAdd libcc1 v1 compatibility to C compile feature
Alexandre Oliva [Fri, 27 Apr 2018 18:17:02 +0000 (11:17 -0700)]
Add libcc1 v1 compatibility to C compile feature

This patch adds v1 compatibiltiy to the C compile feature.  The only change
in v1 concerns the handling of integer types, which permits GDB to specify
the built-in name for the type.

As far as I know, the C frontend is still on v0, so this patch is purely
precautionary. [By default C++ compile uses the equivalent of the C
frontend's int_type and float_type (aka the "v1" versions).]

gdb/ChangeLog:

* compile/compile-c-types.c (convert_int, convert_float):
Update for C FE v1.

6 years agoAdd inclusive range support for Rust
Tom Tromey [Thu, 29 Mar 2018 20:14:07 +0000 (14:14 -0600)]
Add inclusive range support for Rust

This is version 2 of the patch to add inclusive range support for
Rust.  I believe it addresses all review comments.

Rust recently stabilized the inclusive range feature:

    https://github.com/rust-lang/rust/issues/28237

An inclusive range is an expression like "..= EXPR" or "EXPR ..=
EXPR".  It is like an ordinary range, except the upper bound is
inclusive, not exclusive.

This patch adds support for this feature to gdb.

Regression tested on x86-64 Fedora 27.

2018-04-27  Tom Tromey  <tom@tromey.com>

PR rust/22545:
* rust-lang.c (rust_inclusive_range_type_p): New function.
(rust_range): Handle inclusive ranges.
(rust_compute_range): Likewise.
* rust-exp.y (struct rust_op) <inclusive>: New field.
(DOTDOTEQ): New constant.
(range_expr): Add "..=" productions.
(operator_tokens): Add "..=" token.
(ast_range): Add "inclusive" parameter.
(convert_ast_to_expression) <case OP_RANGE>: Handle inclusive
ranges.
* parse.c (operator_length_standard) <case OP_RANGE>: Handle new
bounds values.
* expression.h (enum range_type) <NONE_BOUND_DEFAULT_EXCLUSIVE,
LOW_BOUND_DEFAULT_EXCLUSIVE>: New constants.
Update comments.
* expprint.c (print_subexp_standard): Handle new bounds values.
(dump_subexp_body_standard): Likewise.

2018-04-27  Tom Tromey  <tom@tromey.com>

PR rust/22545:
* gdb.rust/simple.exp: Add inclusive range tests.

6 years agoEnable -Wsuggest-override
Tom Tromey [Fri, 27 Apr 2018 04:46:54 +0000 (22:46 -0600)]
Enable -Wsuggest-override

I noticed the existence of -Wsuggest-override and so this patch
enables it for gdb.  It found a few spots that could use "override".
Also I went ahead and removed all uses of the "OVERRIDE" macro.

Using override is beneficial because it makes it harder to change a
base class and then forget to change a derived class.

Tested by the buildbot.

ChangeLog
2018-04-27  Tom Tromey  <tom@tromey.com>

* configure: Rebuild.
* warning.m4 (AM_GDB_WARNINGS): Add -Wsuggest-override.
* dwarf2loc.c (class dwarf_evaluate_loc_desc): Use "override", not
"OVERRIDE".
(class symbol_needs_eval_context): Likewise.
* dwarf2read.c (mock_mapped_index::symbol_name_count)
(mock_mapped_index::symbol_name_at): Use "override".  Remove
"virtual".
* dwarf2-frame.c (dwarf_expr_executor::get_addr_index): Use
"override".
(class dwarf_expr_executor): Use "override", not "OVERRIDE".
* aarch64-tdep.c (instruction_reader::read): Use "override".
(instruction_reader_test::read): Likewise.
* arm-tdep.c (instruction_reader::read): Use "override".
(instruction_reader_thumb::read): Likewise.

gdbserver/ChangeLog
2018-04-27  Tom Tromey  <tom@tromey.com>

* configure: Rebuild.

6 years agoMIPS/LD/testsuite: Update `run_dump_test' cases for non-DSO targets
Maciej W. Rozycki [Fri, 27 Apr 2018 14:25:20 +0000 (15:25 +0100)]
MIPS/LD/testsuite: Update `run_dump_test' cases for non-DSO targets

Mark these `run_dump_test' cases across `ld-mips-elf/mips-elf.exp' that
are run unconditionally and require shared library support for exclusion
for targets that do not have such support, removing these failures:

FAIL: MIPS BAL/JALX in PIC mode
FAIL: microMIPS BAL/JALX in PIC mode
FAIL: MIPS BAL/JALX in PIC mode (ignore branch ISA)
FAIL: microMIPS BAL/JALX in PIC mode (ignore branch ISA)
FAIL: ld-mips-elf/hash1a
FAIL: ld-mips-elf/hash1b
FAIL: ld-mips-elf/hash1c

with `mipsel-ps2-elf' and `mips64el-ps2-elf' targets.  Tests that are
guarded with `linux_gnu' will have to be reviewed separately.

ld/
* testsuite/ld-mips-elf/bal-jalx-pic.d: Only run for
`check_shared_lib_support' targets.
* testsuite/ld-mips-elf/bal-jalx-pic-n32.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-n64.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-micromips.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-micromips-n32.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-micromips-n64.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-n32.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-n64.d: Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips.d:
Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n32.d:
Likewise.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n64.d:
Likewise.
* testsuite/ld-mips-elf/hash1a.d: Likewise.
* testsuite/ld-mips-elf/hash1b.d: Likewise.
* testsuite/ld-mips-elf/hash1c.d: Likewise.
* testsuite/ld-mips-elf/relax-jalr-n32-shared.d: Likewise.
* testsuite/ld-mips-elf/relax-jalr-n64-shared.d: Likewise.

6 years agotestsuite: Support filtering targets by TCL procedure in `run_dump_test'
Maciej W. Rozycki [Fri, 27 Apr 2018 14:25:20 +0000 (15:25 +0100)]
testsuite: Support filtering targets by TCL procedure in `run_dump_test'

Implement a more complex way of selecting targets to include or exclude
with `run_dump_test' cases, by extending the syntax for the `target',
`not-target', `skip' and `not-skip' options (with the binutils and GAS
test suites) and the `target', `alltargets' and `notarget' options (with
the LD test suite) to also accept a name of a TCL procedure instead of a
target triplet glob matching expression.  The result, 1 or 0, of the
procedure determines whether the test is to be run or not.  This mimics
and expands `dg-require-effective-target' from the GCC test suite.

Names of TCL procedures are supplied in square brackets `[]' as with TCL
procedure calls, observing that target triplet glob matching expressions
do not normally start and end with matching square brackets both at a
time.  Arguments for procedures are allowed if required.

Having a way to specify a complex condition for a `run_dump_test' case
to run has the advantage of keeping it local within the test case itself
where tool options related to the check might be also present, removing
the need to wrap `run_dump_test' calls into an `if' block whose only
reason is to do a feature check, and ultimately lets one have the test
reported as UNSUPPORTED automagically if required (not currently
supported by the `run_dump_test' options used for LD).

binutils/
* testsuite/lib/binutils-common.exp (match_target): New procedure.
* testsuite/lib/utils-lib.exp (run_dump_test): Use it in place
of `istarget' for matching with `target', `not-target', `skip'
and `not-skip' options.

gas/
* testsuite/lib/gas-defs.exp (run_dump_test): Use `match_target'
in place of `istarget' for matching with `target', `not-target',
`skip' and `not-skip' options.

ld/
* testsuite/lib/ld-lib.exp (run_dump_test): Use `match_target'
in place of `istarget' for matching with `target', `alltargets'
and `notarget' options.

6 years agoRevert "Enable Intel MOVDIRI, MOVDIR64B instructions."
Igor Tsimbalist [Fri, 27 Apr 2018 12:34:13 +0000 (14:34 +0200)]
Revert "Enable Intel MOVDIRI, MOVDIR64B instructions."

This reverts commit a914a7c95895161c99533d5919b8504b37ea54a0.

6 years agoRegenerate some files for recent ARM patches
Alan Modra [Fri, 27 Apr 2018 09:54:13 +0000 (19:24 +0930)]
Regenerate some files for recent ARM patches

bfd/
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
ld/
* po/BLD-POTFILES.in: Regenerate.

6 years agoPR23123, PowerPC32 ifunc regression
Alan Modra [Fri, 27 Apr 2018 06:16:40 +0000 (15:46 +0930)]
PR23123, PowerPC32 ifunc regression

Two of the gcc ifunc tests fail for ppc32, due to my pr22374 fix being
a little too enthusiastic in trimming PLT entries.  ppc64 doesn't have
the same failures because ppc64_elf_check_relocs happens to set
needs_plt for any ifunc reloc.

PR 23123
PR 22374
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Don't drop plt
relocs for ifuncs.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Comment fixes.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 27 Apr 2018 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoFix remote 'g' command error handling (PR remote/9665)
Andrzej Kaczmarek [Thu, 26 Apr 2018 22:47:25 +0000 (23:47 +0100)]
Fix remote 'g' command error handling (PR remote/9665)

'g' command returns hex-string as response so simply checking for 'E'
to determine if it failed is not enough and can trigger spurious error
messages.  For example, invalid behaviour can be easily triggered on
Cortex-M as follows:

  (gdb) set $r0 = 0xe0
  Sending packet: $P0=e0000000#72...Packet received: OK
  Packet P (set-register) is supported
  Sending packet: $g#67...Packet received: E0000000849A0020...
  Remote failure reply: E0000000849A0020...

This patch fixes the problem by calling putpkt()/getpkt() directly and
checking result with packet_check_result().  This works fine since Enn
response has odd number of bytes while proper response has even number
of bytes.

Also, remote_send() is now not used anywhere so it can be removed.

gdb/Changelog:
2018-04-26  Andrzej Kaczmarek  <andrzej.kaczmarek@codecoup.pl>

PR remote/9665
* remote.c (send_g_packet): Use putpkt/getpkt/packet_check_result
instead of remote_send.
(remote_send): Remove.

6 years agoEnable Intel MOVDIRI, MOVDIR64B instructions.
Igor Tsimbalist [Wed, 25 Apr 2018 15:02:06 +0000 (17:02 +0200)]
Enable Intel MOVDIRI, MOVDIR64B instructions.

gas/
* config/tc-i386.c (cpu_arch): Add .movdir, .movdir64b.
(cpu_noarch): Likewise.
(process_suffix): Add check for register size.
* doc/c-i386.texi: Document movdiri, movdir64b.
* testsuite/gas/i386/i386.exp: Run MOVDIR{I,64B} tests.
* testsuite/gas/i386/movdir-intel.d: New test.
* testsuite/gas/i386/movdir.d: Likewise.
* testsuite/gas/i386/movdir.s: Likewise.
* testsuite/gas/i386/movdir64b-reg.s: Likewise.
* testsuite/gas/i386/movdir64b-reg.l: Likewise.
* testsuite/gas/i386/x86-64-movdir-intel.d: Likewise.
* testsuite/gas/i386/x86-64-movdir.d: Likewise.
* testsuite/gas/i386/x86-64-movdir.s: Likewise.
* testsuite/gas/i386/x86-64-movdir64b-reg.s: Likewise.
* testsuite/gas/i386/x86-64-movdir64b-reg.l: Likewise.

opcodes/
* i386-dis.c (enum): Add PREFIX_0F38F8, PREFIX_0F38F9.
(prefix_table): New instructions (see prefix above).
Add Gva macro and handling in OP_G.
* i386-gen.c (cpu_flag_init): Add CPU_MOVDIRI_FLAGS,
CPU_MOVDIR64B_FLAGS.
(cpu_flags): Likewise.
(opcode_modifiers): Add AddrPrefixOpReg.
(i386_opcode_modifier): Likewise.
* i386-opc.h (enum): Add CpuMOVDIRI, CpuMOVDIR64B.
(i386_cpu_flags): Likewise.
* i386-opc.tbl: Add movidir{i,64b}.
* i386-init.h: Regenerate.
* i386-tbl.h: Likewise.

6 years agoExtend the assembler so that it can automatically generate GNU Build attribute notes...
Nick Clifton [Thu, 26 Apr 2018 14:12:42 +0000 (15:12 +0100)]
Extend the assembler so that it can automatically generate GNU Build attribute notes if none are present in the input files.

gas * as.c (flag_generate_build_notes): New variable.
(show_usage): Add entry for --generate-missing-build-notes.
(parse_args): Parse --generate-missing-build-notes.
* as.h: Export flag_generate_build_notes.
* symbols.c (save_symbol_name): Ensure that the name parameter is
not NULL.
* write.c (create_obj_attrs_section): Reformat.
(create_note_reloc): New function - creates a relocation for a
field in a GNU Build attribute note.
(maybe_generate_build_notes): New function - created GNU Build
attribute notes if none are present in the output file.
(write_object_file): Call maybe_generate_build_notes.
* configure.ac (--enable-generate-build-notes): New option.
* NEWS: Announce the new feature.
* doc/as.textinfo: Document the new option.
* config.in: Regenerate.
* configure: Regenerate.

binutils* readelf.c (is_32bit_abs_reloc): Support R_PARISC_DIR32 as a
32-bit absolute reloc for the HPPA target.
* testsuite/binutils-all/note-5.d: New test.
* testsuite/binutils-all/note-5.s: Source file for new test.
* testsuite/binutils-all/objcopy.exp: Run new test.

6 years ago[ld/testsuite] Fix pr2404 output.
Christophe Lyon [Thu, 26 Apr 2018 13:44:33 +0000 (13:44 +0000)]
[ld/testsuite] Fix pr2404 output.

2018-04-26  Christophe Lyon  <christophe.lyon@linaro.org>

* testsuite/ld-elf/pr2404b.c (main): Adjust printf to account for
new variable name.
* testsuite/ld-elf/pr2404.out: Adjust expected output accordingly.

6 years agoFix resolving GNU ifunc bp locations when inferior runs resolver
Pedro Alves [Thu, 26 Apr 2018 12:01:27 +0000 (13:01 +0100)]
Fix resolving GNU ifunc bp locations when inferior runs resolver

I noticed that if you set a breakpoint on an ifunc before the ifunc is
resolved, and then let the program call the ifunc, thus resolving it,
GDB end up with a location for that original breakpoint that is
pointing to the ifunc target, but it is left pointing to the first
address of the function, instead of after its prologue.  After
prologue is what you get if you create a new breakpoint at that point.

1) With no debug info for the target function:

  1.a) Set before resolving, and then program continued passed resolving:

    Num     Type           Disp Enb Address            What
    1       breakpoint     keep y   0x0000000000400753 <final>

  1.b) Breakpoint set after inferior resolved ifunc:

    Num     Type           Disp Enb Address            What
    2       breakpoint     keep y   0x0000000000400757 <final+4>

2) With debug info for the target function:

   1.a) Set before resolving, and then program continued passed resolving:

     Num     Type           Disp Enb Address            What
     1       breakpoint     keep y   0x0000000000400753 in final at gdb/testsuite/gdb.base/gnu-ifunc-final.c:20

   1.b) Breakpoint set after inferior resolved ifunc:

     Num     Type           Disp Enb Address            What
     2       breakpoint     keep y   0x000000000040075a in final at gdb/testsuite/gdb.base/gnu-ifunc-final.c:21

The problem is that elf_gnu_ifunc_resolver_return_stop (called by the
internal breakpoint that traps the resolver returning) does not agree
with linespec.c:minsym_found.  It does not skip to the function's
start line (i.e., past the prologue).  We can now use the
find_function_start_sal overload added by the previous commmit to fix
this.

New tests included, which fail before the patch, and pass afterwards.

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* elfread.c (elf_gnu_ifunc_resolver_return_stop): Use
find_function_start_sal instead of find_pc_line.

gdb/testsuite/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* gdb.base/gnu-ifunc.exp (set-break): Test that GDB resolves
ifunc breakpoint locations correctly of ifunc breakpoints set
while the program resolves the ifunc.

6 years agoExtend GNU ifunc testcases
Pedro Alves [Thu, 26 Apr 2018 12:01:27 +0000 (13:01 +0100)]
Extend GNU ifunc testcases

This patch extends/rewrites the gdb.base/gnu-ifunc.exp testcase to
cover the many different fixes in earlier patches.  (This was actually
what encovered most of the problems.)

The current testcase uses an ifunc symbol with the same name as the
ifunc resolver symbol and makes sure to compile the ifunc resolver
without debug info.  That does not model how ifuncs are implemented in
gcc/ifunc nowadays.  Instead, what we have is that the glibc ifunc
resolvers nowadays are written in C and end up with debug info.

Also, in some cases the ifunc target is written in assembly, but in
other cases it's written in C.  In the case of target function written
in C, if the target function has debug info, when we set a break on
the ifunc, we want to set it past the prologue of the target function.
Currently GDB gets that wrong.

To make sure we cover all the different scenarios, the testcase is
tweaked to cover all the different combinations of

 - An ifunc resolver with the same name as the user-visible symbol vs
   an ifunc resolver with a different name as the user-visible symbol.

 - ifunc resolver compiled with and without debug info.

 - ifunc target function compiled with and without debug info.

The testcase currently sets breakpoints on ifuncs, calls ifunc
functions, steps into ifunc functions, etc.  After this series, this
all works and the testcase passes cleanly.

While working on this, I noticed that "b gnu_ifunc" before and after
the inferior resolved the ifunc would end up with a breakpoint with
different locations.  That's now covered by new tests inside the new
"set-break" procedure.

It also tests other things like making sure we can't call an ifunc
without a return-type case if we don't know the type of the target.
And making sure that we pass enough arguments when we do know the
type.

gdb/testsuite/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* gdb.base/gnu-ifunc-final.c: New file.
* gdb.base/gnu-ifunc.c (final): Delete, moved to gnu-ifunc-final.c.
* gdb.base/gnu-ifunc.exp (executable): Delete.
(staticexecutable): Adjust.
(lib_opts, exec_opts): Delete.
(make_binsuffix, build, set-break): New procedures.
(misc_tests): New, with tests factored out from the top level.
(top level): Test different combinations of ifunc resolver name,
resolver with and with debug info, and ifunc target with and
without debug info.  Wrap static tests with with_target_prefix.

6 years agoPPC64: always make synthetic .text symbols for GNU ifunc symbols
Pedro Alves [Thu, 26 Apr 2018 12:01:27 +0000 (13:01 +0100)]
PPC64: always make synthetic .text symbols for GNU ifunc symbols

If you create an ifunc using GCC's __attribute__ ifunc, like:

 extern int gnu_ifunc (int arg);
 static int gnu_ifunc_target (int arg) { return 0; }
 __typeof (gnu_ifunc) *gnu_ifunc_resolver (unsigned long hwcap) { return gnu_ifunc_target; }
 __typeof (gnu_ifunc) gnu_ifunc __attribute__ ((ifunc ("gnu_ifunc_resolver")));

then you end up with two (function descriptor) symbols, one for the
ifunc itself, and another for the resolver:

   (...)
   12: 0000000000020060    104 FUNC    GLOBAL DEFAULT       18 gnu_ifunc_resolver
   (...)
   16: 0000000000020060    104 GNU_IFUNC GLOBAL DEFAULT       18 gnu_ifunc
   (...)

Both ifunc and resolver symbols have the same address/value, so
ppc64_elf_get_synthetic_symtab only creates a synthetic text symbol
for one of them.  In the case above, it ends up being created for the
resolver, only:

  (gdb) maint print msymbols
  (...)
  [ 7] t 0x980 .frame_dummy section .text
  [ 8] T 0x9e4 .gnu_ifunc_resolver section .text
  [ 9] T 0xa58 __glink_PLTresolve section .text
  (...)

GDB needs to know when a program stepped into an ifunc resolver, so
that it can know whether to step past the resolver into the target
function without the user noticing.  The way GDB does it is my
checking whether the current PC points to an ifunc symbol (since
resolver and ifunc have the same address by design).

The problem is then that ppc64_elf_get_synthetic_symtab never creates
the synchetic symbol for the ifunc, so GDB stops stepping at the
resolver (in a test added by the following patch):

  (gdb) step
  gnu_ifunc_resolver (hwcap=21) at gdb/testsuite/gdb.base/gnu-ifunc-lib.c:33
  33      {
  (gdb) FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=1: final_debug=0: step

After this commit, we get:

  [ 8] i 0x9e4 .gnu_ifunc section .text
  [ 9] T 0x9e4 .gnu_ifunc_resolver section .text

And stepping an ifunc call takes to the final function:
  (gdb) step
  0x00000000100009e8 in .final ()
  (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=1: final_debug=0: step

An alternative to touching bfd I considered was for GDB to check
whether there's an ifunc data symbol / function descriptor that points
to the current PC, whenever the program stops, but discarded it
because we'd have to do a linear scan over .opd over an over to find a
matching function descriptor for the current PC.  At that point I
considered caching that info, but quickly dismissed it as then that
has no advantage (memory or performance) over just creating the
synthetic ifunc text symbol in the first place.

I ran the binutils and ld testsuites on PPC64 ELFv1 (machine gcc110 on
the GCC compile farm), and saw no regressions.  This commit is part of
a GDB patch series that includes GDB tests that fail without this fix.

bfd/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Don't consider
ifunc and non-ifunc symbols duplicates.

6 years agoFor PPC64/ELFv1: Introduce mst_data_gnu_ifunc
Pedro Alves [Thu, 26 Apr 2018 12:01:27 +0000 (13:01 +0100)]
For PPC64/ELFv1: Introduce mst_data_gnu_ifunc

Running the new tests added later in the series on PPC64 (ELFv1)
revealed that the current ifunc support needs a bit of a design rework
to work properly on PPC64/ELFv1, as most of the new tests fail.  The
ifunc support only kind of works today if the ifunc symbol and the
resolver have the same name, as is currently tested by the
gdb.base/gnu-ifunc.exp testcase, which is unlike how ifuncs are
written nowadays.

The crux of the problem is that ifunc symbols are really function
descriptors, not text symbols:

   44: 0000000000020060    104 FUNC    GLOBAL DEFAULT       18 gnu_ifunc_resolver
   54: 0000000000020060    104 GNU_IFUNC GLOBAL DEFAULT     18 gnu_ifunc

But, currently GDB only knows about ifunc symbols that are text
symbols.  GDB's support happens to work in practice for PPC64 when the
ifunc and resolver are one and only, like in the current
gdb.base/gnu-ifunc.exp testcase:

   15: 0000000000020060    104 GNU_IFUNC GLOBAL DEFAULT       18 gnu_ifunc

because in that case, the synthetic ".gnu_ifunc" entry point text
symbol that bfd creates from the actual GNU ifunc "gnu_ifunc" function
(descriptor) symbol ends up with the the "is a gnu ifunc" flag set /
copied over:

  (gdb) maint print msymbols
  ...
  [ 8] i 0x9c4 .gnu_ifunc section .text                <<< mst_text_gnu_ifunc
  ...
  [29] D 0x20060 gnu_ifunc section .opd  crtstuff.c    <<< mst_data

But, if the resolver gets a distinct symbol/name from the ifunc
symbol, then we end up with this:

  (gdb) maint print msymbols
  [ 8] T 0x9e4 .gnu_ifunc_resolver section .text               <<< mst_text
  ...
  [29] D 0x20060 gnu_ifunc section .opd  crtstuff.c            <<< mst_data
  [30] D 0x20060 gnu_ifunc_resolver section .opd  crtstuff.c   <<< mst_data

I have a follow up bfd patch that turns that into:

   (gdb) maint print msymbols
+  [ 8] i 0x9e4 .gnu_ifunc section .text               <<< mst_text_gnu_ifunc
   [ 8] T 0x9e4 .gnu_ifunc_resolver section .text      <<< mst_text
   ...
   [29] D 0x20060 gnu_ifunc section .opd  crtstuff.c
   [30] D 0x20060 gnu_ifunc_resolver section .opd  crtstuff.c

but that won't help everything.  We still need this patch.

Specifically, when we do a symbol lookup by name, like e.g., to call a
function (see c-exp.y hunk), e.g., "p gnu_ifunc()", then we need to
know that the found "gnu_ifunc" minimal symbol is an ifunc in order to
do some special processing.  But, on PPC, that lookup by name finds
the function descriptor symbol, which presently is just a mst_data
symbol, while at present, we look for mst_text_gnu_ifunc symbols to
decide whether to do special GNU ifunc processing.  In most of those
places, we could try to resolve the function descriptor with
gdbarch_convert_from_func_ptr_addr, and then lookup the minimal symbol
at the resolved PC, see if that finds a minimal symbol of type
mst_text_gnu_ifunc.  If so, then we could assume that the original
mst_dadta / function descriptor "gnu_ifunc" symbol was an ifunc.  I
tried it, and it mostly works, even if it's not the most efficient.

However, there's one case that can't work with such a design -- it's
that of the user calling the ifunc resolver directly to debug it, like
"p gnu_ifunc_resolver(0)", expecting that to return the function
pointer of the final function (which is exercised by the new tests
added later).  In this case, with the not-fully-working solution, we'd
resolve the function descriptor, find that there's an
mst_text_gnu_ifunc symbol for the resolved address, and proceed
calling the function as if we tried to call "gnu_ifunc", the
user-visible GNU ifunc symbol, instead of the resolver.  I.e., it'd be
impossible to call the resolver directly as a normal function.

Introducing mst_data_gnu_ifunc eliminates the need for several
gdbarch_convert_from_func_ptr_addr calls, and, fixes the "call
resolver directly" use case mentioned above too.  It's the cleanest
approach I could think of.

In sum, we make GNU ifunc function descriptor symbols get a new
"mst_data_gnu_ifunc" minimal symbol type instead of the bare mst_data
type.  So when symbol lookup by name finds such a minimal symbol, we
know we found an ifunc symbol, without resolving the entry/text
symbol.  If the user calls the the resolver symbol instead, like "p
gnu_ifunc_resolver(0)", then we'll find the regular mst_data symbol
for "gnu_ifunc_resolver", and we'll call the resolver function as just
another regular function.

With this, most of the GNU ifunc tests added by a later patch pass on
PPC64 too.  The following bfd patch fixes the remaining issues.

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* breakpoint.c (set_breakpoint_location_function): Handle
mst_data_gnu_ifunc.
* c-exp.y (variable production): Handle mst_data_gnu_ifunc.
* elfread.c (elf_symtab_read): Give data symbols with
BSF_GNU_INDIRECT_FUNCTION set mst_data_gnu_ifunc type.
(elf_rel_plt_read): Update comment.
* linespec.c (convert_linespec_to_sals): Handle
mst_data_gnu_ifunc.
(minsym_found): Handle mst_data_gnu_ifunc.
* minsyms.c (msymbol_is_function, minimal_symbol_reader::record)
(find_solib_trampoline_target): Handle mst_data_gnu_ifunc.
* parse.c (find_minsym_type_and_address): Handle
mst_data_gnu_ifunc.
* symmisc.c (dump_msymbols): Handle mst_data_gnu_ifunc.
* symtab.c (find_gnu_ifunc): Handle mst_data_gnu_ifunc.
* symtab.h (minimal_symbol_type) <mst_text_gnu_ifunc>: Update
comment.
<mst_data_gnu_ifunc>: New enumerator.

6 years agoFix stepping past GNU ifunc resolvers (introduce lookup_msym_prefer)
Pedro Alves [Thu, 26 Apr 2018 12:01:27 +0000 (13:01 +0100)]
Fix stepping past GNU ifunc resolvers (introduce lookup_msym_prefer)

When we're stepping (with "step"), we want to skip trampoline-like
functions automatically, including GNU ifunc resolvers.  That is done
by infrun.c calling into:

  in_solib_dynsym_resolve_code
    -> svr4_in_dynsym_resolve_code
      -> in_gnu_ifunc_stub

A problem here is that if there's a regular text symbol at the same
address as the ifunc symbol, the minimal symbol lookup in
in_gnu_ifunc_stub may miss the GNU ifunc symbol:

(...)
    41: 000000000000071a    53 FUNC    GLOBAL DEFAULT   11 gnu_ifunc_resolver
(...)
    50: 000000000000071a    53 IFUNC   GLOBAL DEFAULT   11 gnu_ifunc
(...)

This causes this FAIL in the tests added later in the series:

 (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: resolver received HWCAP
 set step-mode on
 (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: set step-mode on
 step
 0x00007ffff7bd371a in gnu_ifunc_resolver () from build/gdb/testsuite/outputs/gdb.base/gnu-ifunc/gnu-ifunc-lib-1-0-0.so
 (gdb) FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: step

Above, GDB simply thought that it stepped into a regular function, so
it stopped stepping, while it should have continued stepping past the
resolver.

The fix is to teach minimal symbol lookup to prefer GNU ifunc symbols
if desired.

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* minsyms.c (lookup_minimal_symbol_by_pc_section_1): Rename to ...
(lookup_minimal_symbol_by_pc_section): ... this.  Replace
'want_trampoline' parameter by a lookup_msym_prefer parameter.
Handle it.
(lookup_minimal_symbol_by_pc_section): Delete old implementation.
(lookup_minimal_symbol_by_pc): Adjust.
(in_gnu_ifunc_stub): Prefer GNU ifunc symbols.
(lookup_solib_trampoline_symbol_by_pc): Adjust.
* minsyms.h (lookup_msym_prefer): New enum.
(lookup_minimal_symbol_by_pc_section): Replace 'want_trampoline'
parameter by a lookup_msym_prefer parameter.

6 years agoFor PPC64: elf_gnu_ifunc_record_cache: handle plt symbols in .text section
Pedro Alves [Thu, 26 Apr 2018 12:01:27 +0000 (13:01 +0100)]
For PPC64: elf_gnu_ifunc_record_cache: handle plt symbols in .text section

elf_gnu_ifunc_record_cache doesn't ever record anything on PPC64
(tested on gcc110 on the compile farm, CentOS 7.4, ELFv1), because
that expects to find PLT symbols in the .plt section, while there we
get:

  (gdb) info symbol 'gnu_ifunc@plt'
  gnu_ifunc@plt in section .text
                           ^^^^^

I guess that may be related to the comment in ppc-linux-tdep.c that
says "For secure PLT, stub is in .text".

In any case, this commit fixes the issue by making the function look
at the symbol name instead of at the section.

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* elfread.c (elf_gnu_ifunc_record_cache): Check if the symbol name
ends in "@plt" instead of looking at the symbol's section.

6 years agoFactor out minsym_found/find_function_start_sal overload
Pedro Alves [Thu, 26 Apr 2018 12:01:26 +0000 (13:01 +0100)]
Factor out minsym_found/find_function_start_sal overload

I need to make the ifunc resolving code in elfread.c skip the target
function's prologue like minsym_found does.  I thought of factoring
that out to a separate function, but turns out there's already a
comment in find_function_start_sal that says that should agree with
minsym_found...

Instead of making sure the code agrees with a comment, factor out the
common code to a separate function and use it from both places.

Note that the current find_function_start_sal does a bit more than
minsym_found's equivalent (the "We always should ..." bit), though
that's probably a latent bug.

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* linespec.c (minsym_found): Use find_function_start_sal CORE_ADDR
overload.
* symtab.c (find_function_start_sal(CORE_ADDR, obj_section *,bool)):
New, factored out from ...
(find_function_start_sal(symbol *, int)): ... this.  Reimplement
and use bool.
* symtab.h (find_function_start_sal(CORE_ADDR, obj_section *,bool)):
New.
(find_function_start_sal(symbol *, int)): Change boolean parameter
type to bool.

6 years agoEliminate find_pc_partial_function_gnu_ifunc
Pedro Alves [Thu, 26 Apr 2018 12:01:26 +0000 (13:01 +0100)]
Eliminate find_pc_partial_function_gnu_ifunc

Not used anywhere any longer.

If this is ever reinstated, note that this case:

  cache_pc_function_is_gnu_ifunc = TYPE_GNU_IFUNC (SYMBOL_TYPE (f));

was incorrect in that regular symbols never have type marked as GNU
ifunc type, only minimal symbols.  At some point I had some fix that
checking the matching minsym here.  But in the end I ended up just
eliminating need for this function, so that fix was not necessary.

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* blockframe.c (cache_pc_function_is_gnu_ifunc): Delete.  Remove
all references.
(find_pc_partial_function_gnu_ifunc): Rename to ...
(find_pc_partial_function): ... this, and remove references to
'is_gnu_ifunc_p'.
(find_pc_partial_function): Delete old implementation.
* symtab.h (find_pc_partial_function_gnu_ifunc): Delete.

6 years agoBreakpoints, don't skip prologue of ifunc resolvers with debug info
Pedro Alves [Thu, 26 Apr 2018 12:01:26 +0000 (13:01 +0100)]
Breakpoints, don't skip prologue of ifunc resolvers with debug info

Without this patch, some of the tests added to gdb.base/gnu-ifunc.exp
by a following patch fail like so:

  FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=1: resolved_debug=0: set-break: before resolving: break gnu_ifunc
  FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=1: resolved_debug=0: set-break: before resolving: info breakpoints
  FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=1: resolved_debug=0: set-break: after resolving: break gnu_ifunc
  FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=1: resolved_debug=0: set-break: after resolving: info breakpoints
  FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=1: resolved_debug=1: set-break: before resolving: break gnu_ifunc
  FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=1: resolved_debug=1: set-break: before resolving: info breakpoints
  FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=1: resolved_debug=1: set-break: after resolving: break gnu_ifunc
  FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=1: resolved_debug=1: set-break: after resolving: info breakpoints

All of them trigger iff:

 - you have debug info for the ifunc resolver.
 - the resolver and the user-visible symbol have the same name.

If you have an ifunc that has a resolver with the same name as the
user visible symbol, debug info for the resolver masks out the ifunc
minsym.  When you set a breakpoint by name on the user visible symbol,
GDB finds the DWARF symbol for the resolver, and thinking that it's a
regular function, sets a breakpoint location past its prologue.

Like so, location 1.2, before the ifunc is resolved by the inferior:

  (gdb) break gnu_ifunc
  Breakpoint 2 at 0x7ffff7bd36ea (2 locations)
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
  1.1                         y     0x00007ffff7bd36ea <gnu_ifunc>
  1.2                         y     0x00007ffff7bd36f2 in gnu_ifunc at src/gdb/testsuite/gdb.base/gnu-ifunc-lib.c:34
  (gdb)

And like so, location 2.2, if you set the breakpoint after the ifunc
is resolved by the inferior (to "final"):

  (gdb) break gnu_ifunc
  Breakpoint 5 at 0x400757 (2 locations)
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  2       breakpoint     keep y   <MULTIPLE>
  2.1                         y     0x000000000040075a in final at src/gdb/testsuite/gdb.base/gnu-ifunc-resd.c:21
  2.2                         y     0x00007ffff7bd36f2 in gnu_ifunc at src/gdb/testsuite/gdb.base/gnu-ifunc-lib.c:34
  (gdb)

I don't think this is right because when users set a breakpoint at an
ifunc, they don't care about debugging the resolver.  Instead what you
should is a single location for the ifunc in the first case, and a
single location of the ifunc target in the second case.

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* linespec.c (struct bound_minimal_symbol_search_key): New.
(convert_linespec_to_sals): Sort minimal symbols earlier.  Don't
skip first line if we found a GNU ifunc minimal symbol by name.
(compare_msymbols): Change parameters to work with a destructured
lhs minsym.
(compare_msymbols_for_qsort, compare_msymbols_for_bsearch): New
functions.

6 years agoFix setting breakpoints on ifunc functions after they're already resolved
Pedro Alves [Thu, 26 Apr 2018 12:01:26 +0000 (13:01 +0100)]
Fix setting breakpoints on ifunc functions after they're already resolved

This fixes setting breakpoints on ifunc functions by name after the
ifunc has already been resolved.

In that case, if you have debug info for the ifunc resolver, without
the fix, then gdb puts a breakpoint past the prologue of the resolver,
instead of setting a breakpoint at the ifunc target:

  break gnu_ifunc
  Breakpoint 4 at 0x7ffff7bd36f2: file src/gdb/testsuite/gdb.base/gnu-ifunc-lib.c, line 34.
  (gdb) continue
  Continuing.
  [Inferior 1 (process 13300) exited normally]
  (gdb)

above we should have stopped at "final", but didn't because we never
resolved the ifunc to the final location.

If you don't have debug info for the resolver, GDB manages to resolve
the ifunc target, but, it should be setting a breakpoint after the
prologue of the final function, and instead what you get is that GDB
sets a breakpoint on the first address of the target function.  With
the gnu-ifunc.exp tests added by a later patch, we get, without the
fix:

  (gdb) break gnu_ifunc
  Breakpoint 4 at 0x400753
  (gdb) continue
  Continuing.

  Breakpoint 4, final (arg=1) at src/gdb/testsuite/gdb.base/gnu-ifunc-final.c:20
  20 {

vs, fixed:

  (gdb) break gnu_ifunc
  Breakpoint 4 at 0x40075a: file src/gdb/testsuite/gdb.base/gnu-ifunc-final.c, line 21.
  (gdb) continue
  Continuing.

  Breakpoint 4, final (arg=2) at src/gdb/testsuite/gdb.base/gnu-ifunc-final.c:21
  21   return arg + 1;
  (gdb)

Fix the problems above by moving the ifunc target resolving to
linespec.c, before we skip a function's prologue.  We need to save
something in the sal, so that set_breakpoint_location_function knows
that it needs to create a bp_gnu_ifunc_resolver bp_location.  Might as
well just save a pointer to the minsym.

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* breakpoint.c (set_breakpoint_location_function): Don't resolve
ifunc targets here.  Instead, if we have an ifunc minsym, use its
address/name.
(add_location_to_breakpoint): Store the minsym and the objfile in
the breakpoint location.
* breakpoint.h (bp_location) <msymbol, objfile>: New fields.
* linespec.c (minsym_found): Resolve GNU ifunc targets here.
Record the minsym in the sal.
* symtab.h (symtab_and_line) <msymbol>: New field.

6 years agoFix elf_gnu_ifunc_resolve_by_got buglet
Pedro Alves [Thu, 26 Apr 2018 12:01:26 +0000 (13:01 +0100)]
Fix elf_gnu_ifunc_resolve_by_got buglet

The next patch will add a call to elf_gnu_ifunc_resolve_by_got that
trips on a latent buglet -- the function is writing to its output
parameter even if the address wasn't found, confusing the caller.  The
function's intro comment says:

  /* Try to find the target resolved function entry address of a STT_GNU_IFUNC
     function NAME.  If the address is found it is stored to *ADDR_P (if ADDR_P
     is not NULL) and the function returns 1.  It returns 0 otherwise.

So fix the function accordingly.

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* elfread.c (elf_gnu_ifunc_resolve_by_got): Don't write to *ADDR_P
unless we actually resolved the ifunc.

6 years agoCalling ifunc functions when resolver has debug info, user symbol same name
Pedro Alves [Thu, 26 Apr 2018 12:01:26 +0000 (13:01 +0100)]
Calling ifunc functions when resolver has debug info, user symbol same name

If the GNU ifunc resolver has the same name as the user visible
symbol, and the resolver has debug info, then the DWARF info for the
resolver masks the ifunc minsym.  In that scenario, if you try calling
the ifunc from GDB, you call the resolver instead.  With the
gnu-ifunc.exp testcase added in a following patch, you'd see:

  (gdb) p gnu_ifunc (3)
  $1 = (int (*)(int)) 0x400753 <final>
  (gdb) FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=1: resolved_debug=0: p gnu_ifunc (3)
                                                       ^^^^^^^^^^^^^^^^

That is, we called the ifunc resolver manually, which returned a
pointer to the ifunc target function ("final").  The "final" symbol is
the function that GDB should have called automatically,

  ~~~~~~~~~~~~
  int
  final (int arg)
  {
    return arg + 1;
  }
  ~~~~~~~~~

which is what happens if you don't have debug info for the resolver:

  (gdb) p gnu_ifunc (3)
  $1 = 4
  (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=0: resolved_debug=1: p gnu_ifunc (3)
                                                       ^^^^^^^^^^^^^^^^

or if the resolver's symbol has a different name from the ifunc (as is
the case with modern uses of ifunc via __attribute__ ifunc, such as
glibc uses):

  (gdb) p gnu_ifunc (3)
  $1 = 4
  (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=1: resolved_debug=0: p gnu_ifunc (3)
                                      ^^^^^^^^^^^^^^^

in which case after this patch, you can still call the resolver
directly if you want:

  (gdb) p gnu_ifunc_resolver (3)
  $1 = (int (*)(int)) 0x400753 <final>

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* c-exp.y (variable production): Prefer ifunc minsyms over
regular function symbols.
* symtab.c (find_gnu_ifunc): New function.
* minsyms.h (lookup_msym_prefer): New enum.
(lookup_minimal_symbol_by_pc_section): Replace 'want_trampoline'
parameter by a lookup_msym_prefer parameter.
* symtab.h (find_gnu_ifunc): New declaration.

6 years agoCalling ifunc functions when target has no debug info but resolver has
Pedro Alves [Thu, 26 Apr 2018 12:01:26 +0000 (13:01 +0100)]
Calling ifunc functions when target has no debug info but resolver has

After the previous patch, on Fedora 27 (glibc 2.26), if you try
calling strlen in the inferior, you now get:

  (top-gdb) p strlen ("hello")
  '__strlen_avx2' has unknown return type; cast the call to its declared return type

This is correct, because __strlen_avx2 is written in assembly.

We can improve on this though -- if the final ifunc resolved/target
function has no debug info, but the ifunc _resolver_ does have debug
info, we can try extracting the final function's type from the type
that the resolver returns.  E.g.,:

  typedef size_t (*strlen_t) (const char*);

  size_t my_strlen (const char *) { /* some implementation */ }
  strlen_t strlen_resolver (unsigned long hwcap) { return my_strlen; }

  extern size_t strlen (const char *s);
  __typeof (strlen) strlen __attribute__ ((ifunc ("strlen_resolver")));

In the strlen example above, the resolver returns strlen_t, which is a
typedef for pointer to a function that returns size_t.  "strlen_t" is
the type of both the user-visible "strlen", and of the the target
function that implements it.

This patch teaches GDB to extract that type.

This is done for actual inferior function calls (in infcall.c), and
for ptype (in eval_call).  By the time we get to either of these
places, we've already lost the original symbol/minsym, and only have
values and types to work with.  Hence the changes to c-exp.y and
evaluate_var_msym_value, to ensure that we propagate the ifunc
minsymbol's info.

The change to make ifunc symbols have no/unknown return type exposes a
latent problem -- gdb.compile/compile-ifunc.exp calls a no-debug-info
function, but we did not warn about it.  The test is fixed by this
commit too.

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* blockframe.c (find_gnu_ifunc_target_type): New function.
(find_function_type): New.
* eval.c (evaluate_var_msym_value): For GNU ifunc types, always
return a value with a memory address.
(eval_call): For calls to GNU ifunc functions, try to find the
type of the target function from the type that the resolver
returns.
* gdbtypes.c (objfile_type): Don't install a return type for ifunc
symbols.
* infcall.c (find_function_return_type): Delete.
(find_function_addr): Add 'function_type' parameter.  For calls to
GNU ifunc functions, try to find the type of the target function
from the type that the resolver returns, and return it via
FUNCTION_TYPE.
(call_function_by_hand_dummy): Adjust to use the function type
returned by find_function_addr.
(find_function_addr): Add 'function_type' parameter and move
description here.
* symtab.h (find_function_type, find_gnu_ifunc_target_type): New
declarations.

gdb/testsuite/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* gdb.compile/compile-ifunc.exp: Also expect "function has unknown
return type" warnings.

6 years agoFix calling ifunc functions when resolver has debug info and different name
Pedro Alves [Thu, 26 Apr 2018 12:01:26 +0000 (13:01 +0100)]
Fix calling ifunc functions when resolver has debug info and different name

Currently, on Fedora 27 (glibc 2.26), if you try to call strlen in the
inferior you get:

 (gdb) p strlen ("hello")
 $1 = (size_t (*)(const char *)) 0x7ffff554aac0 <__strlen_avx2>

strlen is an ifunc function, and what we see above is the result of
calling the ifunc resolver in the inferior.  That returns a pointer to
the actual target function that implements strlen on my machine.  GDB
should have turned around and called the resolver automatically
without the user noticing.

This is was caused by commit:

  commit bf223d3e808e6fec9ee165d3d48beb74837796de
  Date: Mon Aug 21 11:34:32 2017 +0100

      Handle function aliases better (PR gdb/19487, errno printing)

which added the find_function_alias_target call to c-exp.y, to try to
find an alias with debug info for a minsym.  For ifunc symbols, that
finds the ifunc's resolver if it has debug info (in the example it's
called "strlen_ifunc"), with the result that GDB calls that as a
regular function.

After this commit, we get now get:

  (top-gdb) p strlen ("hello")
  '__strlen_avx2' has unknown return type; cast the call to its declared return type

Which is correct, because __strlen_avx2 is written in assembly.
That'll be improved in a following patch, though.

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* c-exp.y (variable production): Skip finding an alias for ifunc
symbols.

6 years agoFix breakpoints in ifunc after inferior resolved it (@got.plt symbol creation)
Pedro Alves [Thu, 26 Apr 2018 12:02:26 +0000 (13:02 +0100)]
Fix breakpoints in ifunc after inferior resolved it (@got.plt symbol creation)

Setting a breakpoint on an ifunc symbol after the ifunc has already
been resolved by the inferior should result in creating a breakpoint
location at the ifunc target.  However, that's not what happens on
current Fedora:

  (gdb) n
  53        i = gnu_ifunc (1);    /* break-at-call */
  (gdb)
  54        assert (i == 2);
  (gdb) b gnu_ifunc
  Breakpoint 2 at gnu-indirect-function resolver at 0x7ffff7bd36ee
  (gdb) info breakpoints
  Num     Type                   Disp Enb Address            What
  2       STT_GNU_IFUNC resolver keep y   0x00007ffff7bd36ee <gnu_ifunc+4>

The problem is that elf_gnu_ifunc_resolve_by_got never manages to
resolve an ifunc target.  The reason is that GDB never actually
creates the internal got.plt symbols:

 (gdb) p 'gnu_ifunc@got.plt'
 No symbol "gnu_ifunc@got.plt" in current context.

and this is because GDB expects that rela.plt has relocations for
.plt, while it actually has relocations for .got.plt:

 Relocation section [10] '.rela.plt' for section [22] '.got.plt' at offset 0x570 contains 2 entries:
   Offset              Type            Value               Addend Name
   0x0000000000601018  X86_64_JUMP_SLOT 000000000000000000      +0 __assert_fail
   0x0000000000601020  X86_64_JUMP_SLOT 000000000000000000      +0 gnu_ifunc

Using an older system on the GCC compile farm (machine gcc15, an
x86-64 running Debian 6.0.8, with GNU ld 2.20.1), we see that it used
to be that we'd get a .rela.plt section for .plt:

 Relocation section [ 9] '.rela.plt' for section [11] '.plt' at offset 0x578 contains 3 entries:
   Offset              Type            Value               Addend Name
   0x0000000000600cc0  X86_64_JUMP_SLOT 000000000000000000      +0 __assert_fail
   0x0000000000600cc8  X86_64_JUMP_SLOT 000000000000000000      +0 __libc_start_main
   0x0000000000600cd0  X86_64_JUMP_SLOT 000000000000000000      +0 gnu_ifunc

Those offsets did point into .got.plt, as seen with objdump -h:

  20 .got.plt      00000030  0000000000600ca8  0000000000600ca8  00000ca8  2**3
         CONTENTS, ALLOC, LOAD, DATA

I also tested on gcc110 on the compile farm (PPC64 running CentOS
7.4.1708, with GNU ld 2.25.1), and there we see instead:

 Relocation section [ 9] '.rela.plt' for section [23] '.plt' at offset 0x5d0 contains 4 entries:
   Offset              Type            Value               Addend Name
   0x0000000010020148  PPC64_JMP_SLOT  000000000000000000      +0 __libc_start_main
   0x0000000010020160  PPC64_JMP_SLOT  000000000000000000      +0 __gmon_start__
   0x0000000010020178  PPC64_JMP_SLOT  000000000000000000      +0 __assert_fail
   0x0000000010020190  PPC64_JMP_SLOT  000000000000000000      +0 gnu_ifunc

But note that those offsets point into .plt, not .got.plt, as seen
with objdump -h:

 22 .plt          00000078  0000000010020130  0000000010020130  00010130  2**3
                  ALLOC

This commit makes us support all the different combinations above.

With that addressed, we now get:

 (gdb) p 'gnu_ifunc@got.plt'
 $1 = (<text from jump slot in .got.plt, no debug info>) 0x400753 <final>

And setting a breakpoint on the ifunc finds the ifunc target:

 (gdb) b gnu_ifunc
 Breakpoint 2 at 0x400753
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 2       breakpoint     keep y   0x0000000000400753 <final>

gdb/ChangeLog:
2018-04-26  Pedro Alves  <palves@redhat.com>

* elfread.c (elf_rel_plt_read): Look for relocations for .got.plt too.

6 years agox86: fold various non-memory operand AVX512VL templates
Jan Beulich [Thu, 26 Apr 2018 06:55:02 +0000 (08:55 +0200)]
x86: fold various non-memory operand AVX512VL templates

There's little point carrying up to three templates per insn flavor
when the sole difference is operand size and the dependency on AVX512VL
being enabled. Instead the need for AVX512VL can be derived from an
operand allowing for ZMMword as well as one or both or XMMword and
YMMword (irrespective of whether this is a register or memory operand).
Without further abstraction to deal with the different Disp8MemShift
values between the templates, only a limited set (mostly ones only
allowing for non-memory operands) can be folded, which is being done
here.

Also drop IgnoreSize wherever possible from anything that's being
touched anyway.

6 years agox86: also optimize zeroing-masking variants of insns
Jan Beulich [Thu, 26 Apr 2018 06:53:20 +0000 (08:53 +0200)]
x86: also optimize zeroing-masking variants of insns

When zeroing an element of a register it doesn't matter whether the zero
results from the actual operation (xor, sub, or nand) or from the
zeroing-masking taking effect due to a clear mask register bit.

6 years agox86: properly force / avoid forcing EVEX encoding
Jan Beulich [Thu, 26 Apr 2018 06:49:41 +0000 (08:49 +0200)]
x86: properly force / avoid forcing EVEX encoding

Pseudo prefixes are supposed to be a hint only - when the specific
encoding can't be used to encode an insn, silently override it. But
this overriding must only happen after the respective check, to
avoid forcing EVEX encoding because of something that isn't a valid
register name in the given context.

6 years agox86: CpuXSAVE is a prereq for various other features
Jan Beulich [Thu, 26 Apr 2018 06:48:56 +0000 (08:48 +0200)]
x86: CpuXSAVE is a prereq for various other features

All of AVX, LWP, MPX, and PKU require XSAVE, and hence it as well as
XRSTOR should be enabled when enabling these ISA extensions. Leverage
these implications to shorten some of the cpu_flag_init[] entries.

6 years agox86: drop CpuRegMMX, CpuReg[XYZ]MM, and CpuRegMask
Jan Beulich [Thu, 26 Apr 2018 06:48:01 +0000 (08:48 +0200)]
x86: drop CpuRegMMX, CpuReg[XYZ]MM, and CpuRegMask

It's not clear to me why they had been introduced - the respective
comments in opcodes/i386-gen.c are certainly wrong: ymm<N> registers
are very well supported (and necessary) with just AVX512F.

6 years agox86: don't recognize bnd<N> as registers without CpuMPX
Jan Beulich [Thu, 26 Apr 2018 06:46:39 +0000 (08:46 +0200)]
x86: don't recognize bnd<N> as registers without CpuMPX

This is just like for all other extended/optional register sets.

6 years agox86: x87-related adjustments
Jan Beulich [Thu, 26 Apr 2018 06:45:35 +0000 (08:45 +0200)]
x86: x87-related adjustments

Neither 287 wrt 8087 nor 387 wrt 287 are proper supersets - in each case
some insns get removed from the ISA (they become NOPs, but code intended
for newer co-processors should not use them).

Furthermore with .no87, ST should not be recognized as a register name.

6 years agox86: fix indentation in build_modrm_byte()
Jan Beulich [Thu, 26 Apr 2018 06:31:14 +0000 (08:31 +0200)]
x86: fix indentation in build_modrm_byte()

The VEX3SOURCES code was (originally) written with just space
indentation, which is not in line with general coding style as well as
the style later in the function.

6 years agox86: move and fold common code in build_modrm_byte()
Jan Beulich [Thu, 26 Apr 2018 06:30:45 +0000 (08:30 +0200)]
x86: move and fold common code in build_modrm_byte()

The source and reg_slot calculations in the VEX3SOURCES only depend on
the number of immediate operands.

6 years agox86: drop VexImmExt
Jan Beulich [Thu, 26 Apr 2018 06:30:06 +0000 (08:30 +0200)]
x86: drop VexImmExt

It's only used in assertions, and hence not really needed for correct
code generation.

6 years agox86: tighten assertion in build_modrm_byte()
Jan Beulich [Thu, 26 Apr 2018 06:29:09 +0000 (08:29 +0200)]
x86: tighten assertion in build_modrm_byte()

All VEX3SOURCES cases should have VexW set, and all should have a SIMD
register destination.

6 years agox86: drop dead code from build_modrm_byte()
Jan Beulich [Thu, 26 Apr 2018 06:28:38 +0000 (08:28 +0200)]
x86: drop dead code from build_modrm_byte()

There are no templates with VexImmExt and ImmExt set at the same time.
There are also no VEX3SOURCES templates with CpuFMA. I assume both are
left-overs from the implementation of an early specification which was
later revised.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 26 Apr 2018 00:00:46 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years ago[ARM] FDPIC: Update testsuite so that many tests pass with arm*-uclinuxfdpiceabi.
Christophe Lyon [Wed, 18 Apr 2018 20:55:29 +0000 (20:55 +0000)]
[ARM] FDPIC: Update testsuite so that many tests pass with arm*-uclinuxfdpiceabi.

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>

binutils/
* testsuite/binutils-all/elfedit-2.d: Accept arm*-*-uclinuxfdpiceabi.
* testsuite/binutils-all/elfedit-3.d: Likewise.
* testsuite/binutils-all/objcopy.exp: Likewise.
* testsuite/binutils-all/strip-3.d: Likewise.
* testsuite/lib/binutils-common.exp: Likewise.

ld/
* testsuite/ld-arm/export-class.exp: Accept arm*-*-uclinuxfdpiceabi.
* testsuite/ld-discard/discard.exp: Likewise.
* testsuite/ld-elf/binutils.exp: Likewise.
* testsuite/ld-elf/commonpage1.d: Likewise.
* testsuite/ld-elf/compress1c.d: Likewise.
* testsuite/ld-elf/compressed1b.d: Likewise.
* testsuite/ld-elf/compressed1c.d: Likewise.
* testsuite/ld-elf/compressed1e.d: Likewise.
* testsuite/ld-elf/dynamic1.d: Likewise.
* testsuite/ld-elf/dynsym1.d: Likewise.
* testsuite/ld-elf/ehdr_start-missing.d: Likewise.
* testsuite/ld-elf/ehdr_start-shared.d: Likewise.
* testsuite/ld-elf/ehdr_start-userdef.d: Likewise.
* testsuite/ld-elf/ehdr_start-weak.d: Likewise.
* testsuite/ld-elf/ehdr_start.d: Likewise.
* testsuite/ld-elf/exclude3b.d: Likewise.
* testsuite/ld-elf/export-class.exp: Likewise.
* testsuite/ld-elf/global1.d: Likewise.
* testsuite/ld-elf/hash.d: Likewise.
* testsuite/ld-elf/header.d: Likewise.
* testsuite/ld-elf/loadaddr1.d: Likewise.
* testsuite/ld-elf/loadaddr2.d: Likewise.
* testsuite/ld-elf/loadaddr3a.d: Likewise.
* testsuite/ld-elf/loadaddr3b.d: Likewise.
* testsuite/ld-elf/local1.d: Likewise.
* testsuite/ld-elf/maxpage1.d: Likewise.
* testsuite/ld-elf/maxpage2.d: Likewise.
* testsuite/ld-elf/maxpage3a.d: Likewise.
* testsuite/ld-elf/mbind1a.d: Likewise.
* testsuite/ld-elf/mbind1b.d: Likewise.
* testsuite/ld-elf/mbind1c.d: Likewise.
* testsuite/ld-elf/multibss1.d: Likewise.
* testsuite/ld-elf/noload-2.d: Likewise.
* testsuite/ld-elf/now-1.d: Likewise.
* testsuite/ld-elf/now-2.d: Likewise.
* testsuite/ld-elf/now-3.d: Likewise.
* testsuite/ld-elf/now-4.d: Likewise.
* testsuite/ld-elf/pie.d: Likewise.
* testsuite/ld-elf/pr12975.d: Likewise.
* testsuite/ld-elf/pr13177.d: Likewise.
* testsuite/ld-elf/pr13195.d: Likewise.
* testsuite/ld-elf/pr16322.d: Likewise.
* testsuite/ld-elf/pr16498a.d: Likewise.
* testsuite/ld-elf/pr16498b.d: Likewise.
* testsuite/ld-elf/pr17615.d: Likewise.
* testsuite/ld-elf/pr19162.d: Likewise.
* testsuite/ld-elf/pr19539.d: Likewise.
* testsuite/ld-elf/pr19617a.d: Likewise.
* testsuite/ld-elf/pr19617b.d: Likewise.
* testsuite/ld-elf/pr19617c.d: Likewise.
* testsuite/ld-elf/pr19698.d: Likewise.
* testsuite/ld-elf/pr19789.d: Likewise.
* testsuite/ld-elf/pr20513c.d: Likewise.
* testsuite/ld-elf/pr20513d.d: Likewise.
* testsuite/ld-elf/pr21384.d: Likewise.
* testsuite/ld-elf/pr21389a.d: Likewise.
* testsuite/ld-elf/pr21389b.d: Likewise.
* testsuite/ld-elf/pr21389c.d: Likewise.
* testsuite/ld-elf/pr21562a.d: Likewise.
* testsuite/ld-elf/pr21562b.d: Likewise.
* testsuite/ld-elf/pr21562c.d: Likewise.
* testsuite/ld-elf/pr21562d.d: Likewise.
* testsuite/ld-elf/pr21562e.d: Likewise.
* testsuite/ld-elf/pr21562f.d: Likewise.
* testsuite/ld-elf/pr21562g.d: Likewise.
* testsuite/ld-elf/pr21562h.d: Likewise.
* testsuite/ld-elf/pr21562i.d: Likewise.
* testsuite/ld-elf/pr21562j.d: Likewise.
* testsuite/ld-elf/pr21562k.d: Likewise.
* testsuite/ld-elf/pr21562l.d: Likewise.
* testsuite/ld-elf/pr21562m.d: Likewise.
* testsuite/ld-elf/pr21562n.d: Likewise.
* testsuite/ld-elf/pr21903a.d: Likewise.
* testsuite/ld-elf/pr21903b.d: Likewise.
* testsuite/ld-elf/pr21903d.d: Likewise.
* testsuite/ld-elf/pr22269a.d: Likewise.
* testsuite/ld-elf/pr22269b.d: Likewise.
* testsuite/ld-elf/pr22393-1a.d: Likewise.
* testsuite/ld-elf/pr22393-1b.d: Likewise.
* testsuite/ld-elf/pr22393-1c.d: Likewise.
* testsuite/ld-elf/pr22393-1d.d: Likewise.
* testsuite/ld-elf/pr22393-1e.d: Likewise.
* testsuite/ld-elf/pr22393-1f.d: Likewise.
* testsuite/ld-elf/pr22423.d: Likewise.
* testsuite/ld-elf/rpath-1.d: Likewise.
* testsuite/ld-elf/rpath-2.d: Likewise.
* testsuite/ld-elf/runpath-1.d: Likewise.
* testsuite/ld-elf/runpath-2.d: Likewise.
* testsuite/ld-elf/seg.d: Likewise.
* testsuite/ld-elf/sizeofb.d: Likewise.
* testsuite/ld-elf/startofb.d: Likewise.
* testsuite/ld-elf/strtab.d: Likewise.
* testsuite/ld-elf/textaddr1.d: Likewise.
* testsuite/ld-elf/textaddr2.d: Likewise.
* testsuite/ld-elf/textaddr3.d: Likewise.
* testsuite/ld-elf/textaddr4.d: Likewise.
* testsuite/ld-elf/textaddr5.d: Likewise.
* testsuite/ld-elf/textaddr6.d: Likewise.
* testsuite/ld-elf/textaddr7.d: Likewise.
* testsuite/ld-elf/tls.exp: Likewise.
* testsuite/ld-elf/tls_common.exp: Likewise.
* testsuite/ld-elf/unknown2.d: Likewise.
* testsuite/ld-gc/abi-note.d: Likewise.
* testsuite/ld-gc/pr11218.d: Likewise.
* testsuite/ld-gc/pr19167.d: Likewise.
* testsuite/ld-gc/pr20022.d: Likewise.
* testsuite/ld-gc/start.d: Likewise.
* testsuite/ld-gc/stop.d: Likewise.
* testsuite/ld-scripts/phdrs2.exp: Likewise.
* testsuite/ld-scripts/rgn-at5.d: Likewise.
* testsuite/ld-undefined/entry-3.d: Likewise.
* testsuite/ld-undefined/entry-4.d: Likewise.

6 years ago[ARM] FDPIC: Implement Thumb-only PLT for FDPIC.
Christophe Lyon [Tue, 20 Mar 2018 09:56:17 +0000 (10:56 +0100)]
[ARM] FDPIC: Implement Thumb-only PLT for FDPIC.

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

bfd/
* elf32-arm.c (elf32_arm_fdpic_thumb_plt_entry): New.
(elf32_arm_plt_needs_thumb_stub_p): Handle thumb-only case.
(elf32_arm_populate_plt_entry): Likewise.
(elf32_arm_output_plt_map_1): Likewise.
(elf32_arm_output_arch_local_syms): Likewise.

ld/testsuite/
* arm-elf.exp: Execute the new FDPIC Thumb-only tests.
* fdpic-main-m.d: New test.
* fdpic-main-m.s: New.
* fdpic-main-m.sym: New.
* fdpic-shared-m.d: New test.
* fdpic-shared-m.s: New.
* fdpic-shared-m.sym: New.

6 years ago[ARM] FDPIC: New tests.
Christophe Lyon [Tue, 20 Mar 2018 09:56:10 +0000 (10:56 +0100)]
[ARM] FDPIC: New tests.

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

ld/
* testsuite/ld-arm/arm-elf.exp: Execute the new FDPIC tests.
* testsuite/ld-arm/fdpic-main.d: New test.
* testsuite/ld-arm/fdpic-main.ld: New.
* testsuite/ld-arm/fdpic-main.r: New.
* testsuite/ld-arm/fdpic-main.s: New.
* testsuite/ld-arm/fdpic-main.sym: New.
* testsuite/ld-arm/fdpic-shared.d: New test.
* testsuite/ld-arm/fdpic-shared.ld: New.
* testsuite/ld-arm/fdpic-shared.r: New.
* testsuite/ld-arm/fdpic-shared.s: New.
* testsuite/ld-arm/fdpic-shared.sym: New.

6 years ago[ARM] FDPIC: Fix ld testcase not to conflict with uclibc's includes.
Christophe Lyon [Tue, 20 Mar 2018 09:56:02 +0000 (10:56 +0100)]
[ARM] FDPIC: Fix ld testcase not to conflict with uclibc's includes.

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

ld/
* testsuite/ld-elf/pr2404b.c (main): Rename time variable into
time1.

6 years ago[ARM] FDPIC: Make _GLOBAL_OFFSET_TABLE_ a relative symbol
Christophe Lyon [Tue, 20 Mar 2018 09:55:53 +0000 (10:55 +0100)]
[ARM] FDPIC: Make _GLOBAL_OFFSET_TABLE_ a relative symbol

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

bfd/
* elf32-arm.c (elf32_arm_finish_dynamic_symbol): Handle
_GLOBAL_OFFSET_TABLE_ in FDPIC mode.

6 years ago[ARM] FDPIC: Translate R_ARM_TARGET2 relocation into R_ARM_GOT32 relocation for FDPIC...
Christophe Lyon [Tue, 20 Mar 2018 09:55:45 +0000 (10:55 +0100)]
[ARM] FDPIC: Translate R_ARM_TARGET2 relocation into R_ARM_GOT32 relocation for FDPIC platform

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

bfd/
* elf32-arm.c (bfd_elf32_arm_set_target_params): Handle FDPIC case
for R_ARM_TARGET2.

6 years ago[ARM] FDPIC: Add stack segment
Christophe Lyon [Tue, 20 Mar 2018 09:55:37 +0000 (10:55 +0100)]
[ARM] FDPIC: Add stack segment

The size of the stack segment defaults to 32KB, and can be overridden
by defining the __stacksize symbol.

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

bfd/
* elf32-arm.c (DEFAULT_STACK_SIZE): New.
(elf32_arm_always_size_sections): Create stack segment.

6 years ago[ARM] Add TLS relocations for FDPIC.
Christophe Lyon [Tue, 20 Mar 2018 09:55:29 +0000 (10:55 +0100)]
[ARM] Add TLS relocations for FDPIC.

Define and handle TLS relocations for FDPIC in BFD and gas.

In gas, the new relocations are rejected if the --fdpic option was not
specified.

We also define the __tdata_start symbol to mark the start of the
.tdata section. This allows FDPIC static binaries to find the start of
.tdata section, since phdr->p_vaddr of TLS segment is not a valid
value for FDPIC.

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

bfd/:
* bfd-in2.h (BFD_RELOC_ARM_TLS_GD32_FDPIC)
(BFD_RELOC_ARM_TLS_LDM32_FDPIC, BFD_RELOC_ARM_TLS_IE32_FDPIC): New
relocations.
* elf32-arm.c (elf32_arm_howto_table_2): Add R_ARM_TLS_GD32_FDPIC,
R_ARM_TLS_LDM32_FDPIC, R_ARM_TLS_IE32_FDPIC relocations.
(elf32_arm_reloc_map): Add R_ARM_TLS_GD32_FDPIC,
R_ARM_TLS_LDM32_FDPIC, R_ARM_TLS_IE32_FDPIC.
(struct elf32_arm_link_hash_table): Update comment.
(elf32_arm_final_link_relocate): Handle TLS FDPIC relocations.
(IS_ARM_TLS_RELOC): Likewise.
(elf32_arm_check_relocs): Likewise.
(allocate_dynrelocs_for_symbol): Likewise.
(elf32_arm_size_dynamic_sections): Update comment.
* reloc.c: Add BFD_RELOC_ARM_TLS_GD32_FDPIC,
BFD_RELOC_ARM_TLS_LDM32_FDPIC, BFD_RELOC_ARM_TLS_IE32_FDPIC.

gas/
* config/tc-arm.c (reloc_names): Add TLSGD_FDPIC, TLSLDM_FDPIC,
GOTTPOFF_FDIC relocations.
(md_apply_fix): Handle the new TLS FDPIC relocations.
(tc_gen_reloc): Likewise.
(arm_fix_adjustable): Likewise.

include/
* elf/arm.h: Add R_ARM_TLS_GD32_FDPIC, R_ARM_TLS_LDM32_FDPIC,
R_ARM_TLS_IE32_FDPIC.

ld/
* scripttempl/elf.sc: Define __tdata_start for .tdata section.

6 years ago[ARM] Implement PLT for FDPIC.
Christophe Lyon [Tue, 20 Mar 2018 09:55:20 +0000 (10:55 +0100)]
[ARM] Implement PLT for FDPIC.

FDPIC requires special PLT entries, defined in this patch.

Note that lazy binding is not supported because of a race condition
for lack of an atomic 64-bits load instruction.

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

bfd/
* elf32-arm.c (elf32_arm_fdpic_plt_entry): New.
(elf32_arm_create_dynamic_sections): Handle FDPIC.
(elf32_arm_allocate_plt_entry): Likewise.
(elf32_arm_populate_plt_entry): Likewise.
(elf32_arm_output_plt_map_1): Likewise.

6 years ago[ARM] Implement FDPIC relocations.
Christophe Lyon [Tue, 20 Mar 2018 09:55:09 +0000 (10:55 +0100)]
[ARM] Implement FDPIC relocations.

This is the main BFD patch, that enables the linker to actually handle
the FDPIC relocations.

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

bfd/
* elf32-arm.c (struct fdpic_local): New.
(elf_arm_obj_tdata): Add local_fdpic_cnts field.
(elf32_arm_local_fdpic_cnts): New.
(struct fdpic_global): New.
(elf32_arm_link_hash_entry): Add fdpic_cnts field.
(elf32_arm_link_hash_table): Add srofixup field.
(arm_elf_add_rofixup): New.
(arm_elf_fill_funcdesc): New.
(elf32_arm_link_hash_newfunc): Handle fdpic_cnts.
(elf32_arm_allocate_local_sym_info): Likewise.
(create_got_section): Create .rofixup section.
(elf32_arm_copy_indirect_symbol): Handle fdpic_cnts.
(bfd_elf32_arm_set_target_params): Handle FDPIC.
(elf32_arm_final_link_relocate): Likewise.
(elf32_arm_check_relocs): Likewise.
(allocate_dynrelocs_for_symbol): Likewise.
(elf32_arm_size_dynamic_sections): Likewise.
(elf32_arm_finish_dynamic_sections): Likewise.
(elf32_arm_output_arch_local_syms): Likewise.
(elf32_arm_fdpic_omit_section_dynsym): New.

ld/
* emulparams/armelf_linux_fdpiceabi.sh: Add .rofixup section.

6 years ago[ARM] Add FDPIC relocations definitions
Christophe Lyon [Tue, 20 Mar 2018 09:54:59 +0000 (10:54 +0100)]
[ARM] Add FDPIC relocations definitions

Add FDPIC relocation definitions in BFD and gas.
Gas rejects them if the --fdpic option was not specified.

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

bfd/
* bfd-in2.c (BFD_RELOC_ARM_GOTFUNCDESC)
(BFD_RELOC_ARM_GOTOFFFUNCDESC, BFD_RELOC_ARM_FUNCDESC)
(BFD_RELOC_ARM_FUNCDESC_VALUE): New.
* elf32-arm.c (elf32_arm_howto_table_2): Add R_ARM_GOTFUNCDESC,
R_ARM_GOTOFFFUNCDESC, R_ARM_FUNCDESC, R_ARM_FUNCDESC_VALUE.
(elf32_arm_howto_from_type): Take new members of
elf32_arm_howto_table_2 into account.
(elf32_arm_reloc_map): Add BFD_RELOC_ARM_GOTFUNCDESC,
BFD_RELOC_ARM_GOTOFFFUNCDESC, BFD_RELOC_ARM_FUNCDESC,
BFD_RELOC_ARM_FUNCDESC_VALUE.
* reloc.c: Add BFD_RELOC_ARM_GOTFUNCDESC,
BFD_RELOC_ARM_GOTOFFFUNCDESC, BFD_RELOC_ARM_FUNCDESC,
BFD_RELOC_ARM_FUNCDESC_VALUE.

gas/
* config/tc-arm.c (reloc_names): Add gotfuncdesc, gotofffuncdesc,
funcdesc.
(md_apply_fix): Support the new relocations.
(tc_gen_reloc): Likewise.
* testsuite/gas/arm/reloc-fdpic.d: New.
* testsuite/gas/arm/reloc-fdpic.s: New.

include/
* elf/arm.h (R_ARM_GOTFUNCDESC, R_ARM_GOTOFFFUNCDESC)
(R_ARM_FUNCDESC)
(R_ARM_FUNCDESC_VALUE): Define new relocations.

6 years ago[ARM] Add FDPIC OSABI flag support.
Christophe Lyon [Tue, 20 Mar 2018 09:54:50 +0000 (10:54 +0100)]
[ARM] Add FDPIC OSABI flag support.

ELF files targetting ARM FDPIC use the ELFOSABI_ARM_FDPIC flag.
Set it appropriately in file generators (eg. gas), and handle it in
readers (eg. readelf).

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

bfd/
* elf32-arm.c (elf32_arm_print_private_bfd_data): Support
EF_ARM_PIC and ELFOSABI_ARM_FDPIC.
(elf32_arm_post_process_headers): Support ELFOSABI_ARM_FDPIC.
(ELF_OSABI): Define to ELFOSABI_ARM_FDPIC.

binutils/
* readelf.c (decode_ARM_machine_flags): Support EF_ARM_PIC.
(get_osabi_name): Support ELFOSABI_ARM_FDPIC.

gas/
* config/tc-arm.c (arm_fdpic): New.
(elf32_arm_target_format): Support FDPIC.
(OPTION_FDPIC): New.
(md_longopts): Support FDPIC.
(md_parse_option): Likewise.
(md_show_usage): Likewise.

include/
* elf/arm.h (EF_ARM_FDPIC): New.

6 years ago[ARM] Add armelf_linux_fdpiceabi and armelfb_linux_fdpiceabi BFD backends
Christophe Lyon [Tue, 20 Mar 2018 09:54:26 +0000 (10:54 +0100)]
[ARM] Add armelf_linux_fdpiceabi and armelfb_linux_fdpiceabi BFD backends

Initial definition of these new backends.

2018-04-25  Christophe Lyon  <christophe.lyon@st.com>
Mickaël Guêné  <mickael.guene@st.com>

bfd/
* config.bfd (arm*-*-linux-*): Add arm_elf32_fdpic_be_vec and
arm_elf32_fdpic_le_vec to targ_selvecs. Accept
arm*-*-uclinuxfdpiceabi.
* configure.ac: Add support for arm_elf32_fdpic_be_vec and
arm_elf32_fdpic_le_vec.
* configure: Regenerate.
* elf32-arm.c (struct elf32_arm_link_hash_table): Add fdpic_p.
(elf32_arm_link_hash_table_create): Initialize fdpic_p.
(TARGET_LITTLE_SYM, TARGET_LITTLE_NAME, TARGET_BIG_SYM)
(TARGET_BIG_NAME, elf_match_priority): Define for FDPIC targets.
(elf32_arm_fdpic_link_hash_table_create): New.
* targets.c (_bfd_target_vector): Add arm_elf32_fdpic_be_vec and
arm_elf32_fdpic_le_vec.

ld/
* Makefile.am (ALL_EMULATION_SOURCES): Add
earmelf_linux_fdpiceabi.c and earmelfb_linux_fdpiceabi.c.
(earmelf_linux_fdpiceabi.c, earmelfb_linux_fdpiceabi.c): New rules.
* Makefile.in: Regenerate.
* configure.tgt (arm*-*-uclinuxfdpiceabi): Handle new target.
* emulparams/armelf_linux_fdpiceabi.sh: New.
* emulparams/armelfb_linux_fdpiceabi.sh: New.

6 years agoFix new inferior events output
Pedro Alves [Wed, 25 Apr 2018 16:28:25 +0000 (17:28 +0100)]
Fix new inferior events output

Since f67c0c917150 ("Enable 'set print inferior-events' and improve
detach/fork/kill/exit messages"), when detaching a remote process, we
get, for detach against a remote target:

 (gdb) detach
 Detaching from program: ...., process 5388
 Ending remote debugging.
 [Inferior 1 (Thread 5388.5388) detached]
              ^^^^^^^^^^^^^^^^

That is incorrect, for it is printing a thread id as string while we
should be printing the process id instead.  I.e., either one of:

 [Inferior 1 (process 5388) detached]
 [Inferior 1 (Remote target) detached]

depending on remote stub support for the multi-process extensions.

Similarly, after killing a process, we're printing thread ids while we
should be printing process ids.  E.g., on native GNU/Linux:

 (gdb) k
 Kill the program being debugged? (y or n) y
 [Inferior 1 (Thread 0x7ffff7faa8c0 (LWP 30721)) has been killed]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

while it should have been:

 Kill the program being debugged? (y or n) y
 [Inferior 1 (process 30721) has been killed]
              ^^^^^^^^^^^^^

There's a wording inconsistency between detach and kill:

 [Inferior 1 (process 30721) has been killed]
 [Inferior 1 (process 30721) detached]

Given we were already saying "detached" instead of "has been
detached", and we used to say just "exited", and given that the "has
been" doesn't really add any information, this commit changes the
message to just "killed":

 [Inferior 1 (process 30721) killed]

gdb/ChangeLog:
2018-04-25  Pedro Alves  <palves@redhat.com>

* infcmd.c (kill_command): Print the pid as string, not the whole
thread's ptid.  Add comment.  s/has been killed/killed/ in output
message.
* remote.c (remote_detach_1): Print the pid as string, not the
whole thread's ptid.

gdb/testsuite/ChangeLog:
2018-04-25  Pedro Alves  <palves@redhat.com>

* gdb.base/hook-stop.exp: Expect "killed" instead of "has been
killed".
* gdb.base/kill-after-signal.exp: Likewise.
* gdb.threads/kill.exp: Likewise.

6 years agox86: drop redundant AVX512VL shift templates
Jan Beulich [Wed, 25 Apr 2018 14:26:10 +0000 (16:26 +0200)]
x86: drop redundant AVX512VL shift templates

These were wrongly left in place by commit ed438a93f1 ("x86: fold
certain AVX512 rotate and shift templates").

6 years agoFix the mask for the sqrdml(a|s)h instructions.
Tamar Christina [Wed, 25 Apr 2018 12:37:30 +0000 (13:37 +0100)]
Fix the mask for the sqrdml(a|s)h instructions.

Rn is supposed to have a 5 bit range but instead was given 4 bits
causing these instructions to disassemble as unknown instructions.

opcodes/

* aarch64-tbl.h (sqrdmlah, sqrdmlsh): Fix masks.

gas/

* testsuite/gas/aarch64/rdma.s: Test for larger register numbers.
* testsuite/gas/aarch64/rdma.d: Update results.
* testsuite/gas/aarch64/rdma-directive.d: Likewise.

6 years agoUpdated Spanish translation for the gas directory.
Nick Clifton [Wed, 25 Apr 2018 09:05:12 +0000 (10:05 +0100)]
Updated Spanish translation for the gas directory.

6 years agoSilence gcc-8 warnings
Alan Modra [Wed, 25 Apr 2018 03:57:22 +0000 (13:27 +0930)]
Silence gcc-8 warnings

This seems to work with gcc-8 and a bunch of prior gcc versions I tested.

* elf-linux-core.h: Disable gcc-8 string truncation warning.
* elf.c (elfcore_write_prpsinfo): Likewise.

6 years agoFix bug with relocation addends and merge sections with --icf.
Cary Coutant [Wed, 25 Apr 2018 04:57:37 +0000 (21:57 -0700)]
Fix bug with relocation addends and merge sections with --icf.

During --icf processing, gold was incorrectly processing the relocation
addend for references to items in a merge section. PC-relative references
and other forms of reference with a biased base address require a
non-section local symbol, where the addend is purely the bias.

gold/
PR gold/20642
PR gold/22820
* gc.h (gc_process_relocs): Flag STT_SECTION symbols in symvec.
* icf.cc (get_section_contents): For merge sections, ignore the
addend for relocations against non-section symbols.

6 years agoRemove arm-aout and arm-coff support
Alan Modra [Mon, 16 Apr 2018 11:03:36 +0000 (20:33 +0930)]
Remove arm-aout and arm-coff support

This also removes arm-netbsd (not arm-netbsdelf!), arm-openbsd, and
arm-riscix.  Those targets weren't on the obsolete list but they are
all aout, and it doesn't make all that much sense to remove arm-aout
without removing them too.

bfd/
* Makefile.am: Remove arm-aout and arm-coff support.
* config.bfd: Likewise.
* configure.ac: Likewise.
* targets.c: Likewise.
* aout-arm.c: Delete.
* armnetbsd.c: Delete.
* riscix.c: Delete.
* Makefile.in: Regenerate.
* configure: Regenerate.
* po/SRC-POTFILES.in: Regenerate.
binutils/
* testsuite/binutils-all/arm/objdump.exp: Remove arm-aout and
arm-coff support.
* testsuite/binutils-all/objcopy.exp: Likewise.
* testsuite/lib/binutils-common.exp: Likewise.
gas/
* Makefile.am: Remove arm-aout and arm-coff support.
* config/tc-arm.c: Likewise.
* config/tc-arm.h: Likewise.
* configure.tgt: Likewise.
* testsuite/gas/aarch64/codealign.d: Likewise.
* testsuite/gas/aarch64/mapping.d: Likewise.
* testsuite/gas/aarch64/mapping2.d: Likewise.
* testsuite/gas/arm/adds-thumb1-reloc-local-armv7-m.d: Likewise.
* testsuite/gas/arm/adds-thumb1-reloc-local.d: Likewise.
* testsuite/gas/arm/addsw-bad.d: Likewise.
* testsuite/gas/arm/align.d: Likewise.
* testsuite/gas/arm/align64.d: Likewise.
* testsuite/gas/arm/arch7.d: Likewise.
* testsuite/gas/arm/arch7a-mp.d: Likewise.
* testsuite/gas/arm/arch7em.d: Likewise.
* testsuite/gas/arm/archv8m-main-dsp-5.d: Likewise.
* testsuite/gas/arm/arm-it-auto-2.d: Likewise.
* testsuite/gas/arm/arm-it-auto-3.d: Likewise.
* testsuite/gas/arm/arm-it-auto.d: Likewise.
* testsuite/gas/arm/arm-it-bad-2.d: Likewise.
* testsuite/gas/arm/arm-it.d: Likewise.
* testsuite/gas/arm/armv7e-m+fpv5-d16.d: Likewise.
* testsuite/gas/arm/armv7e-m+fpv5-sp-d16.d: Likewise.
* testsuite/gas/arm/armv8-2-fp16-scalar-thumb.d: Likewise.
* testsuite/gas/arm/armv8-2-fp16-scalar.d: Likewise.
* testsuite/gas/arm/armv8-2-fp16-simd-thumb.d: Likewise.
* testsuite/gas/arm/armv8-2-fp16-simd.d: Likewise.
* testsuite/gas/arm/armv8-a+crypto.d: Likewise.
* testsuite/gas/arm/armv8-a+fp.d: Likewise.
* testsuite/gas/arm/armv8-a+ras.d: Likewise.
* testsuite/gas/arm/armv8-a+rdma-warning.d: Likewise.
* testsuite/gas/arm/armv8-a+rdma.d: Likewise.
* testsuite/gas/arm/armv8-a+simd.d: Likewise.
* testsuite/gas/arm/armv8-a-barrier-thumb.d: Likewise.
* testsuite/gas/arm/armv8-r+fp.d: Likewise.
* testsuite/gas/arm/armv8-r+simd.d: Likewise.
* testsuite/gas/arm/armv8-r-barrier-thumb.d: Likewise.
* testsuite/gas/arm/armv8_1-a+simd.d: Likewise.
* testsuite/gas/arm/armv8_2+rdma.d: Likewise.
* testsuite/gas/arm/armv8_2-a.d: Likewise.
* testsuite/gas/arm/armv8_3-a-fp.d: Likewise.
* testsuite/gas/arm/armv8_3-a-simd.d: Likewise.
* testsuite/gas/arm/armv8a-automatic-hlt.d: Likewise.
* testsuite/gas/arm/armv8a-automatic-lda.d: Likewise.
* testsuite/gas/arm/attr-syntax.d: Likewise.
* testsuite/gas/arm/automatic-bw.d: Likewise.
* testsuite/gas/arm/automatic-cbz.d: Likewise.
* testsuite/gas/arm/automatic-clrex.d: Likewise.
* testsuite/gas/arm/automatic-lda.d: Likewise.
* testsuite/gas/arm/automatic-ldaex.d: Likewise.
* testsuite/gas/arm/automatic-ldaexb.d: Likewise.
* testsuite/gas/arm/automatic-ldrex.d: Likewise.
* testsuite/gas/arm/automatic-ldrexd.d: Likewise.
* testsuite/gas/arm/automatic-movw.d: Likewise.
* testsuite/gas/arm/automatic-sdiv.d: Likewise.
* testsuite/gas/arm/automatic-strexb.d: Likewise.
* testsuite/gas/arm/barrier-bad-thumb.d: Likewise.
* testsuite/gas/arm/barrier-bad.d: Likewise.
* testsuite/gas/arm/barrier-thumb.d: Likewise.
* testsuite/gas/arm/barrier.d: Likewise.
* testsuite/gas/arm/bignum1.d: Likewise.
* testsuite/gas/arm/blx-bad.d: Likewise.
* testsuite/gas/arm/blx-bl-convert.d: Likewise.
* testsuite/gas/arm/blx-local.s: Likewise.
* testsuite/gas/arm/crc32-armv8-a-bad.d: Likewise.
* testsuite/gas/arm/crc32-armv8-a.d: Likewise.
* testsuite/gas/arm/crc32-armv8-r-bad.d: Likewise.
* testsuite/gas/arm/crc32-armv8-r.d: Likewise.
* testsuite/gas/arm/dis-data.d: Likewise.
* testsuite/gas/arm/dis-data2.d: Likewise.
* testsuite/gas/arm/dis-data3.d: Likewise.
* testsuite/gas/arm/eabi_attr_1.d: Likewise.
* testsuite/gas/arm/fp-save.d: Likewise.
* testsuite/gas/arm/group-reloc-alu-encoding-bad.d: Likewise.
* testsuite/gas/arm/group-reloc-alu-parsing-bad.d: Likewise.
* testsuite/gas/arm/group-reloc-alu.d: Likewise.
* testsuite/gas/arm/group-reloc-ldc-encoding-bad.d: Likewise.
* testsuite/gas/arm/group-reloc-ldc-parsing-bad.d: Likewise.
* testsuite/gas/arm/group-reloc-ldc.d: Likewise.
* testsuite/gas/arm/group-reloc-ldr-encoding-bad.d: Likewise.
* testsuite/gas/arm/group-reloc-ldr-parsing-bad.d: Likewise.
* testsuite/gas/arm/group-reloc-ldr.d: Likewise.
* testsuite/gas/arm/group-reloc-ldrs-encoding-bad.d: Likewise.
* testsuite/gas/arm/group-reloc-ldrs-parsing-bad.d: Likewise.
* testsuite/gas/arm/group-reloc-ldrs.d: Likewise.
* testsuite/gas/arm/insn-error-a.d: Likewise.
* testsuite/gas/arm/insn-error-t.d: Likewise.
* testsuite/gas/arm/inst-po-2.d: Likewise.
* testsuite/gas/arm/inst-po-3.d: Likewise.
* testsuite/gas/arm/inst-po-be.d: Likewise.
* testsuite/gas/arm/inst-po.d: Likewise.
* testsuite/gas/arm/ldconst.d: Likewise.
* testsuite/gas/arm/ldgesb-bad.d: Likewise.
* testsuite/gas/arm/ldgesh-bad.d: Likewise.
* testsuite/gas/arm/ldst-offset0.d: Likewise.
* testsuite/gas/arm/local_function.d: Likewise.
* testsuite/gas/arm/local_label_coff.d: Likewise.
* testsuite/gas/arm/local_label_elf.d: Likewise.
* testsuite/gas/arm/mapping.d: Likewise.
* testsuite/gas/arm/mapping2.d: Likewise.
* testsuite/gas/arm/mapping3.d: Likewise.
* testsuite/gas/arm/mapping4.d: Likewise.
* testsuite/gas/arm/mapshort-elf.d: Likewise.
* testsuite/gas/arm/mask_1-armv8-a.d: Likewise.
* testsuite/gas/arm/mask_1-armv8-r.d: Likewise.
* testsuite/gas/arm/movs-thumb1-reloc-local-armv7-m.d: Likewise.
* testsuite/gas/arm/movs-thumb1-reloc-local.d: Likewise.
* testsuite/gas/arm/movw-local.d: Likewise.
* testsuite/gas/arm/mrs-msr-thumb-v6t2.d: Likewise.
* testsuite/gas/arm/mrs-msr-thumb-v7-m.d: Likewise.
* testsuite/gas/arm/mrs-msr-thumb-v7e-m.d: Likewise.
* testsuite/gas/arm/msr-imm-bad.d: Likewise.
* testsuite/gas/arm/msr-reg-bad.d: Likewise.
* testsuite/gas/arm/msr-reg-thumb.d: Likewise.
* testsuite/gas/arm/nomapping.d: Likewise.
* testsuite/gas/arm/nops.d: Likewise.
* testsuite/gas/arm/pic.d: Likewise.
* testsuite/gas/arm/pinsn.d: Likewise.
* testsuite/gas/arm/plt-1.d: Likewise.
* testsuite/gas/arm/pr21458.d: Likewise.
* testsuite/gas/arm/pr9722.d: Likewise.
* testsuite/gas/arm/strex-t.d: Likewise.
* testsuite/gas/arm/t2-branch-global.d: Likewise.
* testsuite/gas/arm/target-reloc-1.d: Likewise.
* testsuite/gas/arm/thumb-b-bad.d: Likewise.
* testsuite/gas/arm/thumb-w-bad.d: Likewise.
* testsuite/gas/arm/thumb-w-good.d: Likewise.
* testsuite/gas/arm/thumb.d: Likewise.
* testsuite/gas/arm/thumb2_it.d: Likewise.
* testsuite/gas/arm/thumb2_it_auto.d: Likewise.
* testsuite/gas/arm/thumb2_it_search.d: Likewise.
* testsuite/gas/arm/thumb2_ldmstm.d: Likewise.
* testsuite/gas/arm/thumb2_ldr_immediate_armv6.d: Likewise.
* testsuite/gas/arm/thumb2_ldr_immediate_armv6t2.d: Likewise.
* testsuite/gas/arm/thumb2_ldr_immediate_highregs_armv6t2.d: Likewise.
* testsuite/gas/arm/thumb2_pool.d: Likewise.
* testsuite/gas/arm/thumb2_vpool.d: Likewise.
* testsuite/gas/arm/thumb2_vpool_be.d: Likewise.
* testsuite/gas/arm/thumb32.d: Likewise.
* testsuite/gas/arm/thumbver.d: Likewise.
* testsuite/gas/arm/tls.d: Likewise.
* testsuite/gas/arm/tls_vxworks.d: Likewise.
* testsuite/gas/arm/undefined.d: Likewise.
* testsuite/gas/arm/undefined_coff.d: Likewise.
* testsuite/gas/arm/unwind.d: Likewise.
* testsuite/gas/arm/v4bx.d: Likewise.
* testsuite/gas/arm/vcmp-noprefix-imm.d: Likewise.
* testsuite/gas/arm/vcvt-bad.d: Likewise.
* testsuite/gas/arm/vfma1.d: Likewise.
* testsuite/gas/arm/vldconst.d: Likewise.
* testsuite/gas/arm/vldconst_be.d: Likewise.
* testsuite/gas/arm/vldm-arm.d: Likewise.
* testsuite/gas/arm/vldr.d: Likewise.
* testsuite/gas/arm/weakdef-1.d: Likewise.
* testsuite/gas/arm/weakdef-2.d: Likewise.
* config/te-riscix.h: Delete.
* Makefile.in: Regenerate.
* po/POTFILES.in: Regenerate.
ld/
* Makefile.am: Remove arm-aout and arm-coff support.
* configure.tgt: Likewise.
* testsuite/ld-arm/attr-merge-div-00.d: Likewise.
* testsuite/ld-arm/attr-merge-div-01-m3.d: Likewise.
* testsuite/ld-arm/attr-merge-div-01.d: Likewise.
* testsuite/ld-arm/attr-merge-div-02.d: Likewise.
* testsuite/ld-arm/attr-merge-div-10-m3.d: Likewise.
* testsuite/ld-arm/attr-merge-div-10.d: Likewise.
* testsuite/ld-arm/attr-merge-div-11.d: Likewise.
* testsuite/ld-arm/attr-merge-div-12.d: Likewise.
* testsuite/ld-arm/attr-merge-div-120.d: Likewise.
* testsuite/ld-arm/attr-merge-div-20.d: Likewise.
* testsuite/ld-arm/attr-merge-div-21.d: Likewise.
* testsuite/ld-arm/attr-merge-div-22.d: Likewise.
* testsuite/ld-arm/attr-merge-hardfp-use-1.d: Likewise.
* testsuite/ld-arm/attr-merge-hardfp-use-2.d: Likewise.
* testsuite/ld-arm/attr-merge-nosection-1.d: Likewise.
* testsuite/ld-arm/attr-merge-unknown-2.d: Likewise.
* testsuite/ld-arm/attr-merge-unknown-2r.d: Likewise.
* testsuite/ld-arm/attr-merge-unknown-3.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-1.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-10.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-10r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-11.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-11r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-12.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-12r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-13.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-13r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-14.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-14r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-1r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-2.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-2r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-3.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-3r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-4.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-4r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-5.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-5r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-6.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-6r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-7.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-7r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-8.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-8r.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-9.d: Likewise.
* testsuite/ld-arm/attr-merge-vfp-9r.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-00-nowarn.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-00.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-02-nowarn.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-02.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-04-nowarn.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-04.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-20-nowarn.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-20.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-22-nowarn.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-22.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-24-nowarn.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-40-nowarn.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-40.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-42-nowarn.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-44-nowarn.d: Likewise.
* testsuite/ld-arm/attr-merge-wchar-44.d: Likewise.
* testsuite/ld-arm/eabi-hard-float.d: Likewise.
* testsuite/ld-arm/eabi-soft-float-ABI4.d: Likewise.
* testsuite/ld-arm/eabi-soft-float-r.d: Likewise.
* testsuite/ld-arm/eabi-soft-float.d: Likewise.
* testsuite/ld-arm/gc-hidden-1.d: Likewise.
* emulparams/armaoutb.sh: Delete.
* emulparams/armaoutl.sh: Delete.
* emulparams/armcoff.sh: Delete.
* emulparams/armnbsd.sh: Delete.
* emulparams/riscix.sh: Delete.
* scripttempl/armaout.sc: Delete.
* scripttempl/armcoff.sc: Delete.
* scripttempl/riscix.sc: Delete.
* Makefile.in: Regenerate.
* po/BLD-POTFILES.in: Regenerate.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 25 Apr 2018 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoFix internal error caused by conflicting default version definitions.
Cary Coutant [Mon, 23 Apr 2018 16:27:35 +0000 (09:27 -0700)]
Fix internal error caused by conflicting default version definitions.

gold/
PR gold/16504
* dynobj.cc (Versions::symbol_section_contents): Don't set
VERSYM_HIDDEN flag for undefined symbols.
* symtab.cc (Symbol_table::add_from_object): Don't override default
version definition with a different default version.
* symtab.h (Symbol::from_dyn): New method.
* testsuite/plugin_test.c (struct sym_info): Add ver field.
(claim_file_hook): Pass symbol version to plugin API.
(parse_readelf_line): Parse symbol version.
* testsuite/Makefile.am (ver_test_pr16504): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/ver_test_pr16504.sh: New test script.
* testsuite/ver_test_pr16504_a.c: New source file.
* testsuite/ver_test_pr16504_a.script: New version script.
* testsuite/ver_test_pr16504_b.c: New source file.
* testsuite/ver_test_pr16504_b.script: New version script.

6 years agoEnable 'set print inferior-events' and improve detach/fork/kill/exit messages
Sergio Durigan Junior [Wed, 31 Jan 2018 00:09:42 +0000 (19:09 -0500)]
Enable 'set print inferior-events' and improve detach/fork/kill/exit messages

This patch aims to turn 'set print inferior-events' always on, and do
some cleanup on the messages printed by GDB when various inferior
events happen (attach, detach, fork, kill, exit).

To make sure that the patch is correct, I've tested it with a handful
of combinations of 'set follow-fork-mode', 'set detach-on-fork' and
'set print inferior-events'.  In the end, I decided to make my
hand-made test into an official testcase.  More on that below.

Using the following program as an example:

  #include <unistd.h>
  int main ()
  {
    fork ();
    return 0;
  }

We see the following outputs from the patched GDB:

- With 'set print inferior-events on':

    (gdb) r
    Starting program: a.out
    [Detaching after fork from child process 27749]
    [Inferior 1 (process 27745) exited normally]
    (gdb)

- With 'set print inferior-events off':

    (gdb) r
    Starting program: a.out
    [Inferior 1 (process 27823) exited normally]
    (gdb)

  Comparing this against an unpatched GDB:

- With 'set print inferior-events off' and 'set follow-fork-mode
  child':

    (gdb) r
    Starting program: a.out
    [Inferior 2 (process 5993) exited normally]
    (gdb)

  Compare this against an unpatched GDB:

    (unpatched-gdb) r
    Starting program: a.out
    [New process 5702]
    [Inferior 2 (process 5702) exited normally]
    (unpatched-gdb)

  It is possible to notice that, in this scenario, the patched GDB
  will lose the '[New process %d]' message.

- With 'set print inferior-events on', 'set follow-fork-mode child'
  and 'set detach-on-fork on':

    (gdb) r
    Starting program: a.out
    [Attaching after process 27905 fork to child process 27909]
    [New inferior 2 (process 27909)]
    [Detaching after fork from parent process 27905]
    [Inferior 1 (process 27905) detached]
    [Inferior 2 (process 27909) exited normally]
    (gdb)

  Compare this output with an unpatched GDB, using the same settings:

    (unpatched-gdb) r
    Starting program: a.out
    [New inferior 28033]
    [Inferior 28029 detached]
    [New process 28033]
    [Inferior 2 (process 28033) exited normally]
    [Inferior 28033 exited]
    (unpatched-gdb)

As can be seen above, I've also made a few modifications to messages
that are printed when 'set print inferior-events' is on.  For example,
a few of the messages did not contain the '[' and ']' as
prefix/suffix, which led to a few inconsistencies like:

  Attaching after process 22995 fork to child process 22999.
  [New inferior 22999]
  Detaching after fork from child process 22999.
  [Inferior 22995 detached]
  [Inferior 2 (process 22999) exited normally]

So I took the opportunity and included the square brackets where
applicable.  I have also made the existing messages more uniform, by
always printing "Inferior %d (process %d)..." where applicable.  This
makes it easier to identify the inferior number and the PID number
from the messages.

As suggested by Pedro, the "[Inferior %d exited]" message from
'exit_inferior' has been removed, because it got duplicated when
'inferior-events' is on.  I'm also using the
'add_{thread,inferior}_silent' versions (instead of their verbose
counterparts) on some locations, also to avoid duplicated messages.
For example, a patched GDB with 'set print inferior-events on', 'set
detach-on-fork on' and 'set follow-fork-mode child', but using
'add_thread', would print:

  (gdb) run
  Starting program: a.out
  [Attaching after process 25088 fork to child process 25092.]
  [New inferior 25092]   <--- duplicated
  [Detaching after fork from child process 25092.]
  [Inferior 25088 detached]
  [New process 25092]    <--- duplicated
  [Inferior 2 (process 25092) exited normally]

But if we use 'add_thread_silent' (with the same configuration as
before):

  (gdb) run
  Starting program: a.out
  [Attaching after process 31606 fork to child process 31610]
  [New inferior 2 (process 31610)]
  [Detaching after fork from parent process 31606]
  [Inferior 1 (process 31606) detached]
  [Inferior 2 (process 31610) exited normally]

As for the tests, the configuration options being exercised are:

- follow-fork-mode: child/parent
- detach-on-fork: on/off
- print inferior-events: on/off

It was also necessary to perform adjustments on several testcases,
because the expected messages changed considerably.

Built and regtested on BuildBot, without regressions.

gdb/ChangeLog:
2018-04-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>
    Pedro Alves  <palves@redhat.com>

* infcmd.c (kill_command): Print message when inferior has
been killed.
* inferior.c (print_inferior_events): Remove 'static'.  Set as
'1'.
(add_inferior): Improve message printed when
'print_inferior_events' is on.
(exit_inferior): Remove message printed when
'print_inferior_events' is on.
(detach_inferior): Improve message printed when
'print_inferior_events' is on.
(initialize_inferiors): Use 'add_inferior_silent' to set
'current_inferior_'.
* inferior.h (print_inferior_events): Declare here as
'extern'.
* infrun.c (follow_fork_inferior): Print '[Attaching...]' or
'[Detaching...]' messages when 'print_inferior_events' is on.
Use 'add_thread_silent' instead of 'add_thread'.  Add '[' and ']'
as prefix/suffix for messages.  Remove periods.  Fix erroneous
'Detaching after fork from child...', replace it by '... from
parent...'.
(handle_vfork_child_exec_or_exit): Add '[' and ']' as
prefix/suffix when printing 'Detaching...' messages.  Print
them when 'print_inferior_events' is on.
* remote.c (remote_detach_1): Print message when detaching
from inferior and '!is_fork_parent'.

gdb/testsuite/ChangeLog:
2018-04-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>
    Pedro Alves  <palves@redhat.com>

* gdb.base/attach-non-pgrp-leader.exp: Adjust 'Detaching...'
regexps to expect for '[Inferior ... detached]' as well.
* gdb.base/attach.exp: Likewise.
* gdb.base/catch-syscall.exp (check_for_program_end): Adjust
"gdb_continue_to_end".
(test_catch_syscall_with_wrong_args): Likewise.
* gdb.base/foll-fork.exp: Adjust regexps to match '[' and
']'.  Don't set 'verbose' on.
* gdb.base/foll-vfork.exp: Likewise.
* gdb.base/fork-print-inferior-events.c: New file.
* gdb.base/fork-print-inferior-events.exp: New file.
* gdb.base/hook-stop.exp: Adjust regexps to expect for new
'[Inferior ... has been killed]' message.
* gdb.base/kill-after-signal.exp: Likewise.
* gdb.base/solib-overlap.exp: Adjust regexps to expect for new
detach message.
* gdb.threads/kill.exp: Adjust regexps to expect for new kill
message.
* gdb.threads/clone-attach-detach.exp: Adjust 'Detaching...'
regexps to expect for '[Inferior ... detached]' as well.
* gdb.threads/process-dies-while-detaching.exp: Likewise.

6 years agoFix an illegal memory access when trying to copy an ELF binary with corrupt section...
Nick Clifton [Tue, 24 Apr 2018 15:57:04 +0000 (16:57 +0100)]
Fix an illegal memory access when trying to copy an ELF binary with corrupt section symbols.

PR 23113
* elf.c (ignore_section_sym): Check for the output_section pointer
being NULL before dereferencing it.

6 years agoFix an illegal memory access when copying a PE format file with corrupt debug informa...
Nick Clifton [Tue, 24 Apr 2018 15:31:27 +0000 (16:31 +0100)]
Fix an illegal memory access when copying a PE format file with corrupt debug information.

PR 23110
* peXXigen.c (_bfd_XX_bfd_copy_private_bfd_data_common): Check for
a negative PE_DEBUG_DATA size before iterating over the debug data.

6 years agoinfo-shared.exp: Replace libs=-ldl with shlib_load
Simon Marchi [Tue, 24 Apr 2018 14:14:14 +0000 (10:14 -0400)]
info-shared.exp: Replace libs=-ldl with shlib_load

As reported in PR 23104, -ldl doesn't work on FreeBSD.  Replace it with
shlib_load, which adds the right flags for dynamic library loading based
on the current target platform.

The test still passes on Linux, and should now pass on FreeBSD, though I
did not test personally.

gdb/testsuite/ChangeLog:

PR gdb/23104
* gdb.base/info-shared.exp: Replace libs=-ldl with shlib_load.

6 years agoReindent cli-out.h
Tom Tromey [Sun, 22 Apr 2018 23:57:32 +0000 (17:57 -0600)]
Reindent cli-out.h

I noticed that cli-out.h had incorrect indentation in some spots.
This fixes it.

ChangeLog
2018-04-24  Tom Tromey  <tom@tromey.com>

* cli-out.h: Reindent.

6 years agoRemove cli_ui_out::out_field_fmt
Tom Tromey [Sun, 22 Apr 2018 23:54:20 +0000 (17:54 -0600)]
Remove cli_ui_out::out_field_fmt

I noticed that cli_ui_out::out_field_fmt is only used by a single
caller, and it can easily be replaced by fputs_filtered.  So, this
patch removes it.

ChangeLog
2018-04-24  Tom Tromey  <tom@tromey.com>

* cli-out.c (cli_ui_out::out_field_fmt): Remove.
(cli_ui_out::do_field_string): Use fputs_filtered.
* cli-out.h (class cli_ui_out) <out_field_fmt>: Remove.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 24 Apr 2018 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoRemove a cleanup from scm-frame.c
Tom Tromey [Sat, 21 Apr 2018 22:38:33 +0000 (16:38 -0600)]
Remove a cleanup from scm-frame.c

This removes a cleanup from scm-frame.c, replacing it with
unique_xmalloc_ptr and a new scope.  I believe this also fixes a
latent bug involving calling do_cleanups twice for a single cleanup.

Regression tested using the gdb.guile test suite on x86-64 Fedora 26.

ChangeLog
2018-04-23  Tom Tromey  <tom@tromey.com>

* guile/scm-frame.c (gdbscm_frame_read_var): Use
gdb::unique_xmalloc_ptr.

6 years agoRegenerate gdb/configure and gdbserver/configure
Tom Tromey [Mon, 23 Apr 2018 15:21:18 +0000 (09:21 -0600)]
Regenerate gdb/configure and gdbserver/configure

Pedro pointed out that gdb/configure and gdbserver/configure weren't
updated after some recent *.m4 changes.

This patch rebuilds those files.  Tested by rebuilding.  Pedro
approved this in the thread where he raised this issue, so I'm pushing
it in.

ChangeLog
2018-04-23  Tom Tromey  <tom@tromey.com>

* configure: Rebuild.

gdbserver/ChangeLog
2018-04-23  Tom Tromey  <tom@tromey.com>

* configure: Rebuild.

6 years agoRevert bfd part of "Silence gcc-8 warnings"
Alan Modra [Mon, 23 Apr 2018 14:17:22 +0000 (23:47 +0930)]
Revert bfd part of "Silence gcc-8 warnings"

The gcc warning has been fixed, and the patch regressed builds with
some older versions of gcc.

* elf-linux-core.h: Revert last change.
* elf.c: Likewise.

6 years agoPrevent an illegal memory access in gprof by ensuring that string tables for aout...
Nick Clifton [Mon, 23 Apr 2018 11:52:42 +0000 (12:52 +0100)]
Prevent an illegal memory access in gprof by ensuring that string tables for aout format files are always zero-terminated.

PR 23056
* aoutx.h (aout_get_external_symbols): Allocate an extra byte at
the end of the string table, and zero it.