]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
11 months agoLoongArch: Add DT_RELR support
Xi Ruoyao [Sun, 30 Jun 2024 07:18:24 +0000 (15:18 +0800)] 
LoongArch: Add DT_RELR support

The logic is same as a71d87680110 ("aarch64: Add DT_RELR support").

As LoongArch does not have -z dynamic-undefined-weak, we don't need to
consider UNDEFWEAK_NO_DYNAMIC_RELOC.

The linker relaxation adds another layer of complexity.  When we delete
bytes in a section during relaxation, we need to fix up the offset in
the to-be-packed relative relocations against this section.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
11 months agoLoongArch: Make protected function symbols local for -shared
Xi Ruoyao [Sun, 30 Jun 2024 07:18:23 +0000 (15:18 +0800)] 
LoongArch: Make protected function symbols local for -shared

On LoongArch there is no reason to treat STV_PROTECTED STT_FUNC symbols
as preemptible.  See the comment above LARCH_REF_LOCAL for detailed
explanation.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
11 months agoLoongArch: Fix bad reloc with mixed visibility ifunc symbols in shared libraries
Xi Ruoyao [Sun, 30 Jun 2024 07:18:22 +0000 (15:18 +0800)] 
LoongArch: Fix bad reloc with mixed visibility ifunc symbols in shared libraries

With a simple test case:

    .globl  ifunc
    .globl  ifunc_hidden
    .hidden ifunc_hidden
    .type   ifunc, %gnu_indirect_function
    .type   ifunc_hidden, %gnu_indirect_function

    .text
    .align  2
    ifunc:  ret
    ifunc_hidden: ret

    test:
      bl ifunc
      bl ifunc_hidden

"ld -shared" produces a shared object with one R_LARCH_NONE (instead of
R_LARCH_JUMP_SLOT as we expect) to relocate the GOT entry of "ifunc".
It's because the indices in .plt and .rela.plt mismatches for
STV_DEFAULT STT_IFUNC symbols when another PLT entry exists for a
STV_HIDDEN STT_IFUNC symbol, and such a mismatch breaks the logic of
loongarch_elf_finish_dynamic_symbol.  Fix the issue by reordering .plt
so the indices no longer mismatch.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
11 months agoLoongArch: Reject R_LARCH_32 from becoming a runtime reloc in ELFCLASS64
Xi Ruoyao [Sun, 30 Jun 2024 07:18:21 +0000 (15:18 +0800)] 
LoongArch: Reject R_LARCH_32 from becoming a runtime reloc in ELFCLASS64

We were converting R_LARCH_32 to R_LARCH_RELATIVE for ELFCLASS64:

    $ cat t.s
    .data
    x:
        .4byte x
.4byte 0xdeadbeef
    $ as/as-new t.s -o t.o
    $ ld/ld-new -shared t.o
    $ objdump -R
    a.out:     file format elf64-loongarch

    DYNAMIC RELOCATION RECORDS
    OFFSET           TYPE              VALUE
    00000000000001a8 R_LARCH_RELATIVE  *ABS*+0x00000000000001a8

But this is just wrong: at runtime the dynamic linker will run
*(uintptr *)&x += load_address, clobbering the next 4 bytes of data
("0xdeadbeef" in the example).

If we keep the R_LARCH_32 reloc as-is in ELFCLASS64, it'll be rejected
by the Glibc dynamic linker anyway.  And it does not make too much sense
to modify Glibc to support it.  So we can just reject it like x86_64:

    relocation R_X86_64_32 against `.data' can not be used when making a
    shared object; recompile with -fPIC

or RISC-V:

    relocation R_RISCV_32 against non-absolute symbol `a local symbol'
    can not be used in RV64 when making a shared object

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
11 months agox86: Correct position of ".s" for CCMPcc in disassembler
Cui, Lili [Fri, 5 Jul 2024 01:55:41 +0000 (09:55 +0800)] 
x86: Correct position of ".s" for CCMPcc in disassembler

Added new macro %SW to CCMPcc to print ".s" after the mnemonic.

Before:
ccmpbl {dfv=}.s %edx,%eax

After:
ccmpbl.s {dfv=} %edx,%eax

gas/ChangeLog:

        * testsuite/gas/i386/x86-64-pseudos-apx.d: Add tests for CCMPcc.
        * testsuite/gas/i386/x86-64-pseudos-apx.s: Ditto.

opcodes/ChangeLog:

        * i386-dis-evex.h: Added %SW for CCMPcc swap operands.
        * i386-dis.c (struct dis386): Added %SW.
        (putop): Handle %SW.

11 months agox86: Add {load}/{store} tests for apx instructions.
Cui, Lili [Fri, 5 Jul 2024 01:55:41 +0000 (09:55 +0800)] 
x86: Add {load}/{store} tests for apx instructions.

gas/ChangeLog:

        * testsuite/gas/i386/x86-64.exp: Add {load}/{store} tests for apx
instructions.
        * testsuite/gas/i386/x86-64-pseudos-apx.d: New test.
        * testsuite/gas/i386/x86-64-pseudos-apx.s: Ditto.

11 months agoAutomatic date update in version.in
GDB Administrator [Fri, 5 Jul 2024 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agoRISC-V: Fix BFD_RELOC_RISCV_PCREL_LO12_S patch issue
Sun Sunny [Thu, 4 Jul 2024 03:03:37 +0000 (03:03 +0000)] 
RISC-V: Fix BFD_RELOC_RISCV_PCREL_LO12_S patch issue

In commit dff565fcca8137954d6ad571ef39f6aec5c0429c, the fixups
for PCREL_LO12_I and PCREL_LO12_S were mixed, so the "IMM"
field were applied to incorrect position, this caused incorrect
src registers to be encoded.

gas/
* config/tc-riscv.c (md_apply_fix): Fix PCREL_LO12_S issue.
* testsuite/gas/riscv/ixup-local.s: Updated for PCREL_LO12_S cases.
* testsuite/gas/riscv/fixup-local-relax.d: Likewise.
* testsuite/gas/riscv/fixup-local-norelax.d: Likewise.

Signed-off-by: Jianwei Sun <sunny.sun@corelabtech.com>
11 months agoRISC-V: hash with segment id and pcrel_hi address while recording pcrel_hi
Lifang Xia [Thu, 4 Jul 2024 01:56:07 +0000 (09:56 +0800)] 
RISC-V: hash with segment id and pcrel_hi address while recording pcrel_hi

When the same address across different segments (sections) needs to be
recorded, it will overwrite the slot, leading to a memory leak. To ensure
uniqueness, the segment (section) ID needs to be included in the hash key
calculation.

gas/
* config/tc-riscv.c (riscv_pcrel_hi_fixup): New "const asection *sec".
(riscv_pcrel_fixup_hash): make sec->id and e->adrsess as the
hash key.
(riscv_pcrel_fixup_eq): Check sec->id at first.
(riscv_record_pcrel_fixup): New member "sec".
(md_apply_fix) <case BFD_RELOC_RISCV_PCREL_HI20>: Likewise.
(md_apply_fix) <case BFD_RELOC_RISCV_PCREL_LO12_I>: Likewise.

11 months agomve: Fix encoding for vcvt[bt] single-half float conversion instructions
Andre Vieira [Thu, 4 Jul 2024 12:45:53 +0000 (13:45 +0100)] 
mve: Fix encoding for vcvt[bt] single-half float conversion instructions

The encoding was previously not taking into account that the Quad vector
registers were being encoded using their Q-register numbers rather than their
D-register equivalent (multiply by 2).

gas/

* config/tc-arm.c (do_neon_cvttb_1): Use Q-register vector number
rather than their D-register equivalent.

gas/testsuite/

* gas/arm/mve-vcvt-3.d: Correct expected values in test.

11 months agogas: Validate SFrame RA tracking and fixed RA offset
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Validate SFrame RA tracking and fixed RA offset

Verify all architectures participating in SFrame generation do define
the mandatory SFrame return address (RA) tracking predicate function
sframe_ra_tracking_p. Do so by explicitly not testing for the macro
SFRAME_FRE_RA_TRACKING as otherwise required.

Verify that architectures not using SFrame RA tracking specify a valid
fixed RA offset.

gas/
* gen-sframe.c (output_sframe_internal): Validate SFrame
RA tracking and fixed RA offset.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agogas: Test predicate whether SFrame RA tracking is used
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Test predicate whether SFrame RA tracking is used

The existence of the macro SFRAME_FRE_RA_TRACKING only ensures the
existence of the macro SFRAME_CFA_RA_REG and the predicate function
sframe_ra_tracking_p. It does not indicate whether SFrame RA tracking
is actually used.

Test the return value of the SFrame RA tracking predicate function
sframe_ra_tracking_p to determine whether RA tracking is used.

This aligns the logic in functions get_fre_num_offsets and
output_sframe_row_entry to the one used in all other places.

gas/
* gen-sframe.c (get_fre_num_offsets, output_sframe_row_entry):
Test predicate to determine whether SFrame RA tracking is used.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agogas: Don't skip SFrame FDE if .cfi_register specifies SP register
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Don't skip SFrame FDE if .cfi_register specifies SP register

Neither ".cfi_offset SP, <offset>", ".cfi_register SP, <regno>", nor
".cfi_val_offset SP, <offset>" alter the tracking information to recover
the stack pointer (SP). Doing so would need an explicit .cfi_def_cfa,
which SFrame tracks.

The stack pointer (SP) register contents on entry can be reconstructed
from the SFrame CFA tracking information using information from the
current and initial SFrame FREs of the SFrame FDE:

1. Compute CFA from the current CFA base register (SP or FP) and CFA
   offset from the SFrame CFA tracking information from the SFrame FRE
   for the current instruction address:

     CFA = <current_base_reg> + <current_cfa_offset>

2. Compute SP from the current CFA and the CFA offset from the SFrame
   CFA tracking information from the initial SFrame FRE of the FDE:

     SP = CFA - <initial_cfa_offset>

While at it add comments to the processing of .cfi_offset and
.cfi_val_offset that the SP can be reconstructed from the CFA tracking
information.

gas/
* gen-sframe.c (sframe_xlate_do_register): Do not skip SFrame
FDE if .cfi_register specifies SP register.
(sframe_xlate_do_offset,sframe_xlate_do_val_offset): Add comment
that this is likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agogas: Don't skip SFrame FDE if .cfi_register specifies RA w/o tracking
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Don't skip SFrame FDE if .cfi_register specifies RA w/o tracking

Do not skip SFrame FDE if .cfi_register specifies RA register without
RA tracking being actually used. Without RA tracking the register
contents can always be restored from the stack using the fixed
RA offset from CFA.

gas/
* gen-sframe.c (sframe_xlate_do_register): Do not skip SFrame
FDE if .cfi_register specifies RA register without RA tracking
being used.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agogas: Skip SFrame FDE if .cfi_window_save
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Skip SFrame FDE if .cfi_window_save

CFI opcode DW_CFA_AARCH64_negate_ra_state is multiplexed with
DW_CFA_GNU_window_save. Process DW_CFA_AARCH64_negate_ra_state on
AArch64. Skip generation of SFrame FDE otherwise with the following
warning message:

  skipping SFrame FDE; .cfi_window_save

gas/
* gen-sframe.c: Skip SFrame FDE if .cfi_window_save.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agogas: Skip SFrame FDE if FP without RA on stack
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Skip SFrame FDE if FP without RA on stack

The SFrame format cannot represent the frame pointer (FP) being saved
on the stack without the return address (RA) also being saved on the
stack, if RA tracking is used.

A SFrame FDE is followed by 1-3 offsets with the following information:

Without RA tracking:
1. Offset from base pointer (SP or FP) to locate the CFA
2. Optional: Offset to CFA to restore the frame pointer (FP)

With RA tracking:
1. Offset from base pointer (SP or FP) to locate the CFA
2. Optional: Offset to CFA to restore the return address (RA)
3. Optional: Offset to CFA to restore the frame pointer (FP)

When RA tracking is used and a FDE is followed by two offsets the
SFrame format does not provide any information to distinguish whether
the second offset is the RA or FP offset. SFrame assumes the offset to
be the RA offset, which may be wrong.

Therefore skip generation of SFrame FDE information and print the
following warning, if RA tracking is used and the FP is saved on the
stack without the RA being saved as well:

  skipping SFrame FDE; FP without RA on stack

gas/
* gen-sframe.c (sframe_do_fde): Skip SFrame FDE if FP without RA
on stack, as the SFrame format cannot represent this case.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agogas: User readable warnings if SFrame FDE is not generated
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: User readable warnings if SFrame FDE is not generated

The following generic warning message, which is printed whenever the
assembler skips generation of SFrame FDE, is not very helpful for the
user:

  skipping SFrame FDE; CFI insn <name> (0x<hexval>)

Whenever possible print meaningful warning messages, when the assembler
skips generation of SFrame FDE:

- skipping SFrame FDE; non-SP/FP register <regno> in .cfi_def_cfa
- skipping SFrame FDE; non-SP/FP register <regno> in
  .cfi_def_cfa_register
- skipping SFrame FDE; .cfi_def_cfa_offset without CFA base register
  in effect
- skipping SFrame FDE; {FP|RA} register <regno> in .cfi_val_offset
- skipping SFrame FDE; {SP|FP|RA} register <regno> in in .cfi_register
- skipping SFrame FDE; .cfi_remember_state without prior SFrame FRE
  state
- skipping SFrame FDE; non-default RA register <regno>

gas/
* gen-sframe.h (SFRAME_FRE_BASE_REG_INVAL): New macro for
invalid SFrame FRE CFA base register value of -1.
* gen-sframe.c: User readable warnings if SFrame FDE is not
generated.

gas/testsuite/
* gas/cfi-sframe/common-empty-1.d: Update generic SFrame test
case to updated warning message texts.
* gas/cfi-sframe/common-empty-2.d: Likewise.
* gas/cfi-sframe/common-empty-3.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agogas: Refactor SFrame CFI opcode DW_CFA_register processing
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Refactor SFrame CFI opcode DW_CFA_register processing

Refactor SFrame processing of CFI opcode DW_CFA_register into a separate
function. This harmonizes the CFI opcode processing.

While at it reword the comment on CFI opcodes that are not processed.

This is a purely mechanical change.

gas/
* gen-sframe.c (sframe_do_cfi_insn, sframe_xlate_do_register):
Refactor SFrame CFI opcode DW_CFA_register processing.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agogas: Warn if SFrame FDE is skipped due to non-default return column
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Warn if SFrame FDE is skipped due to non-default return column

Print a warning message if SFrame FDE is skipped due to a non-default
DWARF return column (i.e. return address (RA) register number). This
may be caused by the use of CFI directive .cfi_return_column with a
non-default return address (RA) register number in the processed
assembler source code.

  Warning: skipping SFrame FDE due to non-default DWARF return column

gas/
* gen-sframe.c: Warn if SFrame FDE is skipped due to non-default
DWARF return column.

gas/testsuite/
* gas/cfi-sframe/common-empty-3.d: Update test case to expect
for new warning message when SFrame FDE is skipped due to
a non-default DWARF return column.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agogas: Skip SFrame FDE if CFI specifies non-FP/SP base register
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Skip SFrame FDE if CFI specifies non-FP/SP base register

Do not generate SFrame FDE if DWARF CFI directives .cfi_def_cfa or
.cfi_def_cfa_register specify a CFA base register number other than
the architecture-specific stack-pointer (SP) or frame-pointer (FP)
register numbers.

This also causes the assembler to print a warning message, so that
skipping of the SFrame FDE does not occur silently.

Update the generic ld SFrame test case to be architecture independent.
Do not use CFI directive .cfi_def_cfa, as the specified CFA base
register number is not a valid SP/FP register number on all
architectures. An invalid SP/FP register number will now cause the
assembler to print a warning message and skip SFrame FDE generation.
Remove the offending CFI directive, that cannot be coded architecture-
independent, as the test case requires SFrame information to be
generated. This was reported by the Linaro-TCWG-CI for AArch64.

gas/
* gen-sframe.c: Skip SFrame generation if CFI specifies
non-FP/SP base register.

ld/testsuite/
* ld-sframe/discard.s: Update generic SFrame test case to be
architecture independent.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agogas: Print DWARF call frame insn name in SFrame warning message
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Print DWARF call frame insn name in SFrame warning message

SFrame generation prints the DWARF call frame instruction opcode in
hexadecimal. Leverage get_DW_CFA_name to additionally print the
DWARF call frame instruction name in human readable form, while also
respecting fake CFI types. Use "(unknown)", if the DWARF call frame
instruction name is not known.

While at it use the terminology "instruction" for these DW_CFA_*, as
suggested by Indu.

This changes the following assembler SFrame generation warning message
as follows:

Old:
Warning: skipping SFrame FDE due to DWARF CFI op 0x<hexval>

New:
Warning: skipping SFrame FDE; CFI insn <name> (0x<hexval>)

gas/
* gen-sframe.c (sframe_get_cfi_name): New function to get the
DWARF call frame instruction name for a DWARF call frame
instruction opcode.
(sframe_do_cfi_insn): Use sframe_get_cfi_name to print the
DWARF call frame instruction name for the DWARF call frame
instruction opcode in the warning message.

gas/testsuite/
* gas/cfi-sframe/common-empty-1.d: Update expected SFrame
warning message text for DWARF call frame insn name.
* gas/cfi-sframe/common-empty-2.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agoreadelf/objdump: Display SFrame fixed RA offset as 'f' in dump
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
readelf/objdump: Display SFrame fixed RA offset as 'f' in dump

For the SFrame FRE frame-pointer (FP) offset from CFA a 'u' is displayed
if it is unavailable.

For the SFrame FRE return-address (RA) offset from CFA a 'u' was
displayed if the ABI uses a fixed RA offset from CFA. By chance a
'u' was also displayed if the RA offset is unavailable, as the string
buffer was not initialized after formatting the FP offset. Note that it
could not occur that the FP offset was erroneously displayed as RA
offset, as the SFrame format cannot have a FRE with FP offset without
RA offset.

For the FRE RA offset display 'f' if the ABI uses a fixed RA offset
from CFA. Display a 'u' if it is unavailable.

libsframe/
* sframe-dump.c: Display SFrame fixed RA offset as 'f' in dump.

gas/testsuite/
* gas/cfi-sframe/cfi-sframe-common-4.d: Test for RA displayed
either as 'u' (if RA tracking) or as 'f' (fixed RA offset if no
RA tracking).
* gas/cfi-sframe/cfi-sframe-common-5.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-6.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-7.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-8.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-1.d: Test for RA displayed
as 'f' (fixed RA offset), as x86-64 does not use RA tracking.
* gas/scfi/x86_64/scfi-cfi-sections-1.d: Likewise.
* gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise.

ld/testsuite/
* ld-x86-64/sframe-plt-1.d: Test for RA displayed as 'f' (fixed
RA offset), as x86-64 does not use RA tracking.
* ld-x86-64/sframe-simple-1.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agoreadelf/objdump: Dump SFrame CFA fixed FP and RA offsets
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
readelf/objdump: Dump SFrame CFA fixed FP and RA offsets

The SFrame format allows architectures to specify fixed offsets from the
CFA, if any, from which the frame pointer (FP) and/or return address
(RA) may be recovered. These offsets are stored in the SFrame header.

For instance the SFrame generation in the assembler for x86 AMD64
specifies a fixed offset from the CFA, from which the return address
(RA) may be recovered.

When dumping the SFrame header, for instance in readelf/objdump with
option --sframe, do also dump the specified fixed offsets from the CFA,
if any, from which the frame pointer (FP) and return address (RA) may
be recovered.

Update the common SFrame test case verification patterns to allow for
the optional dumping of the CFA fixed FP/RA offsets. Update the x86-
specific SFrame and SCFI test case verification patterns to require a
CFA fixed RA offset of -8.

libsframe/
* sframe-dump.c: Dump CFA fixed FP and RA offsets.

gas/testsuite/
* gas/cfi-sframe/cfi-sframe-common-1.d: Test for optional fixed
FP and RA offsets.
* gas/cfi-sframe/cfi-sframe-common-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-3.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-4.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-5.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-6.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-7.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-8.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-1.d: Test for fixed
RA offset.
* gas/cfi-sframe/common-empty-1.d: Test for optional fixed
FP and RA offsets.
* gas/cfi-sframe/common-empty-2.d: Likewise.
* gas/cfi-sframe/common-empty-3.d: Likewise.
* gas/scfi/x86_64/scfi-cfi-sections-1.d: Test for SFrame fixed
RA offset.
* gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise.

ld/testsuite/
* ld-x86-64/sframe-plt-1.d: Test for SFrame fixed RA offset.
* ld-x86-64/sframe-simple-1.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agogas: Enhance arch-specific SFrame configuration descriptions
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Enhance arch-specific SFrame configuration descriptions

Explicitly mention "SFrame" in the descriptions for the architecture-
specific SFrame configuration macros, variables, and functions.

Use the term "frame pointer" (FP) instead of "base pointer". This aligns
with the terminology used in the SFrame specification. Additionally it
helps not to confuse "base-pointer register" with the term "BASE_REG"
used in the specification to denote either the SP or FP register.

Specify what the SFRAME_CFA_*_REG register numbers are used for:
- SP (stack pointer): CFA tracking
- FP (frame pointer): CFA and FP tracking
- RA (return address): RA tracking

Align the descriptions for definitions in the source files to the
declarations in the header files.

gas/
* config/tc-aarch64.h: Enhance architecture-specific SFrame
configuration descriptions.
* config/tc-aarch64.c: Likewise.
* config/tc-i386.h: Likewise.
* config/tc-i386.c: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agox86: Remove unused SFrame CFI RA register variable
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
x86: Remove unused SFrame CFI RA register variable

gas/
* config/tc-i386.c (x86_sframe_cfa_ra_reg): Remove.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
11 months agoSupport APX CFCMOV
Cui, Lili [Thu, 4 Jul 2024 07:49:16 +0000 (15:49 +0800)] 
Support APX CFCMOV

The CMOVcc instruction proposed by EVEX has four different forms,
corresponding to the four possible combinations of EVEX.ND and EVEX.NF
values.

In the encoder part, when the CFCMOV template supports EVEX_NF, it means that
it requires EVEX.NF to be 1.

In the decoder part, CFCMOV_Fixup is used to reverse source and destination
operands in the 2-operand case.

gas/ChangeLog:

        * config/tc-i386.c (build_apx_evex_prefix): Set NF bit for cfcmov
        when the insn template supports EVEX_NF.
        * testsuite/gas/i386/x86-64-apx-inval.l: Add invalid tests for cfcmov.
        * testsuite/gas/i386/x86-64-apx-inval.s: Ditto.
        * testsuite/gas/i386/x86-64.exp: Add tests for cfcmov and cmov.
        * testsuite/gas/i386/x86-64-apx-cfcmov-intel.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-cfcmov.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-cfcmov.s: Ditto.

opcodes/ChangeLog:

        * i386-dis-evex-prefix.h: Add cfcmov instructions.
        * i386-dis.c (CFCMOV_Fixup): Special handling of cfcmov.
        (putop): Print 'cf' for cfcmov instructions.
        * i386-opc.h (EVEX_NF): New.
        * i386-opc.tbl: Add cfcmov instructions.
        * i386-mnem.h: Regerated.
        * i386-tbl.h: Regerated.

11 months agoAutomatic date update in version.in
GDB Administrator [Thu, 4 Jul 2024 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agoRISC-V: Tidy and complete testing of all architecture imply rules.
Nelson Chu [Tue, 2 Jul 2024 07:37:42 +0000 (15:37 +0800)] 
RISC-V: Tidy and complete testing of all architecture imply rules.

gas/
* testsuite/gas/riscv/imply.s: New testcase for all imply cases.
* testsuite/gas/riscv/imply.d: Likewise.
* testsuite/gas/riscv/march-imply-i.s: Renamed to
imply-zicsr-zifencei.s.
* testsuite/gas/riscv/march-imply-i2p0-02.d: Renamed to
imply-zicsr-zifencei-i2p0-misa-spec-2p2.d.
* testsuite/gas/riscv/march-imply-i2p1-01.d/l: Renamed to
imply-zicsr-zifencei-i2p1-misa-spec-20191213.d.
* testsuite/gas/riscv/march-imply-i2p0-01.d: Removed.
Combined into new imply testcase.
* testsuite/gas/riscv/march-imply-i2p1-02.d: Likewise.
* testsuite/gas/riscv/march-imply-a.d: Likewise.
* testsuite/gas/riscv/march-imply-b.d: Likewise.
* testsuite/gas/riscv/march-imply-f.d: Likewise.
* testsuite/gas/riscv/march-imply-g.d: Likewise.
* testsuite/gas/riscv/march-imply-h.d: Likewise.
* testsuite/gas/riscv/march-imply-q.d: Likewise.
* testsuite/gas/riscv/march-imply-smcsrind.d: Likewise.
* testsuite/gas/riscv/march-imply-smstateen.d: Likewise.
* testsuite/gas/riscv/march-imply-unsupported.d: Likewise.
* testsuite/gas/riscv/march-imply-v.d: Likewise.
* testsuite/gas/riscv/march-imply-zcd.d: Likewise.
* testsuite/gas/riscv/march-imply-zcf.d: Likewise.

11 months agoAvoid possible signed overflow in decode_local_label_name
Alan Modra [Mon, 1 Jul 2024 14:32:33 +0000 (00:02 +0930)] 
Avoid possible signed overflow in decode_local_label_name

Matches what both fb_label_name and dollar_label_name use.

* symbols.c (decode_local_label_name): Use unsigned variables.

11 months agogas/doc/riscv: Fixed typo of `.insn cj' format
Nelson Chu [Wed, 3 Jul 2024 03:39:55 +0000 (11:39 +0800)] 
gas/doc/riscv: Fixed typo of `.insn cj' format

gas/
* doc/c-riscv.texi: Fixed typo of `.insn cj' format.

11 months agox86-64: Support APX NF TLS IE with 2 operands
Lingling Kong [Tue, 2 Jul 2024 07:49:19 +0000 (15:49 +0800)] 
x86-64: Support APX NF TLS IE with 2 operands

Support APX NF TLS IE with 2 operands.Verify it with ld and gold.

gas/

* config/tc-i386.c (md_assemble): Allow APX NF TLS IE with
2 operands.
* testsuite/gas/i386/x86-64-gottpoff.d: Updated.
* testsuite/gas/i386/x86-64-gottpoff.s: Add APX NF TLS IE
tests with 2 operands.

gold/

* testsuite/x86_64_ie_to_le.s: Add APX NF TLS IE tests with
2 operands.
* testsuite/x86_64_ie_to_le.sh: Updated.

ld/

* testsuite/ld-x86-64/tlsbindesc.s: Add APX NF TLS IE tests
with 2 operands.
* testsuite/ld-x86-64/tlsbindesc.d: Updated.
* testsuite/ld-x86-64/tlsbindesc.rd: Likewise.

11 months agogas/doc/riscv: Fixed syntax of `.option arch' when reseting whole architecture
Nelson Chu [Wed, 3 Jul 2024 01:40:53 +0000 (09:40 +0800)] 
gas/doc/riscv: Fixed syntax of `.option arch' when reseting whole architecture

gas/
* doc/c-riscv.texi: Fixed syntax of `.option arc'h when reseting whole
architecture.  Don't need the `=' before ISA.

11 months agoAutomatic date update in version.in
GDB Administrator [Wed, 3 Jul 2024 00:00:16 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agoAccept unnamed array in gdb.ada/limited-length.exp
Tom Tromey [Tue, 2 Jul 2024 14:32:36 +0000 (08:32 -0600)] 
Accept unnamed array in gdb.ada/limited-length.exp

Some compiler changes I'm working on cause a regression in
gdb.ada/limited-length.exp -- with the changes, the array type is
nameless and so is not mentioned in the max-value-size error message.

Because the array type is nameless in the source code, this seems like
an improvement to me, and so this patch changes the test to accept
either form.

11 months agoUse lwp field in ptid for AIX.
Aditya Vidyadhar Kamath [Fri, 7 Jun 2024 12:52:40 +0000 (18:22 +0530)] 
Use lwp field in ptid for AIX.

Currently in AIX, the private data is used to maintain the kernel thread ID.

This is a patch to trim the need to have another field in the private data of a thread in AIX.

We want to use the lwp field to represent the kernel thread ID to match or
make things similar to the Linux targets.

11 months agox86-64: Verify that TLS IE works with APX NF
konglin1 [Tue, 2 Jul 2024 06:01:12 +0000 (23:01 -0700)] 
x86-64: Verify that TLS IE works with APX NF

Verify that

{nf} add %reg1, foo@gottpoff(%rip), %reg2
{nf} add foo@gottpoff(%rip), %reg, %reg2

work correctly with ld and gold.

gas/

* testsuite/gas/i386/x86-64-gottpoff.d: Updated.
* testsuite/gas/i386/x86-64-gottpoff.s: Add tests for
"{nf} add %reg1, foo@gottpoff(%rip), %reg2" and
"{nf} add foo@gottpoff(%rip), %reg, %reg2".

gold/

* testsuite/x86_64_ie_to_le.s: Add tests for
"{nf} add %reg1, foo@gottpoff(%rip), %reg2" and
"{nf} add foo@gottpoff(%rip), %reg, %reg2".
* testsuite/x86_64_ie_to_le.sh: Updated.

ld/

* testsuite/ld-x86-64/tlsbindesc.s: Add R_X86_64_CODE_6_GOTTPOFF
for APX NF tests.
* testsuite/ld-x86-64/tlsbindesc.d: Updated.
* testsuite/ld-x86-64/tlsbindesc.rd: Likewise.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
11 months agoAutomatic date update in version.in
GDB Administrator [Tue, 2 Jul 2024 00:00:52 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agold: Move foo before delete in dl5.cc
H.J. Lu [Mon, 1 Jul 2024 09:22:45 +0000 (02:22 -0700)] 
ld: Move foo before delete in dl5.cc

* testsuite/ld-elf/dl5.cc (main): Move foo before delete.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
11 months agoMAINTAINERS: Update my e-mail address
Claudiu Zissulescu [Mon, 1 Jul 2024 07:58:17 +0000 (10:58 +0300)] 
MAINTAINERS: Update my e-mail address

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
11 months agoLoongArch: Remove unused code in ld test suite
Xi Ruoyao [Sat, 22 Jun 2024 10:06:47 +0000 (18:06 +0800)] 
LoongArch: Remove unused code in ld test suite

These seems some left over from MIPS code and they do not make any
sense for LoongArch.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
11 months agoPR31941 objcopy --globalize-symbol
Alan Modra [Sun, 30 Jun 2024 23:32:10 +0000 (09:02 +0930)] 
PR31941 objcopy --globalize-symbol

I think FILE symbols are special, and I can't see why anyone would
want them to be made global.  The fact that no one has reported this
bug since commit 7b4a0685e80a in 2005 supports that claim.

PR 31941
* objcopy.c (filter_symbols): Don't allow BSF_FILE symbols to
be made global.

11 months agoAutomatic date update in version.in
GDB Administrator [Mon, 1 Jul 2024 00:00:58 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agold: Avoid folding new and delete pairs
H.J. Lu [Sun, 30 Jun 2024 05:42:43 +0000 (22:42 -0700)] 
ld: Avoid folding new and delete pairs

GCC 15 may fold new and delete pairs, like

  A *bb = new A[10];
  delete [] bb;
  bb = new (std::nothrow) A [10];
  delete [] bb;

as shown in

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

Avoid folding new and delete pairs by adding a function call between new
and delete.

* testsuite/ld-elf/dl5.cc: Include "dl5.h".
(A): Removed.
Call foo between new and delete.
* testsuite/ld-elf/dl5.h: New file.
* testsuite/ld-elf/new.cc: Include "dl5.h".
(foo): New function.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
11 months agoobjcopy: Allow making symbol global and weak on same invocation
Marcus Nilsson [Sat, 29 Jun 2024 21:01:56 +0000 (23:01 +0200)] 
objcopy: Allow making symbol global and weak on same invocation

Previously objcopy had to be run twice in order to make a local symbol
weak, first once to globalize it, and once again to mark it as weak.

* objcopy.c (filter_symbols): Weaken symbols after making
local/global changes.
* testsuite/binutils-all/symbols-5.d,
* testsuite/binutils-all/symbols-5.s: New test.

11 months agotweak latest vms-alpha.c change
Alan Modra [Wed, 26 Jun 2024 08:16:48 +0000 (17:46 +0930)] 
tweak latest vms-alpha.c change

It's that tiny bit nicer to have the "len" expression in order of
the components in the buffer.

11 months agoAssertion `(data) <= (end)' failed in read_bases
Alan Modra [Sat, 29 Jun 2024 08:14:12 +0000 (17:44 +0930)] 
Assertion `(data) <= (end)' failed in read_bases

* dwarf.c (skip_attribute): Don't increment data past end.
Use SKIP_{S,U}LEB rather than READ_{S,U}LEB.

11 months agoRe: Rewrite SHT_GROUP handling
Alan Modra [Sat, 29 Jun 2024 07:38:02 +0000 (17:08 +0930)] 
Re: Rewrite SHT_GROUP handling

Some more error tweaks.  Report a zero entry as "invalid entry.."
rather than "unknown type..", and allow a section to be mentioned
twice in a group.

* elf.c (process_sht_group_entries): Tweak error messages, and
allow a duplicate index in a group without reporting an error.

11 months agoAutomatic date update in version.in
GDB Administrator [Sun, 30 Jun 2024 00:00:49 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agold: pass -g for ld-elf tests
Sam James [Sat, 29 Jun 2024 10:07:18 +0000 (11:07 +0100)] 
ld: pass -g for ld-elf tests

The "DWARF parse during linker error" and "Build warn libbar.so" tests
require debug information.

configure defaults to "-O2 -g" but if overriding *FLAGS when building
tests, this might be lost. Explicitly pass -g given these tests require
it.

Originally reported downstream in Gentoo at https://bugs.gentoo.org/934149.

ld/
* testsuite/ld-elf/dwarf.exp: Pass -g for "DWARF parse during linker error".
* testsuite/ld-elf/shared.exp: Ditto for "Build warn libbar.so".

11 months agoAutomatic date update in version.in
GDB Administrator [Sat, 29 Jun 2024 00:00:35 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agoaarch64: Add support for Armv9.5-A architecture
Claudio Bantaloukas [Mon, 10 Jun 2024 13:18:52 +0000 (13:18 +0000)] 
aarch64: Add support for Armv9.5-A architecture

The new -march=armv9.5-a flag enables access to the
mandatory cpa, lut and faminmax extensions.
Existing test cases for features are extended to verify they
work without additional flags.

11 months agold/doc: drop stray blank
Jan Beulich [Fri, 28 Jun 2024 11:16:14 +0000 (13:16 +0200)] 
ld/doc: drop stray blank

Old enough tools demand no blank between @option and the opening figure
brace. Re-wrap the paragraph as well while at it.

11 months agoLoongArch: Do not check R_LARCH_SOP_PUSH_ABSOLUTE to avoid broken links to old object...
Lulu Cai [Wed, 19 Jun 2024 03:00:36 +0000 (11:00 +0800)] 
LoongArch: Do not check R_LARCH_SOP_PUSH_ABSOLUTE to avoid broken links to old object files

R_LARCH_SOP_PUSH_ABSOLUTE with -fPIC was heavily used in the era of gas-2.38.
We do not check this relocation to prevent broken links with old object
files.

11 months agox86/APX: apply NDD-to-legacy transformation to further CMOVcc forms
Jan Beulich [Fri, 28 Jun 2024 06:24:45 +0000 (08:24 +0200)] 
x86/APX: apply NDD-to-legacy transformation to further CMOVcc forms

With both sources being registers, these insns are almost commutative;
the only extra adjustment needed is inversion of the encoded condition.

11 months agox86/APX: extend TEST-by-imm7 optimization to CTESTcc
Jan Beulich [Fri, 28 Jun 2024 06:24:12 +0000 (08:24 +0200)] 
x86/APX: extend TEST-by-imm7 optimization to CTESTcc

The same properties apply there.

11 months agox86/APX: optimize {nf}-form IMUL-by-power-of-2 to SHL
Jan Beulich [Fri, 28 Jun 2024 06:22:39 +0000 (08:22 +0200)] 
x86/APX: optimize {nf}-form IMUL-by-power-of-2 to SHL

..., for differing only in the resulting EFLAGS, which are left
untouched anyway. That's a shorter encoding, available as long as
certain constraints on operands are met; see code comments. (SHL-by-1
forms may then be subject to further optimization that was introduced
earlier.)

Note that kind of as a side effect this also converts multiplication by
1 to shift by 0, which is a plain move or even no-op anyway. That could
be further shrunk (as could be presence of shifts/rotates by 0 in the
original code as  well as a fair set of other {nf}-form insns), yet the
expectation (for now) is that people won't write such code in the first
place.

11 months agox86-64: restrict by-imm31 optimization
Jan Beulich [Fri, 28 Jun 2024 06:21:48 +0000 (08:21 +0200)] 
x86-64: restrict by-imm31 optimization

Avoid changing the encoding when there's no size gain: If there's a REX
or REX2 prefix anyway and the base opcode wouldn't be changed, dropping
just REX.W / REX2.W has no (size) effect. (Same for the AND-by-imm7 case
in the same big conditional.)

While there also pull out the .qword check: For the 2-register-operands
case whether that's done on the 1st or 2nd operand doesn't matter. Due
to reduction in necessary parentheses this improves readability a tiny
bit.

11 months agox86/APX: optimize certain {nf}-form insns to LEA
Jan Beulich [Fri, 28 Jun 2024 06:19:59 +0000 (08:19 +0200)] 
x86/APX: optimize certain {nf}-form insns to LEA

..., as that leaves EFLAGS untouched anyway. That's a shorter encoding,
available as long as certain constraints on operand size and registers
are met; see code comments.

Note that this requires deferring to derive encoding_evex from {nf}
presence, as in optimize_encoding() we want to avoid touching the insns
when {evex} was also used.

Note further that this requires want_disp32() to now also consider the
opcode: We don't want to replace i.tm.mnem_off, for diagnostics to still
report the original mnemonic (or else things can get confusing). While
there, correct adjacent mis-indentation.

11 months agox86/APX: optimize {nf}-form rotate-by-width-less-1
Jan Beulich [Fri, 28 Jun 2024 06:19:32 +0000 (08:19 +0200)] 
x86/APX: optimize {nf}-form rotate-by-width-less-1

Unlike for the legacy forms, where there's a difference in the resulting
EFLAGS.CF, for the NF variants the immediate can be got rid of in that
case by switching to a 1-bit rotate in the opposite direction.

11 months agox86/APX: optimize {nf} forms of ADD/SUB with specific immediates
Jan Beulich [Fri, 28 Jun 2024 06:18:40 +0000 (08:18 +0200)] 
x86/APX: optimize {nf} forms of ADD/SUB with specific immediates

Unlike for the legacy forms, where there's a difference in the resulting
EFLAGS, for the NF variants we can safely replace ones using 0x80 by the
respectively other insn while negating the immediate, saving 3 immediate
bytes (just 1 though for 16-bit operand size). Similarly we can replace
ones using 1 / -1 by INC/DEC (eliminating the immediate).

11 months agogas: .irp/.irpc are macro-like
Jan Beulich [Fri, 28 Jun 2024 06:17:41 +0000 (08:17 +0200)] 
gas: .irp/.irpc are macro-like

... for the purposes of get_line_sb() and _find_end_of_line(): They
support \@ just like macros do, and hence the special casing there also
needs applying.

11 months agoRISC-V: Shrink the riscv_implicit_subsets table.
Nelson Chu [Thu, 27 Jun 2024 04:27:33 +0000 (12:27 +0800)] 
RISC-V: Shrink the riscv_implicit_subsets table.

Allow to add implicit extensions by using the syntax of `.option arch, +-', so
that the table is shrinked and more readable.

bfd/
* elfxx-riscv.c (check_implicit_always): Removed the unused IMPLICIT
parameter.
(check_implicit_for_i): Likewise.
(riscv_implicit_subsets): Shrink the table by allowing the syntax of
`.option arch, +-' for implicit extensions.
(riscv_update_subset1): New function, called from riscv_update_subset
or riscv_parse_add_implicit_subsets.  It basically does the same thing
as riscv_update_subset function before.
(riscv_parse_add_implicit_subsets): Updated.
(riscv_update_subset): Updated.

11 months agoRISC-V: PR27180, Update relocation for riscv_zero_pcrel_hi_reloc.
Nelson Chu [Tue, 11 Jun 2024 08:35:58 +0000 (16:35 +0800)] 
RISC-V: PR27180, Update relocation for riscv_zero_pcrel_hi_reloc.

When pcrel access overflow, the riscv_zero_pcrel_hi_reloc may convert pcrel
relocation to absolutly access if possible at the relocate stage.  We used to
encode the target address into r_sym of R_RISCV_HI20 if it is converted from
R_RISCV_PCREL_HI20.  But that may cause segfault if --emit-relocs is set,
since r_sym becomes an address rather than a symbol index.  Although the
relocate result is correct, it does not meet the definition, so may cause
unexpected behaviors.

This patch encodes the target address into r_addend, rather than r_sym, if
riscv_zero_pcrel_hi_reloc converts the relocation.  Besdies, since the
corresponding pcrel_lo relocation are also changed to absolutly access,
we should also update them to R_RISCV_LO12_I/S.

bfd/
PR 27180
* elfnn-riscv.c (riscv_pcrel_hi_reloc): New boolean `absolute', to
inform corresponding pcrel_lo that the pcrel_hi relocation was already
converted to hi20 relocation.
(riscv_record_pcrel_hi_reloc): Likewise, record `absolute'.
(riscv_pcrel_lo_reloc): Removed `const' for Elf_Internal_Rela *reloc,
since we may need to convert it from pcrel_lo to lo relocation.
(riscv_record_pcrel_lo_reloc): Likewise.  Convert pcrel_lo to lo
relocation if corresponding pcrel_hi was converted to hi relocation.
(riscv_zero_pcrel_hi_reloc): Encode target absolute address into
r_addend rather than r_sym.  Clear the `addr' to avoid duplicate
relocate in the perform_relocation.
(riscv_elf_relocate_section): Updated.
ld/
PR 27180
* testsuite/ld-riscv-elf/pcrel-lo-addend-3a-emit-relocs.d: New testcase.
Segfault without applying this patch.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.

11 months agoRISC-V: Add Zabha extension CAS instructions.
Jiawei [Thu, 27 Jun 2024 16:13:54 +0000 (00:13 +0800)] 
RISC-V: Add Zabha extension CAS instructions.

This patch update the cas instruction in Zabha extension [1],
when both Zabha and Zacas extension enabled.

[1] https://github.com/riscv/riscv-zabha/tags

bfd/ChangeLog:

* elfxx-riscv.c (riscv_multi_subset_supports): New extension case.

gas/ChangeLog:

* testsuite/gas/riscv/zabha-32.d: New instructions.
* testsuite/gas/riscv/zabha.d: Ditto.
* testsuite/gas/riscv/zabha.s: Ditto.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_AMOCAS_B): New opcodes.
(MASK_AMOCAS_B): Ditto.
(MATCH_AMOCAS_H): Ditto.
(MASK_AMOCAS_H): Ditto.
(DECLARE_INSN): New instructions.
* opcode/riscv.h (enum riscv_insn_class): New class case.

opcodes/ChangeLog:

* riscv-opc.c: New instructions.

11 months agoAutomatic date update in version.in
GDB Administrator [Fri, 28 Jun 2024 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agoSet BFD_DECOMPRESS when reading build-id debuglink
H.J. Lu [Tue, 25 Jun 2024 07:45:22 +0000 (00:45 -0700)] 
Set BFD_DECOMPRESS when reading build-id debuglink

We should set BFD_DECOMPRESS to decompress sections unless dumping the
section contents when reading build-id debuglink.

PR binutils/31925
* objdump.c (open_debug_file): Set BFD_DECOMPRESS to decompress
sections unless dumping the section contents.
* testsuite/binutils-all/objdump.exp (test_build_id_debuglink):
Add a compress option.
Run test_build_id_debuglink with none and zlib.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
11 months agogdb: add overloads of gdb_tilde_expand
Andrew Burgess [Wed, 19 Jun 2024 10:13:14 +0000 (11:13 +0100)] 
gdb: add overloads of gdb_tilde_expand

Like the previous commit, add two overloads of gdb_tilde_expand, one
takes std::string and other takes gdb::unique_xmalloc_ptr<char>.  Make
use of these overloads throughout GDB and gdbserver.

There should be no user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
11 months agogdb: add overloads of gdb_abspath
Andrew Burgess [Wed, 19 Jun 2024 10:12:28 +0000 (11:12 +0100)] 
gdb: add overloads of gdb_abspath

Add two overloads of gdb_abspath, one which takes std::string and one
which takes gdb::unique_xmalloc_ptr<char>, then make use of these
overloads throughout GDB and gdbserver.

There should be no user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
11 months agoImprove comments describing the Import Directory Table
Pali Roh?r [Thu, 27 Jun 2024 11:17:27 +0000 (12:17 +0100)] 
Improve comments describing the Import Directory Table

  PR 31728

11 months agoFix new libdep test so that if the plugin cannot be located the test fails gracefully.
Nick Clifton [Thu, 27 Jun 2024 10:52:33 +0000 (11:52 +0100)] 
Fix new libdep test so that if the plugin cannot be located the test fails gracefully.

11 months agoRe: Rewrite SHT_GROUP handling
Alan Modra [Thu, 27 Jun 2024 03:01:46 +0000 (12:31 +0930)] 
Re: Rewrite SHT_GROUP handling

There is no need to loop over the headers twice.  Remove that leftover
from the previous scheme.  Also, the previous scheme silently ignored
a section being mentioned in two or more SHT_GROUP sections.

* elf.c (process_sht_group_entries): Prevent sections from
belonging to two groups.
(_bfd_elf_setup_sections): Process groups in a single loop
over headers.

11 months agoAutomatic date update in version.in
GDB Administrator [Thu, 27 Jun 2024 00:00:51 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 months agoRewrite SHT_GROUP handling
Alan Modra [Wed, 26 Jun 2024 08:17:21 +0000 (17:47 +0930)] 
Rewrite SHT_GROUP handling

This patch delays setting up elf_next_in_group, elf_sec_group and
elf_group_name when reading ELF object files until after all ELF
sections have been processed by bfd_section_from_shdr.  This is simpler
and more robust than the current scheme of driving the whole process
on detecting a section with SHF_GROUP set.

* elf-bfd.h (struct elf_obj_tdata): Delete group_sect_ptr,
num_group and group_search_offset.
* elf.c (Elf_Internal_Group): Delete.
(setup_group): Delete function.
(IS_VALID_GROUP_SECTION_HEADER): Delete macro.
(is_valid_group_section_header),
(process_sht_group_entries): New functions.
(_bfd_elf_setup_sections): Handle group sections here..
(_bfd_elf_make_section_from_shdr): ..rather than here.
(bfd_section_from_shdr): Don't check SHT_GROUP validity here.

12 months agoRevert: 35fd2ddeb1d90f1750401cfb6d01fe055656b88d
Nick Clifton [Wed, 26 Jun 2024 12:17:25 +0000 (13:17 +0100)] 
Revert: 35fd2ddeb1d90f1750401cfb6d01fe055656b88d

  PR 20814

12 months ago[gdb/testsuite] Minor cleanup in gdb.base/bg-execution-repeat.exp
Tom de Vries [Wed, 26 Jun 2024 07:05:09 +0000 (09:05 +0200)] 
[gdb/testsuite] Minor cleanup in gdb.base/bg-execution-repeat.exp

Simplify a gdb_test_multiple in test-case gdb.base/bg-execution-repeat.exp
using "gdb_test -no-prompt-anchor".

Suggested-By: Guinevere Larsen <blarsen@redhat.com>
Tested on x86_64-linux.

12 months ago[gdb/testsuite] Fix timeout in gdb.base/bg-execution-repeat.exp
Tom de Vries [Wed, 26 Jun 2024 06:49:40 +0000 (08:49 +0200)] 
[gdb/testsuite] Fix timeout in gdb.base/bg-execution-repeat.exp

I ran into the following test failure with test-case
gdb.base/bg-execution-repeat.exp:
...
(gdb) PASS: gdb.base/bg-execution-repeat.exp: c&: repeat bg command
^M
Breakpoint 2, foo () at bg-execution-repeat.c:23^M
23        return 0; /* set break here */^M
print 1^M
$1 = 1^M
(gdb) PASS: gdb.base/bg-execution-repeat.exp: c&: input still accepted
FAIL: gdb.base/bg-execution-repeat.exp: c&: breakpoint hit 2 (timeout)
...

The failure can be easily reproduced by adding a sleep 5 here:
...
+    sleep 5
     gdb_test "print 1" " = 1" "input still accepted"
...

There's a race in the test-case, between:
- the command handled in the foreground: the "print 1" command, and
- the command handled in the background: the continue command.

The current way of dealing with this is by putting the inferior to sleep for 5
seconds:
...
  foo ();
  sleep (5);
  foo ();
...
with the aim that the "print 1" command will win the race.

This method is both slow and unreliable.

Fix this by making the inferior wait till the "print 1" command is done.

This reduces running time from ~11s to ~1s.

I also verified that the test-case still triggers on the original problem by
applying this gdb/infcmd.c patch:
...
-strip_bg_char (const char *args, int *bg_char_p)
+strip_bg_char (const char *_args, int *bg_char_p)
 {
-  const char *p;
+  char *args = const_cast<char *>(_args);
+  char *p;

   if (args == nullptr || *args == '\0')
     {
@@ -210,6 +211,7 @@ strip_bg_char (const char *args, int *bg_char_p)
       p--;
       while (p > args && isspace (p[-1]))
  p--;
+      *p = '\0';
...

Tested on x86_64-linux, with make-check-all.sh.

PR testsuite/31794
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31794

Reviewed-By: Guinevere Larsen <blarsen@redhat.com>
12 months agodoc: sframe: small improvements for readability
Indu Bhagat [Wed, 26 Jun 2024 05:27:12 +0000 (22:27 -0700)] 
doc: sframe: small improvements for readability

Update some of the content to make the specification document hopefully
clearer:
  - Fix some typos.
  - Use Title case consistently for headings.
  - Update text around detection of foreign endianness.
  - Split the structure field "Name" in each table to two separate
    colunms for additional attention: "Type" and "Name".
  - Rename "SFrame endianness" section to "SFrame magic number and
    endianness"
  - Update text around provisions for extending SFrame for future
    ABIs/architectures.  Make it clear by tagging all provisions with an
    explicit index item "Provisions for future ABIs".
  - Add a paragraph on sort order of SFrame FDEs.
  - Add a statement for SFRAME_F_FRAME_POINTER flag.
  - Add a statement to assert that SFrame version 1 is now obsolete and
    should not be used.

libsframe/
* doc/sframe-spec.texi: Small improvements for readability.

12 months agoAutomatic date update in version.in
GDB Administrator [Wed, 26 Jun 2024 00:00:46 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoaarch64: FP8 scale and convert - Implement minor improvements
Victor Do Nascimento [Tue, 25 Jun 2024 13:13:25 +0000 (14:13 +0100)] 
aarch64: FP8 scale and convert - Implement minor improvements

Following feedback received shortly after the initial commit of the
aarch64 instructions for scaling and converting fp8 instructions, this
patch addresses the issues raised in the relevant feedback.

This includes the following changes:

* Standardize all FP8 qualifier-set names.  This has resulted in the
  renaming of QL_V2FP8B8H to QL_V2_HB_LOWER and, likewise, QL_V28H16B
  to QL_V2_HB_FULL.

* Update `FP8_INSN' aarch64_opcode_table[] entries to reflect the new
  standardized qualifier-set names mentioned above and, in the case of
  the "fcvtn" entries, also add a leading 0 to their opcode values so
  they are given as 8 hexadecimal digits in length to ensure
  consistency in formatting relative to other entries in the table.

* Revise the added test-cases so that when checking operand fields in
  the disassembled binaries, all bits for these fields get tested to
  ensure they can be toggled on/off by the relevant operand arguments.

12 months agoHurd port: update interface to match upstream and fix warnings.
Flavio Cruz [Wed, 7 Feb 2024 06:53:40 +0000 (01:53 -0500)] 
Hurd port: update interface to match upstream and fix warnings.

We have recently updated the interface for raising exceptions to use
long [1] and updated mach_port_t to be "unsigned int". This patches fixes
those problems and will help us port GDB to Hurd x86_64.

Tested on Hurd i686 and x86_64.

[1] https://git.savannah.gnu.org/cgit/hurd/gnumach.git/tree/include/mach/exc.defs

Approved-By: Simon Marchi <simon.marchi@efficios.com>
12 months agoaarch64: Treat operand ADDR_SIMPLE as address with base register
Jens Remus [Tue, 25 Jun 2024 15:25:55 +0000 (17:25 +0200)] 
aarch64: Treat operand ADDR_SIMPLE as address with base register

The AArch64 instruction table (aarch64-tbl.h) defines the operand
ADDR_SIMPLE as "address with base register (no offset)". During assembly
it is correctly encoded as address with base register (addr.base_regno)
in parse_operands. In warn_unpredictable_ldst it is erroneously treated
as register number (reg.regno).

This resolves the assembler test case "Diagnostics Quality" to
erroneously fail when changing the union in struct aarch64_opnd_info
from union to struct for debugging purposes.

gas/
* config/tc-aarch64.c: Treat operand ADDR_SIMPLE as address with
base register.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
12 months agoaarch64: Treat operand Rt_IN_SYS_ALIASES as register number (PR 31919)
Jens Remus [Tue, 25 Jun 2024 15:25:55 +0000 (17:25 +0200)] 
aarch64: Treat operand Rt_IN_SYS_ALIASES as register number (PR 31919)

The AArch64 instruction table (aarch64-tbl.h) defines the operand
Rt_IN_SYS_ALIASES as register number. During assembly it is correctly
encoded as register number (reg.regno) in parse_operands. During
disassembly it is first correctly decoded as register number (reg.regno)
in aarch64_ext_regno called by aarch64_extract_operand, but then
erroneously treated as immediate value (imm.value) in
aarch64_print_operand.

This resolves the assembler test case "gas/aarch64/brbe-brb-inst" to
erroneously fail on s390. On AArch64 - being little-endian - the struct
aarch64_opnd_info union fields reg.regno and imm.value share their
least-significant bits. On s390 - being big-endian - they do not.

opcodes/
PR binutils/31919
* aarch64-opc.c: Treat operand Rt_IN_SYS_ALIASES as register
number.

Bug: https://sourceware.org/PR31919
Fixes: 72476aca8f58 ("aarch64: add Branch Record Buffer extension instructions")
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
12 months agogdb/doc: the all-doc build target should build .... all docs
Andrew Burgess [Mon, 24 Jun 2024 11:22:26 +0000 (12:22 +0100)] 
gdb/doc: the all-doc build target should build .... all docs

I noticed that the 'all-doc' build target doesn't build all the doc
formats, 'man' and 'html' are missing.

This commit updates 'all-doc' so that all formats are built.

This doesn't change the default 'all' target, which is the default
target used when building GDB itself, the 'all' target continues to
just build the 'info' docs.

There should be no difference in the actual generated output after
this commit, I'm just changing what gets built.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb/doc: fix cannot create directory error when building dvi/pdf
Andrew Burgess [Tue, 25 Jun 2024 13:29:10 +0000 (14:29 +0100)] 
gdb/doc: fix cannot create directory error when building dvi/pdf

After this commit:

  commit 0700386f142f0b0d3d0021995970a1b41c36cc92 (gdb-tmp-c)
  Date:   Wed May 8 19:12:57 2024 +0100

      gdb/doc: fix parallel build of pdf and dvi files

When building the dvi or pdf targets you'd get errors like this:

  mkdir: cannot create directory ‘texi2dvi_tmpdir/gdb_dvi’: No such file or directory
  mkdir: cannot create directory ‘texi2dvi_tmpdir/gdb_pdf’: No such file or directory

fixed by ensuring the directory is created before calling texi2dvi.

12 months agoUpdated Russian translation for the bfd/ sub-directory
Nick Clifton [Tue, 25 Jun 2024 13:16:58 +0000 (14:16 +0100)] 
Updated Russian translation for the bfd/ sub-directory

12 months agoaarch64: Fix FEAT_B16B16 sve2 instruction constraints.
Srinath Parvathaneni [Tue, 25 Jun 2024 12:02:03 +0000 (13:02 +0100)] 
aarch64: Fix FEAT_B16B16 sve2 instruction constraints.

This patch adds missing contraints to FEAT_B16B16 sve2 instructions
bfclamp, bfmla and bfmls and add negative tests for all the bfloat
instructions.

The bfloat16-invalid.* testcases are renamed to bfloat16-1-invalid.*
to maintain consistency in the testsuite.

The bfloat16-1-invalid.* tests are  modified so that "selected
processor does not support" is generated by the assembler, since
+b16b16 is not passed in the command line.

The bfloat16-2-invalid.* testcase includes the wrong operands
bfloat16 tests.

12 months agoaarch64: Add extra tests for sve2p1 min max instructions.
Srinath Parvathaneni [Tue, 25 Jun 2024 12:01:50 +0000 (13:01 +0100)] 
aarch64: Add extra tests for sve2p1 min max instructions.

This patch adds some extra tests for the sve2p1 "addqv, andqv, smaxqv,
sminqv, umaxqv, uminqv, eorqv, faddqv, fmaxnmqv, fmaxqv, fminnmqv and
fminqv" instructions.

The patch also adds couple of negative testcases, sve2p1-1-bad.d testcase
without "+sve2p1" option and sve2p1-2-bad.d testcase with wrong operands
for sve2p1 instructions.

12 months agoarch64: Fix the wrong constraint used for sve2p1 instructions.
Srinath Parvathaneni [Tue, 25 Jun 2024 12:00:03 +0000 (13:00 +0100)] 
arch64: Fix the wrong constraint used for sve2p1 instructions.

The current implementation for the following SVE2p1 instructions add a
constraint in aarch64_opcode_table[] array, so that these instruction
might be immediately preceded in program order by a MOVPRFX instruction.

As per the spec these instruction does not immediately preceded in
program order by a MOVPRFX instruction and to fix this issue, SVE2p1_INSNC
macro is replaced with SVE2p1_INSN macro for the entries of these
instructions in aarch64_opcode_table[] array.

List of instructions updated: addqv, andqv, smaxqv, sminqv, umaxqv, uminqv,
eorqv, faddqv, fmaxnmqv, fmaxqv, fminnmqv and fminqv.

12 months agoaarch64: Fix sve2p1 ld[1-4]/st[1-4]q instruction operands.
Srinath Parvathaneni [Tue, 25 Jun 2024 11:58:27 +0000 (12:58 +0100)] 
aarch64: Fix sve2p1 ld[1-4]/st[1-4]q instruction operands.

This patch fixes encoding and syntax for sve2p1 instructions ld[1-4]q/st[1-4]q
as mentioned below, for the issues reported here.
https://sourceware.org/pipermail/binutils/2024-February/132408.html

1) Previously all the ld[1-4]q/st[1-4]q instructions are wrongly added as
predicated instructions and this issue is fixed in this patch by replacing
"SVE2p1_INSNC" with "SVE2p1_INSN" macro.
2) Wrong first operand in all the ld[1-4]q/st[1-4]q instructions is fixed
by replacing "SVE_Zt" with "SVE_ZtxN".
3) Wrong operand qualifiers in ld1q and st1q instructions are also fixed in
this patch.
4) In ld1q/st1q the index in the second argument is optional and if index
   is xzr and is skipped in the assembly, the index field is ignored by the
   disassembler.

Fixing above mentioned issues helps with following:
1) ld1q and st1q first register operand accepts enclosed figure braces.
2) ld2q, ld3q, ld4q, st2q, st3q, and st4q instructions accepts wrapping
   sequence of vector registers.

For the instructions ld[2-4]q/st[2-4]q, tests for wrapping sequence of vector
registers are added along with short-form of operands for non-wrapping sequence.

I have added test using following logic:
ld2q {Z0.Q, Z1.Q}, p0/Z, [x0,  #0, MUL VL]  //raw insn encoding (all zeroes)
ld2q {Z31.Q, Z0.Q}, p0/Z, [x0,  #0, MUL VL] // encoding of <Zt1>
ld2q {Z0.Q, Z1.Q}, p7/Z, [x0,  #0, MUL VL] // encoding of <Pg>
ld2q {Z0.Q, Z1.Q}, p0/Z, [x30,  #0, MUL VL] // encoding of <Xm>
ld2q {Z0.Q, Z1.Q}, p0/Z, [x0,  #-16, MUL VL] // encoding of <imm> (low value)
ld2q {Z0.Q, Z1.Q}, p0/Z, [x0,  #14, MUL VL] // encoding of <imm> (high value)
ld2q {Z31.Q, Z0.Q}, p7/Z, [x30,  #-16, MUL VL] // encoding of all fields (all ones)
ld2q {Z30.Q, Z31.Q}, p1/Z, [x3,  #-2, MUL VL] // random encoding.

For all the above form of instructions the hyphenated form is preferred for
disassembly if there are more than two registers in the list, and the register
numbers are monotonically increasing in increments of one.

12 months agoaarch64: Fix sve2p1 extq instruction operands.
Srinath Parvathaneni [Tue, 25 Jun 2024 10:30:24 +0000 (11:30 +0100)] 
aarch64: Fix sve2p1 extq instruction operands.

This patch fixes the syntax of sve2p1 "extq" instruction by modifying the operands
count to 4. A new operand AARCH64_OPND_SVE_UIMM4 is defined to handle the 4th
argument an 4-bit unsigned immediate of extq instruction. The instruction encoding
is updated to use constraint C_SCAN_MOVPRFX, to enable "extq" instruction to immediately
precede in program order by a MOVPRFX instruction. Also removed the unused operand
AARCH64_OPND_SVE_Zm_imm4.

This issues was reported here:
 https://sourceware.org/pipermail/binutils/2024-February/132408.html

12 months agoaarch64: Fix sve2p1 dupq instruction operands.
Srinath Parvathaneni [Tue, 25 Jun 2024 10:27:23 +0000 (11:27 +0100)] 
aarch64: Fix sve2p1 dupq instruction operands.

This patch fixes the syntax of sve2p1 "dupq" instruction by modifying the way
2nd operand does the encoding and decoding using the [<imm>] value.

dupq makes use of already existing aarch64_ins_sve_index and aarch64_ext_sve_index
inserter and extractor functions. The definitions of aarch64_ins_sve_index_imm (inserter)
and aarch64_ext_sve_index_imm (extractor) is removed in this patch.

This issues was reported here:
 https://sourceware.org/pipermail/binutils/2024-February/132408.html

12 months agoaarch64: Enable mandatory feature bits for v9.4-A.
Srinath Parvathaneni [Tue, 25 Jun 2024 10:25:26 +0000 (11:25 +0100)] 
aarch64: Enable mandatory feature bits for v9.4-A.

This patch fixes the mandatory feature bits in v9.4-a architectures,
by enabling FEAT_SVE2p1 for Armv9.4-A architecture by default.

12 months agoRevert 4ee1d7e401a8c1aedfdc86aac7faa8267eab1e5c
Nick Clifton [Tue, 25 Jun 2024 11:41:20 +0000 (12:41 +0100)] 
Revert 4ee1d7e401a8c1aedfdc86aac7faa8267eab1e5c

  PR 20880

12 months agoFix calculation of space remaining in buffer when printing the contents of a DST__K_R...
Nick Clifton [Tue, 25 Jun 2024 10:56:38 +0000 (11:56 +0100)] 
Fix calculation of space remaining in buffer when printing the contents of a DST__K_RECBEG type debug symbol for the VMS Alpha port.

  PR 31873

12 months agogdb: use alternative for demangled name for non-demangeable linkage names
Schimpe, Christina [Wed, 10 Jan 2024 17:36:09 +0000 (09:36 -0800)] 
gdb: use alternative for demangled name for non-demangeable linkage names

In case a DIE contains a linkage name which cannot be demangled and
a source language name (DW_AT_NAME) exists then we want to display this name
instead of the non-demangeable linkage name.

dwarf2_physname returns the linkage name in case the linkage name
cannot be demangled.  Before this patch we always set the returned physname
as demangled name.  This patch changes this by comparing the value
of physname with the linkage name.  Now after this change in case it is equals
to the linkage name and if DW_AT_NAME exists then this is set as the demangled
name otherwise like before still linkage name is used.

For the reproducer, using the test source file added in this change:
"gdb/testsuite/gdb.dwarf2/dw2-wrong-mangled-name.c"

Here is an example of the DWARF where wrong linkage name is emitted by the
compiler for the "func_demangled_test" function:

subprogram {
    {MACRO_AT_range {func_demangled_test}}
    {linkage_name "_FUNC_WRONG_MANGLED__"}
    {name "func_demangled_test"}
    {external 1 flag}
}
subprogram {
    {MACRO_AT_range {main}}
    {external 1 flag}
    {name main}
    {main_subprogram 1 flag}
}

Before this change for a function having both DIEs DW_AT_name and
DW_AT_LINKAGENAME but with the wrong linkage name info, the backtrace
command shows following:

(gdb) b func_demangled_test
(gdb) r
Breakpoint 1, 0x0000555555555131 in _FUNC_WRONG_MANGLED__ ()
(gdb) backtrace
\#0  0x0000555555555131 in  _FUNC_WRONG_MANGLED__ ()
\#1  0x000055555555514a in main ()

After the change now GDB shows the name emitted by DW_AT_NAME:

(gdb) b func_demangled_test
(gdb) r
Breakpoint 1, 0x0000555555555131 in func_demangled_test ()
(gdb) backtrace
\#0  0x0000555555555131 in func_demangled_test ()
\#1  0x000055555555514a in main ()

A new test is added to verify this change.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoaarch64: Add DT_RELR tests for ILP32 ABI
Szabolcs Nagy [Thu, 13 Jun 2024 12:40:35 +0000 (13:40 +0100)] 
aarch64: Add DT_RELR tests for ILP32 ABI

12 months agoaarch64: Add DT_RELR support for ILP32 ABI
Szabolcs Nagy [Wed, 12 Jun 2024 14:17:09 +0000 (15:17 +0100)] 
aarch64: Add DT_RELR support for ILP32 ABI

Extend the 64bit DT_RELR support to work on 32bit ELF too. For this
only a few changes were needed in the sizing and creation of the
relr relocations.

12 months ago[gdb/symtab] Remove dead code in parse_macro_definition
Tom de Vries [Tue, 25 Jun 2024 05:59:13 +0000 (07:59 +0200)] 
[gdb/symtab] Remove dead code in parse_macro_definition

In parse_macro_definition, there's a loop:
...
  for (p = body; *p; p++)
    if (*p == ' ' || *p == '(')
      break;
...
whose post-condition is:
...
  gdb_assert (*p == ' ' || *p == '(' || *p == '\0');
...

Consequently, in the following:
...
  if (*p == ' ' || *p == '\0')
    <BODY1>
  else if (*p == '(')
    <BODY2>
  else
    <BODY3>
...
BODY3 is dead code.

Remove it, and get rid of unnecessary indentation by using an early-exit:
....
  if (*p == ' ' || *p == '\0')
    {
      <BODY1>
      return;
    }

  gdb_assert (*p == '(');
  <BODY2>
...

Tested on aarch64-linux.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
12 months agoAutomatic date update in version.in
GDB Administrator [Tue, 25 Jun 2024 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agogdb: LoongArch: Add support for hardware breakpoint
Hui Li [Tue, 11 Jun 2024 11:21:26 +0000 (19:21 +0800)] 
gdb: LoongArch: Add support for hardware breakpoint

LoongArch defines hardware watchpoint functions for fetch operations.
After the software configures the watchpoints for fetch, the processor
hardware will monitor the access addresses of the fetch operations and
trigger a watchpoint exception when the watchpoint setting conditions
are met.

Hardware watchpoints for fetch operations is used to implement hardware
breakpoint function on LoongArch. Refer to the following document for
hardware breakpoint.
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#control-and-status-registers-related-to-watchpoints

A simple test is as follows:

lihui@bogon:~$ cat test.c
  #include <stdio.h>
  int a = 0;
  int main()
  {
        printf("start test\n");
        a = 1;
        printf("a = %d\n", a);
        printf("end test\n");
        return 0;
  }
lihui@bogon:~$ gcc -g test.c -o test

without this patch:

lihui@bogon:~$ gdb test
...
(gdb) start
...
Temporary breakpoint 1, main () at test.c:5
5               printf("start test\n");
(gdb) hbreak 8
No hardware breakpoint support in the target.

with this patch:

lihui@bogon:~$ gdb test
...
(gdb) start
...

Temporary breakpoint 1, main () at test.c:5
5               printf("start test\n");
(gdb) hbreak 8
Hardware assisted breakpoint 2 at 0x1200006ec: file test.c, line 8.
(gdb) c
Continuing.
start test
a = 1

Breakpoint 2, main () at test.c:8
8               printf("end test\n");
(gdb) c
Continuing.
end test
[Inferior 1 (process 25378) exited normally]

Signed-off-by: Hui Li <lihui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>