binutils-gdb.git
4 years agoDon't re-process a DIE in read_lexical_block_scope
Tom Tromey [Fri, 8 May 2020 20:26:11 +0000 (14:26 -0600)]
Don't re-process a DIE in read_lexical_block_scope

A customer reported a crash in the DWARF reader.

Investigation showed that the crash occurred in an unusual scenario: a
function was lexically scoped within some other function -- but the
inner function inlined the outer function and referred to its DIE via
DW_AT_abstract_origin.  With the executable in question,
inherit_abstract_dies could eventually call read_lexical_block_scope,
which in turn could recurse into process_die, to process a DIE that
was already being read, triggering an assert.

This came up once before; see:

https://www.sourceware.org/ml/gdb-patches/2014-02/msg00652.html

However, in this case, I don't have an easy way to reproduce.  So,
there is no test case.

I did experiment with the failing executable.  This patch fixes the
bug and doesn't seem to cause other issues.  For example, I can still
set breakpoints on the relevant functions.

gdb/ChangeLog
2020-05-08  Tom Tromey  <tromey@adacore.com>

* dwarf2/read.c (read_lexical_block_scope): Don't process a DIE
already being processed.

4 years agoMore C++-ification for struct display
Tom Tromey [Fri, 8 May 2020 20:21:22 +0000 (14:21 -0600)]
More C++-ification for struct display

This changes displays to have a constructor, use bool and std::string,
and to be stored using std::vector.  The ALL_DISPLAYS and
ALL_DISPLAYS_SAFE macros are removed.  While internal iteration is
still done via map_display_numbers, this is updated to use a
function_view.  These changes simplify the code somewhat; for example,
free_display can now be removed in favor of ordinary destruction.

gdb/ChangeLog
2020-05-08  Tom Tromey  <tom@tromey.com>

* printcmd.c (struct display) <next>: Remove.
<display>: New constructor.
<exp_string>: Now a std::string.
<enabled_p>: Now a bool.
(display_number): Move definition earlier.
(displays): Rename from display_chain.  Now a std::vector.
(ALL_DISPLAYS, ALL_DISPLAYS_SAFE): Remove.
(display_command): Update.
(do_one_display, disable_display)
(enable_disable_display_command, do_enable_disable_display):
Update.
(free_display): Remove.
(clear_displays): Rewrite.
(delete_display): Update.
(map_display_numbers): Use function_view.  Remove "data"
parameter.  Update.
(do_delete_display): Remove.
(undisplay_command): Update.
(do_one_display, do_displays, disable_display)
(info_display_command): Update.
(do_enable_disable_display): Remove.
(enable_disable_display_command)
(clear_dangling_display_expressions): Update.

4 years agoRemove ALL_PSPACES
Tom Tromey [Fri, 8 May 2020 20:21:22 +0000 (14:21 -0600)]
Remove ALL_PSPACES

This removes the ALL_PSPACES macro.  In this case it seemed cleanest
to change how program spaces are stored -- instead of using a linked
list, they are now stored in a std::vector.

gdb/ChangeLog
2020-05-08  Tom Tromey  <tom@tromey.com>

* symtab.c (set_symbol_cache_size)
(maintenance_print_symbol_cache, maintenance_flush_symbol_cache)
(maintenance_print_symbol_cache_statistics): Update.
* symmisc.c (print_symbol_bcache_statistics)
(print_objfile_statistics, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs)
(maintenance_expand_symtabs, maintenance_info_line_tables):
Update.
* symfile-debug.c (set_debug_symfile): Update.
* source.c (forget_cached_source_info): Update.
* python/python.c (gdbpy_progspaces): Update.
* psymtab.c (maintenance_info_psymtabs): Update.
* probe.c (parse_probes): Update.
* linespec.c (iterate_over_all_matching_symtabs)
(collect_symtabs_from_filename, search_minsyms_for_name): Update.
* guile/scm-progspace.c (gdbscm_progspaces): Update.
* exec.c (exec_target::close): Update.
* ada-tasks.c (ada_tasks_new_objfile_observer): Update.
* breakpoint.c (print_one_breakpoint_location)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint): Update.
* progspace.c (program_spaces): Now a std::vector.
(maybe_new_address_space): Update.
(add_program_space): Remove.
(program_space::program_space): Update.
(remove_program_space): Update.
(number_of_program_spaces): Remove.
(print_program_space, update_address_spaces): Update.
* progspace.h (program_spaces): Change type.
(ALL_PSPACES): Remove.
(number_of_program_spaces): Don't declare.
(struct program_space) <next>: Remove.

4 years agoRemove ALL_SO_LIBS and so_list_head
Tom Tromey [Fri, 8 May 2020 20:21:22 +0000 (14:21 -0600)]
Remove ALL_SO_LIBS and so_list_head

This patch started as an attempt to replace ALL_SO_LIBS with an
ordinary C++ iterator.  However, then I tripped over the so_list_head
define again, and decided to remove it as well.

gdb/ChangeLog
2020-05-08  Tom Tromey  <tom@tromey.com>

* mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Update.
* solib-svr4.c (svr4_fetch_objfile_link_map): Update.
(enable_break): Update.
* solib-frv.c (frv_fdpic_find_global_pointer): Update.
(frv_fdpic_find_canonical_descriptor): Update.
(frv_fetch_objfile_link_map): Update.
* progspace.c (program_space::free_all_objfiles): Update.
(program_space::solibs): New method.
* progspace.h (struct program_space) <solibs>: New method.
* solist.h (master_so_list): Don't declare.
(ALL_SO_LIBS): Remove.
* solib.h (so_list_head): Remove.
(update_solib_list): Update comment.
* solib.c (master_so_list): Remove.
(solib_used, update_solib_list, solib_add)
(info_sharedlibrary_command, clear_solib)
(reload_shared_libraries_1, remove_user_added_objfile): Update.

4 years agoRemove ALL_EXTENSION_LANGUAGES and ALL_ENABLED_EXTENSION_LANGUAGES
Tom Tromey [Fri, 8 May 2020 20:21:22 +0000 (14:21 -0600)]
Remove ALL_EXTENSION_LANGUAGES and ALL_ENABLED_EXTENSION_LANGUAGES

This removes the ALL_EXTENSION_LANGUAGES and
ALL_ENABLED_EXTENSION_LANGUAGES macros, in favor of ordinary
iterators.  For ALL_ENABLED_EXTENSION_LANGUAGES, I chose to simply
inline the check, as that seemed simpler than trying to make
filtered_iterator work for std::array.  (As an aside, this sort of
thing will be easier once we can use the ranges library...)

gdb/ChangeLog
2020-05-08  Tom Tromey  <tom@tromey.com>

* extension.c (extension_languages): Now a std::array.
(ALL_EXTENSION_LANGUAGES): Remove.
(get_ext_lang_defn, get_ext_lang_of_file)
(eval_ext_lang_from_control_command): Update.
(finish_ext_lang_initialization)
(auto_load_ext_lang_scripts_for_objfile)
(ext_lang_type_printers::ext_lang_type_printers)
(apply_ext_lang_type_printers)
(ext_lang_type_printers::~ext_lang_type_printers)
(apply_ext_lang_val_pretty_printer, apply_ext_lang_frame_filter)
(preserve_ext_lang_values, get_breakpoint_cond_ext_lang)
(breakpoint_ext_lang_cond_says_stop, check_quit_flag)
(get_matching_xmethod_workers, ext_lang_colorize)
(ext_lang_before_prompt): Update.
(ALL_ENABLED_EXTENSION_LANGUAGES): Remove.

4 years agoSpeed up psymbol reading by removing a copy
Tom Tromey [Fri, 8 May 2020 20:14:05 +0000 (14:14 -0600)]
Speed up psymbol reading by removing a copy

I noticed that cp_canonicalize_string and friends copy a
unique_xmalloc_ptr to a std::string.  However, this copy isn't
genuinely needed anywhere, and it serves to slow down DWARF psymbol
reading.

This patch removes the copy and updates the callers to adapt.

This speeds up the reader from 1.906 seconds (mean of 10 runs, of gdb
on a copy of itself) to 1.888 seconds (mean of 10 runs, on the same
copy as the first trial).

gdb/ChangeLog
2020-05-08  Tom Tromey  <tom@tromey.com>

* symtab.h (class demangle_result_storage) <set_malloc_ptr>: New
overload.
<swap_string, m_string>: Remove.
* symtab.c (demangle_for_lookup, completion_list_add_symbol):
Update.
* stabsread.c (define_symbol, read_type): Update.
* linespec.c (find_linespec_symbols): Update.
* gnu-v3-abi.c (gnuv3_get_typeid): Update.
* dwarf2/read.c (dwarf2_canonicalize_name): Update.
* dbxread.c (read_dbx_symtab): Update.
* cp-support.h (cp_canonicalize_string_full)
(cp_canonicalize_string, cp_canonicalize_string_no_typedefs):
Return unique_xmalloc_ptr.
* cp-support.c (inspect_type): Update.
(cp_canonicalize_string_full): Return unique_xmalloc_ptr.
(cp_canonicalize_string_no_typedefs, cp_canonicalize_string):
Likewise.
* c-typeprint.c (print_name_maybe_canonical): Update.
* break-catch-throw.c (check_status_exception_catchpoint):
Update.

4 years ago[gdb] Fix stepping over fork with follow-fork-mode child and gcc-8
Tom de Vries [Fri, 8 May 2020 15:26:32 +0000 (17:26 +0200)]
[gdb] Fix stepping over fork with follow-fork-mode child and gcc-8

When running test-case gdb.threads/fork-child-threads.exp with gcc-8 instead
of gcc-7, we have:
...
 (gdb) next^M
 [Attaching after Thread 0x7ffff7fae740 (LWP 27574) fork to child process \
   27578]^M
 [New inferior 2 (process 27578)]^M
 [Detaching after fork from parent process 27574]^M
 [Inferior 1 (process 27574) detached]^M
 [Thread debugging using libthread_db enabled]^M
 Using host libthread_db library "/lib64/libthread_db.so.1".^M
 [Switching to Thread 0x7ffff7fae740 (LWP 27578)]^M
-main () at src/gdb/testsuite/gdb.threads/fork-child-threads.c:41^M
+main () at src/gdb/testsuite/gdb.threads/fork-child-threads.c:34^M
-41            i = pthread_create (&thread, NULL, start, NULL);^M
+34        switch (fork ())^M
-(gdb) PASS: gdb.threads/fork-child-threads.exp: next over fork
+(gdb) FAIL: gdb.threads/fork-child-threads.exp: next over fork
...

This is due to the fact that gcc-8 generates more precise line info, making
the instruction after the call to fork a "recommended breakpoint location".
However, it is a bug because next is supposed to move to the next source
line.

The problem is that in process_event_stop_test we hit this code:
...
  if ((ecs->event_thread->suspend.stop_pc == stop_pc_sal.pc)
      && (ecs->event_thread->current_line != stop_pc_sal.line
  || ecs->event_thread->current_symtab != stop_pc_sal.symtab))
    {
      if (stop_pc_sal.is_stmt)
{
  /* We are at the start of a different line.  So stop.  Note that
     we don't stop if we step into the middle of a different line.
     That is said to make things like for (;;) statements work
     better.  */
  if (debug_infrun)
    fprintf_unfiltered (gdb_stdlog,
"infrun: stepped to a different line\n");
  end_stepping_range (ecs);
  return;
}
...
because current_line and current_symtab have initial values:
...
(gdb) p ecs->event_thread->current_line
$8 = 0
(gdb) p ecs->event_thread->current_symtab
$9 = (symtab *) 0x0
...

Fix this in follow_fork by copying current_line and current_symtab from
parent thread to child thread.

Tested on x86_64-linux, with gcc 7.5.0 and gcc 10.0.1.

gdb/ChangeLog:

2020-05-08  Tom de Vries  <tdevries@suse.de>

* infrun.c (follow_fork): Copy current_line and current_symtab to
child thread.

4 years ago[gdb/testsuite] Add gdb.dwarf2/clang-debug-names.c
Tom de Vries [Fri, 8 May 2020 14:24:09 +0000 (16:24 +0200)]
[gdb/testsuite] Add gdb.dwarf2/clang-debug-names.c

Add test-case with .debug_names section using DW_FORM_ref4.

There's currently no support for .debug_names in the dwarf assembler, so we
use plain _emit rather than something more structured.

Consequently, we cannot use regular declare_labels-generated labels to refer
from .debug_names to .debug_info.  Instead, we use labels with a
predefined name, which we generate using _compute_label, and then define using
define_label.

This is the test-case for PR25952, so kfail the corresponding test.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-08  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/clang-debug-names.c: New test.
* gdb.dwarf2/clang-debug-names.exp: New file.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 8 May 2020 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb: small cleanup of async-event.c structs
Simon Marchi [Thu, 7 May 2020 15:41:45 +0000 (11:41 -0400)]
gdb: small cleanup of async-event.c structs

This is a small cleanup to normalize the structures in async-event.c
with the rest of the code base:

- Remove the unnecessary typedefs
- Fix indentation of struct bodies
- Put comments above fields

No functional changes expected.

gdb/ChangeLog:

* async-event.c (struct async_signal_handler, struct
async_event_handler): Reformat, remove typedef.

4 years agogdb: remove TYPE_DYN_PROP_LIST macro
Simon Marchi [Thu, 7 May 2020 15:18:42 +0000 (11:18 -0400)]
gdb: remove TYPE_DYN_PROP_LIST macro

Remove this macro, which abstracts how to obtain the dyn_prop_list of a
given type.  We could replace it with a method on `struct type`, but I
don't think it's needed, as the only code that accesses the dynamic prop
list directly is internal gdbtypes.c code (that can be seen as code
internal to `struct type`).  So it can just refer to the field directly.

gdb/ChangeLog:

* gdbtypes.h (TYPE_DYN_PROP_LIST): Remove.  Update all users
access thistype->main_type->dyn_prop_list directly.

4 years agogdb: make remove_dyn_prop a method of struct type
Simon Marchi [Thu, 7 May 2020 15:08:54 +0000 (11:08 -0400)]
gdb: make remove_dyn_prop a method of struct type

Move remove_dyn_prop, currently a free function, to be a method of
struct type.

gdb/ChangeLog:

* gdbtypes.h (struct type) <remove_dyn_prop>: New method.
(remove_dyn_prop): Remove.  Update all users to use
type::remove_dyn_prop.
* gdbtypes.c (remove_dyn_prop): Rename to...
(type::remove_dyn_prop): ... this.

4 years agogdb: make add_dyn_prop a method of struct type
Simon Marchi [Thu, 7 May 2020 15:17:33 +0000 (11:17 -0400)]
gdb: make add_dyn_prop a method of struct type

Move add_dyn_prop, currently a free function, to be a method of struct
type.

gdb/ChangeLog:

* gdbtypes.h (struct type) <add_dyn_prop>: New method.
(add_dyn_prop): Remove.  Update all users to use
type::add_dyn_prop.
* gdbtypes.c (add_dyn_prop): Rename to...
(type::add_dyn_prop): ... this.

4 years agogdb: make get_dyn_prop a method of struct type
Simon Marchi [Thu, 7 May 2020 15:32:25 +0000 (11:32 -0400)]
gdb: make get_dyn_prop a method of struct type

Move get_dyn_prop, currently a free function, to be a method on struct
type.

gdb/ChangeLog:

* gdbtypes.h (struct type) <get_dyn_prop>: New method.
(get_dyn_prop): Remove.  Update all users to use
type::dyn_prop.
* gdbtypes.c (get_dyn_prop): Rename to...
(type::dyn_prop): ... this.

4 years agoobjcopy: Mention 'entry address' in description
Andrew Burgess [Tue, 5 May 2020 14:48:13 +0000 (15:48 +0100)]
objcopy: Mention 'entry address' in description

The ELF header contains a start address, which is also sometimes
called the entry address.  The 'objdump -x' output calls this field
the 'start address', while readelf calls it 'entry point address'.
The linker talks about setting the 'entry' point in its manual.

I've always thought of this field as the 'entry address', and so when
I recently wanted to know if objcopy could adjust this field I opened
up the manual and searched for 'entry', which found no hits.

I thought it would be useful (for people like me) if the description
of 'set-start' and 'adjust-start' in the objcopy manual mentioned the
word 'entry' to make it easier to find.

binutils/ChangeLog:

* doc/binutils.texi: Mention 'entry address' in the set-start and
adjust-start options descriptions.

4 years agoUpdated French translation for the gprof sub-directory.
Nick Clifton [Thu, 7 May 2020 09:48:21 +0000 (10:48 +0100)]
Updated French translation for the gprof sub-directory.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 7 May 2020 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb: remove main_type::flag_static
Simon Marchi [Wed, 6 May 2020 16:26:05 +0000 (12:26 -0400)]
gdb: remove main_type::flag_static

It is not used.

gdb/ChangeLog:

* gdbtypes.h (struct main_type) <flag_static>: Remove.

4 years agogdb: handle endbr64 instruction in amd64_analyze_prologue
Simon Marchi [Wed, 6 May 2020 16:01:37 +0000 (12:01 -0400)]
gdb: handle endbr64 instruction in amd64_analyze_prologue

v2:
  - test: build full executable instead of object
  - test: add and use supports_fcf_protection
  - test: use gdb_test_multiple's -wrap option
  - test: don't execute gdb_assert if failed to get breakpoint address

Some GCCs now enable -fcf-protection by default.  This is the case, for
example, with GCC 9.3.0 on Ubuntu 20.04.  Enabling it causes the
`endbr64` instruction to be inserted at the beginning of all functions
and that breaks GDB's prologue analysis.

I noticed this because it gives many failures in gdb.base/break.exp.
But let's take this dummy program and put a breakpoint on main:

    int main(void)
    {
        return 0;
    }

Without -fcf-protection, the breakpoint is correctly put after the prologue:

    $ gcc test.c -g3 -O0 -fcf-protection=none
    $ ./gdb -q -nx --data-directory=data-directory a.out
    Reading symbols from a.out...
    (gdb) disassemble main
    Dump of assembler code for function main:
       0x0000000000001129 <+0>:     push   %rbp
       0x000000000000112a <+1>:     mov    %rsp,%rbp
       0x000000000000112d <+4>:     mov    $0x0,%eax
       0x0000000000001132 <+9>:     pop    %rbp
       0x0000000000001133 <+10>:    retq
    End of assembler dump.
    (gdb) b main
    Breakpoint 1 at 0x112d: file test.c, line 3.

With -fcf-protection, the breakpoint is incorrectly put on the first
byte of the function:

    $ gcc test.c -g3 -O0 -fcf-protection=full
    $ ./gdb -q -nx --data-directory=data-directory a.out
    Reading symbols from a.out...
    (gdb) disassemble main
    Dump of assembler code for function main:
       0x0000000000001129 <+0>:     endbr64
       0x000000000000112d <+4>:     push   %rbp
       0x000000000000112e <+5>:     mov    %rsp,%rbp
       0x0000000000001131 <+8>:     mov    $0x0,%eax
       0x0000000000001136 <+13>:    pop    %rbp
       0x0000000000001137 <+14>:    retq
    End of assembler dump.
    (gdb) b main
    Breakpoint 1 at 0x1129: file test.c, line 2.

Stepping in amd64_skip_prologue, we can see that the prologue analysis,
for GCC-compiled programs, is done in amd64_analyze_prologue by decoding
the instructions and looking for typical patterns.  This patch changes
the analysis to check for a prologue starting with the `endbr64`
instruction, and skip it if it's there.

gdb/ChangeLog:

* amd64-tdep.c (amd64_analyze_prologue): Check for `endbr64`
instruction, skip it if it's there.

gdb/testsuite/ChangeLog:

* gdb.arch/amd64-prologue-skip-cf-protection.exp: New file.
* gdb.arch/amd64-prologue-skip-cf-protection.c: New file.

4 years agoUpdated Swedish translation for the gas sub-directory
Nick Clifton [Wed, 6 May 2020 13:17:36 +0000 (14:17 +0100)]
Updated Swedish translation for the gas sub-directory

4 years ago[gdb/testsuite] Fix gdb.reverse/consecutive-{precsave,reverse}.exp with gcc-8
Tom de Vries [Wed, 6 May 2020 12:48:50 +0000 (14:48 +0200)]
[gdb/testsuite] Fix gdb.reverse/consecutive-{precsave,reverse}.exp with gcc-8

When running test-cases gdb.reverse/consecutive-precsave.exp and
gdb.reverse/consecutive-reverse.exp with gcc-8, we get:
...
FAIL: gdb.reverse/consecutive-precsave.exp: stopped at bp, 2nd instr
FAIL: gdb.reverse/consecutive-reverse.exp: stopped at bp, 2nd instr
...

These FAILs are duplicates of the FAILs fixed in commit 7c99e7e2b08
"[gdb/testsuite] Fix gdb.base/consecutive.exp with gcc-8".

Fix these in the same manner.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-06  Tom de Vries  <tdevries@suse.de>

* gdb.reverse/consecutive-precsave.exp: Handle if instruction after
breakpoint is at a "recommended breakpoint location".
* gdb.reverse/consecutive-reverse.exp: Same.

4 years ago[gdb/testsuite] Fix gdb.base/watchpoint-reuse-slot.exp with gcc-8
Tom de Vries [Wed, 6 May 2020 12:27:36 +0000 (14:27 +0200)]
[gdb/testsuite] Fix gdb.base/watchpoint-reuse-slot.exp with gcc-8

When running test-case gdb.base/watchpoint-reuse-slot.exp with gcc-8 instead
of gcc-7, we have:
...
 (gdb) PASS: $conf: watch *(buf.byte + 0 + 0)@1
 stepi^M
-0x00000000004004b9      34        for (i = 0; i < 100000; i++);^M
+34        for (i = 0; i < 100000; i++);^M
-(gdb) PASS: $conf: stepi advanced
+(gdb) FAIL: $conf: stepi advanced
...
where $conf is "gdb.base/watchpoint-reuse-slot.exp: hw-watch: always-inserted
off: watch x watch: : width 1, iter 0: base + 0".

This is due to the fact that gcc-8 generates more precise line info, making
the instruction at 0x4004b9 a "recommended breakpoint location", such that gdb
no longer prints the instruction address.

Fix this by getting the instruction address by printing $pc.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-06  Tom de Vries  <tdevries@suse.de>

* gdb.base/watchpoint-reuse-slot.exp (stepi): Print $pc to get current
address.

4 years agoSection "3.1 Preprocessing" of the online GAS manual has a wrong reference to "Using...
Nick Clifton [Wed, 6 May 2020 12:21:02 +0000 (13:21 +0100)]
Section "3.1 Preprocessing" of the online GAS manual has a wrong reference to "Using GNU CC".  This fixes that link.

PR 25927
* doc/as.texi (Preprocessing): Replace cross reference to not
existant document with a URL to the equivalent page in the GCC
manual.

4 years ago[gdb/testsuite] Fix cur_addr update in gdb.base/watchpoint-reuse-slot.exp
Tom de Vries [Wed, 6 May 2020 12:13:02 +0000 (14:13 +0200)]
[gdb/testsuite] Fix cur_addr update in gdb.base/watchpoint-reuse-slot.exp

I noticed this code in gdb.base/watchpoint-reuse-slot.exp, proc stepi:
...
    gdb_test_multiple "stepi" $test {
-re "($hex).*[string_to_regexp $srcline]\r\n$gdb_prompt $" {
    set addr $expect_out(1,string)
    if {$addr != $cur_addr} {
pass $test
    } else {
fail $test
    }
    set cur_addr addr
}
    }
...

The variable cur_addr is documented as:
...
 # The address the program is stopped at currently.
 set cur_addr ""
...
but in the gdb_test_multiple clause we assign the string "addr" to cur_addr,
while $addr contains the current address.

Fix this by assigning $addr instead "addr".

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-06  Tom de Vries  <tdevries@suse.de>

* gdb.base/watchpoint-reuse-slot.exp: Fix incorrect assignment.

4 years ago[gdb/testsuite] Fix gdb.base/store.exp with gcc-10
Tom de Vries [Wed, 6 May 2020 11:49:34 +0000 (13:49 +0200)]
[gdb/testsuite] Fix gdb.base/store.exp with gcc-10

When running gdb.base/store.exp with gcc-10 instead of gcc-9, we have:
...
 (gdb) PASS: gdb.base/store.exp: continue to wack_double
 print l^M
-$22 = <optimized out>^M
+$22 = -1^M
-(gdb) UNSUPPORTED: gdb.base/store.exp: var double l; print old l, expecting -1
-(gdb) PASS: gdb.base/store.exp: var double l; print old l, expecting -1
+print r^M
+$23 = <optimized out>^M
+(gdb) FAIL: gdb.base/store.exp: var double l; print old r, expecting -2
...

With gcc-9, there's no location info for both l and r, but with gcc-10,
there's location info for l, but not r.

The test-case only checks for location info availability of l, and then
assumes location info for r is also available.

Fix this by allowing missing location info for r.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-06  Tom de Vries  <tdevries@suse.de>

* gdb.base/store.exp (check_set, up_set): Allowing missing location
info for r.

4 years ago[gdb/testsuite] Fix gdb.base/shlib-call.exp with gcc-8
Tom de Vries [Wed, 6 May 2020 09:50:52 +0000 (11:50 +0200)]
[gdb/testsuite] Fix gdb.base/shlib-call.exp with gcc-8

When running test-case gdb.base/shlib-call.exp with gcc-8 instead of gcc-7, we
have:
...
 (gdb) step^M
-main () at /data/gdb_versions/devel/src/gdb/testsuite/gdb.base/shmain.c:42^M
-42        g = mainshr1(g);^M
-(gdb) PASS: gdb.base/shlib-call.exp: step out of shr2 epilogue to main
+main () at /data/gdb_versions/devel/src/gdb/testsuite/gdb.base/shmain.c:41^M
+41        g = shr2(g);^M
+(gdb) FAIL: gdb.base/shlib-call.exp: step out of shr2 epilogue to main
...

This is due to the fact that gcc-8 generates more precise line info, making
the instruction after the call to shr2 at 0x4008f1:
...
  4008e4:  8b 05 aa 07 20 00  mov    0x2007aa(%rip),%eax  # 601094 <g>
  4008ea:  89 c7              mov    %eax,%edi
  4008ec:  e8 1f fe ff ff     callq  400710 <shr2@plt>
  4008f1:  89 05 9d 07 20 00  mov    %eax,0x20079d(%rip)  # 601094 <g>
...
a "recommended breakpoint location":
...
  [0x00000287]  Special opcode 187: advance Address by 13 to 0x4008f1 and \
    Line by 0 to 41
...
so when stepping out of shr2, gdb steps back onto line 41, the line containing
the call to shr2.

Fix this by detecting this situation and adding an extra step to reach
line 42.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-06  Tom de Vries  <tdevries@suse.de>

* gdb.base/shlib-call.exp: Add extra step to reach shmain.c:42, if
necessary.

4 years ago[gdb/testsuite] Fix gdb_unbuffer_output return-type
Tom de Vries [Wed, 6 May 2020 07:41:26 +0000 (09:41 +0200)]
[gdb/testsuite] Fix gdb_unbuffer_output return-type

When running test-case gdb.base/shlib-call.exp with clang, we get:
...
gdb compile failed, In file included from shmain.c:6:
unbuffer_output.c:39:1: warning:
      control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
...

Fix this by changing the return-type to void.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-06  Tom de Vries  <tdevries@suse.de>

* lib/unbuffer_output.c (gdb_unbuffer_output): Change return type to
void.

4 years ago[gdb/testsuite] Fix gdb.base/consecutive.exp with gcc-8
Tom de Vries [Wed, 6 May 2020 05:07:47 +0000 (07:07 +0200)]
[gdb/testsuite] Fix gdb.base/consecutive.exp with gcc-8

When running test-case gdb.base/consecutive.exp with gcc-8 instead of gcc-7,
we get:
...
 (gdb) step^M
 ^M
-Breakpoint 3, 0x00000000004004b1 in foo () at consecutive.c:10^M
+Breakpoint 3, foo () at consecutive.c:10^M
 10        return a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6];^M
-(gdb) PASS: gdb.base/consecutive.exp: stopped at bp, 2nd instr
+(gdb) FAIL: gdb.base/consecutive.exp: stopped at bp, 2nd instr
...

This is due to the fact that gcc-8 generates more precise line info, making
the breakpoint address a "recommended breakpoint location", and consequently
gdb doesn't print the address prefix anymore.

Fix the FAIL by checking in the test-case whether the breakpoint address is at
"recommended breakpoint location" or not.

gdb/testsuite/ChangeLog:

2020-05-06  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (is_stmt_addresses, hex_in_list): New proc, factored out
of ...
* gdb.base/async.exp: ... here.
* gdb.base/consecutive.exp: Handle if 2nd breakpoint is at a
"recommended breakpoint location".

4 years ago[gdb/testsuite] Compile compile-ifunc.c with -Wno-attribute-alias
Tom de Vries [Wed, 6 May 2020 03:27:48 +0000 (05:27 +0200)]
[gdb/testsuite] Compile compile-ifunc.c with -Wno-attribute-alias

Consider the following test-case:
...
$ cat 1.c
typedef int (*final_t) (int arg);
int final (int arg)
  { return arg + 1; }
final_t gnu_ifunc (void)
  { return final; }
int gnu_ifunc_alias (int) __attribute__ ((ifunc ("gnu_ifunc")));
int main (void)
  { return gnu_ifunc_alias (10); }
...
with result:
...
$ gcc 1.c
$ ./a.out; echo $?
11
...

The test-case uses the ifunc attribute, but there's another solution using
%gnu_indirect_function.  Consider 2.c and 3.c:
...
$ cat 2.c
typedef int (*final_t) (int arg);
int final (int arg)
  { return arg + 1; }
asm (".type gnu_ifunc, %gnu_indirect_function");
final_t gnu_ifunc (void)
  { return final; }
$ cat 3.c
extern int gnu_ifunc (int);
int main (void)
  { return gnu_ifunc (10); }
...

However, it can be inconvenient to have seperate files for the incompatible
decls of gnu_ifunc, so we can use this in a single file like this:
...
$ cat 4.c
typedef int (*final_t) (int arg);
int final (int arg)
  { return arg + 1; }
asm (".type gnu_ifunc, %gnu_indirect_function");
final_t gnu_ifunc (void)
  { return final; }
extern int gnu_ifunc_alias (int arg) __attribute__ ((alias ("gnu_ifunc")));
int main (void)
  { return gnu_ifunc_alias (10); }
...

This alias trick works ok at -O0, but not at -O2:
...
$ gcc 4.c
$ ./a.out; echo $?
11
$ gcc 4.c
$ ./a.out; echo $?
176
...
and produces a warning with gcc-8 and later:
...
$ gcc-8 4.c
4.c:7:12: warning: 'gnu_ifunc_alias' alias between functions of incompatible \
  types 'int(int)' and 'int (*(void))(int)' [-Wattribute-alias]
 extern int gnu_ifunc_alias (int arg) __attribute__ ((alias ("gnu_ifunc")));
            ^~~~~~~~~~~~~~~
4.c:5:9: note: aliased declaration here
 final_t gnu_ifunc (void)
         ^~~~~~~~~
...
The warning is correct, but the mismatch is intentional.

The last variant (%gnu_indirect_function + alias) is used in
gdb.compile/compile-ifunc.c, so we run into the warning with recent gcc.

Fix the warning by compiling with -Wno-attribute-alias.

Tested the test-case on x86_64-linux with gcc-10, and observed I no longer see
the warning:
...
Running src/gdb/testsuite/gdb.compile/compile-ifunc.exp ...

                === gdb Summary ===

nr of untested testcases         1
...

gdb/testsuite/ChangeLog:

2020-05-06  Tom de Vries  <tdevries@suse.de>

* gdb.compile/compile-ifunc.exp: Use -Wno-attribute-alias.

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 6 May 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb: remove main_type::flag_incomplete
Simon Marchi [Tue, 5 May 2020 20:59:32 +0000 (16:59 -0400)]
gdb: remove main_type::flag_incomplete

It is unused.  The corresponding macro was removed in c3236f84c17 ("gdb:
remove TYPE_INCOMPLETE").

gdb/ChangeLog:

* gdbtypes.h (struct main_type) <flag_incomplete>: Remove.

4 years agoMention the NetBSD support in "info proc" documentation
Kamil Rytarowski [Tue, 5 May 2020 13:48:17 +0000 (15:48 +0200)]
Mention the NetBSD support in "info proc" documentation

gdb/doc/ChangeLog:

        * gdb.texinfo (info proc, info proc cmdline, info proc cwd)
        (info proc exe, info proc mappings, info proc stat): Mention
        NetBSD support.

4 years agoRestore readelf's warnings that describe real problems with the file being examined...
Nick Clifton [Tue, 5 May 2020 15:16:03 +0000 (16:16 +0100)]
Restore readelf's warnings that describe real problems with the file being examined.  Fix bug displaying empty file name tables.

binutils* dwarf.c (do_checks): New global variable.
(display_formatted_table): Warn about an unexpected number of
columns in the table, if checks are enabled.  Do not complain
about the lack of data following the number of entries in the
table if the table is empty.
(display_debug_lines_decoded): Only warn about an unexpected
number of columns in a table if checks are enabled.
* dwarf.h (do_checks): Add a prototype.
* elfcomm.c (error): Remove weak attribute.
(warn): Likewise.
* readelf.c (do_checks): Delete.
(warn): Delete.
(process_section_headers): Only warn about empty sections if
checks are enabled.

gas * dwarf2dbg.c (out_dir_and_file_list): Add comments describing the
construction of a DWARF-5 directory name table.
* testsuite/gas/elf/pr25917.d: Update expected output.

4 years ago[GAS] change of ELF flags initial value in rx-linux
Gunther Nikl [Tue, 5 May 2020 09:19:41 +0000 (10:19 +0100)]
[GAS] change of ELF flags initial value in rx-linux

* config/tc-rx.c (elf_flags): Initialize for non-linux targets.
(md_parse_option): Remove initialization of elf_flags.

4 years agogdb: remove TYPE_INCOMPLETE
Simon Marchi [Tue, 5 May 2020 02:39:38 +0000 (22:39 -0400)]
gdb: remove TYPE_INCOMPLETE

The "HP platforms" comment prompted me to check if this was still used
somewhere.  Apparently it's not, so remove it.

gdb/ChangeLog:

* gdbtypes.h (TYPE_INCOMPLETE): Remove.
* gdbtypes.c (recursive_dump_type): Remove use of
TYPE_INCOMPLETE.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 5 May 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years ago[PATCH] objcopy: Allow --dump-section to dump an empty SEC_HAS_CONTENTS section
Fangrui Song [Mon, 4 May 2020 16:04:25 +0000 (17:04 +0100)]
[PATCH] objcopy: Allow --dump-section to dump an empty SEC_HAS_CONTENTS section

* objcopy.c (copy_object): Allow empty section.
* testsuite/binutils-all/update-section.exp: Add test.

4 years ago[PATCH] bfd: tweak SET_ARCH_MACH of aout-cris.c
Gunther Nikl [Mon, 4 May 2020 15:07:26 +0000 (16:07 +0100)]
[PATCH] bfd: tweak SET_ARCH_MACH of aout-cris.c

* aout-cris.c (DEFAULT_ARCH): Delete define.
(MY_set_arch_mach): Likewise.
(SET_ARCH_MACH): Use bfd_set_arch_mach with an explicit architecture
of bfd_arch_cris.
(swap_ext_reloc_in): Add casts to r_index extraction. Mask valid bits
of r_type before the shift.

4 years ago[binutils-gdb][ld][AArch64] Fix group_sections algorithm
Wilco Dijkstra [Mon, 4 May 2020 14:51:56 +0000 (15:51 +0100)]
[binutils-gdb][ld][AArch64] Fix group_sections algorithm

PR ld/25665
* bfd/elfnn-aarch64.c (group_sections): Copy implementation
from elf32-arm.c.
* testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
* testsuite/ld-aarch64/farcall-group.s: New large group test.
* testsuite/ld-aarch64/farcall-group.d: Likewise.

4 years agoGAS: Do not create an entry for the default directory if the directory table is empty...
Nick Clifton [Mon, 4 May 2020 12:50:05 +0000 (13:50 +0100)]
GAS: Do not create an entry for the default directory if the directory table is empty.  Improve readelf's decoding of empty directory and file name tables.

PR 25917
* dwarf.c (display_debug_lines_decoded): Warn if encountering a
supicious number of entries for DWARF-5 format directory and file
name tables.  Do not display file name table header if the table
is empty.  Do not allocate space for empty tables.

4 years agogas: PR 25863: Fix scalar vmul inside it block when assembling for MVE
Andre Simoes Dias Vieira [Mon, 4 May 2020 12:05:42 +0000 (13:05 +0100)]
gas: PR 25863: Fix scalar vmul inside it block when assembling for MVE

This fixes PR 25863 by fixing the condition in the parsing of vmul in
do_mve_vmull.  It also simplifies the code in there fixing latent issues that
would lead to NEON code being accepted when it shouldn't.

gas/ChangeLog:
2020-05-04  Andre Vieira  <andre.simoesdiasvieira@arm.com>

PR gas/25863
* config/tc-arm.c (do_mve_vmull): Fix scalar and NEON parsing of vmul.
* testsuite/gas/arm/mve-scalar-vmult-it.d: New test.
* testsuite/gas/arm/mve-scalar-vmult-it.s: New test.

4 years agoFix an illegal memory access in the assembler when generating a DWARF5 file/directory...
Nick Clifton [Mon, 4 May 2020 09:19:38 +0000 (10:19 +0100)]
Fix an illegal memory access in the assembler when generating a DWARF5 file/directory table with no entries.

PR 25917
* dwarf2dbg.c (out_dir_and_file_list): Check for the directory
table's existence before looking at its entries.
* testsuite/gas/elf/pr25917.s: New test source file.
* testsuite/gas/elf/pr25917.d: New test driver.
* testsuite/gas/elf/elf.exp (run_elf_list_test): Run the new test.

4 years ago[gdb/testsuite] Fix gdb.base/async.exp with gcc-8
Tom de Vries [Mon, 4 May 2020 06:40:38 +0000 (08:40 +0200)]
[gdb/testsuite] Fix gdb.base/async.exp with gcc-8

When running test-case gdb.base/async.exp with gcc-8, we run into:
...
FAIL: gdb.base/async.exp: stepi&
...

The problem is that with gcc-8, the instruction address is no longer printed:
...
 stepi&
-(gdb) 0x00000000004004b2       9        x = 5; x = 5; x = 5;
+(gdb) 9         x = 5; x = 5; x = 5;
 completed.
-PASS: gdb.base/async.exp: stepi&
+FAIL: gdb.base/async.exp: stepi&
...

This is due to the fact that gcc-8 contains more precise line info, making the
address being stepped to a "recommended breakpoint location", and consequently
gdb doesn't print the address prefix anymore.

Given that:
- we step through statements on the same line, and
- there's no addres prefix anymore,
this gives the impression of lack of progress, which could be improved upon,
filed as enhancement PR25911 - "Show column when stepping through line".

Fix the FAIL by checking in the test-case whether addresses are at
"recommended breakpoint location" or not.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-04  Tom de Vries  <tdevries@suse.de>

* gdb.base/async.exp: Check whether instruction addresses are a
"recommended breakpoint location".

4 years agoreadelf: nds32 specific decoding
Alan Modra [Mon, 4 May 2020 00:50:54 +0000 (10:20 +0930)]
readelf: nds32 specific decoding

* readelf.c (process_nds32_specific): Check size of .nds32_e_flags
section.  Don't assume endian of host matches nds32 target.  Free
buffer.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 4 May 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoUpdate more calls to add_prefix_cmd
Tom Tromey [Sun, 3 May 2020 17:31:19 +0000 (11:31 -0600)]
Update more calls to add_prefix_cmd

I looked at all the calls to add_prefix_cmd, and replaced them with
calls to add_basic_prefix_cmd or add_show_prefix_cmd when appropriate.
This makes gdb's command language a bit more regular.  I don't think
there's a significant downside.

Note that this patch removes a couple of tests.  The removed ones are
completely redundant.

gdb/ChangeLog
2020-05-03  Tom Tromey  <tom@tromey.com>

* breakpoint.c (catch_command, tcatch_command): Remove.
(_initialize_breakpoint): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(set_breakpoint_cmd, show_breakpoint_cmd): Remove
* utils.c (set_internal_problem_cmd, show_internal_problem_cmd):
Remove.
(add_internal_problem_command): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* mips-tdep.c (set_mipsfpu_command): Remove.
(_initialize_mips_tdep): Use add_basic_prefix_cmd.
* dwarf2/index-cache.c (set_index_cache_command): Remove.
(_initialize_index_cache): Use add_basic_prefix_cmd.
* memattr.c (dummy_cmd): Remove.
(_initialize_mem): Use add_basic_prefix_cmd, add_show_prefix_cmd.
* tui/tui-win.c (set_tui_cmd, show_tui_cmd): Remove.
(_initialize_tui_win): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* cli/cli-logging.c (set_logging_command): Remove.
(_initialize_cli_logging): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(show_logging_command): Remove.
* target.c (target_command): Remove.
(add_target): Use add_basic_prefix_cmd.

gdb/testsuite/ChangeLog
2020-05-03  Tom Tromey  <tom@tromey.com>

* gdb.base/sepdebug.exp: Remove "catch" test.
* gdb.base/break.exp: Remove "catch" test.
* gdb.base/default.exp: Update expected output.

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 3 May 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogold: Compile common tests with -fcommon
H.J. Lu [Sat, 2 May 2020 13:18:16 +0000 (06:18 -0700)]
gold: Compile common tests with -fcommon

Since GCC 10 defaults to -fno-common, add -fcommon to common tests to
force common behavior.

PR gold/25904
* testsuite/Makefile.am (COMMON_TEST_C_CFLAGS): New.
(common_test_1.o): New rule.
(common_test_2.o): Likewise.
(common_test_3.o): Likewise.
(plugin_common_test_1.o): Likewise.
(plugin_common_test_2.o): Likewise.
(common_test_1_v1.o): Likewise.
(common_test_1_v2.o): Likewise.
(common_test_2_pic.o): Compile with $(COMMON_TEST_C_CFLAGS).
(common_test_3_pic.o): Likewise.
* testsuite/Makefile.in: Regenerated.

4 years agoFix typo in comment of DYN_PROP_ASSOCIATED
Hannes Domani [Fri, 1 May 2020 12:50:08 +0000 (14:50 +0200)]
Fix typo in comment of DYN_PROP_ASSOCIATED

gdb/ChangeLog:

2020-05-02  Hannes Domani  <ssbssa@yahoo.de>

* gdbtypes.h (enum dynamic_prop_node_kind): Fix typo.

4 years agogdb: Fix formatting error in ChangeLog
Andrew Burgess [Sat, 2 May 2020 09:28:56 +0000 (10:28 +0100)]
gdb: Fix formatting error in ChangeLog

4 years ago[gdb/testsuite] Fix i386-mpx.exp compilation warnings
Tom de Vries [Sat, 2 May 2020 08:56:48 +0000 (10:56 +0200)]
[gdb/testsuite] Fix i386-mpx.exp compilation warnings

When running test-case gdb.arch/i386-mpx.exp with gcc-10, we get:
...
Running src/gdb/testsuite/gdb.arch/i386-mpx.exp ...
gdb compile failed, xgcc: warning: switch '-mmpx' is no longer supported
xgcc: warning: switch '-fcheck-pointer-bounds' is no longer supported
...

The test-case uses a combination of options, -mmpx and -fcheck-pointer-bounds.

The -fcheck-pointer-bounds option requires the -mmpx option:
...
$ gcc -fcheck-pointer-bounds ~/hello.c
hello.c:1:0: warning: Pointer Checker requires MPX support on this target. \
  Use -mmpx options to enable MPX.
 #include <stdio.h>

cc1: error: â€˜-fcheck-pointer-bounds’ is not supported for this target
...

Both options is no longer supported in gcc-9.

Fix the warnings by testing if the option combination is supported.

Tested on x86_64-linux, with gcc-7.5.0 and gcc-10.0.1.

gdb/testsuite/ChangeLog:

2020-05-02  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (supports_mpx_check_pointer_bounds): New proc.
* gdb.arch/i386-mpx-call.exp: Use supports_mpx_check_pointer_bounds.
* gdb.arch/i386-mpx-map.exp: Same.
* gdb.arch/i386-mpx-sigsegv.exp: Same.
* gdb.arch/i386-mpx-simple_segv.exp: Same.
* gdb.arch/i386-mpx.exp: Same.

4 years ago[gdb/testsuite] Update psym-external-decl.exp for gcc-10/clang
Tom de Vries [Sat, 2 May 2020 07:50:50 +0000 (09:50 +0200)]
[gdb/testsuite] Update psym-external-decl.exp for gcc-10/clang

When running test-case gdb.base/psym-external-decl.exp with gcc-10, we have:
...
(gdb) print aaa^M
'aaa' has unknown type; cast it to its declared type^M
(gdb) FAIL: gdb.base/psym-external-decl.exp: print aaa
...

With an an earlier version, gcc still emits the debug info for the
declaration of aaa:
...
 <0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <d8>   DW_AT_name        : psym-external-decl.c
 <1><f4>: Abbrev Number: 2 (DW_TAG_variable)
    <f5>   DW_AT_name        : aaa
    <ff>   DW_AT_external    : 1
    <ff>   DW_AT_declaration : 1
...
but with gcc-10 that's no longer the case.

Fix the test-case by adding a use of aaa in psym-external-decl.c.

That still doesn't work for clang, so skip test in that case.

Tested with x86_64-linux, with gcc 7.5.0, gcc 10.0.0 and clang 5.0.2.

Also tested by reverting corresponding fix and ensuring test-case still
fails.

gdb/testsuite/ChangeLog:

2020-05-02  Tom de Vries  <tdevries@suse.de>

* gdb.base/psym-external-decl.c (main): Add use of variable aaa.

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 2 May 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogold: x86-64: Fix TLSDESC relaxation for x32
H.J. Lu [Fri, 1 May 2020 17:11:06 +0000 (10:11 -0700)]
gold: x86-64: Fix TLSDESC relaxation for x32

X32 TLSDESC sequences can be:

40 8d 05 00 00 00 00 rex lea foo@TLSDESC(%rip), %reg
...
67 ff 10 call *foo@TLSCALL(%eax)

or the same sequence as LP64:

48 8d 05 00 00 00 00 lea foo@TLSDESC(%rip), %reg
...
ff 10 call *foo@TLSCALL(%rax)

We need to support both sequences for x32.  For both GDesc -> IE/LE
transitions,

67 ff 10 call *foo@TLSCALL(%eax)

should relaxed to

0f 1f 00 nopl (%rax)

For GDesc -> LE transition,

40 8d 05 00 00 00 00 rex lea foo@TLSDESC(%rip), %reg

should relaxed to

40 c7 c0 fc ff ff ff rex movl $foo@tpoff, %reg

For GDesc -> IE transition,

40 8d 05 00 00 00 00 rex lea foo@TLSDESC(%rip), %reg

should relaxed to

40 8b 05 00 00 00 00 rex movl foo@gottpoff(%rip), %eax

PR gold/25426
* x86_64.cc (Target_x86_64<size>::Relocate::tls_desc_gd_to_ie):
For x32, relax "rex leal foo@tlsdesc(%rip), %reg" to
"rex movl foo@gottpoff(%rip), %eax" and relax ""call *(%eax)"
to "nopl (%rax)".
(Target_x86_64<size>::Relocate::tls_desc_gd_to_le): For x32,
relax "rex leal foo@tlsdesc(%rip), %reg" to
"rex movl foo@tpoff, %eax" and relax "call *foo@tlscall(%eax)"
to "nopl (%rax)".
* testsuite/Makefile.am (tls_test_gnu2.o): Depend on
gcctestdir/as.
(tls_test_file2_gnu2.o): Likewise.
(tls_test_c_gnu2.o): Likewise.
* testsuite/Makefile.in: Regenerated.

4 years agogold: x86-64: Fix TLSDESC -> LE relaxation
H.J. Lu [Fri, 1 May 2020 17:08:31 +0000 (10:08 -0700)]
gold: x86-64: Fix TLSDESC -> LE relaxation

X86-64 TLSDESC sequences can be:

4c 8d 0d 00 00 00 00 leaq foo@TLSDESC(%rip), %r9
4c 89 c8 movq %r9, %rax
ff 10 call *foo@TLSCALL(%rax)

TLSDESC -> LE relaxation can turn them into:

49 c7 c1 fc ff ff ff  mov    $0xfffffffffffffffc,%r9
4c 89 c8              mov    %r9,%rax
66 90                 xchg   %ax,%ax

We need to check and update the REX byte in this case.

PR gold/25473
* x86_64.cc (Target_x86_64<size>::Relocate::tls_desc_gd_to_ie):
Properly check r8 - r15 in "lea foo@TLSDESC(%rip), %reg".
(Target_x86_64<size>::Relocate::tls_desc_gd_to_le): Properly
relax r8 - r15 in "lea foo@TLSDESC(%rip), %reg".
* testsuite/Makefile.am (check_SCRIPTS): Add x86_64_gd_to_le.sh.
(check_DATA): Add x86_64_gd_to_le.stdout.
(MOSTLYCLEANFILES): Add x86_64_gd_to_le.
(x86_64_gd_to_le.o): New target.
(x86_64_gd_to_le): Likewise.
(x86_64_gd_to_le.stdout): Likewise.
* testsuite/Makefile.in: Regenerated.
* testsuite/x86_64_gd_to_le.s: New file.
* testsuite/x86_64_gd_to_le.sh: Likewise.

4 years agogold: Make Ordering::operator() even more complex
H.J. Lu [Fri, 1 May 2020 17:06:15 +0000 (10:06 -0700)]
gold: Make Ordering::operator() even more complex

GCC 9 generates the same function size for Ordering::operator() in
odr_violation1.cc and odr_violation2.cc on x32:

  134: 00000000    31 FUNC    WEAK   DEFAULT   64 _ZN8OrderingclEii
   40: 00000000    31 FUNC    GLOBAL DEFAULT   10 _ZN8OrderingclEii

This patch makes Ordering::operator() even more complex

   134: 00000000    31 FUNC    WEAK   DEFAULT   64 _ZN8OrderingclEii
    42: 00000000    35 FUNC    GLOBAL DEFAULT   11 _ZN8OrderingclEii

* testsuite/odr_violation2.cc (Ordering::operator()): Make
expression even more complex.

4 years agogold: Update ver_test_pr16504.sh
H.J. Lu [Fri, 1 May 2020 16:05:01 +0000 (09:05 -0700)]
gold: Update ver_test_pr16504.sh

commit df3a023bd614133fe69afb02cd0e8f3e590a36a9
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Jul 23 17:54:42 2019 +0930

    SHF_GNU_MBIND requires ELFOSABI_GNU

changed readelf to print IFUNC only for ELFOSABI_GNU.  Since

$ readelf -h ver_test_pr16504.so
...
 OS/ABI:                            UNIX - System V
...

we get

$ readelf -sW ver_test_pr16504.so
...
     3: 0000000000000378    13 <OS specific>: 10 GLOBAL DEFAULT    9 foo@@VER1
...

Update ver_test_pr16504.sh to also accept "<OS specific>: 10".

* testsuite/ver_test_pr16504.sh: Updated.

4 years agogold: Increment plt_offset after setting TLSDESC PLT entry
H.J. Lu [Fri, 1 May 2020 16:00:14 +0000 (09:00 -0700)]
gold: Increment plt_offset after setting TLSDESC PLT entry

Increment plt_offset after setting the reserved TLSDESC PLT entry.

PR gold/25872
* x86_64.cc (Output_data_plt_x86_64_bnd::do_write): Increment
plt_offset after setting the reserved TLSDESC PLT entry.
(Output_data_plt_x86_64_ibt<size>::do_write): Likewise.

4 years agogold: Handle local IFUNC symbol for APLT
H.J. Lu [Fri, 1 May 2020 15:53:47 +0000 (08:53 -0700)]
gold: Handle local IFUNC symbol for APLT

Handle local IFUNC symbol for APLT like global IFUNC symbol.

PR gold/25872
* x86_64.cc (Output_data_plt_x86_64_bnd::do_address_for_local):
Handle local IFUNC symbol.
(Output_data_plt_x86_64_ibt::do_address_for_local): Likewise.

4 years ago[gdb/testsuite] Fix gdb.ada/operator_bp.exp breakpoint location FAILs
Tom de Vries [Fri, 1 May 2020 15:57:56 +0000 (17:57 +0200)]
[gdb/testsuite] Fix gdb.ada/operator_bp.exp breakpoint location FAILs

When running test-case gdb.ada/operator_bp.exp with gcc-10, I run into:
...
FAIL: gdb.ada/operator_bp.exp: break "+"
FAIL: gdb.ada/operator_bp.exp: break "-"
FAIL: gdb.ada/operator_bp.exp: break "<"
FAIL: gdb.ada/operator_bp.exp: break "<="
FAIL: gdb.ada/operator_bp.exp: break ">"
FAIL: gdb.ada/operator_bp.exp: break ">="
FAIL: gdb.ada/operator_bp.exp: break "="
FAIL: gdb.ada/operator_bp.exp: break "and"
FAIL: gdb.ada/operator_bp.exp: break "or"
FAIL: gdb.ada/operator_bp.exp: break "xor"
FAIL: gdb.ada/operator_bp.exp: break "not"
...

The first FAIL is because two breakpoint locations are expected, but there are
more than 2:
...
(gdb) break "+"
Breakpoint 2 at 0x402c3c: "+". (6 locations)
(gdb) info break
Num     Type           Disp Enb Address            What
2       breakpoint     keep y   <MULTIPLE>
2.1                         y   0x0000000000402c3c in ops."+"
                                                   at operator_bp/ops.adb:25
2.2                         y   0x0000000000402e5b in ops."+"
                                                   at operator_bp/ops.adb:119
2.3                         y   0x0000000000414207 in
  system.storage_elements."+" at s-stoele.adb:82
2.4                         y   0x0000000000414404 in
  system.storage_elements."+" at s-stoele.adb:87
2.5                         y   0x0000000000414413 in
  system.storage_elements."+" at s-stoele.adb:87
2.6                         y   0x0000000000414430 in
  system.storage_elements."+" at s-stoele.adb:81
...

This can be traced back to a extra debug info in the executable:
...
$ readelf -w ops_test | grep system__storage_elements__Oadd
    <28104>   DW_AT_name        : system__storage_elements__Oadd__2
    <2812e>   DW_AT_name        : system__storage_elements__Oadd
...

Fix the FAILs by allowing more than the required amount of breakpoint
locations.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-01  Tom de Vries  <tdevries@suse.de>

* gdb.ada/operator_bp.exp: Allow more than required amount of
breakpoint.

4 years agoRemove gdb-gdb.gdb breakpoint on disappeared function info_command.
Philippe Waroquiers [Fri, 1 May 2020 14:47:05 +0000 (16:47 +0200)]
Remove gdb-gdb.gdb breakpoint on disappeared function info_command.

The function info_command has disappeared, so this breakpoint does not
work anymore.
"info_command" was a function for the prefix command "info",
giving the list of "info" subcommands.
It is not very clear what the removed breakpoint and its associated
command list was supposed to do.

Removed and pushed as obvious, after discussion with Tom.

4 years agoFix size recalculation of fortran arrays
Hannes Domani [Fri, 1 May 2020 12:01:02 +0000 (14:01 +0200)]
Fix size recalculation of fortran arrays

My recent change regarding size calculation of arrays of stubbed types
didn't take array strides and associated/allocated type properties into
account, which basically broke fortran arrays.

Fixed by refactoring the array size calculation of
create_array_type_with_stride into a new function, and also use it for
the stubbed array size recalculation.

gdb/ChangeLog:

2020-05-01  Hannes Domani  <ssbssa@yahoo.de>

* gdbtypes.c (update_static_array_size): New function.
(create_array_type_with_stride): Use update_static_array_size.
(check_typedef): Likewise.

4 years ago[gdb/testsuite] Fix Wunused-result warning in until-reverse.c
Tom de Vries [Fri, 1 May 2020 09:04:22 +0000 (11:04 +0200)]
[gdb/testsuite] Fix Wunused-result warning in until-reverse.c

When running test-case gdb.reverse/until-reverse.exp or
gdb.reverse/until-precsave.exp with gcc-10, we run into a Wunused-result
warning:
...
gdb compile failed, gdb.reverse/until-reverse.c: In function 'main':
gdb.reverse/until-reverse.c:40:14: warning: ignoring return value of \
  'malloc' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |       (void) malloc (1);
      |              ^~~~~~~~~~
...

Fix this by using the result of malloc as argument to a free call.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-01  Tom de Vries  <tdevries@suse.de>

* gdb.reverse/until-reverse.c (main): Fix Wunused-result warning.

4 years agoPR25900, RISC-V: null pointer dereference
Alan Modra [Fri, 1 May 2020 06:02:00 +0000 (15:32 +0930)]
PR25900, RISC-V: null pointer dereference

PR 25900
* elfnn-riscv.c (_bfd_riscv_relax_section): Check root.type before
accessing root.u.def of symbols.  Also check root.u.def.section
is non-NULL.  Reverse tests so as to make the logic positive.

4 years agoobjdump: long run time when using -D -z
Alan Modra [Fri, 1 May 2020 06:00:12 +0000 (15:30 +0930)]
objdump: long run time when using -D -z

The zero scan is silly when the result isn't used.

* objdump.c (disassemble_bytes): Don't scan for zeros when
disassembling zeros.  Translate "resuming at file offset" message.
Formatting.  Replace some signed variables with unsigned.

4 years agoPR25882, .gnu.attributes are not checked for shared libraries
Alan Modra [Fri, 1 May 2020 05:53:17 +0000 (15:23 +0930)]
PR25882, .gnu.attributes are not checked for shared libraries

This allows backend merge_private_bfd_data to examine shared library
e_flags and/or .gnu.attributes.  ARM and PowerPC have done so when
using ld.gold for a long time.

(The tic6x change below is dead code due to the earlier FIXME,
but this is probably one of the changes needed there.)

PR 25882
bfd/
* elf32-tic6x.c (elf32_tic6x_merge_attributes): Don't transfer
Tag_ABI_PIC or Tag_ABI_PID from dynamic objects to the output.
ld/
* ldlang.c (lang_check): Call bfd_merge_private_bfd_data for
shared libraries.

4 years agoFIXME for merging of e_flags and .gnu.attributes
Alan Modra [Fri, 1 May 2020 05:50:14 +0000 (15:20 +0930)]
FIXME for merging of e_flags and .gnu.attributes

Code in the linker, present before the addition of .gnu.attributes
support, results in shared libraries not being considered by BFD when
merging e_flags and .gnu.attributes from input files to the output.
That doesn't seem correct to me, but I don't know enough about all the
various ABIs to change the behaviour with any confidence.  So this
patch merely punts on dynamic objects in merge_private_bfd_data target
functions, with a FIXME for maintainer attention.

I haven't excluded shared libraries from being considered where the
target merge_private_bfd_data (a) already has code dealing with shared
libraries, or (b) where that function just sets the output to the most
constraining arch/mach combination and other fairly trivial merges, or
(c) when the target has no shared library linker support.

In (a) are: arc, arm, aarch64, riscv, sparc.
In (b) are: bpf, cris, csky, m32r, m68k, mn10300, nios2, tilegx,
    tilepro, vax, visium, xtensa.
In (c) are: bpf, cr16, h8300, iq2000, m32c, m68hc11, m68hc12, mcore,
    mep, msp430, mt, rl78, rx, v850.

PR 25882
* elf32-bfin.c (elf32_bfin_merge_private_bfd_data): Add FIXME.
* elf32-frv.c (frv_elf_merge_private_bfd_data): Likewise.
* elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Likewise.
* elf32-nds32.c (nds32_elf_merge_private_bfd_data): Likewise.
* elf32-score.c (s3_elf32_score_merge_private_bfd_data): Likewise.
* elf32-score7.c (s7_elf32_score_merge_private_bfd_data): Likewise.
* elf32-sh.c (sh_elf_merge_private_data): Likewise.
* elf32-tic6x.c (elf32_tic6x_merge_attributes): Likewise.
* elf64-ia64-vms.c (elf64_ia64_merge_private_bfd_data): Likewise.
* elfnn-ia64.c (elfNN_ia64_merge_private_bfd_data): Likewise.

4 years agoppc32 merging of e_flags from dynamic objects
Alan Modra [Fri, 1 May 2020 05:47:42 +0000 (15:17 +0930)]
ppc32 merging of e_flags from dynamic objects

EF_PPC_RELOCATABLE and similar flags, if present in an input shared
library, don't have any relevance as far as the output file is
concerned.

Currently, dynamic objects aren't seen in merge_private_bfd_data.
This patch is in preparation for a change to that.

PR 25882
* elf32-ppc.c (ppc_elf_merge_private_bfd_data): Ignore e_flags
from shared libraries.

4 years agoRegen ld BLD-POTFILES.in
Alan Modra [Fri, 1 May 2020 02:19:25 +0000 (11:49 +0930)]
Regen ld BLD-POTFILES.in

* po/BLD-POTFILES.in: Regenerate.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 1 May 2020 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoAdd support for NetBSD thread events (create, exit)
Kamil Rytarowski [Thu, 30 Apr 2020 14:13:33 +0000 (16:13 +0200)]
Add support for NetBSD thread events (create, exit)

Report LWP CREATE and LWP EXIT events and setup this on post_attach()
and post_startup_inferior().

Stop reinitializing the list of recognized threads in update_thread_list().

Handle LWP CREATE and EXIT events in nbsd_nat_target::wait().

gdb/ChangeLog:

        * nbsd-nat.c (nbsd_enable_proc_events)
        (nbsd_nat_target::post_startup_inferior): Add.
        (nbsd_nat_target::post_attach): Call `nbsd_enable_proc_events'.
        (nbsd_nat_target::update_thread_list): Rewrite.
        (nbsd_nat_target::wait): Handle "PTRACE_LWP_EXIT" and
        "PTRACE_LWP_CREATE".
        * nbsd-nat.h (nbsd_nat_target::post_startup_inferior): Add.

4 years agoRevert "2020-04-29 Sterling Augustine <saugustine@google.com>"
Tom de Vries [Thu, 30 Apr 2020 16:51:49 +0000 (18:51 +0200)]
Revert "2020-04-29  Sterling Augustine <saugustine@google.com>"

This reverts commit 84ed7a472551bce1ac58e0eced619433fabc956c.

The problem that the commit attempts to address has already been fixed in
commit 770479f223e "gdb: Fix toplevel types with -fdebug-types-section".

The commit itself is superfluous because it sets list_in_scope at a point that
it's already set (by start_symtab).

4 years agoRemove duplicated creation of "frame" command and "f" alias.
Philippe Waroquiers [Thu, 30 Apr 2020 16:35:33 +0000 (18:35 +0200)]
Remove duplicated creation of "frame" command and "f" alias.

"frame" and "f" are created twice by stack.c _initialize_stack.
Remove the second creation.
Regression tested on amd64/Debian.

2020-04-30  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
* stack.c (_initialize_stack): Remove duplicated creation
of "frame" command and "f" alias.

4 years agoImplement debugging of WOW64 processes in gdbserver
Hannes Domani [Fri, 24 Apr 2020 15:23:59 +0000 (17:23 +0200)]
Implement debugging of WOW64 processes in gdbserver

gdbserver/ChangeLog:

2020-04-30  Hannes Domani  <ssbssa@yahoo.de>

* configure.srv <x86_64-*-mingw*, x86_64-*-cygwin*> (srv_tgtobj):
Add arch/i386.o.
* win32-arm-low.cc (arm_num_regs): New function.
(struct win32_target_ops): Use arm_num_regs.
* win32-i386-low.cc (win32_get_current_dr): Adapt for WOW64
processes.
(i386_get_thread_context): Likewise.
(i386_prepare_to_resume): Likewise.
(i386_thread_added): Likewise.
(i386_single_step): Likewise.
(i386_fetch_inferior_register): Likewise.
(i386_store_inferior_register): Likewise.
(i386_arch_setup): Likewise.
(i386_win32_num_regs): New function.
(struct win32_target_ops): Use i386_win32_num_regs.
* win32-low.cc (win32_get_thread_context): Adapt for WOW64
processes.
(win32_require_context): Likewise.
(child_add_thread): Likewise.
(do_initial_child_stuff): Likewise.
(continue_one_thread): Likewise.
(win32_process_target::resume): Likewise.
(load_psapi): Likewise.
(win32_add_all_dlls): Likewise.
(maybe_adjust_pc): Likewise.
(win32_process_target::qxfer_siginfo): Likewise.
(initialize_low): Likewise.
* win32-low.h (struct win32_target_ops): Change num_regs to
callback function.

4 years agoCalculate size of array of stubbed type
Hannes Domani [Mon, 27 Apr 2020 11:14:24 +0000 (13:14 +0200)]
Calculate size of array of stubbed type

Sizes of stubbed types are calculated on demand in check_typedef, so the
same must also be done for arrays of stubbed types.

A stubbed type is usually a structure that has only been forward declared,
but can also happen if the structure has a virtual function that's not
inline in the class definition.

For these stubbed types, the size must be recalculated once the full
definition is available.

gdb/ChangeLog:

2020-04-30  Hannes Domani  <ssbssa@yahoo.de>

PR gdb/18706
* gdbtypes.c (check_typedef): Calculate size of array of
stubbed type.

gdb/testsuite/ChangeLog:

2020-04-30  Hannes Domani  <ssbssa@yahoo.de>

PR gdb/18706
* gdb.cp/stub-array-size.cc: New test.
* gdb.cp/stub-array-size.exp: New file.
* gdb.cp/stub-array-size.h: New test.
* gdb.cp/stub-array-size2.cc: New test.

4 years agoAdjust array pretty printer tests to the new format
Hannes Domani [Thu, 30 Apr 2020 11:17:30 +0000 (13:17 +0200)]
Adjust array pretty printer tests to the new format

gdb/testsuite/ChangeLog:

2020-04-30  Hannes Domani  <ssbssa@yahoo.de>

* gdb.python/py-format-string.exp: Adjust pretty_arrays expected
output to the new format.

4 years agoAArch64: add GAS support for UDF instruction
Alex Coplan [Thu, 30 Apr 2020 14:47:30 +0000 (15:47 +0100)]
AArch64: add GAS support for UDF instruction

binutils * testsuite/binutils-all/aarch64/in-order-all.d: Update to use new
          disassembly.
        * testsuite/binutils-all/aarch64/out-of-order-all.d: Likewise.

ld/     * testsuite/ld-aarch64/erratum843419_tls_ie.d: Use udf in disassembly.
        * testsuite/ld-aarch64/farcall-b-section.d: Likewise.
        * testsuite/ld-aarch64/farcall-back.d: Likewise.
        * testsuite/ld-aarch64/farcall-bl-section.d: Likewise.

gas/   * config/tc-aarch64.c (fix_insn): Implement for AARCH64_OPND_UNDEFINED.
          (parse_operands): Implement for AARCH64_OPND_UNDEFINED.
        * testsuite/gas/aarch64/udf.s: New.
        * testsuite/gas/aarch64/udf.d: New.
        * testsuite/gas/aarch64/udf-invalid.s: New.
        * testsuite/gas/aarch64/udf-invalid.l: New.
        * testsuite/gas/aarch64/udf-invalid.d: New.

include * opcode/aarch64.h (enum aarch64_opnd): Add AARCH64_OPND_UNDEFINED.

opcodes * aarch64-opc.h (enum aarch64_field_kind): Add FLD_imm16_2.
        * aarch64-opc.c (fields): Add entry for FLD_imm16_2.
          (operand_general_constraint_met_p): validate AARCH64_OPND_UNDEFINED.
        * aarch64-tbl.h (aarch64_opcode_table): Add udf instruction, entry for
          FLD_imm16_2.
        * aarch64-asm-2.c: Regenerated.
        * aarch64-dis-2.c: Regenerated.
        * aarch64-opc-2.c: Regenerated.

4 years agoAdd generic tests for linker support of the -shared or -pie options to tests which...
Nick Clifton [Thu, 30 Apr 2020 12:49:30 +0000 (13:49 +0100)]
Add generic tests for linker support of the -shared or -pie options to tests which use them.

binutils* testsuite/lib/binutils-common.exp (check_pie_support): New
proc.

ld * testsuite/ld-elf/compress1c.d: XFAIL if thet target linker does
not support the -shared command line option.
* /ld-elf/compressed1c.d: Likewise.
* /ld-elf/compressed1e.d: Likewise.
* /ld-elf/dynamic1.d: Likewise.
* /ld-elf/dynsym1.d: Likewise.
* /ld-elf/ehdr_start-shared.d: Likewise.
* /ld-elf/exclude3b.d: Likewise.
* /ld-elf/global1.d: Likewise.
* /ld-elf/hash.d: Likewise.
* /ld-elf/local1.d: Likewise.
* /ld-elf/mbind1b.d: Likewise.
* /ld-elf/now-1.d: Likewise.
* /ld-elf/now-2.d: Likewise.
* /ld-elf/now-3.d: Likewise.
* /ld-elf/now-4.d: Likewise.
* /ld-elf/pr12975.d: Likewise.
* /ld-elf/pr13177.d: Likewise.
* /ld-elf/pr13195.d: Likewise.
* /ld-elf/pr16322.d: Likewise.
* /ld-elf/pr16498a.d: Likewise.
* /ld-elf/pr16498b.d: Likewise.
* /ld-elf/pr17615.d: Likewise.
* /ld-elf/pr19162.d: Likewise.
* /ld-elf/pr19698.d: Likewise.
* /ld-elf/pr20513c.d: Likewise.
* /ld-elf/pr20513d.d: Likewise.
* /ld-elf/pr21389a.d: Likewise.
* /ld-elf/pr21389b.d: Likewise.
* /ld-elf/pr21389c.d: Likewise.
* /ld-elf/pr21562a.d: Likewise.
* /ld-elf/pr21562b.d: Likewise.
* /ld-elf/pr21562c.d: Likewise.
* /ld-elf/pr21562d.d: Likewise.
* /ld-elf/pr21562e.d: Likewise.
* /ld-elf/pr21562f.d: Likewise.
* /ld-elf/pr21562g.d: Likewise.
* /ld-elf/pr21562h.d: Likewise.
* /ld-elf/pr21562i.d: Likewise.
* /ld-elf/pr21562j.d: Likewise.
* /ld-elf/pr21562k.d: Likewise.
* /ld-elf/pr21562l.d: Likewise.
* /ld-elf/pr21562m.d: Likewise.
* /ld-elf/pr21562n.d: Likewise.
* /ld-elf/pr21903a.d: Likewise.
* /ld-elf/pr21903b.d: Likewise.
* /ld-elf/pr22269b.d: Likewise.
* /ld-elf/pr22393-1a.d: Likewise.
* /ld-elf/pr22393-1b.d: Likewise.
* /ld-elf/pr23658-1c.d: Likewise.
* /ld-elf/pr25708.d: Likewise.
* /ld-elf/rpath-1.d: Likewise.
* /ld-elf/rpath-2.d: Likewise.
* /ld-elf/runpath-1.d: Likewise.
* /ld-elf/runpath-2.d: Likewise.
* /ld-elf/sizeofb.d: Likewise.
* /ld-elf/startofb.d: Likewise.
* /ld-elf/strtab.d: Likewise.
* /ld-elf/textaddr2.d: Likewise.
* /ld-elf/textaddr5.d: Likewise.
* /ld-elf/textaddr6.d: Likewise.
* /ld-elf/unknown2.d: Likewise.
* /ld-undefined/entry-3.d: Likewise.
* /ld-undefined/entry-4.d: Likewise.
* /ld-elf/mbind1c.d: XFAIL if the target linker does not support
the -pie option.
* /ld-elf/pie.d: Likewise.
* /ld-elf/pr19539.d: Likewise.
* /ld-elf/pr21903d.d: Likewise.
* /ld-elf/pr22269a.d: Likewise.
* /ld-elf/pr22393-1c.d: Likewise.
* /ld-elf/pr22393-1d.d: Likewise.
* /ld-elf/pr22423.d: Likewise.
* /ld-elf/loadaddr1.d: Expect to fail on the rx-linux target.
* /ld-elf/loadaddr2.d: Likewise.
* /ld-elf/pr22393-1e.d: Likewise.
* /ld-elf/pr22393-1f.d: Likewise.
* /ld-elf/textaddr1.d: Likewise.
* /ld-elf/textaddr4.d: Likewise.

4 years agoUse thiscall calling convention for class members
Hannes Domani [Mon, 27 Apr 2020 13:58:09 +0000 (15:58 +0200)]
Use thiscall calling convention for class members

Non-static member functions for Windows 32bit programs need the thiscall
calling convention, so the 'this' pointer needs to be passed in ECX.

gdb/ChangeLog:

2020-04-30  Hannes Domani  <ssbssa@yahoo.de>

PR gdb/15559
* i386-tdep.c (i386_push_dummy_call): Call
i386_thiscall_push_dummy_call.
(i386_thiscall_push_dummy_call): New function.
* i386-tdep.h (i386_thiscall_push_dummy_call): Declare.
* i386-windows-tdep.c (i386_windows_push_dummy_call): New function.
(i386_windows_init_abi): Call set_gdbarch_push_dummy_call.

4 years agold: Add rx-linux emulation. gas: Change ELF flags initial value in rx-linux
Yoshinori Sato [Thu, 30 Apr 2020 12:35:37 +0000 (13:35 +0100)]
ld: Add rx-linux emulation.  gas: Change ELF flags initial value in rx-linux

ld * emulparams/elf32rx_linux.sh: New rx-linux emulation.
* emultempl/rxlinux.em: New.
* configure.tgt: Add rx-linux.
* Makefile.am: Add eelf32rx_linux.c
* Makefile.in: Regenerate.

gas * config/tc-rx.c (elf_flags): Reset default value.
(md_parse_option): For rx-elf Initialize elf_flags with RX_ABI.

4 years agoxtensa: fix XTENSA_NDIFF handling for PR ld/25861
Max Filippov [Sat, 25 Apr 2020 07:40:25 +0000 (00:40 -0700)]
xtensa: fix XTENSA_NDIFF handling for PR ld/25861

Fields marked with XTENSA_NDIFF relocations are not negated, they only
have sign bits removed. Don't negate their values when relaxation is
performed. Don't add sign bits when the value is zero. Report overflow
when the result has negative sign but all significant bits are zero.

2020-04-29  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (relax_section): Don't negate diff_value for
XTENSA_NDIFF relocations. Don't add sign bits whe diff_value
equals 0. Report overflow when the result has negative sign but
all significant bits are zero.

ld/
* testsuite/ld-xtensa/relax-diff1.d: New test definition.
* testsuite/ld-xtensa/relax-diff1.s: New test source.
* testsuite/ld-xtensa/relax-ndiff.d: New test definition.
* testsuite/ld-xtensa/relax-ndiff.s: New test source.
* testsuite/ld-xtensa/xtensa.exp: (relax-diff1)
(relax-ndiff): New tests.

4 years agoxtensa: gas: support optional immediate simcall parameter
Max Filippov [Tue, 28 Apr 2020 11:15:05 +0000 (04:15 -0700)]
xtensa: gas: support optional immediate simcall parameter

Starting with RH.0 release Xtensa ISA adds immediate parameter to
simcall opcode. For assembly source compatibility treat "simcall"
instruction without parameter as "simcall 0" when parameter is required.

2020-04-29  Max Filippov  <jcmvbkbc@gmail.com>
gas/
* config/tc-xtensa.c (XTENSA_MARCH_EARLIEST): Define macro as 0
if it's not defined.
(microarch_earliest): New static variable.
(xg_translate_idioms): Translate "simcall" to "simcall 0" when
simcall opcode has mandatory parameter.
(xg_init_global_config): Initialize microarch_earliest.

4 years agogdb: silence shellcheck warning SC2162 (use read -r) in gdbarch.sh
Simon Marchi [Thu, 30 Apr 2020 00:35:35 +0000 (20:35 -0400)]
gdb: silence shellcheck warning SC2162 (use read -r) in gdbarch.sh

shellcheck reports:

    In gdbarch.sh line 53:
        while IFS='' read line
                     ^--^ SC2162: read without -r will mangle backslashes.

See the rationale at [1].  In our case, we actually want the backslashes
to be interpreted and removed.  Silence the warning using a directive.

[1] https://github.com/koalaman/shellcheck/wiki/SC2162

gdb/ChangeLog:

* gdbarch.sh (do_read): Add shellcheck disable directive for
warning SC2162.

4 years agogdb: fix shellcheck warnings SC2154 (referenced but not assigned) in gdbarch.sh
Simon Marchi [Thu, 30 Apr 2020 00:35:35 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2154 (referenced but not assigned) in gdbarch.sh

Fix all instances of this kind of warning:

    In gdbarch.sh line 96:
                    m ) staticdefault="${predefault}" ;;
                                       ^-----------^ SC2154: predefault is referenced but not assigned.

These warnings appear because we are doing something a bit funky when reading
the gdbarch fields.  These variables are not assigned explicitly, but
using some `eval` commands.

I don't think there is so much we can fix about those warnings.  To
silence them, I've changed `${foo}` to `${foo:-}`.  This tells the shell
to substitute with an empty string if `foo` is not defined.  This
retains the current behavior, but the warnings go away.

gdb/ChangeLog:

* gdbarch.sh: Use ${foo:-} where shellcheck would report a
"referenced but not assigned" warning.

4 years agogdb: fix shellcheck warnings SC2034 (unused variable) in gdbarch.sh
Simon Marchi [Thu, 30 Apr 2020 00:35:35 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2034 (unused variable) in gdbarch.sh

shellcheck reports:

    In gdbarch.sh line 139:
                    fallbackdefault="0"
                    ^-------------^ SC2034: fallbackdefault appears unused. Verify use (or export if used externally).

Indeed, the `fallbackdefault` variable appears to be unused, remove the
code that sets it.

gdb/ChangeLog:

* gdbarch.sh: Remove code that sets fallbackdefault.

4 years agogdb: fix shellcheck warnings SC2166 (&& and !! instead of -a and -o) in gdbarch.sh
Simon Marchi [Thu, 30 Apr 2020 00:35:34 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2166 (&& and !! instead of -a and -o) in gdbarch.sh

Fix all warnings of this type:

    In gdbarch.sh line 1238:
        if [ "x${invalid_p}" = "x0" -a -n "${postdefault}" ]
                                    ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.

See the rationale here [1].

[1] https://github.com/koalaman/shellcheck/wiki/SC2166

gdb/ChangeLog:

* gdbarch.sh: Use shell operators && and || instead of
-a and -o.

4 years agogdb: fix shellcheck warnings SC2006 (use $() instead of ``) in gdbarch.sh
Simon Marchi [Thu, 30 Apr 2020 00:35:34 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2006 (use $() instead of ``) in gdbarch.sh

Fix all instances of:

    In gdbarch.sh line 2195:
            printf "            `echo "$function" | sed -e 's/./ /g'`  %s %s)\n" "$returntype" "$function"
                                ^-- SC2006: Use $(...) notation instead of legacy backticked `...`.

    Did you mean:
            printf "            $(echo "$function" | sed -e 's/./ /g')  %s %s)\n" "$returntype" "$function"

See here [1] for the rationale.

[1] https://github.com/koalaman/shellcheck/wiki/SC2006

gdb/ChangeLog:

* gdbarch.sh: Use $(...) instead of `...`.

4 years agogdb: fix shellcheck warnings SC2086 (missing double quotes) in gdbarch.sh
Simon Marchi [Thu, 30 Apr 2020 00:35:34 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2086 (missing double quotes) in gdbarch.sh

Fix all instances of:

    In gdbarch.sh line 31:
        if test ! -r ${file}
                     ^-----^ SC2086: Double quote to prevent globbing and word splitting.

    Did you mean:
        if test ! -r "${file}"

Note that some instances of these are in text that is eval'ed.  I'm
pretty sure that things could go wrong during the eval too, but that's
not something shellcheck can check.

gdb/ChangeLog:

* gdbarch.sh: Use double quotes around variables.

4 years agogdb: fix shellcheck warnings SC2059 (variables in printf format string) in gdbarch.sh
Simon Marchi [Thu, 30 Apr 2020 00:35:33 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2059 (variables in printf format string) in gdbarch.sh

Fix all instances of this:

    In gdbarch.sh line 2182:
                printf "  gdb_assert (!(${invalid_p}));\n"
                       ^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".

... by doing exactly as the message suggests.

The rationale explained here [1] makes sense, if there happens to be a
format specifier in text substituted for the variable, the printf won't
do what we expect.

[1] https://github.com/koalaman/shellcheck/wiki/SC2059

gdb/ChangeLog:

* gdbarch.sh: Use %s with printf, instead of variables in the
format string.

4 years ago2020-04-29 Sterling Augustine <saugustine@google.com>
Sterling Augustine [Tue, 28 Apr 2020 18:17:50 +0000 (11:17 -0700)]
2020-04-29  Sterling Augustine <saugustine@google.com>

       * dwarf2/read.c (setup_type_unit_groups): Set list_in_scope.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 30 Apr 2020 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoSync config and libiberty with GCC
H.J. Lu [Wed, 29 Apr 2020 21:25:36 +0000 (14:25 -0700)]
Sync config and libiberty with GCC

config/

2020-04-29  H.J. Lu  <hongjiu.lu@intel.com>

Sync with GCC
2020-04-28  H.J. Lu  <hongjiu.lu@intel.com>

PR bootstrap/94739
* cet.m4 (GCC_CET_HOST_FLAGS): Add -fcf-protection=none to
-Wl,-z,ibt,-z,shstk.  Check whether -fcf-protection=none
-Wl,-z,ibt,-z,shstk works first.

2020-04-25  H.J. Lu  <hongjiu.lu@intel.com>

PR bootstrap/94739
* cet.m4 (GCC_CET_HOST_FLAGS): New.

2020-04-22  Jakub Jelinek  <jakub@redhat.com>

PR libfortran/94694
PR libfortran/94586
* math.m4 (GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1,
GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2): New.

libiberty/

2020-04-28  H.J. Lu  <hongjiu.lu@intel.com>

PR bootstrap/94739
* configure: Regenerated.

4 years agogdb: fix duplicate test names in gdb.base/break.exp
Simon Marchi [Wed, 29 Apr 2020 20:34:54 +0000 (16:34 -0400)]
gdb: fix duplicate test names in gdb.base/break.exp

These test names are duplicated:

      2 PASS: gdb.base/break.exp: set breakpoint via non-integer convenience variable disallowed
      2 PASS: gdb.base/break.exp: set convenience variable $foo to 81.5

Wrap them with `with_test_prefix`. I've actually wrapped a bit more
tests that are related, I think it helps to give the test names a bit
more context.  The modified test names are:

    -PASS: gdb.base/break.exp: set convenience variable $foo to bp_location11
    -PASS: gdb.base/break.exp: set breakpoint via convenience variable
    -PASS: gdb.base/break.exp: set convenience variable $foo to 81.5
    -PASS: gdb.base/break.exp: set breakpoint via non-integer convenience variable disallowed
    +PASS: gdb.base/break.exp: set line breakpoint via convenience variable: set convenience variable $foo to bp_location11
    +PASS: gdb.base/break.exp: set line breakpoint via convenience variable: break $foo
    +PASS: gdb.base/break.exp: set line breakpoint via convenience variable: set convenience variable $foo to 81.5
    +PASS: gdb.base/break.exp: set line breakpoint via convenience variable: non-integer convenience variable disallowed

    -PASS: gdb.base/break.exp: set $l = 47
    -PASS: gdb.base/break.exp: break break.c:$l
    -PASS: gdb.base/break.exp: set convenience variable $foo to 81.5
    -PASS: gdb.base/break.exp: set breakpoint via non-integer convenience variable disallowed
    +PASS: gdb.base/break.exp: set line:file breakpoint via convenience variable: set $l = 47
    +PASS: gdb.base/break.exp: set line:file breakpoint via convenience variable: break break.c:$l
    +PASS: gdb.base/break.exp: set line:file breakpoint via convenience variable: set convenience variable $foo to 81.5
    +PASS: gdb.base/break.exp: set line:file breakpoint via convenience variable: non-integer convenience variable disallowed

gdb/testsuite/ChangeLog:

* gdb.base/break.exp: Use with_test_prefix.

4 years agoFix Ada crash with .debug_types
Tom Tromey [Wed, 29 Apr 2020 17:16:57 +0000 (11:16 -0600)]
Fix Ada crash with .debug_types

PR ada/25875 concerns a gdb crash when gdb.ada/arr_enum_idx_w_gap.exp
is run using the .debug_types board.

The problem turns out to be caused by weird compiler output.  In this
test, the compiler emits a top-level type that refers to an
enumeration type which is nested in a function.  However, this
function is just a declaration.

This results in gdb calling read_enumeration_type for the enum type,
but process_enumeration_scope is never called, yielding an enum with
no fields.  This causes the crash.

This patch fixes the problem by arranging to create the enum fields in
read_enumeration_type.

Tested on x86-64 Fedora 30.

gdb/ChangeLog
2020-04-29  Tom Tromey  <tromey@adacore.com>

PR ada/25875:
* dwarf2/read.c (update_enumeration_type_from_children): Compute
type fields here.
(read_enumeration_type): Call
update_enumeration_type_from_children later.  Update comments.
(process_enumeration_scope): Don't create type fields.

4 years agoSet NetBSD xml syscall file name to syscalls/netbsd.xml
Kamil Rytarowski [Wed, 29 Apr 2020 13:33:33 +0000 (15:33 +0200)]
Set NetBSD xml syscall file name to syscalls/netbsd.xml

The syscall literal names are not stable on NetBSD and can change
once a syscall is versioned. Thus these names are internal to the
system and in GDB mostly descriptive, not intended to be a stable
interface with fixed names across GDB and NetBSD versions to track
certain syscalls.

gdb/ChangeLog:

* nbsd-tdep.c: Include "xml-syscall.h".
(nbsd_init_abi): Call `set_xml_syscall_file_name'.

4 years agoAdd basic event handling in the NetBSD target
Kamil Rytarowski [Tue, 28 Apr 2020 23:57:38 +0000 (01:57 +0200)]
Add basic event handling in the NetBSD target

Implement the following events:
 - single step (TRAP_TRACE)
 - software breakpoint (TRAP_DBREG)
 - exec() (TRAP_EXEC)
 - syscall entry/exit (TRAP_SCE / TRAP_SCX)

Add support for NetBSD specific ::wait () and ::resume ().

Instruct the generic code that exec and syscall events are supported.

Define an empty nbsd_get_syscall_number as it is prerequisite for
catching syscall entry and exit events, even if it is unused.
This function is used to detect whether the gdbarch supports the
'catch syscall' feature.

gdb/ChangeLog:

       * nbsd-nat.c: Include "sys/wait.h".
       (nbsd_resume, nbsd_nat_target::resume, nbsd_wait)
       (nbsd_nat_target::wait, nbsd_nat_target::insert_exec_catchpoint)
       (nbsd_nat_target::remove_exec_catchpoint)
       (nbsd_nat_target::set_syscall_catchpoint): Add.
       * nbsd-nat.h (nbsd_nat_target::resume, nbsd_nat_target::wait)
       (nbsd_nat_target::insert_exec_catchpoint)
       (nbsd_nat_target::remove_exec_catchpoint)
       (nbsd_nat_target::set_syscall_catchpoint): Add.
       * nbsd-tdep.c (nbsd_get_syscall_number): Add.
       (nbsd_init_abi): Call `set_gdbarch_get_syscall_number' and pass
       `nbsd_get_syscall_number'.

4 years agoWhen displaying ranges, ignore duplicate offsets.
Andrew Burgess [Wed, 29 Apr 2020 16:21:10 +0000 (17:21 +0100)]
When displaying ranges, ignore duplicate offsets.

* dwarf.c (display_debug_ranges): Ignore duplicate entries in
range_entries for the same offset.

4 years agoUpdate expected disassembly after recent update.
Nick Clifton [Wed, 29 Apr 2020 16:18:56 +0000 (17:18 +0100)]
Update expected disassembly after recent update.

PR 22699
* testsuite/gas/sh/sh4al-dsp.d: Update expected disassembly.

4 years agoAlso use unsigned 8-bit immediate values for the LDRC and SETRC insns.
Nick Clifton [Wed, 29 Apr 2020 15:09:38 +0000 (16:09 +0100)]
Also use unsigned 8-bit immediate values for the LDRC and SETRC insns.

PR 22699
* sh-opc.h: Also use unsigned 8-bit immediate values for the LDRC
and SETRC insns.

4 years agoAdd a warning if an emtpty SHT_REL, SHT_RELA or SHT_PROGBITS section is detected...
Nick Clifton [Wed, 29 Apr 2020 15:01:40 +0000 (16:01 +0100)]
Add a warning if an emtpty SHT_REL, SHT_RELA or SHT_PROGBITS section is detected.  Disable all warnings unless the (new) lint mode is enabled.

* readelf.c (warn): New function - like elfcomm.c version but only
produces output if warnings are enabled.
(struct options): Add --lint and --enable-checks.
(usage): Add entry for --lint.
(parse_args): Handle -L.  If checks are enabled but no dumps have
been selected then enable all dumps.
(process_section_headers): Replace long if-then-else sequence with
a switch.  Add warning messages for empty SHT_REL, SHT_RELA and
SHT_PROGBITS sections.
(process_file): Do not complain if the file is an archive and lint
mode has been enabled.
* elfcomm.c (error): Make the function weak.
(warn): Likewise.
* NEWS: Mention the new feature.
* doc/binutils.texi: Document the new feature.
* dwarf.h (report_leb_status): Add file name and line number
parameters.  Include them in the diagnostic output.
(READ_ULEB): Pass file and line number to report_leb_status.
(READ_SLEB): Likewise.
* dwarf.c (read_and_print_leb128): Pass file and line number to
report_leb_status.
* testsuite/binutils-all/readelf.exp: Add test of new feature.
* testsuite/binutils-all/zero-sec.s: New test source file.
* testsuite/binutils-all/zero-sec.r: Expected output from new
test.