]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
7 years agoDecouple user selection from internal selection users/simark/user-selection-rfc
Simon Marchi [Thu, 8 Dec 2016 18:06:14 +0000 (13:06 -0500)] 
Decouple user selection from internal selection

I am sending this as an RFC because it's far from complete and
definitive, but I'd like to gather some comments and opinions before
going further in this direction.

The goal of this patch is to decouple the notion of the user-selected
inferior/thread/frame from GDB's internally selected
inferior/thread/frame.

Currently, for example, the inferior_ptid variable has two jobs:

 - it's the user-selected thread: it's changed by the "thread" command.
   Other commands (continue, backtrace, etc) apply to this thread.
 - it's the internally-selected thread: it defines the thread GDB is
   currently "working" on.  For example, implementations of
   to_xfer_partial will refer to it to know from which thread to
   read/write memory.

Because of this dual usage, if we want to do some operations on a thread
other than the currently selected one, we have to save the current
inferior/thread/frame and restore them when we're done.  Failing to do
so would result in an unexpected selection switch for the user.

To improve this, Pedro suggested in [1] to decouple the two concepts.  This
is essentially what this patch is trying to do.

A new "user_selection" object is introduced, which contains the selected
inferior/thread/frame from the point of view of the user.  Before every
command, we "apply" this selection to the core of GDB to make sure the
internal selection matches the user selection.

There is a single user selection for the whole GDB (named "global
user-selection"), but as was mentioned in the linked thread, it opens
the door to having different selections for different UIs.  This means
that each UI would have its own user-selection object, which would be
applied to the core prior to executing commands from this UI.

The global user-selection object only gets modified when we really
intend to change it.  It can be because of the thread / -thread-select /
up / down / frame / inferior commands, a breakpoint hit in all-stop, an
inferior exit, etc.

The problem that initially prompted this effort is that the "--thread"
flag of MI commands changes the user-selected thread under the user's
feet.  My initial attempt to fix it was to restore the selection after
the MI command execution.  However, some cases are hard to get right.
For example:

  (thread 1 is currently selected)
  -interpreter-exec --thread 2 console "thread 3"

Restoring the selected thread to thread 1 after the MI command execution
wrongfully cancels the switch to thread 3.  So it's hard to determine
when we should or shouldn't restore.   With the current patch, it works
naturally: the --thread flag doesn't touch the user-selected thread,
only the internal one.  The "thread 3" command updates the user
selection.

Another difficulty is to send the right notifications to MI when the
user selection changes.  That means to not miss any, but not send too
many either.  Getting it somewhat right lead to ugly hacks (see the
command_notifies_uscc_observer function) and even then it's not perfect
(see the kfails in user-selected-context-sync.exp test).  With the
proposed method, it's easy to know when the user-selection changes and
send notifications.

With this patch, there are probably a few usage of
make_cleanup_restore_current_thread that are not needed anymore, if they
are only used to restore the user selection.  I kept removing them for a
later time though.

In the current state, there are a few minor regressions in the testsuite
(especially some follow-fork stuff I'm not sure how to handle), but the
vast majority of the previously passing tests still pass.

Comments are welcome!

Thanks,

Simon

[1] https://sourceware.org/ml/gdb-patches/2016-08/msg00031.html

7 years agoDWARF-5: testcase
Jan Kratochvil [Thu, 23 Feb 2017 21:54:02 +0000 (22:54 +0100)] 
DWARF-5: testcase

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

* testsuite/binutils-all/dw5.S: New file.
* testsuite/binutils-all/dw5.W: New file.
* testsuite/binutils-all/readelf.exp (readelf -wiaoRlL): New test.

7 years agoDWARF-5: DW_FORM_data16
Jan Kratochvil [Thu, 23 Feb 2017 21:54:02 +0000 (22:54 +0100)] 
DWARF-5: DW_FORM_data16

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

* dwarf.c (read_and_display_attr_value): Support DW_FORM_data16.

7 years agoDWARF-5: Macros
Jan Kratochvil [Thu, 23 Feb 2017 21:54:01 +0000 (22:54 +0100)] 
DWARF-5: Macros

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

* dwarf.c (display_debug_macro): Support DWARF-5.  Rename
DW_MACRO_GNU_*.

7 years agoDWARF-5: call sites
Jan Kratochvil [Thu, 23 Feb 2017 21:54:01 +0000 (22:54 +0100)] 
DWARF-5: call sites

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

* dwarf.c (decode_location_expression): Support DW_OP_implicit_pointer,
DW_OP_const_type, DW_OP_regval_type, DW_OP_deref_type, DW_OP_convert
and DW_OP_reinterpret.
(read_and_display_attr_value): Support DW_AT_call_value,
DW_AT_call_data_value, DW_AT_call_target and
DW_AT_call_target_clobbered.

7 years agoDWARF-5 basic functionality
Jan Kratochvil [Thu, 23 Feb 2017 21:54:01 +0000 (22:54 +0100)] 
DWARF-5 basic functionality

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

* dwarf.c (fetch_indirect_line_string): New function.
(abbrev_attr): New field implicit_const.
(add_abbrev_attr): New parameter implicit_const.
(process_abbrev_section): Support DW_FORM_implicit_const.
(decode_location_expression): Support DW_OP_entry_value.
(read_and_display_attr_value): Add parameter implicit_const.  Support
DW_FORM_line_strp and DW_FORM_implicit_const.
(read_and_display_attr): Add parameter implicit_const.
(process_debug_info): Support line_str and DWARF-5.
(read_debug_line_header): Support DWARF-5.
(display_formatted_table): New function.
(display_debug_lines_raw): New parameter file.  Support DWARF-5.
(display_debug_lines_decoded): New parameter fileptr.  Support DWARF-5.
(display_debug_lines): Pass file parameter.
(display_debug_macro): Update read_and_display_attr_value caller.
(display_debug_abbrev): Support DW_FORM_implicit_const.
(display_loclists_list): New function.
(display_loc_list): Support .debug_loclists.
(display_debug_ranges_list): New function from display_debug_ranges.
(display_debug_rnglists_list): New function.
(display_debug_ranges): Support .debug_rnglists.
(debug_displays): Add .debug_line_str, .debug_loclists and
.debug_rnglists.
* dwarf.h: Include dwarf2.h
(DWARF2_Internal_LineInfo): Add li_offset_size.
(DWARF2_Internal_CompUnit): Add cu_unit_type.
(enum dwarf_section_display_enum): Add line_str.
* readelf.c (process_section_headers): Add rnglists and loclists.

7 years agoDWARF attrs: add delimiter
Jan Kratochvil [Thu, 23 Feb 2017 21:54:00 +0000 (22:54 +0100)] 
DWARF attrs: add delimiter

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

* dwarf.c (display_block): Add parameter delimiter.
(decode_location_expression): Update display_block callers.
(read_and_display_attr_value): Add parameter delimiter.
(read_and_display_attr, display_debug_macro): Update
read_and_display_attr_value caller.

7 years agoPR21166: Validate rdrand/rdseed support separately in gdb.reverse/insn-reverse-x86.c
Luis Machado [Thu, 23 Feb 2017 20:36:58 +0000 (14:36 -0600)] 
PR21166: Validate rdrand/rdseed support separately in gdb.reverse/insn-reverse-x86.c

As reported in PR21166, there are Intel processors out there that support
rdrand but not rdseed. The fix is to verify both features separately and only
run rdrand/rdseed tests if supported.

gdb/testsuite/ChangeLog:
2017-02-23  Luis Machado  <lgustavo@codesourcery.com>

* gdb.reverse/insn-reverse.x86.c (check_rdrand_support): Renamed to ...
(check_supported_features): ... this. Changed return type to void.
(supports_rdseed): New static global.
(rdseed): Check supports_rdseed.
(initialize): Call check_supported_features.

7 years agodwarf.c: Use more dwarf_vma
Jan Kratochvil [Thu, 23 Feb 2017 20:37:31 +0000 (21:37 +0100)] 
dwarf.c: Use more dwarf_vma

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

* dwarf.c (display_loc_list): Use dwarf_vma for offset, base_address
and off.
(display_loc_list_dwo): Use dwarf_vma for offset.
(display_debug_loc): Use dwarf_vma for offset, base_address.
(struct range_entry, range_entry_compar): Use dwarf_vma for
ranges_offset.
(display_debug_ranges): Use dwarf_vma for ranges_offset, offset and
base_address.

7 years agoS/390: Add support for new cpu architecture - arch12.
Andreas Krebbel [Mon, 2 Jan 2017 15:40:29 +0000 (16:40 +0100)] 
S/390: Add support for new cpu architecture - arch12.

This adds support of new instructions to the S/390 specific parts.

The important feature of the new instruction set is the support of
single and extended precision floating point vector operations.

Note: arch12 is NOT the official name of the new CPU.  It just
continues the series of archXX options supported as alternate names.
The archXX terminology refers to the edition number of the Principle
of Operations manual.  The official CPU name will be added later while
keeping support of the arch12 for backwards compatibility.

No testsuite regressions.

Committed to mainline.

Bye,

-Andreas-

opcodes/ChangeLog:

2017-02-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-mkopc.c (main): Accept arch12 as cpu string and vx2 as
facility.
* s390-opc.c: Add new operand description macros, new instruction
types, instruction masks, and new .insn instruction types.
* s390-opc.txt: Add new arch12 instructions.

include/ChangeLog:

2017-02-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* opcode/s390.h (enum s390_opcode_cpu_val): New value
S390_OPCODE_ARCH12.
(S390_INSTR_FLAG_VX2): New macro definition.

gas/ChangeLog:

2017-02-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* config/tc-s390.c (s390_parse_cpu): New entry for arch12.
* doc/as.texinfo: Document arch12 as cpu type.
* doc/c-s390.texi: Likewise.
* testsuite/gas/s390/s390.exp: Run arch12 specific tests.
* testsuite/gas/s390/zarch-arch12.d: New test.
* testsuite/gas/s390/zarch-arch12.s: New test.
* testsuite/gas/s390/zarch-z13.d: Rename some mnemonics in the
output patterns.

7 years agoUse gdb::function_view in iterate_over_symtabs & co
Pedro Alves [Wed, 22 Feb 2017 14:43:35 +0000 (14:43 +0000)] 
Use gdb::function_view in iterate_over_symtabs & co

I wanted to pass a lambda to iterate_over_symtabs (see following
patch), so I converted it to function_view, and then the rest is
cascaded from that.

This gets rid of a bunch of single-use callback functions and
corresponding manually managed callback capture types
(add_partial_datum, search_symbols_data, etc.) in favor of letting the
compiler generate them for us by using lambdas with a capture.  In a
couple cases, it was more natural to convert the existing function
callbacks to function objects (i.e., operator(), e.g.,
decode_compound_collector).

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

* ada-lang.c: Include "common/function-view.h".
(ada_iterate_over_symbols): Adjust to use function_view as
callback type.
(struct add_partial_datum, ada_complete_symbol_matcher): Delete.
(ada_make_symbol_completion_list): Use a lambda.
(ada_exc_search_name_matches): Delete.
(name_matches_regex): New.
(ada_add_global_exceptions): Use a lambda and name_matches_regex.
* compile/compile-c-support.c: Include "common/function-view.h".
(print_one_macro): Change prototype to accept a ui_file pointer.
(write_macro_definitions): Use a lambda.
* dwarf2read.c: Include "common/function-view.h".
(dw2_map_expand_apply, dw2_map_symtabs_matching_filename)
(dw2_expand_symtabs_matching): Adjust to use function_view as
callback type.
* language.h: Include "common/function-view.h".
(struct language_defn) <la_iterate_over_symbols>: Adjust to use
function_view as callback type.
(LA_ITERATE_OVER_SYMBOLS): Remove DATA parameter.
* linespec.c: Include "common/function-view.h".
(collect_info::add_symbol): New method.
(struct symbol_and_data_callback, iterate_inline_only, struct
symbol_matcher_data, iterate_name_matcher): Delete.
(iterate_over_all_matching_symtabs): Adjust to use function_view
as callback type and lambdas.
(iterate_over_file_blocks): Adjust to use function_view as
callback type.
(decode_compound_collector): Now a class with private fields.
(decode_compound_collector::release_symbols): New method.
(collect_one_symbol): Rename to...
(decode_compound_collector::operator()): ... this and adjust.
(lookup_prefix_sym): decode_compound_collector construction bits
move to decode_compound_collector ctor.  Pass the
decode_compound_collector object directly as callback.  Remove
cleanups and use decode_compound_collector::release_symbols
instead.
(symtab_collector): Now a class with private fields.
(symtab_collector::release_symtabs): New method.
(add_symtabs_to_list): Rename to...
(symtab_collector::operator()): ... this and adjust.
(collect_symtabs_from_filename): symtab_collector construction
bits move to symtab_collector ctor.  Pass the symtab_collector
object directly as callback.  Remove cleanups and use
symtab_collector::release_symtabs instead.
(collect_symbols): Delete.
(add_matching_symbols_to_info): Use lambdas.
* macrocmd.c (print_macro_callback): Delete.
(info_macro_command): Use a lambda.
(info_macros_command): Pass print_macro_definition as callable
directly.
(print_one_macro): Remove 'ignore' parameter.
(macro_list_command): Adjust.
* macrotab.c (macro_for_each_data::fn): Now a function_view.
(macro_for_each_data::user_data): Delete field.
(foreach_macro): Adjust to call the function_view.
(macro_for_each): Adjust to use function_view as callback type.
(foreach_macro_in_scope): Adjust to call the function_view.
(macro_for_each_in_scope): Adjust to use function_view as callback
type.
* macrotab.h: Include "common/function-view.h".
(macro_callback_fn): Declare a prototype instead of a pointer.
Remove "user_data" parameter.
(macro_for_each, macro_for_each_in_scope): Adjust to use
function_view as callback type.
* psymtab.c (partial_map_expand_apply)
(psym_map_symtabs_matching_filename, recursively_search_psymtabs):
Adjust to use function_view as callback type and to return bool.
(psym_expand_symtabs_matching): Adjust to use function_view as
callback types.
* symfile-debug.c (debug_qf_map_symtabs_matching_filename): Adjust
to use function_view as callback type and to return bool.
(debug_qf_expand_symtabs_matching): Adjust to use function_view as
callback types.
* symfile.c (expand_symtabs_matching): Adjust to use function_view
as callback types.
* symfile.h: Include "common/function-view.h".
(expand_symtabs_file_matcher_ftype)
(expand_symtabs_symbol_matcher_ftype)
(expand_symtabs_exp_notify_ftype): Remove "data" parameter and
return bool.
(quick_symbol_functions::map_symtabs_matching_filename)
(quick_symbol_functions::expand_symtabs_matching): Adjust to use
function_view as callback type and return bool.
(expand_symtabs_matching): Adjust to use function_view as callback
type.
(maintenance_expand_name_matcher)
(maintenance_expand_file_matcher): Delete.
(maintenance_expand_symtabs): Use lambdas.
* symtab.c (iterate_over_some_symtabs): Adjust to use
function_view as callback types and return bool.
(iterate_over_symtabs): Likewise.  Use unique_xmalloc_ptr instead
of a cleanup.
(lookup_symtab_callback): Delete.
(lookup_symtab): Use a lambda.
(iterate_over_symbols): Adjust to use function_view as callback
type.
(struct search_symbols_data, search_symbols_file_matches)
(search_symbols_name_matches): Delete.
(search_symbols): Use a pair of lambdas.
(struct add_name_data, add_macro_name, symbol_completion_matcher)
(symtab_expansion_callback): Delete.
(default_make_symbol_completion_list_break_on_1): Use lambdas.
* symtab.h: Include "common/function-view.h".
(iterate_over_some_symtabs): Adjust to use function_view as
callback type and return bool.
(iterate_over_symtabs): Adjust to use function_view as callback
type.
(symbol_found_callback_ftype): Remove 'data' parameter and return
bool.
(iterate_over_symbols): Adjust to use function_view as callback
type.

7 years agoIntroduce gdb::function_view
Pedro Alves [Thu, 23 Feb 2017 16:14:08 +0000 (16:14 +0000)] 
Introduce gdb::function_view

This commit adds a new function_view type.  This type holds a
non-owning reference to a callable.  It is meant to be used as
callback type of functions, instead of using the C-style pair of
function pointer and 'void *data' arguments.  function_view allows
passing references to stateful function objects / lambdas with
captures as callbacks efficiently, while function pointer + 'void *'
does not.

See the intro in the new function-view.h header for more.

Unit tests included, put into a new gdb/unittests/ subdir.

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

* Makefile.in (SUBDIR_UNITTESTS_SRCS, SUBDIR_UNITTESTS_OBS): New.
(%.o) <unittests/%.c>: New pattern.
* configure.ac ($development): Add $(SUBDIR_UNITTESTS_OBS) to
CONFIG_OBS, and $(SUBDIR_UNITTESTS_SRCS) to CONFIG_SRCS.
* common/function-view.h: New file.
* unittests/function-view-selftests.c: New file.
* configure: Regenerate.

7 years agoopcodes,gas: associate SPARC ASIs with an architecture level.
Sheldon Lobo [Thu, 23 Feb 2017 15:49:37 +0000 (07:49 -0800)] 
opcodes,gas: associate SPARC ASIs with an architecture level.

With this change an architecture level bump due to assembly ASIs will show
up as a warning/error depending on options passed to gas.

Tested with sparc64-linux-gnu, and it does not introduce any regressions.

gas/ChangeLog:

Add support for associating SPARC ASIs with an architecture level.
* config/tc-sparc.c (parse_sparc_asi): New encode SPARC ASIs.

opcodes/ChangeLog:

Add support for associating SPARC ASIs with an architecture level.
* include/opcode/sparc.h (sparc_asi): New sparc_asi struct.
* opcodes/sparc-opc.c (asi_table): Updated asi_table and encoding/
decoding of SPARC ASIs.

7 years agoFix usage of inferior_ptid in two thread_alive implementations
Simon Marchi [Thu, 23 Feb 2017 15:36:20 +0000 (10:36 -0500)] 
Fix usage of inferior_ptid in two thread_alive implementations

While inspecting some target code, I noticed that in these two
implementations of thread_alive, inferior_ptid is referenced directly
instead of using the ptid passed as parameters.  I guess that it is
wrong, although I can't really test it in both cases.

gdb/ChangeLog:

* bsd-uthread.c (bsd_uthread_thread_alive): Use ptid instead of
inferior_ptid.
* go32-nat.c (go32_thread_alive): Likewise.

7 years agoAdd support to readelf for displaying gnu attributes in architectures not known to...
Nick Clifton [Thu, 23 Feb 2017 13:45:21 +0000 (13:45 +0000)] 
Add support to readelf for displaying gnu attributes in architectures not known to support them.

* readelf.c (display_tag_value): Use an explicit signed type for
the tag parameter.
(display_gnu_attributes): Use an unsigned integer type for
attribute tags.
(display_power_gnu_attribute): Likewise.
(display_s390_gnu_attribute): Likewise.
(display_sparc_hwcaps): Likewise.
(display_sparc_hwcaps2): Likewise.
(display_sparc_gnu_attribute): Likewise.
(display_mips_gnu_attribute): Likewise.
(display_tic6x_attribute): Likewise.
(display_raw_attribute): Likewise.
(process_attributes): Likewise.
(process_arm_specific): Delete redundant function.
(process_power_specific): Likewise.
(process_s390_specific): Likewise.
(process_sparc_specific): Likewise.
(process_tic6x_specific): Likewise.
(process_msp430x_specific): Likewise.
(display_public_gnu_attributes): New function.  Displays known
information about an unknown gnu attribute.
(display_generic_attribute): New function.  Calls
display_tag_value for non-nul tags.
(process_arch_specific): Call process_attributes even for
architectures not known to specifically support gnu attributes.

7 years agoUse xfree rather than delete for varobj_iter
Yao Qi [Thu, 23 Feb 2017 11:57:46 +0000 (11:57 +0000)] 
Use xfree rather than delete for varobj_iter

ASAN reports an error,

-var-create container @ c^M
=================================================================^M
^[[1m^[[31m==21639==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x6030000805c0^M
^[[1m^[[0m    #0 0x7f2449b01b2a in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99b2a)^M
    #1 0xbb601d in update_dynamic_varobj_children ../../binutils-gdb/gdb/varobj.c:794^M
    #2 0xbb6556 in varobj_get_num_children(varobj*) ../../binutils-gdb/gdb/varobj.c:854^M
    #3 0x580cb4 in print_varobj ../../binutils-gdb/gdb/mi/mi-cmd-var.c:61^M
    #4 0x58138b in mi_cmd_var_create(char*, char**, int) ../../binutils-gdb/gdb/mi/mi-cmd-var.c:145^M
    #5 0x5967ce in mi_cmd_execute ../../binutils-gdb/gdb/mi/mi-main.c:2301^M
    #6 0x594b05 in captured_mi_execute_command ../../binutils-gdb/gdb/mi/mi-main.c:2001
....
^M
^[[1m^[[32m0x6030000805c0 is located 0 bytes inside of 32-byte region [0x6030000805c0,0x6030000805e0)^M
^[[1m^[[0m^[[1m^[[35mallocated by thread T0 here:^[[1m^[[0m^M
    #0 0x7f2449b00602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)^M
    #1 0x7d1596 in xmalloc ../../binutils-gdb/gdb/common/common-utils.c:43^M
    #2 0x604176 in py_varobj_iter_new ../../binutils-gdb/gdb/python/py-varobj.c:159^M
    #3 0x6042da in py_varobj_get_iterator(varobj*, _object*) ../../binutils-gdb/gdb/python/py-varobj.c:198^M
    #4 0xbb5806 in varobj_get_iterator ../../binutils-gdb/gdb/varobj.c:720^M
    #5 0xbb5b9b in update_dynamic_varobj_children ../../binutils-gdb/gdb/varobj.c:758^M

gdb:

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

* varobj-iter.h (varobj_iter_delete): Call xfree instead of
delete.

7 years agoUse delete instead of xfree for varobj_item
Yao Qi [Thu, 23 Feb 2017 11:05:03 +0000 (11:05 +0000)] 
Use delete instead of xfree for varobj_item

In commit 2f408ec (Use ui_file_as_string throughout more), we start to
new varobj_item,

> -  vitem = XNEW (struct varobj_item);
> +  vitem = new varobj_item ();

but we still use xfree.  This causes some ASAN errors,

-var-update container^M
=================================================================^M
^[[1m^[[31m==20660==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x602000090c10^M
^[[1m^[[0m    #0 0x2baa77d03631 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x54631)^M
    #1 0x80e0c8 in xfree(void*) /home/yao/SourceCode/gnu/gdb/git/gdb/common/common-utils.c:100^M
    #2 0xc13670 in varobj_clear_saved_item /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:727^M
    #3 0xc13957 in update_dynamic_varobj_children /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:752^M
    #4 0xc1841c in varobj_update(varobj**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:1699^M
    #5 0x5a2bf7 in varobj_update_one /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:712^M
    #6 0x5a2a41 in mi_cmd_var_update(char*, char**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:695^
........
^M
^[[1m^[[32m0x602000090c10 is located 0 bytes inside of 16-byte region [0x602000090c10,0x602000090c20)^M
^[[1m^[[0m^[[1m^[[35mallocated by thread T0 here:^[[1m^[[0m^M
    #0 0x2baa77d0415f in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5515f)^M
    #1 0x63613e in py_varobj_iter_next /home/yao/SourceCode/gnu/gdb/git/gdb/python/py-varobj.c:112^M
    #2 0xc13b89 in update_dynamic_varobj_children /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:776^M
    #3 0xc1841c in varobj_update(varobj**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:1699^M
    #4 0x5a2bf7 in varobj_update_one /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:712^M
    #5 0x5a2a41 in mi_cmd_var_update(char*, char**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:695^M

gdb:

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

* varobj.c (varobj_clear_saved_item): Use delete instead of
xfree.
(update_dynamic_varobj_children): Likewise.

7 years agogas: slightly relax .startof.()/.sizeof.() testcase
Jan Beulich [Thu, 23 Feb 2017 10:21:10 +0000 (11:21 +0100)] 
gas: slightly relax .startof.()/.sizeof.() testcase

7 years agox86: drop stray VEX opcode 82 references
Jan Beulich [Thu, 23 Feb 2017 10:03:55 +0000 (11:03 +0100)] 
x86: drop stray VEX opcode 82 references

No such ModR/M-less opcode has ever existed in public documentation
afaict, so I can't see why it had been added in the first place.
Furthermore opcode 77 is special only with implied prefix 0F.

7 years agox86: extend 64-bit invalid MPX insn forms testcase
Jan Beulich [Thu, 23 Feb 2017 10:00:44 +0000 (11:00 +0100)] 
x86: extend 64-bit invalid MPX insn forms testcase

7 years agoCorrect VLE 16D and SDAREL relocations
Alan Modra [Thu, 23 Feb 2017 01:50:42 +0000 (12:20 +1030)] 
Correct VLE 16D and SDAREL relocations

PR 20744
bfd/
* elf32-ppc.c (ppc_elf_howto_raw): Correct dst_mask on all VLE
16D relocations.
(ppc_elf_vle_split16): Correct field mask and shift for 16D relocs.
(ppc_elf_relocate_section): Correct calculation for VLE SDAREL
relocs.
ld/
* testsuite/ld-powerpc/vle-reloc-2.s: Use r6 for last insn of
each group.
* testsuite/ld-powerpc/vle-reloc-2.d: Update for above change
and sdarel reloc fix.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 23 Feb 2017 00:00:41 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoDisplay user op byte
Jan Kratochvil [Wed, 22 Feb 2017 19:22:59 +0000 (20:22 +0100)] 
Display user op byte

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

* dwarf.c (decode_location_expression): Display also OP.

7 years agoreadelf: Restore a lost new line in version information
Maciej W. Rozycki [Wed, 22 Feb 2017 18:09:41 +0000 (18:09 +0000)] 
readelf: Restore a lost new line in version information

Fix a commit 74e1a04b9787 ("More fixes for reading corrupt ELF files.")
`readelf --version-info' output formatting regression where a dropped
new line caused section header information from the `.gnu.version_d'
version definition section to be printed on the same line as this
section's first entry.

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

$ cat ver_def.s
.data
.globl new_foo
.type new_foo, %object
new_foo:
.symver new_foo, foo@@ver_foo
$ cat ver_def.ver
{ global: *foo*; local: *; };
$ as -o ver_def.o ver_def.s
$ ld -e 0 --export-dynamic --version-script=ver_def.ver -o ver_def ver_def.o
$ readelf -V ver_def

Version symbols section '.gnu.version' contains 4 entries:
 Addr: 000000000000007e  Offset: 0x01007e  Link: 2 (.dynsym)
  000:   0 (*local*)       2 (ver_foo)       1 (*global*)      2 (ver_foo)

Version definition section '.gnu.version_d' contains 2 entries:
  Addr: 0x0000000000000088  Offset: 0x010088  Link: 3 (.dynstr)  000000: Rev: 1  Flags: BASE   Index: 1  Cnt: 1  Name: ver_def
  0x001c: Rev: 1  Flags: none  Index: 2  Cnt: 1  Name: ver_foo
  Version definition past end of section
$

Add the new line then, to get:

$ readelf -V ver_def

Version symbols section '.gnu.version' contains 4 entries:
 Addr: 000000000000007e  Offset: 0x01007e  Link: 2 (.dynsym)
  000:   0 (*local*)       2 (ver_foo)       1 (*global*)      2 (ver_foo)

Version definition section '.gnu.version_d' contains 2 entries:
  Addr: 0x0000000000000088  Offset: 0x010088  Link: 3 (.dynstr)
  000000: Rev: 1  Flags: BASE   Index: 1  Cnt: 1  Name: ver_def
  0x001c: Rev: 1  Flags: none  Index: 2  Cnt: 1  Name: ver_foo
  Version definition past end of section
$

instead.

binutils/
* readelf.c (process_version_sections) <SHT_GNU_verdef>: Print a
new line between the heading and the first version definition
entry.

7 years agoPR ld/20828: Move symbol version processing ahead of GC symbol sweep
Maciej W. Rozycki [Tue, 21 Feb 2017 01:46:42 +0000 (01:46 +0000)] 
PR ld/20828: Move symbol version processing ahead of GC symbol sweep

Complement commit b531344c34b0 ("PR ld/20828: Reorder the symbol sweep
stage of section GC") and commit 81ff47b3a546 ("PR ld/20828: Fix linker
script symbols wrongly forced local with section GC") and move symbol
version processing ahead of the symbol sweep stage of section GC, all in
`bfd_elf_size_dynamic_sections', so that version symbols created stay in
the global scope and are not output as local symbols to the dynamic
symbol table in the presence of corresponding symbol definitions pulled
from a DSO involved in a link.

Consolidate the whole of symbol version processing into a single block
from all parts scattered across the function and rearranging the local
variables used as necessary, however leaving the setting of dynamic
entries associated with the DT_VERDEF, DT_VERDEFNUM, DT_VERNEED and
DT_VERNEEDNUM tags and the SEC_EXCLUDE flag for unused `.gnu.version'
section in the original places.

With the rearrangement of code blocks `Elf_Internal_Verneed *t' would
shadow the previous definition of `struct bfd_elf_version_tree *t', so
rename the former variable to `vn'.

bfd/
PR ld/20828
* elflink.c (bfd_elf_size_dynamic_sections): Move symbol version
processing ahead of the call to `elf_gc_sweep_symbol'.

ld/
PR ld/20828
* testsuite/ld-elf/pr20828-d.sd: New test.
* testsuite/ld-elf/pr20828-e.sd: New test.
* testsuite/ld-elf/pr20828-v.od: New test.
* testsuite/ld-elf/pr20828-v.ver: New test version script.
* testsuite/ld-elf/pr20828-v.ld: New test linker script.
* testsuite/ld-elf/pr20828.ld: Add `.gnu.version' and
`.gnu.version_d'.
* testsuite/ld-elf/shared.exp: Run the new tests.

7 years agoGAS: Consistently fix labels at the `.end' pseudo-op
Maciej W. Rozycki [Fri, 17 Feb 2017 20:30:55 +0000 (20:30 +0000)] 
GAS: Consistently fix labels at the `.end' pseudo-op

Fix a functional regression with the `.end' pseudo-op, introduced with
commit ecb4347adecd ("Last take: approval for MIPS_STABS_ELF killing"),
<https://sourceware.org/ml/binutils/2002-06/msg00443.html>, and commit
dcd410fe1544 ("GNU as 2.14 on IRIX 6: crashes with shared libs"),
<https://sourceware.org/ml/binutils/2003-07/msg00415.html>, which caused
symbol values for labels placed between the end of a function's contents
and its terminating `.end' followed by one of the alignment pseudo-ops
to be different depending on whether either `-mdebug', or `-mno-pdr', or
neither of the command-line options is in effect, be it implied or
specified.

Given debug-label-end.s as follows and the `mips-linux' target we have:

$ cat debug-label-end.s
.text

.globl foo
.globl bar
.align 4, 0
.ent foo
foo:
nop
.aent bar
bar:
.insn
.end foo
.align 4, 0
.space 16

.globl baz
.ent baz
baz:
nop
.end baz
.align 4, 0
.space 16
$ as -o debug-label-end.o debug-label-end.s
$ readelf -s debug-label-end.o | grep bar
     9: 00000004     0 FUNC    GLOBAL DEFAULT    1 bar
$ as -mdebug -o debug-label-end.o debug-label-end.s
$ readelf -s debug-label-end.o | grep bar
     9: 00000010     0 FUNC    GLOBAL DEFAULT    1 bar
$ as -mno-pdr -o debug-label-end.o debug-label-end.s
$ readelf -s debug-label-end.o | grep bar
     8: 00000010     0 FUNC    GLOBAL DEFAULT    1 bar
$

The reason is the call to `md_flush_pending_output', which in the case
of `mips*-*-*' targets expands to `mips_emit_delays', which in turn
calls `mips_no_prev_insn', which calls `mips_clear_insn_labels', which
clears the list of outstanding labels.  That list is in turn consulted
in `mips_align', called in the interpretation of alignment directives,
and the labels adjusted to the current location.

A call to `md_flush_pending_output' is only made from `s_mips_end' and
then only if `-mpdr' is in effect, which is the default for `*-*-linux*'
and some other `mips*-*-*' targets.  A call to `md_flush_pending_output'
is never made from `ecoff_directive_end', which is used in place of
`s_mips_end' when `-mdebug' is in effect.  Consequently if `-mno-pdr' or
`-mdebug' is in effect the list of outstanding labels makes it through
to any alignment directive that follows and the labels are differently
interpreted depending on the command-lines options used.  And we want
code produced to be always the same.

Call `md_flush_pending_output' unconditionally then in `s_mips_end' and
add such a call from `ecoff_directive_end' as well, as long as the macro
is defined.  While `ecoff_directive_end' is shared among targets, the
only one other than `mips*-*-*' actually using it is `alpha*-*-*' and it
does not define `md_flush_pending_output'.  So the semantics isn't going
to change for it and neither it has to have its `s_alpha_end' updated
or have code in `ecoff_directive_end' conditionalized.

gas/
* ecoff.c (ecoff_directive_end) [md_flush_pending_output]: Call
`md_flush_pending_output'.
* config/tc-mips.c (s_mips_end) [md_flush_pending_output]: Call
`md_flush_pending_output' unconditionally.
* testsuite/gas/mips/debug-label-end-1.d: New test.
* testsuite/gas/mips/debug-label-end-2.d: New test.
* testsuite/gas/mips/debug-label-end-3.d: New test.
* testsuite/gas/mips/debug-label-end.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

7 years agoAlign .gnu_debuglink sections on a 4-byte boundary.
Nick Clifton [Wed, 22 Feb 2017 17:28:33 +0000 (17:28 +0000)] 
Align .gnu_debuglink sections on a 4-byte boundary.

PR binutils/21193
* opncls.c (bfd_create_gnu_debuglink_section): Give the newly
created section 4-byte alignment.

7 years agoFix gas/all/err-sizeof.s for cris*-*-*
Hans-Peter Nilsson [Wed, 22 Feb 2017 13:17:33 +0000 (14:17 +0100)] 
Fix gas/all/err-sizeof.s for cris*-*-*

7 years agoSkip ARM vcmp-noprefix-imm test on non-ELF targets
Nick Clifton [Wed, 22 Feb 2017 11:57:49 +0000 (11:57 +0000)] 
Skip ARM vcmp-noprefix-imm test on non-ELF targets

7 years agogas: require an operand to .startof.()/.sizeof.()
Jan Beulich [Wed, 22 Feb 2017 09:37:52 +0000 (10:37 +0100)] 
gas: require an operand to .startof.()/.sizeof.()

7 years agoaarch64: actually copy first operand in convert_bfc_to_bfm()
Jan Beulich [Wed, 22 Feb 2017 09:36:05 +0000 (10:36 +0100)] 
aarch64: actually copy first operand in convert_bfc_to_bfm()

Commit 93562a343c ("[AArch64] PR target/20666, fix wrong encoding of
new introduced BFC pseudo") changed the destination operand to 0,
making the whole function invocation a no-op. We really want to copy
operand 0 (a register) to operand 1 (an immediate before coming here),
even if right now this likely is only a latent bug.

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

7 years agoFix a regression by: Code cleanup: Split dwarf2_ranges_read to a callback
Jan Kratochvil [Tue, 21 Feb 2017 23:13:03 +0000 (00:13 +0100)] 
Fix a regression by: Code cleanup: Split dwarf2_ranges_read to a callback

On some Fedora 23 systems an internal error has been printed.

gdb/ChangeLog
2017-02-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (dwarf2_record_block_ranges): Add forgotten BASEADDR.

7 years agoPowerPC ld segfault on script discarding dynamic sections
Alan Modra [Tue, 21 Feb 2017 21:40:58 +0000 (08:10 +1030)] 
PowerPC ld segfault on script discarding dynamic sections

bfd/
* elf64-ppc.c (ppc64_elf_finish_dynamic_sections): Don't segfault
on .got or .plt output section being discarded by script.
* elf32-ppc.c (ppc_elf_finish_dynamic_sections): Likewise.  Move
vxworks splt temp.
gold/
* powerpc.cc (Target_powerpc::make_iplt_section): Check that
output_section exists before attempting add_output_section_data.
(Target_powerpc::make_brlt_section): Likewise.

7 years agoDefault initialize enum flags to 0
Simon Marchi [Tue, 21 Feb 2017 16:48:49 +0000 (11:48 -0500)] 
Default initialize enum flags to 0

... so that we don't need to do it manually, and potentially forget.
For example, this allows to do:

  my_flags flags;

  ...

  flags |= some_flag;

gdb/ChangeLog:

* common/enum-flags.h (enum_flags::enum_flags): Initialize
m_enum_value to 0 in default constructor.

7 years ago[ppc64] Add POWER8/ISA 2.07 atomic sequences single-stepping support
Edjunior Barbosa Machado [Tue, 21 Feb 2017 14:14:56 +0000 (11:14 -0300)] 
[ppc64] Add POWER8/ISA 2.07 atomic sequences single-stepping support

gdb/
2017-02-21  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

* rs6000-tdep.c (LOAD_AND_RESERVE_MASK): Rename from LWARX_MASK.
(STORE_CONDITIONAL_MASK): Rename from STWCX_MASK.
(LBARX_INSTRUCTION, LHARX_INSTRUCTION, LQARX_INSTRUCTION,
STBCX_INSTRUCTION, STHCX_INSTRUCTION, STQCX_INSTRUCTION): New defines.
(IS_LOAD_AND_RESERVE_INSN, IS_STORE_CONDITIONAL_INSN): New macros.
(ppc_displaced_step_copy_insn): Use IS_LOAD_AND_RESERVE_INSN.
(ppc_deal_with_atomic_sequence): Use IS_LOAD_AND_RESERVE_INSN and
IS_STORE_CONDITIONAL_INSN.

gdb/testsuite/
2017-02-21  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

* gdb.arch/ppc64-isa207-atomic-inst.exp: New testcase based on
gdb.arch/ppc64-atomic-inst.exp.  Add tests for lbarx/stbcx, lharx/sthcx
and lqarx/stqcx.
* gdb.arch/ppc64-isa207-atomic-inst.S: New file.
* gdb.arch/ppc64-isa207-atomic-inst.c: Likewise.

7 years agoFix test names starting with uppercase in gdb.arch/ppc64-atomic-inst.exp
Edjunior Barbosa Machado [Tue, 21 Feb 2017 13:59:29 +0000 (10:59 -0300)] 
Fix test names starting with uppercase in gdb.arch/ppc64-atomic-inst.exp

gdb/testsuite/
2017-02-21  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

* gdb.arch/ppc64-atomic-inst.exp: Fix test names starting with
uppercase.

7 years agoFix compile time warning message in linker testsuite test.
Nick Clifton [Tue, 21 Feb 2017 11:00:21 +0000 (11:00 +0000)] 
Fix compile time warning message in linker testsuite test.

* testsuite/ld-ifunc/pr18808b.c (bar): Fix compile time warning
about non-void function returning without a result.

7 years agoFix recent compiler warnings.
Jan Kratochvil [Tue, 21 Feb 2017 08:14:37 +0000 (09:14 +0100)] 
Fix recent compiler warnings.

gcc-4.8.5-11.el7.x86_64

dwarf2read.c: In function ‘pc_bounds_kind dwarf2_get_pc_bounds(die_info*, CORE_ADDR*, CORE_ADDR*, dwarf2_cu*, partial_symtab*)’:
dwarf2read.c:12134:7: error: ‘range_end’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
dwarf2read.c:12133:7: error: ‘range_beginning’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

gdb/ChangeLog
2017-02-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2_rnglists_process: Initialize range_beginning and range_end.

7 years agoAlpha DT_RELA
Alan Modra [Mon, 20 Feb 2017 07:27:43 +0000 (17:57 +1030)] 
Alpha DT_RELA

* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Only emit
DT_RELA, DT_RELASZ, and DT_RELAENT when DT_RELASZ is non-zero.

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

7 years agoDWARF-5: NEWS
Jan Kratochvil [Mon, 20 Feb 2017 19:53:22 +0000 (20:53 +0100)] 
DWARF-5: NEWS

a NEWS entry.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* NEWS (Changes since GDB 7.12): Add DWARF-5.

7 years agoDWARF-5: DW_FORM_data16
Jan Kratochvil [Mon, 20 Feb 2017 19:53:22 +0000 (20:53 +0100)] 
DWARF-5: DW_FORM_data16

DWARF-5 has new form DW_FORM_data16.  The problem is that GDB cannot pass
16-byte constant as a constant value as that would require GDB to use GCC
extension __int128.

Formerly such data was coded as DW_FORM_block* so GDB still decodes
DW_FORM_data16 like DW_FORM_block*.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (skip_one_die, read_attribute_value)
(dwarf2_const_value_attr, dump_die_shallow)
(dwarf2_get_attr_constant_value, dwarf2_fetch_constant_bytes)
(skip_form_bytes, attr_form_is_constant): Handle DW_FORM_data16.

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

* gdb.dwarf2/formdata16.c: New file.
* gdb.dwarf2/formdata16.exp: New file.
* lib/dwarf.exp (Dwarf): Add DW_FORM_data16.

7 years agoDWARF-5: Macros
Jan Kratochvil [Mon, 20 Feb 2017 19:53:21 +0000 (20:53 +0100)] 
DWARF-5: Macros

DWARF-5 renamed DW_MACRO_GNU_* to DW_MACRO_*.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (read_file_scope): Rename DW_MACRO_GNU_*.
(dwarf_parse_macro_header): Accept DWARF version 5.
(dwarf_decode_macro_bytes, dwarf_decode_macros): Rename DW_MACRO_GNU_*.

7 years agoDWARF-5: call sites
Jan Kratochvil [Mon, 20 Feb 2017 19:53:21 +0000 (20:53 +0100)] 
DWARF-5: call sites

this patch updates all call sites related DWARF-5 renames.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* block.c (call_site_for_pc): Rename DW_OP_GNU_*, DW_TAG_GNU_* and
DW_AT_GNU_*.
* common/common-exceptions.h (enum errors): Likewise.
* dwarf2-frame.c (class dwarf_expr_executor): Likewise.
* dwarf2expr.c (dwarf_block_to_dwarf_reg)
(dwarf_expr_context::execute_stack_op): Likewise.
* dwarf2expr.h (struct dwarf_expr_context, struct dwarf_expr_piece):
Likewise.
* dwarf2loc.c (dwarf_evaluate_loc_desc::get_base_type)
(dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value)
(show_entry_values_debug, call_site_to_target_addr)
(func_addr_to_tail_call_list, func_verify_no_selftailcall)
(dwarf_expr_reg_to_entry_parameter, dwarf_entry_parameter_to_value)
(entry_data_value_free_closure, value_of_dwarf_reg_entry)
(value_of_dwarf_block_entry, indirect_pieced_value)
(symbol_needs_eval_context::push_dwarf_reg_entry_value):
(disassemble_dwarf_expression): Likewise.
* dwarf2read.c (process_die, inherit_abstract_dies)
(read_call_site_scope): Likewise.
* gdbtypes.h (struct func_type, struct call_site_parameter)
(struct call_site): Likewise.
* stack.c (read_frame_arg): Likewise.
* std-operator.def (OP_VAR_ENTRY_VALUE): Likewise.

gdb/doc/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.texinfo (Print Settings, Tail Call Frames): Rename DW_OP_GNU_*,
DW_TAG_GNU_* and DW_AT_GNU_*.

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

* gdb.arch/amd64-entry-value-param-dwarf5.S: New file.
* gdb.arch/amd64-entry-value-param-dwarf5.c: New file.
* gdb.arch/amd64-entry-value-param-dwarf5.exp: New file.
* gdb.arch/amd64-entry-value.exp: Rename DW_OP_GNU_*, DW_TAG_GNU_* and
DW_AT_GNU_*.

7 years agoDWARF-5 basic functionality
Jan Kratochvil [Mon, 20 Feb 2017 19:53:21 +0000 (20:53 +0100)] 
DWARF-5 basic functionality

this is a kitchen-sink patch for everything that did not fit into its own
patch.

DWO is not yet implemented.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* defs.h (read_unsigned_leb128): New declaration.
* dwarf2loc.c (decode_debug_loclists_addresses): New function.
(decode_debug_loc_dwo_addresses): Update DEBUG_LOC_* to DW_LLE_*.
(dwarf2_find_location_expression): Call also
decode_debug_loclists_addresses.  Handle DWARF-5 ULEB128 length.
* dwarf2loc.h (dwarf2_version): New declaration.
* dwarf2read.c (struct dwarf2_per_objfile): Add loclists, line_str,
rnglists.
(dwarf2_elf_names): Add .debug_loclists, .debug_line_str,
.debug_rnglists.
(struct dwop_section_names): Add loclists_dwo.
(dwop_section_names): Add .debug_loclists.dwo.
(struct comp_unit_head): Add unit_type, signature, type_offset_in_tu.
(struct dwarf2_per_cu_data): Add dwarf_version.
(struct dwo_sections): Add loclists.
(struct attr_abbrev): Add implicit_const.
(read_indirect_line_string): New declaration.
(read_unsigned_leb128): Delete declaration.
(rcuh_kind): New definition.
(read_and_check_comp_unit_head): Change parameter
is_debug_types_section to section_kind.
(dwarf2_locate_sections): Handle loclists, line_str and rnglists.
(read_comp_unit_head): Change parameter abfd to section, add parameter
section_kind.  Handle DWARF-5.
(error_check_comp_unit_head): Accept also DWARF version 5.
(read_and_check_comp_unit_head): Change parameter
is_debug_types_section to section_kind.
(read_and_check_type_unit_head): Delete function.
(read_abbrev_offset): Handle DWARF-5.
(create_debug_type_hash_table): Add parameter section_kind.  Process
only DW_UT_type.  Use signature and type_offset_in_tu from struct
comp_unit_head.
(create_debug_types_hash_table): Update create_debug_type_hash_table
caller.
(create_all_type_units): Call create_debug_type_hash_table.
(read_cutu_die_from_dwo, init_cutu_and_read_dies): Change
read_and_check_type_unit_head caller to read_and_check_comp_unit_head
caller.
(skip_one_die): Handle DW_FORM_implicit_const.
(dwarf2_rnglists_process): New function.
(dwarf2_ranges_process): Call dwarf2_rnglists_process for DWARF-5.
(abbrev_table_read_table): Handle DW_FORM_implicit_const.
(read_attribute_value): Handle DW_FORM_implicit_const,
DW_FORM_line_strp.
(read_attribute): Handle DW_FORM_implicit_const.
(read_indirect_string_at_offset_from): New function from
read_indirect_string_at_offset.
(read_indirect_string_at_offset): Call
read_indirect_string_at_offset_from.
(read_indirect_line_string_at_offset): New function.
(read_indirect_string): New function comment.
(read_indirect_line_string): New function.
(read_unsigned_leb128): Make it global.
(dwarf2_string_attr): Handle DWARF-5.
(add_include_dir_stub, read_formatted_entries): New functions.
(dwarf_decode_line_header, dump_die_shallow, cu_debug_loc_section):
Handle DWARF-5.
(per_cu_header_read_in): Update read_comp_unit_head caller.
(dwarf2_version): New function.
* symfile.h (struct dwarf2_debug_sections): Add loclists, line_str and
rnglists.
* xcoffread.c (dwarf2_xcoff_names): Update struct dwarf2_debug_sections
fields.

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

* gdb.dwarf2/dw2-error.exp (file $testfile): Update expected string.

7 years agoCode cleanup: Refactor abbrev_table_read_table cycle
Jan Kratochvil [Mon, 20 Feb 2017 19:53:20 +0000 (20:53 +0100)] 
Code cleanup: Refactor abbrev_table_read_table cycle

I find it as an improvement on its own, it prevents more code duplication in
a future patch.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (abbrev_table_read_table): Read the data only once.

7 years agoCode cleanup: Split dwarf2_ranges_read to a callback
Jan Kratochvil [Mon, 20 Feb 2017 19:53:20 +0000 (20:53 +0100)] 
Code cleanup: Split dwarf2_ranges_read to a callback

DWARF-5 has .debug_rnglists which is somehow similar to .debug_ranges.

This patch converts dwarf2_ranges_read to dwarf2_ranges_process which can work
with both DWARF kinds of range lists through a callback.

It also simplifies dwarf2_record_block_ranges which can benefit from it.

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (dwarf2_ranges_process): New function from
dwarf2_ranges_read.
(dwarf2_ranges_read, dwarf2_record_block_ranges): Use
dwarf2_ranges_process.

7 years agoCode cleanup: Split create_debug_types_hash_table
Jan Kratochvil [Mon, 20 Feb 2017 19:53:19 +0000 (20:53 +0100)] 
Code cleanup: Split create_debug_types_hash_table

DWARF-5 moved .debug_types into .debug_info and so the types reading code needs
to be reused more (in a future patch).

gdb/ChangeLog
2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2read.c (create_debug_type_hash_table): New function from
create_debug_types_hash_table.
(create_debug_types_hash_table): Call create_debug_type_hash_table.
(create_all_type_units, open_and_init_dwo_file): Update
create_debug_types_hash_table callers.

7 years agoFix another memory access error in readelf when parsing a corrupt binary.
Nick Clifton [Mon, 20 Feb 2017 14:40:39 +0000 (14:40 +0000)] 
Fix another memory access error in readelf when parsing a corrupt binary.

PR binutils/21156
* dwarf.c (cu_tu_indexes_read): Move into...
(load_cu_tu_indexes): ... here.  Change the variable into
tri-state.  Change the function into boolean, returning
false if the indicies could not be loaded.
(find_cu_tu_set): Return NULL if the indicies could not be
loaded.

7 years agoPE ld -r script fixes
Alan Modra [Mon, 20 Feb 2017 02:54:28 +0000 (13:24 +1030)] 
PE ld -r script fixes

PR 15041
* scripttempl/pe.sc: Don't combine sections for ld -r.
* scripttempl/pep.sc: Likewise.

7 years agoFix thinko on last commit
Sergio Durigan Junior [Mon, 20 Feb 2017 13:01:04 +0000 (08:01 -0500)] 
Fix thinko on last commit

On fork-child.c:trace_start_error, va_end should refer to 'ap', not
'args.  This fixes it.

Sorry about the breakage.

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

PR gdb/16188
* fork-child.c (trace_start_error): Fix thinko.  va_end should
refer to 'ap', not 'args'.

7 years agoSync ZLIB with FSF GCC sources, bringing in version 1.2.11.
Nick Clifton [Mon, 20 Feb 2017 12:52:22 +0000 (12:52 +0000)] 
Sync ZLIB with FSF GCC sources, bringing in version 1.2.11.

- Fix deflate stored bug when pulling last block from window
- Permit immediate deflateParams changes before any deflate input

7 years agoPR gdb/16188: Verify PTRACE_TRACEME succeeded
Sergio Durigan Junior [Tue, 14 Feb 2017 23:27:23 +0000 (18:27 -0500)] 
PR gdb/16188: Verify PTRACE_TRACEME succeeded

This patch fixes PR gdb/16188, which is about the fact that
fork_inferior doesn't verify the return value of the "traceme_fun"
callback.  On most targets, this callback is actually a wrapper to a
ptrace call that does a PTRACE_TRACEME on the forked GDB process that
will eventually become the inferior.

Thanks to Pedro, this second version of the patch is simpler and more
more logical.  Basically, two helper functions are added:
trace_start_error and trace_start_error_with_name.  The former can be
used when there is a customized error message to be printed to the
user.  The latter works like perror_with_name, so you just need to
pass the function that error'd.

Both helper functions mentioned above do basically the same thing:
print the error message to stderr and call _exit, properly terminating
the forked inferior.

Most of the patch takes care of guarding the necessary system calls
against errors on the "traceme_fun" callbacks.  It is not right to
call error on these situations, so I've replaced these calls with the
proper helper function call.

Regression-tested on BuildBot.

Thanks,

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

PR gdb/16188
* darwin-nat.c (darwin_ptrace_me): Check if calls to system
calls succeeded.
* fork-child.c (trace_start_error): New function.
(trace_start_error_with_name): Likewise.
* gnu-nat.c (gnu_ptrace_me): Check if call to PTRACE succeeded.
* inf-ptrace.c (inf_ptrace_me): Likewise.
* inferior.h (trace_start_error): New prototype.
(trace_start_error_with_name): Likewise.

7 years agofix PR number
Alan Modra [Mon, 20 Feb 2017 10:58:59 +0000 (21:28 +1030)] 
fix PR number

7 years agoAlpha executables segfault when linked with -z,now
Alan Modra [Mon, 20 Feb 2017 06:50:45 +0000 (17:20 +1030)] 
Alpha executables segfault when linked with -z,now

PR 21181
* elflink.c (bfd_elf_final_link): Make DT_REL/DT_RELA zero
if DT_RELSZ/DT_RELASZ is zero.

7 years agoMove .stack before debug sections
Alan Modra [Mon, 20 Feb 2017 02:55:13 +0000 (13:25 +1030)] 
Move .stack before debug sections

PR 20199
* emulparams/elf32m32c.sh: Define STACK_ADDR and STACK_SENTINEL
rather than using OTHER_SECTIONS.
* emulparams/elf32mt.sh: Likewise.
* emulparams/elf32rx.sh: Likewise.
* emulparams/elf32rl78.sh: Likewise.  Use OTHER_SYMBOLS to
define __rl78_abs__.
* emulparams/shelf.sh: Define STACK_ADDR and STACK_SENTINEL
rather than using OTHER_SECTIONS.
* emulparams/shelf32.sh: Likewise.  Use OTHER_SECTIONS for .cranges.
* emulparams/shelf64.sh: Unset OTHER_SECTIONS.
* emulparams/shelf_nbsd.sh: Unset STACK_ADDR not OTHER_SECTIONS.
* emulparams/shelf_uclinux.sh: Likewise.
* emulparams/shlsymbian.sh: Unset STACK_ADDR.  Use OTHER_SYMBOLS
to define _stack, not OTHER_SECTIONS.
* scripttempl/elf.sc: Move STACK, TINY_DATA_SECTION, and
TINY_BSS_SECTION before debug sections.  Add STACK_SENTINEL.
* scripttempl/arclinux.sc: Likewise.
* scripttempl/elf64hppa.sc: Likewise.
* scripttempl/elfxtensa.sc: Likewise.
* scripttempl/nds32elf.sc: Likewise.
* scripttempl/armbpabi.sc: Move STACK before debug sections.
* scripttempl/elf_chaos.sc: Likewise.
* scripttempl/elfarc.sc: Delete STACK.
* scripttempl/epiphany_4x4.sc: Delete STACK.  Move TINY_DATA_SECTION,
TINY_BSS_SECTION, and .stack before debug sections.

7 years agoDowngrade powerpc register error to warning
Alan Modra [Mon, 20 Feb 2017 01:36:52 +0000 (12:06 +1030)] 
Downgrade powerpc register error to warning

PR 21118
* NEWS: Revise powerpc register check.
* config/tc-ppc.c (ppc_optimize_expr, md_assemble): Make "invalid
register expression" a warning.

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

7 years agoFix for aarch64 sim sxtl/uxtl insns, plus another fix for addv.
Jim Wilson [Sun, 19 Feb 2017 21:16:56 +0000 (13:16 -0800)] 
Fix for aarch64 sim sxtl/uxtl insns, plus another fix for addv.

sim/aarch64/
* simulator.c (do_vec_ADDV): Mov val declaration inside each case,
with type set to input type size.
(do_vec_xtl): Change bias from 3 to 4 for byte case.

sim/testsuite/sim/aarch64/
* bit.s: Change cmp immediates to account for addv bug fix.
* cmtst.s, ldn_single.s, stn_single.s: Likewise.
* xtl.s: New.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Feb 2017 00:00:31 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 18 Feb 2017 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoGAS: Add ECOFF `.aent' pseudo-op support
Maciej W. Rozycki [Thu, 16 Feb 2017 01:50:29 +0000 (01:50 +0000)] 
GAS: Add ECOFF `.aent' pseudo-op support

Implement the ECOFF `.aent' pseudo-op for ECOFF-style `.mdebug' section
support with ELF objects and, for consistency, also with ECOFF objects.
This is so that the same MIPS source can be assembled without and with
`.mdebug' section generation enabled.

Taking the `gas/testsuite/gas/mips/aent.s' test case source as an
example and the `mips-linux' target we have:

$ as -o aent.o aent.s
$ as -mdebug -o aent.o aent.s
aent.s: Assembler messages:
aent.s:10: Error: unknown pseudo-op: `.aent'
$

because for the !ECOFF_DEBUGGING case (which is the default) the
pseudo-op is already handled by the MIPS backend with `s_mips_ent',
however no handler is present for the opposite case.

For the MIPS target this is a functional regression introduced with
commit ecb4347adecd ("Last take: approval for MIPS_STABS_ELF killing"),
<https://sourceware.org/ml/binutils/2002-06/msg00443.html>, where
support for the `.mdebug' section was added along with its associated
`-mdebug'/`-no-mdebug' command-line options, bringing an inconsistency
between the assembly syntax supported for each of these options as far
as the `.aent' pseudo-op is concerned.

Assembly language documentation available describes the pseudo-op
respectively as follows[1]:

"
.aent name, symno Sets an alternate entry point for the current
                  procedure.  Use this information when you want
                  to generate information for the debugger.  It must
                  appear inside an .ent/.end pair."

and[2]:

"
.aent name [,symno]
     Sets an alternate entry point for the current procedure.  Use this
     information when you want to generate information for the debugger.
     This directive must appear between a pair of .ent and .end directives.
     (The optional symno is for compiler use only.  It refers to a dense
     number in a .T file (symbol table).)"

Copy the approach from `s_mips_ent' then and add `.aent' support to the
`.ent' pseudo-op handler shared between the ELF and ECOFF object file
format backends, by setting BSF_FUNCTION for the symbol requested.

References:

[1] "MIPSpro Assembly Language Programmer's Guide", Silicon Graphics,
    Inc., Document Number 007-2418-004, Section 8.1 "Op-Codes", p. 96
    <http://techpubs.sgi.com/library/manuals/2000/007-2418-004/pdf/007-2418-004.pdf>

[2] "Digital UNIX Assembly Language Programmer's Guide", Digital
    Equipment Corporation, Order Number: AA-PS31D-TE, March 1996,
    Chapter 5 "Assembler Directives", p. 5-2
    <http://h41361.www4.hpe.com/docs/base_doc/DOCUMENTATION/V40G_PDF/APS31DTE.PDF>

gas/
* ecoff.c (ecoff_directive_ent, add_procedure): Handle `.aent'.
* config/obj-ecoff.c (obj_pseudo_table): Add "aent" entry.
* config/obj-elf.c (ecoff_debug_pseudo_table): Likewise.
* testsuite/gas/mips/aent-2.d: New test.
* testsuite/gas/mips/aent-mdebug.d: New test.
* testsuite/gas/mips/aent-mdebug-2.d: New test.
* testsuite/gas/mips/mips.exp: Run the new tests.

7 years agoFix documentation of the linker's --pop-state command line option.
Nick Clifton [Fri, 17 Feb 2017 16:31:09 +0000 (16:31 +0000)] 
Fix documentation of the linker's --pop-state command line option.

PR ld/20825
* ld.texinfo (Options): Add missing @item entry for --pop-state.

7 years agoFix illegal memory accesses in readelf when parsing a corrupt binary.
Nick Clifton [Fri, 17 Feb 2017 15:59:45 +0000 (15:59 +0000)] 
Fix illegal memory accesses in readelf when parsing a corrupt binary.

PR binutils/21156
* readelf.c (find_section_in_set): Test for invalid section
indicies.

7 years agoAdd support to readelf for displaying GNU section types.
Nick Clifton [Fri, 17 Feb 2017 15:31:54 +0000 (15:31 +0000)] 
Add support to readelf for displaying GNU section types.

* readelf.c (get_section_type_name): Add decoding of GNU section
types.

7 years agoFix potential illegal memory access in ZLIB because of an erroneous declaration of...
Nick Clifton [Fri, 17 Feb 2017 11:39:20 +0000 (11:39 +0000)] 
Fix potential illegal memory access in ZLIB because of an erroneous declaration of the size of the input buffer.

* compress.c (bfd_get_full_section_contents): Remember to reduce
compressed size by the sizeof the compression header when
decompressing the contents.

7 years agoAdd support for Intel PKRU register to GDB and GDBserver.
Michael Sturm [Wed, 1 Feb 2017 11:22:27 +0000 (12:22 +0100)] 
Add support for Intel PKRU register to GDB and GDBserver.

This patch adds support for the registers added by the
Memory Protection Keys for Userspace (PKU aka PKEYs) feature.
Native and remote debugging are covered by this patch.

The XSAVE area is extended with a new state containing
the 32-bit wide PKRU register. The new register is added to
amd64-avx-mpx_avx512-* tdesc, thus it is renamed accordingly. Also,
respective xstate mask X86_XSTATE_AVX_MPX_AVX512_MASK is renamed to
X86_XSTATE_AVX_MPX_AVX512_PKU_MASK to reflect the new feature set
it supports.

For more information, please refer to the
Intel(R) 64 and IA-32 Architectures Software Developer's
Manual - Septemper 2015
http://www.intel.com/content/dam/www/public/us/en/documents/
manuals/64-ia-32-architectures-software-developer-manual-325462.pdf

gdb/Changelog:
2015-12-08  Michael Sturm  <michael.sturm@intel.com>

     * NEWS: Mention addition of PKU feature.
     * amd64-linux-nat.c (amd64_linux_gregset32_reg_offset): Add PKRU register.
     * amd64-linux-tdep.c (features/i386/amd64-avx-mpx-avx512-linux.c): Rename
       to...
     (features/i386/amd64-avx-mpx-avx512-pku-linux.c): ...this.
     (amd64_linux_gregset_reg_offset): Add PKRU register.
     (amd64_linux_core_read_description): Rename
     X86_XSTATE_AVX_MPX_AVX512_MASK,
     rename tdesc_amd64_avx_mpx_avx512_pku_linux.
     (_initialize_amd64_linux_tdep): Rename
     initialize_tdesc_amd64_avx_mpx_avx512_linux.
     * amd64-linux-tdep.h (AMD64_LINUX_ORIG_RAX_REGNUM): Adjust regnum
     calculation.
     (tdesc_amd64_avx_mpx_avx512_linux): Rename to...
     (tdesc_amd64_avx_mpx_avx512_pku_linux): ...this.
     * amd64-tdep.c (features/i386/amd64-avx-mpx-avx512-pku.c): Rename to...
     (features/i386/amd64-avx-mpx-avx512-pku.c): ...this.
     (amd64_pkeys_names): New register name for raw register PKRU.
     (amd64_init_abi): Add code to initialize PKRU tdep variables if feature
     is present.
     (amd64_target_description): Rename X86_XSTATE_AVX_MPX_AVX512_MASK,
     rename tdesc_amd64_avx_mpx_avx512.
     (_initialize_amd64_tdep): Rename initialize_tdesc_amd64_avx_mpx_avx512.
     * amd64-tdep.h (enum amd64_regnum): Add PKRU register.
     (AMD64_NUM_REGS): Adjust regnum calculation.
     * i386-linux.nat.c (GETXSTATEREGS_SUPPLIES): Extend range of
     registers supplied via XSTATE by PKRU register.
     * common/x86-xstate.h (X86_XSTATE_PKRU): New macro.
     (X86_XSTATE_AVX_MPX_AVX512_MASK): Add PKRU and renamed mask.
     (X86_XSTATE_ALL_MASK): Rename X86_XSTATE_AVX_MPX_AVX512_MASK.
     (X86_XSTATE_PKRU_SIZE): New macro.
     (X86_XSTATE_MAX_SIZE): Adjust size.
     (HAS_PKRU(XCR0)): New macro.
     (X86_XSTATE_SIZE): Add checkfor PKRU.
     * features/Makefile (WHICH): Rename i386/i386-avx-mpx-avx512,
     i386/i386-avx-mpx-avx512-linux, i386/amd64-avx-mpx-avx512,
     i386/amd64-avx-mpx-avx512-linux.
     (i386/i386-avx-mpx-avx512-expedite): Rename expedite.
     (i386/i386-avx-mpx-avx512-linux-expedite): Likewise.
     (i386/amd64-avx-mpx-avx512-expedite): Likewise.
     (i386/amd64-avx-mpx-avx512-linux-expedite): Likewise.
     (XMLTOC): Rename i386/amd64-avx-mpx-avx512-linux.xml,
     i386/amd64-avx-mpx-avx512.xml, i386/i386-avx-mpx-avx512-linux.xml,
     i386/i386-avx-mpx-avx512.xml.
     ((outdir)/i386/i386-avx-mpx-avx512.dat): Rename rule, add
     i386/32bit-pkeys.xml.
     ((outdir)/i386/i386-avx-mpx-avx512-pku-linux.dat): Likewise.
     ((outdir)/i386/amd64-avx-mpx-avx512.dat): Rename rule, add
     i386/64bit-pkeys.xml.
     ((outdir)/i386/amd64-avx-mpx-avx512-linux.dat): Likewise.
     * features/i386/32bit-pkeys.xml: New file.
     * features/i386/64bit-pkeys.xml: Likewise.
     * features/i386/amd64-avx-mpx-avx512-linux-pku.c: Regenerate from
     renamed XML file.
     * features/i386/amd64-avx-mpx-avx512-linux.xml: Rename to
     amd64-avx-mpx-avx512-pku-linux.xml, add 64bit-pkeys.xml
     * features/i386/amd64-avx-mpx-avx512.c: Regenerate from
     renamed XML file.
     * features/i386/amd64-avx-mpx-avx512.xml: Rename to
     amd64-avx-mpx-avx512-pku.xml, add 64bit-pkeys.xml.
     * features/i386/i386-avx-mpx-avx512-linux.c: Regenerate from
     renamed XML file.
     * features/i386/i386-avx-mpx-avx512-linux.xml: Rename to
     i386-avx-mpx-avx512-pku-linux.xml, add 32bit-pkeys.xml.
     * features/i386/i386-avx-mpx-avx512.c: Regenerate from
     renamed XML file.
     * features/i386/i386-avx-mpx-avx512.xml: Rename to
     i386-avx-mpx-avx512-pku.xml, add 32bit-pkeys.xml.
     * i386-linux-nat.c (GETXSTATEREGS_SUPPLIES): Change to use
     I386_PKEYS_NUM_REGS.
     * i386-linux-tdep.c (features/i386/i386-avx-mpx-avx512-linux.c): Rename
     include.
     (i386_linux_gregset_reg_offset): Add PKRU register.
     (i386_linux_core_read_description): Rename xstate mask and returned
     tdesc for X86_XSTATE_AVX_MPX_AVX512_PKU_MASK.
     (_initialize_i386_linux_tdep): Rename
     initialize_tdesc_i386_avx_mpx_avx512_linux.
     * i386-linux-tdep.h (I386_LINUX_ORIG_EAX_REGNUM): Adjuste regnum
     calculation.
     (tdesc_i386_avx_mpx_avx512_linux): Rename prototype.
     (/* Format of XSAVE...): Add pkru register.
     * i386-tdep.c (i386-avx-mpx-avx512.c): Rename include.
     (i386_pkeys_names): New register name for raw register PKRU.
     (i386_pkru_regnum_p): Add function to look up register number of
     PKRU raw register.
     (i386_register_reggroup_p): Add code to exclude PKRU from general
     register group.
     (i386_validate_tdesc_p): Add code to handle PKRU feature, add PKRU
     registers if feature is present in xcr0.
     (i386_gdbarch_init): Adjust number of registers in architecture. Add code
     to initialize PKRU feature variables in tdep structure.
     (i386_target_description): Rename xstate mask and returned
     tdesc for X86_XSTATE_AVX_MPX_AVX512_PKU_MASK.
     (_initialize_i386_tdep): Rename initialize_tdesc_i386_avx_mpx_avx512.
     * i386-tdep.h (struct gdbarch_tdep): Add feature variables to tdep
     structure.
     (enum i386_regnum): Add PKRU register.
     (I386_PKEYS_NUM_REGS): New define for number of registers in PKRU feature.
     (i386_pkru_regnum_p): New prototype.
     * i387-tdep.c (xsave_pkeys_offset): New table for PKRU offsets in
     XSAVE buffer.
     (XSAVE_PKEYS_ADDR): New macro.
     (i387_supply_xsave): Add code to handle PKRU register.
     (i387_collect_xsave): Likewise.
     * i387-tdep.h (I387_NUM_PKEYS_REGS): New define for number of registers
     in PKRU feature.
     (I387_PKRU_REGNUM): New macro.
     (I387_PKEYSEND_REGNUM): Likewise.
     * regformats/i386/amd64_avx_mpx_avx512_pku_linux.dat: Regenerate from
     renamed XML file.
     * regformats/i386/amd64_avx_mpx_avx512_pku.dat: Likewise.
     * regformats/i386/i386/amd64-avx-mpx-avx512-pku.dat: Likewise.
     * regformats/i386/i386_avx_mpx_avx512_pku_linux.dat: Likewise.

testsuite/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * gdb.arch/i386-pkru.c: New file.
     * gdb.arch/i386-pkru.exp: Likewise.

gdbserver/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * Makefile.in (clean): Rename i386-avx-mpx-avx512.c,
     i386-avx-mpx-avx512-linux.c, amd64-avx-mpx-avx512.c,
     amd64-avx-mpx-avx512-linux.c.
     (i386-avx-mpx-avx512-linux-ipa.o:): Rename rule and source file.
     (amd64-avx-mpx-avx512-linux-ipa.o:): Likewise.
     (i386-avx-mpx-avx512.c :): Rename rule, source files and dat files.
     (i386-avx-mpx-avx512-linux.c :): Likewise.
     (amd64-avx-mpx-avx512.c :): Likewise.
     (amd64-avx-mpx-avx512-linux.c :): Likewise.
     * configure.srv (srv_i386_regobj): Rename i386-avx-mpx-avx512.o.
     (srv_i386_linux_regobj): Rename i386-avx-mpx-avx512-linux.o.
     (srv_amd64_regobj): Rename amd64-avx-mpx-avx512.o.
     (srv_amd64_linux_regobj): Rename amd64-avx-mpx-avx512-linux.o.
     (ipa_i386_linux_regobj): Rename i386-avx-mpx-avx512-linux-ipa.o.
     (ipa_amd64_linux_regobj): Rename amd64-avx-mpx-avx512-pku-linux-ipa.o.
     (srv_i386_32bit_xmlfiles): Add 32bit-pkeys.xml.
     (srv_i386_64bit_xmlfiles): Add 64bit-pkeys.xml.
     (srv_i386_xmlfiles): Rename i386/i386-avx-mpx-avx512.xml.
     (srv_amd64_xmlfiles): Rename i386/amd64-avx-mpx-avx512.xml.
     (srv_i386_linux_xmlfiles): Rename i386/i386-avx-mpx-avx512-linux.xml.
     (srv_amd64_linux_xmlfiles): Rename di386/amd64-avx-mpx-avx512-linux.xml.
     * i387-fp.c (num_pkeys_registers): New variable.
     (struct i387_xsave): Add space for pkru values.
     (i387_cache_to_fsave): Add code to handle PKRU register.
     (i387_xsave_to_cache): Likewise.
     * linux-amd64-ipa.c (get_ipa_tdesc): Rename
     tdesc_amd64_avx_mpx_avx512_linux.
     (initialize_low_tracepoint): Rename
     init_registers_amd64_avx_mpx_avx512_linux.
     * linux-i386-ipa.c (get_ipa_desc): Rename
     tdesc_i386_avx_mpx_avx512_linux.
     (initialize_low_tracepoint): Rename
     init_registers_i386_avx_mpx_avx512_linux.
     * linux-x86-low.c (x86_64_regmap[]): Add PKRU register.
     (x86_linux_read_description): Rename X86_XSTATE_AVX_MPX_AVX512_MASK,
     rename tdesc_amd64_avx_mpx_avx512_linux, rename
     tdesc_i386_avx_mpx_avx512_linux.
     (x86_get_ipa_tdesc_idx): Rename tdesc_amd64_avx_mpx_avx512_linux,
     rename tdesc_i386_avx_mpx_avx512_linux.
     (initialize_low_arch): Rename init_registers_amd64_avx_mpx_avx512_linux,
     rename init_registers_i386_avx_mpx_avx512_linux.
     * linux-x86-tdesc.h (init_registers_amd64_avx_mpx_avx512_linux): Renamed
     prototype.
     (tdesc_amd64_avx_mpx_avx512_linux): Likewise.
     (init_registers_i386_avx_mpx_avx512_linux): Likewise.
     (tdesc_i386_avx_mpx_avx512_linux): Likewise.

doc/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * gdb.texinfo (i386 Features): Add description of PKRU register.

Change-Id: If75ce5aba7dfd33fdbe3d8b47f04ef3f550c52be
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
7 years agoAdd target description for avx-avx512.
Michael Sturm [Tue, 22 Mar 2016 15:26:09 +0000 (16:26 +0100)] 
Add target description for avx-avx512.

Add a dedicated target description for the feature combination
avx-avx512 as implemented by certain IA CPU models.

The corresponding X86_XSTATE_AVX_AVX512_MASK already exists, but shared
the tdesc with X86_XSTATE_AVX_MPX_AVX512_MASK. This caused MPX registers
displayed as undefined on CPUs that only implemented
X86_XSTATE_AVX_AVX512_MASK, which is undesired. This patch solves this issue.

This patch also corrects the wrong usage of x32-avx-mpx-avx512, which is
replaced by x32-avx-avx512. The MPX feature is not implemented in x32 mode.

gdb/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * amd64-linux-tdep.c (features/i386/amd64-avx-avx512-linux.c):
     New include.
     (features/i386/x32-avx-mpx-avx512-linux.c): Rename to...
     (features/i386/x32-avx-avx512-linux.c): ...this.
     (amd64_linux_core_read_description): Add dedicated cases for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_amd64_linux_tdep): Add calls to
     initialize_tdesc_amd64_avx_avx512_linux and
     initialize_tdesc_x32_avx_avx512_linux.
     * amd64-linux.tdep.h (tdesc_amd64_avx_avx512_linux): New prototype.
     (tdesc_x32_avx_mpx_avx512_linux): Rename to...
     (tdesc_x32_avx_avx512_linu): ...this.
     * amd64-tdep.c (features/i386/amd64-avx-avx512.c): New include.
     (features/i386/x32-avx-mpx-avx512.c): Rename to...
     (features/i386/x32-avx-avx512.c): ...this.
     (amd64_target_description): Add dedicated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_amd64_tdep): Add call to
     initialize_tdesc_amd64_avx_avx512.
     (initialize_tdesc_x32_avx_mpx_avx512): Rename to...
     (initialize_tdesc_x32_avx_avx512): ...this.
     * features/Makefile (WHICH): New tdescs i386/i386-avx-avx512,
     i386/i386-avx-avx512-linux, i386/amd64-avx-avx512,
     i386/amd64-avx-avx512-linux.
     (i386/x32-avx-mpx-avx512): Rename to...
     (i386/x32-avx-avx512): ...this.
     (i386/x32-avx-mpx-avx512-linux): Rename to...
     (i386/x32-avx-avx512-linux): ...this.
     (i386/i386-avx-avx512-expedite, i386/i386-avx-avx512-linux-expedite,
     i386/amd64-avx-avx512-expedite, i386/amd64-avx-avx512-linux-expedite):
     New expedites.
     (i386/x32-avx-mpx-avx512-expedite): Rename to...
     (i386/x32-avx-avx512-expedite): ...this.
     (i386/x32-avx-mpx-avx512-linux-expedite): Rename to...
     (i386/x32-avx-avx512-linux-expedite): ...this.
     (XMLTOC): New XML files i386/amd64-avx-avx512-linux.xml,
     i386/amd64-avx-avx512.xml, i386/i386-avx-avx512-linux.xml,
     i386/i386-avx-avx512.xml.
     (i386/x32-avx-mpx-avx512-linux.xml): Rename to...
     (i386/x32-avx-avx512-linux.xml): ...this.
     (i386/x32-avx-mpx-avx512.xml): Rename to...
     (i386/x32-avx-avx512.xml): ...this.
     ($(outdir)/i386/i386-avx-avx512.dat): New rule.
     ($(outdir)/i386/i386-avx-avx512-linux.dat): Likewise.
     ($(outdir)/i386/amd64-avx-avx512.dat): Likewise.
     ($(outdir)/i386/amd64-avx-avx512-linux.dat): Likewise.
     ($(outdir)/i386/x32-avx-mpx-avx512.dat):  Rename to...
     ($(outdir)/i386/x32-avx-avx512.dat): ...this.
     ($(outdir)/i386/x32-avx-mpx-avx512-linux.dat): Rename to...
     ($(outdir)/i386/x32-avx-avx512-linux.dat): ...this.
     * features/i386/amd64-avx-avx512-linux.c: New file.
     * features/i386/amd64-avx-avx512-linux.xml: Likewise.
     * features/i386/amd64-avx-avx512.c: Likewise.
     * features/i386/amd64-avx-avx512.xml: Likewise.
     * features/i386/i386-avx-avx512-linux.c: Likewise.
     * features/i386/i386-avx-avx512-linux.xml: Likewise.
     * features/i386/i386-avx-avx512.c: Likewise.
     * features/i386/i386-avx-avx512.xml: Likewise.
     * features/i386/x32-avx-mpx-avx512-linux.c: Deleted.
     * features/i386/x32-avx-avx512-linux.c: New file.
     * features/i386/x32-avx-mpx-avx512-linux.xml: Deleted.
     * features/i386/x32-avx-avx512-linux.xml: New file.
     * features/i386/x32-avx-mpx-avx512.c: Deleted.
     * features/i386/x32-avx-avx512.c: New file.
     * features/i386/x32-avx-mpx-avx512.xml: Deleted.
     * features/i386/x32-avx-avx512.xml: New file.
     * i386-linux-tdep.c (features/i386/i386-avx-avx512-linux.c): New include.
     (i386_linux_core_read_description): Add dedicated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_i386_linux_tdep): Add call to
     initialize_tdesc_i386_avx_avx512_linux.
     * i386-linux-tdep.h (tdesc_i386_avx_avx512_linux): New prototype.
     * i386-tdep.c (features/i386/i386-avx-avx512.c): New include.
     (i386_validate_tdesc_p): Correct XSTATE mask used for feature_avx512.
     (i386_target_description): Add dedicated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (_initialize_i386_tdep): Add call to initialize_tdesc_i386_avx_avx512.
     * regformats/i386/amd64-avx-avx512-linux.dat: New file
     * regformats/i386/amd64-avx-avx512.dat: Likewise.
     * regformats/i386/i386-avx-avx512-linux.dat: Likewise.
     * regformats/i386/i386-avx-avx512.dat: Likewise.
     * regformats/i386/x32-avx-mpx-avx512-linux.dat: Deleted.
     * regformats/i386/x32-avx-avx512-linux.dat: New file.
     * regformats/i386/x32-avx-mpx-avx512.dat: Deleted.
     * regformats/i386/x32-avx-avx512.dat: New file.
     * x86-linux-nat.c (x86_linux_read_description): Add dedidated case for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate description.

gdbserver/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * Makefile.in  (clean): Add handling of new source files
     i386-avx-avx512.c, i386-avx-avx512-linux.c, amd64-avx-avx512.c,
     amd64-avx-avx512-linux.c.
     (x32-avx-mpx-avx512.c): Rename to...
     (x32-avx-avx512.c): ...this.
     (x32-avx-mpx-avx512-linux.c): Rename to...
     (x32-avx-avx512-linux.c): ...this.
     (i386-avx-avx512-linux-ipa.o): New rule.
     (amd64-avx-avx512-linux-ipa.o): Likewise.
     (i386-avx-avx512.c): Likewise.
     (i386-avx-avx512-linux.c): Likewise.
     (amd64-avx-avx512.c): Likewise.
     (amd64-avx-avx512-linux.c): Likewise.
     (x32-avx-avx512.c): Rename rule, source files, dat files from
     x32-avx-mpx-avx512.*) to this.
     (x32-avx-avx512-linux.c): Rename rule, source files, dat files from
     x32-avx-mpx-avx512-linux.*) to this.
     * configure.srv (srv_i386_regobj): Add i386-avx-avx512.o.
     (srv_i386_linux_regobj): Add i386-avx-avx512-linux.o.
     (srv_amd64_regobj): Add amd64-avx-avx512.o, rename
     x32-avx-mpx-avx512.o to x32-avx-avx512.o.
     (srv_amd64_linux_regobj): Add amd64-avx-avx512-linux.o, rename
     x32-avx-mpx-avx512-linux.o to x32-avx-avx512-linux.o.
     (ipa_i386_linux_regobj): Add i386-avx-avx512-linux-ipa.o.
     (ipa_amd64_linux_regobj): Add amd64-avx-avx512-linux-ipa.o.
     (srv_i386_xmlfiles): Add i386/i386-avx-avx512.xml.
     (srv_amd64_xmlfiles): Add i386/amd64-avx-avx512.xml, rename
     x32-avx-mpx-avx512.xml to x32-avx-avx512.xml.
     (srv_i386_linux_xmlfiles): Add i386/i386-avx-avx512-linux.xml.
     (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-avx512-linux.xml,
     rename x32-avx-mpx-avx512-linux.xml to x32-avx-avx512-linux.xml.
     * linux-amd64-ipa.c (get_ipa_tdesc): Add dedicated case for
     X86_TDESC_AVX_AVX512 and return appropriate tdesc.
     (initialize_low_tracepoint): Add init_registers_amd64_avx_avx512_linux.
     * linux-i386-ipa.c (get_ipa_tdesc): Add dedicated case for
     X86_TDESC_AVX_AVX512 and return appropriate tdesc.
     (initialize_low_tracepoint): Add init_registers_i386_avx_avx512_linux.
     * linux-x86-low.c (x86_linux_read_description): Add dedicated cases for
     X86_XSTATE_AVX_AVX512_MASK and return appropriate tdesc.
     (x86_get_ipa_tdesc_idx): Rename tdesc_x32_avx_mpx_avx512_linux to
     tdesc_x32_avx_avx512_linux, add dedicated if-clause for
     tdesc_amd64_avx_avx512_linux and return appropriate mask.
     Add dedicated clause for tdesc_i386_avx_avx512_linux
     and return appropriate mask.
     (initialize_low_arch): Add init_registers_amd64_avx_avx512_linux,
     rename init_registers_x32_avx_mpx_avx512_linux, add
     init_registers_i386_avx_avx512_linux.
     * linux-x86-tdesc.h (enum x86_linux_tdesc): Add new value for
     X86_TDESC_AVX_AVX512.
     (init_registers_amd64_avx_avx512_linux): New prototype.
     (tdesc_amd64_avx_avx512_linux): Likewise.
     (init_registers_x32_avx_mpx_avx512_linux): Rename to...
     (init_registers_x32_avx_avx512_linux): ...this.
     (tdesc_x32_avx_mpx_avx512_linux): Rename to...
     (tdesc_x32_avx_avx512_linux): ...this.
     (init_registers_i386_avx_avx512_linux): New prototype.
     (tdesc_i386_avx_avx512_linux): Likewise.

Change-Id: I01359fab56c961a39568df50af39714ec7b31706
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
7 years agoRename target descriptions to reflect actual content of description.
Michael Sturm [Fri, 27 Jan 2017 15:14:28 +0000 (16:14 +0100)] 
Rename target descriptions to reflect actual content of description.

To better reflect the actual feature set covered by the IA target
descriptions, the existing descriptions are renamed. Each feature of
the extended state is added to the name of a description or xstate mask
starting from AVX.
For example, amd64-mpx-avx512-linux becomes amd64-avx-mpx-avx512-linux,
while amd64-avx-linux remains unchanged.
Likewise, the corresponding xstate masks are changed, e.g. from
X86_XSTATE_MPX_AVX512_MASK to X86_XSTATE_AVX_MPX_AVX512_MASK.

gdb/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * amd64-linux-tdep.c (features/i386/amd64-avx512-linux.c): Rename
     include to...
     (features/i386/amd64-avx-mpx-avx512-linux.c): ...this.
     (features/i386/x32-avx512-linux.c): Rename include to...
     (features/i386/x32-avx-mpx-avx512-linux.c): ...this.
     (amd64_linux_core_read_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     X86_XSTATE_AVX512_MASK, desc_x32_avx512_linux, tdesc_amd64_avx512_linux.
     (_initialize_amd64_linux_tdep): Rename
     initialize_tdesc_amd64_avx512_linux, initialize_tdesc_x32_avx512_linux.
     * amd64-linux-tdep.h (tdesc_amd64_avx512_linux): Rename to...
     (tdesc_amd64_avx_mpx_avx512_linux): ...this.
     (tdesc_x32_avx512_linux): Rename to...
     (tdesc_x32_avx_mpx_avx512_linux): ...this.
     * amd64-tdep.c (features/i386/amd64-avx512.c): Rename include to...
     (features/i386/amd64-avx-mpx-avx512.c): ...this.
     (features/i386/x32-avx512.c): Rename include to...
     (features/i386/x32-avx-mpx-avx512.c): ...this.
     (amd64_target_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     X86_XSTATE_AVX512_MASK, tdesc_amd64_avx512.
     (_initialize_amd64_tdep): Rename initialize_tdesc_amd64_avx512. Rename
     initialize_tdesc_x32_avx512.
     * common/x86-xstate.h (X86_XSTATE_AVX512_MASK): Rename to...
     (X86_XSTATE_AVX_AVX512_MASK): ...this.
     (86_XSTATE_MPX_AVX512_MASK): Rename to...
     (X86_XSTATE_AVX_MPX_AVX512_MASK): ...this.
     (X86_XSTATE_ALL_MASK): Rename X86_XSTATE_MPX_AVX512_MASK to
     X86_XSTATE_AVX_MPX_AVX512_MASK.
     * features/Makefile (WHICH): Rename i386/i386-avx512,
     i386/i386-avx512-linux, i386/amd64-avx512, i386/amd64-avx512-linux,
     i386/x32-avx512, i386/x32-avx512-linux.
     (i386/i386-avx512-expedite, i386/i386-avx512-linux-expedite,
     i386/amd64-avx512-expedite, i386/amd64-avx512-linux-expedite,
     i386/x32-avx512-expedite, i386/x32-avx512-linux-expedite): Rename
     expedites.
     (XMLTOC): Rename i386/amd64-avx512-linux.xml, i386/amd64-avx512.xml,
     i386/i386-avx512-linux.xml, i386/i386-avx512.xml,
     i386/x32-avx512-linux.xml, i386/x32-avx512.xml.
     ($(outdir)/i386/i386-avx512.dat): Rename dat file in rule.
     ($(outdir)/i386/i386-avx512-linux.dat): Likewise.
     ($(outdir)/i386/amd64-avx512.dat): Likewise.
     ($(outdir)/i386/amd64-avx512-linux.dat): Likewise.
     ($(outdir)/i386/x32-avx512.dat): Likewise.
     ($(outdir)/i386/x32-avx512-linux.dat): Likewise.
     * features/i386/amd64-avx512-linux.c: Regenerate from renamed XML file.
     * features/i386/amd64-avx512-linux.xml: Rename XML file.
     * features/i386/amd64-avx512.c: Regenerate from renamed XML file.
     * features/i386/amd64-avx512.xml: Rename XML file.
     * features/i386/i386-avx512-linux.c: Regenerate from renamed XML file.
     * features/i386/i386-avx512-linux.xml: Rename XML file.
     * features/i386/i386-avx512.c: Regenerate from renamed XML file.
     * features/i386/i386-avx512.xml: Rename XML file.
     * features/i386/x32-avx512-linux.c: Regenerate from renamed XML file.
     * features/i386/x32-avx512-linux.xml: Rename XML file.
     * features/i386/x32-avx512.c: Regenerate from renamed XML file.
     * features/i386/x32-avx512.xml: Rename XML file.
     * i386-linux-tdep.c (features/i386/i386-avx512-linux.c): Rename to...
     (features/i386/i386-avx-mpx-avx512-linux.c): ...this.
     (i386_linux_core_read_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     X86_XSTATE_AVX512_MASK, tdesc_i386_avx512_linux.
     (_initialize_i386_linux_tdep): Rename initialize_tdesc_i386_avx512_linux.
     * i386-linux-tdep.h (tdesc_i386_avx512_linux): Rename to...
     (tdesc_i386_avx_mpx_avx512_linux): ...this.
     * i386-tdep.c (features/i386/i386-avx512.c): Rename to...
     (features/i386/i386-avx-mpx-avx512.c): ...this.
     (i386_register_reggroup_p): Rename X86_XSTATE_AVX512_MASK.
     (i386_validate_tdesc_p): Likewise.
     (i386_target_description): Rename X86_XSTATE_MPX_AVX512_MASK,
     tdesc_i386_avx512.
     (_initialize_i386_tdep): Rename initialize_tdesc_i386_avx512.
     * regformats/i386/amd64-avx512-linux.dat: Regenerate from renamed XML
     file.
     * regformats/i386/amd64-avx512.dat: Likewise.
     * regformats/i386/i386-avx512-linux.dat: Likewise.
     * regformats/i386/i386-avx512.dat: Likewise.
     * regformats/i386/x32-avx512-linux.dat: Likewise.
     * regformats/i386/x32-avx512.dat: Likewise.
     * x86-Linux-nat.c (x86_linux_read_description): Rename
     X86_XSTATE_MPX_AVX512_MASK, X86_XSTATE_AVX512_MASK,
     tdesc_x32_avx512_linux, tdesc_amd64_avx512_linux, tdesc_i386_avx512_linux.

gdbserver/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * Makefile.in (clean): Rename i386-avx512.c, i386-avx512-linux.c,
     amd64-avx512.c, amd64-avx512-linux.c, x32-avx512.c, x32-avx512-linux.c.
     (i386-avx512-linux-ipa.o): Rename rule and source files.
     (amd64-avx512-linux-ipa.o): Likewise.
     (i386-avx512.c): Rename rule, source fils and dat files.
     (i386-avx512-linux.c): Likewise.
     (amd64-avx512.c): Likewise.
     (amd64-avx512-linux.c): Likewise.
     (x32-avx512.c): Likewise.
     (x32-avx512-linux.c): Likewise.
     * configfure.srv (srv_i386_regobj): Rename i386-avx512.o.
     (i386_linux_regobj): Rename i386-avx512-linux.o.
     (srv_amd64_regobj): Rename amd64-avx512.o, x32-avx512.o.
     (srv_amd64_linux_regobj): Rename amd64-avx512-linux.o,
     x32-avx512-linux.o.
     (ipa_i386_linux_regobj): Rename i386-avx512-linux-ipa.o.
     (ipa_amd64_linux_regobj): Rename amd64-avx512-linux-ipa.o.
     (srv_i386_xmlfiles): Rename i386/i386-avx512.xml.
     (srv_amd64_xmlfiles): Rename i386/amd64-avx512.xml, i386/x32-avx512.xml.
     (srv_i386_linux_xmlfiles): Rename i386/i386-avx512-linux.xml.
     (srv_amd64_linux_xmlfiles): Rename i386/amd64-avx512-linux.xml,
     i386/x32-avx512-linux.xml).
     * linux-amd64-ipa.c (get_ipa_tdesc): Rename X86_TDESC_AVX512 and returned
     tdesc for that case.
     (initialize_low_tracepoint): Rename init_registers_amd64_avx512_linux.
     * linux-i386-ipa.c (get_ipa_tdesc): Rename X86_TDESC_AVX512 and tdesc
     returned for that case.
     (initialize_low_tracepoint): Rename init_registers_i386_avx512_linux.
     * linux-x86-low.c (x86_linux_read_description): Rename
     X86_XSTATE_AVX512_MASK and tdesc returned for that case.
     (x86_get_ipa_tdesc_idx): Rename tdesc_amd64_avx512_linux,
     tdesc_x32_avx512_linux and mask returned for these descriptions.
     Rename tdesc_i386_avx512_linux and mask returned for that description.
     (initialize_low_arch): Rename init_registers_amd64_avx512_linux,
     init_registers_x32_avx512_linux, init_registers_i386_avx512_linux.
     * linux-x86-tdesc.h (enum x86_linux_tdesc): Rename X86_TDESC_AVX512.
     (init_registers_amd64_avx512_linux): Rename to...
     (init_registers_amd64_avx_mpx_avx512_linux): ...this.
     (tdesc_amd64_avx512_linux): Rename to...
     (tdesc_amd64_avx_mpx_avx512_linux): ...this.
     (init_registers_x32_avx512_linux): Rename to...
     (init_registers_x32_avx_mpx_avx512_linux): ...this.
     (tdesc_x32_avx512_linux): Rename to...
     (tdesc_x32_avx_mpx_avx512_linux): ...this.
     (init_registers_i386_avx512_linux): Rename to...
     (init_registers_i386_avx_mpx_avx512_linux): ...this.
     (tdesc_i386_avx512_linux): Rename to...
     (tdesc_i386_avx_mpx_avx512_linux): ...this.

Change-Id: Idb83be3b3b72d5487542d4b568193df2777a3d9d
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
7 years agoChange xstate_bv handling to use 8 bytes of data.
Michael Sturm [Wed, 3 Feb 2016 16:55:20 +0000 (17:55 +0100)] 
Change xstate_bv handling to use 8 bytes of data.

The size of the state-component bitmap as specified in
Intel(R) 64 and IA-32 Architectures Software Developer's Manual,
Chapter 13.4.2 is 8 bytes.
So far, the data types used for xstate_bv_p (gdb_byte*),
clear_bv (unsigned int) and tdep->xcr0 (uint64_t) were
inconsistent. But, since the xstate components were still
fitting into a single byte, the code still worked
as expected.
However, with the addition of the PKU feature (bit 9),
using one byte for the bitmap will no longer be sufficient.

This patch changes related code to use 64 bit data types
consistently and changes read/write acces of the XSAVE
header in the xsave buffer to use the endianess-aware
functions extract_unsigned_integer and store_unsigned_integer.
This is required to make sure that eventual differences
in endianess between host and target are taken care off.

gdb/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * i387-tdep.c (i387_supply_xsave): Change type
     of clear_bv to ULONGEST. Replace gdb_byte *xstate_bv_p
     with ULONGEST xstate_bv and use extract_unsigned_integer
     and store_unsigned_integer to read/write its value from
     the xsave buffer.
     (i387_collect_xsave): Replace gdb_byte *xstate_bv_p
     with ULONGEST initial_xstate_bv and use
     extract_unsigned_integer/store_unsigned_integer to
     read/write its value from the xsave buffer.
     Change type of clear_bv to ULONGEST.

gdbserver/Changelog:
2016-04-18  Michael Sturm  <michael.sturm@intel.com>

     * i387-fp.c (i387_cache_to_xsave): Change type of clear_bv to
     unsigned long long.
     (i387_fxsave_to_cache): Likewise.

Change-Id: I0de254158960b4f7bcbc9fe2fb857034fa1f7ca5
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
7 years agoSync up x86-gcc-cpuid.h with cpuid.h from gcc-6 branch.
Michael Sturm [Mon, 5 Dec 2016 14:03:06 +0000 (15:03 +0100)] 
Sync up x86-gcc-cpuid.h with cpuid.h from gcc-6 branch.

Pedro suggested a separate patch synching with GCCs cpuid.h
instead of just adding new bits for PKU feature.

 gdb/Changelog:
     2016-11-14  Michael Sturm  <michael.sturm@intel.com>

          * nat/x86-gcc-cpuid.h: Replace with copy of cpuid.h
            from gcc-6 branch.

Change-Id: I16f8f7f2d0aa7c2e815701d15ed831a6c6b33d21
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
7 years agoRelax dwarf2 expected error match
Alan Modra [Fri, 17 Feb 2017 07:28:17 +0000 (17:58 +1030)] 
Relax dwarf2 expected error match

* testsuite/ld-elf/dwarf2.err: Accept other errors between the
multiple definition errors.

7 years agoRelax dwarf3 expected error match
Alan Modra [Fri, 17 Feb 2017 06:54:02 +0000 (17:24 +1030)] 
Relax dwarf3 expected error match

* testsuite/ld-elf/dwarf2.err: Add missing newline at end.
* testsuite/ld-elf/dwarf3.err: Likewise.  Allow match without filename.

7 years agobfd: Rename Chunk and S3Forced
Pedro Alves [Fri, 17 Feb 2017 01:26:12 +0000 (01:26 +0000)] 
bfd: Rename Chunk and S3Forced

The direct references in objcopy kind of look like a hack to me, so
I'm calling these symbols internal too.  Certainly they aren't named
and documented as a public BFD symbol today anyway.

So ... give these bfd-internal symbols with external linkage a _bfd_
prefix to avoid collisions in the global symbol namespace.

While at it, give them names that more closely match the corresponding
option name that toggles them.

Also while at it, fix a few related comment typos.

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

* srec.c (Chunk): Rename to ...
(_bfd_srec_len): ... this.
(S3Forced): Rename to ...
(_bfd_srec_forceS3): ... this.
* objcopy.c: Adjust all references.

7 years agobfd: Rename bsd_write_armap and coff_write_armap
Pedro Alves [Fri, 17 Feb 2017 01:26:12 +0000 (01:26 +0000)] 
bfd: Rename bsd_write_armap and coff_write_armap

Give these bfd-internal symbols with external linkage a _bfd_ prefix
to avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-17  Pedro Alves  <palves@redhat.com>

* archive.c (bsd_write_armap): Rename to ...
(_bfd_bsd_write_armap): ... this.
(coff_write_armap): Rename to ...
(_bfd_coff_write_armap): ... this.
* libbfd-in.h (bsd_write_armap): Rename to ...
(_bfd_bsd_write_armap): ... this.
(coff_write_armap): Rename to ...
(_bfd_coff_write_armap): ... this.
* aout-target.h, aout-tic30.c: Adjust all users.
* libbfd.h: Regenerate.

7 years agobfd: Rename warn_deprecated
Pedro Alves [Fri, 17 Feb 2017 01:26:12 +0000 (01:26 +0000)] 
bfd: Rename warn_deprecated

Give this bfd-internal symbol with external linkage a _bfd_ prefix to
avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-17  Pedro Alves  <palves@redhat.com>

* bfd-in.h (bfd_read, bfd_write): Adjust to rename.
(warn_deprecated): Rename to ...
(_bfd_warn_deprecated): ... this.
* libbfd.c (warn_deprecated): Rename to ...
(_bfd_warn_deprecated): ... this.
* bfd-in2.h: Regenerate.

7 years agobfd: Rename real_{ftell, fseek, fopen}
Pedro Alves [Fri, 17 Feb 2017 01:26:12 +0000 (01:26 +0000)] 
bfd: Rename real_{ftell, fseek, fopen}

Give these bfd-internal symbols with external linkage a _bfd_ prefix
to avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-17  Pedro Alves  <palves@redhat.com>

* bfdio.c (real_ftell): Rename to ...
(_bfd_real_ftell): ... this.
(real_fseek): Rename to ...
(_bfd_real_fseek): ... this.
(real_fopen): Rename to ...
(_bfd_real_fopen): ... this.
* libbfd-in.h (real_ftell): Rename to ...
(_bfd_real_ftell): ... this.
(real_fseek): Rename to ...
(_bfd_real_fseek): ... this.
(real_fopen): Rename to ...
(_bfd_real_fopen): ... this.
* cache.c, dwarf2.c, opncls.c: Adjust all callers.
* libbfd.h: Regenerate.

7 years agobfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128
Pedro Alves [Fri, 17 Feb 2017 01:26:11 +0000 (01:26 +0000)] 
bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128

Give these bfd-internal symbols with external linkage a _bfd_ prefix
to avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-17  Pedro Alves  <palves@redhat.com>

* dwarf2.c, elf-attrs.c, elf32-nds32.c: Adjust all callers.
* libbfd.c (read_unsigned_leb128): Rename to ...
(_bfd_read_unsigned_leb128): ... this.
(read_signed_leb128): Rename to ...
(_bfd_read_signed_leb128): ... this.
(safe_read_leb128): Rename to ...
(_bfd_safe_read_leb128): ... this.
* libbfd-in.h (read_unsigned_leb128): Rename to ...
(_bfd_read_unsigned_leb128): ... this.
(read_signed_leb128): Rename to ...
(_bfd_read_signed_leb128): ... this.
(safe_read_leb128): Rename to ...
(_bfd_safe_read_leb128): ... this.
* libbfd.h: Renegerate.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 17 Feb 2017 00:00:26 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agobfd: Improve lookup of file / line information for errors
Andrew Burgess [Mon, 19 Dec 2016 15:27:59 +0000 (15:27 +0000)] 
bfd: Improve lookup of file / line information for errors

When looking up file and line information (used from the linker to
report error messages) if no symbol is passed in, then use the symbol
list to look for a matching symbol.

If a matching symbol is found then use this to look up the file / line
information.

This should improve errors when looking up file / line information for
data sections.  Hopefully we should find a matching data symbol, which
should, in turn (we hope) match a DW_TAG_variable in the DWARF, this
should allow us to give accurate file / line errors for data symbols.

As the hope is to find a matching DW_TAG_variable in the DWARF then we
ignore section symbols, and prefer global symbols to locals.

bfd/ChangeLog:

* dwarf2.c (_bfd_dwarf2_find_nearest_line): Perform symbol lookup
before trying to fine matching file and line information.

ld/ChangeLog:

* testsuite/ld-elf/shared.exp: Update expected results.
* testsuite/ld-elf/dwarf2.err: Likewise

7 years agobfd/dwarf: Improve use of previously loaded dwarf information
Andrew Burgess [Thu, 15 Dec 2016 15:22:49 +0000 (15:22 +0000)] 
bfd/dwarf: Improve use of previously loaded dwarf information

When parsing DWARF data in order to report file/line type error messages
we perform section placement to make section addresses unique within
relocatable object files.

Currently, if we reuse previously loaded (and cached) dwarf data then we
neglect to perform section placement, the result is that the section
addresses will not be unique, and we might, incorrectly associate an
address with the wrong debug information, and so report an incorrect
file and line number.

Further we neglect to check that that bfd for which we are looking up
debug information is actually the bfd for which the previous debug
information was loaded, it is possible that we will reuse previously
loaded debug information for a different bfd.

And finally, due to following of gnu_debuglink links in one bfd to
another, the process of checking that the cached debug information is
valid requires us to track the original bfd in the cached debug
information.  The original debug information here is either the bfd that
we're interested in, not the bfd we finally load the debug information
from.

bfd/ChangeLog:

* dwarf2.c (struct dwarf2_debug): Add orig_bfd member.
(_bfd_dwarf2_slurp_debug_info): If stashed debug information does
not match current bfd, then reload debug information.  Record bfd
we're loading debug info for in the stash.  If we have debug
informatin in the cache then perform section placement before
returning.

ld/ChangeLog:

* testsuite/ld-elf/dwarf.exp (build_tests): Add new tests.
* testsuite/ld-elf/dwarf2.err: New file.
* testsuite/ld-elf/dwarf2a.c: New file.
* testsuite/ld-elf/dwarf2b.c: New file.
* testsuite/ld-elf/dwarf3.c: New file.
* testsuite/ld-elf/dwarf3.err: New file.

7 years agold: Add additional checking for warnings/errors in testsuite
Andrew Burgess [Tue, 7 Feb 2017 22:31:46 +0000 (22:31 +0000)] 
ld: Add additional checking for warnings/errors in testsuite

This commit adds new actions to the run_cc_link_tests mechanism in the
linker testsuite.

Previously this procedure could take a parameter containing a regular
expression that would be matched against warnings from the linker.

After this commit the warnings parameter is removed, instead, the
actions list can contain the actions 'warning', 'error',
'warning_output', or 'error_output'.  The action names are chosen to
match the actions already present in the run_dump_test procedure.

These new actions allow for the current warning checking, but also allow
for checking of errors using a regular expression.  More interestingly,
the *_output actions allow for the warning/error patterns to be placed
in a separate file.

The small number of tests that make use of the warning parameter have
been updated to the new mechanism.  Later commits will make use of the
new features added in this commit.

ld/ChangeLog:

* testsuite/lib/ld-lib.exp (run_cc_link_tests): Add warning,
error, warning_output, and error_output actions.  Remove separate
warnings parameter.
* testsuite/ld-elf/shared.exp (build_tests): Updated to use
'warning' action.
* testsuite/ld-plugin/lto.exp (lto_link_tests): Likewise.

7 years agold testsuite function pointer comparisons vs. hppa
Alan Modra [Thu, 16 Feb 2017 11:49:10 +0000 (22:19 +1030)] 
ld testsuite function pointer comparisons vs. hppa

ld/testsuite/ld-elf/check-ptr-eq.c fails for hppa, since function
pointers may point at plabels.  It isn't valid to cast two function
pointers to void* and then compare the void pointers.

* testsuite/ld-elf/check-ptr-eq.c (check_ptr_eq): Change params
from void pointers to function pointers.
* testsuite/ld-elf/pr18718.c: Update to suit.
* testsuite/ld-elf/pr18720a.c: Update to suit.

7 years agohppa -z relro again
Alan Modra [Tue, 14 Feb 2017 00:15:51 +0000 (10:45 +1030)] 
hppa -z relro again

I misunderstood the hppa alias problem.  File offsets of segments need
to be such that no page is mapped twice with different permissions.
(Which still seems to me like something the kernel could fix, but
anyhow, this is not so difficult to achieve in ld.)

PR 21000
bfd/
* elf-bfd.h (struct elf_backend_data): Add no_page_alias.
* elfxx-target.h (elf_backend_no_page_alias): Define.
(elfNN_bed): Init new field.
* elf.c (assign_file_positions_for_load_sections): If no_page_alias
ensure PT_LOAD segment starts on a new page.
* elf32-hppa.c (elf_backend_no_page_alias): Define.
ld/
* testsuite/ld-elf/loadaddr1.d: Adjust for hppa file offsets.
* testsuite/ld-elf/loadaddr2.d: Likewise.
* testsuite/ld-elf/loadaddr3a.d: Likewise.
* testsuite/ld-scripts/rgn-at5.d: Likewise.

7 years agoPR21132, hppa-linux pie support doesn't work
Alan Modra [Thu, 16 Feb 2017 01:53:12 +0000 (12:23 +1030)] 
PR21132, hppa-linux pie support doesn't work

This fixes a long-standing hppa bug seen when generating PIEs, and I
think possible to trigger with forced local symbols in shared
libraries.  Not allocating enough space for PLT relocs results in ld
writing outside of the buffer.

PR 21132
* elf32-hppa.c (allocate_plt_static): Allocate space for relocs
if pic.

7 years agoFix more powerpc testsuite source errors
Alan Modra [Thu, 16 Feb 2017 04:43:56 +0000 (15:13 +1030)] 
Fix more powerpc testsuite source errors

* testsuite/ld-powerpc/vxworks1-lib.s: Correct addi to addic.
* testsuite/ld-powerpc/vxworks1-lib.dd: Adjust to suit.

7 years ago[Patch] Add BFD_LINKER_CREATED to BFD_FLAGS_SAVED
Jiong Wang [Thu, 16 Feb 2017 09:40:03 +0000 (09:40 +0000)] 
[Patch] Add BFD_LINKER_CREATED to BFD_FLAGS_SAVED

bfd/
* bfd.c (BFD_FLAGS_SAVED): Add BFD_LINKER_CREATED.
* bfd-in2.h: Regenerated.

Bug exposed by https://sourceware.org/ml/binutils/2017-02/msg00128.html

7 years agoPR gdb/21164: maint print {symbols,msymbols,psymbols} without args crash
Sergio Durigan Junior [Wed, 15 Feb 2017 20:08:19 +0000 (15:08 -0500)] 
PR gdb/21164: maint print {symbols,msymbols,psymbols} without args crash

This is a fix for PR gdb/21164.  The problem started to happen after:

 commit 34c41c681f4a0a0dfe0405c7d2aecf458520557a
 Author:     Doug Evans <xdje42@gmail.com>
 AuthorDate: Mon Dec 19 08:33:46 2016 -0800

    New syntax for mt print symbols,msymbols,psymbols.

This change introduced new syntax for the mentioned commands, and
improved the parsing of arguments by using 'gdb_buildargv'.  However,
it is necessary to check if the argv being built is not NULL, which
can happen if the user doesn't provide any arguments to these
commands.

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

PR gdb/21164
* psymtab.c (maintenance_print_psymbols): Verify if 'argv' is not
NULL before using it.
* symmisc.c (maintenance_print_symbols): Likewise.
(maintenance_print_msymbols): Likewise.

gdb/testsuite/ChangeLog:

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

PR gdb/21164
* gdb.base/maint.exp: Add testcases for when the commands do
not have arguments.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 16 Feb 2017 00:00:30 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoi386: Allow "lea foo@GOT, %reg" in PIC
H.J. Lu [Wed, 15 Feb 2017 19:39:30 +0000 (11:39 -0800)] 
i386: Allow "lea foo@GOT, %reg" in PIC

"lea foo@GOT, %reg" is OK in PIC since it only loads the GOT offset
into register, which can be used later with a GOT base register to
get the value in the GOT entry.

bfd/

PR ld/21168
* elf32-i386.c (elf_i386_relocate_section): Allow
"lea foo@GOT, %reg" in PIC.

ld/

PR ld/21168
* testsuite/ld-i386/i386.exp: Run pr21168.
* testsuite/ld-i386/pr21168a.c: New file.
* testsuite/ld-i386/pr21168b.S: Likewise.

7 years agoAdd a test for R_386_GOT32/R_386_GOT32X IFUNC reloc error
H.J. Lu [Wed, 15 Feb 2017 18:55:51 +0000 (10:55 -0800)] 
Add a test for R_386_GOT32/R_386_GOT32X IFUNC reloc error

bfd/

PR ld/20244
* elf32-i386.c (elf_i386_relocate_section): Properly get IFUNC
symbol name when reporting R_386_GOT32/R_386_GOT32X relocation
error against local IFUNC symbol without a base register for
PIC.

ld/

PR ld/20244
* testsuite/ld-i386/i386.exp: Run pr20244-4a, pr20244-4b and
pr20244-4c.
* testsuite/ld-i386/pr20244-4.s: New file.
* testsuite/ld-i386/pr20244-4a.d: Likewise.
* testsuite/ld-i386/pr20244-4b.d: Likewise.
* testsuite/ld-i386/pr20244-4c.d: Likewise.

7 years agoAdd SFENCE.VMA instruction
Andrew Waterman [Tue, 14 Feb 2017 23:37:04 +0000 (15:37 -0800)] 
Add SFENCE.VMA instruction

include/ChangeLog:

2017-02-14  Andrew Waterman  <andrew@sifive.com>

        * opcode/riscv-opc.h (MATCH_SFENCE_VMA): New define.
        (MASK_SFENCE_VMA): Likewise.
        (sfence_vma): Declare instruction.

opcodes/ChangeLog:

2017-02-14  Andrew Waterman  <andrew@sifive.com>

        * riscv-opc.c (riscv_opcodes): Add sfence.vma instruction and
        pseudoinstructions.

7 years ago[AArch64] Add SVE system registers
Richard Sandiford [Wed, 15 Feb 2017 16:54:21 +0000 (16:54 +0000)] 
[AArch64] Add SVE system registers

This patch adds the SVE-specific system registers.

opcodes/
* aarch64-opc.c (aarch64_sys_regs): Add SVE registers.
(aarch64_sys_reg_supported_p): Handle them.

gas/
* testsuite/gas/aarch64/sve-sysreg.s,
testsuite/gas/aarch64/sve-sysreg.d,
testsuite/gas/aarch64/sve-sysreg-invalid.d,
testsuite/gas/aarch64/sve-sysreg-invalid.l: New tests.

7 years ago[AArch64] Fix +sve documentation
Richard Sandiford [Wed, 15 Feb 2017 16:51:17 +0000 (16:51 +0000)] 
[AArch64] Fix +sve documentation

The documentation entry for the SVE feature incorrectly said that
it was enabled by default for ARMv8-A or later.  This patch fixes
that and also mentions that +sve implies +simd.  (It also implies
+fp, but that follows by transitivity.)

gas/
* doc/c-aarch64.texi: Fix sve entry.

7 years agoLD: vfinfo: Make clever formatters consistent WRT function name reporting
Maciej W. Rozycki [Tue, 7 Feb 2017 02:08:23 +0000 (02:08 +0000)] 
LD: vfinfo: Make clever formatters consistent WRT function name reporting

Remove an inconsistency in linker error message processing causing that
it depends on the ability to infer the name of the originating source
file whether or not the name of the offending function is repeated by
clever formatters for each issue reported within the function.

Taking the `ld/testsuite/ld-powerpc/tocopt7.s' test case source as an
example and the `powerpc-linux' target we have:

$ as -gdwarf2 -o tocopt.o -a64 tocopt.s
$ ld -o tocopt -melf64ppc tocopt.o
tocopt.o: In function `_start':
tocopt.s:35:(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction.
tocopt.s:49:(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction.
$

vs:

$ as -o tocopt.o -a64 tocopt.s
$ ld -o tocopt -melf64ppc tocopt.o
tocopt.o: In function `_start':
(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction.
tocopt.o: In function `_start':
(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction.
$

Similarly with the `mips-linux' target and this source:

$ cat jal-global-multi-overflow.s
.text
.set noreorder
.space 0x2000

.align 4
.globl foo
.ent foo
foo:
jal bar
 nor $0, $0
jal bar
 nor $0, $0
.end foo

.space 0x1ff0

.align 4
.globl bar
.ent bar
bar:
jal foo
 nor $0, $0
jal foo
 nor $0, $0
.end bar
$ as -o jal-global-multi-overflow.o jal-global-multi-overflow.s
$ ld -Ttext 0x1fffd000 -e foo -o jal-global-multi-overflow jal-global-multi-overflow.o
jal-global-multi-overflow.o: In function `foo':
(.text+0x2000): relocation truncated to fit: R_MIPS_26 against `bar'
jal-global-multi-overflow.o: In function `foo':
(.text+0x2008): relocation truncated to fit: R_MIPS_26 against `bar'
jal-global-multi-overflow.o: In function `bar':
(.text+0x4000): relocation truncated to fit: R_MIPS_26 against `foo'
jal-global-multi-overflow.o: In function `bar':
(.text+0x4008): relocation truncated to fit: R_MIPS_26 against `foo'
$

Not only this is inconsistent, but it causes output clutter as well with
redundant information.

The cause for this is a check in `vfinfo' the intent of which is to
print the function heading whenever (among others) the name of the
source file has changed, which however does not take into account a
situation where the name couldn't have been established both now and
previously.

Adjust the check then for this situation, yielding:

$ as -o tocopt.o -a64 tocopt.s
$ ld -o tocopt -melf64ppc tocopt.o
tocopt.o: In function `_start':
(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction.
(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction.
$

and:

$ as -o jal-global-multi-overflow.o jal-global-multi-overflow.s
$ ld -Ttext 0x1fffd000 -e foo -o jal-global-multi-overflow jal-global-multi-overflow.o
jal-global-multi-overflow.o: In function `foo':
(.text+0x2000): relocation truncated to fit: R_MIPS_26 against `bar'
(.text+0x2008): relocation truncated to fit: R_MIPS_26 against `bar'
jal-global-multi-overflow.o: In function `bar':
(.text+0x4000): relocation truncated to fit: R_MIPS_26 against `foo'
(.text+0x4008): relocation truncated to fit: R_MIPS_26 against `foo'
$

respectively instead.  Adjust the test suite accordingly.

ld/
* ldmisc.c (vfinfo): Don't print the function name again either
if no source file name has been found both now and previously.
* testsuite/ld-cris/tls-err-20x.d: Adjust accordingly.
* testsuite/ld-mips-elf/mode-change-error-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-mips16.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-micromips.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-r6-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-2.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-r6-2.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-ignore-2.d: Likewise.
* testsuite/ld-mips-elf/unaligned-branch-ignore-mips16.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-branch-ignore-micromips.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-branch-ignore-r6-1.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-1.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-1.d:
Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-addend-3.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jump.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jump-mips16.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jump-micromips.d: Likewise.
* testsuite/ld-mips-elf/unaligned-lwpc-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-ldpc-1.d: Likewise.
* testsuite/ld-powerpc/tocopt.out: Likewise.
* testsuite/ld-powerpc/tocopt7.out: Likewise.

7 years agoPowerPC/BFD: Convert `%P: %H:' to `%H:' in error messages
Maciej W. Rozycki [Tue, 7 Feb 2017 02:07:21 +0000 (02:07 +0000)] 
PowerPC/BFD: Convert `%P: %H:' to `%H:' in error messages

Remove an inconsistency in BFD linker error messages across the PowerPC
backends, where in the presence of line information the `%P: %H:' format
sequence makes the first error message produced for any given function
different from subsequent ones.

Taking the `ld/testsuite/ld-powerpc/tocopt7.s' test case source as an
example and the `powerpc-linux' target we have:

$ as -gdwarf2 -o tocopt.o -a64 tocopt.s
$ ld -o tocopt -melf64ppc tocopt.o
ld: tocopt.o: In function `_start':
tocopt.s:35:(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction.
ld: tocopt.s:49:(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction.
$

where the first error message does not have the source file name
prefixed with the linker program executable's name, i.e. `ld:', whereas
the second error message does, as would any subsequent.

This is because with a multiple-line error message such as `%H' produces
`%P' only prints the program executable's name on the first line and not
any later ones.  Also the PowerPC backend is the only part of BFD which
uses `%P' along with one of the clever `%C', `%D', `%G', `%H' format
specifiers.  And last but not least this breaks a GNU Coding Standard's
requirement that error messages from compilers should look like this:

source-file-name:lineno: message

also quoted in `vfinfo' code handling these specifiers.

Convert `%P: %H:' to `%H:' in error messages across the PowerPC backends
then, yielding:

$ as -gdwarf2 -o tocopt.o -a64 tocopt.s
$ ld -o tocopt -melf64ppc tocopt.o
tocopt.o: In function `_start':
tocopt.s:35:(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction.
tocopt.s:49:(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction.
$

instead, making it consistent and matching the GNU Coding Standard's
requirement.

bfd/
* elf32-ppc.c (ppc_elf_check_relocs): Use `%H:' rather than
`%P: %H:' with `info->callbacks->einfo'.
(ppc_elf_relocate_section): Likewise.
* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
(ppc64_elf_edit_toc): Likewise.
(ppc64_elf_relocate_section): Likewise.

7 years agoLD: vfinfo: Remove static NULL initializers
Maciej W. Rozycki [Tue, 7 Feb 2017 02:06:20 +0000 (02:06 +0000)] 
LD: vfinfo: Remove static NULL initializers

Remove static NULL initializers, moving the respective variables from
data to BSS and saving some storage space.

ld/
* ldmisc.c (vfinfo) <'H'>: Remove static NULL initializers.

7 years agoFix illegal upper case gdb cmd in chained-calls.exp
Thomas Preud'homme [Wed, 15 Feb 2017 11:24:27 +0000 (11:24 +0000)] 
Fix illegal upper case gdb cmd in chained-calls.exp

3d7b173c29900879c9a5958dd6029fd36666e57c made upper case commands now
illegal. However gdb.cp/chained-calls.exp still contains one test using
P to print an expression. This patch fixes the testcase to use p
instead.

2017-02-13  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gdb/
* gdb.cp/chained-calls.exp: Use p instead of P.

7 years ago[ARC] Fix assembler relaxation.
Claudiu Zissulescu [Wed, 15 Feb 2017 10:57:51 +0000 (11:57 +0100)] 
[ARC] Fix assembler relaxation.

Fix assembler relaxation step for add, ld, mov, mpy and sub
instructions. Add tests to it.

gas/
2017-02-15  Claudiu Zissulescu  <claziss@synopsys.com>

* config/tc-arc.c (md_convert_frag): Remove @pcl relocation
information from input expression.
(assemble_insn): Make sure pcrel is correctly set.
(arc_pcrel_adjust): Compensate for PCL rounding.
* testsuite/gas/arc/relax-add01.d: New file.
* testsuite/gas/arc/relax-add01.s: Likewise.
* testsuite/gas/arc/relax-add02.d: Likewise.
* testsuite/gas/arc/relax-add02.s: Likewise.
* testsuite/gas/arc/relax-add03.d: Likewise.
* testsuite/gas/arc/relax-add03.s: Likewise.
* testsuite/gas/arc/relax-add04.d: Likewise.
* testsuite/gas/arc/relax-add04.s: Likewise.
* testsuite/gas/arc/relax-ld01.d: Likewise.
* testsuite/gas/arc/relax-ld01.s: Likewise.
* testsuite/gas/arc/relax-ld02.d: Likewise.
* testsuite/gas/arc/relax-ld02.s: Likewise.
* testsuite/gas/arc/relax-mov01.d: Likewise.
* testsuite/gas/arc/relax-mov01.s: Likewise.
* testsuite/gas/arc/relax-mov02.d: Likewise.
* testsuite/gas/arc/relax-mov02.s: Likewise.
* testsuite/gas/arc/relax-mpy01.d: Likewise.
* testsuite/gas/arc/relax-mpy01.s: Likewise.
* testsuite/gas/arc/relax-sub01.d: Likewise.
* testsuite/gas/arc/relax-sub01.s: Likewise.
* testsuite/gas/arc/relax-sub02.d: Likewise.
* testsuite/gas/arc/relax-sub02.s: Likewise.
* testsuite/gas/arc/relax-sub03.d: Likewise.
* testsuite/gas/arc/relax-sub03.s: Likewise.
* testsuite/gas/arc/relax-sub04.d: Likewise.
* testsuite/gas/arc/relax-sub04.s: Likewise.

opcodes/
2017-02-15  Claudiu Zissulescu  <claziss@synopsys.com>

* arc-opc.c (UIMM6_20R): Define.
(SIMM12_20): Use above.
(SIMM12_20R): Define.
(SIMM3_5_S): Use above.
(UIMM7_A32_11R_S): Define.
(UIMM7_9_S): Use above.
(UIMM3_13R_S): Define.
(SIMM11_A32_7_S): Use above.
(SIMM9_8R): Define.
(UIMM10_A32_8_S): Use above.
(UIMM8_8R_S): Define.
(W6): Use above.
(arc_relax_opcodes): Use all above defines.