Commit Graph

117921 Commits

Author SHA1 Message Date
Jens Remus
75a28d1a97 s390: Print base register 0 as "0" in disassembly
Base and index register 0 have no effect in address computation:

"A value of zero in the B [base] or X [index] field specifies that no
base or index is to be applied, and, thus, general register 0 cannot be
designated as containing a base address or index."
IBM z/Architecture Principles of Operation [1], chapter "Organization",
section "General Registers".

Index register 0 is omitted in the s390 disassembly. Base register 0 is
omitted in D(B), D(L,B) and D(X,B) - the latter only if the index
register is zero.

To make it more apparent print base register 0 as "0" instead of "%r0",
whenever it would still be printed in the disassembly.

[1]: IBM z/Architecture Principles of Operation, SA22-7832-13,
     https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf

opcodes/
	* s390-dis.c: Print base register 0 as "0" in disassembly.

binutils/
	* NEWS: Mention base register 0 now being printed as "0" in s390
	disassembly.

gas/
	* testsuite/gas/s390/zarch-base-index-0.d: Update test case
	output verification patterns to accept "0" as base base
	register due to disassembler output format change.
	* gas/testsuite/gas/s390/zarch-omitted-base-index.d: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
dfa4ac9728 s390: Warn when register name type does not match operand
Print a warning message when the register type of a specified register
name does not match with the operand's register type:

operand {#}: expected {access|control|floating-point|general|vector}
  register name [as {base|index} register]

Introduce a s390-specific assembler option "warn-regtype-mismatch"
with the values "strict", "relaxed", and "no" as well as an option
"no-warn-regtype-mismatch" which control whether the assembler
performs register name type checks and generates above warning messages.

warn-regtype-mismatch=strict:
  Perform strict register name type checks.

warn-regtype-mismatch=relaxed:
  Perform relaxed register name type checks, which allow floating-point
  register (FPR) names %f0 to %f15 to be specified as argument to vector
  register (VR) operands and vector register (VR) names %v0 to %v15 to
  be specified as argument to floating-point register (FPR) operands.
  This is acceptable as the FPRs are embedded into the lower halves of
  the VRs. Make "relaxed" the default, as GCC generates assembler code
  using FPR and VR interchangeably, which would cause assembler warnings
  to be generated with "strict".

warn-regtype-mismatch=no:
no-warn-regtype-mismatch:
  Disable any register name type checks.

Tag .insn pseudo mnemonics as such, to skip register name type checks
on those. They need to be skipped, as there do not exist .insn pseudo
mnemonics for every possible operand register type combination. Keep
track of the currently parsed operand number to provide it as reference
in warning messages.

To verify that the introduction of this change does not unnecessarily
affect the compilation of existing code the GNU Binutils, GNU C Library,
and Linux Kernel have been build with the new assembler, verifying that
the assembler did not generate any of the new warning messages.

gas/
	* config/tc-s390.c: Handle new assembler options
	"[no]warn-regtype-mismatch[=strict|relaxed|no". Annotate
	parsed register expressions with register type. Keep track of
	operand number being parsed. Print warning message in case of
	register type mismatch between instruction operand and parsed
	register expression.
	* doc/as.texi: Document new s390-specific assembler options
	"[no-]warn-regtype-mismatch[=strict|relaxed|no]".
	* NEWS: Mention new s390-specific register name type checks and
	related assembler option "warn-regtype-mismatch=strict|
	relaxed|no".
	* testsuite/gas/s390/s390.exp: Add test cases for new assembler
	option "warn-regtype-mismatch={strict|relaxed}".
	* testsuite/gas/s390/esa-g5.s: Fix register types in tests for
	didbr, diebr, tbdr, and tbedr.
	* testsuite/gas/s390/zarch-z13.s: Fix register types in tests
	for vgef, vgeg, vscef, and vsceg.
	* testsuite/gas/s390/zarch-warn-regtype-mismatch-strict.s:
	Tests for assembler option "warn-regtype-mismatch=strict".
	* testsuite/gas/s390/zarch-warn-regtype-mismatch-strict.l:
	Likewise.
	* gas/testsuite/gas/s390/zarch-warn-regtype-mismatch-relaxed.s:
	Tests for assembler option "warn-regtype-mismatch=relaxed".
	* gas/testsuite/gas/s390/zarch-warn-regtype-mismatch-relaxed.l:
	Likewise.
	* gas/testsuite/gas/s390/zarch-omitted-base-index-err.s: Update
	test cases for assembler option "warn-regtype-mismatch"
	defaulting to "relaxed".
	* testsuite/gas/s390/zarch-omitted-base-index-err.l: Likewise.

include/
	* opcode/s390.h (S390_INSTR_FLAG_PSEUDO_MNEMONIC): Add
	instruction flag to tag .insn pseudo-mnemonics.

opcodes/
	* s390-opc.c (s390_opformats): Tag .insn pseudo-mnemonics as
	such.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
0a4b39672b s390: Revise s390-specific assembler option descriptions
Reorder, reword, and complete the s390-specific option descriptions.
Align the formatting of s390-specific assembler options to that of the
general assembler options in "as --help".

While at it change a warning message to use the term "z/Architecture"
instead of the deprecated "esame" (ESA Modal Extensions or ESAME) one.

gas/
	* config/tc-s390.c: Revise s390-specific assembler option
	descriptions.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
c3d72d73f8 s390: Add test case for disassembler option warn-areg-zero
gas/
	* testsuite/gas/s390/s390.exp: Add test cases for s390-specific
	assembler option "warn-areg-zero".
	* testsuite/gas/s390/zarch-warn-areg-zero.s: Likewise.
	* testsuite/gas/s390/zarch-warn-areg-zero.l: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
bd0ee1ee41 s390: Add test cases for base/index register 0
While at it add comments to logic to omit base and/or index register 0
in s390 disassembly.

opcodes/
	* s390-dis.c: Add comments related to omitting base and/or index
	register 0 in disassembly.
gas/
	* testsuite/gas/s390/s390.exp: Add test cases for base and/or
	index register 0.
	* testsuite/gas/s390/zarch-base-index-0.s: Add test cases for
	base and/or index register 0.
	* testsuite/gas/s390/zarch-base-index-0.d: Likewise.
	* testsuite/gas/s390/zarch-base-index-0-err.s: Add error test
	cases for base and/or index register 0.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
a0af167da2 s390: Add comments to assembler operand parsing logic
gas/
	* config/tc-s390.c: Add comments to assembler operand parsing
	logic.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
566d4098fd s390: Assemble processor specific test cases for their processor
Assemble the esa-g5 test case with -march=g5.
Assemble the zarch-z900 test case with -march=z900.

gas/
	* testsuite/gas/s390/s390.exp: Assemble processor specific test
	cases for their respective processor (-march=<processor>).

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
9c021aef48 s390: Correct setting of highgprs flag in ELF output
The combination of an architecture size of 32 bits and z/Architecture
mode requires the highgprs flag to be set in the ELF output. It causes
the high-halves of the general purpose registers (GPRs) to be preserved
at run-time, so that the code can use 64-bit GPRs.

The architecture size of 32 bits can either be the default in case of
a default architecture name of "s390" or due to specification of the
option -m31 (to generate the 31-bit file format).
The z/Architecture mode can either be the default or due to
specification of the option -mzarch (to assemble for z/Architecture
mode). It can also be selected using the pseudo commands
".machinemode zarch" and ".machinemode zarch_nohighgprs". The latter
not causing the highgprs flag to be set.

The highgprs flag was only set when the following s390-specific
assembler options were given in the following specific order:
"-m31 -mzarch".

The highgprs flag was erroneously not set when:
- the order of above options was inverse (i.e. "-mzarch -m31"),
- the architecture mode defaulted to z/Architecture mode and
  option "-m31" was specified,
- the architecture size defaulted to 32 bits due to a default
  architecture name of "s390" and option -mzarch was specified,
- the architecture size defaulted to 32 bits and the architecture
  mode defaulted to z/Architecture due to the specified processor
  (e.g. "-march=z900" or follow-on processor).

Determine whether to set the highgprs flag in init_default_arch() after
having processed all assembler options in md_parse_option(). This
ensures the flag is set in all of the above cases it was erroneously not
set. Add test cases for highgprs flag, including ones that use
.machinemode to switch the architecture mode.

gas/
	* config/tc-s390.c: Correct setting of highgprs flag in ELF
	output.
	* testsuite/gas/s390/s390.exp: Add test cases for highgprs
	flag.
	* testsuite/gas/s390/blank.s: Empty assembler source used in
	test cases for "highgprs" flag.
	* testsuite/gas/s390/esa-highgprs-0.d: Add test case for
	highgprs flag.
	* testsuite/gas/s390/zarch-highgprs-0.d: Likewise.
	* testsuite/gas/s390/zarch-highgprs-1.d: Likewise.
	* testsuite/gas/s390/esa-highgprs-machinemode-0.s: Add test case
	for highgprs flag when using .machinemode to switch
	architecture mode.
	* testsuite/gas/s390/esa-highgprs-machinemode-0.d: Likewise.
	* testsuite/gas/s390/esa-highgprs-machinemode-1.s: Likewise.
	* testsuite/gas/s390/esa-highgprs-machinemode-1.d: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
dd327181e9 s390: Do not erroneously use base operand value for length operand
The base register operand B may optionally be omitted in D(B) by coding
D and in D(L,B) by coding D(L). The index register operand X may
optionally be omitted in D(X,B) by coding D(,B) or D(B). Both base and
index register operands may optionally be omitted in D(X,B) by coding D.
In any case the omitted base and/or index register operand value
defaults to zero.

When parsing an erroneously omitted length L operand in D(L,B) by coding
D(,B) the base register operand B was erroneously consumed as length
operand. When using a register name for the base register operand this
was detected and reported as error. But when not using a register name
the base register operand value was erroneously used as length operand
value.

Correct the parsing of an omitted optional base or index register to not
erroneously use the base register operand value as length, when
erroneously omitting the length operand.

While at it rename the variable used to remember whether the base or
index register operand was omitted to enhance code readability.
Additionally add test cases for the optional omission of base and/or
index register operands.

Example assembler source:
	mvc	16(1,%r1),32(%r2)
	mvc	16(1),32(%r2)
	mvc	16(,1),32(%r2)		# undetected syntax error

Disassembly of bad assembly without commit shows the base register
operand value was erroneously used as length operand value:
   0:   d2 00 10 10 20 20       mvc     16(1,%r1),32(%r2)
   6:   d2 00 00 10 20 20       mvc     16(1,%r0),32(%r2)
   c:   d2 00 00 10 20 20       mvc     16(1,%r0),32(%r2)

Assembler messages with commit:
3: Error: operand 1: missing operand

gas/
	* config/tc-s390.c: Correct parsing of omitted base register.
	* testsuite/gas/s390/s390.exp: Add test cases for omitted base
	and/or index register.
	* testsuite/gas/s390/zarch-omitted-base-index.s: Test cases for
	omitted optional base or index register.
	* testsuite/gas/s390/zarch-omitted-base-index.d: Likewise.
	* testsuite/gas/s390/zarch-omitted-base-index-err.s: Test cases
	for omitted base and/or index register.
	* testsuite/gas/s390/zarch-omitted-base-index-err.l: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
6130dcb9e5 s390: Enhance handling of syntax errors in assembler
Do not consume any unexpected character including newline ('\n') when
detecting a syntax error when parsing an operand block with parenthesis.
This resolves the unfavorable assembler messages from the example below,
including consuming the newline at the end of the current statement and
reporting the next statement as junk.

While at it change the only pre-increment of the current instruction
string pointer into a post-increment to align with the other instances.

Example assembler source:
	mvi	16(),32		# syntax error
	a	%r1,16(%r2	# syntax error
	a	%r1,16(%r2)
	mvc	16(1,),32(%r2)	# syntax error
	mvc	16(1,%r1,32(%r2	# syntax error

Assembler messages without commit:
1: Error: bad expression
1: Error: syntax error; missing ')' after base register
1: Error: syntax error; expected ','
1: Error: junk at end of line: `32'
2: Error: syntax error; missing ')' after base register
2: Error: junk at end of line: `a %r1,16(%r2)'
4: Error: bad expression
4: Error: syntax error; missing ')' after base register
4: Error: syntax error; expected ','
4: Error: operand out of range (32 is not between 0 and 15)
4: Error: syntax error; missing ')' after base register
4: Error: junk at end of line: `%r2)'
5: Error: syntax error; missing ')' after base register
5: Error: syntax error; expected ','
5: Error: operand out of range (32 is not between 0 and 15)
5: Error: syntax error; missing ')' after base register
5: Error: junk at end of line: `%r2'

Assembler messages with commit:
1: Error: bad expression
1: Error: syntax error; missing ')' after base register
2: Error: syntax error; missing ')' after base register
4: Error: bad expression
4: Error: syntax error; missing ')' after base register
5: Error: syntax error; missing ')' after base register
5: Error: syntax error; missing ')' after base register

gas/
	* config/tc-s390.c: Do not erroneously consume newline when
	parsing an addressing operand with parentheses.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
5159682a61 s390: Lower severity of assembler syntax errors from fatal to error
Report s390 assembler syntax errors as error instead of fatal error.
This allows the assembler to continue and potentially report further
syntax errors in the source. This should not cause syntax errors to
be erroneously accepted, as both error and fatal error cause the
assembler to return with a non-zero return code.

The following syntax errors are changed from fatal to error:
- invalid length field specified
- odd numbered general purpose register specified as register pair
- invalid floating point register pair.  Valid fp register pair operands
  are 0, 1, 4, 5, 8, 9, 12 or 13.

gas/
	* config/tc-s390.c: Lower severity of assembler syntax errors
	from fatal to error.
	* testsuite/gas/s390/zarch-z9-109-err.l: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
996097d5ca s390: Use proper string lengths when parsing opcode table flags
opcodes/
	* s390-mkopc.c: Use proper string lengths when parsing opcode
	table flags.

Fixes: c5306fed7d ("s390: Support for jump visualization in disassembly")
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
2024-03-01 11:12:40 +01:00
Jens Remus
d9d4fc898d s390: Whitespace fixes in conditional branch flavor descriptions
opcodes/
	* s390-mkopc.c: Whitespace fixes in conditional branch flavor
	descriptions.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
2024-03-01 11:12:40 +01:00
Jan Beulich
fabb73d1bb x86: adjust which Dwarf2 register numbers to use
Consumers can't know which execution mode is in effect for a certain
piece of code; they can only go from object file properties. Hence which
register numbers to encode ought to depend solely on object file type.

In tc_x86_frame_initial_instructions() do away with parsing a register
name: We have a symbolic constant already for the 64-bit case, and the
32-bit number isn't going to change either. Said constant's definition
needs moving, though, to be available also for non-ELF. While moving
also adjust the comment to clarify that it's applicable to 64-bit mode
only.
2024-03-01 09:25:59 +01:00
Jan Beulich
77b07380de gas/NEWS: drop mention of Arm64's SVE2.1 and SME2.1
... plus the SME part of B16B16. As per

https://sourceware.org/pipermail/binutils/2024-February/132408.html

SVE2.1 support is both incomplete and buggy. SME2.1 "support" goes as
far as a single instruction (a subset of movaz forms) only. The SME part
of B16B16 is entirely missing.
2024-03-01 09:23:34 +01:00
Jan Beulich
09de03fce5 x86/APX: honor -mevexwig= for byte-size insns
These uniformly ignore EVEX.W, and hence what we emit ought to be
controllable by the command line option.
2024-03-01 09:22:46 +01:00
Jan Beulich
c73a37b268 x86/APX: optimize certain XOR and SUB forms
While most logic in optimize_encoding() is already covering APX by way
of the earlier NDD->REX2 conversion, there's a remaining set of cases
which wants handling separately.
2024-03-01 09:21:40 +01:00
Jan Beulich
6804f42c67 x86/APX: correct .insn opcode space determination when REX2 is needed
In this case spaces 0f38 and 0f3a may not be put in place. To achieve
the intended effect, operand parsing (but not operand processing) needs
pulling ahead, so we know whether eGRP-s are in use.
2024-03-01 09:20:56 +01:00
Jan Beulich
eb3f3841da x86/APX: respect {vex}/{vex3}
Even when an EVEX encoding is available, use of such a prefix ought to
be respected (resulting in an error) rather than ignored. As requested
during review already, introduce a new encoding enumerator to record use
of eGPR-s, and update state transitions accordingly.

The optimize_encoding() change also addresses an internal assembler
error that was previously raised when respective memory operands used
eGPR-s for addressing.

While this results in a change of diagnostic issued for VEX-encoded
insns, the new one is at least no worse than the prior one.
2024-03-01 09:19:58 +01:00
Tom Tromey
932e5949a9 Use DW_FORM_ref_addr for DIE offset in .debug_names
Today I realized that while the .debug_names writer uses DW_FORM_udata
for the DIE offset, DW_FORM_ref_addr would be more appropriate here.
This patch makes this change.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31361
2024-02-29 17:12:58 -07:00
GDB Administrator
3f13a7b28c Automatic date update in version.in 2024-03-01 00:00:49 +00:00
Alan Modra
d5c5b27095 PR19871, description of --pie
Say why we even mention shared libraries here (ET_DYN), and clarify
symbol resolution.  There are of course many other ways that PIEs
resemble PDEs more closely than shared libraries.

	PR 19871
	* ld.texi (-pie): Clarify.
2024-03-01 09:22:32 +10:30
Tom Tromey
f9771d0e80 Synchronize GCC compile plugin headers
This patch copies some changes to the compile headers from GCC's
include/ directory.  It is the gdb equivalent of the GCC commit
bc0e18a9 -- however, while that commit also necessarily touched
libcc1, this one of course does not.

Tested by rebuilding and also running the gdb.compile tests.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31397
2024-02-29 15:34:38 -07:00
Srinath Parvathaneni
4b067447e1 aarch64: Fix the 2nd operand in gcsstr and gcssttr instructions.
The assembler wrongly expects plain register name instead of
memory-form 2nd operand for gcsstr and gcssttr instructions.
This patch fixes the issue.
2024-02-29 21:06:35 +00:00
Tom de Vries
032d23a6db [gdb/dap] Fix stray KeyboardInterrupt after cancel
When running test-case gdb.dap/pause.exp 100 times in a loop, it passes
100/100.

But if we remove the two "sleep 0.2" from the test-case, we run into
(copied from dap.log and edited for readability):
...
Traceback (most recent call last):
  File "startup.py", line 251, in message
    def message():

KeyboardInterrupt
Quit
...

This happens as follows.

CancellationHandler.cancel calls gdb.interrupt to cancel a request in flight.

The idea is that this interrupt triggers while in fn here in message (a nested
function of send_gdb_with_response):
...
    def message():
        try:
            val = fn()
            result_q.put(val)
        except (Exception, KeyboardInterrupt) as e:
            result_q.put(e)
...
but instead it triggers outside the try/except.

Fix this by:
- in CancellationHandler, renaming variable in_flight to in_flight_dap_thread,
  and adding a variable in_flight_gdb_thread to be able to distinguish when
  a request is in flight in the dap thread or the gdb thread.
- adding a wrapper Cancellable to to deal with cancelling the wrapped
  event
- using Cancellable in send_gdb and send_gdb_with_response to wrap the posted
  event
- in CancellationHandler.cancel, only call gdb.interrupt if
  req == self.in_flight_gdb_thread.

This makes the test-case pass 100/100, also when adding the extra stressor of
"taskset -c 0", which makes the fail more likely without the patch.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>

PR dap/31275
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31275
2024-02-29 21:29:34 +01:00
Tom de Vries
fd09caf44f [gdb/dap] Move send_gdb and send_gdb_with_response to server module
Move functions send_gdb and send_gdb_with_response, as well as class Invoker
to server module.

Separated out to make the following patch easier to read.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-02-29 21:29:34 +01:00
Thiago Jung Bauermann
bbb12eb9c8 gdb/arm: Remove tpidruro register from non-FreeBSD target descriptions
Commit 92d48a1e4e ("Add an arm-tls feature which includes the tpidruro
register from CP15.") introduced the org.gnu.gdb.arm.tls feature, which
adds the tpidruro register, and unconditionally enabled it in
aarch32_create_target_description.

In Linux, the tpidruro register isn't available via ptrace in the 32-bit
kernel but it is available for an aarch32 program running under an arm64
kernel via the ptrace compat interface.  This isn't currently implemented
however, which causes GDB on arm-linux with 64-bit kernel to list the
register but show it as unavailable, as reported by Tom de Vries:

  $ gdb -q -batch a.out -ex start -ex 'p $tpidruro'
  Temporary breakpoint 1 at 0x512

  Temporary breakpoint 1, 0xaaaaa512 in main ()
  $1 = <unavailable>

Simon Marchi then clarified:

> The only time we should be seeing some "unavailable" registers or memory
> is in the context of tracepoints, for things that are not collected.
> Seeing an unavailable register here is a sign that something is not
> right.

Therefore, disable the TLS feature in aarch32 target descriptions for Linux
and NetBSD targets (the latter also doesn't seem to support accessing
tpidruro either, based on a quick look at arm-netbsd-nat.c).

This patch fixes the following tests:

Running gdb.base/inline-frame-cycle-unwind.exp ...
FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 3: backtrace when the unwind is broken at frame 3
FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 5: backtrace when the unwind is broken at frame 5
FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 1: backtrace when the unwind is broken at frame 1

Tested with Ubuntu 22.04.3 on armv8l-linux-gnueabihf in native,
native-gdbserver and native-extended-gdbserver targets with no regressions.

PR tdep/31418
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31418

Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-02-29 12:27:27 -03:00
H.J. Lu
801977ce47 bfd: Add ATTRIBUTE_HIDDEN to x86 internal functions
* elfxx-x86.h: Add ATTRIBUTE_HIDDEN to internal functions.
	* libbfd-in.h (_bfd_get_link_info): Add ATTRIBUTE_HIDDEN.
	* libbfd.h: Regenerated.
2024-02-29 04:32:26 -08:00
Alan Modra
f757c5cae9 PR21739, Inconsistent diagnostics
PR 21739
cpu/
	* mep.opc (parse_lo16, parse_unsigned7): Mark %function
	message as no-c-format.
opcodes/
	* mep-asm.c: Regenerate.
2024-02-29 21:07:04 +10:30
Tatsuyuki Ishi
159afbb761 RISC-V: Initial ld.bfd support for TLSDESC.
Only relocation handling for now; relaxation is not implemented yet.

bfd/
    * elfnn-riscv.c (riscv_elf_check_relocs): Record GOT reference and
    paired relocation for TLSDESC_HI20.
    (riscv_elf_adjust_dynamic_symbol): Allocate GOT and reloc slots for
    TLSDESC symbols.
    (riscv_elf_size_dynamic_sections): Likewise but for local symbols.
    (tlsdescoff): New helper to determine static addend for R_TLSDESC.
    (riscv_elf_relocate_section): Ignore TLSDESC_CALL reloc for now (it is
    relaxation only).
    Handle TLSDESC_{LOAD,ADD}_LO12 as paired pcrel relocs.
    For TLS GOT slot generation, generalize the logic to handle any
    combination of (GD, IE, TLSDESC).
    Add TLSDESC Rela generation.
    * ld/testsuite/ld-riscv-elf/tls*: Add TLSDESC instruction sequences
    next to the existing GD and IE sequences. Update expectations.
2024-02-29 15:02:55 +08:00
Tatsuyuki Ishi
e0f747d5e9 RISC-V: Define and use GOT entry size constants for TLS.
As the size calculation is split by global and local symbols, using a
shared constant definition for its size improves clarity.

bfd/
    * elfnn-riscv.c: Add macros for sizes of a normal GOT entry, TLS GD and
    TLS IE entry.
    (allocate_dynrelocs): Replace GOT size expressions with the new
    constants.
    (riscv_elf_size_dynamic_sections): Likewise.
    (riscv_elf_relocate_section): Likewise.
2024-02-29 15:02:53 +08:00
Tatsuyuki Ishi
04d352509c RISC-V: Add assembly support for TLSDESC.
gas/
    * tc-riscv.c (percent_op_*): Add support for %tlsdesc_hi,
    %tlsdesc_load_lo, %tlsdesc_add_lo and %tlsdesc_call. percent_op_rtype
    renamed to percent_op_relax_only as this matcher is extended to handle
    jalr as well which is not R-type.
    (riscv_ip): Apply the percent_op_relax_only rename and update comment.
    (md_apply_fix): Add TLSDESC_* to relaxable list. Add TLSDESC_HI20 to
    TLS relocation check list.
    * testsuite/gas/riscv/tlsdesc.*: New test cases for TLSDESC relocation
    generation.
opcodes/
    * riscv-opc.c (riscv_opcodes): Add a new syntax for jalr with
    %tlsdesc_call annotations.
2024-02-29 15:02:51 +08:00
Tatsuyuki Ishi
dc1470f1d8 RISC-V: Add TLSDESC reloc definitions.
bfd/
    * elfxx-riscv.c: Add 5 TLSDESC reloc descriptions.
    * reloc.c: Likewise.
    * libbfd.h: Regenerate.
    * bfd-in2.h: Regenerate.
include/
    * elf/riscv.h: Add 5 TLSDESC reloc descriptions.
2024-02-29 15:02:49 +08:00
Ruud van der Pas
3243d790ee gprofng: change use of bignum to use of bigint
Change the statement "use bignum" to "use bigint".  This is sufficient
for gp-display-html to work and removes the dependency on bignum.

gprofng/ChangeLog
2024-02-27  Ruud van der Pas  <ruud.vanderpas@oracle.com>

	PR 31390
	* gprofng/gp-display-html: One line change to "use bigint".
2024-02-28 16:32:29 -08:00
John Baldwin
b081c003ff aarch64: Use aarch64_debug_printf in a few more places
No functional change

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-02-28 16:03:16 -08:00
GDB Administrator
d3da86d037 Automatic date update in version.in 2024-02-29 00:00:32 +00:00
Alan Modra
62143ef92c PR23877, bad value (n32r5900) for default CPU
Catching this at configure time would be nicer, but we'd need to exactly
match mips_parse_cpu in configure.ac and keep it all in sync.

	PR 23877
	* config/tc-mips.c (mips_after_parse_args): Don't assert that
	mips_parse_cpu returns non-NULL, call as_fatal with an informative
	message instead.
2024-02-29 08:55:51 +10:30
Vladislav Belov
60856b5cda Fix implementation of SUBALIGN. 2024-02-28 16:36:37 +00:00
Tom Tromey
8bb8f83467 Fix gdb.interrupt race
gdb.interrupt was introduced to implement DAP request cancellation.
However, because it can be run from another thread, and because I
didn't look deeply enough at the implementation, it turns out to be
racy.

The fix here is to lock accesses to certain globals in extension.c.

Note that this won't work in the case where configure detects that the
C++ compiler doesn't provide thread support.  This version of the
patch disables DAP entirely in this situation.

Regression tested on x86-64 Fedora 38.  I also ran gdb.dap/pause.exp
in a thread-sanitizer build tree to make sure the reported race is
gone.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31263
2024-02-28 09:08:16 -07:00
Alan Modra
4b72a278f4 PR23881, pdp11 binutils fails if too much debug data
The PR testcase overflows one of the exec header fields, e_syms (the
size of the symbol table), leading to the string table offset being
wrong.  Things go downhill from there.  Fixed by checking for
overflow.  This happens to trigger in the ld testsuite, so xfail that
test.

	PR 23881
bfd/
	* libaout.h (swap_exec_header_out): Return a bool.
	* aoutx.h (swap_exec_header_out): Check for overflow in exec
	header.
	* pdp11.c (swap_exec_header_out): Likewise.
	* i386lynx.c (WRITE_HEADERS): Adjust.
ld/
	* testsuite/ld-scripts/map-address.exp: xfail pdp11.
2024-02-28 21:24:39 +10:30
GDB Administrator
4e0d612410 Automatic date update in version.in 2024-02-28 00:00:28 +00:00
Tom Tromey
407ca65454 Two minor addrmap cleanups
While working on a different patch, I found a couple of simple addrmap
cleanups.

In one case, a forward declaration is no longer needed, as the header
now includes addrmap.h.

In the other, an include of addrmap.h is no longer needed.

Tested by rebuilding.
2024-02-27 14:30:51 -07:00
Tom Tromey
b452b96c1e Explicitly quit gdb from DAP server thread
This changes the DAP code to explicitly request that gdb exit.
Previously this could cause crashes, but with the previous cleanups,
this should no longer happen.

This also adds a tests that ensures that gdb exits with status 0.
2024-02-27 10:30:30 -07:00
Tom Tromey
6313c05640 Add final cleanup for runnables
This changes run-on-main-thread.c to clear 'runnables' in a final
cleanup.  This avoids an issue where a pending runnable could require
Python, but be run after the Python interpreter was finalized.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31172
2024-02-27 10:30:29 -07:00
Tom Tromey
ec471b627a Change finalize_values into a final cleanup
This removes finalize_values in favor of adding a new final cleanup.
This is safe now that extension languages are explicitly shut down.
2024-02-27 10:30:29 -07:00
Tom Tromey
beadf91284 Add extension_language_ops::shutdown
Right now, Python is shut down via a final cleanup.  However, it seems
to me that it is better for extension languages to be shut down
explicitly, after all the ordinary final cleanups are run.  The main
reason for this is that a subsequent patch adds another case like
finalize_values; and rather than add a series of workarounds for
Python shutdown, it seemed better to let these be done via final
cleanups, and then have Python shutdown itself be the special case.
2024-02-27 10:30:29 -07:00
Tom Tromey
1eae7be116 Rewrite final cleanups
This patch rewrites final cleanups to use std::function and otherwise
be more C++-ish.
2024-02-27 10:30:29 -07:00
Tom Tromey
cfe51255b8 Use the .py file in gdb.dap/pause.exp
Tom de Vries pointed out that the gdb.dap/pause.exp test writes a
Python file but then does not use it.  This patch corrects the
oversight.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31354
Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-02-27 09:46:31 -07:00
Tom Tromey
a207f6b3a3 Rewrite "python" command exception handling
The "python" command (and the Python implementation of the gdb
"source" command) does not handle Python exceptions in the same way as
other gdb-facing Python code.  In particular, exceptions are turned
into a generic error rather than being routed through
gdbpy_handle_exception, which takes care of converting to 'quit' as
appropriate.

I think this was done this way because PyRun_SimpleFile and friends do
not propagate the Python exception -- they simply indicate that one
occurred.

This patch reimplements these functions to respect the general gdb
convention here.  As a bonus, some Windows-specific code can be
removed, as can the _execute_file function.

The bulk of this change is tweaking the test suite to match the new
way that exceptions are displayed.  These changes are largely
uninteresting.  However, it's worth pointing out the py-error.exp
change.  Here, the failure changes because the test changes the host
charset to something that isn't supported by Python.  This then
results in a weird error in the new setup.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31354
Acked-By: Tom de Vries <tdevries@suse.de>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-02-27 09:46:31 -07:00
Tom Tromey
8ee6f71b1a Fix formatting buglet in python.c
python.c has a split string that is missing a space.  There's also a
stray backslash in this code.

Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-02-27 09:46:31 -07:00