Alan Modra [Thu, 16 Jan 2025 04:20:03 +0000 (14:50 +1030)]
genlink tidy
Some of the declarations in genlink.h are not used in current sources
apart from needing them in linker.c, so delete and/or move them there.
The patch also fixes a FIXME. It's actually quite easy to return
a failure from a hash traversal function.
* genlink.h (_bfd_generic_link_hash_newfunc): Delete.
(_bfd_generic_link_output_symbols),
(generic_write_global_symbol_info),
(_bfd_generic_link_write_global_symbol): Move to..
* linker.c: ..here, making functions static.
(generic_write_global_symbol_info): Add "failed".
(_bfd_generic_final_link): Handle wginfo.failed.
(_bfd_generic_link_write_global_symbol): Set wginfo->failed
on memory failures and return false rather than aborting.
Tom de Vries [Thu, 16 Jan 2025 08:39:55 +0000 (09:39 +0100)]
[gdb/testsuite] Fix timeouts in gdb.threads/step-over-thread-exit.exp
Once in a while, I run into a timeout in test-case
gdb.threads/step-over-thread-exit.exp:
...
(gdb) continue^M
Continuing.^M
[New Thread 0xfffff7cff1a0 (LWP 2874854)]^M
^M
Thread 97 "step-over-threa" hit Breakpoint 2, 0x0000000000410314 in \
my_exit_syscall () at gdb/testsuite/lib/my-syscalls.S:74^M
74 SYSCALL (my_exit, __NR_exit)^M
(gdb) [Thread 0xfffff7cff1a0 (LWP 2874853) exited]^M
FAIL: $exp: step_over_mode=displaced: non-stop=on: target-non-stop=on: \
schedlock=off: cmd=continue: ns_stop_all=0: iter 95: continue (timeout)
...
I can reproduce it more frequently by running with taskset -c <slow core id>.
Fix this by using -no-prompt-anchor.
This requires us to add -no-prompt-anchor to proc gdb_test_multiple.
Commit 3470a0e144df6c01f8479fa649f43aa907936e7e inadvertently broke
the build on MIPS because it's passing a non-existent "pid" argument
to "proc->for_each_thread". This commit fixes the problem by removing
the argument from the call.
Alan Modra [Wed, 15 Jan 2025 12:42:52 +0000 (23:12 +1030)]
x86 relr memory leaks
This fixes some x86 memory leaks. I think it would be possible to
free the relr data in _bfd_elf_x86_finish_relative_relocs if we
wanted to reclaim some memory earlier, but for tidying after errors we
likely would need to free in the hash_table_free function anyway.
_bfd_x86_elf_link_relax_section is called via bfd_relax_section,
ie. whenever relaxation is enabled. This is a waste of time if
dt_relr relocs are not enabled since the function is there only to
handle relr.
* elfxx-x86.c (elf_x86_link_hash_table_free): Free relr data.
(_bfd_x86_elf_link_relax_section): Return early
if !info->enable_dt_relr. Do set "again" false before early
returns.
Martin Storsjö [Sat, 11 Jan 2025 18:42:09 +0000 (20:42 +0200)]
Add support for IMPORT_CONST in ILF (MSVC style) import libraries
This is a very strange and obsolete kind of import type; it is
used for imported data just like IMPORT_DATA - but with an extra
odd caveat.
The behaviour is explained at [1]; generating such import libraries
with current MSVC tools produces "warning LNK4087: CONSTANT keyword is
obsolete; use DATA".
While obsolete, some import libraries within the Microsoft WDK (Windows
Driver Kit) do contain such symbols, which currently are ignored by
binutils and produce warnings about "file format not recognized".
For IMPORT_CONST for a DLL exported symbol "foo", we should provide
the import library symbols "__imp_foo" and "foo". For IMPORT_DATA, we
only provide "__imp_foo", and for IMPORT_CODE, "foo" points at a thunk.
The odd/surprising thing for IMPORT_CONST is that the "foo" symbol also
points at the same thing as "__imp_foo", i.e. directly at the IAT
entry.
Matthieu Longo [Fri, 8 Nov 2024 11:03:55 +0000 (11:03 +0000)]
aarch64: check GCS feature in GNU properties of input dynamic objects
The Guarded Control Stack (GCS) feature requires that two things:
- at static link time, all the input objects of a link unit have to
be compatible with GCS.
- at runtime, the executable and the shared libraries which it
depends on have to be compatible with GCS.
Both of those criteria are checked with the GCS feature stored in
the GNU property note.
The previous patch, adding support for the GCS feature check in GNU
note properties for input objects, ignored the input dynamic objects.
Although this support was better than no check, it was still
delaying the detection of compatibility issues up to the runtime
linker.
In order to help the developer in detecting such an incompatibility
issue as early as possible, this patch adds a check for input dynamic
objects lacking the GCS marking. This check can be controlled via the
linker option '-z gcs-report-dynamic[=none|warning|error]'. By default,
if the option is omitted, it inherits the value from '-z gcs-report'.
However, the inherited value is capped to 'warning' as a user might
want to only report errors in the currently built module, and not the
shared dependencies. If a user also wants to error on GCS issues in
the shared libraries, '-z gcs-report-dynamic=error' will have to be
specified explicitly.
gdbserver: remove an obsolete comment in tracepoint.cc
The comment
/* Functions local to this file. */
has somehow been positioned above struct definitions, not functions.
Some static function declarations are given after the structs, to
where the comment could be moved, but the comment is not really
helpful. Therefore remove it.
Tom de Vries [Wed, 15 Jan 2025 16:02:00 +0000 (17:02 +0100)]
[gdb/tdep] Fix gdb.base/store.exp on s390x
On s390x-linux, I get:
...
(gdb) print l^M
$29 = 0^M
(gdb) FAIL: gdb.base/store.exp: var doublest l; print old l, expecting -1
...
So, we're in wack_doublest trying to print l, which is a copy of parameter u:
...
register doublest l = u, r = v;
...
which does have the expected value:
...
(gdb) p u
$1 = -1
...
which is a long double, 16 bytes and looks like this:
...
(gdb) p /x u
$3 = 0xbfff0000000000000000000000000000
...
Parameter u is passed in two registers:
...
<2><6a5>: Abbrev Number: 15 (DW_TAG_formal_parameter)
<6a6> DW_AT_name : v
<69e> DW_AT_location : 6 byte block: 50 93 8 51 93 8 \
(DW_OP_reg0 (r0); DW_OP_piece: 8; DW_OP_reg1 (r1); DW_OP_piece: 8)
...
and indeed we find the msw in r0 and the lsw in r1:
...
(gdb) p /x $r0
$4 = 0xbfff000000000000
(gdb) p /x $r1
$5 = 0x0
(gdb)
...
Likewise, variable l consists of two registers:
...
<2><6b5>: Abbrev Number: 13 (DW_TAG_variable)
<6b6> DW_AT_name : l
<6be> DW_AT_location : 6 byte block: 68 93 8 69 93 8 \
(DW_OP_reg24 (f8); DW_OP_piece: 8; DW_OP_reg25 (f10); DW_OP_piece: 8)
...
and we find the same values there:
...
(gdb) p /x $f8
$6 = 0xbfff000000000000
(gdb) p /x $f10
$7 = 0x0
...
So, we get the expected results when fetching the value from two gprs, but not
when fetching the value from two fprs.
When fetching the values from the two fprs, we stumble upon a particularity of
the DWARF register numbers as defined by the s390x ABI [1]: dwarf register 24
maps to both floating-point register f8 (8 bytes), and vector register v8
(16 bytes).
In s390_dwarf_reg_to_regnum, it's determined which of the two is chosen, and
if available vector registers are preferred over floating-point registers, so
v8 is chosen, and used to fetch the value.
Since the size of the DW_OP_piece is 8 bytes, and the register size is 16
bytes, this bit in rw_pieced_value is activated:
...
/* If the piece is located in a register, but does not
occupy the entire register, the placement of the piece
within that register is defined by the ABI. */
bits_to_skip
+= 8 * gdbarch_dwarf2_reg_piece_offset (arch, gdb_regnum,
p->size / 8);
...
but since the default implemention default_dwarf2_reg_piece_offset does not
match the s390x ABI, we get the wrong answer.
This is a known problem, see FOSDEM 2018 presentation "DWARF Pieces And Other
DWARF Location Woes" [2].
Fix this by adding s390_dwarf2_reg_piece_offset, roughly implementing the same
logic as in s390_value_from_register.
Tested on s390x-linux.
Approved-By: Tom Tromey <tom@tromey.com>
[1] https://github.com/IBM/s390x-abi
[2] https://archive.fosdem.org/2018/schedule/event/dwarfpieces
Tom de Vries [Wed, 15 Jan 2025 16:02:00 +0000 (17:02 +0100)]
[gdb] Add gdbarch_dwarf2_reg_piece_offset hook
In rw_pieced_value, when reading/writing part of a register, DW_OP_piece and
DW_OP_bit_piece are handled the same, but the standard tells us:
- DW_OP_piece: if the piece is located in a register, but does not occupy the
entire register, the placement of the piece within that register is defined
by the ABI.
- DW_OP_bit_piece: if the location is a register, the offset is from the least
significant bit end of the register.
Add a new hook gdbarch_dwarf2_reg_piece_offset that allows us to define the
ABI-specific behaviour for DW_OP_piece.
The default implementation of the hook is the behaviour of DW_OP_bit_piece, so
there should not be any functional changes.
Hui Li [Mon, 6 Jan 2025 10:21:23 +0000 (18:21 +0800)]
gdbserver: LoongArch: Add hardware watchpoint/breakpoint support
LoongArch defines hardware watchpoint functions for fetch and load/store
operations, the related support for gdb was added in the following two
commit c1cdee0e2c17 ("gdb: LoongArch: Add support for hardware watchpoint")
commit 6ced1278fc00 ("gdb: LoongArch: Add support for hardware breakpoint")
Now, add hardware watchpoint and breakpoint support for gdbserver on
LoongArch.
Here is a simple example
$ cat test.c
#include <stdio.h>
int a = 0;
int b = 0;
int main()
{
printf("start test\n");
a = 1;
printf("a = %d\n", a);
a = 2;
printf("a = %d\n", a);
b = 2;
printf("b = %d\n", b);
return 0;
}
$ gcc -g test.c -o test
Execute on the target machine:
$ gdbserver 192.168.1.100:1234 ./test
Execute on the host machine:
$ gdb ./test
...
(gdb) target remote 192.168.1.100:1234
...
(gdb) b main
Breakpoint 1 at 0x1200006b8: file test.c, line 6.
(gdb) c
Continuing.
...
Breakpoint 1, main () at test.c:6
6 printf("start test\n");
(gdb) watch a
Hardware watchpoint 2: a
(gdb) hbreak 11
Hardware assisted breakpoint 3 at 0x120000700: file test.c, line 11.
(gdb) c
Continuing.
Hardware watchpoint 2: a
Old value = 0
New value = 1
main () at test.c:8
8 printf("a = %d\n", a);
(gdb) c
Continuing.
Hardware watchpoint 2: a
Old value = 1
New value = 2
main () at test.c:10
10 printf("a = %d\n", a);
(gdb) c
Continuing.
Breakpoint 3, main () at test.c:11
11 b = 2;
(gdb) c
Continuing.
[Inferior 1 (process 696656) exited normally]
Output on the target machine:
Process ./test created; pid = 696708
Listening on port 1234
Remote debugging from host 192.168.1.200, port 60742
start test
a = 1
a = 2
b = 2
Child exited with status 0
Signed-off-by: Hui Li <lihui@loongson.cn> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
loongarch_stopped_data_address() is a common function and will be used by
gdb and gdbserver, so move its definition from gdb/loongarch-linux-nat.c
to gdb/nat/loongarch-hw-point.c. This is preparation for later gdbserver
patch on LoongArch and is no effect for the current code.
Signed-off-by: Hui Li <lihui@loongson.cn> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
loongarch_{get,remove}_debug_reg_state() are used as helper functions
by loongarch_linux_nat_target. We should move their definitions from
gdb/nat/loongarch-linux-hw-point.c to gdb/loongarch-linux-nat.c.
Signed-off-by: Hui Li <lihui@loongson.cn> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
H.J. Lu [Wed, 15 Jan 2025 10:13:50 +0000 (18:13 +0800)]
ld: Update gld${EMULATION_NAME}_place_orphan for PE/PEP
Similar to ldelf_place_orphan, initialize hold from orig_hold at run-time
in PE and PEP gld${EMULATION_NAME}_place_orphan.
* emultempl/pe.em (orphan_init_done): Make it file scope.
(gld${EMULATION_NAME}_finish): Set orphan_init_done to false for
the object-only output.
(gld${EMULATION_NAME}_place_orphan): Rename hold to orig_hold.
Initialize hold from orig_hold at run-time.
* emultempl/pep.em (orphan_init_done): Make it file scope.
(gld${EMULATION_NAME}_finish): Set orphan_init_done to false for
the object-only output.
(gld${EMULATION_NAME}_place_orphan): Rename hold to orig_hold.
Initialize hold from orig_hold at run-time.
Jan Vrany [Wed, 15 Jan 2025 12:20:06 +0000 (12:20 +0000)]
gdb/testsuite: make gdb.reverse/i386-avx-reverse.exp require also avx2
The test gdb.reverse/i386-avx-reverse.exp requires CPU to have AVX
instructions but it actually also uses AVX2 instructions (like
vpcmpeqd). This caused the test to fail on CPUs that have AVX but not
AVX2.
This commit adds check for AVX2.
Tested on Intel Xeon CPU E3-1265L (no AVX2) and Intel Core i7-1355U
(has AVX2).
Alan Modra [Sat, 11 Jan 2025 05:22:58 +0000 (15:52 +1030)]
elflink.c memory leaks
Many targets leaked parts of the elf_link_hash_table. Fix that by
making _bfd_elf_link_hash_table_init set up hash_table_free correctly,
so that targets that extend elf_link_hash_table without adding
anything that needs freeing, will use _bfd_elf_link_hash_table_free.
* elflink.c (elf_link_add_object_symbols): Always free
nondeflt_vers. Don't return false without freeing.
(_bfd_elf_link_hash_table_init): Set hash_table_free here..
(_bfd_elf_link_hash_table_create): ..rather than here.
(elf_link_swap_symbols_out): Don't free strtab here..
(elf_link_add_object_symbols): ..do so here instead. Don't
omit freeing on some error return paths.
Alan Modra [Sat, 11 Jan 2025 05:18:55 +0000 (15:48 +1030)]
eh-frame memory leaks
The set_loc array attached to eh-frame sec_info isn't freed, and is
used in _bfd_elf_eh_frame_section_offset. Rather than finding a
suitable late stage of linking past any b_e_e_f_s_o use, I decided
this might as well persist until the bfd is closed.
Some memory is freed in _bfd_elf_discard_section_eh_frame_hdr, but
the function isn't always called, so fix that too.
* elf-eh-frame.c (_bfd_elf_parse_eh_frame): bfd_alloc the
set_loc array.
(find_merged_cie): Use bfd_malloc rather than malloc.
(_bfd_elf_discard_section_eh_frame_hdr): Move condition under
which this function does anything except free memory from..
* elflink.c (bfd_elf_discard_info): ..here.
Andrew Burgess [Fri, 3 Nov 2023 21:40:29 +0000 (21:40 +0000)]
gdbserver: convert program_args to a single string
This commit changes how gdbserver stores the inferior arguments from
being a vector of separate arguments into a single string with all of
the arguments combined together.
Making this change might feel a little strange; intuitively it feels
like we would be better off storing the arguments as a vector, but
this change is part of a larger series of work that aims to improve
GDB's inferior argument handling. The full series was posted here:
But asking people to review a 14 patch series in unreasonable, so I'm
instead posting the patches in smaller batches. This patch can stand
alone, and I do think this change makes sense on its own:
First, GDB already stores the inferior arguments as a single string,
so doing this moves gdbserver into line with GDB. The common code
into which gdbserver calls requires the arguments to be a single
string, so currently each target's create_inferior implementation
merged the arguments anyway, so all this commit really does is move
the merging up the call stack, and store the merged result rather than
storing the separate parts.
However, the biggest reason for why this commit is needed, is an issue
with passing arguments from GDB to gdbserver when starting a new
inferior.
Consider:
(gdb) set args $VAR
(gdb) run
...
When using a native target the inferior will see the value of $VAR
expanded by the shell GDB uses to start the inferior. However, if
using an extended-remote target the inferior will see literally $VAR,
the unexpanded name of the variable, the reason for this is that,
although GDB sends '$VAR' to gdbserver, when gdbserver receives this,
it converts this to '\$VAR', which prevents the variable from being
expanded by the shell.
The reason for this is that construct_inferior_arguments escapes all
special shell characters within its arguments, and it is
construct_inferior_arguments that is used to combine the separate
arguments into a single string.
In the future I will change construct_inferior_arguments so that
it can apply different escaping strategies. When this happens we will
want to escape arguments coming from the gdbserver command line
differently than arguments coming from GDB (via a vRun packet), which
means we need to call construct_inferior_arguments earlier, at the
point where we know if the arguments came from the gdbserver command
line, or from the vRun packet.
This argument escaping issue is discussed in PR gdb/28392.
This commit doesn't fix any issues, nor does it change
construct_inferior_arguments to actually do different escaping, that
will all come later. This is purely a restructuring.
There should be no user visible changes after this commit.
Alan Modra [Wed, 15 Jan 2025 08:43:43 +0000 (19:13 +1030)]
PR32560 stack-buffer-overflow at objdump disassemble_bytes
There's always someone pushing the boundaries.
PR 32560
* objdump.c (MAX_INSN_WIDTH): Define.
(insn_width): Make it an unsigned long.
(disassemble_bytes): Use MAX_INSN_WIDTH to size buffer.
(main <OPTION_INSN_WIDTH>): Restrict size of insn_width.
Tom de Vries [Wed, 15 Jan 2025 08:38:18 +0000 (09:38 +0100)]
[gdb/symtab] Require current language before symbol lookups
Test-case gdb.python/py-symbol.exp fails with various target boards, including
fission and gold-gdb-index.
The problem here is that, in this test, the current language is still
unset (i.e., lazy) when the symbol lookup is done. It is eventually
set deep in the lookup -- but this then requires a reentrant symbol
lookup, which fails. (DWARF symbol lookup is not reentrant.)
Fix this by:
- detecting symbol lookup reentrance using an assert, and
- requiring the current language to be set when entering symbol lookup.
Tested on x86_64-linux.
Co-Authored-By: Tom Tromey <tom@tromey.com> Approved-By: Tom Tromey <tom@tromey.com>
PR symtab/32490
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32490
Alan Modra [Wed, 15 Jan 2025 03:57:11 +0000 (14:27 +1030)]
Re: elf: Add GNU_PROPERTY_MEMORY_SEAL gnu property
Don't run tests on targets without required support. Supply an
explicit -z nomemory-seal rather then relying on the harness default,
to lessen confusion for people looking at the test. Don't use numeric
labels for the sake of hppa64*-hpux, and run the tests there. Remove
incorrect comment about source editing. Also, xfail rather than
notarget failing tests with a list of target triples so we check that
the list is correct.
Alan Modra [Wed, 15 Jan 2025 03:02:00 +0000 (13:32 +1030)]
Re: ld: Add --enable-memory-seal configure option
Commit 80dc29527ff9 accidentally removed an assignment to board_flags,
resulting in tcl errors 'can't read "board_flags": no such variable'
on sh4-linux-gnu. Fix that by calling [get_board_flags] in the
condition rather than reinstating the removed line since it seems most
configurations don't have a null STATIC_LDFLAGS. Do the same in
another similar test too.
Tom Tromey [Sat, 11 Jan 2025 18:35:15 +0000 (11:35 -0700)]
Use bool in decode_line_2_item
This changes decode_line_2_item::selected to bool. There was no
benefit to keeping this as a bitfield, so I removed that. Note that
the constructor already uses bool here.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
In that commit, linetables were made independent from the objfile, which
requires objfile->section_offsets to be initialized. However, section_offsets
were never initialized in objfiles generated by GDB's JIT Interface
with custom jit-readers, leading to GDB crashes when stepping into JITed code
blocks with the following command already executed:
jit-reader-load libmygdbjitreader.so
This patch fixes the issue by initializing the minimum section_offsets required
for linetable parsing procedures.
A minimal test is included. The test sets up some very simple line
table information, which is enough to trigger the bug. However, the
line table information is crafted such that none of the line table
entries will end up being displayed in GDB's output when the test is
run, as such, none of the expected output actually changes.
It might be nice in the future to extend some of the jit tests to
actually test hitting line table entries added via the jit reader.
gdb/record: add support for AVX floating point arithmetic instructions
This commit adds support for the following types of instructions
relating to floating poitn values: add, mul, sub, min, div, max.
These are supported with packed or single values, and single or double
precision.
Some of the instructions had opcode clashes, however, considering the
mechanics of recording the registers is the same on both instructions,
this is just marked with a comment.
gdb/record: add support for floating point vunpck instructions
This commit adds support for the AVX instructions vunpck[l|h][ps|pd]
instructions, which was pretty straightforward.
This commit also fixes a mistake in the test, where "record stop" was
used after the recording was already stopped, if it failed during
vpunpck_test recording. It also improved the documentation at the start
of the relevant .c function.
gdb/record: add support for floating point vmov instructions
This commit updates GDB's record-full to be able to record vmov[ss|sd]
and vmov [u|a] [ps|pd] AVX instructions, and tests for them.
Unlike the vmovdq[u|a] instructions, the aligned and unalgined versions
of vmov?[ps|pd] have different opcodes. The mechanics of recording them
is the same, but the aligned version has opcodes 0x28 and 0x29, while
the unaligned has the same opcode as vmov[ss|sd] instruction, 0x10 and
0x11.
The GNU_PROPERTY_MEMORY_SEAL gnu property is a way to mark binaries
to be memory sealed by the loader, to avoid further changes of
PT_LOAD segments (such as unmapping or change permission flags).
This is done along with Linux kernel (the mseal syscall [1]), and
C runtime supports to instruct the kernel on the correct time during
program startup (for instance, after RELRO handling). This support
is added along the glibc support to handle the new gnu property [2].
This is a opt-in security features, like other security hardening
ones like NX-stack or RELRO.
The new property is ignored if present on ET_REL objects, and only
added on ET_EXEC/ET_DYN if the linker option is used. A gnu property
is used instead of DT_FLAGS_1 flag to allow memory sealing to work
with ET_EXEC without PT_DYNAMIC support (at least on glibc some ports
still do no support static-pie).
H.J. Lu [Tue, 14 Jan 2025 01:09:28 +0000 (09:09 +0800)]
ld: Update mixed LTO and non-LTO relocatable output tests
Since mixed LTO and non-LTO relocatable output is only supported on ELF
platforms, limit these tests to ELF targets. Since powerpc64 elfv1
defines a function symbol on its procedure descriptor, which is in a
data section, rather than on the code for that function, allow both D
and T for nm test on mixed object.
* testsuite/ld-plugin/lto.exp: Limits mixed LTO and non-LTO
relocatable output tests to ELF targets. Allow both D and T for
nm test on mixed object.
Matthieu Longo [Thu, 21 Nov 2024 18:44:22 +0000 (18:44 +0000)]
aarch64 SFrame: skip with warning new CFI directive used with pauth_lr
Today, SFrame v2 specification does not describe how to encode the
information corresponding to the PAuth_LR PAC signing method (it only
supports PAuth PAC signing method).
SFrame v3 specification should hopefully specify it.
In the meantime, if the GNU assembler finds .cfi_negate_ra_state_with_pc
and --gsframe is specified, it will output a warning to the user and
will fail to generate the FDE entry.
A new SFrame test for .cfi_negate_ra_state_with_pc is also added to
reflect this issue.
Matthieu Longo [Mon, 25 Nov 2024 12:17:56 +0000 (12:17 +0000)]
aarch64 DWARF: add new CFI directive for PAuth_LR
This patch adds a new CFI directive (cfi_negate_ra_state_with_pc) which
set an additional bit in the RA state to inform that RA was signed with
SP but also PC as an additional diversifier.
RA state | Description
0b00 | Return address not signed (default if no cfi_negate_ra_state*)
0b01 | Return address signed with SP (cfi_negate_ra_state)
0b10 | Invalid state
0b11 | Return address signed with SP+PC (cfi_negate_ra_state_with_pc)
Approved-by: Indu Bhagat <indu.bhagat@oracle.com> Approved-by: Jan Beulich <jbeulich@suse.com>
Matthieu Longo [Thu, 21 Nov 2024 18:40:41 +0000 (18:40 +0000)]
aarch64 SFrame: use preferred CFI directive for AArch64 PAC
ARMv8.3 addded support for a new security feature named Pointer
Authentication. Support for this feature in SFrame already exists.
In GCC 14 and older, the Sparc DWARF extension .cfi_gnu_window_save
is emitted instead of .cfi_negate_ra_state.
GCC 15 fixed this issue, but this behavior is preserved for backward
compatibility.
The existing sframe test for AArch64 PAC was using .cfi_gnu_window_save.
This patch replaces this CFI in the existing test by the preferred one,
and adds a new test to check for backward compatibility when using
.cfi_gnu_window_save.
Matthieu Longo [Thu, 21 Nov 2024 18:44:07 +0000 (18:44 +0000)]
aarch64: make explicit that CFI gnu_window_save is for Sparc, not AArch64
- add a detailed comment when parsing DW_CFA_GNU_window_save in SFrame to
explain why we are checking whether the targeted architecture is AArch64,
whereas this CFI is a Sparc extension.
- replace .cfi_gnu_window_save by .cfi_negate_ra_state in existing AArch64
DWARF tests as this is the preferred directive since GCC 15.
- add a new AArch64 test to check backward compatibility with old GCC
versions that emits .cfi_gnu_window_save.
Approved-by: Indu Bhagat <indu.bhagat@oracle.com> Approved-by: Richard Earnshaw <richard.earnshaw@arm.com>
gdbserver: remove handling of the 'L' tracepoint action
Now that static tracepoint support is removed from gdbserver, it makes
sense to remove handling of the 'L' tracepoint action, too. The code
that checks received actions already has a default case that tolerates
unrecognized actions:
gdbserver: remove the static_tracepoint enum value
As a continuation of the previous patches that remove UST from
gdbserver, remove the `static_tracepoint` enum value from
`tracepoint_type` and all the associated code.
Now that the last use of `write_e_static_tracepoints_not_supported`
is gone, also remove that function.
The handling of the 'S' option, where the `static_tracepoint` enum
value was being used, is removed completely, because recognizing that
option makes sense only when static tracepoint support is announced.
This patch is easier to view with "git show -w".
Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdbserver: do not announce static tracepoint support
Remove the announcement that `qXfer:statictrace:read` and
`StaticTracepoints` are supported. Associated to this, remove the
handling of "qTfSTM", "qTsSTM", and "qTSTMat" packets and the
qXfer:statictrace:read handling.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdbserver: remove UST (static tracepoint) support (part 2)
With the removal of UST, the `in_process_agent_supports_ust` query
would essentially always be false. Remove the function and adjust
the uses, comments, and warning/error messages.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdbserver: remove UST (static tracepoint) support (part 1)
UST support in gdbserver is substantially outdated. Simon says:
...[having HAVE_UST defined] never happens nowadays because it used
a version of lttng-ust that has been deprecated for a loooong time
(the 0.x series). So everything in HAVE_UST just bitrots. It might
be possible to update all this code to use lttng-ust 2.x (1.x never
existed), but I don't think it's going to happen unless somebody
specifically asks for it. I would suggest removing support for UST
from gdbserver. ...If we ever want to resurrect the support for UST
and port to 2.x, we can get the code from the git history.
This patch removes the support, mostly mechanically by deleting code
guarded by `#ifdef HAVE_UST`. After these removals, `struct
static_tracepoint_ctx` becomes unused. So, remove it, too.
The following patches remove more code.
Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb, doc: mention the 'S' option for the QTDP packet
I noticed that gdbserver accepts an 'S' option for the QTDP packet to
create a static tracepoint, but this is not mentioned in the document.
Update the document.
I first thought about updating the argument as `[:Flen|:S]`, but then
opted for `[:Flen][:S]`. Although it is odd that ':F' and ':S' are
allowed to co-exist, the implementation at the gdbserver side allows
this and handles the packet arguments so that the right-most
positioned ':F' or ':S' overwrites the final tracepoint type. When
the documentation is missing, the implementation usually determines
the behavior.
Haochen Jiang [Tue, 14 Jan 2025 02:30:44 +0000 (10:30 +0800)]
x86: Remove "NE" in mnemonics for convert insns related to AI data types
NE is quite ambiguous and misleading in mnemonics since it should be
Rounding to Nearest Even, but could be mis-interpretated to No
Exception.
Under its correct meaning, which means rounding, it should only be used
in down-convert, since up-convert is always exact for normal values
It could be difficult to judge which kind of convert it is if we have
the convert between same bit float types.
For all AI data types including BF16 and FP8, the default rounding is
Rounding to Nearest Even. So removing them in mnemonics would reduce
burden for programmers to consider whether it should be added or not
in mnemonics and stop the ambiguous meaning on "NE" itself.
If the convert itself is using a rounding mode other than RNE, it would
be explicitly added in mnemonics (e.g., Long used "T" and "BIAS"
introduced in AVX10.2).
Haochen Jiang [Tue, 14 Jan 2025 02:30:43 +0000 (10:30 +0800)]
x86: Rename VCOMSBF16 to VCOMISBF16
The functionality for VCOMSBF16 is exactly the same as the VCOMISD/S/H.
The only difference is the bf16 type. Thus, it should be VCOMISBF16.
This patch would fix that.
Haochen Jiang [Tue, 14 Jan 2025 02:30:42 +0000 (10:30 +0800)]
x86: Remove "P" and "NE" in mnemonics for BF16 arithmetic insns
Since the bf16 is an AI data types, it will be implicitly packed. Thus,
"P" (for packed) is omitted in mnemonics from its introduction. AVX10.2
BF16 arithmetic insns are introduced with "P" in mnemonics with packed.
This patch will remove them for consistency.
NE is quite ambiguous and misleading in mnemonics since it should be
Rounding to Nearest Even, but could be mis-interpretated to No
Exception. While AI data types like BF16 and FP8 are using Rounding to
Nearest Even as default rounding modes. There is no need to use the
ambiguous mnemonics in AVX10.2 insns. This patch will also remove them.
For convert insns, it will be handled in the upcoming patch.
Hu, Lin1 [Tue, 14 Jan 2025 02:30:38 +0000 (10:30 +0800)]
Support Intel AMX-MOVRS
This patch will support AMX-MOVRS feature. Unlike all the other
AMX insns in vector space where we pass vex_len_table before
vex_w_table, we first pass vex_w_table for tileloaddrs[,t1] to
align with the order in EVEX space. The reason why we first pass
vex_w_table in EVEX space is due to AMX-AVX512, where tcvtrowd2ps
and tilemovrow with r32 shares the same opcode with tileloaddrs[,t1].
All of them have evex.w = 0 but with different evex.length. Re-doing
that shortly is not ideal.
APX_F extension is also implemented in this patch. The encoding will
be:
- EVEX.128.NP/66.MAP5.W0 F8/F9 !(11):rrr:100 for
T2RPNTLVW[Z0,Z1]RS[,T1] with NF=0.
- EVEX.128.F2/66.0F38.W0 4A !(11):rrr:100 FOR TILELOADDRS[,T1] with
NF=0.
For APX_F extension, we could not use APX_F(AMX_TRANSPOSE&AMX_MOVRS)
since the transformation could not be done. Instead, we will use
AMX_TRANSPOSE & APX_F(AMX_MOVRS). Thus, we should set AMX_TRANSPOSE
for "any" for cpu_flags in assembler. Since it will only affect the
cpu_flags_match, handle that there.
gas/ChangeLog:
* config/tc-i386.c (cpu_arch): Add amx_movrs.
(cpu_flags_match): Set any bitfield for multiple cpuid
enabled insns.
* doc/c-i386.texi: Document .amx_movrs.
* testsuite/gas/i386/x86-64.exp: Run AMX-MOVRS tests.
* testsuite/gas/i386/x86-64-amx-movrs-intel.d: New test.
* testsuite/gas/i386/x86-64-amx-movrs-inval.l: Ditto.
* testsuite/gas/i386/x86-64-amx-movrs-inval.s: Ditto.
* testsuite/gas/i386/x86-64-amx-movrs.d: Ditto.
* testsuite/gas/i386/x86-64-amx-movrs.s: Ditto.
Hu, Lin1 [Tue, 14 Jan 2025 02:30:36 +0000 (10:30 +0800)]
Support Intel MOVRS
This patch focus on supporting MOVRS ISA. We could take this full ISA
as four part: PREFETCHRST2, MOVRS, MOVRS APX_F extension and MOVRS AVX10.2
extension.
The APX_F extension for MOVRS will be:
- EVEX.LLZ.NP.MAP4.WIG 8A !(11):rrr:bbb for r8/m8 with NF=0 and
ND=0
- EVEX.LLZ.NP/66.MAP4.SCALABLE 8B !(11):rrr:bbb for rv/mv with NF=0
and ND=0
We did not merge the table together for APX_F since there is an explicit
x64 for movrs insn. The current APX_F() did not support the combination
between CPUIDs. Also, the space is different for legacy and apx_f forms.
Haochen Jiang [Tue, 14 Jan 2025 02:30:32 +0000 (10:30 +0800)]
x86: Remove mod_table pass for MVexSIBMEM
When using MVexSIBMEM, OP_M will help check modrm. Thus, no need
to pass mod_table.
Since we have OP_M do the work, from now on, mod_table[] should
not gain any new entries, unless both slots of them are populated,
e.g., different modrm leading to different insns could not be
combined (Bad_Opcode is not the case since OP_M could handle that).
opcodes/ChangeLog:
* i386-dis.c: Remove mod_table pass for MVexSIBMEM.
H.J. Lu [Mon, 4 Nov 2013 17:17:45 +0000 (09:17 -0800)]
ld: Add LTO and none-LTO output support for ld -r
Link with mixed IR/non-IR objects
* 2 kinds of object files
o non-IR object file has
* non-IR sections
o IR object file has
* IR sections
* non-IR sections
* The output of "ld -r" with mixed IR/non-IR objects should work with:
o Compilers/linkers with IR support.
o Compilers/linkers without IR support.
* Add the mixed object file which has
o IR sections
o non-IR sections:
* Object codes from IR sections.
* Object codes from non-IR object files.
o Object-only section:
* With section name ".gnu_object_only" and SHT_GNU_OBJECT_ONLY type
on ELF:
https://gitlab.com/x86-psABIs/Linux-ABI
#define SHT_GNU_OBJECT_ONLY 0x6ffffff8 /* Object only */
* Contain non-IR object file.
* Input is discarded after link.
* Linker action:
o Classify each input object file:
* If there is a ".gnu_object_only" section, it is a mixed object file.
* If there is a IR section, it is an IR object file.
* Otherwise, it is a non-IR object file.
o Relocatable non-IR link:
* Prepare for an object-only output.
* Prepare for a regular output.
* For each mixed object file:
* Add IR and non-IR sections to the regular output.
* For object-only section:
* Extract object only file.
* Add it to the object-only output.
* Discard object-only section.
* For each IR object file:
* Add IR and non-IR sections to the regular output.
* For each non-IR object file:
* Add non-IR sections to the regular output.
* Add non-IR sections to the object-only output.
* Final output:
* If there are IR objects, non-IR objects and the object-only
output isn't empty:
* Put the object-only output into the object-only section.
* Add the object-only section to the regular output.
* Remove the object-only output.
o Normal link and relocatable IR link:
* Prepare for output.
* IR link:
* For each mixed object file:
* Compile and add IR sections to the output.
* Discard non-IR sections.
* Object-only section:
* Extract object only file.
* Add it to the output.
* Discard object-only section.
* For each IR object file:
* Compile and add IR sections to the output.
* Discard non-IR sections.
* For each non-IR object file:
* Add non-IR sections to the output.
* Non-IR link:
* For each mixed object file:
* Add non-IR sections to the output.
* Discard IR sections and object-only section.
* For each IR object file:
* Add non-IR sections to the output.
* Discard IR sections.
* For each non-IR object file:
* Add non-IR sections to the output.
This is useful for Linux kernel build with LTO.
bfd/
PR ld/12291
PR ld/12430
PR ld/13298
* bfd.c (bfd_lto_object_type): Add lto_mixed_object.
(bfd): Add object_only_section.
(bfd_group_signature): New.
* elf.c (special_sections_g): Add .gnu_object_only.
* format.c: Include "plugin-api.h" and "plugin.h" if
BFD_SUPPORTS_PLUGINS is defined.
(bfd_set_lto_type): Set type to lto_mixed_object for
GNU_OBJECT_ONLY_SECTION_NAME section.
(bfd_check_format_matches): Don't check the plugin target twice
if the plugin target is explicitly specified.
* opncls.c (bfd_extract_object_only_section): New.
* plugin.c (bfd_plugin_fake_text_section): New.
(bfd_plugin_fake_data_section): Likewise.
(bfd_plugin_fake_bss_section): Likewise.
(bfd_plugin_fake_common_section): Likewise.
(bfd_plugin_get_symbols_in_object_only): Likewise.
* plugin.c (add_symbols): Call
bfd_plugin_get_symbols_in_object_only and count
plugin_data->object_only_nsyms.
(bfd_plugin_get_symtab_upper_bound): Count
plugin_data->object_only_nsyms.
bfd_plugin_get_symbols_in_object_only and add symbols from
object only section.
(bfd_plugin_canonicalize_symtab): Remove fake_section,
fake_data_section, fake_bss_section and fake_common_section.
Set udata.p to NULL. Use bfd_plugin_fake_text_section,
bfd_plugin_fake_data_section, bfd_plugin_fake_bss_section and
bfd_plugin_fake_common_section.
Set udata.p to NULL.
* plugin.h (plugin_data_struct): Add object_only_nsyms and
object_only_syms.
* section.c (GNU_OBJECT_ONLY_SECTION_NAME): New.
* bfd-in2.h: Regenerated.
In AIX a recent commit caused a build break with the error as shown below.
In file included from python/py-color.h:23,
from python/python.c:39:
python/python-internal.h:86:10: fatal error: Python.h: No such file or directory
86 | #include <Python.h>
In AIX, we run builds with and without python for our internal CI's.
A feature development made by the recent commit https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=6447969d0ac774b6dec0f95a0d3d27c27d158690
missed to guard Python.h in HAVE_PYTHON macro.
Tom Tromey [Mon, 6 Jan 2025 14:45:33 +0000 (07:45 -0700)]
Handle case where DAP line can be None
A comment in bugzilla pointed out a bug in my earlier patch to handle
the DAP "linesStartAt1" setting. In particular, in the backtrace
code, "line" can be None, which would lead to an exception from
export_line.
Jan Beulich [Mon, 13 Jan 2025 12:32:19 +0000 (13:32 +0100)]
bfd/ELF: slightly "better" file alignment for object files
PR gas/32435
Commit 1f1b5e506bf0 ("bfd/ELF: restrict file alignment for object
files") caused an issue in the Linux kernels modpost utility, which was
building upon .rodata sections to be 4-byte aligned in the file when
they have 4-byte alignment. While we don't want to revert back to
original behavior, apply the same alignment "capping" as done originally
in two other places also for "ordinary" sections.
Simon Marchi [Mon, 13 Jan 2025 03:29:51 +0000 (22:29 -0500)]
gdb/jit: use correctly-sized array view in deprecated_frame_register_read call
Commit 7fcdec025c05 ("GDB: Use gdb::array_view for buffers used in
register reading and unwinding") introduces a regression in
gdb.base/jit-reader.exp:
This GDB supports auto-downloading debuginfo from the following URLs:
<https://debuginfod.archlinux.org>
Enable debuginfod for this session? (y or [n]) [answered N; input not from terminal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1".
Program received signal SIGTRAP, Trace/breakpoint trap.
Recursive internal problem.
The "Recusive internal problem" part is not good, but it's not the point
of this patch. It still means we hit an internal error.
The stack trace is:
#0 internal_error_loc (file=0x55555ebefb20 "/home/simark/src/binutils-gdb/gdb/frame.c", line=1207, fmt=0x55555ebef500 "%s: Assertion `%s' failed.") at /home/simark/src/binutils-gdb/gdbsupport/errors.cc:53
#1 0x0000555561604d83 in frame_register_unwind (next_frame=..., regnum=16, optimizedp=0x7ffff12e5a20, unavailablep=0x7ffff12e5a30, lvalp=0x7ffff12e5a40, addrp=0x7ffff12e5a60, realnump=0x7ffff12e5a50, buffer=...)
at /home/simark/src/binutils-gdb/gdb/frame.c:1207
#2 0x0000555561608334 in deprecated_frame_register_read (frame=..., regnum=16, myaddr=...) at /home/simark/src/binutils-gdb/gdb/frame.c:1496
#3 0x0000555561a74259 in jit_unwind_reg_get_impl (cb=0x7ffff1049ca0, regnum=16) at /home/simark/src/binutils-gdb/gdb/jit.c:988
#4 0x00007fffd26e634e in read_register (callbacks=0x7ffff1049ca0, dw_reg=16, value=0x7fffffffb4c8) at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jit-reader.c:100
#5 0x00007fffd26e645f in unwind_frame (self=0x50400000ac10, cbs=0x7ffff1049ca0) at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jit-reader.c:143
#6 0x0000555561a74a12 in jit_frame_sniffer (self=0x55556374d040 <jit_frame_unwind>, this_frame=..., cache=0x5210002905f8) at /home/simark/src/binutils-gdb/gdb/jit.c:1042
#7 0x00005555615f499e in frame_unwind_try_unwinder (this_frame=..., this_cache=0x5210002905f8, unwinder=0x55556374d040 <jit_frame_unwind>) at /home/simark/src/binutils-gdb/gdb/frame-unwind.c:138
#8 0x00005555615f512c in frame_unwind_find_by_frame (this_frame=..., this_cache=0x5210002905f8) at /home/simark/src/binutils-gdb/gdb/frame-unwind.c:209
#9 0x00005555616178d0 in get_frame_type (frame=...) at /home/simark/src/binutils-gdb/gdb/frame.c:2996
#10 0x000055556282db03 in do_print_frame_info (uiout=0x511000027500, fp_opts=..., frame=..., print_level=0, print_what=SRC_AND_LOC, print_args=1, set_current_sal=1) at /home/simark/src/binutils-gdb/gdb/stack.c:1033
The problem is that function `jit_unwind_reg_get_impl` passes field
`gdb_reg_value::value`, a gdb_byte array of 1 element (used as a
flexible array member), as the array view parameter of
`deprecated_frame_register_read`. This results in an array view of size
1. The assertion in `frame_register_unwind` that verifies the passed in
buffer is larger enough to hold the unwound register value then fails.
Fix this by explicitly creating an array view of the right size.
Andrei Pikas [Sat, 5 Oct 2024 19:27:44 +0000 (22:27 +0300)]
Add an option with a color type.
Colors can be specified as "none" for terminal's default color, as a name of
one of the eight standard colors of ISO/IEC 6429 "black", "red", "green", etc.,
as an RGB hexadecimal tripplet #RRGGBB for 24-bit TrueColor, or as an
integer from 0 to 255. Integers 0 to 7 are the synonyms for the standard
colors. Integers 8-15 are used for the so-called bright colors from the
aixterm extended 16-color palette. Integers 16-255 are the indexes into xterm
extended 256-color palette (usually 6x6x6 cube plus gray ramp). In
general, 256-color palette is terminal dependent and sometimes can be
changed with OSC 4 sequences, e.g. "\033]4;1;rgb:00/FF/00\033\\".
It is the responsibility of the user to verify that the terminal supports
the specified colors.
PATCH v5 changes: documentation fixed.
PATCH v6 changes: documentation fixed.
PATCH v7 changes: rebase onto master and fixes after review.
PATCH v8 changes: fixes after review.
Tom Tromey [Wed, 8 Jan 2025 01:10:19 +0000 (18:10 -0700)]
Use std::vector in linespec_state
This changes linespec_state to use a std::vector, and changes
linespec_canonical_name to use std::string. This removes some manual
memory management, including some odd cleanup code in in
decode_line_full.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Wed, 8 Jan 2025 01:03:28 +0000 (18:03 -0700)]
Use gdb::unordered_set in linespec_state
This patch changes linespec_state to use gdb::unordered_set. This
simplifies the code a little and removes some manual management. It
also replaces address_entry with a std::pair, which simplifies the
code even more; and since this is a private type, IMO it doesn't
reduce readability at all.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
GDB: Use gdb::array_view for buffers used in register reading and unwinding
This allows checking the size of the given buffer. Changes
frame_register_unwind (), frame_unwind_register (), get_frame_register ()
and deprecated_frame_register_read ().
As pointed out by Baris, in the case of MIPS target code this is best
done by changing a couple of alloca-based buffers in
mips_read_fp_register_single and mips_print_fp_register to
gdb::byte_vector instances.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
aarch64: Add support for FEAT_SVE_B16B16 min and max instructions.
This patch adds support for SME Z-targeting multi-vector non-widening
BFloat16 instructions, under tick FEAT_SVE_B16B16 and command line flag
"+sve-b16b16+sme2".
Also the test files related to FEAT_SVE_B16B16 (+sme2) are prefixed with
sve-b16b16-sme2*.
eg: sve-b16b16-sme2-1.s, sve-b16b16-sme2-1.d.
The spec for this feature and instructions is availabe here [1]:
[1]: https://developer.arm.com/documentation/ddi0602/2024-06/SME-Instructions?lang=en