Commit Graph

101647 Commits

Author SHA1 Message Date
Simon Marchi 0d4bf01694 gdb: remove main_type::flag_static
It is not used.

gdb/ChangeLog:

	* gdbtypes.h (struct main_type) <flag_static>: Remove.
2020-05-06 12:26:05 -04:00
Simon Marchi ac4a4f1cd7 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.
2020-05-06 12:01:37 -04:00
Nick Clifton bfeaed386d Updated Swedish translation for the gas sub-directory 2020-05-06 14:17:36 +01:00
Tom de Vries 24fe640b4d [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 7c99e7e2b0
"[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.
2020-05-06 14:48:50 +02:00
Tom de Vries 0d8683a321 [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.
2020-05-06 14:27:36 +02:00
Nick Clifton 6ef719c016 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.
2020-05-06 13:21:02 +01:00
Tom de Vries b8983c4663 [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.
2020-05-06 14:13:02 +02:00
Tom de Vries abf6d805a0 [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.
2020-05-06 13:49:34 +02:00
Tom de Vries 0fc2a808cb [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.
2020-05-06 11:50:52 +02:00
Tom de Vries 873dd4273f [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.
2020-05-06 09:41:26 +02:00
Tom de Vries 7c99e7e2b0 [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".
2020-05-06 07:07:47 +02:00
Tom de Vries 6173d6a696 [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.
2020-05-06 05:27:48 +02:00
GDB Administrator 4167d44ce2 Automatic date update in version.in 2020-05-06 00:00:06 +00:00
Simon Marchi a3bbacc120 gdb: remove main_type::flag_incomplete
It is unused.  The corresponding macro was removed in c3236f84c1 ("gdb:
remove TYPE_INCOMPLETE").

gdb/ChangeLog:

	* gdbtypes.h (struct main_type) <flag_incomplete>: Remove.
2020-05-05 16:59:32 -04:00
Kamil Rytarowski aa8509b4ed 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.
2020-05-05 17:41:57 +02:00
Nick Clifton 546cb2d85e 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.
2020-05-05 16:16:03 +01:00
Gunther Nikl 7d0bd48744 [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.
2020-05-05 10:19:41 +01:00
Simon Marchi c3236f84c1 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.
2020-05-04 22:39:39 -04:00
GDB Administrator dc7148375d Automatic date update in version.in 2020-05-05 00:00:06 +00:00
Fangrui Song e052e2ba29 [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.
2020-05-04 17:04:25 +01:00
Gunther Nikl 7242fa8aa7 [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.
2020-05-04 16:07:26 +01:00
Wilco Dijkstra cff69cf4cf [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.
2020-05-04 15:51:56 +01:00
Nick Clifton 070b775f03 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.
2020-05-04 13:50:05 +01:00
Andre Simoes Dias Vieira fe05f369f0 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.
2020-05-04 13:07:45 +01:00
Nick Clifton 4706679dac 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.
2020-05-04 10:19:38 +01:00
Tom de Vries 6015a06749 [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".
2020-05-04 08:40:38 +02:00
Alan Modra 9c7b8e9b92 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.
2020-05-04 11:28:40 +09:30
GDB Administrator c3bf7d31de Automatic date update in version.in 2020-05-04 00:00:06 +00:00
Tom Tromey 3b6acaee89 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.
2020-05-03 11:31:20 -06:00
GDB Administrator c69ad65744 Automatic date update in version.in 2020-05-03 00:00:07 +00:00
H.J. Lu 8c16443418 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.
2020-05-02 06:48:26 -07:00
Hannes Domani a51119cde4 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.
2020-05-02 12:55:51 +02:00
Andrew Burgess 6a6ea76aee gdb: Fix formatting error in ChangeLog 2020-05-02 10:28:56 +01:00
Tom de Vries 5beb4d1771 [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.
2020-05-02 10:56:48 +02:00
Tom de Vries 8caf140db2 [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.
2020-05-02 09:50:50 +02:00
GDB Administrator a4be18526b Automatic date update in version.in 2020-05-02 00:00:07 +00:00
H.J. Lu ccf20d460f 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.
2020-05-01 10:11:23 -07:00
H.J. Lu 6d520e36de 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.
2020-05-01 10:08:48 -07:00
H.J. Lu e10cfd0633 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.
2020-05-01 10:06:31 -07:00
H.J. Lu de6d6067f5 gold: Update ver_test_pr16504.sh
commit df3a023bd6
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.
2020-05-01 09:05:21 -07:00
H.J. Lu 48bc218262 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.
2020-05-01 09:00:27 -07:00
H.J. Lu e977e74712 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.
2020-05-01 08:59:32 -07:00
Tom de Vries 693196cba2 [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.
2020-05-01 17:57:56 +02:00
Philippe Waroquiers 652fc23a30 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.
2020-05-01 16:47:05 +02:00
Hannes Domani 8dbb13755b 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.
2020-05-01 15:32:17 +02:00
Tom de Vries 53ae0aa9c6 [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.
2020-05-01 11:04:22 +02:00
Alan Modra a2714d6cca 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.
2020-05-01 15:32:36 +09:30
Alan Modra 6083233224 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.
2020-05-01 15:32:36 +09:30
Alan Modra a8acd6eeb6 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.
2020-05-01 15:32:36 +09:30
Alan Modra 6b728d3286 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.
2020-05-01 15:32:36 +09:30