]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
10 months agoPrevent an illegal memory access when running the strings program with an excessively...
Nick Clifton [Fri, 30 Jun 2023 10:18:42 +0000 (11:18 +0100)] 
Prevent an illegal memory access when running the strings program with an excessively lerge minimum string length.

  PR 30595
  * strings.c (main): Check for an excessively large minimum string length.

10 months agoFix used-before-initialized warnings when compiling elf.c with Clang-16.
Nick Clifton [Fri, 30 Jun 2023 09:45:20 +0000 (10:45 +0100)] 
Fix used-before-initialized warnings when compiling elf.c with Clang-16.

10 months agoLoongArch: gas: Fix code style issues
mengqinggang [Fri, 30 Jun 2023 09:04:16 +0000 (17:04 +0800)] 
LoongArch: gas: Fix code style issues

  Blocks of 8 spaces be replaced with tabs.
  Fix alignment issues.

10 months agoLoongArch: gas: Add LVZ and LBT instructions support
mengqinggang [Fri, 30 Jun 2023 09:04:15 +0000 (17:04 +0800)] 
LoongArch: gas: Add LVZ and LBT instructions support

gas/ChangeLog:
* config/tc-loongarch.c (md_parse_option): Add LARCH_opts.ase_lvz and
LARCH_opts.ase_lbt.
* testsuite/gas/loongarch/uleb128.d: Regenerated.
* testsuite/gas/loongarch/lvz-lbt.d: New test.
* testsuite/gas/loongarch/lvz-lbt.s: New test.

include/ChangeLog:
* opcode/loongarch.h (ase_lvz): New.
(ase_lbt): New.

opcodes/ChangeLog:
* loongarch-dis.c (set_default_loongarch_dis_options): Add
LARCH_opts.ase_lvz and LARCH_opts.ase_lbt.
* loongarch-opc.c (struct loongarch_ase): Add LVZ and LBT instructions.

10 months agoLoongArch: Deprecate $v[01], $fv[01] and $x names per spec
WANG Xuerui [Thu, 29 Jun 2023 16:35:04 +0000 (00:35 +0800)] 
LoongArch: Deprecate $v[01], $fv[01] and $x names per spec

As outlined in the LoongArch ELF psABI spec [1], it is actually already
2 versions after the initial LoongArch support, and the $v[01] and
$fv[01] names should really get sunset by now.

In addition, the "$x" name for $r21 was never included in any released
version of the ABI spec, and such usages are all fixed to say just $r21
for every project I could think of that accepted a LoongArch port.

Plus, the upcoming LSX/LASX support makes use of registers named
"$vrNN" and "$xrNN", so having "$vN" and "$x" alongside would almost
certainly create confusion for developers.

Issue warnings for such usages per the deprecation procedure detailed
in the spec, so we can finally remove support in the next release cycle
after this.

[1]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html

gas/ChangeLog:

* config/tc-loongarch.c: Init canonical register ABI name
mappings and deprecated register names.
(loongarch_args_parser_can_match_arg_helper): Warn in case of
deprecated register name usage.
* testsuite/gas/loongarch/deprecated_reg_aliases.d: New test.
* testsuite/gas/loongarch/deprecated_reg_aliases.l: Likewise.
* testsuite/gas/loongarch/deprecated_reg_aliases.s: Likewise.

include/ChangeLog:

* opcode/loongarch.h: Rename global variables.

opcodes/ChangeLog:

* loongarch-opc.c: Rename the alternate/deprecated register name
mappings, and move $x to the deprecated name map.

Signed-off-by: WANG Xuerui <git@xen0n.name>
10 months agoopcodes/loongarch: print unrecognized insn words with the .word directive
WANG Xuerui [Thu, 29 Jun 2023 16:35:03 +0000 (00:35 +0800)] 
opcodes/loongarch: print unrecognized insn words with the .word directive

For better round-trip fidelity and readability in general.

gas/ChangeLog:

* testsuite/gas/loongarch/uleb128.d: Update test case.
* testsuite/gas/loongarch/raw-insn.d: New test.
* testsuite/gas/loongarch/raw-insn.s: Likewise.

opcodes/ChangeLog:

* loongarch-dis.c (disassemble_one): Print ".word" if !opc.

Signed-off-by: WANG Xuerui <git@xen0n.name>
10 months agoopcodes/loongarch: do not print hex notation for signed immediates
WANG Xuerui [Thu, 29 Jun 2023 16:35:02 +0000 (00:35 +0800)] 
opcodes/loongarch: do not print hex notation for signed immediates

The additional hex notation was minimally useful when one had to
inspect code with heavy bit manipulation, or of unclear signedness, but
it clutters the output, and the style is not regular assembly language
syntax either.

Precisely how one approaches the original use case is not taken care of
in this patch (maybe we want a disassembler option forcing a certain
style for immediates, like for example printing every immediate in
decimal or hexadecimal notation), but at least let's stop the current
practice.

ChangeLog:

* testsuite/gas/loongarch/imm_ins.d: Update test case.
* testsuite/gas/loongarch/imm_ins_32.d: Likewise.
* testsuite/gas/loongarch/imm_op.d: Likewise.
* testsuite/gas/loongarch/jmp_op.d: Likewise.
* testsuite/gas/loongarch/load_store_op.d: Likewise.
* testsuite/gas/loongarch/macro_op.d: Likewise.
* testsuite/gas/loongarch/macro_op_32.d: Likewise.
* testsuite/gas/loongarch/privilege_op.d: Likewise.
* testsuite/gas/loongarch/uleb128.d: Likewise.
* testsuite/gas/loongarch/vector.d: Likewise.

ld/ChangeLog:

* testsuite/ld-loongarch-elf/jmp_op.d: Update test case.
* testsuite/ld-loongarch-elf/macro_op.d: Likewise.
* testsuite/ld-loongarch-elf/macro_op_32.d: Likewise.

opcodes/ChangeLog:

* loongarch-dis.c (dis_one_arg): Remove the "(0x%x)" part from
disassembly output of signed immediate operands.

Signed-off-by: WANG Xuerui <git@xen0n.name>
10 months agoopcodes/loongarch: style disassembled address offsets as such
WANG Xuerui [Thu, 29 Jun 2023 16:35:01 +0000 (00:35 +0800)] 
opcodes/loongarch: style disassembled address offsets as such

Add a modifier char 'o' telling the disassembler to print the immediate
using the address offset style, and mark the memory access instructions'
offset operands as such.

opcodes/ChangeLog:

* loongarch-dis.c (dis_one_arg): Style disassembled address
offsets as such when the operand has a modifier char 'o'.
* loongarch-opc.c: Add 'o' to operands that represent address
offsets.

Signed-off-by: WANG Xuerui <git@xen0n.name>
10 months agoopcodes/loongarch: implement style support in the disassembler
WANG Xuerui [Thu, 29 Jun 2023 16:35:00 +0000 (00:35 +0800)] 
opcodes/loongarch: implement style support in the disassembler

Update the LoongArch disassembler to supply style information to the
disassembler output. The output formatting remains unchanged.

opcodes/ChangeLog:

* disassemble.c: Mark LoongArch as created_styled_output=true.
* loongarch-dis.c (dis_one_arg): Use fprintf_styled_func
throughout with proper styles.

Signed-off-by: WANG Xuerui <git@xen0n.name>
10 months agoopcodes/loongarch: remove unused code
WANG Xuerui [Thu, 29 Jun 2023 16:34:59 +0000 (00:34 +0800)] 
opcodes/loongarch: remove unused code

Remove some unused declarations and code.

include/ChangeLog:

* opcode/loongarch.h: Remove unused declarations.

opcodes/ChangeLog:

* loongarch-dis.c (loongarch_parse_dis_options): Remove.
(my_print_address_func): Likewise.
(loongarch_disassemble_one): Likewise.

Signed-off-by: WANG Xuerui <git@xen0n.name>
10 months agoLoongArch: support disassembling certain pseudo-instructions
WANG Xuerui [Thu, 29 Jun 2023 16:34:58 +0000 (00:34 +0800)] 
LoongArch: support disassembling certain pseudo-instructions

Add a flag in the pinfo field for being able to mark certain specialized
matchers as disassembler-only, so some degree of isolation between
assembler-side and disassembler-side can be achieved.

This isolation is necessary, firstly because some pseudo-instructions
cannot be fully described in the opcode table, like `li.[wd]`, so the
corresponding opcode entry cannot have meaningful match/mask values.
Secondly, some of these pseudo-instructions can be realized in more than
one plausible ways; e.g. `li.w rd, <something between 0 and 0x7ff>` can
be realized on LA64 with any of `addi.w`, `addi.d` or `ori`. If we tie
disassembly of such aliases with the corresponding GAS support, only one
canonical form among the above would be recognized as `li.w`, and it
would mildly impact the readability of disassembly output.
People wanting the exact disassembly can always set `-M no-aliases` to
get the original behavior back.

In addition, in certain cases, information is irreversibly lost after
assembling, so perfect round-trip would not be possible in such cases.
For example, `li.w` and `li.d` of immediates within int32_t range
produce the same code; in this patch, `addi.d rd, $zero, imm` is treated
as `li.d`, while `addi.w` and `ori` immediate loads are shown as `li.w`,
due to the expressible value range well within 32 bits.

gas/ChangeLog:

* config/tc-loongarch.c (get_loongarch_opcode): Ignore
disassembler-only aliases.
* testsuite/gas/loongarch/64_pcrel.d: Update test case.
* testsuite/gas/loongarch/imm_ins.d: Likewise.
* testsuite/gas/loongarch/imm_ins_32.d: Likewise.
* testsuite/gas/loongarch/jmp_op.d: Likewise.
* testsuite/gas/loongarch/li.d: Likewise.
* testsuite/gas/loongarch/macro_op.d: Likewise.
* testsuite/gas/loongarch/macro_op_32.d: Likewise.
* testsuite/gas/loongarch/macro_op_large_abs.d: Likewise.
* testsuite/gas/loongarch/macro_op_large_pc.d: Likewise.
* testsuite/gas/loongarch/nop.d: Likewise.
* testsuite/gas/loongarch/relax_align.d: Likewise.
* testsuite/gas/loongarch/reloc.d: Likewise.

include/ChangeLog:

* opcode/loongarch.h (INSN_DIS_ALIAS): Add.

ld/ChangeLog:

* testsuite/ld-loongarch-elf/jmp_op.d: Update test case.
* testsuite/ld-loongarch-elf/macro_op.d: Likewise.
* testsuite/ld-loongarch-elf/macro_op_32.d: Likewise.
* testsuite/ld-loongarch-elf/relax-align.dd: Likewise.

opcodes/ChangeLog:

* loongarch-dis.c: Move register name map declarations to top.
(get_loongarch_opcode_by_binfmt): Consider aliases when
disassembling without the no-aliases option.
(parse_loongarch_dis_option): Support the no-aliases option.
* loongarch-opc.c: Collect pseudo instructions into a new
dedicated table.

Signed-off-by: WANG Xuerui <git@xen0n.name>
10 months agoAutomatic date update in version.in
GDB Administrator [Fri, 30 Jun 2023 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agobinutils/NEWS: announce SFrame version 2 as the new default
Indu Bhagat [Thu, 29 Jun 2023 23:29:16 +0000 (16:29 -0700)] 
binutils/NEWS: announce SFrame version 2 as the new default

10 months agodoc: sframe: update specification for SFRAME_VERSION_2
Indu Bhagat [Thu, 29 Jun 2023 23:29:12 +0000 (16:29 -0700)] 
doc: sframe: update specification for SFRAME_VERSION_2

Add details for the changes made from Version 1 to Version 2 of the format.

Also add details about alignment in the SFrame format.  A portion of the
SFrame stack trace format has an unaligned on-disk representation.  Add
description at relevant points in the specificatin to clarify the
alignment related details.

10 months agosframe: bfd: gas: ld: format bump to SFrame version 2
Indu Bhagat [Thu, 29 Jun 2023 23:29:09 +0000 (16:29 -0700)] 
sframe: bfd: gas: ld: format bump to SFrame version 2

SFrame version 2 encodes the size of repetitive insn block explicitly
in the format.  Add information in the SFrame FDE to convey the size
of the block of repeating instructions.  This information is used only
for SFrame FDEs of type SFRAME_FDE_TYPE_PCMASK.

Introduce two extra bytes for padding: this ensures that the memory
accesses to the members of the SFrame Frame Descriptor Entry (FDE) are
naturally aligned.

gas generates SFrame section with version SFRAME_VERSION_2 by default.

libsframe provides two new APIs to:
  - get an SFrame FDE data from the decoder context, and
  - add an SFrame FDE to the encoder context.
The additional argument (for rep_block_size) is useful for SFrame FDEs
where FDE type is SFRAME_FDE_TYPE_PCMASK.

The linker will generate the output SFrame sections in the
SFRAME_VERSION_2 format.  If the input sections offered to the linker
are not all in the SFRAME_VERSION_2 format, the linker issues an error
to the user.

objdump/readelf will show the following message to the user if .sframe
section in SFRAME_VERSION_1 format is seen:

 "No further information can be displayed.  SFrame version not
 supported."

In other words, like the rest of the binutils, only the current SFrame
format version, i.e., SFRAME_VERSION_2 is supported by the textual dump
facilities.

bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe): Generate an
output SFrame section with version SFRAME_VERSION_2.  Also,
error out if the SFrame sections do not all have
SFRAME_VERSION_2.
* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Generate SFrame
section for plt entries with version SFRAME_VERSION_2.
gas/
* gen-sframe.c (sframe_set_version): Update to SFRAME_VERSION_2.
(output_sframe): Likewise.
gas/testsuite/
* gas/cfi-sframe/cfi-sframe-aarch64-1.d: Use SFRAME_VERSION_2.
* gas/cfi-sframe/cfi-sframe-aarch64-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-1.d: Likewise.
* 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: Likewise.
* gas/cfi-sframe/common-empty-1.d: Likewise.
* gas/cfi-sframe/common-empty-2.d: Likewise.
* gas/cfi-sframe/common-empty-3.d: Likewise.
ld/testsuite/
* ld-aarch64/sframe-simple-1.d: Adjust for SFRAME_VERSION_2.
* ld-x86-64/sframe-plt-1.d: Likewise.
* ld-x86-64/sframe-simple-1.d: Likewise.
libsframe/
* libsframe.ver: Add the new APIs.
* sframe.c (sframe_decoder_get_funcdesc_v2): New definition.
(sframe_encoder_add_funcdesc_v2): Likewise.
(sframe_header_sanity_check_p): Include SFRAME_VERSION_2.
(sframe_fre_check_range_p): Get rep_block_size info from SFrame
FDE.
* sframe-dump.c (dump_sframe_header): Add support for
SFRAME_VERSION_2.
(dump_sframe): Inform user if SFrame section in SFRAME_VERSION_1
format is seen.
libsframe/testsuite/
* libsframe.decode/DATA-BE: Regenerated data file.
* libsframe.decode/DATA1: Likewise.
* libsframe.decode/DATA2: Likewise.
* libsframe.find/plt-findfre-1.c: Use new API in the testcase.
include/
* sframe.h: Add member to encode size of the code block of
repeating instructions.  Add 2 bytes of padding.
* sframe-api.h (sframe_decoder_get_funcdesc_v2): New
declaration.
(sframe_encoder_add_funcdesc_v2): Likewise.

10 months agolibsframe: add new APIs to get SFrame version
Indu Bhagat [Thu, 29 Jun 2023 23:28:56 +0000 (16:28 -0700)] 
libsframe: add new APIs to get SFrame version

While the SFrame preamble is guaranteed to not change between versions,
providing these access APIs from the SFrame decoder and encoder APIs is
for convenience only.  The linker may want to use these APIs as the
format evolves.

include/
* sframe-api.h (sframe_decoder_get_version): New declaration.
(sframe_encoder_get_version): Likewise.

libsframe/
* libsframe/libsframe.ver: Add new APIs.
* libsframe/sframe.c (sframe_decoder_get_version): New
definition.
(sframe_encoder_get_version): Likewise.

10 months agolibsframe: fix sframe_find_fre for pltN entries
Indu Bhagat [Thu, 29 Jun 2023 18:03:32 +0000 (11:03 -0700)] 
libsframe: fix sframe_find_fre for pltN entries

For a toy application on x86_64, for example, following is the SFrame
stack trace information for the 3 pltN entries of 16 bytes each:

   func idx [1]: pc = 0x401030, size = 48 bytes
   STARTPC[m]      CFA       FP        RA
   0000000000000000  sp+8      u         u
   000000000000000b  sp+16     u         u

The data in first column is the start_ip_offset.  Also note that the FDE
is of type SFRAME_FDE_TYPE_PCMASK (denoted by the [m] on LHS).

Where each pltN (note: excluding plt0 entry) entry looks like:

  401030: jmp    *0x2fca(%rip)
  401036: push   $0x0
  40103b: jmp    401020<_init+0x20>

  401040: jmp    *0x2fc2(%rip)
  401046: push   $0x1
  40104b: jmp    401020<_init+0x20>

  401050: jmp    *0x2fba(%rip)
  401056: push   $0x2
  40105b: jmp    401020<_init+0x20>

Now, to find SFrame stack trace information from an FDE of type
SFRAME_FDE_TYPE_PCMASK, sframe_find_fre () was doing an operation
like,
  (start_ip_offset & 0xf) >= (pc & 0xf)

This works for pltN entry of size, say, less than 16 bytes.  But if the
pltN entries or similar code stubs (for which SFrame FDE of type
SFRAME_FDE_TYPE_PCMASK may be used), evolve to be of size > 16 bytes,
this will cease to work.

To match the range covered by the SFrame FRE, one should instead perform
a modulo operation.  The constant for the modulo operation must be the
size of the pltN entry.  Further, this constant should ideally be
encoded in the format, as it may be different for each ABI.

In SFrame Version 2 of the format, we will move towards encoding it
explicitly in the SFrame FDE.  For now, fix up the logic to at least
move towards modulo operation.

libsframe/
* sframe.c (sframe_fre_check_range_p): New definition.
(sframe_find_fre): Refactor a bit and use the new definition
above.
include/
* sframe.h (SFRAME_FDE_TYPE_PCMASK): Update comment.
libsframe/doc/
* sframe-spec.texi: Fix the text for SFRAME_FDE_TYPE_PCMASK FDE
type.

10 months agold: Add -z nosectionheader test to bootstrap.exp
H.J. Lu [Mon, 9 Mar 2020 21:37:26 +0000 (14:37 -0700)] 
ld: Add -z nosectionheader test to bootstrap.exp

PR ld/25617
* testsuite/ld-bootstrap/bootstrap.exp: Add -z nosectionheader
test.

10 months agold: Add tests for -z nosectionheader and --strip-section-headers
H.J. Lu [Sat, 7 Mar 2020 16:24:35 +0000 (08:24 -0800)] 
ld: Add tests for -z nosectionheader and --strip-section-headers

Add tests to verify that the linker option, -z nosectionheader and
objcopy and strip option, --strip-section-headers, work correctly as well
as linker issues an error when dynamic symbol table from PT_DYNAMIC
segment is used.

PR ld/25617
* testsuite/ld-elf/hash-2.d: New file.
* testsuite/ld-elf/no-section-header.exp: Likewise.
* testsuite/ld-elf/pr25617-1-no-sec-hdr.nd: Likewise.
* testsuite/ld-elf/pr25617-1-no-sec-hdr.rd: Likewise.
* testsuite/ld-elf/pr25617-1-static-no-sec-hdr.rd: Likewise.
* testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd: Likewise.
* testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd: Likewise.
* testsuite/ld-elf/pr25617-1a-sec-hdr.rd: Likewise.
* testsuite/ld-elf/pr25617-1a.c: Likewise.
* testsuite/ld-elf/pr25617-1b.c: Likewise.
* testsuite/ld-elf/start-noheader.rd: Likewise.
* testsuite/ld-elf/start-shared-noheader-gnu.rd: Likewise.
* testsuite/ld-elf/start-shared-noheader-sysv.rd: Likewise.
* testsuite/ld-elf/start-shared-noheader.nd: Likewise.

10 months agobinutils: Add a --strip-section-headers test
H.J. Lu [Sat, 7 Mar 2020 13:27:12 +0000 (05:27 -0800)] 
binutils: Add a --strip-section-headers test

PR ld/25617
* testsuite/binutils-all/objcopy.exp: Run strip-section-headers-1.
* testsuite/binutils-all/strip-section-headers-1.d: New file.

10 months agold: Add simple tests for -z nosectionheader
Kaylee Blake [Thu, 5 Mar 2020 03:12:31 +0000 (13:42 +1030)] 
ld: Add simple tests for -z nosectionheader

2020-06-06  Kaylee Blake  <klkblake@gmail.com>
    H.J. Lu  <hongjiu.lu@intel.com>

PR ld/25617
* testsuite/ld-elf/nosectionheader-1.d: New file.
* testsuite/ld-elf/nosectionheader-2.d: Likewise.

10 months agobfd: Improve nm and objdump without section header
H.J. Lu [Thu, 5 Mar 2020 04:32:35 +0000 (20:32 -0800)] 
bfd: Improve nm and objdump without section header

When there is no section header in an executable or shared library, we
reconstruct dynamic symbol table from the PT_DYNAMIC segment, which
contains DT_HASH/DT_GNU_HASH/DT_MIPS_XHASH, DT_STRTAB, DT_SYMTAB,
DT_STRSZ, and DT_SYMENT entries, to improve nm and objdump.  For DT_HASH,
the number of dynamic symbol table entries equals the number of chains.
For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols with non-STB_LOCAL
indings are in hash table.  Since DT_GNU_HASH/DT_MIPS_XHASH place all
symbols with STB_LOCAL binding before symbols with other bindings and
all undefined symbols defined ones in dynamic symbol table, the highest
symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest dynamic symbol
table index.  We can also get symbol version from DT_VERSYM, DT_VERDEF
and DT_VERNEED entries.

dt_symtab, dt_versym, dt_verdef, dt_verneed, dt_symtab_count,
dt_verdef_count, dt_verneed_count and dt_strtab are added to
elf_obj_tdata to store dynamic symbol table information.

PR ld/25617
* elf-bfd.h (elf_obj_tdata): Add dt_symtab, dt_verdef, dt_verneed,
dt_symtab_count, dt_verdef_count, dt_verneed_count and dt_strtab.
(elf_use_dt_symtab_p): New.
(_bfd_elf_get_dynamic_symbols): Likewise.
(_bfd_elf_get_section_from_dynamic_symbol): Likewise.
* elf.c (bfd_elf_get_elf_syms): Use dynamic symbol table if
neeeded.
(_bfd_elf_get_dynamic_symtab_upper_bound): Likewise.
(_bfd_elf_slurp_version_tables): Likewise.
(offset_from_vma): New function.
(get_hash_table_data): Likewise.
(_bfd_elf_get_dynamic_symbols): Likewise.
(_bfd_elf_get_section_from_dynamic_symbol): Likewise.
(_bfd_elf_get_symbol_version_name): Likewise.
* elfcode.h (elf_object_p): Call _bfd_elf_get_dynamic_symbols
to reconstruct dynamic symbol table from PT_DYNAMIC segment if
there is no section header.
(elf_slurp_symbol_table): Use dynamic symbol table if neeeded.
Don't free isymbuf when dynamic symbol table is used.
* elflink.c (elf_link_is_defined_archive_symbol): Return wrong
format error when dynamic symbol table is used.
(elf_link_add_object_symbols): Likewise.

10 months agoELF: Discard non-alloc sections without section header
H.J. Lu [Wed, 31 May 2023 19:36:49 +0000 (12:36 -0700)] 
ELF: Discard non-alloc sections without section header

Discard non-alloc sections when section headers are stripped.

bfd/

PR ld/25617
* elf.c (_bfd_elf_assign_file_positions_for_non_load): Skip
non-load sections without section header.
(_bfd_elf_write_object_contents): Don't set the sh_name field
without section header.  Write out the .shstrtab section only
if its sh_offset field isn't -1.

binutils/

PR ld/25617
* objcopy.c (is_strip_section_1): Remove non-alloc sections for
--strip-section-headers.

ld/

PR ld/25617
* ldlang.c (lang_discard_section_p): Discard non-alloc sections
if we are stripping section headers.

10 months agoELF: Strip section header in ELF objects
Kaylee Blake [Wed, 4 Mar 2020 08:48:07 +0000 (19:18 +1030)] 
ELF: Strip section header in ELF objects

Section header isn't mandatory on ELF executable nor shared library.
This patch adds a new linker option, -z nosectionheader, to omit ELF
section header, a new objcopy and strip option, --strip-section-headers,
to remove ELF section headers.

bfd/

2023-06-06  H.J. Lu  <hongjiu.lu@intel.com>
    Kaylee Blake  <klkblake@gmail.com>

PR ld/25617
* bfd.c (BFD_NO_SECTION_HEADER): New.
(BFD_FLAGS_SAVED): Add BFD_NO_SECTION_HEADER.
(BFD_FLAGS_FOR_BFD_USE_MASK): Likewise.
* elfcode.h (elf_swap_ehdr_out): Omit section header with
BFD_NO_SECTION_HEADER.
(elf_write_shdrs_and_ehdr): Likewise.
* elfxx-target.h (TARGET_BIG_SYM): Add BFD_NO_SECTION_HEADER
to object_flags.
(TARGET_LITTLE_SYM): Likewise.
* bfd-in2.h: Regenerated.

binutils/

2023-06-06  H.J. Lu  <hongjiu.lu@intel.com>

PR ld/25617
* NEWS: Mention --strip-section-headers for objcopy and strip.
* objcopy.c (strip_section_headers): New.
(command_line_switch): Add OPTION_STRIP_SECTION_HEADERS.
(strip_options): Add --strip-section-headers.
(copy_options): Likewise.
(copy_usage): Add --strip-section-headers.
(strip_usage): Likewise.
(copy_object): Handle --strip-section-headers for ELF files.
(strip_main): Handle OPTION_STRIP_SECTION_HEADERS.
(copy_main): Likewise.
* doc/binutils.texi: Document --strip-section-headers for objcopy
and strip.

ld/

2023-06-06  H.J. Lu  <hongjiu.lu@intel.com>
    Kaylee Blake  <klkblake@gmail.com>

PR ld/25617
* NEWS: Mention -z nosectionheader.
* emultempl/elf.em: Support -z sectionheader and
-z nosectionheader.
* ld.h (ld_config_type): Add no_section_header.
* ld.texi: Document -z sectionheader and -z nosectionheader.
* ldlang.c (ldlang_open_output): Handle
config.no_section_header.
* lexsup.c (parse_args): Enable --strip-all with
-z nosectionheader.  Disallow -r with -z nosectionheader.
(elf_static_list_options): Add -z sectionheader and
-z nosectionheader.

10 months agoIgnore --prefix-file-map compiler option whist running testsuite.
Matthias Klose [Thu, 29 Jun 2023 13:44:52 +0000 (14:44 +0100)] 
Ignore --prefix-file-map compiler option whist running testsuite.

10 months agoignore lto-wrapper warnings for lto builds.
Matthias Klose [Thu, 29 Jun 2023 13:30:55 +0000 (14:30 +0100)] 
ignore lto-wrapper warnings for lto builds.

  I see these warnings from time to time, when configuring a build with  --enable-pgo-build=lto, I haven't yet found out why I see these sometime, and  why not. E.g. https://gcc.gnu.org/PR109241. Just ignore these when they appear  in test cases. lto-wrapper: warning: using serial compilation of N LTRANS jobs

10 months agoAutomatic date update in version.in
GDB Administrator [Thu, 29 Jun 2023 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agogprofng: Add new tests
Vladimir Mezentsev [Mon, 26 Jun 2023 21:36:50 +0000 (14:36 -0700)] 
gprofng: Add new tests

gprofng/ChangeLog
2023-06-26  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* Makefile.am: Pass CLOCK_GETTIME_LINK to the testsuite
* Makefile.in: Rebuild.
* testsuite/gprofng.display/gp-archive.exp: New file.
* testsuite/gprofng.display/gp-collect-app_F.exp: New file.
* testsuite/gprofng.display/setpath_map.exp: New file.
* testsuite/lib/smalltest.c: New file.

10 months agoaarch64: Remove version dependencies from features
Andrew Carlotti [Wed, 28 Jun 2023 17:05:28 +0000 (18:05 +0100)] 
aarch64: Remove version dependencies from features

Many instructions were enabled only when both a feature flag and a minimum
architecture version are specified.  This behaviour differs from GCC, which (in
most cases) allows features to be enabled at any architecture version.

There is no need for the toolchain to restrict combinations of unrelated
features in this way, so this patch removes the unnecessary dependencies.

10 months agoRemove Python 2 from gdb documentation
Tom Tromey [Wed, 28 Jun 2023 15:39:37 +0000 (09:39 -0600)] 
Remove Python 2 from gdb documentation

GDB can't be built using Python 2 any more, so remove the remaining
vestiges of this from the documentation.

Approved-By: Eli Zaretskii <eliz@gnu.org>
10 months agosection-match: Check parent archive name as well
Michael Matz [Mon, 26 Jun 2023 15:11:31 +0000 (17:11 +0200)] 
section-match: Check parent archive name as well

rewriting the section matching routines lost a special case
of matching: section statements of the form

    NAME(section-glob)

normally match against NAME being an object file, but like in
the exclude list we happened to accept archive names as NAME
(undocumented).  The documented way to specify (all) archive members
is by using e.g.

    lib.a:(section-glob)

(that does work also with the prefix tree matcher).

But I intended to not actually change behaviour with the prefix
tree implementation.  So, let's also implement checking against
archive names with a similar FIXME comment we already have in
walk_wild_file_in_exclude_list.

PR 30590

ld/
* ldlang.c (walk_wild_section_match): Also look at archive
parents for a name match.

10 months agoFix handling of DW_TAG_unspecified_type for Ada
Tom Tromey [Tue, 13 Jun 2023 15:36:35 +0000 (09:36 -0600)] 
Fix handling of DW_TAG_unspecified_type for Ada

Commit 80eaec735e ("[gdb/symtab] Handle named DW_TAG_unspecified_type
DIE") changed the handling of DW_TAG_unspecified_type.  Before this
change, such types were not entered into the symbol table.

It turns out that, when such a type is in the symtab, it can cause
failures in Ada.  In particular, a private type in another package may
be seen locally as "void".

Now, it would probably be better to fix this via check_typedef.
However, that is somewhat difficult given the state of the DWARF
reader -- in particular with gdb_index, this would require expanding
potentially many CUs to find the correct type.

Instead, this patch changes gdb to not enter a symbol for an
unspecified type -- but only for Ada.

10 months agoRemove some Python 2 code
Tom Tromey [Tue, 13 Jun 2023 18:51:55 +0000 (12:51 -0600)] 
Remove some Python 2 code

I found some Python 2 compatibility code in gdb's Python library.
There's no need for this any more, so this removes it.  There is still
a bit more of this remaining in __init__.py, but I haven't tried
removing that yet.

Reviewed-By: Bruno Larsen <blarsen@redhat.com>
10 months agoStop the linker's --dependency-file option from including temporary lto files.
Nick Clifton [Wed, 28 Jun 2023 12:49:43 +0000 (13:49 +0100)] 
Stop the linker's --dependency-file option from including temporary lto files.

  PR 30568
  * ldfile.c (ldfile_try_open_bfd): Do not track lto generated temporary files.

10 months agoUpdated French translation for the gold sub-directory
Nick Clifton [Wed, 28 Jun 2023 10:43:13 +0000 (11:43 +0100)] 
Updated French translation for the gold sub-directory

10 months agoLoongArch: gas: Add LSX and LASX instructions test
mengqinggang [Thu, 22 Jun 2023 02:32:49 +0000 (10:32 +0800)] 
LoongArch: gas: Add LSX and LASX instructions test

gas/ChangeLog:

* testsuite/gas/loongarch/vector.d: New test.
* testsuite/gas/loongarch/vector.s: New test.

10 months agoLoongArch: gas: Add lsx and lasx instructions support
mengqinggang [Thu, 22 Jun 2023 02:35:28 +0000 (10:35 +0800)] 
LoongArch: gas: Add lsx and lasx instructions support

gas/ChangeLog:

* config/tc-loongarch.c (md_parse_option): Add lsx and lasx option.
(loongarch_after_parse_args): Add lsx and lasx option.

opcodes/ChangeLog:

* loongarch-opc.c (struct loongarch_ase): Add lsx and lasx
instructions.

10 months agoLoongArch: Add R_LARCH_64_PCREL relocation support
mengqinggang [Sun, 25 Jun 2023 09:47:42 +0000 (17:47 +0800)] 
LoongArch: Add R_LARCH_64_PCREL relocation support

  Gas defaults to emit R_LARCH_ADD64/R_LARCH_SUB64 unless explcitly declared
  to emit R_LARCH_64_PCREL.

  The LoongArch ABI at here:
    https://github.com/loongson/la-abi-specs/blob/release/la-abi.adoc

bfd/ChangeLog:

* bfd-in2.h (not): Add R_LARCH_64_PCREL
* elfnn-loongarch.c (perform_relocation): Likewise.
* elfxx-loongarch.c: Likewise.
* libbfd.h: Likewise.
* reloc.c: Likewise.

gas/ChangeLog:

* config/tc-loongarch.c (loongarch_args_parser_can_match_arg_helper):
(md_apply_fix): Add R_LARCH_64_PCREL.
* testsuite/gas/loongarch/64_pcrel.d: New test.
* testsuite/gas/loongarch/64_pcrel.s: New test.

include/ChangeLog:

* elf/loongarch.h (RELOC_NUMBER): Add R_LARCH_64_PCREL.

ld/ChangeLog:

* testsuite/ld-loongarch-elf/ld-loongarch-elf.exp: Add test.
* testsuite/ld-loongarch-elf/64_pcrel.d: New test.
* testsuite/ld-loongarch-elf/64_pcrel.s: New test.

10 months agoAutomatic date update in version.in
GDB Administrator [Wed, 28 Jun 2023 00:00:25 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agobinutils/NEWS: add note about upcoming libsframe changes
Indu Bhagat [Tue, 27 Jun 2023 18:57:44 +0000 (11:57 -0700)] 
binutils/NEWS: add note about upcoming libsframe changes

Some of these changes update the ABI in an incompatible way.

10 months agolibsframe: bfd: use uint32_t for return type of get_num_fidx APIs
Indu Bhagat [Tue, 27 Jun 2023 18:56:26 +0000 (11:56 -0700)] 
libsframe: bfd: use uint32_t for return type of get_num_fidx APIs

Keep the data types usage in libsframe look consistent.

bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe): Use uint32_t
type alias.
* libsframe/sframe.c (sframe_decoder_get_funcdesc_at_index):
Likewise.
(sframe_decoder_get_num_fidx): Likewise.
(sframe_encoder_get_num_fidx): Likewise.
include/
* sframe-api.h (sframe_decoder_get_num_fidx): Likewise.
(sframe_encoder_get_num_fidx): Likewise.

10 months agolibsframe: use appropriate data types for args of sframe_encode
Indu Bhagat [Tue, 27 Jun 2023 18:56:13 +0000 (11:56 -0700)] 
libsframe: use appropriate data types for args of sframe_encode

include/
* sframe-api.h (sframe_encode): Use of uint8_t is more
appropriate.
libsframe/
* sframe.c (sframe_encode): Likewise.

10 months agolibsframe: use uint8_t for return type of sframe_fre_get_base_reg_id
Indu Bhagat [Tue, 27 Jun 2023 18:56:04 +0000 (11:56 -0700)] 
libsframe: use uint8_t for return type of sframe_fre_get_base_reg_id

Use a more appropriate data type.

include/
* sframe-api.h (sframe_fre_get_base_reg_id): Use uint8_t as
return type.
libsframe/
* sframe-dump.c (dump_sframe_func_with_fres): Use uint8_t type
for base reg id.
* sframe.c (sframe_fre_get_base_reg_id): Use uin8_t as return
type.

10 months agolibsframe: use uint8_t instead of unsigned char for abi_arch
Indu Bhagat [Tue, 27 Jun 2023 18:55:59 +0000 (11:55 -0700)] 
libsframe: use uint8_t instead of unsigned char for abi_arch

Use uint8_t consistently for identifying ABI/arch in SFrame format.

bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe):
libsframe/
* sframe-dump.c (is_sframe_abi_arch_aarch64): Use uint8_t for
local variable.
* sframe.c (sframe_decoder_get_abi_arch): Update return type to
uint8_t.
(sframe_encoder_get_abi_arch): Likewise.
include/
* sframe-api.h (sframe_decoder_get_abi_arch): Likewise.
(sframe_encoder_get_abi_arch): Likewise.

10 months agolibsframe: bfd: use uint32_t for return type of sframe_calc_fre_type
Indu Bhagat [Tue, 27 Jun 2023 18:55:38 +0000 (11:55 -0700)] 
libsframe: bfd: use uint32_t for return type of sframe_calc_fre_type

Use uint32_t type alias consistently for all APIs in libsframe.

bfd/
* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Adjust for the
changed return type.
libsframe/
* sframe.c (sframe_calc_fre_type): Use uint32_t for return type.
include/
* sframe-api.h (sframe_calc_fre_type): Likewise.

10 months agolibsframe: use uint32_t for fre_type and fde_type function args
Indu Bhagat [Tue, 27 Jun 2023 18:55:08 +0000 (11:55 -0700)] 
libsframe: use uint32_t for fre_type and fde_type function args

The API sframe_fde_create_func_info is provided by libsframe.  Current
users are the bfd linker.  Adjust the argument type for the variables
carrying the SFrame FRE type and SFrame FDE type to consistenly use
uint32_t type alias.

include/
* sframe-api.h (sframe_fde_create_func_info): Use uint32_t
instead of unsigned int.
libsframe/
* sframe.c (sframe_get_fre_type): Likewise.
(sframe_get_fde_type): Likewise.
(flip_fre_start_address): Likewise.
(sframe_fre_start_addr_size): Likewise.
(sframe_fre_entry_size): Likewise.
(flip_fre): Likewise.
(flip_sframe): Likewise.
(sframe_fde_create_func_info): Likewise.
(sframe_calc_fre_type): Likewise.
(sframe_decode_fre_start_address): Likewise.
(sframe_decode_fre): Likewise.
(sframe_find_fre): Likewise.
(sframe_decoder_get_fre): Likewise.
(sframe_encoder_add_fre): Likewise.
(sframe_encoder_write_fre_start_addr): Likewise.
(sframe_encoder_write_fre): Likewise.
(sframe_encoder_write_sframe): Likewise.

10 months agolibsframe: update the semantics of sframe_fre_get_fp_offset
Indu Bhagat [Tue, 27 Jun 2023 18:55:00 +0000 (11:55 -0700)] 
libsframe: update the semantics of sframe_fre_get_fp_offset

Until now, sframe_fre_get_fp_offset () would return
SFRAME_ERR_FREOFFSET_NOPRESENT if the ABI uses fixed FP offset.  A stack
tracer, then, would call an explicit sframe_decoder_get_fixed_fp_offset ()
to get the FP offset.

On second look, it appears to make sense to hide these details of
whether the FP offset is fixed or not in an ABI from the consumer.  Now,
with the changed semantics, the call to sframe_fre_get_fp_offset () will
fetch the fixed FP offset if applicable, or get the FP offset from FRE
when there is no fixed FP offset.

This patch changes the behavior of sframe_fre_get_fp_offset (): it turns
an error into non-error.  This change will be included with the next
release of libsframe, where all the exposed symbols will be versioned
with version node LIBSFRAME_1.0 for the first time.

libsframe/
* sframe.c (sframe_fre_get_fp_offset): Return the fixed offset, if
applicable. Else return the FP offset from the FRE.

10 months agolibsframe: update the semantics of sframe_fre_get_ra_offset
Indu Bhagat [Tue, 27 Jun 2023 18:54:49 +0000 (11:54 -0700)] 
libsframe: update the semantics of sframe_fre_get_ra_offset

Until now, sframe_fre_get_ra_offset () would return
SFRAME_ERR_FREOFFSET_NOPRESENT if the ABI uses fixed RA offset (e.g.,
AMD64).  A stack tracer, then, will call an explicit
sframe_decoder_get_fixed_ra_offset () to get the RA offset.

On second look, it appears to make sense to hide these details of
whether the RA offset is fixed or not from the consumer.  Now, with the
changed semantics, the call to sframe_fre_get_ra_offset () will fetch
the fixed RA offset if applicable, or get the RA offset from FRE when
there is no fixed RA offset.

Adjustments need to be made to ensure the textual dump remains the same
as preivous.  Currently, e.g., if RA is not being tracked per FRE,
following is seen with objdump --sframe:

    STARTPC         CFA       FP        RA
    000000000000NNNN  sp+X      u         u

This patch changes the behavior of sframe_fre_get_ra_offset: it turns an
error into non-error.  This change will be included with the next
release of libsframe, where all exposed symbols will be versioned for
the first time.

libsframe/
* sframe.c (sframe_fre_get_ra_offset): Return the fixed offset,
if applicable.  Else return the RA offset from the FRE.
* sframe-dump.c (dump_sframe_func_with_fres): Make adjustments
to keep the textual dump same as previous.

10 months agolibsframe: add symbol versioning
Indu Bhagat [Tue, 27 Jun 2023 18:54:12 +0000 (11:54 -0700)] 
libsframe: add symbol versioning

Define an empty base version LIBSFRAME_0.0 and add all symbols to
version LIBSFRAME_1.0.

The previous release of libsframe (libsframe.so.0) did not have
versioned symbols.  Adding a libsframe.ver file so that future releases
of the library (and its consumers) can manage the changes better.

For Solaris ld, use -M mapfile command line option.  libsframe does not
restrict the set of exported symbols, so at this time there is no need
to fall back on the libtool's -export-symbols option for platforms where
some other linker (with a different command line option for symbol
versioning) may be used.

libsframe/
* Makefile.am: Use symbol versioning for libsframe.
* Makefile.in: Regenerated.
* configure: Check for Solaris ld.
* configure.ac: Regenerated.
* libsframe.ver: New file.

10 months agolibsframe: remove sframe_get_funcdesc_with_addr API
Indu Bhagat [Tue, 27 Jun 2023 18:53:40 +0000 (11:53 -0700)] 
libsframe: remove sframe_get_funcdesc_with_addr API

This is an incompatible ABI change in libsframe.

The interface provided by this function is not a healthy abstraction to
expose: the return type sframe_func_desc_entry, which is defined in
include/sframe.h (the SFrame binary format definition).  This ties up
the library in a undesirable way.  Most importantly, this function
should technically not be directly necessary for a stack tracer.  A
stack tracer will likely only need to do a sframe_find_fre ().

Rename the API to continue to use the functionality internally in the
library.  bfd/linker does not use this function.

Change the return type of the previous definition and make a note about
its planned deprecation.

include/
* sframe-api.h:  Change return type of sframe_get_funcdesc_with_addr.
Add comment for intention to deprecate.
libsframe/
*sframe.c (sframe_get_funcdesc_with_addr): Change return type
and set error code. This API is deprecated.
        (sframe_get_funcdesc_with_addr_internal): New definition for
internal use.
(sframe_find_fre): Use sframe_get_funcdesc_with_addr_internal
instead.

10 months agolibsframe: add library versioning
Indu Bhagat [Tue, 27 Jun 2023 18:52:43 +0000 (11:52 -0700)] 
libsframe: add library versioning

lisbframe was first released with Bintuils 2.40.  As the library
evolves, some changes will break the ABI.  Add library versioning for
users to manage these changes.

For the next release of the library (libsframe.so.1), incompatible ABI
changes are planned. These will include:
 - Deprecation of some APIs, like sframe_get_funcdesc_with_addr (), and
 - Change in the contract of some APIs (e.g., return type, behavior).

In libtool-version, set the current to 1 to prepare for the upcoming
release.  Reset revision and age to 0.

Add libtool-version file to EXTRA_DIST.

libsframe/
* Makefile.am: Use libtool versioning.
* Makefile.in: Regenerated.
* libtool-version: New file.

10 months ago RISC-V: Support Zicond extension
Philipp Tomsich [Tue, 27 Jun 2023 13:22:49 +0000 (07:22 -0600)] 
RISC-V: Support Zicond extension

    This implements the Zicond (conditional integer operations) extension,
    as of version 1.0-rc2.

    The Zicond extension acts as a building block for branchless sequences
    including conditional-arithmetic, conditional-logic and
    conditional-select/move.
    The following instructions constitute Zicond:
      - czero.eqz rd, rs1, rs2  =>  rd = (rs2 == 0) ? 0 : rs1
      - czero.nez rd, rs1, rs2  =>  rd = (rs2 != 0) ? 0 : rs1

    See
      https://github.com/riscv/riscv-zicond/releases/download/v1.0-rc2/riscv-zicond-v1.0-rc2.pdf
    for the proposed specification and usage details.

    bfd/ChangeLog:

            * elfxx-riscv.c (riscv_multi_subset_supports): Recognize
            INSN_CLASS_ZICOND.
            (riscv_multi_subset_supports_ext): Recognize INSN_CLASS_ZICOND.

    gas/ChangeLog:

            * testsuite/gas/riscv/zicond.d: New test.
            * testsuite/gas/riscv/zicond.s: New test.

    include/ChangeLog:

            * opcode/riscv-opc.h (MATCH_CZERO_EQZ): Define.
            (MASK_CZERO_EQZ): Define.
            (MATCH_CZERO_NEZ): Define,
            (MASK_CZERO_NEZ): Define.
            (DECLARE_INSN): Add czero.eqz and czero.nez.
            * opcode/riscv.h (enum riscv_insn_class): Add
            INSN_CLASS_ZICOND.

    opcodes/ChangeLog:

            * riscv-opc.c: Add czero.eqz and czero.nez.

Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
10 months agoAdd note about adding ChangeLog.git to src-release.sh
Nick Clifton [Tue, 27 Jun 2023 09:15:51 +0000 (10:15 +0100)] 
Add note about adding ChangeLog.git to src-release.sh

10 months agogprofng: Update intel url
Cui, Lili [Tue, 27 Jun 2023 07:58:12 +0000 (07:58 +0000)] 
gprofng: Update intel url

Since the old software.intel.com has been removed, update a new one.

gprofng/ChangeLog
2023-06-27  Lili Cui  <lili.cui@intel.com>

* gp-display-html/gp-display-html.in: Update intel url.

10 months agoAutomatic date update in version.in
GDB Administrator [Tue, 27 Jun 2023 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agoFix gas tests for aarch64-pe
Nick Clifton [Mon, 26 Jun 2023 16:37:19 +0000 (17:37 +0100)] 
Fix gas tests for aarch64-pe

10 months agoSynchromize libiberty sources with master version in gcc repository
Nick Clifton [Mon, 26 Jun 2023 14:47:15 +0000 (15:47 +0100)] 
Synchromize libiberty sources with master version in gcc repository

10 months agoSync config.guess and config.sub with upstream master versions.
Nick Clifton [Mon, 26 Jun 2023 13:11:30 +0000 (14:11 +0100)] 
Sync config.guess and config.sub with upstream master versions.

10 months agoUpdated French translation for the gprof sub-directory
Nick Clifton [Mon, 26 Jun 2023 12:24:19 +0000 (13:24 +0100)] 
Updated French translation for the gprof sub-directory

10 months agoAutomatic date update in version.in
GDB Administrator [Mon, 26 Jun 2023 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agoLoongArch: Support referring to FCSRs as $fcsrX
Feiyang Chen [Fri, 16 Jun 2023 03:16:10 +0000 (11:16 +0800)] 
LoongArch: Support referring to FCSRs as $fcsrX

Previously, FCSRs were referred to as $rX, which seemed strange.
We refer to FCSRs as $fcsrX, which ensures compatibility with LLVM
IAS as well.

gas/ChangeLog:

        * config/tc-loongarch.c:
        (loongarch_fc_normal_name): New definition.
        (loongarch_fc_numeric_name): New definition.
        (loongarch_single_float_opcodes): Modify `movgr2fcsr` and
        `movfcsr2gr`.
        testsuite/gas/loongarch/float_op.d: Likewise.
        testsuite/gas/loongarch/float_op.s: Likewise.

include/ChangeLog:

        * opcode/loongarch.h:
        (loongarch_fc_normal_name): New extern.
        (loongarch_fc_numeric_name): New extern.

opcodes/ChangeLog:

        * opcodes/loongarch-dis.c (loongarch_after_parse_args): Support
        referring to FCSRs as $fcsrX.
        * opcodes/loongarch-opc.c (loongarch_args_parser_can_match_arg_helper):
        Likewise.

Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
10 months agoAutomatic date update in version.in
GDB Administrator [Sun, 25 Jun 2023 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agoAutomatic date update in version.in
GDB Administrator [Sat, 24 Jun 2023 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agogdb/testsuite: Avoid infinite loop in gdb.reverse/step-reverse.exp
Thiago Jung Bauermann [Wed, 31 May 2023 19:46:29 +0000 (21:46 +0200)] 
gdb/testsuite: Avoid infinite loop in gdb.reverse/step-reverse.exp

This testcase sometimes gets stuck in a loop for hours when running in our
CI.  The problem is that due to an issue unrelated to reverse debugging the
inferior exits early, and because of the overly generic ".*" pattern the
testcase keeps sending the "next" command without noticing that the
inferior is gone.

gdb_test_multiple has a pattern to detect that "The program is not being
run.", but since it is placed after the patterns from the caller it won't
be triggered.  It also has a timeout pattern but because it is triggered
between successful matches, each time the test matches the '-re -wrap ".*"'
this counts as a successful match and the timeout is reset.

Since the test binary is compiled with debug information, fix by changing
one of the generic patterns to match entering the main function and the
other one to match the source code line number that is shown by GDB right
after the "step" command.

Also, as a precaution add a maximum number of times the "next" command will
be sent.

Co-Authored-By: Tom de Vries <tdevries@suse.de>
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
Approved-By: Tom de Vries <tdevries@suse.de>
10 months ago[GOLD] PowerPC64 huge branch dynamic relocs
Alan Modra [Fri, 23 Jun 2023 01:07:53 +0000 (10:37 +0930)] 
[GOLD] PowerPC64 huge branch dynamic relocs

PowerPC64 gold and ld.bfd implement an indirect branch trampoline,
used when the destination of a branch exceeds a bounce through another
"b" instruction.  When generating PIEs or shared libraries, the
addresses need dynamic relocations.  This was implemented in gold
using a dedicated relocation section, but this means the relative
relocations for these addresses are not sorted properly with other
dynamic relative relocations: gold doesn't support merging relocation
sections, then sorting.  Instead we need to use a single .rela.dyn
section.

This is done by increasing the size of rela_dyn_ during do_relax to
account for needed dynamic relocations, delaying adding the actual
relocations until the end of relaxation once the layout has
stabilised.

* powerpc.cc (Target_powerpc): Add rela_dyn_size_;
(update_current_size): New function.
(Target_powerpc::do_relax): Capture the size of rela_dyn_ at
the start of relaxation.  Artifically increase its size during
relaxation to account for needed indirect branches, and add
those relocations at the end.
(Output_data_brlt_powerpc::rel_, reset_brlt_sizes),
(finalize_brlt_sizes, add_reloc, set_current_size): Delete.
(Target_powerpc::make_brlt_section): Don't make reloc section.

10 months ago[GOLD] Support setting DT_RELACOUNT late
Alan Modra [Fri, 23 Jun 2023 00:08:13 +0000 (09:38 +0930)] 
[GOLD] Support setting DT_RELACOUNT late

PowerPC gold adds relative dynamic relocs in do_relax.  These aren't
accounted for in the value set in add_target_dynamic_tags, which is
called before do_relax.  Provide a way of setting DT_RELCOUNT and
DT_RELACOUNT at the point where .dynamic is written.

* layout.cc (Layout::add_target_dynamic_tags): Add custom_relcount
parameter.  Emit DT_RELCOUNT/RELACOUNT as a custom target handled
dynamic tag if set.
* layout.h(Layout::add_target_dynamic_tags): Update prototype.
* aarch64.cc (Target_aarch64::do_finalize_sections): Adjust
add_target_dynamic_tags call.
* arm.cc (Target_arm::do_finalize_sections): Likewise.
* i386.cc (Target_i386::do_finalize_sections): Likewise.
* mips.cc (Target_mips::do_finalize_sections): Likewise.
* s390.cc (Target_s390::do_finalize_sections): Likewise.
* sparc.cc (Target_sparc::do_finalize_sections): Likewise.
* tilegx.cc (Target_tilegx::do_finalize_sections): Likewise.
* x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.
* powerpc.cc (Target_powerpc::do_finalize_sections): Likewise.
(Target_powerpc::do_dynamic_tag_custom_value): New function.

10 months ago[GOLD] powerpc DT_RELACOUNT
Alan Modra [Thu, 22 Jun 2023 23:18:38 +0000 (08:48 +0930)] 
[GOLD] powerpc DT_RELACOUNT

DT_RELACOUNT was calculated incorrectly, and relative relocs not
sorted as they should be to the start of .rela.dyn, due to adding one
particular class of dynamic reloc using the wrong "add" method.

* powerpc.cc (Target_powerpc::Scan::global): Add relative
dyn relocs for ADDR64 and similar using add_global_relative.

10 months agolto test fails with -fno-inline in CFLAGS
Alan Modra [Fri, 23 Jun 2023 02:06:13 +0000 (11:36 +0930)] 
lto test fails with -fno-inline in CFLAGS

Putting -fno-inline in CFLAGS results in these failures.
FAIL: Build liblto-17b.so 1
FAIL: PR ld/12365
FAIL: PR ld/13183

* ld-plugin/lto.exp: Add -finline to compiler flags in some tests.

10 months agoFix off-by-one error
Tom Tromey [Fri, 23 Jun 2023 02:34:56 +0000 (20:34 -0600)] 
Fix off-by-one error

Simon pointed out that commit a2bbca9fa5e ("Use std::vector<bool> for
agent_expr::reg_mask") caused a regression in libstdc++ debug mode.
This was due to an off-by-one error in a vector resize.  This patch
fixes the problem.

10 months agoAutomatic date update in version.in
GDB Administrator [Fri, 23 Jun 2023 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agogdb/testsuite: fix gdb.python/py-unwind.exp with python >= 3.11
Ilya Leoshkevich [Wed, 21 Jun 2023 21:55:42 +0000 (23:55 +0200)] 
gdb/testsuite: fix gdb.python/py-unwind.exp with python >= 3.11

Python 3.11 changed the AttributeError message - see commit
0cb765b2cec9 ("bpo-46730: Add more info to @property AttributeError
messages (GH-31311)").  Add the new message to the expectations.

Approved-By: Tom Tromey <tom@tromey.com>
Link: https://sourceware.org/pipermail/gdb-patches/2023-June/200433.html
10 months agoRevert "x86: Don't check if AVX512 template requires AVX512VL"
H.J. Lu [Thu, 22 Jun 2023 19:37:51 +0000 (12:37 -0700)] 
Revert "x86: Don't check if AVX512 template requires AVX512VL"

This reverts commit c7face14225296a2f5d3ebeb8ace88c166d80c3e.

10 months ago[gdb/testsuite] Clean or check standard_output_file dir in gdb_init
Tom de Vries [Thu, 22 Jun 2023 17:15:23 +0000 (19:15 +0200)] 
[gdb/testsuite] Clean or check standard_output_file dir in gdb_init

In commit e2adba909e7 ("[gdb/testsuite] Clean up before compilation in
gdb.ada/call-no-debug.exp") I added some code in the test-case to remove some
files at the start of the test-case:
...
remote_file host delete [standard_output_file prog.o]
remote_file host delete [standard_output_file prog.ali]
...

Then in commit b7b77500dc5 ("[gdb/testsuite] Clean standard_output_file dir in
gdb_init") I tried to do this more structurally, by cleaning up the entire
standard_output_file directory, for all test-cases.

This caused a regression when using "make check -j 2", due to the cleanup
removing the active gdb.log, so I reverted the commit.

Try again, this time handling the two cases separately.

If the standard_output_file directory contains an active gdb.log, check that
the directory contains no files other than gdb.log and gdb.sum.  This puts
the reponsibility for the cleanup at the callers in gdb/testsuite/Makefile.in
which use --outdir.

If the standard_output_file directory doesn't contain an active gdb.log, clean
it by removing the entire directory.

An exception is made for performance tests, where cleaning up the
standard_output_file dir is the wrong thing to do, because an invocation with
GDB_PERFTEST_MODE == run is intended to reuse binaries left there by an
earlier invocation with GDB_PERFTEST_MODE == compile.

Tested on x86_64-linux.

Suggested-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Tom Tromey <tom@tromey.com>
Tested-By: Luis Machado <luis.machado@arm.com>
10 months agoImplement DAP "hover" context
Tom Tromey [Thu, 1 Jun 2023 17:54:17 +0000 (11:54 -0600)] 
Implement DAP "hover" context

A DAP client can request that an expression be evaluated in "hover"
context, meaning that it should not cause side effects.  In gdb, this
can be implemented by temporarily setting a few "may-" parameters to
"off".

In order to make this work, I had to also change "may-write-registers"
so that it can be changed while the program is running.  I don't think
there was any reason for this prohibition in the first place.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30476

10 months agoImplement DAP logging breakpoints
Tom Tromey [Wed, 31 May 2023 17:21:09 +0000 (11:21 -0600)] 
Implement DAP logging breakpoints

DAP allows a source breakpoint to specify a log message.  When this is
done, the breakpoint acts more like gdb's dprintf: it logs a message
but does not cause a stop.

I looked into implement this using dprintf with the new %V printf
format.  However, my initial attempt at this did not work, because
when the inferior is continued, the dprintf output is captured by the
gdb.execute call.  Maybe this could be fixed by having all
inferior-continuation commands use the "&" form; the main benefit of
this would be that expressions are only parsed a single time.

10 months agoHandle supportsVariablePaging in DAP
Tom Tromey [Fri, 26 May 2023 19:35:52 +0000 (13:35 -0600)] 
Handle supportsVariablePaging in DAP

A bug report about the supportsVariablePaging capability in DAP
resulted in a clarification: when this capability is not present, DAP
implementations should ignore the paging parameters to the "variables"
request.  This patch implements this clarification.

10 months agoImplement type checking for DAP breakpoint requests
Tom Tromey [Thu, 25 May 2023 18:25:43 +0000 (12:25 -0600)] 
Implement type checking for DAP breakpoint requests

I realized that with a small refactoring, it is possible to type-check
the parameters to the various DAP breakpoint requests.  This would
have caught the earlier bug involving hitCondition.

10 months agoHandle exceptions when creating DAP breakpoints
Tom Tromey [Thu, 25 May 2023 17:24:39 +0000 (11:24 -0600)] 
Handle exceptions when creating DAP breakpoints

When creating a DAP breakpoint, a failure should be returned by
setting "verified" to False.  gdb didn't properly implement this, and
there was a FIXME comment to this effect.  This patch fixes the
problem.

10 months agoReuse breakpoints more frequently in DAP
Tom Tromey [Wed, 24 May 2023 20:22:55 +0000 (14:22 -0600)] 
Reuse breakpoints more frequently in DAP

The DAP breakpoint code tries to reuse a breakpoint when possible.
Currently it uses the condition and the hit condition (aka ignore
count) when making this determination.  However, these attributes are
just going to be reset anyway, so this patch changes the code to
exclude these from the reuse decision.

10 months agoFix type of DAP hitCondition
Tom Tromey [Wed, 24 May 2023 20:24:13 +0000 (14:24 -0600)] 
Fix type of DAP hitCondition

DAP specifies a breakpoint's hitCondition as a string, meaning it is
an expression to be evaluated.  However, gdb implemented this as if it
were an integer instead.  This patch fixes this oversight.

10 months agogdb/DAP Few bug fixes & Evaluate Array Watch vars
Simon Farre [Mon, 19 Jun 2023 23:27:28 +0000 (01:27 +0200)] 
gdb/DAP Few bug fixes & Evaluate Array Watch vars

v2.

EvaluateResult does not need a name, just as what Tom pointed out in
previous review. It's only the *children* that need to be made sure that
their names are valid. An identifier for a variable, can't ever have an
integer as a name, anyhow (not as far as I am aware, no programming
languages allow for that).

Removed the f-strings and use str() instead as pointed out that
f-strings might not be supported fully.

v1.

This patch fixes a few bugs.

First of all, name of VariableReferences must always be of string type.
This patch makes sure that this is the case by formatting the name. If
(when) the name is an integer, this will cause clients to fail or throw
errors.

Fixes a bug in NoOpArrayPrinter that calculated children to be N, but
only ever retrieves N-1 children, which makes Python at some time later
(during fetch_children -> fetch_one_child(N) ) raise an exception (out
of list index) which makes the entire request go bad.

The result[self.result_name] also f-strings the printer.to_string()
value, because this can potentially be a LazyString (which is a Python
object, not a string) and is not serializable by json.dumps.

Approved-By: Tom Tromey <tom@tromey.com>
10 months agoAutomatic date update in version.in
GDB Administrator [Thu, 22 Jun 2023 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agox86: Free the symbol buffer and the relocation buffer after use
H.J. Lu [Tue, 20 Jun 2023 22:10:11 +0000 (15:10 -0700)] 
x86: Free the symbol buffer and the relocation buffer after use

When --no-keep-memory is used, the symbol buffer and the relocation
buffer aren't cached.  When packing relative relocations, we may
allocate a new symbol buffer and a new relocation buffer for each
eligible section in an object file.  If there are many sections,
memory may be exhausted.  In this case, we should free the symbol
buffer and the relocation buffer after use.  If symbol buffer entries
are used to track relative relocations against local symbols for later
use, the symbol buffer should be cached.

PR ld/30566
* elfxx-x86.c (elf_x86_relative_reloc_record_add): Add an
argument to inform caller if the symbol buffer should be kept.
(_bfd_x86_elf_link_relax_section): Call
_bfd_elf_link_info_read_relocs instead of
_bfd_elf_link_read_relocs.  Free the symbol buffer and the
relocation buffer after use.  Cache the symbol buffer if it
is used.

10 months agoAdd missing backslash to update-gnulib.sh
Tom Tromey [Wed, 31 May 2023 12:27:16 +0000 (06:27 -0600)] 
Add missing backslash to update-gnulib.sh

A user on irc noticed a missing backslash on one line in
update-gnulib.sh.  This patch adds it.

Re-running update-gnulib.sh causes a few copyright notices to change.
Presumably these are from upstream gnulib and shouldn't be touched by
our yearly update.  I've updated the script to account for this, but I
did not want to try testing it...

10 months ago[gdb/testsuite] Add have_host_locale
Tom de Vries [Wed, 21 Jun 2023 14:29:04 +0000 (16:29 +0200)] 
[gdb/testsuite] Add have_host_locale

With test-case gdb.tui/pr30056.exp, I run into:
...
sh: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)^M
...
and then subsequently into:
...
WARNING: timeout in accept_gdb_output
FAIL: gdb.tui/pr30056.exp: Control-C
...

This is on a CentOS 7 distro for powerpc64le.

Either it has no C.UTF-8 support, or it's not installed:
...
$ locale -a | grep ^C
C
$
...

Fix this by:
- adding a new proc have_host_locale, and
- using it in all test-cases using setenv LC_ALL.

Tested on powerpc64le-linux and x86_64-linux.

10 months ago[gdb/testsuite] Fix gdb.tui/wrap-line.exp
Tom de Vries [Wed, 21 Jun 2023 14:16:50 +0000 (16:16 +0200)] 
[gdb/testsuite] Fix gdb.tui/wrap-line.exp

PR testsuite/30458 reports the following FAIL:
...
PASS: gdb.tui/wrap-line.exp: width-auto-detected: cli: wrap
^CQuit
(gdb) WARNING: timeout in accept_gdb_output
Screen Dump (size 50 columns x 24 rows, cursor at column 6, row 3):
    0 Quit
    1 (gdb) 7890123456789012345678901234567890123456789
    2 W^CQuit
    3 (gdb)
  ...
FAIL: gdb.tui/wrap-line.exp: width-auto-detected: cli: prompt after wrap
...

The problem is that the regexp doesn't account for the ^C:
...
    gdb_assert { [Term::wait_for "^WQuit"] } "prompt after wrap"
...

The ^C occurs occasionally.  This is something we'd like to fix.  It's
reported as a readline problem here (
https://lists.gnu.org/archive/html/bug-readline/2023-06/msg00000.html ).

For now, fix this by updating the regexp, and likewise in another place in the
test-case where we use ^C.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30458

10 months agoPR30536, ppc64el gold linker produces unusable clang-16 binary
Alan Modra [Wed, 21 Jun 2023 13:14:09 +0000 (22:44 +0930)] 
PR30536, ppc64el gold linker produces unusable clang-16 binary

In commit 0961e631575b, the fix for PR30217, make_lplt_section and
make_brlt_section were changed to use rela_dyn_ rather than their own
separate dynamic reloc sections.  This fails miserably whenever brlt_
is needed for long branches, due to needing to iterate sizing and thus
reset brlt_ sizes.

PR 30536
PR 30217
* powerpc.cc (Target_powerpc::make_brlt_section): Don't use
rela_dyn_.

10 months ago[gdb/testsuite] Reimplement Term::command_no_prompt_prefix
Tom de Vries [Wed, 21 Jun 2023 13:31:37 +0000 (15:31 +0200)] 
[gdb/testsuite] Reimplement Term::command_no_prompt_prefix

Say we run test-case gdb.tui/basic.exp.  It calls Term::enter_tui, which does:
...
command_no_prompt_prefix "tui enable"
...

The proc command_no_prompt_prefix is documented as:
...
    # As proc command, but don't wait for an initial prompt.  This is used for
    # initial terminal commands, where there's no prompt yet.
...

Indeed, before the "tui enable" command, the tuiterm is empty, so there is no
prompt and just before switching to TUI we have in the tuiterm:
...
tui enable
...

The reason that there is no prompt, is that:
- in order for tuiterm to show something, its input processing procs need to
  be called, and
- the initial gdb prompt, and subsequent prompts generated by gdb_test-style
  procs, are all consumed by those procs instead.

This is in principle not a problem, but the absence of a prompt makes a
tuiterm session look less like a session on an actual xterm.

Add a new proc gen_prompt, that:
- generates a prompt using echo
- consumes the response before the prompt using gdb_expect
- consumes the prompt using Term::wait_for "".

This allows us to reimplement Term::command_no_prompt_prefix using
Term::command, and just before switching to TUI we have in the tuiterm:
...
(gdb) tui enable
...

Tested on x86_64-linux.

10 months ago[gdb/testsuite] Make Term::wait_for "" match only a prompt
Tom de Vries [Wed, 21 Jun 2023 13:31:37 +0000 (15:31 +0200)] 
[gdb/testsuite] Make Term::wait_for "" match only a prompt

The semantics of Term::wait_for is:
...
    # Accept some output from gdb and update the screen.  WAIT_FOR is
    # a regexp matching the line to wait for.  Return 0 on timeout, 1
    # on success.
    proc wait_for {wait_for} {
...

Note that besides the regexp, also a subsequent gdb prompt is matched.

I recently used wait_for "" in a few test-cases, thinking that this would
match just a prompt, but in fact that's not the case.

Fix this in wait_for, and add a corresponding test in gdb.tui/tuiterm-2.exp.

Tested on x86_64-linux.

10 months agoPrune linker warnings about an executable stack being created with the -z execstack...
Nick Clifton [Wed, 21 Jun 2023 11:10:03 +0000 (12:10 +0100)] 
Prune linker warnings about an executable stack being created with the -z execstack option.

  * testsuite/lib/binutils-common.exp (prune_warnings_extra): Prune warnings about -z execstack creating an executable stack.

10 months agoFor test for PR 29072 when the linker is configured with --enable-default-execstack=no.
Nick Clifton [Wed, 21 Jun 2023 10:47:19 +0000 (11:47 +0100)] 
For test for PR 29072 when the linker is configured with --enable-default-execstack=no.

  PR 29072
  * testsuite/ld-elf/elf.exp (target_defaults_to_execstack): Always return false for linkers configured with the --enable-default-execstack=no option.

10 months agogdbserver: use target_waitstatus::to_string in 'prepare_resume_reply'
Tankut Baris Aktemur [Wed, 21 Jun 2023 06:47:01 +0000 (08:47 +0200)] 
gdbserver: use target_waitstatus::to_string in 'prepare_resume_reply'

Use the to_string method of target_waitstatus in
'prepare_resume_reply' for a more readable log message.

Approved-By: Tom Tromey <tom@tromey.com>
10 months agox86: fix expansion of %XV
Jan Beulich [Wed, 21 Jun 2023 06:32:13 +0000 (08:32 +0200)] 
x86: fix expansion of %XV

Only %LV should continue on to S handling; avoid emitting a stray 'l'
(typically) in suffix-always mode.

10 months agoelf32_arm_get_synthetic_symtab memory leak
Alan Modra [Wed, 21 Jun 2023 05:03:59 +0000 (14:33 +0930)] 
elf32_arm_get_synthetic_symtab memory leak

ARM get_synthetic_symtab reads .plt and caches that data.  Caching the
data doesn't make a lot of sense since get_synthetic_symtab is only
called once per bfd, and the memory might be put to better use.  It
also leaks on closing the bfd.

* elf32-arm.c (elf32_arm_get_synthetic_symtab): Don't cache
plt contents.  Free plt data before returning.

10 months agomacho-o.c don't leak strtab
Alan Modra [Tue, 20 Jun 2023 23:51:54 +0000 (09:21 +0930)] 
macho-o.c don't leak strtab

* mach-o.c (bfd_mach_o_write_symtab_content): Free strtab on
success path.

10 months agoAutomatic date update in version.in
GDB Administrator [Wed, 21 Jun 2023 00:00:16 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agoUse ARRAY_SIZE in ax-general.c
Tom Tromey [Tue, 20 Jun 2023 17:11:06 +0000 (11:11 -0600)] 
Use ARRAY_SIZE in ax-general.c

This changes a couple of spots in ax-general.c to use ARRAY_SIZE.
While making this change, I noticed that one of the bounds checks was
incorrect.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
10 months agoRemove aop_last
Tom Tromey [Tue, 20 Jun 2023 17:09:18 +0000 (11:09 -0600)] 
Remove aop_last

aop_last is only used for an assertion.  However, due to the '.def'
construct in the sources, this assert could never plausibly trigger
(the assert predates the use of a .def file here).  This patch removes
the constant and the assert.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
10 months agoMake aop_map 'static'
Tom Tromey [Mon, 19 Jun 2023 20:44:43 +0000 (14:44 -0600)] 
Make aop_map 'static'

This changes aop_map to be 'static'.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
10 months agoUse bool for agent_expr::tracing
Tom Tromey [Sat, 17 Jun 2023 18:56:54 +0000 (12:56 -0600)] 
Use bool for agent_expr::tracing

This changese agent_expr::tracing to have type bool, allowing inline
initialization and cleaning up the code a little.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>