H.J. Lu [Tue, 5 Jul 2022 19:45:23 +0000 (12:45 -0700)]
elf: Copy p_align of PT_GNU_STACK for stack alignment
commit
74e315dbfe5200c473b226e937935fb8ce391489
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Dec 13 19:46:04 2021 -0800
elf: Set p_align to the minimum page size if possible
may ignore p_align of PT_GNU_STACK when copying ELF program header if
the maximum page size is larger than p_align of PT_LOAD segments. Copy
p_align of PT_GNU_STACK since p_align of PT_GNU_STACK describes stack
alignment, not page size,
PR binutils/29319
* elf.c (copy_elf_program_header): Copy p_align of PT_GNU_STACK
for stack alignment.
Jan Beulich [Wed, 6 Jul 2022 13:40:04 +0000 (15:40 +0200)]
x86: make D attribute usable for XOP and FMA4 insns
This once again allows to reduce redundancy in (and size of) the opcode
table.
Don't go as far as also making D work on the two 5-operand XOP insns:
This would significantly complicate the code, as there the first
(immediate) operand would need special treatment in several places.
Note that the .s suffix isn't being enabled to have any effect, for
being deprecated. Whereas neither {load} nor {store} pseudo prefixes
make sense here, as the respective operands are inputs (loads) only
anyway, regardless of order. Hence there is (as before) no way for the
programmer to request the alternative encoding to be used for register-
only insns.
Note further that it is always the first original template which is
retained (and altered), to make sure the same encoding as before is
used for register-only insns. This has the slightly odd (but pre-
existing) effect of XOP register-only insns having XOP.W clear, but FMA4
ones having VEX.W set.
Jan Beulich [Wed, 6 Jul 2022 13:39:37 +0000 (15:39 +0200)]
x86: fold two switch() statements in match_template()
I don't see why two of them were introduced (very long ago) using
similar fall-through logic.
Jan Beulich [Wed, 6 Jul 2022 13:39:03 +0000 (15:39 +0200)]
x86: fix 3-operand insn reverse-matching
The middle operand would have gone entirely unchecked, allowing e.g.
vmovss %xmm0, %esp, %xmm2
to assemble successfully, or e.g.
vmovss %xmm0, $4, %xmm2
causing an internal error. Alongside dealing with this also drop a
related comment, which hasn't been applicable anymore since the
introduction of 3-operand patterns with D set (and which perhaps never
had been logical to be there, as reverse-matched insns don't make it
there in the first place).
Bhuvanendra Kumar N [Wed, 6 Jul 2022 10:56:25 +0000 (16:26 +0530)]
Descriptive DWARF operations dump support for DW_AT_rank
DW_AT_rank is a dwarf-5 feature.
Jan Beulich [Wed, 6 Jul 2022 07:22:47 +0000 (09:22 +0200)]
x86: introduce a state stack for .arch
When using just slightly non-trivial combinations of .arch, it can be
quite useful to be able to go back to prior state without needing to
re-invoke perhaps many earlier directives and without needing to invoke
perhaps many "negative" ones. Like some other architectures allow
saving (pushing) and restoring (popping) present/prior state.
For now require the same .code<N> to be in effect for ".arch pop" that
was in effect for the corresponding ".arch push".
Also change the global "no_cond_jump_promotion" to be bool, to match the
new struct field.
Jan Beulich [Wed, 6 Jul 2022 07:22:11 +0000 (09:22 +0200)]
x86: generalize disabling of sub-architectures
I never really understood upon what basis ".arch .no*" options were made
available. Let's not have any "criteria" at all, and simply allow
disabling of all of them. Then we also have all data for a sub-arch in
a single place, as we now only need a single table.
Jan Beulich [Wed, 6 Jul 2022 07:21:40 +0000 (09:21 +0200)]
x86: permit "default" with .arch
So far there was no way to reset the architecture to that assembly would
start with in the absence of any overrides (command line or directives).
Note that for Intel MCU "default" is merely an alias of "iamcu".
While there also zap a stray @item from the doc section, as noticed
when inspecting the generated output (which still has some quirks, but
those aren't easy to address without re-flowing almost the entire
section).
Jan Beulich [Wed, 6 Jul 2022 07:20:29 +0000 (09:20 +0200)]
x86: don't leak sub-architecture accumulated strings
While it may not be necessary in i386_target_format() (but then setting
the variable to NULL also wouldn't be necessary), at least in the other
cases strings may already have accumulated.
GDB Administrator [Wed, 6 Jul 2022 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Tue, 5 Jul 2022 20:41:25 +0000 (22:41 +0200)]
[gdb/exp] Fix internal error when printing C++ pointer-to-member
When running the test-case included with this patch, we run into:
...
(gdb) print ptm^M
$1 = gdb/gdbtypes.h:695: internal-error: loc_bitpos: \
Assertion `m_loc_kind == FIELD_LOC_KIND_BITPOS' failed.^M
...
while printing a c++ pointer-to-member.
Fix this by skipping static fields in cp_find_class_member, such that we have:
...
(gdb) print ptm^M
$1 = &A::i^M
...
Tested on x86_64-linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29294
Tom Tromey [Mon, 20 Jun 2022 18:32:52 +0000 (12:32 -0600)]
Add gdb.Objfile.is_file attribute
Sometimes an objfile comes from memory and not from a file. It can be
useful to be able to check this from Python, so this patch adds a new
"is_file" attribute.
Tom Tromey [Fri, 3 Jun 2022 13:59:49 +0000 (07:59 -0600)]
Make 'import gdb.events' work
Pierre-Marie noticed that, while gdb.events is a Python module, it
can't be imported. This patch changes how this module is created, so
that it can be imported, while also ensuring that the module is always
visible, just as it was in the past.
This new approach required one non-obvious change -- when running
gdb.base/warning.exp, where --data-directory is intentionally not
found, the event registries can now be nullptr. Consequently, this
patch probably also requires
https://sourceware.org/pipermail/gdb-patches/2022-June/189796.html
Note that this patch obsoletes
https://sourceware.org/pipermail/gdb-patches/2022-June/189797.html
Xi Ruoyao [Tue, 5 Jul 2022 11:30:12 +0000 (19:30 +0800)]
gdb: LoongArch: add orig_a0 into register set
The basic support for LoongArch has been merged into the upstream Linux
kernel since 5.19-rc1 on June 5, 2022. This commit adds orig_a0 which
is added into struct user_pt_regs [1] to match the upstream kernel, and
then the upstream GDB will work with the upstream kernel.
Note that orig_a0 was added into struct user_pt_regs in the development
cycle for merging LoongArch port into the upstream Linux kernel, so
earlier kernels (notably, the product kernel with version 4.19 used in
distros like UOS and Loongnix) don't have it. Inspect
arch/loongarch/include/uapi/asm/ptrace.h in the kernel tree to make sure.
To build upstream GDB for a kernel lacking orig_a0, it's necessary to
revert this commit locally.
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/include/uapi/asm/ptrace.h#n24
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Bhuvanendra Kumar N [Tue, 5 Jul 2022 11:23:45 +0000 (16:53 +0530)]
Support for location and range lists for split-dwarf and dwarf-5.
Adding support for location and range lists for split-dwarf and dwarf-5.
Following issues are taken care.
1. Display of the index values for DW_FORM_loclistx and DW_FORM_rnglistx.
2. Display of .debug_loclists.dwo and .debug_rnglists.dwo sections.
* dwarf.c(read_and_display_attr_value): Handle DW_FORM_loclistx
and DW_FORM_rnglistx for .dwo files.
(process_debug_info): Load .debug_loclists.dwo and
.debug_rnglists.dwo if exists.
(load_separate_debug_files): Load .debug_loclists and
.debug_rnglists if exists.
Include 2 entries in debug_displays table.
* dwarf.h (enum dwarf_section_display_enum): Include 2 entries.
Jan Beulich [Tue, 5 Jul 2022 06:40:39 +0000 (08:40 +0200)]
x86: introduce fake processor type to mark sub-arch entries in cpu_arch[]
This is in preparation of dropping the leading . from the strings.
While there also move PROCESSOR_GENERIC{32,64} from the middle of AMD
entries to near the top.
Jan Beulich [Tue, 5 Jul 2022 06:40:09 +0000 (08:40 +0200)]
x86: macro-ize cpu_arch[] entries
Putting individual elements behind macros, besides (imo) improving
readability, will make subsequent (and likely also future) changes less
intrusive.
Utilize this right away to pack the table a little more tightly, by
converting "skip" to bool and putting it earlier in a group of bitfields
together with "len".
Jan Beulich [Tue, 5 Jul 2022 06:39:43 +0000 (08:39 +0200)]
x86: de-duplicate sub-architecture strings accumulation
Introduce a helper function to replace 4 instances of similar code. Use
reconcat() to cover the previously explicit free().
GDB Administrator [Tue, 5 Jul 2022 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Nick Clifton [Mon, 4 Jul 2022 15:28:02 +0000 (16:28 +0100)]
Fix snafu in rust demangler recursion limit code
Alan Modra [Mon, 4 Jul 2022 03:15:47 +0000 (12:45 +0930)]
alloc gas seginfo on notes obstack
Lots of memory used in gas should go on this obstack. The patch also
frees all the gas obstacks on exit, which isn't a completely trivial
task.
* subsegs.c (alloc_seginfo): New function.
(subseg_change, subseg_get): Use it.
(subsegs_end): New function.
* as.h (subsegs_end): Declare.
* output-file.c: Include subsegs.h
(stash_frchain_obs): New function.
(output_file_close): Save obstacks attached to output bfd before
closing. Call subsegs_end with the array of obstacks.
Alan Modra [Mon, 4 Jul 2022 01:54:22 +0000 (11:24 +0930)]
objcopy: bfd_alloc orelocation
This fixes an inconsequential objcopy memory leak. I'd normally
ignore reports of leaks like this one, that are merely one block or
fewer per section processed, since objcopy soon exits and frees all
memory. However I thought it worth providing support for allocating
memory on a bfd objalloc in objcopy and other utils.
PR 29233
* bucomm.c (bfd_xalloc): New function.
* bucomm.h (bfd_xalloc): Declare.
* objcopy.c (copy_relocations_in_section): Use it to allocate
array of reloc pointers. Rewrite code stripping relocs to do
without extra memory allocation.
Nick Clifton [Mon, 4 Jul 2022 12:57:12 +0000 (13:57 +0100)]
Synchronize libbierty sources with gcc.
Bhuvanendra Kumar N [Mon, 4 Jul 2022 10:50:29 +0000 (16:20 +0530)]
Modified changes for split-dwarf and dwarf-5.
* dwarf.c(process_debug_info): Include DW_TAG_skeleton_unit.
(display_debug_str_offsets): While dumping .debug_str_offsets.dwo,
pass proper str_offsets_base to fetch_indexed_string().
(load_separate_debug_files): Skip DWO ID dump for dwarf-5.
Marcus Nilsson [Mon, 4 Jul 2022 10:25:42 +0000 (11:25 +0100)]
opcodes/avr: Implement style support in the disassembler
* disassemble.c: (disassemble_init_for_target): Set
created_styled_output for AVR based targets.
* avr-dis.c: (print_insn_avr): Use fprintf_styled_ftype
instead of fprintf_ftype throughout.
(avr_operand): Pass in and fill disassembler_style when
parsing operands.
Tom de Vries [Mon, 4 Jul 2022 08:28:42 +0000 (10:28 +0200)]
[gdb/symtab] Add get/set functions for per_cu->lang/unit_type
The dwarf2_per_cu_data fields lang and unit_type both have a dont-know
initial value (respectively language_unknown and (dwarf_unit_type)0), which
allows us to add certain checks, f.i. checking that that a field is not read
before written.
Add get/set member functions for the two fields as a convenient location to
add such checks, make the fields private to enforce using the member
functions, and add the m_ prefix.
Tested on x86_64-linux.
Jan Beulich [Mon, 4 Jul 2022 06:42:10 +0000 (08:42 +0200)]
gas/testsuite: properly exclude aout in all/weakref1u
Use the (wider) predicate rather than a triplet. This eliminates the sole
i386-msdos failure in the testsuite.
Jan Beulich [Mon, 4 Jul 2022 06:32:50 +0000 (08:32 +0200)]
x86: fold Disp32S and Disp32
The only case where 64-bit code uses non-sign-extended (can also be
considered zero-extended) displacements is when an address size override
is in place for a memory operand (i.e. particularly excluding
displacements of direct branches, which - if at all - are controlled by
operand size, and then are still sign-extended, just from 16 bits).
Hence the distinction in templates is unnecessary, allowing code to be
simplified in a number of places. The only place where logic becomes
more complicated is when signed-ness of relocations is determined in
output_disp().
The other caveat is that Disp64 cannot be specified anymore in an insn
template at the same time as Disp32. Unlike for non-64-bit mode,
templates don't specify displacements for both possible addressing
modes; the necessary adjustment to the expected ones has already been
done in match_template() anyway (but of course the logic there needs
tweaking now). Hence the single template so far doing so is split.
Jan Beulich [Mon, 4 Jul 2022 06:32:20 +0000 (08:32 +0200)]
x86: restore masking of displacement kinds
Commit
7d5e4556a375 rendered the check near the end of what is now
i386_finalize_displacement() entirely dead for AT&T mode, since for
operands involving a displacement .unspecified will always be set. But
the logic there is bogus anyway - Intel syntax operand size specifiers
are of no interest there either. The only thing which matters in the
"displacement only" determination is .baseindex.
Of course when masking displacement kinds we should not at the same time
also mask off other attributes.
Furthermore the type mask returned by lex_got() also needs to be
adjusted: The only case where we want Disp32 (rather than Disp32S) is
when dealing with 32-bit addressing mode in 64-bit code.
Jan Beulich [Mon, 4 Jul 2022 06:31:21 +0000 (08:31 +0200)]
x86-64: improve handling of branches to absolute addresses
There are two related problems here: The use of "addr32" on a direct
branch would, besides causing a warning, result in operands to be
permitted which mistakenly are refused without "addr32". Plus at some
point not too long ago I'm afraid it may have been me who regressed the
relocation addends emitted for such branches. Correct both problems,
adding a testcase to guard against regressing this again.
Tsukasa OI [Sun, 3 Jul 2022 10:31:23 +0000 (19:31 +0900)]
RISC-V: Update Zihintpause extension version
Because ratified Zihintpause extension has a version number of 2.0
(not 1.0), we should update the number.
bfd/ChangeLog:
* elfxx-riscv.c (riscv_supported_std_z_ext): Update version
number of Zihintpause extension.
GDB Administrator [Mon, 4 Jul 2022 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 3 Jul 2022 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Sat, 2 Jul 2022 11:03:34 +0000 (13:03 +0200)]
[gdb/symtab] Fix data race on per_cu->dwarf_version
When building gdb with -fsanitize=thread and gcc 12, and running test-case
gdb.dwarf2/dwz.exp, we run into a data race between thread T2 and the main
thread in the same write:
...
Write of size 1 at 0x7b200000300c:^M
#0 cutu_reader::cutu_reader(dwarf2_per_cu_data*, dwarf2_per_objfile*, \
abbrev_table*, dwarf2_cu*, bool, abbrev_cache*) gdb/dwarf2/read.c:6252 \
(gdb+0x82f3b3)^M
...
which is here:
...
this_cu->dwarf_version = cu->header.version;
...
Both writes are called from the parallel for in dwarf2_build_psymtabs_hard,
this one directly:
...
#1 process_psymtab_comp_unit gdb/dwarf2/read.c:6774 (gdb+0x8304d7)^M
#2 operator() gdb/dwarf2/read.c:7098 (gdb+0x8317be)^M
#3 operator() gdbsupport/parallel-for.h:163 (gdb+0x872380)^M
...
and this via the PU import:
...
#1 cooked_indexer::ensure_cu_exists(cutu_reader*, dwarf2_per_objfile*, \
sect_offset, bool, bool) gdb/dwarf2/read.c:17964 (gdb+0x85c43b)^M
#2 cooked_indexer::index_imported_unit(cutu_reader*, unsigned char const*, \
abbrev_info const*) gdb/dwarf2/read.c:18248 (gdb+0x85d8ff)^M
#3 cooked_indexer::index_dies(cutu_reader*, unsigned char const*, \
cooked_index_entry const*, bool) gdb/dwarf2/read.c:18302 (gdb+0x85dcdb)^M
#4 cooked_indexer::make_index(cutu_reader*) gdb/dwarf2/read.c:18443 \
(gdb+0x85e68a)^M
#5 process_psymtab_comp_unit gdb/dwarf2/read.c:6812 (gdb+0x830879)^M
#6 operator() gdb/dwarf2/read.c:7098 (gdb+0x8317be)^M
#7 operator() gdbsupport/parallel-for.h:171 (gdb+0x8723e2)^M
...
Fix this by setting the field earlier, in read_comp_units_from_section.
The write in cutu_reader::cutu_reader() is still needed, in case
read_comp_units_from_section is not used (run the test-case with say, target
board cc-with-gdb-index).
Make the write conditional, such that it doesn't trigger if the field is
already set by read_comp_units_from_section. Instead, verify that the
field already has the value that we're trying to set it to.
Move this logic into into a member function set_version (in analogy to the
already present member function version) to make sure it's used consistenly,
and make the field private in order to enforce access through the member
functions, and rename it to m_dwarf_version.
While we're at it, make sure that the version is set before read, to avoid
say returning true for "per_cu.version () < 5" if "per_cu.version () == 0".
Tested on x86_64-linux.
Tom de Vries [Sat, 2 Jul 2022 09:50:03 +0000 (11:50 +0200)]
[gdb/testsuite] Fix gdb.base/early-init-file.exp with -fsanitize=thread
When building gdb with -fsanitize=thread, I run into:
...
FAIL: gdb.base/early-init-file.exp: check startup version string has style \
version
...
due to this:
...
warning: Found custom handler for signal 7 (Bus error) preinstalled.^M
warning: Found custom handler for signal 8 (Floating point exception) \
preinstalled.^M
warning: Found custom handler for signal 11 (Segmentation fault) \
preinstalled.^M
Some signal dispositions inherited from the environment (SIG_DFL/SIG_IGN)^M
won't be propagated to spawned programs.^M
...
appearing before the "GNU gdb (GDB) $version" line.
This is similar to the problem fixed by commit
f0bbba7886f
("gdb.debuginfod/fetch_src_and_symbols.exp: fix when GDB is built with
AddressSanitizer").
In that commit, the problem was fixed by starting gdb with -quiet, but using
that would mean the "GNU gdb (GDB) $version" line that we're trying to check
would disappear.
Fix this instead by updating the regexp to allow the message.
Tested on x86_64-linux.
GDB Administrator [Sat, 2 Jul 2022 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Maciej W. Rozycki [Fri, 1 Jul 2022 16:11:09 +0000 (17:11 +0100)]
GDB/doc: Remove indentation from `print -elements' completion example
Remove indentation from the text of the manual after the example here:
" Completion will in some cases guide you with a suggestion of what
kind of argument an option expects. For example:
(gdb) print -elements <TAB><TAB>
NUMBER unlimited
Here, the option expects a number (e.g., '100'), not literal
'NUMBER'. Such metasyntactical arguments are always presented in
uppercase."
as this is a continuation of the same paragraph.
Maciej W. Rozycki [Fri, 1 Jul 2022 16:11:09 +0000 (17:11 +0100)]
GDB/doc: Remove extraneous spaces from completion examples
Completion results are usually different when the operation is applied
to a word that is or is not followed by a space. In some cases they are
equivalent, however a space would not be produced if completion was used
earlier on in the word processed.
However in the manual we have completion examples given using a space
that actually prevents the example from working. E.g.:
(gdb) info bre <TAB>
(nothing) and:
(gdb) info bre <TAB><TAB>
Display all 200 possibilities? (y or n)
as it now goes on to propose the entire symbol table, while:
(gdb) info bre<TAB>
(gdb) info breakpoints
does the right thing, but is not what is shown in the manual.
In other cases an extraneous space is used that does not correspond to
the actual completion pattern shown, which gives an impression of
sloppiness.
Remove extraneous spaces then from completion examples as appropriate.
Nick Clifton [Fri, 1 Jul 2022 14:08:44 +0000 (15:08 +0100)]
Add newline to the end of the rnglists displsy.
GDB Administrator [Fri, 1 Jul 2022 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in
Maciej W. Rozycki [Thu, 30 Jun 2022 18:57:34 +0000 (19:57 +0100)]
GDB: Add `NUMBER' completion to `set' integer commands
Fix a completion consistency issue with `set' commands accepting integer
values and the special `unlimited' keyword:
(gdb) complete print -elements
print -elements NUMBER
print -elements unlimited
(gdb)
vs:
(gdb) complete set print elements
set print elements unlimited
(gdb)
(there is a space entered at the end of both commands, not shown here)
which also means if you strike <Tab> with `set print elements ' input,
it will, annoyingly, complete to `set print elements unlimited' right
away rather than showing a choice between `NUMBER' and `unlimited'.
Add `NUMBER' then as an available completion for such `set' commands:
(gdb) complete set print elements
set print elements NUMBER
set print elements unlimited
(gdb)
Adjust the testsuite accordingly. Also document the feature in the
Completion section of the manual in addition to the Command Options
section already there.
Bruno Larsen [Tue, 7 Jun 2022 19:07:07 +0000 (16:07 -0300)]
gdb/testsuite: Expand gdb.cp/mb-ctor.exp to test dynamic allocation
When testing GDB's ability to stop in constructors, gdb.cp/mb-ctor.exp
only tested objects allocated on the stack. This commit adds a couple of
dynamic allocations and tests if GDB can stop in it as well.
Nick Clifton [Thu, 30 Jun 2022 13:53:02 +0000 (14:53 +0100)]
Fix implementation of readelf's -wE and -wN options,
* dwarf.c (dwarf_select_sections_by_name): If the entry's value is
zero then clear the corresponding variable.
(dwarf_select_sections_by_letters): Likewise.
* testsuite/binutils-all/debuginfo.exp: Expect -WE and -wE
debuginfod tests to fail.
Tom de Vries [Thu, 30 Jun 2022 11:31:06 +0000 (13:31 +0200)]
[gdb] Block SIGTERM in worker threads
With gdb build with gcc-12 and -fsanitize=thread, and test-case
gdb.base/gdb-sigterm.exp, I run into:
...
WARNING: ThreadSanitizer: data race (pid=9722)^M
Write of size 4 at 0x00000325bc68 by thread T1:^M
#0 handle_sigterm(int) src/gdb/event-top.c:1211 (gdb+0x8ec01f)^M
...
Previous read of size 4 at 0x00000325bc68 by main thread:^M
[failed to restore the stack]^M
^M
Location is global 'sync_quit_force_run' of size 4 at \
0x00000325bc68 (gdb+0x325bc68)^M
...
SUMMARY: ThreadSanitizer: data race gdb/event-top.c:1211 in \
handle_sigterm(int)^M
...
and 3 more data races involving handle_sigterm and locations:
- active_ext_lang
- quit_flag
- heap block of size 40
(XNEW (async_signal_handler) in create_async_signal_handler)
This was reported in PR29297.
The testcase executes a "kill -TERM $gdb_pid", which generates a
process-directed signal.
A process-directed signal can be delivered to any thread, and what we see
here is the fallout of the signal being delivered to a worker thread rather
than the main thread.
Fix this by blocking SIGTERM in the worker threads.
[ I have not been able to reproduce this after it occurred for the first time,
so unfortunately I cannot confirm that the patch fixes the problem. ]
Tested on x86_64-linux, with and without -fsanitize=thread.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29297
Andrew Burgess [Thu, 23 Jun 2022 12:55:02 +0000 (13:55 +0100)]
gdb/doc: fix column widths in MI compatibility table
In passing I noticed that the column headings for the table of MI
compatibility and breaking changes, were overlapping, at least when
the PDF is generated on my machine.
I propose giving slightly more space to the two version number
columns, this prevents the headers overlapping for me.
GDB Administrator [Thu, 30 Jun 2022 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Wed, 29 Jun 2022 15:38:43 +0000 (16:38 +0100)]
Fix GDBserver regression due to change to avoid reading shell registers
Simon reported that the recent change to make GDB and GDBserver avoid
reading shell registers caused a GDBserver regression, caught with
ASan while running gdb.server/non-existing-program.exp:
$ /home/smarchi/build/binutils-gdb/gdb/testsuite/../../gdb/../gdbserver/gdbserver stdio non-existing-program
=================================================================
==127719==ERROR: AddressSanitizer: heap-use-after-free on address 0x60f0000000e9 at pc 0x55bcbfa301f4 bp 0x7ffd238a7320 sp 0x7ffd238a7310
WRITE of size 1 at 0x60f0000000e9 thread T0
#0 0x55bcbfa301f3 in scoped_restore_tmpl<bool>::~scoped_restore_tmpl() /home/smarchi/src/binutils-gdb/gdbserver/../gdbsupport/scoped_restore.h:86
#1 0x55bcbfa2ffe9 in post_fork_inferior(int, char const*) /home/smarchi/src/binutils-gdb/gdbserver/fork-child.cc:120
#2 0x55bcbf9c9199 in linux_process_target::create_inferior(char const*, std::__debug::vector<char*, std::allocator<char*> > const&) /home/smarchi/src/binutils-gdb/gdbserver/linux-low.cc:991
#3 0x55bcbf954549 in captured_main /home/smarchi/src/binutils-gdb/gdbserver/server.cc:3941
#4 0x55bcbf9552f0 in main /home/smarchi/src/binutils-gdb/gdbserver/server.cc:4084
#5 0x7ff9d663b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2)
#6 0x55bcbf8ef2bd in _start (/home/smarchi/build/binutils-gdb/gdbserver/gdbserver+0x1352bd)
0x60f0000000e9 is located 169 bytes inside of 176-byte region [0x60f000000040,0x60f0000000f0)
freed by thread T0 here:
#0 0x7ff9d6c6f0c7 in operator delete(void*) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:160
#1 0x55bcbf910d00 in remove_process(process_info*) /home/smarchi/src/binutils-gdb/gdbserver/inferiors.cc:164
#2 0x55bcbf9c4ac7 in linux_process_target::remove_linux_process(process_info*) /home/smarchi/src/binutils-gdb/gdbserver/linux-low.cc:454
#3 0x55bcbf9cdaa6 in linux_process_target::mourn(process_info*) /home/smarchi/src/binutils-gdb/gdbserver/linux-low.cc:1599
#4 0x55bcbf988dc4 in target_mourn_inferior(ptid_t) /home/smarchi/src/binutils-gdb/gdbserver/target.cc:205
#5 0x55bcbfa32020 in startup_inferior(process_stratum_target*, int, int, target_waitstatus*, ptid_t*) /home/smarchi/src/binutils-gdb/gdbserver/../gdb/nat/fork-inferior.c:515
#6 0x55bcbfa2fdeb in post_fork_inferior(int, char const*) /home/smarchi/src/binutils-gdb/gdbserver/fork-child.cc:111
#7 0x55bcbf9c9199 in linux_process_target::create_inferior(char const*, std::__debug::vector<char*, std::allocator<char*> > const&) /home/smarchi/src/binutils-gdb/gdbserver/linux-low.cc:991
#8 0x55bcbf954549 in captured_main /home/smarchi/src/binutils-gdb/gdbserver/server.cc:3941
#9 0x55bcbf9552f0 in main /home/smarchi/src/binutils-gdb/gdbserver/server.cc:4084
#10 0x7ff9d663b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2)
previously allocated by thread T0 here:
#0 0x7ff9d6c6e5a7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
#1 0x55bcbf910ad0 in add_process(int, int) /home/smarchi/src/binutils-gdb/gdbserver/inferiors.cc:144
#2 0x55bcbf9c477d in linux_process_target::add_linux_process_no_mem_file(int, int) /home/smarchi/src/binutils-gdb/gdbserver/linux-low.cc:425
#3 0x55bcbf9c8f4c in linux_process_target::create_inferior(char const*, std::__debug::vector<char*, std::allocator<char*> > const&) /home/smarchi/src/binutils-gdb/gdbserver/linux-low.cc:985
#4 0x55bcbf954549 in captured_main /home/smarchi/src/binutils-gdb/gdbserver/server.cc:3941
#5 0x55bcbf9552f0 in main /home/smarchi/src/binutils-gdb/gdbserver/server.cc:4084
#6 0x7ff9d663b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2)
Above we see that in the non-existing-program case, the process gets
deleted before the starting_up flag gets restored to false.
This happens because startup_inferior calls target_mourn_inferior
before throwing an error, and in GDBserver, unlike in GDB, mourning
deletes the process.
Fix this by not using a scoped_restore to manage the starting_up flag,
since we should only clear it when startup_inferior doesn't throw.
Change-Id: I67325d6f81c64de4e89e20e4ec4556f57eac7f6c
Maciej W. Rozycki [Wed, 29 Jun 2022 14:27:41 +0000 (15:27 +0100)]
GDB/testsuite: Tighten `set print elements' error check
Match the whole error message expected to be given rather than omitting
the part about the "unlimited" keyword. There's no point in omitting
the missing part first, and second with an upcoming change the part in
parentheses will no longer be a fixed string, so doing a full match will
ensure the algorithm correctly builds the message expected here. Also
avoid any wildcard matches.
Maciej W. Rozycki [Wed, 29 Jun 2022 14:27:41 +0000 (15:27 +0100)]
GDB: Remove extraneous full stops from `set' command error messages
With errors given for bad commands such as `set annotate' or `set width'
we produce an extraneous full stop within parentheses:
(gdb) set annotate
Argument required (integer to set it to.).
(gdb) set width
Argument required (integer to set it to, or "unlimited".).
(gdb)
This is grammatically incorrect, so remove the full stop and adjust the
testsuite accordingly.
Andrew Burgess [Wed, 22 Jun 2022 10:39:00 +0000 (11:39 +0100)]
gdb/doc: improve description of --data-disassemble opcodes output
Extend the description of the MI command --data-disassemble.
Specifically, expand the description of the 'opcodes' field to explain
how the bytes are formatted.
Yvan Roux [Wed, 29 Jun 2022 12:01:45 +0000 (14:01 +0200)]
gdb/arm: Only stack S16..S31 when FPU registers are secure
The FPCCR.TS bit is used to identify if FPU registers are considered
non-secure or secure. If they are secure, then callee saved registers
(S16 to S31) are stacked on exception entry or otherwise skipped.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
Andrew Burgess [Thu, 16 Jun 2022 12:46:41 +0000 (13:46 +0100)]
opcodes/aarch64: split off creation of comment text in disassembler
The function aarch64_print_operand (aarch64-opc.c) is responsible for
converting an instruction operand into the textual representation of
that operand.
In some cases, a comment is included in the operand representation,
though this (currently) only happens for the last operand of the
instruction.
In a future commit I would like to enable the new libopcodes styling
for AArch64, this will allow objdump and GDB[1] to syntax highlight
the disassembler output, however, having operands and comments
combined in a single string like this makes such styling harder.
In this commit, I propose to extend aarch64_print_operand to take a
second buffer. Any comments for the instruction are written into this
extra buffer. The two callers of aarch64_print_operand are then
updated to pass an extra buffer, and print any resulting comment.
In this commit no styling is added, that will come later. However, I
have adjusted the output slightly. Before this commit some comments
would be separated from the instruction operands with a tab character,
while in other cases the comment was separated with two single spaces.
After this commit I use a single tab character in all cases. This
means a few test cases needed updated. If people would prefer me to
move everyone to use the two spaces, then just let me know. Or maybe
there was a good reason why we used a mix of styles, I could probably
figure out a way to maintain the old output exactly if that is
critical.
Other than that, there should be no user visible changes after this
commit.
[1] GDB patches have not been merged yet, but have been posted to the
GDB mailing list:
https://sourceware.org/pipermail/gdb-patches/2022-June/190142.html
Carl Love [Wed, 22 Jun 2022 15:14:20 +0000 (16:14 +0100)]
gdb/testsuite: fix gdb.base/break-idempotent.exp on ppc
When running the gdb.base/break-idempotent.exp test on ppc, I was
seeing some test failures (or rather errors), that looked like this:
(gdb) watch local
Hardware watchpoint 2: local
has_hw_wp_support: Hardware watchpoint detected
ERROR: no fileid for gcc2-power8
ERROR: Couldn't send delete breakpoints to GDB.
ERROR OCCURED: can't read "gdb_spawn_id": no such variable
while executing
"expect {
-i 1000 -timeout 100
-re ".*A problem internal to GDB has been detected" {
fail "$message (GDB internal error)"
gdb_internal_erro..."
("uplevel" body line 1)
invoked from within
What happens is that in break-idempotent.exp we basically do this:
if {[prepare_for_testing "failed to prepare" $binfile $srcfile $opts]} {
continue
}
# ....
if {![skip_hw_watchpoint_tests]} {
test_break $always_inserted "watch"
}
The problem with this is that skip_hw_watchpoint_tests, includes this:
if { [istarget "i?86-*-*"]
|| [istarget "x86_64-*-*"]
|| [istarget "ia64-*-*"]
|| [istarget "arm*-*-*"]
|| [istarget "aarch64*-*-*"]
|| ([istarget "powerpc*-*-linux*"] && [has_hw_wp_support])
|| [istarget "s390*-*-*"] } {
return 0
}
For powerpc only we call has_hw_wp_support. This is a caching proc
that runs a test within GDB to detect if we have hardware watchpoint
support or not.
Unfortunately, to run this test we restart GDB, and when the test has
completed, we exit GDB. This means that in break-idempotent.exp, when
we call skip_hw_watchpoint_tests for the first time on powerpc, GDB
will unexpectedly be exited. When we later call delete_breakpoints we
see the errors I reported above.
The fix is to call skip_hw_watchpoint_tests early, before we start GDB
as part of the break-idempotent.exp script, and store the result in a
variable, we can then check this variable in the script as needed.
After this change break-idempotent.exp runs fine on powerpc.
Co-authored-by: Andrew Burgess <aburgess@redhat.com>
Jan Beulich [Wed, 29 Jun 2022 08:16:22 +0000 (10:16 +0200)]
x86: drop stray NoRex64 from XBEGIN
Presumably this being there was a result of taking CALL as a reference
when adding the RTM insns. But with No_qSuf the attribute has no effect.
Vladimir Mezentsev [Tue, 28 Jun 2022 20:14:15 +0000 (13:14 -0700)]
gprofng: fix build when BUILD_MAN is false
gprofng/ChangeLog
2022-06-28 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
PR gprofng/29131
* gp-display-html/Makefile.am: Set man_MANS only when BUILD_MAN is true.
* src/Makefile.am: Likewise.
* gp-display-html/Makefile.in: Rebuild.
* src/Makefile.in: Rebuild.
Vladimir Mezentsev [Tue, 28 Jun 2022 16:04:49 +0000 (09:04 -0700)]
gprofng: use $(sysconfdir) instead $(prefix)/etc
gprofng/ChangeLog
2022-06-28 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
PR gprofng/29191
* src/Makefile.am: Use $(sysconfdir) instead $(prefix)/etc.
* src/Settings.cc: Likewise.
* src/Makefile.in: Rebuild.
Alan Modra [Wed, 29 Jun 2022 00:40:15 +0000 (10:10 +0930)]
Re: ld/x86: skip p_align-1 tests with unsuitable compiler
commit
d0e0f9c87a3e results "ERROR: i586-linux-cc does not exist" if
cross-building an i586-linux target without a target compiler
installed.
* testsuite/ld-elf/linux-x86.exp (compiler_honours_aligned): New.
Use it after first testing check_compiler_available.
GDB Administrator [Wed, 29 Jun 2022 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Mon, 27 Jun 2022 19:41:50 +0000 (20:41 +0100)]
gdb+gdbserver/Linux: avoid reading registers while going through shell
For every stop, Linux GDB and GDBserver save the stopped thread's PC,
in lwp->stop_pc. This is done in save_stop_reason, in both
gdb/linux-nat.c and gdbserver/linux-low.cc. However, while we're
going through the shell after "run", in startup_inferior, we shouldn't
be reading registers, as we haven't yet determined the target's
architecture -- the shell's architecture may not even be the same as
the final inferior's.
In gdb/linux-nat.c, lwp->stop_pc is only needed when the thread has
stopped for a breakpoint, and since when going through the shell, no
breakpoint is going to hit, we could simply teach save_stop_reason to
only record the stop pc when the thread stopped for a breakpoint.
However, in gdbserver/linux-low.cc, lwp->stop_pc is used in more cases
than breakpoint hits (e.g., it's used in tracepoints & the
"while-stepping" feature).
So to avoid GDB vs GDBserver divergence, we apply the same approach to
both implementations.
We set a flag in the inferior (process in GDBserver) whenever it is
being nursed through the shell, and when that flag is set,
save_stop_reason bails out early. While going through the shell,
we'll only ever get process exits (normal or signalled), random
signals, and exec events, so nothing is lost.
Change-Id: If0f01831514d3a74d17efd102875de7d2c6401ad
Tom de Vries [Tue, 28 Jun 2022 15:07:18 +0000 (17:07 +0200)]
[gdb/build] Fix gdb build with -fsanitize=thread and gcc 7
When building gdb with system gcc 7.5.0, I run into:
...
gdb/ia64-tdep.c: In function ‘int is_float_or_hfa_type_recurse(type*, type**)’:
gdb/ia64-tdep.c:3362:1: error: control reaches end of non-void function \
[-Werror=return-type]
...
This is due to PR gcc/81275 - "-fsanitize=thread produce incorrect
-Wreturn-type warning", which has been fixed in gcc-8.
Work around this by moving the default return outside the switch.
Tested on x86_64-linux.
Clément Chigot [Tue, 28 Jun 2022 07:42:12 +0000 (09:42 +0200)]
bfd: handle codepage when opening files on MinGW
Even if MS docs say that CP_UTF8 should always be used on newer
applications, forcing it might produce undefined filename if the
encoding isn't UTF-8.
MinGW seems to call ___lc_codepage_func() in order to retrieve the
current thread codepage.
bfd/ChangeLog:
* bfdio.c (_bfd_real_fopen): Retrieve codepage with
___lc_codepage_func() on MinGW.
Clément Chigot [Thu, 16 Jun 2022 11:43:26 +0000 (13:43 +0200)]
windres: add quotes around preprocessor cmd if needed
This patch ensures that the gcc binary called by windres is quoted if
needed. Otherwise, errors can occur if the gcc is under a folder having
a name containing a space (eg "Program Files").
binutils/
* resrc.c (DEFAULT_PREPROCESSOR): Split into...
(DEFAULT_PREPROCESSOR_CMD): that...
(DEFAULT_PREPROCESSOR_ARGS): and that.
(look_for_default): Add quotes around the command if needed.
(read_rc_file): Adapt to new defines.
Nick Clifton [Tue, 28 Jun 2022 11:30:19 +0000 (12:30 +0100)]
Fix the display of the idnex values for DW_FORM_loclistx and DW_FORM_rnglistx. Correct the display of .debug.loclists sections.
PR 29267
* dwarf.c (display_debug_rnglists): New function, broken out of..
(display_debug_ranges): ... here.
(read_and_display_attr_value): Correct calculation of index
displayed for DW_FORM_loclistx and DW_FORM_rnglistx.
* testsuite/binutils-all/x86-64/pr26808.dump: Update expected
output.
Jan Beulich [Tue, 28 Jun 2022 06:56:06 +0000 (08:56 +0200)]
ld/x86: skip p_align-1 tests with unsuitable compiler
When the compiler doesn't properly arrange for foo's alignment, there's
no point even trying these tests. Report the situation as a single
"unsupported" test.
Alan Modra [Mon, 27 Jun 2022 08:47:18 +0000 (18:17 +0930)]
PowerPC64: align plt_branch stubs
plt_branch stubs are similar to plt_call stubs in that they branch
via bctr. Align them too.
bfd/
* elf64-ppc.c (ppc_size_one_stub): Align plt_branch stubs as for
plt_call stubs.
ld/
* testsuite/ld-powerpc/elfv2exe.d: Adjust for plt_branch changes.
* testsuite/ld-powerpc/notoc.d: Likewise.
* testsuite/ld-powerpc/notoc.wf: Likewise.
* testsuite/ld-powerpc/notoc3.d: Likewise.
* testsuite/ld-powerpc/pr23937.d: Likewise.
Alan Modra [Mon, 27 Jun 2022 08:49:32 +0000 (18:19 +0930)]
PowerPC64: plt_stub_pad
* elf64-ppc.c (plt_stub_pad): Simplify parameters and untangle
from plt_stub_size.
(ppc_size_one_stub): Call plt_stub_size before plt_stub_pad to
provide size. Recalculate size if it might change.
Alan Modra [Mon, 27 Jun 2022 07:45:22 +0000 (17:15 +0930)]
PowerPC64: Tidy stub type changes
It made sense before I started using separate fields for main type and
sub type to add a difference in main type to the type (thus keeping
sub type unchanged). Not so much now.
* elf64-ppc.c (ppc_merge_stub): Simplify stub type change.
(ppc_size_one_stub): Likewise.
Jiangshuai Li [Tue, 28 Jun 2022 03:05:30 +0000 (11:05 +0800)]
gdb:csky add pseudo regs for float and vector regs
In the existing CSKY architecture, there are at most 32 floating
and 16 vector registers. Float registers's count can be configured
as 16 or 32. In the future, the vector registers's count may be
extended to 32.
The bit width of floating-point register is 64bits, and the bit
width of vector register is 128bit.
Special points: in fr0~fr15 and vr0~vr15, each FRx is the lower
64 bits of the corresponding VRx.
Here, we will split each floating-point and vector register to
32bits wide, add the corresponding pseudo registers, and finally
use them for the dwarf registers.
There are 128 pseudo registers in total, s0~s127, including:
1. s0 and s1 correspond to fr0, s4 and s5 correspond to fr1, and so on.
Every two separated pseudo registers correspond to a float register.
2. s0, s1, s2 and s3 correspond to vr0; s4, s5, s6 and s7 correspond to vr1,
and so on. Every four pseudo registers corresponds to a vector register.
Therefore, in s64~s127, there are general registers that are not actually
used. This part is to prepare for the expansion of vector registers to 32
Therefore, in s64~s127, half of the registers are actually unused. This
part is to prepare for the expansion of the vector register to 32.
Pekka Seppänen [Tue, 28 Jun 2022 01:41:35 +0000 (11:11 +0930)]
PR29293, elfnn-aarch64.c: def_protected member unintialized
PR 29293
* elfnn-aarch64.c (elfNN_aarch64_link_hash_newfunc): Init def_protected.
Tsukasa OI [Fri, 24 Jun 2022 02:51:56 +0000 (11:51 +0900)]
RISC-V: Add 'Sstc' extension and its CSRs
This commit adds "stimecmp / vstimecmp" Extension (Sstc) and its CSRs.
bfd/ChangeLog:
* elfxx-riscv.c (riscv_supported_std_s_ext): Add 'Sstc'
extension to valid 'S' extension list.
gas/ChangeLog:
* config/tc-riscv.c (enum riscv_csr_class): Add CSR classes for
'Sstc' extension. (riscv_csr_address): Add handling for new CSR
classes.
* testsuite/gas/riscv/csr-dw-regnums.s: Add new CSRs.
* testsuite/gas/riscv/csr-dw-regnums.d: Likewise.
* testsuite/gas/riscv/csr.s: Add new CSRs.
* testsuite/gas/riscv/csr-version-1p9p1.d: Likewise.
* testsuite/gas/riscv/csr-version-1p9p1.l: Likewise.
* testsuite/gas/riscv/csr-version-1p10.d: Likewise.
* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
* testsuite/gas/riscv/csr-version-1p11.d: Likewise.
* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
* testsuite/gas/riscv/csr-version-1p12.d: Likewise.
* testsuite/gas/riscv/csr-version-1p12.l: Likewise.
include/ChangeLog:
* opcode/riscv-opc.h (CSR_STIMECMP, CSR_STIMECMPH,
CSR_VSTIMECMP, CSR_VSTIMECMPH): New CSR macros.
Tsukasa OI [Fri, 24 Jun 2022 02:51:55 +0000 (11:51 +0900)]
RISC-V: Add 'Sscofpmf' extension with its CSRs
This commit adds Count Overflow and Mode-Based Filtering Extension
(Sscofpmf) and its CSRs.
bfd/ChangeLog:
* elfxx-riscv.c (riscv_supported_std_s_ext): Add 'Sscofpmf'
extension to valid 'S' extension list.
gas/ChangeLog:
* config/tc-riscv.c (enum riscv_csr_class): Add CSR classes for
'Sscofpmf' extension. (riscv_csr_address): Add handling for new
CSR classes.
* testsuite/gas/riscv/csr-dw-regnums.s: Add new CSRs.
* testsuite/gas/riscv/csr-dw-regnums.d: Likewise.
* testsuite/gas/riscv/csr.s: Add new CSRs.
* testsuite/gas/riscv/csr-version-1p9p1.d: Likewise.
* testsuite/gas/riscv/csr-version-1p9p1.l: Likewise.
* testsuite/gas/riscv/csr-version-1p10.d: Likewise.
* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
* testsuite/gas/riscv/csr-version-1p11.d: Likewise.
* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
* testsuite/gas/riscv/csr-version-1p12.d: Likewise.
* testsuite/gas/riscv/csr-version-1p12.l: Likewise.
include/ChangeLog:
* opcode/riscv-opc.h (CSR_SCOUNTOVF, CSR_MHPMEVENT3H,
CSR_MHPMEVENT4H, CSR_MHPMEVENT5H, CSR_MHPMEVENT6H,
CSR_MHPMEVENT7H, CSR_MHPMEVENT8H, CSR_MHPMEVENT9H,
CSR_MHPMEVENT10H, CSR_MHPMEVENT11H, CSR_MHPMEVENT12H,
CSR_MHPMEVENT13H, CSR_MHPMEVENT14H, CSR_MHPMEVENT15H,
CSR_MHPMEVENT16H, CSR_MHPMEVENT17H, CSR_MHPMEVENT18H,
CSR_MHPMEVENT19H, CSR_MHPMEVENT20H, CSR_MHPMEVENT21H,
CSR_MHPMEVENT22H, CSR_MHPMEVENT23H, CSR_MHPMEVENT24H,
CSR_MHPMEVENT25H, CSR_MHPMEVENT26H, CSR_MHPMEVENT27H,
CSR_MHPMEVENT28H, CSR_MHPMEVENT29H, CSR_MHPMEVENT30H,
CSR_MHPMEVENT31H): New CSR macros.
Tsukasa OI [Fri, 24 Jun 2022 02:51:54 +0000 (11:51 +0900)]
RISC-V: Add 'Smstateen' extension and its CSRs
This commit adds State Enable Extension (Smstateen) and its CSRs.
bfd/ChangeLog:
* elfxx-riscv.c (riscv_supported_std_s_ext): Add 'Smstateen'
extension to valid 'S' extension list.
gas/ChangeLog:
* config/tc-riscv.c (enum riscv_csr_class): Add CSR classes for
'Smstateen' extension. (riscv_csr_address): Add handling for
new CSR classes.
* testsuite/gas/riscv/csr-dw-regnums.s: Add new CSRs.
* testsuite/gas/riscv/csr-dw-regnums.d: Likewise.
* testsuite/gas/riscv/csr.s: Add new CSRs.
* testsuite/gas/riscv/csr-version-1p9p1.d: Likewise.
* testsuite/gas/riscv/csr-version-1p9p1.l: Likewise.
* testsuite/gas/riscv/csr-version-1p10.d: Likewise.
* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
* testsuite/gas/riscv/csr-version-1p11.d: Likewise.
* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
* testsuite/gas/riscv/csr-version-1p12.d: Likewise.
* testsuite/gas/riscv/csr-version-1p12.l: Likewise.
include/ChangeLog:
* opcode/riscv-opc.h (CSR_MSTATEEN0, CSR_MSTATEEN1,
CSR_MSTATEEN2, CSR_MSTATEEN3, CSR_SSTATEEN0, CSR_SSTATEEN1,
CSR_SSTATEEN2, CSR_SSTATEEN3, CSR_HSTATEEN0, CSR_HSTATEEN1,
CSR_HSTATEEN2, CSR_HSTATEEN3, CSR_MSTATEEN0H, CSR_MSTATEEN1H,
CSR_MSTATEEN2H, CSR_MSTATEEN3H, CSR_HSTATEEN0H, CSR_HSTATEEN1H,
CSR_HSTATEEN2H, CSR_HSTATEEN3H): New CSR macros.
Tsukasa OI [Fri, 24 Jun 2022 02:51:53 +0000 (11:51 +0900)]
RISC-V: Add new CSR feature gate handling (RV32,H)
To support feature gate like Smstateen && H, this commit adds certain
CSR feature gate handling. It also changes how RV32-only CSRs are
handled for cleanliness.
gas/ChangeLog:
* config/tc-riscv.c (riscv_csr_address): Add CSR feature gate
handling for H. Change handling on RV32.
Alan Modra [Mon, 27 Jun 2022 11:09:09 +0000 (20:39 +0930)]
Re: Disable execstack and rwx segments warnings for MIPS targets.
PR 29263
* configure.ac: Fix typo.
* testsuite/ld-elf/elf.exp: Add mips to targets that need
--warn-execstack to pass first pr29072 test.
GDB Administrator [Tue, 28 Jun 2022 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
Bruno Larsen [Mon, 27 Jun 2022 19:39:03 +0000 (16:39 -0300)]
gdb/testsuite: update bug numbers from Gnats to bugzilla
Some tests link to outdated bug numbers when an XFAIL or a KFAIL happen.
gdb.base/macscp.exp was referencing bug number 555, and the bug 7660
mentions that it used to be 555 on the Gnats system and seems to relate
to the issue at hand.
gdb.base/annota1.exp was referencing bug number 1270, and bug 8375
mentions being number 1270 on Gnats, and mentions annota1 specifically,
so it seemed pretty obvious.
Tom de Vries [Mon, 27 Jun 2022 13:36:19 +0000 (15:36 +0200)]
[gdb/build] Fix build breaker with --enable-shared
When building gdb with --enable-shared, I run into:
...
ld: build/zlib/libz.a(libz_a-inffast.o): relocation R_X86_64_32S against \
`.rodata' can not be used when making a shared object; recompile with -fPIC
ld: build/zlib/libz.a(libz_a-inflate.o): warning: relocation against \
`inflateResetKeep' in read-only section `.text'
collect2: error: ld returned 1 exit status
make[3]: *** [libbfd.la] Error 1
...
This is a regression since commit
a08bdb159bb ("[gdb/build] Fix gdbserver
build with -fsanitize=thread").
The problem is that a single case statement in configure is shared to handle
special requirements for both the host libiberty and host zlib, which has the
effect that only one is handled.
Fix this by handling libiberty and zlib each in its own case statement.
Build on x86_64-linux, with and without --enable-shared.
ChangeLog:
2022-06-27 Tom de Vries <tdevries@suse.de>
* configure.ac: Set extra_host_libiberty_configure_flags and
extra_host_zlib_configure_flags in separate case statements.
* configure: Regenerate.
Pedro Alves [Fri, 24 Jun 2022 11:42:38 +0000 (12:42 +0100)]
Make GDBserver abort on internal error in development mode
Currently, if GDBserver hits some internal assertion, it exits with
error status, instead of aborting. This makes it harder to debug
GDBserver, as you can't just debug a core file if GDBserver fails an
assertion. I've had to hack the code to make GDBserver abort to debug
something several times before.
I believe the reason it exits instead of aborting, is to prevent
potentially littering the filesystem of smaller embedded targets with
core files. I think I recall Daniel Jacobowitz once saying that many
years ago, but I can't be sure. Anyhow, that seems reasonable to me.
Since we nowadays have a distinction between development and release
modes, I propose to make GDBserver abort on internal error if in
development mode, while keeping the status quo when in release mode.
Thus, after this patch, in development mode, you get:
$ ../gdbserver/gdbserver
../../src/gdbserver/server.cc:3711: A problem internal to GDBserver has been detected.
captured_main: Assertion `0' failed.
Aborted (core dumped)
$
while in release mode, you'll continue to get:
$ ../gdbserver/gdbserver
../../src/gdbserver/server.cc:3711: A problem internal to GDBserver has been detected.
captured_main: Assertion `0' failed.
$ echo $?
1
I do not think that this requires a separate configure switch.
A "--target_board=native-extended-gdbserver" run on Ubuntu 20.04 ends
up with:
=== gdb Summary ===
# of unexpected core files 29
...
for me, of which 8 are GDBserver core dumps, 7 more than without this
patch.
Change-Id: I6861e08ad71f65a0332c91ec95ca001d130b0e9d
Nick Clifton [Mon, 27 Jun 2022 12:43:02 +0000 (13:43 +0100)]
Replace a run-time assertion failure with a warning message when parsing corrupt DWARF data.
PR 29289
* dwarf.c (display_debug_names): Replace assert with a warning
message.
Nick Clifton [Mon, 27 Jun 2022 12:30:35 +0000 (13:30 +0100)]
Fix NULL pointer indirection when parsing corrupt DWARF data.
PR 29290
* dwarf.c (read_and_display_attr_value): Check that debug_info_p
is set before dereferencing it.
Nick Clifton [Mon, 27 Jun 2022 12:07:40 +0000 (13:07 +0100)]
Have gold's File_read::do_read() function check the start parameter
PR 23765
* fileread.cc (File_read::do_read): Check start parameter before
computing number of bytes to read.
Yvan Roux [Mon, 27 Jun 2022 11:26:36 +0000 (13:26 +0200)]
gdb/arm: Unwind Non-Secure callbacks from Secure
Without this changeset, the unwinding doesn't take into account
Non-Secure to Secure stack unwinding enablement status and
doesn't choose the proper SP to do the unwinding.
This patch only unwinds the stack when Non-Secure to Secure
unwinding is enabled, previous SP is set w/r to the current mode
(Handler -> msp_s, Thread -> psp_s) and then the Secure stack is
unwound. Ensure thumb bit is set in PSR when needed. Also, drop
thumb bit from PC if set.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Signed-off-by: Yvan ROUX <yvan.roux@foss.st.com>
Nick Clifton [Mon, 27 Jun 2022 10:48:24 +0000 (11:48 +0100)]
Stop bogus warnings about DWARF indexed string offsets being too big.
* dwarf.c (fetch_indexed_string): Do not use length of first table
in string section as the length of every table in the section.
* testsuite/binutils-all/pr26112.r: Update expected output.
Tom de Vries [Mon, 27 Jun 2022 10:47:26 +0000 (12:47 +0200)]
[gdb/testsuite] Handle older python in gdb.python/py-send-packet.py
With python 3.4, I run into:
...
Traceback (most recent call last):^M
File "<string>", line 1, in <module>^M
File
"outputs/gdb.python/py-send-packet/py-send-packet.py", line 128, in \
run_set_global_var_test^M
res = conn.send_packet(b"X%x,4:\x02\x02\x02\x02" % addr)^M
TypeError: Could not convert Python object: b'X%x,4:\x02\x02\x02\x02'.^M
Error while executing Python code.^M
...
while with python 3.6 this works fine.
The type of addr is <class 'gdb.Value'>, so the first thing to try is whether
changing it into a string works:
...
addr_str = "%x" % addr
res = conn.send_packet(b"X%s,4:\x02\x02\x02\x02" % addr_str)
...
which gets us the more detailed:
...
TypeError: unsupported operand type(s) for %: 'bytes' and 'str'
...
Fix this by avoiding the '%' operator in the byte literal, and use instead:
...
def xpacket_header (addr):
return ("X%x,4:" % addr).encode('ascii')
...
res = conn.send_packet(xpacket_header(addr) + b"\x02\x02\x02\x02")
...
Tested on x86_64-linux, with python 3.4 and 3.6, and a backported version was
tested on the gdb-12-branch in combination with python 2.7.
Tom de Vries [Mon, 27 Jun 2022 10:47:26 +0000 (12:47 +0200)]
[gdb/testsuite] Fix gdb.reverse/i387-env-reverse.exp for -pie
When running test-case gdb.reverse/i387-env-reverse.exp for x86_64-linux with
target board unix/-m32/-fPIE/-pie, we run into:
...
(gdb) PASS: gdb.reverse/i387-env-reverse.exp: push st0
info register eax^M
eax 0x56550000
1448411136^M
(gdb) FAIL: gdb.reverse/i387-env-reverse.exp: verify eax == 0x8040000
...
The problem is that the tested instruction (fstsw) only sets $ax, not $eax.
Fix this by verifying $ax instead of $eax.
Tested on x86_64-linux with target boards unix/-m32 and unix/-m32/-fPIE/-pie.
Tom de Vries [Mon, 27 Jun 2022 10:47:26 +0000 (12:47 +0200)]
[gdb/testsuite] Enable some test-cases for x86_64 -m32
When trying to run test-case gdb.reverse/i387-env-reverse.exp for x86_64-linux
with target board unix/-m32, it's skipped.
Fix this by using is_x86_like_target instead of istarget "i?86-*linux*".
This exposes a number of duplicates, fix those by making the test names unique.
Likewise in a couple of other test-cases.
Tested on x86_64-linux with target boards unix/-m32.
Tom de Vries [Mon, 27 Jun 2022 10:47:26 +0000 (12:47 +0200)]
[gdb/testsuite] Workaround unnecessary .s file with gfortran 4.8
After running test-case gdb.fortran/namelist.exp with gfortran 4.8.5, I'm left
with:
...
$ git sti
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
gdb/testsuite/lib/compiler.s
nothing added to commit but untracked files present (use "git add" to track)
...
We're running into PR gcc/60447, which was fixed in gcc 4.9.0.
Workaround this by first copying the source file to the temp dir, such that
the .s file is left there instead:
...
$ ls build/gdb/testsuite/temp/<runtest pid>/
compiler.c compiler.F90 compiler.s
...
Tested on x86_64-linux.
Tom de Vries [Mon, 27 Jun 2022 10:47:26 +0000 (12:47 +0200)]
[gdb/testsuite] Skip gdb.fortran/namelist.exp for gfortran 4.8
The test-case gdb.fortran/namelist.exp uses a gfortran feature (emitting
DW_TAG_namelist in the debug info) that has been supported since gfortran 4.9,
see PR gcc/37132.
Skip the test for gfortran 4.8 and earlier. Do this using gcc_major_version,
and update it to be able to handle "gcc_major_version {gfortran-*} f90".
Tested on x86_64-linux, with gfortran 4.8.5, 7.5.0, and 12.1.1.
Tom de Vries [Mon, 27 Jun 2022 10:47:26 +0000 (12:47 +0200)]
[gdb/symtab] Fix parsing of .debug_str_offsets header
When running test-case gdb.dwarf2/fission-mix.exp with target board dwarf64
and gcc-12 (defaulting to DWARF5), I run into:
...
(gdb) break func2^M
Offset from DW_FORM_GNU_str_index or DW_FORM_strx pointing outside of \
.debug_str.dwo section in CU at offset 0x0 [in module fission-mix]^M
(gdb) FAIL: gdb.dwarf2/fission-mix.exp: break func2
...
The .debug_str_offsets section has version 5, so as per the standard it has
it's own header, with initial length and version:
...
Contents of the .debug_str_offsets.dwo section (loaded from fission-mix2.dwo):
Length: 0x1c
Version: 0x5
Index Offset [String]
0 0 build/gdb/testsuite
1 33 GNU C17
2 8f src/gdb/testsuite/gdb.dwarf2/fission-mix-2.c
...
But when trying to read the string offset at index 0 in the table (which
is 0), we start reading at offset 8, which points in the header, at the last
4 bytes of the initial length (it's 12 bytes because of 64-bit dwarf), as well
at the 2-byte version field and 2 bytes of padding, so we get:
...
(gdb) p /x str_offset
$1 = 0x500000000
...
which indeed is an offset that doesn't fit in the .debug_str section.
The offset 8 is based on reader->cu->header.addr_size:
...
static const char *
read_dwo_str_index (const struct die_reader_specs *reader, ULONGEST str_index)
{
ULONGEST str_offsets_base = reader->cu->header.version >= 5
? reader->cu->header.addr_size : 0;
...
which doesn't in look in agreement with the standard.
Note that this happens to give the right answer for 32-bit dwarf and
addr_size == 8, because then we have header size ==
(initial length (4) + version (2) + padding (2)) == 8.
Conversely, for 32-bit dwarf and addr_size == 4 (target board unix/-m32)
we run into a similar problem. It just happens to not trigger the warning,
instead we get the wrong strings, like "func2" for DW_AT_producer and
"build/gdb/testsuite" for DW_AT_name of the DW_TAG_compile_unit DIE.
Fix this by parsing the .debug_str_offsets header in read_dwo_str_index.
Add a FIXME that we should not parse this for every call.
Tested on x86_64-linux.
Tom de Vries [Mon, 27 Jun 2022 10:47:26 +0000 (12:47 +0200)]
[gdb/build] Fix gdbserver build with -fsanitize=thread
[ Copied from gcc commit
153689603fd ("[gdb/build] Fix gdbserver build with
-fsanitize=thread"). ]
When building gdbserver with -fsanitize=thread (added to CFLAGS/CXXFLAGS) we
run into:
...
ld: ../libiberty/libiberty.a(safe-ctype.o): warning: relocation against \
`__tsan_init' in read-only section `.text'
ld: ../libiberty/libiberty.a(safe-ctype.o): relocation R_X86_64_PC32 \
against symbol `__tsan_init' can not be used when making a shared object; \
recompile with -fPIC
ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[1]: *** [libinproctrace.so] Error 1
...
which looks similar to what is described in commit
78e49486944 ("[gdb/build]
Fix gdbserver build with -fsanitize=address").
The gdbserver component builds a shared library libinproctrace.so, which uses
libiberty and therefore requires the pic variant. The gdbserver Makefile is
setup to use this variant, if available, but it's not there.
Fix this by listing gdbserver in the toplevel configure alongside libcc1, as a
component that needs the libiberty pic variant, setting:
...
extra_host_libiberty_configure_flags=--enable-shared
...
Tested on x86_64-linux.
ChangeLog:
2022-06-27 Tom de Vries <tdevries@suse.de>
* configure.ac: Build libiberty pic variant for gdbserver.
* configure: Regenerate.
Nick Clifton [Mon, 27 Jun 2022 10:39:27 +0000 (11:39 +0100)]
Disable execstack and rwx segments warnings for MIPS targets.
PR 29263
* configure.ac: Move HPPA specific code from here...
* configure.tgt: ... to here. Add similar code for MIPS.
Move code for CRIS, MIPS and HPPA to block at start of file.
* configure: Regenerate.
Jan Beulich [Mon, 27 Jun 2022 09:12:57 +0000 (11:12 +0200)]
bfd: prune config.bfd's setting of targ_archs
The final "match all" case can take care of a few explicit entries:
Purge those. Also move s12z* into proper position (the table is
otherwise sorted, after all).
Jan Beulich [Mon, 27 Jun 2022 09:11:46 +0000 (11:11 +0200)]
drop XC16x bits
Commit
04f096fb9e25 ("Move the xc16x target to the obsolete list") moved
the architecture from the "obsolete but still available" to the
"obsolete / support removed" list in config.bfd, making the architecture
impossible to enable (except maybe via "enable everything" options").
Note that I didn't touch */po/*.po{,t} on the assumption that these
would be updated by some (half)automatic means.
Bhuvanendra Kumar N [Mon, 27 Jun 2022 07:37:55 +0000 (13:07 +0530)]
Fix location list offset address dump under DW_AT_location (dwarf-5)
For clang compiled objects with dwarf-5, location list offset address dump
under DW_AT_location is corrected, where DW_FORM_loclistx is used. While
dumping the location list offset, the address dumped is wrong where it was
refering to .debug_addr instead of .debug_loclists
* dwarf.c (fetch_indexed_value): Add base_address as parameter and
use it to access the section offset.
(read_and_display_attr_value): Handle DW_FORM_loclistx form separately.
Pass loclists_base to fetch_indexed_value().
Alan Modra [Sat, 25 Jun 2022 02:27:22 +0000 (11:57 +0930)]
PowerPC64 .branch_lt address
.branch_lt is really an extension of .plt, as is .iplt. We'd like all
of the PLT sections to be fixed relative to .TOC. after stub sizing,
because changes in offset to PLT entries might mean a change in stub
sizes. When -z relro, the relro layout does this by laying out
sections from the end of the relro segment. So for example, a change
in .eh_frame (which happens after stub sizing) will keep the same GOT
to PLT offset when -z relro. Not so when -z norelro, because then the
usual forward layout of section is done and .got is more aligned than
.branch_lt.
* emulparams/elf64ppc.sh: Set .branch_lt address fixed relative
to .got.
* testsuite/ld-powerpc/elfv2exe.d: Adjust to suit.
Alan Modra [Fri, 24 Jun 2022 03:55:45 +0000 (13:25 +0930)]
-z relro relaxation and ld script SIZEOF
A number of targets use assignments like:
. = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 12 ? 12 : 0, .);
(from i386) in linker scripts to put the end of the relro segment past
the header in .got.plt. Examination of testcases like those edited by
this patch instead sees the end of the relro segment being placed at
the start of .got.plt. For the i386 pie1 test:
[ 9] .got.plt PROGBITS
00002000 001000 00000c 04 WA 0 0 4
GNU_RELRO 0x000f90 0x00001f90 0x00001f90 0x00070 0x00070 R 0x1
A map file shows:
.dynamic 0x0000000000001f90 0x70
*(.dynamic)
.dynamic 0x0000000000001f90 0x70 tmpdir/pie1.o
0x0000000000001f90 _DYNAMIC
.got 0x0000000000002000 0x0
*(.got)
.got 0x0000000000002000 0x0 tmpdir/pie1.o
*(.igot)
0x0000000000002ff4 . = DATA_SEGMENT_RELRO_END (., (SIZEOF (.got.plt) >= 0xc)?0xc:0x0)
.got.plt 0x0000000000002000 0xc
*(.got.plt)
.got.plt 0x0000000000002000 0xc tmpdir/pie1.o
0x0000000000002000 _GLOBAL_OFFSET_TABLE_
The DATA_SEGMENT_RELRO_END value in the map file is weird too. All of
this is triggered by SIZEOF (.got.plt) being evaluated wrongly as
zero. Fix it by taking into account the action of
lang_reset_memory_regions during relaxation.
* ldexp.c (fold_name <SIZEOF>): Use rawsize if size has been reset.
* ldlang.c (lang_size_sections_1): Don't reset processed_vma here.
* testsuite/ld-i386/pie1.d: Adjust to suit.
* testsuite/ld-x86-64/pr20830a.d: Likewise.
* testsuite/ld-x86-64/pr20830b.d: Likewise.
* testsuite/ld-x86-64/pr21038a.d: Likewise.
* testsuite/ld-x86-64/pr21038b.d: Likewise.
* testsuite/ld-x86-64/pr21038c.d: Likewise.
GDB Administrator [Mon, 27 Jun 2022 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 26 Jun 2022 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in
Fangrui Song [Sat, 25 Jun 2022 17:27:49 +0000 (10:27 -0700)]
arm: Define elf_backend_extern_protected_data to 0 [PR 18705]
Similar to commit
4fb55bf6a9606eb7b626c30a9f4e71d6c2d4fbb2 for aarch64.
Commit
b68a20d6675f1360ea4db50a9835c073675b9889 changed ld to produce
R_ARM_GLOB_DAT but that defeated the purpose of protected visibility
as an optimization. Restore the previous behavior (which matches
ld.lld) by defining elf_backend_extern_protected_data to 0.
Tom Tromey [Thu, 9 Jun 2022 13:19:13 +0000 (07:19 -0600)]
Fix corrupt DWARF in dw2-double-set-die-type
The dw2-double-set-die-type.exp test case caused an AddressSanitizer
failure in the new DWARF scanner.
The immediate cause was bad DWARF in the test -- in particular, the
the sibling attribute here:
<2><181>: Abbrev Number: 33 (DW_TAG_subprogram)
<182> DW_AT_external : 1
<183> DW_AT_name : address
<18b> DW_AT_type : <0x171>
<18f> DW_AT_declaration : 1
<190> DW_AT_sibling : <0x1a1>
...
<1><1a1>: Abbrev Number: 23 (DW_TAG_pointer_type)
<1a2> DW_AT_byte_size : 4
<1a3> DW_AT_type : <0x1a7>
...points to a "sibling" DIE that is at a different child depth.
Because this test case doesn't really require sibling attributes, this
patch fixes the problem by removing them from the test.
Note that gdb is not generally robust against malformed DWARF.
Detecting and compensating for this problem would probably be
expensive and, IMO, is better left to some (still hypothetical) DWARF
linter.