Commit Graph

119752 Commits

Author SHA1 Message Date
Christophe Lyon
9a3781f120 contrib: Add autoregen.py
This script is a copy of the current script used by Sourceware's
autoregen buildbots.

It is intended as a helper to regenerate files managed by autotools
(autoconf, automake, aclocal, ....), as well as the toplevel
Makefile.in which is created by autogen.

Other files can be updated when using maintainer-mode, but this is not
covered by this script.

2024-04-19  Christophe Lyon  <christophe.lyon@linaro.org>

	contrib/
	* autoregen.py: New script.
2024-09-04 13:35:10 +00:00
Shahab Vahedi
8cfe8572e1 MAINTAINERS: Update my email address 2024-09-04 10:59:01 +02:00
Tom de Vries
3bd0f5c4d9 [gdb/testsuite] Fix gdb.dwarf2/dw2-lines.exp on arm-linux
With test-case gdb.dwarf2/dw2-lines.exp on arm-linux, I run into:
...
(gdb) break bar_label^M
Breakpoint 2 at 0x4004f6: file dw2-lines.c, line 29.^M
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, bar () at dw2-lines.c:29^M
29        foo (2);^M
(gdb) PASS: $exp: cv=2: cdw=32: lv=2: ldw=32: continue to breakpoint: foo \(1\)
...

The pass is incorrect because the continue lands at line 29 with "foo (2)"
instead of line line 27 with "foo (1)".

A minimal version is:
...
$ gdb -q -batch dw2-lines.cv-2-cdw-32-lv-2-ldw-32 -ex "b bar_label"
Breakpoint 1 at 0x4f6: file dw2-lines.c, line 29.
...
where:
...
000004ec <bar>:
 4ec:	b580      	push	{r7, lr}
 4ee:	af00      	add	r7, sp, #0

000004f0 <bar_label>:
 4f0:	2001      	movs	r0, #1
 4f2:	f7ff fff1 	bl	4d8 <foo>

000004f6 <bar_label_2>:
 4f6:	2002      	movs	r0, #2
 4f8:	f7ff ffee 	bl	4d8 <foo>
...

So, how does this happen?  In short:
- skip_prologue_sal calls arm_skip_prologue with pc == 0x4ec,
- thumb_analyze_prologue returns 0x4f2
  (overshooting by 1 insn, PR tdep/31981), and
- skip_prologue_sal decides that we're mid-line, and updates to 0x4f6.

However, this is a test-case about .debug_line info, so why didn't arm_skip_prologue
use the line info to skip the prologue?

The answer is that the line info starts at bar_label, not at bar.

Fixing that allows us to work around PR tdep/31981.

Likewise in gdb.dwarf2/dw2-line-number-zero.exp.

Instead, add a new test-case gdb.arch/skip-prologue.exp that is dedicated to
checking quality of architecture-specific prologue analysis, without being
written in an architecture-specific way.

If fails on arm-linux for both marm and mthumb:
...
FAIL: gdb.arch/skip-prologue.exp: f2: $bp_addr == $prologue_end_addr (skipped too much)
FAIL: gdb.arch/skip-prologue.exp: f4: $bp_addr == $prologue_end_addr (skipped too much)
...
and passes for:
- x86_64-linux for {m64,m32}x{-fno-PIE/-no-pie,-fPIE/-pie}
- aarch64-linux.

Tested on arm-linux.
2024-09-04 10:07:19 +02:00
Mark Harmstone
b281480b26 bfd/pdb: fix bitmap generation in pdb_write_bitmap
MSVC 2022 is more pedantic than MSVC 2019 when it comes to loading PDB
files in readonly mode, and was rejecting PDB files generated by binutils
because of their invalid free-space bitmaps. It's unknown what would
have happened if you tried to use MS tools to modify a PDB created by
binutils, but it probably would have led to a corrupted file.

This patch fixes pdb_write_bitmap so we generate files that MSVC will accept.

Specifically there were three things we were doing wrong:

- We weren't including the superblock (block 0)

- We were setting bits in bytes backwards (MSB to LSB, rather than LSB to MSB)

- We should have been marking the contents of stream 0 as free. This is
  because, as the comment says, it's intended to be used for the
  directory for the previous write, to allow atomic updates.
2024-09-04 02:24:37 +01:00
GDB Administrator
6225a4d33a Automatic date update in version.in 2024-09-04 00:00:13 +00:00
Tom de Vries
bbc8c5a1d1 [gdb] Fix typos
Fix a few typos.

unconditionaly -> unconditionally
gratuitiously -> gratuitously
configureable -> configurable
represention -> representation
distiguished -> distinguished
breakpointer -> breakpoint
asssignments -> assignments
architectual -> architectural
compatibity -> compatibility
adjustement -> adjustment
unexcepted -> unexpected
propogated -> propagated
consistant -> consistent
succeding -> succeeding
higlight -> highlight
detachs -> detach

Tested by rebuilding on x86_64-linux.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-09-03 17:30:37 +02:00
Mary Bennett
a6ecb18b79 RISC-V: Add support for XCVsimd extension in CV32E40P
Spec: https://docs.openhwgroup.org/projects/cv32e40p-user-manual/en/latest/instruction_set_extensions.html

Contributors:
  Mary Bennett <mary.bennett682@gmail.com>
  Nandni Jamnadas <nandni.jamnadas@embecosm.com>
  Pietra Ferreira <pietra.ferreira@embecosm.com>
  Charlie Keaney
  Jessica Mills
  Craig Blackmore <craig.blackmore@embecosm.com>
  Simon Cook <simon.cook@embecosm.com>
  Jeremy Bennett <jeremy.bennett@embecosm.com>
  Helene Chelin <helene.chelin@embecosm.com>

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_multi_subset_supports): Add `xcvsimd`
	instruction class.
	(riscv_multi_subset_supports_ext): Likewise.

gas/ChangeLog:
	* NEWS: Updated.
	* config/tc-riscv.c (validate_riscv_insn): Add custom operands.
	(riscv_ip): Likewise.
	* doc/c-riscv.texi: Note XCVsimd as an additional ISA extension
	for CORE-V.
	* testsuite/gas/riscv/march-help.l: Add xcvsimd.
	* testsuite/gas/riscv/x-cv-simd.d: New test.
	* testsuite/gas/riscv/x-cv-simd.s: New test.
	* testsuite/gas/riscv/x-cv-simd-fail.d: New test.
	* testsuite/gas/riscv/x-cv-simd-fail.l: New test.
	* testsuite/gas/riscv/x-cv-simd-fail.s: New test.

include/ChangeLog:

	* opcode/riscv-opc.h: Add corresponding MATCH and MASK macros
	for XCVsimd.
	* opcode/riscv.h: Add corresponding EXTRACT and ENCODE macros
	for XCVsimd.
	(enum riscv_insn_class): Add the XCVsimd instruction class.

opcodes/ChangeLog:

	* riscv-dis.c (print_insn_args): Add custom operands.
	* riscv-opc.c: Add XCVsimd instructions.
2024-09-03 12:02:28 +08:00
GDB Administrator
cf52562182 Automatic date update in version.in 2024-09-03 00:00:29 +00:00
Haochen Jiang
85e370a3d6 Support ymm rounding control for Intel AVX10.2
In the patch, in order to support ymm rounding for AVX10.2, we derive
evex attribute for all cases instead of only for rc_none to encode U bit.
Also changed some bad_opcode return due to the share of U bit with APX_F.

gas/ChangeLog:

	* config/tc-i386.c
	(cpu_flags_match): Handle AVX10_2.
	(build_evex_prefix): Handle U bit. Derive evex attribute
	for all cases.
	(check_VecOperands): Handle AVX10.2 and ymm roundings.
	* doc/c-i386.texi: Document .avx10.2.
	* testsuite/gas/i386/i386.exp: Run AVX10.2 tests.
	* testsuite/gas/i386/x86-64.exp: Ditto.
	* testsuite/gas/i386/avx10_2-rounding-intel.d: New test.
	* testsuite/gas/i386/avx10_2-rounding-inval.l: Ditto.
	* testsuite/gas/i386/avx10_2-rounding-inval.s: Ditto.
	* testsuite/gas/i386/avx10_2-rounding.d: Ditto.
	* testsuite/gas/i386/avx10_2-rounding.s: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-rounding-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-rounding.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-rounding.s: Ditto.

opcodes/ChangeLog:

	* i386-dis.c (struct instr_info): Add U bit.
	(get_valid_dis386): Handle U bit.
	* i386-gen.c (isa_dependencies): Add AVX10.2.
	(cpu_flags): Ditto.
	* i386-init.h: Regenerated.
	* i386-opc.h (CpuAVX10_2): New.
	(i386_cpu_flags): Add cpuavx10_2.
	* i386-opc.tbl: Add rounding to old entries which do not
	permit rounding previously. Also eliminate the redundant
	RegXMM for vcvtps2uqq.
	* i386-tbl.h: Regenerated.
2024-09-02 10:53:59 +08:00
GDB Administrator
073e508b61 Automatic date update in version.in 2024-09-02 00:00:12 +00:00
GDB Administrator
95dac28352 Automatic date update in version.in 2024-09-01 00:00:09 +00:00
H.J. Lu
5a655b5291 x86: Fix comment typos in TLS relocation check
R_386_TLS_IE is used only in

	movl foo@indntpoff, %eax
	movl foo@indntpoff, %reg
	addl foo@indntpoff, %reg

R_386_TLS_DESC_CALL and R_X86_64_TLSDESC_CALL are used only in

	call *x@tlscall(%[er]ax)

	* elf32-i386.c (elf_i386_check_tls_transition): Use foo@indntpoff
	in comments for R_386_TLS_IE check.
	(elf_i386_tls_transition): Use @tlscall in comments for
	R_386_TLS_DESC_CALL check.
	* elf64-x86-64.c (elf_x86_64_tls_transition): Use @tlscall in
	comments for R_X86_64_TLSDESC_CALL check.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-31 05:07:19 -07:00
H.J. Lu
229ecf80f3 gold: Always resolve non-default weak undefined to 0
Non-default weak undefined symbols in executable and shared library are
always resolved to 0 at runtime and don't need dynamic relocation.

Tested on i686, x86-64, powerpc64le and aarch64.

	PR gold/32071
	* symtab.cc (Symbol::final_value_is_known): Always resolve
	non-default weak undefined symbol in executable and shared library
	to 0 at runtime.
	* symtab.h (Symbol::needs_dynamic_reloc): Return false for
	non-default weak undefined symbol in executable and shared library.
	* testsuite/Makefile.am: Add weak_undef_test_3 and
	weak_undef_test_4 tests.
	* testsuite/Makefile.in: Regenerated.
	* testsuite/weak_undef_lib_4.c: New file.
	* testsuite/weak_undef_test_3.c: Likewise.
	* testsuite/weak_undef_test_4.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-31 04:28:43 -07:00
Tom de Vries
1a86b364a3 [gdb/testsuite] Handle unsupported catch syscall
On riscv64-linux, I run into:
...
Expecting: ^(catch syscall[^M
]+)?((&.*)*.*~"Catchpoint 5 .*\\n".*=breakpoint-created,bkpt=\{number="5",type="catchpoint".*\}.*\n\^done[^M
]+[(]gdb[)] ^M
[ ]*)
catch syscall^M
&"catch syscall\n"^M
&"The feature 'catch syscall' is not supported on this architecture yet.\n"^M
^error,msg="The feature 'catch syscall' is not supported on this architecture yet."^M
(gdb) ^M
FAIL: gdb.mi/mi-breakpoint-changed.exp: test_insert_delete_modify: catch syscall (unexpected output)
...

Fix this by:
- factoring out proc supports_catch_syscall out of gdb.base/catch-syscall.exp,
  and
- using it in gdb.mi/mi-breakpoint-changed.exp.

Tested on x86_64-linux and riscv64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-31 07:56:48 +02:00
GDB Administrator
d5de35fb07 Automatic date update in version.in 2024-08-31 00:00:08 +00:00
Andrew Burgess
c201bc6e93 gdb: remove duplicate check in disable_breakpoints_in_freed_objfile
I spotted that we have a duplicate condition check in the function
disable_breakpoints_in_freed_objfile.

Lets remove it.

There should be no user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-30 21:24:07 +01:00
Simon Marchi
e5afccc7e4 gdb/dwarf2: cleanup includes
Cleanup includes in dwarf2/*.

 1. Add the necessary includes so that clangd reports no errors when
    opening header files.  This ensures that header files include what
    they use.

 2. Remove all includes reported as unused by clangd (except
    gdb-safe-ctype.h, which I think does some magic that affects what
    follows).

Built-tested --enable-threading at "yes" and "no", since there are some
portions of code gated by `#ifdef CXX_STD_THREAD`.

Change-Id: I21debffcd7c2caf90f08e1e0fbba3ce30422d042
Approved-By: Tom Tromey <tom@tromey.com>
2024-08-30 13:57:11 -04:00
Tom Tromey
71e0850800 Minor formatting fix in breakpoint.c
I noticed a spot in breakpoint.c that doesn't follow gdb's formatting
rules: the return type is on the same line as the method name.
2024-08-30 10:38:22 -06:00
Tom Tromey
bcae3bb650 Fix regexp quoting in gdb.ada test cases
I noticed that some gdb.ada tests used regular expressions like:

         "Continuing\..*$inferior_exited_re.*" \

Here, the "\." should either be "." or "\\." -- "\." is not really
meaningful.

This patch fixes all the cases of this I could find in gdb.ada.  In
one test (fun_renaming.exp), using "\\." would result in failures, and
here I rewrote the tests to use -wrap.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-30 09:11:12 -06:00
H.J. Lu
67e30b1521 x86: Check invalid TLS descriptor call
TLS descriptor call,

call *x@tlsdesc(%rax)

or

call *x@tlsdesc(%eax)

calls _dl_tlsdesc_return which expects that RAX/EAX points to the TLS
descriptor.  Update x86 linker to issue an error with or without TLS
transition.

bfd/

	PR ld/32123
	* elf32-i386.c (elf_i386_check_tls_transition): Move
	R_386_TLS_DESC_CALL to ...
	(elf_i386_tls_transition): Here.
	* elf64-x86-64.c (elf_x86_64_check_tls_transition): Move.
	R_X86_64_TLSDESC_CALL check to ...
	(elf_x86_64_tls_transition): Here.

ld/

	PR ld/32123
	* testsuite/ld-i386/i386.exp: Run tlsgdesc3.
	* testsuite/ld-i386/tlsgdesc3.d: New file.
	* testsuite/ld-x86-64/tlsdesc5.d: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run tlsdesc5.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-30 05:18:10 -07:00
Jan Beulich
ca6f0a61e7 x86: replace conditional operators used to calculate booleans
The boolean expressions themselves are fine to use there.
2024-08-30 11:24:19 +02:00
Jan Beulich
5d67152772 x86/APX: drop %SW disassembler macro again
Not the least due to its extremely rare use I didn't really like that
macro's introduction. Adjust swap_operand() accordingly instead.
2024-08-30 11:23:51 +02:00
Jan Beulich
4eb19fde73 x86: limit RegRex64 use
The special property really only applies to the "extended" byte regs
having legacy word/dword counterparts.

While touching involved code also drop redundant byte checks from a
conditional in establish_rex(): The other remaining RegRex64 uses only
exist on registers which can't be used as register operands anyway.
Hence RegRex64 as an attribute of a (valid) register operand implies
that it's a byte reg.
2024-08-30 11:23:16 +02:00
Jan Beulich
91fa2ea221 gas: properly check for ELF in LISTING_NODEBUG handling
While OBJ_MAYBE_ELF presently implies OBJ_ELF (due to obj-multi.h
including obj-elf.h for obscure reasons), there still need to be IS_ELF
checks to cover for the OBJ_MAYBE_ELF case. Note, however, that code
checking for ->debugging being true doesn't need such extra checks, as
the field can only ever be true when IS_ELF.

On the same basis reduce #ifdef-ary in debugging_pseudo().

Also move the field (into what on 64-bit architectures is a 32-bit gap)
and put it inside an OBJ_ELF conditional, too.

While there further switch int to bool in related code.
2024-08-30 11:22:41 +02:00
Jan Beulich
4f14f47e0c gas: generated code/data listing output vs .endr and alike
These ending directives are swallowed by buffer_and_nest() and hence
aren't seen by read_a_source_file(). Thus they also weren't announced to
the listing subsystem. That was, when macro expansions are included,
thus misguided to associate possible output resulting from the first
line of the construct being expanded with both the .endr and that first
line (i.e. showing it twice).
2024-08-30 11:21:58 +02:00
Nicolás Ortega Froysa
358ada8bc5 gdb/doc: fix typo in 'watch' command
* gdb/breakpoint.c (watch_option_defs): Fix typo.

Copyright-paperwork-exempt: yes.
2024-08-30 10:42:25 +03:00
Lulu Cai
4311b2c9cf LoongArch: LoongArch64 allows relocations to use 64-bit addends
Relocations using 64-bit addends allow larger constant offset address
calculations to be fused.
2024-08-30 11:53:31 +08:00
GDB Administrator
2e9df7573a Automatic date update in version.in 2024-08-30 00:00:09 +00:00
Andrew Burgess
dcaa85e58c gdb: reject inserting breakpoints between functions
When debugging ROCm code, you might have something like this:

  __global__ void kernel ()
  {
    ...
    // break here
    ...
  }

  int main ()
  {
    // Code to call `kernel`
  }

... where kernel is a function compiled to execute on the GPU.  It does
not exist in the host x86-64 program that runs the main function, and
GDB doesn't know about that function until it is called, at which point
the runtime loads the corresponding code object and GDB learns about the
code of the "kernel" function.  Before the GPU code object is loaded,
from the point of view of GDB, you might as well have blank lines
instead of the "kernel" function.  The DWARF in the host program doesn't
describe anything at these lines.

So, a common problem that users face is:

 - Start GDB with the host binary
 - Place a breakpoint by line number at the "break here" line
 - At this point, GDB only knows about the host code, the lines of the
   `kernel` function are a big void.
 - GDB finds no code mapped to the "break here" line and searches for
   the first following line that has code mapped to it.
 - GDB finds that the line with the opening bracket of the `main`
   function (or around there) has code mapped to it, places breakpoint
   there.
 - User runs the program.
 - The programs hits the breakpoint at the start of main.
 - User is confused, because they didn't ask for a breakpoint in main.

If they continue, the code object eventually gets loaded, GDB reads the
debug info from it, re-evaluates the breakpoint locations, and at this
point the breakpoint is placed at the expected location.

The goal of this patch is to get rid of this annoyance.

A case similar to the one shown above can actually be simulated without
GPU-specific code: using a single source file to generate a library and
an executable loading that library (see the new test
gdb.linespec/line-breakpoint-outside-function.c for an example).  Before
the library is loaded, trying to place a breakpoint in the library code
results in the breakpoint "drifting" down to the main function.

To address this problem, make it so that when a user requests a
breakpoint outside a function, GDB makes a pending breakpoint, rather
than placing a breakpoint at the next line with code, which happens to
be in the next function.  When the GPU kernel or shared library gets
loaded, the breakpoint resolves to a location in the kernel or library.

Note that we still want breakpoints placed inside a function to
"drift" down to the next line with code.  For example, here:

   9
  10 void foo()
  11 {
  12   int x;
  13
  14   x++;

There is probably no code associated to lines 10, 12 and 13, but the
user can still reasonably expect to be able to put a breakpoint there.
In my experience, GCC maps the function prologue to the line with the
opening curly bracket, so the user will be able to place a breakpoint
there anyway (line 11 in the example).  But I don't really see a use
case to put a breakpoint above line 10 and expect to get a breakpoint in
foo.  So I think that is a reasonable behavior change for GDB.

This is implemented using the following heuristic:

 - If a breakpoint is requested at line L but there is no code mapped to
   L, search for a following line with associated code (this already
   exists today).
 - However, if:

     1. the found location falls in a function symbol's block
     2. the found location's address is equal the entry PC of that
        function
     3. the found location's line is greater that the requested line

   ... then we don't place a breakpoint at the found location, we will
   end up with a pending breakpoint.

Change the message "No line X in file..." to "No compiled code for line
X in file...".  There is clearly a line 9 in the example above, so it
would be weird to say "No line 9 in file...".  What we mean is that
there is no code associated to line 9.

All the regressions that I found this patch to cause were:

 1. tests specifically this behavior where placing a breakpoint before
    a function results in a breakpoint on that function, in which case I
    removed the tests or changed them to expect a pending breakpoint
 2. linespec tests expecting things like "break -line N garbage" to
    error out because of the following garbage, but we now got a
    different error because line N now doesn't resolve to something
    anymore.  For example, before:

      (gdb) break -line 3 if foofoofoo == 1
      No symbol "foofoofoo" in current context.

    became

      (gdb) break -line 3 if foofoofoo == 1
      No line 3 in the current file.

    These tests were modified to refer to a valid line with code, so
    that we can still test what we intended to test.

Notes:

 - The CUDA compiler "solves" this problem by adding dummy function
   symbols between functions, that are never called.  So when you try to
   insert a breakpoint in the not-yet-loaded kernel, the breakpoint
   still drifts, but is placed on some dummy symbol.  For reasons that
   would be too long to explain here, the ROCm compiler does not do
   that, and it is not a desirable option.

 - You can have constructs like this:

   void host_function()
   {
     struct foo
     {
       static void __global__ kernel ()
       {
         // Place breakpoint here
       }
     };

     // Host code that calls `kernel`
   }

   The heuristic won't work then, as the breakpoint will drift somewhere
   inside the enclosing function, but won't be at the start of that
   function.  So a bogus breakpoint location will be created on the host
   side.  I don't think that people are going to use this kind of
   construct often though, so we can probably ignore it (or at least it
   shouldn't prevent making the more common case better).

   ROCm doesn't support passing a lambda kernel function to
   hipLaunchKernelGGL (the function used to launch kernels on the
   device), but if it eventually does, there will be the same
   problem.

   I think that to properly support this, we will need some DWARF
   improvements to be able to say "there is really nothing at these
   lines" in the line table.

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I3cc12cfa823dc7d8e24dd4d35bced8e8baf7f9b6
2024-08-29 14:56:59 -04:00
Andrew Burgess
83fbcee1a1 gdb/doc: move NEWS entry to the correct place
In commit:

  commit 3055e3d2f1
  Date:   Tue May 21 15:58:02 2024 +0100

      gdb: add GDB side target_ops::fileio_stat implementation

I managed to place a NEWS entry in the wrong place.  I put the entry
in 'Changes in GDB 15' rather than 'Changes since GDB 15'.  This
commit moves the entry to the correct place.
2024-08-29 17:31:48 +01:00
Simon Marchi
f70987f0b9 gdb: include gdbsupport/gdb_obstack.h in addrmap.h
This header file uses auto_obstack, found in gdbsupport/gdb_obstack.h.
This fixes an error shown when editing addrmap.h with clangd, and makes
it so addrmap.h includes what it uses.

Change-Id: I0b0c8d26638e2150fcb65c601098ed9df5a8945a
2024-08-29 12:07:32 -04:00
Simon Marchi
ae60acec42 gdb: remove unused includes in linespec.c
Remove some includes reported as unused by clangd.

Change-Id: Id1d5130430cdd2a37da1325a5eb67677f37905df
2024-08-29 11:34:42 -04:00
Alan Modra
f2a15e7cde get_type_abbrev_from_form tidy
* dwarf.c (get_type_abbrev_from_form): Make uvalue param a
	uint64_t.  Localise variables.  Don't bother clearing *data_return
	and *addrev_num_return for a NULL return value.
2024-08-29 21:05:57 +09:30
Alan Modra
9459f695d3 ld testsuite output files
In many cases the output of one run_cc_link_tests test is used as
input for another test.  I hit a case where some system change caused
errors when compiling object files, but the old .so output from a
previous test run was still there, and then was used in following
tests.

	* testsuite/lib/ld-lib.exp (run_ld_link_tests): Delete output
	file before building.
	(run_ld_link_exec_tests, run_cc_link_tests): Likewise.
2024-08-29 21:05:57 +09:30
Alan Modra
35e273526b PR32093, -Walloc-size warning in ctf-hash.c
PR 32093
	* ctf-hash.c (ctf_dynhash_create_sized, ctf_hashtab_insert): Avoid
	-Walloc-size warning.
2024-08-29 21:05:57 +09:30
Tom de Vries
8ee4561d38 [gdb/testsuite] Fix another regexp in gdb.threads/stepi-over-clone.exp
On openSUSE Tumbleweed, I run into:
...
(gdb) PASS: gdb.threads/stepi-over-clone.exp: catch process syscalls
continue^M
Continuing.^M
^M
Catchpoint 2 (call to syscall clone3), __clone3 () at clone3.S:62^M
(gdb) FAIL: gdb.threads/stepi-over-clone.exp: continue
...

Fix this by updating another (see commit 8fbf220321) regexp to also recognize
__clone3.

Tested on x86_64-linux.
2024-08-29 11:39:02 +02:00
Tom de Vries
b55b65bc56 [gdb/testsuite] Fix regexp in gdb.arch/i386-disp-step-self-call.exp
Usually, with test-case gdb.arch/i386-disp-step-self-call.exp I get:
...
(gdb) x/1wx 0xffffc4f8^M
0xffffc4f8:     0x08048472^M
(gdb) PASS: $exp: check return address was updated correctly
...
but sometimes I run into:
...
(gdb) x/1wx 0xffffc5c8^M
0xffffc5c8:     0x0804917e^M
(gdb) FAIL: $exp: check return address was updated correctly
...

The problem is that here:
...
set next_insn_addr 0x[format %08X $next_insn_addr]
gdb_test "x/1wx 0x[format %x $sp]" "$hex:\\s+$next_insn_addr" \
    "check return address was updated correctly"
...
we're trying to match string 0x0804917e against regexp 0x0804917E due to using
"%08X" as format string.

We only run into this problem if the address contains letters, which apparently
usually isn't the case.

Fix this by using "%08x" instead as format string.

Likewise in test-case gdb.arch/amd64-disp-step-self-call.exp.

Tested on x86_64-linux.

PR testsuite/32121
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32121
2024-08-29 07:31:12 +02:00
GDB Administrator
5cca20f614 Automatic date update in version.in 2024-08-29 00:00:14 +00:00
Tom Tromey
5a06416ebf Don't check dwarf2_name in process_enumeration_scope
I noticed that process_enumeration_scope checks the result of
dwarf2_name.  However, this isn't needed, because new_symbol does the
same check.  This patch removes the unnecessary code.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-28 14:14:43 -06:00
Jiaying Song
a253bea899 dlltool: file name too long
During the execution of the command: i686-w64-mingw32-dlltool
--input-def $def_filepath --output-delaylib $filepath --dllname qemu.exe
An error occurred:
i686-w64-mingw32-dlltool: failed to open temporary head file: ..._w64_mingw32_nativesdk_qemu_8_2_2_build_plugins_libqemu_plugin_api_a_h.s

Due to the path length exceeding the Linux system's file name length
limit (NAME_MAX=255), the temporary file name generated by the
i686-w64-mingw32-dlltool command becomes too long to open. To address
this, a new temporary file name prefix is generated using tmp_prefix =
prefix_encode ("d", getpid()), ensuring that the file name does not
exceed the system's length limit.

Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
Reviewed-by: Alan Modra <amodra@gmail.com>
2024-08-28 22:29:40 +09:30
H.J. Lu
c9652a062f x86: Report expected register for elf_x86_tls_error_indirect_call
Since R_386_TLS_DESC_CALL can only be used with

	call	*variable@TLSCALL(%eax)

and R_X86_64_TLSDESC_CALL can only be used with

	call	*variable@TLSCALL(%rax)

update TLS transition error report to display the expected register in
indirect CALL.

bfd/

	PR ld/32017
	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	the ax_register field.
	(_bfd_x86_elf_link_report_tls_transition_error): Report the
	expected register in elf_x86_tls_error_indirect_call error.
	* elfxx-x86.h (elf_x86_link_hash_table): Add ax_register.

ld/

	PR ld/32017
	* testsuite/ld-i386/tlsgdesc2.d: Updated.
	* testsuite/ld-i386/tlsgdesc2.s: Change jmp to call via ECX.
	* testsuite/ld-x86-64/tlsdesc4.d: Updated.
	* testsuite/ld-x86-64/tlsdesc4.s: Change jmp to call via RCX.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-28 05:56:25 -07:00
H.J. Lu
a2776c438c gold: Force a PC-relative reference to .LC0
Force a PC-relative reference to .LC0 with:

__asm__ (".dc.a .LC0 - .");

for all targets.

Tested on x86, powerpc64le and aarch64.

	* testsuite/discard_locals_relocatable_test.c: Force a PC-relative
	reference to .LC0.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-28 05:51:58 -07:00
H.J. Lu
dbb062e5e9 gold: Disable &no_such_symbol_ != NULL check when GOT in use
Since this test:

  if (&no_such_symbol_ != NULL)
    {
      fprintf(stderr, "FAILED weak undef test 4: %s\n",
              "&no_such_symbol_ is not NULL");
      status = 1;
    }

always fails when GOT is used and aarch64 always uses GOT, disable it
for aarch64 and PIC.

	PR gold/32112
	* testsuite/weak_undef_test.cc (main): Disable the
	&no_such_symbol_ != NULL check for aarch64 and PIC.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-28 05:51:58 -07:00
Alan Modra
57a3845126 dlltool.c formatting
Mostly whitespace fixes, some removal of excess parens.
2024-08-28 22:19:38 +09:30
Alan Modra
0eb85fc242 Re: x86: Allow R_386_TLS_LE_32 with KMOVD
Adjust the new test to pass on i686-pc-elf where it failed due to not
matching the _start address.
2024-08-28 22:19:38 +09:30
H.J. Lu
86db7e7da8 gold: Use asm for GCC 9 and older in PR gold/31830 tests
Since GCC 9 and older fail to compile PR gold/31830 tests:

$ gcc -S testsuite/ver_test_pr31830_b.c -o /tmp/x.s
testsuite/ver_test_pr31830_b.c:3:1: warning: ‘__symver__’ attribute directive ignored [-Wattributes]
 void __collector_foo_2_2(void) {}
 ^~~~

use asm statement, instead of symver attribute, for GCC 9 and older.

	PR gold/31830
	* testsuite/ver_test_pr31830_b.c (__collector_foo_2_2): Use asm
	statement, instead of symver attribute, for GCC 9 and older.
	symver attribute with __asm__.
	* testsuite/ver_test_pr31830_lto.c (__collector_foo_2_2): Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-28 05:48:55 -07:00
H.J. Lu
93ea177e95 gold: Remove duplicated rules for ifuncmain[12457]picstatic
When HAVE_STATIC and IFUNC_STATIC both are false, "make" reports:

Makefile:3796: warning: overriding recipe for target 'ifuncmain1picstatic'
Makefile:3788: warning: ignoring old recipe for target 'ifuncmain1picstatic'
Makefile:3900: warning: overriding recipe for target 'ifuncmain2picstatic'
Makefile:3892: warning: ignoring old recipe for target 'ifuncmain2picstatic'
Makefile:3932: warning: overriding recipe for target 'ifuncmain4picstatic'
Makefile:3924: warning: ignoring old recipe for target 'ifuncmain4picstatic'
Makefile:3972: warning: overriding recipe for target 'ifuncmain5picstatic'
Makefile:3964: warning: ignoring old recipe for target 'ifuncmain5picstatic'
Makefile:4048: warning: overriding recipe for target 'ifuncmain7picstatic'
Makefile:4040: warning: ignoring old recipe for target 'ifuncmain7picstatic'

due to duplicated rules for ifuncmain[12457]picstatic:

@GCC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@HAVE_STATIC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@IFUNC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@IFUNC_STATIC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@NATIVE_LINKER_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@GCC_TRUE@@HAVE_STATIC_TRUE@@IFUNC_STATIC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1picstatic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld

Make rules for ifuncmain[12457]picstatic independent of HAVE_STATIC and
IFUNC_STATIC:

@GCC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@IFUNC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@NATIVE_LINKER_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1picstatic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld

	PR gold/32116
	* testsuite/Makefile.am (ifuncmain1picstatic): Make it independent
	of HAVE_STATIC and IFUNC_STATIC.
	(ifuncmain2picstatic): Likewise.
	(ifuncmain4picstatic): Likewise.
	(ifuncmain5picstatic): Likewise.
	(ifuncmain7picstatic): Likewise.
	* testsuite/Makefile.in: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-28 05:38:19 -07:00
H.J. Lu
903ae63656 x86: Report invalid TLS operator
Report invalid TLS operator, instead of relocation.

	PR gas/28595
	* config/tc-i386.c (gotrel): Replace int with unsigned int.
	(i386_assemble): Report invalid TLS operator.
	* testsuite/gas/i386/inval-tls.l: updated.
	* testsuite/gas/i386/x86-64-inval-tls.l: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-28 05:01:34 -07:00
Guinevere Larsen
2e3759c260 gdb/testsuite: fix gdb.btrace/non-stop.exp end of history check
The recent commit 0891970109 changed the
warnings when GDB reaches the end of the recorded history, and updated
tests to expect the new messages. The pattern used for
gdb.btrace/non-stop.exp, however, was too broad and could cause the
following test result:

    ...
    (gdb) PASS: gdb.btrace/non-stop.exp: no progress: all: thread apply all continue: prompt
    ^M
    Reached end of recorded history; stopping.^M
    Following forward execution will be added to history.^M
    test (arg=0x0) at /data/vries/gdb/src/gdb/testsuite/gdb.btrace/non-stop.c:30^M
    30        return arg; /* bp.2 */^M
    ^M
    Reached end of recorded history; stopping.^M
    Following forward execution will be added to history.^M
    test (arg=0x0) at /data/vries/gdb/src/gdb/testsuite/gdb.btrace/non-stop.c:30^M
    30        return arg; /* bp.2 */^M
    PASS: gdb.btrace/non-stop.exp: no progress: all: thread apply all continue: thread 0
    FAIL: gdb.btrace/non-stop.exp: no progress: all: thread apply all continue: thread 1 (timeout)
    ...

This happens because the pattern looks like one of these 2:
    "Reached end of recorded.*Backwards execution.*"
    "Reached end of recorded.*Following forward.*"

What seems to have happened is that all the output came at once, and
most of it was consumed by the first '.*' pattern when checking for
thread 0, so there was no output left for checking thread 1. This commit
fixes that by making the expected outputs more exact.

I also fixed the whitespace errors in gdb_cont_to_no_history_backwards
that pre-dated the commit above, since I was already touching that proc.

Approved-By: Tom de Vries <tdevries@suse.de>
2024-08-28 08:41:05 -03:00
Andrew Burgess
0e64306335 gdb/testsuite: add no-delete-breakpoints option to 'runto' proc
New 'no-delete-breakpoints' option for the 'runto' proc.  This option
disables the delete_breakpoints call early on in this proc.

There are a couple of places in the testsuite where I have used:

  proc no_delete_breakpoints {} {}

  with_override delete_breakpoints no_delete_breakpoints {
    if {![runto_main]} {
      return
    }
 }

In order to avoid the deleting all breakpoints when I call
runto_main.  I was about to add yet another instance of this pattern
and I figured that it's time to do this properly.

This commit adds the new option to 'runto' which causes the
delete_breakpoints call to be skipped.

And, we now forward any arguments from 'runto_main' through to
'runto', this means I can now just do:

  if {![runto_main no-delete-breakpoints]} {
    return
  }

which I think is cleaner and easier to understand.

I've updated the two tests I found that use the old with_override
approach.

There should be no change in what is tested after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-28 10:39:21 +01:00