116093 Commits

Author SHA1 Message Date
Frederic Cambus
73b22419ed Add support to readelf for the PT_OPENBSD_NOBTCFI segment type. 2023-09-28 13:39:01 +01:00
Nick Clifton
6136093c0d Fix: nm: SEGV on unknow address at nm.c:718 in print_symname
PR 30886 * elf-bfd.h (struct elf_obj_tdata): Add dt_strsz field.
  * elf.c (_bfd_elf_get_dynamic_symbols): Add a NUL byte at the end of the string table. Initialise the dt_strsz field. (_bfd_elf_slurp_version_tables): Only free the contents if they were malloc'ed. Add checks before setting string pointers in the dt_strtab buffer.
2023-09-28 12:37:59 +01:00
Tom de Vries
2654f77d14 [gdb/testsuite] Add nopie to gdb.base/unwind-on-each-insn-amd64-2.exp
When running test-case gdb.base/unwind-on-each-insn-amd64-2.exp with target
board unix/-fPIE/-pie, I run into:
...
gdb compile failed, ld: unwind-on-each-insn-amd64-21.o: relocation \
  R_X86_64_32S against `.text' can not be used when making a PIE object; \
  recompile with -fPIE
ld: failed to set dynamic section sizes: bad value
...

Fix this by hardcoding nopie in the test-case, and for good measure in the
other test-cases that source unwind-on-each-insn.exp.tcl and use a .s file.

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
2023-09-28 09:47:36 +02:00
GDB Administrator
be92e53428 Automatic date update in version.in 2023-09-28 00:00:33 +00:00
Aaron Merey
28bc495137 config/debuginfod.m4: Add check for libdebuginfod 0.188
Add check for libdebuginfod 0.188 in AC_DEBUGINFOD and if found
define macro HAVE_LIBDEBUGINFOD_FIND_SECTION.

This macro indicates support for downloading ELF sections from
debuginfod servers.
2023-09-27 15:11:13 -04:00
Nick Clifton
4befded43f nm: heap-buffer-overflow at elfcode.h:1507 in bfd_elf64_slurp_symbol_table
PR 30885
  * elfcode.h (elf_slurp_symbol_table): Compute the symcount for non dynamic symbols in the same way as _bfd_elf_get_symtab_upper_bound.
2023-09-27 16:09:06 +01:00
Jan Beulich
58bceb1827 x86: prefer VEX encodings over EVEX ones when possible
AVX-* features / insns paralleling earlier introduced AVX512* ones can
be encoded more compactly when the respective feature was explicitly
enabled by the user.
2023-09-27 16:53:09 +02:00
Jan Beulich
fb2637073b x86: drop cpu_arch_tune_flags
Apparently from its introduction the variable was only ever written (the
only read is merely to determine whether to write it with another value).
(Since, due to the need to re-indent, the adjacent lines setting
cpu_arch_tune need touching anyway, switch to using PREOCESSOR_*
constants where applicable, to make more obvious what the resulting
state is going to be.)
2023-09-27 16:52:08 +02:00
Jan Beulich
bd483d213a x86: correct cpu_arch_isa_flags maintenance
These may not be set from a value derived from cpu_arch_flags: That
starts with (almost) all functionality enabled, while cpu_arch_isa_flags
is supposed to track features that were explicitly enabled (and perhaps
later disabled) by the user.

To avoid needing to do any such adjustment in two places (each),
introduce helper functions used by both command line handling and
directive processing.
2023-09-27 16:51:46 +02:00
Pedro Alves
aeb889f580 Adjust gdb.thread/pthreads.exp for Cygwin
The Cygwin runtime spawns a few extra threads, so using hardcoded
thread numbers in tests rarely works correctly.  Thankfully, this
testcase already records the ids of the important threads in globals.
It just so happens that they are not used in a few tests.  This commit
fixes that.

With this, the test passes cleanly on Cygwin [1].  Still passes cleanly on
x86-64 GNU/Linux.

[1] - with system GDB.  Upstream GDB is missing a couple patches
Cygwin carries downstream.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I01bf71fcb44ceddea8bd16b933b10b964749a6af
2023-09-27 15:28:40 +01:00
Pedro Alves
b572643722 In gdb.threads/pthreads.c, handle pthread_attr_setscope ENOTSUP
On Cygwin, I see:

 (gdb) PASS: gdb.threads/pthreads.exp: break thread1
 continue
 Continuing.
 pthread_attr_setscope 1: Not supported (134)
 [Thread 3732.0x265c exited with code 1]
 [Thread 3732.0x2834 exited with code 1]
 [Thread 3732.0x2690 exited with code 1]

 Program terminated with signal SIGHUP, Hangup.
 The program no longer exists.
 (gdb) FAIL: gdb.threads/pthreads.exp: Continue to creation of first thread

 ... and then a set of cascading failures.

Fix this by treating ENOTSUP the same way as if PTHREAD_SCOPE_SYSTEM
were not defined.  I.e., ignore ENOTSUP errors, and proceed with
testing.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: Iea68ff8b9937570726154f36610c48ef96101871
2023-09-27 15:28:40 +01:00
Pedro Alves
f3e4716cc5 Fix gdb.threads/pthreads.exp error handling/printing
On Cygwin, I noticed:

 (gdb) PASS: gdb.threads/pthreads.exp: break thread1
 continue
 Continuing.
 pthread_attr_setscope 1: No error
 [Thread 8732.0x28f8 exited with code 1]
 [Thread 8732.0xb50 exited with code 1]
 [Thread 8732.0x17f8 exited with code 1]

 Program terminated with signal SIGHUP, Hangup.
 The program no longer exists.
 (gdb) FAIL: gdb.threads/pthreads.exp: Continue to creation of first thread

Note "No error" in "pthread_attr_setscope 1: No error".  That is a bug
in the test.  It is using perror, but that prints errno, while the
pthread functions return the error directly.  Fix all cases of the
same problem, by adding a new print_error function and using it.

We now get:

  ...
  pthread_attr_setscope 1: Not supported (134)
  ...

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I972ebc931b157bc0f9084e6ecd8916a5e39238f5
2023-09-27 15:28:39 +01:00
Pedro Alves
ed11fb37b3 Fix gdb.threads/pthreads.c formatting
Just some GNU formatting fixes throughout.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: Ie851e3815b839e57898263896db0ba8ddfefe09e
2023-09-27 15:28:39 +01:00
Pedro Alves
3c3aa8bfc2 gdb.threads/pthreads.c, K&R -> ANSI function style
gdb.threads/pthreads.c is declaring functions with old K&R style.
This commit converts them to ANSI style.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I1ce007c67bb4ab1e49248c014c7881e46634f8f8
2023-09-27 15:28:39 +01:00
Neal Frager
a4045fdf2e opcodes: microblaze: Add wdc.ext.clear and wdc.ext.flush insns 2023-09-27 14:47:01 +01:00
Hsinyuan Xavier
193327db9f Fix: Output section type does not been applied to section forced output by . = . assignment
PR 30875
  * ldlang.c (get_os_init_flag): New function. (exp_init_os, map_input_to_output_sections): Use it.
2023-09-27 13:21:43 +01:00
Jan Beulich
da0784f961 x86: fold FMA VEX and EVEX templates
Following the folding of some generic AVX/AVX2 templates with their
AVX512F counterpart ones, do this for FMA ones as well, requiring one
further adjustment to cpu_flags_match().
2023-09-27 14:16:09 +02:00
Jan Beulich
f94f390ef8 x86: fold VAES/VPCLMULQDQ VEX and EVEX templates
Following the folding of some generic AVX/AVX2 templates with their
AVX512F counterpart ones, do this for VAES and VPCLMULQDQ ones as well.
2023-09-27 14:15:44 +02:00
Jan Beulich
a6f3add002 x86: fold certain VEX and EVEX templates
In anticipation of APX introduce logic to reduce the number of templates
we have now, allowing to limit some the number of ones we then need to
gain.

The fundamental requirements are that
- attributes be compatible, which specifically means VexW needs to be
  the same in the templates (which often isn't the case, for VEX
  encodings having far more WIG tha, EVEX ones),
- the EVEX form being AVX512F (with or without AVX512VL), not any of its
  extensions (the same will then be required for APX - it'll need to be
  APX_F).

Note that in check_register() there's now a redundant zmm check. Since
this logic will need revisiting for APX anyway, I'd like to keep it that
way for now. (Similarly a couple of if()-s which could be folded are
kept separate, to reduce code churn when adding APX support.)
2023-09-27 14:15:19 +02:00
Jan Beulich
f586e3409b x86: tighten .insn SAE and broadcast checking
SAE / embedded rounding are invalid when there's the memory operand, as
the bit encoding this specifies broadcast in that case.

Broadcast needs to be specified on the memory operand.
2023-09-27 10:54:23 +02:00
Jan Beulich
f79d55e124 x86-64: REX.W overrides DATA_PREFIX
REX.W needs to be respected when immediate size and relocation type are
determined.
2023-09-27 10:53:59 +02:00
Jan Beulich
fb1c10585e x86-64: fix suffix-less PUSH of symbol address
PR gas/30856

In 5cc007751cdb ("x86: further adjust extend-to-32bit-address
conditions") I neglected the case of PUSH, which is the only insn
allowing (proper) symbol addresses to be used as immediates (not
displacements, like CALL/JMP) in the absence of any register operands.
Since it defaults to 64-bit operand size, guessing an L suffix is wrong
there.
2023-09-27 10:53:38 +02:00
Sam James
df940f8bb3 gdb: Fix an ODR warning with byacc with GDB_YY_REMAP
With byacc, we get an ODR warning with YYSTACKDATA between ada-exp.c.tmp
and c-exp.c.tmp. Just include it in the list of symbols we rename.

PR gdb/30839

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30839
Approved-By: Tom de Vries <tdevries@suse.de>
Copyright-paperwork-exempt: yes
2023-09-27 08:35:13 +01:00
mengqinggang
f07dd5f7dd Add support for "pcaddi rd, symbol"
Add a macro pcaddi instruction to support "pcaddi rd, symbol".

pcaddi has a 20-bit signed immediate, it can address a +/- 2MB pc relative
address, and the address should be 4-byte aligned.
2023-09-27 15:07:51 +08:00
GDB Administrator
5f22c5abdc Automatic date update in version.in 2023-09-27 00:00:32 +00:00
Simon Marchi
ea186080fe gdb/testsuite: add xfail for gdb/29965 in gdb.threads/process-exit-status-is-leader-exit-status.exp
Bug 29965 shows on a Linux kernel >= 6.1, that test fails consistently
with:

    FAIL: gdb.threads/process-exit-status-is-leader-exit-status.exp: iteration=0: continue (the program exited)
    ...
    FAIL: gdb.threads/process-exit-status-is-leader-exit-status.exp: iteration=9: continue (the program exited)

This is due to a change in Linux kernel behavior [1] that affects
exactly what this test tests.  That is, if multiple threads (including
the leader) call SYS_exit, the exit status of the process should be the
exit status of the leader.  After that change in the kernel, it is no
longer the case.

Add an xfail in the test, based on the Linux kernel version.  The goal
is that if a regression is introduced in GDB regarding this feature, it
should be caught if running on an older kernel where the behavior was
consistent.

[1] https://bugzilla.suse.com/show_bug.cgi?id=1206926

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29965
Change-Id: If6ab7171c92bfc1a3b961c7179e26611773969eb
Approved-By: Tom de Vries <tdevries@suse.de>
2023-09-26 14:20:07 -04:00
Tom de Vries
9373a4b891 [gdb/testsuite] Fix gdb.ada/mi_task_arg.exp with newer gcc
When running test-case gdb.ada/mi_task_arg.exp on openSUSE Tumbleweed using
gcc 13.2.1, I run into (layout adapted for readability):
...
-stack-list-arguments 1^M
^done,stack-args=[
  frame={level="0",args=[]},
  frame={level="1",args=[{name="<_task>",value="0x464820"},
                         {name="<_taskL>",value="129"}]},
  frame={level="2",args=[{name="self_id",value="0x464840"}]},
  frame={level="3",args=[]},
  frame={level="4",args=[]}
]^M
(gdb) ^M
FAIL: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 (unexpected output)
...

On openSUSE Leap 15.4 with gcc 7.5.0 I get instead:
...
-stack-list-arguments 1^M
^done,stack-args=[
  frame={level="0",args=[]},
  frame={level="1",args=[{name="<_task>",value="0x444830"}]},
  frame={level="2",args=[{name="self_id",value="0x444850"}]},
  frame={level="3",args=[]},
  frame={level="4",args=[]}]^M
(gdb) ^M
PASS: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1
...

The difference in gdb output is due to difference in the dwarf generated by
the compiler, so I don't see a problem with gdb here.

Fix this by updating the test-case to accept this output.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2023-09-26 18:57:49 +02:00
Tom Tromey
54e053874d Remove some unnecessary qualification from printing.py
printing.py references "gdb.printing" in a few spots, but there's no
need for this.  I think this is leftover from when this code was
(briefly) in some other module.  This patch removes the unnecessary
qualifications.  Tested on x86-64 Fedora 36.
2023-09-26 09:51:56 -06:00
Tom Tromey
f35baff348 Add two new pretty-printer methods
This adds two new pretty-printer methods, to support random access to
children.  The methods are implemented for the no-op array printer,
and DAP is updated to use this.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-09-26 09:29:14 -06:00
Tom Tromey
fb28257699 Introduce gdb.ValuePrinter
There was an earlier thread about adding new methods to
pretty-printers:

https://sourceware.org/pipermail/gdb-patches/2023-June/200503.html

We've known about the need for printer extensibility for a while, but
have been hampered by backward-compatibilty concerns: gdb never
documented that printers might acquire new methods, and so existing
printers may have attribute name clashes.

To solve this problem, this patch adds a new pretty-printer tag class
that signals to gdb that the printer follows new extensibility rules.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30816
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-09-26 09:29:14 -06:00
Nick Clifton
854f72b36d Fix a snafu in the new tests for reproducible archives that assumed a umask of 22. 2023-09-26 16:27:28 +01:00
Tom de Vries
940bb336cb [gdb/testsuite] Fix gdb.server/ext-run.exp in container
When running the gdb testsuite inside a container, I run into:
...
(gdb) gdb_expect_list pattern: /1 +root +[/a-z]*(init|systemd)/
FAIL: gdb.server/ext-run.exp: get process list (pattern 2)
...
because there's no process with pid 1 and cmd init or systemd.

In the host system (where the test passes), I have:
...
$ ps -f 1
UID        PID  PPID  C STIME TTY      STAT   TIME CMD
root         1     0  0 Sep25 ?        Ss     0:03 /usr/lib/systemd/systemd ...
...
but in the container instead:
...
UID        PID  PPID  C STIME TTY      STAT   TIME CMD
root         1     0  0 11:45 pts/0    Ss     0:00 /bin/bash
...

Fix this by also accepting bash as a valid cmd.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2023-09-26 16:28:48 +02:00
Richard Sandiford
d86dbbea8a aarch64: Allow feature flags to occupy >64 bits
Following on from the previous patch to make the feature macros take
a word number, this one increases the number of flag words from 1 to 2.

The patch uses some dummy features to push the number of features
over 64.  The intention is that these should be reused by real
features rather than kept as-is.
2023-09-26 15:01:21 +01:00
Richard Sandiford
4abb672ac1 aarch64: Restructure feature flag handling
The AArch64 feature-flag code is currently limited to a maximum
of 64 features.  This patch reworks it so that the limit can be
increased more easily.  The basic idea is:

(1) Turn the ARM_FEATURE_FOO macros into an enum, with the enum
    counting bit positions.

(2) Make the feature-list macros take an array index argument
    (currently always 0).  The macros then return the
    aarch64_feature_set contents for that array index.

    An N-element array would then be initialised as:

      { MACRO (0), ..., MACRO (N - 1) }

(3) Provide convenience macros for initialising an
    aarch64_feature_set for:

    - a single feature
    - a list of individual features
    - an architecture version
    - an architecture version + a list of additional features

(2) and (3) use the preprocessor to generate static initialisers.
The main restriction was that uses of the same preprocessor macro
cannot be nested.  So if a macro wants to do something for N individual
arguments, it needs to use a chain of N macros to do it.  There then
needs to be a way of deriving N, as a preprocessor token suitable for
pasting.

The easiest way of doing that was to precede each list of features
by the number of features in the list.  So an aarch64_feature_set
initialiser for three features A, B and C would be written:

  AARCH64_FEATURES (3, A, B, C)

This scheme makes it difficult to keep AARCH64_FEATURE_CRYPTO as a
synonym for SHA2+AES, so the patch expands the former to the latter.
2023-09-26 15:01:21 +01:00
Tom de Vries
fc21e0f029 [gdb/dap] Fix dap for python < 3.8
With any gdb.dap test and python 3.6 I run into:
...
Error occurred in Python: 'code' object has no attribute 'co_posonlyargcount'
ERROR: eof reading json header
...

The attribute is not supported before python 3.8, which introduced the
"Positional−only Parameters" concept.

Fix this by using try/except AttributeError.

Tested on x86_64-linux:
- openSUSE Leap 15.4 with python 3.6, and
- openSUSE Tumbleweed with python 3.11.5.

Approved-By: Tom Tromey <tom@tromey.com>
2023-09-26 15:51:27 +02:00
Enze Li
d5fa6e8c6c fbsd-nat: Fix build failure with GCC 12
A user pointed out that the build failed on FreeBSD/amd64 with my last
commit.  The problem is that I'm not using the proper way to tell the
compiler that the variable has been "used".  This patch fixes this issue
as suggested by John.  Pushed as obvious.

Tested both on FreeBSD/amd64 and FreeBSD/aarch64 by rebuilding.

Suggested-By: John Baldwin <jhb@FreeBSD.org>
2023-09-26 21:19:07 +08:00
Aditya Vidyadhar Kamath
dd05a5ca69 Fix to step instruction due to P10 prefix instruction.
In AIX, power 10 instructions like paddi occupy 8 bytes, while the other instructions
4 bytes of space. Due to this when we do a stepi on paddi instruction we get a SIGILL interrupt. Hence, we
need to check during stepi if we are able to step 8 bytes during this instruction execution and is the
breakpoint to this instruction set correctly in both 32- and 64-bit mode.

This patch is a fix to the same.
2023-09-26 15:13:18 +02:00
Nick Clifton
6f56739807 Allow the use of SOURCE_DATE_EPOCH in the timestamps for members of static archives.
(For some reason this commit was not applied at the time that the patch was approved).
2023-09-26 14:07:23 +01:00
Tom Tromey
0128542673 Use string_file::release in some places
I found a few spots like:

    string_file f;
    std::string x = f.string ();

However, string_file::string returns a 'const std::string &'...  so it
seems to me that this must be copying the string (? I find it hard to
reason about this in C++).

This patch changes these spots to use release() instead, which moves
the string.

Reviewed-by: Keith Seitz <keiths@redhat.com>
Reviewed-by: Lancelot Six <lancelot.six@amd.com>
2023-09-26 06:56:27 -06:00
GDB Administrator
5437a94464 Automatic date update in version.in 2023-09-26 00:00:42 +00:00
Vsevolod Alekseyev
84102ebc29 Fix readelf's display of dwarf v5 range lists
PR 30792
  * dwarf.h (struct debug_info): Remove range_versions field.
  * dwarf.c (fetch_indexed_offset): New function. (read_and_display_attr_value): Use it for DW_FORM_rnglistx. Remove code to initialise range_versions. (skip_attribute): New function. (read_bases): Read and reccord all range and address bases in a CU. (process_debug_info): Call read_bases. (display_debug_rnglists): Rename to display_debug_rnglists_unit_header and only display the range list header information. (display_debug_ranges): Adjust.
2023-09-25 18:01:31 +01:00
Claudiu Zissulescu
35d21ea02d Revert "arc: Add new GAS tests for ARCv3."
This reverts commit 462693a455f04fc52c1c91ffc52ea2446a086444.
2023-09-25 17:03:35 +03:00
Claudiu Zissulescu
ad6a51b91c Revert "arc: Add new LD tests for ARCv3."
This reverts commit 6e467e9a94c1135bd11d985e9263d43204a9258b.
2023-09-25 17:03:20 +03:00
Claudiu Zissulescu
d9d85c086f Revert "arc: Add new ARCv3 ISA to BFD."
This reverts commit 06e8d9861d16c5b7e6920ad0e89889ccf45c575a.
2023-09-25 17:03:06 +03:00
Claudiu Zissulescu
7f2b40892a Revert "arc: Add new linker emulation and scripts for ARCv3 ISA."
This reverts commit 4deb1ee57fdb711cac6f36fed75b3c8cb5112d99.
2023-09-25 17:02:55 +03:00
Claudiu Zissulescu
8784b6df88 Revert "arc: Update opcode related include files for ARCv3."
This reverts commit 04414221df53bb5129e34bec354dae3121db436a.
2023-09-25 17:02:41 +03:00
Claudiu Zissulescu
6ba813bf38 Revert "arc: Update ARC's Gnu Assembler backend with ARCv3 ISA."
This reverts commit f3d38d7d0b7346515ba603454feeddc58a3fc451.
2023-09-25 17:02:29 +03:00
Claudiu Zissulescu
3b7e24aa56 Revert "arc: Add new opcode functions for ARCv3 ISA."
This reverts commit c99dc76089a2de97ea0ee755aa8e87037a17b6d6.
2023-09-25 17:02:19 +03:00
Claudiu Zissulescu
f3594421d7 Revert "arc: New ARCv3 ISA instruction table"
This reverts commit 67036dfacf87e79317984f51892bfc0eda0e597f.
2023-09-25 17:02:08 +03:00
Claudiu Zissulescu
efd35d85fc Revert "arc: Update arc's gas tests"
This reverts commit ef90c0991e78c28bebdd3ed31a77c05be0444191.
2023-09-25 17:01:58 +03:00