]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
3 weeks agogas standardise md_section_align
Alan Modra [Tue, 8 Jul 2025 23:43:14 +0000 (09:13 +0930)] 
gas standardise md_section_align

The point here is that when valueT is 64 bits and int is 32 bits,
1 << align doesn't work for shifts larger than the size of int.  (Not
that anyone is likely to use such large alignments in real code.)

3 weeks agogas function arg casts
Alan Modra [Tue, 8 Jul 2025 23:42:53 +0000 (09:12 +0930)] 
gas function arg casts

This patch removes more unnecessary arg casts in various function
calls.

3 weeks agogas fixups
Alan Modra [Tue, 8 Jul 2025 23:42:45 +0000 (09:12 +0930)] 
gas fixups

Remove unnecessary arg casts in fix_new and similar calls.

3 weeks agogas char/unsigned char casts
Alan Modra [Tue, 8 Jul 2025 23:42:20 +0000 (09:12 +0930)] 
gas char/unsigned char casts

This patch removes many unneeded casts to char or unsigned char.  It's
worth noting that safe-ctype.h macros ISDIGIT and the like cope with
either signed or unsigned char.
In some cases a cast to unsigned char is replaced by anding with 0xff,
which accomplishes the same thing but doesn't rely on char being eight
bits.  The patch also removes pointer casts, and a few unsigned char
pointer variables.

3 weeks agogas alpha sign extension macros
Alan Modra [Tue, 8 Jul 2025 23:39:23 +0000 (09:09 +0930)] 
gas alpha sign extension macros

Use standard sign extend and range checking using unsigned
expressions that don't rely on implementation defined right shifts or
size of short and int.

3 weeks agogas md_number_to_chars
Alan Modra [Tue, 8 Jul 2025 23:35:12 +0000 (09:05 +0930)] 
gas md_number_to_chars

Calls to md_number_to_chars don't need to cast their value arg (*).
Remove those casts.  avr_output_property_recode made a call to
md_number_to_chars with size of 1.  Simplify that.  tc-bpf.c
md_convert_frag used write_insn_bytes that simply copied input to
output.  Dispense with that nonsense, and similarly in a couple of
other places where md_number_to_chars was called with size 1.

*) unless the value arg is an expression that needs a cast, eg. tic54x
   emit_insn where the shift left could trigger signed overflow UB
   without a cast.

3 weeks agoz8k opcode_entry_type
Alan Modra [Tue, 8 Jul 2025 23:34:47 +0000 (09:04 +0930)] 
z8k opcode_entry_type

z8k opcode_entry_type.func is never used as a function pointer, only
as a pointer to a pseudo_typeS.  Change it to a void*.

3 weeks agogas various other void* casts
Alan Modra [Tue, 8 Jul 2025 23:33:45 +0000 (09:03 +0930)] 
gas various other void* casts

This removes assorted unneeded casts of void* pointers, and casts when
passing args to void* parameters or storing to void* pointers.  The
patch also changes obj-coff.c stack_push to take a void* parameter,
and replaces an odd memcpy in tc-metag.c find_insn_templates with a
simple assignment.

3 weeks agogas various other const pointer changes
Alan Modra [Tue, 8 Jul 2025 23:33:08 +0000 (09:03 +0930)] 
gas various other const pointer changes

This removes a bunch of casts involving const pointers, in some cases
by making variables const pointers so a cast is not needed.  In a
couple of places the cast hid errors with "&array" written rather than
"array", see iq2000_macro_defs and s_pru_align.  tc-xgate.c cmp_opcode
is changed to be the standard qsort predicate to avoid a function
cast.

3 weeks agogas d30v_insn plus other non-const pointers
Alan Modra [Tue, 8 Jul 2025 23:32:43 +0000 (09:02 +0930)] 
gas d30v_insn plus other non-const pointers

d30v has a bunch of casts that are only needed due to various types
missing a const.  Fix that.

3 weeks agogas alloc casts
Alan Modra [Tue, 8 Jul 2025 23:32:28 +0000 (09:02 +0930)] 
gas alloc casts

All of the various memory allocation function return a "void *"
pointer, which needs no cast to assign to other pointer types.

3 weeks agogas bfd_put and bfd_get arg casts
Alan Modra [Tue, 8 Jul 2025 23:32:05 +0000 (09:02 +0930)] 
gas bfd_put and bfd_get arg casts

bfd_{h_,}put_* and bfd_{h_,}get_* have "void *" pointer params
nowadays.  We don't need casts on their pointer args.  We also don't
need to cast values passed to bfd_put.

3 weeks agogas NULL casts
Alan Modra [Tue, 8 Jul 2025 23:29:10 +0000 (08:59 +0930)] 
gas NULL casts

This removes many unnecessary NULL casts.  I'm also adding a few arg
casts in concat calls, to make the code consistent.  Advice from quite
a few years ago was that it's better to use the exact type for args
corresponding to function ellipses, in case NULL is defined as plain
0.  (I think that happened with some early 64-bit systems.  Plain NULL
ought to be OK nowadays.)

3 weeks agogas s3_FAIL and s7_FAIL
Alan Modra [Tue, 8 Jul 2025 23:28:52 +0000 (08:58 +0930)] 
gas s3_FAIL and s7_FAIL

s3_FAIL is defined as 0x80000000 which is unsigned, but everywhere it
is used it is cast to int.  Get rid of that silliness, and likewise
for s7_FAIL.

3 weeks agogas more enum casts
Alan Modra [Tue, 8 Jul 2025 23:28:31 +0000 (08:58 +0930)] 
gas more enum casts

Remove more unnecessary enum casts.

3 weeks agogas bfd_reloc_code_real_type
Alan Modra [Tue, 8 Jul 2025 23:28:11 +0000 (08:58 +0930)] 
gas bfd_reloc_code_real_type

Enumeration constants are integer types, so there should be no need to
cast such constants to int in expressions.  (Perhaps some older gccs
warned, I checked back to gcc-4.5.)  Remove some of those unnecessary
casts.  Also remove unnecessary casts to bfd_reloc_code_real_type.

3 weeks agogas add_ecoff_symbol
Alan Modra [Tue, 8 Jul 2025 23:27:49 +0000 (08:57 +0930)] 
gas add_ecoff_symbol

* ecoff.c: Remove unnecessary arg casts in add_ecoff_symbol
calls throughout file.

3 weeks agogas frag_var
Alan Modra [Tue, 8 Jul 2025 23:24:56 +0000 (08:54 +0930)] 
gas frag_var

Many frag_var calls have unnecessary casts on arguments, no doubt from
the days when binutils was written for K&R C.  (ie. functions were not
prototyped so you needed to cast anything that didn't match the
expected type after default promotions, as you still do for args
matching a function ellipsis.)  Remove those casts.

* config/tc-alpha.c (s_alpha_comm): Use offset_T for cur_size
to avoid need for casts.  Remove casts from frag_var args.
* config/tc-ia64.c (obj_elf_vms_common): Remove casts from
frag_var args.
* config/tc-m32r.c (m32r_scomm): Likewise.
* config/tc-m68hc11.c (build_jump_insn): Likewise.
(build_dbranch_insn): Likewise.
* config/tc-m68k.c (md_assemble): Likewise.
* config/tc-microblaze.c (microblaze_s_lcomm): Likewise.
* config/tc-mmix.c (s_loc): Likewise.
* config/tc-ppc.c (ppc_elf_lcomm, ppc_comm): Likewise.
* config/tc-score.c (s3_s_score_lcomm): Likewise.
* config/tc-score7.c (s7_s_score_lcomm): Likewise.
* config/tc-sh.c (sh_cons_align): Likewise.
* config/tc-sparc.c (s_reserve, s_common): Likewise.
(sparc_cons_align): Likewise.
* config/tc-tic4x.c (tic4x_seg_alloc, tic4x_bss): Likewise.
* config/tc-tic54x.c (tic54x_bss, tic54x_space): Likewise.
(tic54x_usect, tic54x_field): Likewise.
* config/tc-tic6x.c (s_tic6x_scomm): Likewise.
* config/tc-v850.c (v850_offset, v850_comm): Likewise.
* frags.c (frag_align, frag_align_pattern, frag_align_code): Likewise.
* gen-sframe.c (output_sframe_row_entry): Likewise.
(output_sframe_funcdesc): Likewise.
* read.c (s_fill, do_org, s_space, emit_leb128_expr): Likewise.
* symbols.c (colon)): Likewise.

3 weeks agogas pointer to int and vice versa
Alan Modra [Tue, 8 Jul 2025 23:24:24 +0000 (08:54 +0930)] 
gas pointer to int and vice versa

Use "intptr_t" or "uintptr_t" for these conversions, not "long" which
is wrong on LLP64 systems, or "size_t" which is better but still not
the correct type.

* config/tc-alpha.c (emit_ldXu, emit_ldX, emit_uldXu, emit_uldX),
(emit_stX, emit_ustX, emit_sextX): Use correct type when
converting vlgsize pointer to in.  Use "int" rather than
"long" for result.
* config/tc-ia64.c (generate_unwind_image): Use intptr_t cast
when passing personality_routine to frag_var.
* config/tc-ppc.c (ppc_frob_symbol <coff>): Use uintptr_t cast
when converting symbol pointer to valueT.
* config/tc-v850.c (md_assemble): Use intptr_t cast when
loading integer opindex.

3 weeks agoAutomatic date update in version.in
GDB Administrator [Wed, 9 Jul 2025 00:01:27 +0000 (00:01 +0000)] 
Automatic date update in version.in

3 weeks agoaarch64: Add support for FEAT_SVE2p2 and FEAT_SME2p2
Alice Carlotti [Tue, 3 Jun 2025 19:35:34 +0000 (20:35 +0100)] 
aarch64: Add support for FEAT_SVE2p2 and FEAT_SME2p2

3 weeks agoaarch64: Reorder virtual feature dependencies
Alice Carlotti [Tue, 8 Jul 2025 19:43:37 +0000 (20:43 +0100)] 
aarch64: Reorder virtual feature dependencies

This will improve readability when more combinations of "SVE* or SME*"
are added.

3 weeks agogdb/reverse: Add 2 AVX instructions VADDSUBPS and VADDSUBPD
First Last [Tue, 10 Jun 2025 13:34:50 +0000 (19:04 +0530)] 
gdb/reverse: Add 2 AVX instructions VADDSUBPS and VADDSUBPD

add support to recording 2 missing AVX instructions: vaddsubps and vaddsubpd, and add associated tests.

Approved-By: Guinevere Larsen <guinevere@redhat.com>
3 weeks agogprofng: support external debug info
Vladimir Mezentsev [Mon, 7 Jul 2025 18:56:22 +0000 (11:56 -0700)] 
gprofng: support external debug info

Use bfd_follow_gnu_debuglink() and bfd_follow_gnu_debugaltlink() to find files
with debug info.
If necessary, gprofng-archive copies these files to EXP/archives.

For each executable, gprofng creates the Elf class twice.
One of them was a memory leak.
Fixed this by adding a new argument to Stabs::Stabs().

gprofng/ChangeLog
2025-07-07  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR 32147
PR 30194
* src/Disasm.cc (get_funcname_in_plt): Use the executable file instead
of the debug information file.
* src/Dwarf.h: Define debug_alt_strSec.
* src/DwarfLib.cc: Add support for DW_FORM_GNU_ref_alt,
DW_FORM_GNU_strp_alt.
* src/Elf.h (find_gnu_debug_files, get_dwr_section): New functions.
* src/Elf.cc: Likewise.
* src/Experiment.cc (copy_file): Add the const qualifier.
* src/Experiment.h: Likewise.
* src/LoadObject.cc (get_elf, openDebugInfo): Find files with debug info.
* src/LoadObject.h: Remove unused variables.
* src/Module.cc: Remove an argument in openDebugInfo().
* src/Stabs.cc (Stabs::Stabs): Add the Elf* argument.
* src/Stabs.h: Likewise.
* src/gp-archive.cc: Archive files with debug info.
* src/gp-archive.h (archive_file): New function.

3 weeks agoFix wchar.exp test case per review
Tom Tromey [Tue, 8 Jul 2025 14:52:59 +0000 (08:52 -0600)] 
Fix wchar.exp test case per review

A recent patch of mine modified wchar.exp, but I failed to notice one
part of the review.  This patch updates the code to conform to the
review comments.

3 weeks agoNew Malay translation for bfd/ and new Spanish translation for gas/
Nick Clifton [Tue, 8 Jul 2025 12:27:56 +0000 (13:27 +0100)] 
New Malay translation for bfd/ and new Spanish translation for gas/

3 weeks agoRISC-V: Fix libpath_suffix selection for ldscript
Mark Goncharov [Tue, 1 Jul 2025 05:57:51 +0000 (08:57 +0300)] 
RISC-V: Fix libpath_suffix selection for ldscript

When building a cross-compiler ld for RISC-V Linux systems, you can specify
target=riscv64*-linux* to create a linker that supports both 32-bit
(-march=rv32*) and 64-bit (-march=rv64*) architectures.  The specified -march
value populates the EMULATION_NAME variable, which determines the default
linker script selection.  For proper riscv64 target support, the build process
must prepare both elf32lriscv* and elf64lriscv* linker scripts.  These should
align with the standard RISC-V Linux sysroot directory structure.

Signed-off-by: Mark Goncharov <mark.goncharov@syntacore.com>
3 weeks agoRISC-V: Fixed mapping symbol for .option norvc directive
Nelson Chu [Tue, 8 Jul 2025 09:07:24 +0000 (17:07 +0800)] 
RISC-V: Fixed mapping symbol for .option norvc directive

3 weeks agoRISC-V: Fixed dis-assembler to set correct xlen from mapping symbol
Nelson Chu [Fri, 4 Jul 2025 05:42:38 +0000 (13:42 +0800)] 
RISC-V: Fixed dis-assembler to set correct xlen from mapping symbol

3 weeks agoRISC-V: Fixed that .option push/pop won't recover the xlen
Nelson Chu [Fri, 4 Jul 2025 05:42:37 +0000 (13:42 +0800)] 
RISC-V: Fixed that .option push/pop won't recover the xlen

3 weeks agoRISC-V: Added testcase to show the current rvc and xlen problems
Nelson Chu [Fri, 4 Jul 2025 05:42:36 +0000 (13:42 +0800)] 
RISC-V: Added testcase to show the current rvc and xlen problems

3 weeks agoRISC-V: Bind defined symbol locally in PIE
Linsen Zhou [Mon, 7 Jul 2025 22:34:18 +0000 (06:34 +0800)] 
RISC-V: Bind defined symbol locally in PIE

Reference commit 1dcb9720d62cd053a72c31881b7724ce9f74332c

bfd/
* elfnn-riscv.c (RISCV_COPY_INPUT_RELOC): Bind defined symbol
locally in PIE.

ld/
* testsuite/ld-riscv-elf/pie-bind-locally-a.s: New test source.
* testsuite/ld-riscv-elf/pie-bind-locally-b.s: Likewise.
* testsuite/ld-riscv-elf/pie-bind-locally-rv32.d: New testcase.
* testsuite/ld-riscv-elf/pie-bind-locally-rv64.d: Likewise.

Signed-off-by: Linsen Zhou <i@lin.moe>
3 weeks agoAutomatic date update in version.in
GDB Administrator [Tue, 8 Jul 2025 00:01:25 +0000 (00:01 +0000)] 
Automatic date update in version.in

3 weeks agogprofng: remove ElfReloc class and unused functions and declarations
Vladimir Mezentsev [Fri, 4 Jul 2025 21:49:18 +0000 (14:49 -0700)] 
gprofng: remove ElfReloc class and unused functions and declarations

class ElfReloc is not used after we started use libbfd.
Removed ElfReloc and other unused declarations.

gprofng/ChangeLog
2025-07-03  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* src/Disasm.cc: Remove unused functions and variables.
* src/Disasm.h: Likewise.
* src/Dwarf.cc: Likewise.
* src/DwarfLib.cc: Likewise.
* src/DwarfLib.h: Likewise.
* src/Elf.cc: Likewise.
* src/Elf.h: Likewise.
* src/Stabs.cc: Likewise.
* src/Stabs.h: Likewise.

3 weeks agoCorrectly handle L'\\'
Tom Tromey [Thu, 3 Jul 2025 18:35:11 +0000 (12:35 -0600)] 
Correctly handle L'\\'

Hannes filed a bug that pointed out that:

    print L'\\'

... did not work correctly.  The bug is in convert_escape, which
simply transcribes the backslash character, rather than convert it
between encodings.

This patch fixes the error.  I also turned a macro into a lambda to
clean up this code a little.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33124
Reviewed-By: Tom de Vries <tdevries@suse.de>
Tested-By: Hannes Domani <ssbssa@yahoo.de>
3 weeks agoLoongArch: Allow to relax instructions into NOPs after handling alignment
WANG Xuerui [Sun, 6 Jul 2025 01:06:20 +0000 (09:06 +0800)] 
LoongArch: Allow to relax instructions into NOPs after handling alignment

Right now, LoongArch linker relaxation is 2-pass, since after alignment
is done, byte deletion can no longer happen. However, as the alignment
pass also shrinks text sections, new relaxation chances may well be
created after alignment is done. Although at this point we can no longer
delete unused instructions without disturbing alignment, we can still
replace them with NOPs; popular LoongArch micro-architectures can
eliminate NOPs during execution, so we can expect a (very) slight
performance improvement from those late-created relaxation chances.

To achieve this, the number of relax passes is raised to 3 for
LoongArch, and every relaxation handler except loongarch_relax_align is
migrated to a new helper loongarch_relax_delete_or_nop, that either
deletes bytes or fills the bytes to be "deleted" with NOPs, depending on
whether the containing section already has undergone alignment. Also,
since no byte can be deleted during this relax pass, in the pass the
pending_delete_ops structure is no longer allocated, and
loongarch_calc_relaxed_addr(x) degrades to the trivial "return x" in
this case.

In addition, previously when calculating distances to symbols, an
extra segment alignment must be considered, because alignment may
increase distance between sites. However in the newly added 3rd pass
code size can no longer increase for "closed" sections, so we can skip
the adjustment for them to allow for a few more relaxation chances.

A simple way to roughly measure this change's effectiveness is to check
how many pcalau12i + addi.d pairs are relaxed into pcaddi's. Taking a
Firefox 140.0.2 test build of mine as an example:

Before: 47842 pcaddi's in libxul.so
After: 48089

This is a 0.5% increase, which is kind of acceptable for a peephole
optimization like this; of which 9 are due to the "relax"ed symbol
distance treatment.

Signed-off-by: WANG Xuerui <git@xen0n.name>
3 weeks agoAutomatic date update in version.in
GDB Administrator [Mon, 7 Jul 2025 00:01:07 +0000 (00:01 +0000)] 
Automatic date update in version.in

3 weeks agold: bfd: sframe: Update section size also for relocatable links
Jens Remus [Sun, 6 Jul 2025 19:47:43 +0000 (12:47 -0700)] 
ld: bfd: sframe: Update section size also for relocatable links

For relocatable links the output .sframe section size may be wrong.
This can be observed when dumping the SFrame information from the x86-64
sframe-reloc-1 test:

Name              Address          Off    Size
.sframe           0000000000000000 000110 00007f

Offset            Type               Symbol's Value  Symbol's Name + Addend
000000000000001c  R_X86_64_PC32      0000000000000000 .text + 1c
0000000000000030  R_X86_64_PC32      0000000000000000 .text + 65

0x00000000 e2de0201 0300f800 02000000 08000000 ................
0x00000010 1e000000 00000000 28000000 00000000 ........(.......
0x00000020 35000000 00000000 04000000 00000000 5...............
0x00000030 00000000 25000000 0f000000 04000000 ....%...........
            offset 1st FRE---^^^^^^^^ ^^^^^^^^---number of FREs
0x00000040 00000000 00030801 0510f004 0410f034 ...............4
FDE info---^^      | begin of FDEs
0x00000050 0508f000 03080105 10f00404 10f02405 ..............$.
                 11111112222222223333333334444---FRE 1, 2, 3, 4
0x00000060 08f00000 00000000 00000000 00000000 ................
           4444^^^^...
0x00000070 00000000 00000000 00000000 000000   ...............
                                   ...^^^^^^---excessive section

When running the x86-64 test cross build on a big-endian system, such
as s390x, objdump and readelf fail to dump the SFrame information with
the following error message:

Error: SFrame decode failure: Buffer does not contain SFrame data.

This is because the following check in flip_sframe() fails, which gets
only invoked if the endianness of the SFrame data is different from the
host system one:

/* All FDEs and FREs must have been endian flipped by now.  */
if ((j != ihp->sfh_num_fres) || (bytes_flipped != (buf_size - hdrsz)))
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

With:
j=8, ihp->sfh_num_fres=8, bytes_flipped=70, buf_size=127, hdrsz=28

While at it, remove the incorrect code comment.  There is no
relationship between "do not update size" and the fact that the
"contents have not been relocated".

bfd/
* elf-sframe.c (_bfd_elf_write_section_sframe): Update section
size also for relocatable links.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
3 weeks agoNEWS: sframe: mention new semantics for SFrame FDE function start addr
Indu Bhagat [Sun, 6 Jul 2025 19:47:31 +0000 (12:47 -0700)] 
NEWS: sframe: mention new semantics for SFrame FDE function start addr

The SFrame FDE's function start address is always emitted as follows by
GAS and ld:  it is the offset of the start PC of the respective function
from the FDE field itself.

GAS and ld will emit a flag SFRAME_F_FDE_FUNC_START_PCREL set to 1
when emitting the field in this encoding.

* binutils/NEWS: Announce the change of encoding for SFrame FDE
  func start addr field.
        * gas/NEWS: Announce the emission of new flag
  SFRAME_F_FDE_FUNC_START_PCREL.
        * ld/NEWS: Likewise.  Relocatable links are now fixed.

3 weeks agold: bfd: sframe: fix incorrect r_offset in RELA entries
Indu Bhagat [Sun, 6 Jul 2025 19:47:18 +0000 (12:47 -0700)] 
ld: bfd: sframe: fix incorrect r_offset in RELA entries

PR/32666  Incorrect .rela.sframe when using ld -r

Input SFrame sections are merged using _bfd_elf_merge_section_sframe (),
which clubs all SFrame FDEs together in one blob and all SFrame FREs in
another.  This, of course, means the offset of an SFrame FDE in the output
section cannot be simply derived from the output_offset of the sections.

Fix this by providing _bfd_elf_sframe_section_offset () which returns
the new offset of the SFrame FDE in the merged SFrame section.

Unlike EH_Frame sections, which also use the _bfd_elf_section_offset (),
to update the r_offset, SFrame sections have distinct merging semantics.
In case of SFrame, the SFrame FDE will not simply sit at location
"sec->output_offset + offset of SFrame FDE in sec".  Recall that information
layout in an SFrame section is as follows:
   SFrame Header
   SFrame FDE 1
   SFrame FDE 2
   ...
   SFrame FDEn
   SFrame FREs (Frame Row Entries)
Note how the SFrame FDEs and SFrame FREs are clubber together in groups
of their own.

Next, also note how the elf_link_input_bfd () does a:
            irela->r_offset += o->output_offset;
This, however, needs to be avoided for SFrame sections because the
placement of all FDEs is at the beginning of the section.  So, rather than
conditionalizing this as follows:
          if (o->sec_info_type != SEC_INFO_TYPE_SFRAME)
            irela->r_offset += o->output_offset;
the implementation in _bfd_elf_sframe_section_offset () does a reverse
adjustment, so that the generic parts of the linking process in
elf_link_input_bfd () are not made to do SFrame specific adjustments.

Add a new enum to track the current state of the SFrame input section
during the linking process (SFRAME_SEC_DECODED, SFRAME_SEC_MERGED) for
each input SFrame section.  This is then used to assert an assumption
that _bfd_elf_sframe_section_offset () is being used on an input SFrame
sections which have not been merged (via
_bfd_elf_merge_section_sframe ()) yet.

bfd/
        * elf-bfd.h: New declaration.
        * elf-sframe.c (_bfd_elf_sframe_section_offset): New definition.
        * elf.c (_bfd_elf_section_offset): Adjust offset if SFrame
section.
ld/testsuite/
        * ld-x86-64/x86-64.exp: New test.
        * ld-x86-64/sframe-reloc-1.d: New test.

3 weeks agobfd: gas: ld: libsframe: adopt new encoding for FDE func start addr field
Indu Bhagat [Sun, 6 Jul 2025 19:47:05 +0000 (12:47 -0700)] 
bfd: gas: ld: libsframe: adopt new encoding for FDE func start addr field

This patch convenes a set of changes in bfd, gas, ld, libsframe towards
moving to the new encoding for the 'sfde_func_start_address' field in
SFrame FDE.

First, gas must now mark all SFrame sections with the new flag
SFRAME_F_FDE_FUNC_START_PCREL.  gas was already emitting the field
in the said encoding.

* gas/gen-sframe.c (output_sframe_internal): Emit the flag
SFRAME_F_FDE_FUNC_START_PCREL.

Similarly for ld, adopt the new semantics of sfde_func_start_address
consistently.  This means:
  - When merging SFrame sections, check that all input SFrame sections
    have the SFRAME_F_FDE_FUNC_START_PCREL flag set.  If the check
    fails, ld errors out.
  - When merging SFrame sections, keep even the in-memory contents of
    the FDE function start address (buffer passed to libsframe
    sframe_encoder_write () for writing out) encoded in the new
    semantics.  While it is, in theory, possible that instead of doing this
    change here, we adjust the value of sfde_func_start_address at the final
    write (sframe_encoder_write) time.  But latter is not favorable for
    maintenanance and may be generally confusing for developers.
  - When creating SFrame for PLT entries, emit flag
    SFRAME_F_FDE_FUNC_START_PCREL.

include/
        * sframe-api.h (SFRAME_F_LD_MUSTHAVE_FLAGS): New definition.
bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe): Check for flag
combinatation SFRAME_F_LD_MUSTHAVE_FLAGS set for all input and
output SFrame sections.  If not, error out.  Also, adopt the new
        semantics of function start address encoding.
* bfd/elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Emit flag
SFRAME_F_FDE_FUNC_START_PCREL.

Next, for dumping SFrame sections, now that we are emitting the same
encoding in GAS, non-relocatable and relocatable SFrame links, it is the
time to set relocate to TRUE in debug_displays[].

binutils/
* dwarf.c (struct dwarf_section_display): Allow sframe sections
  to now be relocated.
gas/testsuite/
* gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.d: Update the
test.  Relocatable SFrame sections now display non-zero value
(appropriate function start address).

Now, as the SFrame sections on-disk and in-memory use the new semantics of
sfde_func_start_address encoding (i.e., function start address is the
offset from the sfde_func_start_address field to the start PC), the
calculation to make it human readable (i.e., relatable to the addresses
in .text sections) needs adjustment.

libsframe/
* sframe-dump.c (dump_sframe_func_with_fres): Adjust the
function start address for dumping.

Now that both the emission of the new encoding, and the relocation of
sections before dumping them is in place, it is time to adjust the
testcases.

gas/testsuite/
* gas/cfi-sframe/cfi-sframe-aarch64-1.d: Update expected output
to include SFRAME_F_FDE_FUNC_START_PCREL instead of NONE.
* gas/cfi-sframe/cfi-sframe-aarch64-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe-aarch64-3.d: Likewise.
* gas/cfi-sframe/cfi-sframe-aarch64-4.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-1.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-10.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-11.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-common-9.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-1.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-1.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-3.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-4.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.
* gas/scfi/x86_64/scfi-cfi-sections-1.d: Likewise.
* gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise.
ld/testsuite/
* ld-aarch64/sframe-simple-1.d: Update expected output to
include SFRAME_F_FDE_FUNC_START_PCREL.
* ld-x86-64/sframe-ibt-plt-1.d: Likewise.
* ld-x86-64/sframe-plt-1.d: Likewise.
* ld-x86-64/sframe-pltgot-1.d: Likewise.
* ld-x86-64/sframe-pltgot-2.d: Likewise.
* ld-x86-64/sframe-simple-1.d: Likewise.

Naturally, the change of semantics for 'SFrame FDE function start address'
has consequences on the implementation in libsframe.  As per the new
semantics:
  - Function start address in the SFrame FDE (sfde_func_start_address)
    is an offset from the FDE function start address field to the start
    PC of the associated function.

Note that, the libsframe library brings the SFrame section contents into
its own memory to create a sframe_decoder_ctx object via sframe_decode
().  Many internal and user-interfacing APIs then may use
sframe_decoder_ctx object to interact and fulfill the work.

In context of changing semantics for sfde_func_start_address, following
relevant examples may help understand the impact:
  - sframe_find_fre () finds a the SFrame stack trace data (SFrame FRE)
    given a lookup offset (offset of lookup_pc from the start of SFrame
    section).  Now that the sfde_func_start_address includes the
    distance from the sfde_func_start_address field to the start of
    SFrame section itself, the comparison checks of
    sfde_func_start_address with the incoming lookup offset need
    adjustment.
  - Some internal functions (sframe_get_funcdesc_with_addr_internal ()
    finds SFrame FDE by using binary seach comparing
    sfde_func_start_address fields, etc.) need adjustments.
  - sframe_encoder_write () sorts the SFrame FDEs before writing out
    the SFrame data.  Sorting of SFrame FDE via the internal function
    sframe_sort_funcdesc() needs adjustments: the new encoding of
    sfde_func_start_address means the distances are not from the same
    anchor, so cannot be sorted directly.

This patch takes the approach of adding a new internal function:
  - sframe_decoder_get_secrel_func_start_addr (): This function returns
    the offset of the start PC of the function from the start of SFrame
    section, i.e., it gives a section-relative offset.

As the sframe_decoder_get_secrel_func_start_addr () API needs the value
of the function index in the FDE list, another internal API needs
sframe_fre_check_range_p () adjustments too.

Sorting the FDEs (via sframe_sort_funcdesc ()) is done by first bringing
all offsets in sfde_func_start_address relative to start of SFrame
section, followed by sorting, and then readjusting the offsets accroding
to the new position in the FDE list.

libsframe/
* sframe.c (sframe_decoder_get_secrel_func_start_addr): New
static function.
        (sframe_fre_check_range_p): Adjust the interface a bit.
(sframe_get_funcdesc_with_addr_internal): Use
sframe_decoder_get_secrel_func_start_addr () when comparing
sfde_func_start_address with user input offset.
        (sframe_find_fre): Adopt the new semantics.
        (sframe_sort_funcdesc): Likewise.

For the libsframe testsuite, use the new encoding for FDE func start
addr: distance between the FDE sfde_func_start_address field and the
start PC of the function itself.

Use SFRAME_F_FDE_FUNC_START_PCREL flag, though the sframe_encode ()
interface in libsframe applies no sanity checks for the encoding itself.

libsframe/testsuite/
* libsframe.find/findfre-1.c: Adjust to use the new
SFRAME_F_FDE_FUNC_START_PCREL specific encoding.
* libsframe.find/findfunc-1.c: Likewise.
* libsframe.find/plt-findfre-1.c: Likewise.
* libsframe/testsuite/libsframe.decode/DATA2: Update data file
due to usage of new SFRAME_F_FDE_FUNC_START_PCREL flag.
* libsframe/testsuite/libsframe.encode/encode-1.c: Use flag
SFRAME_F_FDE_FUNC_START_PCREL.

3 weeks agoobjdump, readelf: sframe: apply relocations before textual dump
Indu Bhagat [Sun, 6 Jul 2025 19:46:53 +0000 (12:46 -0700)] 
objdump, readelf: sframe: apply relocations before textual dump

PR libsframe/32589 - function start address is zero in SFrame section dump

Currently, readelf and objdump display the SFrame sections in ET_REL
object files with function start addresses of each function as 0.  This
makes it difficult to correlate SFrame stack trace information with the
individual functions in the object file.

For objdump, use the dump_dwarf () interface to dump SFrame section.
Similarly, for readelf, use the display_debug_section () interface to
dump SFrame section.  These existing interfaces (for DWARF debug
sections) already support relocating the section contents before
dumping, so lets use them for SFrame sections as well.

When adding a new entry for SFrame in debug_option_table[], use char
'nil' and the option name of "sframe-internal-only".  This is done so
that there is no additional (unnecessary) user-exposed ways of dumping
SFrame sections.  Additionally, we explicitly disallow the
"sframe-internal-only" from external/user input in --dwarf (objdump).
Similarly, "sframe-internal-only" is explicitly matched and disallowed
from --debug-dump (readelf).

For objdump and readelf, we continue to keep the same error messaging as
earlier:

  $ objdump --sframe=sframe bubble_sort.o
  ...
  No sframe section present

  $ objdump --sframe=.sfram bubble_sort.o
  ...
  No .sfram section present

  $ objdump --sframe=sframe-internal-only sort
  ...
  No sframe-internal-only section present

Similarly for readelf:

  $ readelf --sframe= bubble_sort.o
  readelf: Error: Section name must be provided
  $ readelf --sframe=.sfram bubble_sort.o
  readelf: Warning: Section '.sfram' was not dumped because it does not exist
  $ readelf --sframe=sframe bubble_sort.o
  readelf: Warning: Section 'sframe' was not dumped because it does not exist

PS: Note how this patch adds a new entry to debug_displays[] with a
    relocate value set to FALSE.  This will be set to TRUE in a subsequent
    patch ("bfd: gas: ld: libsframe: emit func start addr field as an offset
    from FDE") when fixes are made to emit the value of the
    'sfde_func_start_address' field in the new encoding
    SFRAME_F_FDE_FUNC_START_PCREL across gas and ld.

binutils/
* dwarf.c (display_sframe): New definition.
(dwarf_select_sections_all): Enable SFrame section too.
(struct dwarf_section_display): Add entry for SFrame section.
* dwarf.h (enum dwarf_section_display_enum): Add enumerator for
SFrame.
* objdump.c (dump_section_sframe): Remove.
(dump_sframe_section): Add new definition.
(dump_bfd): Use dump_sframe_section.
* binutils/readelf.c (dump_section_as_sframe): Remove.

3 weeks agoinclude: sframe: doc: define new flag SFRAME_F_FDE_FUNC_START_PCREL
Indu Bhagat [Sun, 6 Jul 2025 19:46:43 +0000 (12:46 -0700)] 
include: sframe: doc: define new flag SFRAME_F_FDE_FUNC_START_PCREL

Add a new flag SFRAME_F_FDE_FUNC_START_PCREL to SFrame stack trace
format.  If set, this flag indicates that the function start address
field (sfde_func_start_address) is the offset to the function start
address from the SFrame FDE function start address field itself.

Such an encoding is friendlier to the exisitng PC-REL relocations
available in the ABIs supported in SFrame: AMD64 (R_X86_64_PC32) and
AArch64 (R_AARCH64_PREL32).  In subsequent patches, we will make the
implementation in gas and ld to both:
  - emit the values in the same (above-mentioned) encoding uniformly.
  - set the flag SFRAME_F_FDE_FUNC_START_PCREL in the SFrame header
    for consumers to be able to distinguish.

Define SFRAME_V2_F_ALL_FLAGS in sframe.h to help keep the implementation
less error-prone by keeping a set of all defined flags at a central
place.  Adjust the check in sframe_header_sanity_check_p () to use the
SFRAME_V2_F_ALL_FLAGS instead.

Add documentation for SFRAME_F_FDE_FUNC_START_PCREL.  Update the
documentation about the encoding of the sfde_func_start_address field.

Also, update the section "Changes from Version 1 to Version 2" to
include the specification of the new flag SFRAME_F_FDE_FUNC_START_PCREL
as an erratum to the SFrame Version 2 specification.

include/
        * sframe.h (SFRAME_F_FDE_FUNC_START_PCREL): New definition.
        (SFRAME_V2_F_ALL_FLAGS): Likewise.
libsframe/
* sframe-dump.c (dump_sframe_header_flags): Update to include
the new flag SFRAME_F_FDE_FUNC_START_PCREL.
* sframe.c (sframe_header_sanity_check_p): Use
SFRAME_V2_F_ALL_FLAGS.
libsframe/doc/
* sframe-spec.texi: Add details about the new flag.  Also update
the defails about the sfde_func_start_address encoding.

3 weeks agoinclude: libsframe: add APIs for offsetof FDE func start addr field
Indu Bhagat [Sun, 6 Jul 2025 19:46:33 +0000 (12:46 -0700)] 
include: libsframe: add APIs for offsetof FDE func start addr field

These APIs will be later used by the linker to arrange SFrame FDEs in
the output SFrame section.

include/
        * sframe-api.h (sframe_decoder_get_offsetof_fde_start_addr): New
declaration.
        (sframe_encoder_get_offsetof_fde_start_addr): Likewise.

libsframe/
        * libsframe.ver: List the new APIs.
        * sframe.c (sframe_decoder_get_offsetof_fde_start_addr): New
definition.
        (sframe_encoder_get_offsetof_fde_start_addr): Likewise.

3 weeks agolibsframe: refactor code for dumping section flags
Indu Bhagat [Sun, 6 Jul 2025 19:46:24 +0000 (12:46 -0700)] 
libsframe: refactor code for dumping section flags

To prepare code for accommodating new flag additions easily as the
format evolves.

libsframe/
        * sframe-dump.c (SFRAME_HEADER_FLAGS_STR_MAX_LEN): Remove.
        (dump_sframe_header_flags): .. to here. New definition.
        (PRINT_FLAG): New definition.
        (dump_sframe_header): Move some implementation from here ..

3 weeks agoinclude: libsframe: add APIs for SFrame header flags
Indu Bhagat [Sun, 6 Jul 2025 19:46:09 +0000 (12:46 -0700)] 
include: libsframe: add APIs for SFrame header flags

Add new APIs, one each for getting flags from the SFrame decoder and
SFrame encoder context objects respectively.

These will later be used by the linker to uniformly access the flags,
given the SFrame decoder and SFrame encoder objects.

Use the new API, where applicable, within libsframe.

include/
        * sframe-api.h (sframe_decoder_get_flags): New declaration.
        (sframe_encoder_get_flags): Likewise.
libsframe/
* libsframe.ver: List new APIs.
        * sframe.c (sframe_decoder_get_flags): New definition.
(sframe_encoder_get_flags): Likewise.
        (sframe_get_funcdesc_with_addr_internal): Use the new API.
        (sframe_encoder_get_flags): Likewise.
        (sframe_encoder_write_sframe): Likewise.

3 weeks agoMIPS/LD/testsuite: Remove empty pic-and-nonpic-1-r6.s file
Maciej W. Rozycki [Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)] 
MIPS/LD/testsuite: Remove empty pic-and-nonpic-1-r6.s file

It was never used, pushed by mistake along with pic-and-nonpic-1a-r6.s.

3 weeks agoMIPS: Correct HI/LO rela reloc howto special_function entries
Alan Modra [Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)] 
MIPS: Correct HI/LO rela reloc howto special_function entries

The patch corrects the mips16 and micromips rela tables to *not*
use _bfd_mips_elf_{hi,lo}16_reloc.  These special functions are
inappropriate for RELA relocs where addends are in the reloc rather
than in the section contents.  See corresponding rela R_MIPS howtos.

bfd/
* elf64-mips.c (mips16_elf64_howto_table_rela)
<R_MIPS16_HI16, R_MIPS16_LO16>: Use _bfd_mips_elf_generic_reloc
special_function.
(micromips_elf64_howto_table_rela)
<R_MICROMIPS_HI16, R_MICROMIPS_LO16>: Similarly.
* elfn32-mips.c: As for elf64-mips.c.

3 weeks agoMIPS/BFD: Fix RELA handling of borrow in the generic linker
Maciej W. Rozycki [Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)] 
MIPS/BFD: Fix RELA handling of borrow in the generic linker

Fix an issue with `_bfd_mips_elf_generic_reloc' not taking into account
any borrow from the lower part in the handling of relocations of the
HI/LO kind and resulting in incorrect calculations made for RELA targets
in the generic used for non-ELF output such as S-records.  This doesn't
trigger for REL targets because they call `_bfd_mips_elf_generic_reloc'
indirectly from `_bfd_mips_elf_lo16_reloc' so as to obtain a complete
32-bit addend from relocation pairs and in calculating the addend the
latter function uses a hack to work around the lack of borrow handling
in the former function.

The MIPS/ELF linker is unaffected as it uses its own calculations.

Correct the calculation of the relevant partial relocations made in
`_bfd_mips_elf_generic_reloc' then to take the borrow into account and
remove the hack from `_bfd_mips_elf_lo16_reloc' as no longer needed.

Add generic linker test cases accordingly expecting the same disassembly
from srec output produced as from ELF output produced by the MIPS/ELF
linker.

3 weeks agoMIPS/testsuite: Expand GAS and LD HI/LO relocation coverage
Maciej W. Rozycki [Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)] 
MIPS/testsuite: Expand GAS and LD HI/LO relocation coverage

Expand test coverage for HI/LO relocation handling and add conventional
MIPS and microMIPS GAS tests as well as conventional MIPS, microMIPS,
and MIPS16e2 LD tests, covering R_MIPS_HI16, R_MIPS_LO16, R_MIPS16_HI16,
R_MIPS16_LO16, R_MICROMIPS_HI16, and R_MICROMIPS_LO16 relocations, as
well as 64-bit R_MIPS_HIGHEST, R_MIPS_HIGHER, R_MICROMIPS_HIGHEST, and
R_MICROMIPS_HIGHER relocations.

Modify the linker script so as to retain the `.MIPS.abiflags' section so
as to disassemble MIPS16e2 code correctly, as MIPS16e2 ASE information
is only carried in that section and not in ELF file header's `e_flags'.

MIPS16e2 and microMIPS code requires at least the MIPS32r2 ISA (or the
MIPS64r2 one for the n32 and n64 ABIs), which is incompatible with the
`mips:5900' linker output architecture and causes link failures such as:

./ld-new: tmpdir/mips-hilo1.o: linking mips:isa32r2 module with previous mips:5900 modules
./ld-new: failed to merge target specific data of file tmpdir/mips-hilo1.o

Therefore exclude `mips*el-ps2-elf*' targets from microMIPS and MIPS16e2
LD testing.

3 weeks agoMIPS/LD/testsuite: Switch mips16-hilo tests to new disassembly format
Maciej W. Rozycki [Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)] 
MIPS/LD/testsuite: Switch mips16-hilo tests to new disassembly format

Switch the o32 and n32 mips16-hilo MIPS LD tests to the new disassembly
format, to reduce discrepancies in output in preparation to reuse for
generic linker tests.

Taking the first line of disassembly output as an example the difference
is:

00500000 <stuff> 6c00       li a0,0

vs:

0x0000000000500000 6c00       li a0,0

for ELF and srec input respectively with the currently used older format
requested with `--prefix-addresses', but with the new disassembly format
it is exactly the same between the two input formats and no information
that we need is lost in the transition:

  500000: 6c00       li a0,0

3 weeks agoMIPS/LD/testsuite: Remove symbol table output from mips16-hilo tests
Maciej W. Rozycki [Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)] 
MIPS/LD/testsuite: Remove symbol table output from mips16-hilo tests

The o32 and n32 mips16-hilo MIPS LD tests request symbol table output
only to discard it in matching.  The symbol table is not relevant to
these tests, so remove it from output requested and adjust matching
patterns accordingly.

3 weeks agoMIPS/testsuite: Fix %hi usage across MIPS16 GAS/LD tests
Maciej W. Rozycki [Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)] 
MIPS/testsuite: Fix %hi usage across MIPS16 GAS/LD tests

Fix a couple of places in MIPS GAS and LD R_MIPS16_HI16/R_MIPS16_LO16
relocation tests where the %hi operator has been incorrectly used, but
the %lo operator is expected to complement the preceding %hi operation.

3 weeks agoMIPS/LD/testsuite: Fix mips16-hilo IRIX 6 emulation failures
Maciej W. Rozycki [Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)] 
MIPS/LD/testsuite: Fix mips16-hilo IRIX 6 emulation failures

IRIX 6 emulations place external small common symbols in the regular
common section instead of the small common section.  With mips16-hilo
test this leads to a different symbol assignment to memory locations
between o32 and n32 ABIs, as follows:

--- o32.map
+++ n32.map
@@ -46,23 +46,22 @@
  *(.sdata)
                 0x00765430                        . = 0x765430

-.bss            0x00765430      0x7d8
+.bss            0x00765430      0x7d9
  *(.bss)
  .bss           0x00765430      0x3f0 tmpdir/mips16-hilo.o
  .bss           0x00765820        0x0 tmpdir/mips16-hilo1.o
  *(COMMON)
- COMMON         0x00765820      0x3e8 tmpdir/mips16-hilo.o
+ COMMON         0x00765820      0x3e9 tmpdir/mips16-hilo.o
                 0x00765820                big_external_common
+                0x00765c08                small_external_common

-.sbss           0x00765c08        0x2
+.sbss           0x00765c09        0x1
  *(.sbss)
- .sbss          0x00765c08        0x1 tmpdir/mips16-hilo.o
+ .sbss          0x00765c09        0x1 tmpdir/mips16-hilo.o
  *(.scommon)
- .scommon       0x00765c09        0x1 tmpdir/mips16-hilo.o
-                0x00765c09                small_external_common

 /DISCARD/
  *(*)
 LOAD tmpdir/mips16-hilo.o
 LOAD tmpdir/mips16-hilo1.o
-OUTPUT(tmpdir/dump elf32-bigmips)
+OUTPUT(tmpdir/dump elf32-nbigmips)

which in turn causes a testsuite regression.  Since the specific mapping
of symbols does not matter for the scope of the test, reorder the small
common section ahead of SBSS, so that the `small_external_common' symbol
ends up in the same place regardless of whether via the regular common
section or the small common section.  Adjust embedded addresses in the
disassembly expected accordingly, removing the regression concerned:

mips-sgi-irix6  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs n32
mips64el-ps2-elf  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs n32

3 weeks agoMIPS/LD/testsuite: Unify o32/n32 mips16-hilo test output
Maciej W. Rozycki [Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)] 
MIPS/LD/testsuite: Unify o32/n32 mips16-hilo test output

The mips16-hilo MIPS LD test case is supposed to produce the same final
linked output regardless of whether the o32 or n32 ABI has been chosen
for assembly.  Reuse o32 output for the n32 test then.

3 weeks agoMIPS/LD/testsuite: Set architecture for MIPS16 HI/LO tests
Maciej W. Rozycki [Sun, 6 Jul 2025 18:22:49 +0000 (19:22 +0100)] 
MIPS/LD/testsuite: Set architecture for MIPS16 HI/LO tests

Remove regressions across MIPSr6 targets with the MIPS16 HI/LO tests,
which are incompatible with the default architecture of these targets:

mips-img-elf  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mips-img-linux  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mips64-img-linux  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mips64-img-linux  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs n32
mips64el-img-linux  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mips64el-img-linux  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs n32
mipsel-img-elf  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mipsel-img-linux  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mipsisa32r6-elf  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mipsisa32r6-linux  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mipsisa32r6el-elf  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mipsisa32r6el-linux  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mipsisa64r6-elf  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mipsisa64r6-linux-gnuabi64  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mipsisa64r6-linux  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mipsisa64r6el-elf  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mipsisa64r6el-linux-gnuabi64  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs
mipsisa64r6el-linux  -FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs

3 weeks agoMIPS/GAS/testsuite: Cover microMIPS HI/LO relocation pairing
Maciej W. Rozycki [Sun, 6 Jul 2025 18:22:48 +0000 (19:22 +0100)] 
MIPS/GAS/testsuite: Cover microMIPS HI/LO relocation pairing

Add a GAS test case for R_MICROMIPS_HI16/R_MICROMIPS_LO16 REL relocation
pairing, analogous to one for R_MIPS16_HI16/R_MIPS16_LO16 relocations.

3 weeks agoMIPS/GAS/testsuite: Remove useless whitespace from mips16-hilo-match test
Maciej W. Rozycki [Sun, 6 Jul 2025 18:22:48 +0000 (19:22 +0100)] 
MIPS/GAS/testsuite: Remove useless whitespace from mips16-hilo-match test

Remove trailing whitespace and extraneous new-line characters from
mips16-hilo-match.d test case.

3 weeks agogas pending_bundle_size assert
Alan Modra [Sat, 5 Jul 2025 08:57:36 +0000 (18:27 +0930)] 
gas pending_bundle_size assert

oss-fuzz managed to trigger this assert, by assembling directives in
the absolute section.  Avoid this using similar code to that in
frags.c:frag_new (commit 2dc2dfa7d7a5).

3 weeks agogas bundle support
Alan Modra [Sat, 5 Jul 2025 08:47:21 +0000 (18:17 +0930)] 
gas bundle support

Use valueT when calculating sizes, since fr_fix is that type.
unsigned int was fine for sane code, but can lose to fuzzed input.

3 weeks agoubsan: gas resolve_symbol_value
Alan Modra [Sat, 5 Jul 2025 01:25:47 +0000 (10:55 +0930)] 
ubsan: gas resolve_symbol_value

Avoid signed overflow when resolving constant +/- constant.

3 weeks agolibsframe: fix error code in sframe_decode
Indu Bhagat [Sun, 6 Jul 2025 02:02:24 +0000 (19:02 -0700)] 
libsframe: fix error code in sframe_decode

When sanity check of SFrame header fails, set error code to
SFRAME_ERR_BUF_INVAL instead of the current SFRAME_ERR_NOMEM.

3 weeks agoAutomatic date update in version.in
GDB Administrator [Sun, 6 Jul 2025 00:01:17 +0000 (00:01 +0000)] 
Automatic date update in version.in

3 weeks ago[gdb/tdep] Fix selftest scoped_mmap on freebsd
Tom de Vries [Sat, 5 Jul 2025 11:29:53 +0000 (13:29 +0200)] 
[gdb/tdep] Fix selftest scoped_mmap on freebsd

On x86_64-freebsd, I run into:
...
$ gdb -q -batch -ex "maint selftest scoped_mmap"
Running selftest scoped_mmap.
Self test failed: self-test failed at scoped_mmap-selftests.c:50

Failures:
  scoped_mmap

Ran 1 unit tests, 1 failed
...

The problem is that this call:
...
    ::scoped_mmap smmap (nullptr, sysconf (_SC_PAGESIZE), PROT_WRITE,
 MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
...
returns MAP_FAILED and sets errno to EINVAL because the argument fd == 0.

If MAP_ANONYMOUS is used, fd == -1 should be used on freebsd.  On linux, fd is
ignored but -1 is recommended for portability.

Fix this by using fd == -1 instead.

Tested x86_64-freebsd and x86_64-linux.

3 weeks ago[gdb/tdep] Fix doc string of kvm pcb/proc command
Tom de Vries [Sat, 5 Jul 2025 11:29:53 +0000 (13:29 +0200)] 
[gdb/tdep] Fix doc string of kvm pcb/proc command

On x86_64-freebsd, I ran into:
...
$ gdb -q -batch -ex "maint selftest help_doc_invariants"
Running selftest help_doc_invariants.
help doc broken invariant: command 'kvm pcb' help doc first line is not \
  terminated with a '.' character
Self test failed: self-test failed at command-def-selftests.c:120

Failures:
  help_doc_invariants

Ran 1 unit tests, 1 failed
...

Fix this by adding the missing terminating dot.

Likewise for the kvm proc command.

Tested on x86_64-freebsd.

3 weeks agogdb: create gdb.sum/gdb.log summary after using check-all-boards
Andrew Burgess [Mon, 23 Jun 2025 15:32:28 +0000 (16:32 +0100)] 
gdb: create gdb.sum/gdb.log summary after using check-all-boards

Use the contrib/dg-extract-results.sh script to create a gdb.sum and
gdb.log summary after running the check-all-boards make target.

Having the results from all the boards merged into a single file
isn't (maybe) the most useful, but it isn't a bad thing.  However, the
great thing about merge the results is that the totals are also
merged.

The 'check-all-boards' recipe can then extract these totals, just as
we do for the normal 'check' recipe, this makes is much easier to
spot if there are any unexpected failures when using
'check-all-boards'.

Reviewed-By: Keith Seitz <keiths@redhat.com>
3 weeks agocontrib: sync dg-extract-results.{sh,py} with GCC
Andrew Burgess [Mon, 23 Jun 2025 15:30:20 +0000 (16:30 +0100)] 
contrib: sync dg-extract-results.{sh,py} with GCC

Sync the dg-extract-results.{sh,py} scripts with GCC, up to commit
4e9104ae5455a3c02c2a7e07f52e6bc574cc761d.

This extends the dg-extract-results scripts to handle GDB's
'unexpected core files' count.

contrib/ChangeLog:

* dg-extract-results.py: Handle GDB's unexpected core file count.
* dg-extract-results.sh: Likewise.

Reviewed-By: Keith Seitz <keiths@redhat.com>
3 weeks agosim: ppc: use correct macros
Pietro Monteiro [Sat, 5 Jul 2025 01:44:21 +0000 (21:44 -0400)] 
sim: ppc: use correct macros

AC_STRUCT_ST_* are the names of the autoconf macros, the C
preprocessor macros defined by autoconf/authoeader are
HAVE_STRUCT_STAT_ST_*.

Approved-By: Andrew Burgess <aburgess@redhat.com>
3 weeks agosim: configury: fix obsolete macros
Pietro Monteiro [Sat, 5 Jul 2025 01:13:13 +0000 (21:13 -0400)] 
sim: configury: fix obsolete macros

Running `autoreconf -vf -Wall' in the sim directory shows errors about the use
of obsolete macros.  This patch fix the issues with macros used or defined in
the sim directory.  However, it doesn't fix all warnings.  There's 1 autoconf
warning  from `config/pkg.m4', and many automake warnings about target
shadowing.  It cuts a lot of the noise down and makes an upgrade to
autoconf 2.71+ easier.

- Replace AC_CANONICAL_SYSTEM by AC_CANONICAL_TARGET
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fCANONICAL_005fSYSTEM-1997

- Replace AC_TRY_COMPILE by AC_COMPILE_IFELSE
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fTRY_005fCOMPILE-2203

- Replace AC_ERROR by AC_MSG_ERROR
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fERROR-2034

- Remove AC_TYPE_SIGNAL and replace `RETSIGTYPE' by `void' in the source
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fTYPE_005fSIGNAL-2213

- Remove AC_STRUCT_ST_BLKSIZE, it's already covered by a AC_CHECK_MEMBERS call
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fSTRUCT_005fST_005fBLKSIZE-2176

- Remove AC_STRUCT_ST_RDEV, it's already covered by a AC_CHECK_MEMBERS call
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fSTRUCT_005fST_005fRDEV-2180

- Remove AC_STRUCT_ST_BLOCKS.  It is not obsolete, but it's already covered by a
AC_CHECK_MEMBERS call.

- Replace deprecated C macros HAVE_ST_${MEMBER} by HAVE_STRUCT_STAT_ST_${MEMBER}
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Particular-Structures.html#index-AC_005fSTRUCT_005fST_005fBLOCKS-693

Approved-By: Tom Tromey <tom@tromey.com>
3 weeks agogdb: add Pietro Monteiro to gdb/MAINTAINERS
Pietro Monteiro [Sat, 5 Jul 2025 00:46:02 +0000 (20:46 -0400)] 
gdb: add Pietro Monteiro to gdb/MAINTAINERS

3 weeks agoAutomatic date update in version.in
GDB Administrator [Sat, 5 Jul 2025 00:01:07 +0000 (00:01 +0000)] 
Automatic date update in version.in

3 weeks agogas: introduce .errif and .warnif
Jan Beulich [Fri, 4 Jul 2025 08:42:18 +0000 (10:42 +0200)] 
gas: introduce .errif and .warnif

Rather than having people resort to indirect means to issue a certain
kind of diagnostic conditionally upon an expression which can (or
should) only be evaluated when all sections were sized and all symbols
had their final values established, provide directives to directly
achieve this.

3 weeks agogas: add a means to programmatically determine the assembler version
Jan Beulich [Fri, 4 Jul 2025 08:41:34 +0000 (10:41 +0200)] 
gas: add a means to programmatically determine the assembler version

It has been more than once that I would have wanted to have a way to
know the gas version in assembly sources, perhaps for use with .if. Add
such a pre-defined symbol, introducing the common pattern GAS(<symbol>)
for any such symbols. The use of parentheses is to keep the risk of
collisions with users' symbols as low as possible. (Possible future
arch-specific symbols may want to use GAS(<arch>:<symbol>).)

Similarly permit determining whether the assembler is a released
version. The exact value probably isn't of much use, it's more the
defined-ness that one might care about. Yet the symbol needs to have
some value anyway.

While by default pre-defined symbols won't be emitted to the symbol
table, introduce -emit-local-absolute to allow requesting this. Re-
purpose flag_strip_local_absolute to become tristate, with a negative
value indicating to also emit pre-defined symbols.

3 weeks agocris/testsuite: don't use --em=
Jan Beulich [Fri, 4 Jul 2025 08:40:31 +0000 (10:40 +0200)] 
cris/testsuite: don't use --em=

Using such abbreviations is fine when written on an interactive command
line by a human. In scripts and alike, doing so risks colliding with
later option additions, as is about to occur for gas: Shortly there'll
be --emit-local-absolute.

3 weeks agoAutomatic date update in version.in
GDB Administrator [Fri, 4 Jul 2025 00:01:17 +0000 (00:01 +0000)] 
Automatic date update in version.in

3 weeks agogdb/linux-nat: initialize lwp_info::syscall_state
Simon Marchi [Thu, 3 Jul 2025 17:37:41 +0000 (13:37 -0400)] 
gdb/linux-nat: initialize lwp_info::syscall_state

When running gdb.base/foll-fork-syscall.exp with a GDB built with UBSan,
I get:

    /home/simark/src/binutils-gdb/gdb/linux-nat.c:1906:28: runtime error: load of value 3200171710, which is not a valid value for type 'target_waitkind'
    ERROR: GDB process no longer exists
    GDB process exited with wait status 3026417 exp9 0 1
    UNRESOLVED: gdb.base/foll-fork-syscall.exp: follow-fork-mode=child: detach-on-fork=on: test_catch_syscall: continue to breakpoint after fork

The error happens here:

    #0  __sanitizer::Die () at /usr/src/debug/gcc/gcc/libsanitizer/sanitizer_common/sanitizer_termination.cpp:50
    #1  0x00007ffff600d8dd in __ubsan::__ubsan_handle_load_invalid_value_abort (Data=<optimized out>, Val=<optimized out>) at /usr/src/debug/gcc/gcc/libsanitizer/ubsan/ubsan_handlers.cpp:551
    #2  0x00005555636d37b6 in linux_handle_syscall_trap (lp=0x7cdff1eb1b00, stopping=0) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:1906
    #3  0x00005555636e0991 in linux_nat_filter_event (lwpid=3030627, status=1407) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:3044
    #4  0x00005555636e407f in linux_nat_wait_1 (ptid=..., ourstatus=0x7bfff0d6cf18, target_options=...) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:3381
    #5  0x00005555636e7795 in linux_nat_target::wait (this=0x5555704d35e0 <the_amd64_linux_nat_target>, ptid=..., ourstatus=0x7bfff0d6cf18, target_options=...) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:3607
    #6  0x000055556378fad2 in thread_db_target::wait (this=0x55556af42980 <the_thread_db_target>, ptid=..., ourstatus=0x7bfff0d6cf18, options=...) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1398
    #7  0x0000555564811327 in target_wait (ptid=..., status=0x7bfff0d6cf18, options=...) at /home/simark/src/binutils-gdb/gdb/target.c:2593

I believe the problem is that lwp_info::syscall_state is never
initialized.  Fix that by initializing it with TARGET_WAITKIND_IGNORE.
This is the value we use elsewhere when resetting this field to mean
"not stopped at a syscall".

Change-Id: I5b76c63d1466d6e63448fced03305fd5ca8294eb
Approved-By: Tom Tromey <tom@tromey.com>
3 weeks agobfd/aarch64-linux: Support reading and writing the GCS core file note
Thiago Jung Bauermann [Thu, 1 May 2025 19:48:15 +0000 (16:48 -0300)] 
bfd/aarch64-linux: Support reading and writing the GCS core file note

Reviewed-By: Luis Machado <luis.machado@arm.com>
3 weeks agogdb/testsuite: remove spurious whitespace in gdb.python/py-symbol.exp
Simon Marchi [Fri, 27 Jun 2025 15:26:27 +0000 (11:26 -0400)] 
gdb/testsuite: remove spurious whitespace in gdb.python/py-symbol.exp

Change-Id: I15e307e6910ecbea5a5852e07757f892ea799536

3 weeks agogdb/alpha-tdep: add empty line
Simon Marchi [Thu, 3 Jul 2025 16:00:49 +0000 (12:00 -0400)] 
gdb/alpha-tdep: add empty line

This was suggested in review, to separate the comment from the following
code.

Change-Id: I077ad4545ee5ef1d362dcfacf585400e26dfdb29

4 weeks agoAutomatic date update in version.in
GDB Administrator [Thu, 3 Jul 2025 00:01:22 +0000 (00:01 +0000)] 
Automatic date update in version.in

4 weeks agogdb/alpha: Redefine fpcr with fpcr_flags type
Yodel Eldar [Mon, 26 May 2025 15:12:19 +0000 (10:12 -0500)] 
gdb/alpha: Redefine fpcr with fpcr_flags type

This commit adds fpcr_flags and dyn_rm_enum types to define the fpcr.

For details on the floating-point control register (fpcr), please see
the Alpha Architecture Reference Manual, 4th Ed. [1]; in brief, it
consists of a 64-bit bitfield with most bits reserved/unused. All but a
pair of the used bits are boolean flags; the exception, DYN_RM, is a
2-bit enum indicating the IEEE rounding mode and is defined as a
dyn_rm_enum type in the target description annex.

[1] https://archive.org/details/dec-alpha_arch_ref

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Iea54c9e201faae6147a03de124b0368752bce060

4 weeks agogdb/alpha: Add target description support
Yodel Eldar [Mon, 26 May 2025 15:12:18 +0000 (10:12 -0500)] 
gdb/alpha: Add target description support

This commit adds target description support for Alpha.

The target description obviates the alpha_register_type and
alpha_register_name functions in alpha-tdep.c. Removal of
alpha_register_reggroup_p was considered but ultimately abandoned,
because the "info regs" command would no longer omit the zero, fpcr, and
unique registers from its output (they are neither vector nor float
types).

Register types in the target description annex match the types that the
alpha_register_type function returned.

The locally defined register_names array was moved out of
alpha_register_name and renamed to alpha_register_names as a static
global; calls to alpha_register_name have been replaced with direct
access of the array.

The patch follows the code pattern outlined in the following GDB
Internals Wiki entry:

https://sourceware.org/gdb/wiki/Internals%20Adding-Target-Described-Register-Support

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: If4b25a891228388519074a31a682e33358c71063

4 weeks ago[gdb/testsuite] Use support_displaced_stepping in gdb.arch/amd64-disp-step-avx.exp
Tom de Vries [Wed, 2 Jul 2025 16:05:11 +0000 (18:05 +0200)] 
[gdb/testsuite] Use support_displaced_stepping in gdb.arch/amd64-disp-step-avx.exp

In commit 8e73fddeb0d ("[gdb/testsuite] Fix gdb.arch/amd64-disp-step-avx.exp
on x86_64-freebsd") I added a "require {istarget *-*-linux*}", but since then
I found support_displaced_stepping, which seems more appropriate and
descriptive.

Fix this by requiring support_displaced_stepping instead.

Tested on x86_64-freebsd.

4 weeks ago[gdb/testsuite] Fix gdb.arch/amd64-disp-step-avx.exp on x86_64-freebsd
Tom de Vries [Wed, 2 Jul 2025 06:14:03 +0000 (08:14 +0200)] 
[gdb/testsuite] Fix gdb.arch/amd64-disp-step-avx.exp on x86_64-freebsd

With test-case gdb.arch/amd64-disp-step-avx.exp on x86_64-freebsd I run into:
...
(gdb) continue
Continuing.

Breakpoint 3, test_rip_vex2_end () at amd64-disp-step-avx.S:35
35 nop
(gdb) FAIL: $exp: vex2: continue to test_rip_vex2_end
...

This happens while executing this bit of the test-case:
...
    # Turn "debug displaced" on to make sure a displaced step is actually
    # executed, not an inline step.
    gdb_test_no_output "set debug displaced on"

    gdb_test "continue" \
"Continuing.*prepared successfully .*Breakpoint.*, ${test_end_label} ().*" \
"continue to ${test_end_label}"
...

The problem is that on x86_64, displaced stepping is only supported for linux.
Consequently, the "prepared successfully" message is missing.

Fix this by requiring linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
Tested on x86_64-freebsd.

4 weeks agoAutomatic date update in version.in
GDB Administrator [Wed, 2 Jul 2025 00:01:21 +0000 (00:01 +0000)] 
Automatic date update in version.in

4 weeks agoFix handling of terminal escape sequences in TUI
Tom Tromey [Fri, 13 Jun 2025 18:54:16 +0000 (12:54 -0600)] 
Fix handling of terminal escape sequences in TUI

A user noticed that if the remote sends terminal escape sequences from
the "monitor" command, then these will not be correctly displayed when
in TUI mode.

I tracked this down to remote.c emitting one character at a time --
something the TUI output functions did not handle correctly.

I decided in the end to fix in this in the ui-file layer, because the
same bug seems to affect logging and, as is evidenced by the test case
in this patch, Python output in TUI mode.

The idea is simple: buffer escape sequences until they are either
complete or cannot possibly be recognized by gdb.

Regression tested on x86-64 Fedora 40.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=14126
Approved-By: Andrew Burgess <aburgess@redhat.com>
4 weeks agox86: ld: sframe: Remove SFrame NULL FRE template
Jens Remus [Tue, 1 Jul 2025 15:56:10 +0000 (17:56 +0200)] 
x86: ld: sframe: Remove SFrame NULL FRE template

A SFrame NULL FRE template is used as NULL value in some but not all
instances to initialize unused elements of SFrame FRE pointer arrays of
fixed size.  Additionally it is erroneously used as SFrame FRE template
for PLT GOT entries.

Define a separate SFrame FRE template for PLT GOT entries with the same
properties as the SFrame NULL FRE and use that for all PLT GOT entries.
Remove the SFrame NULL FRE template, as initialization of unused array
elements is not required, as demonstrated by the instances where it was
not done.

bfd/
* elf64-x86-64.c (elf_x86_64_sframe_null_fre): Remove.
(elf_x86_64_sframe_pltgot_fre1): New SFrame FRE template for
PLT GOT entries.
(elf_x86_64_sframe_non_lazy_plt,
elf_x86_64_sframe_non_lazy_ibt_plt): Do not initialize unused
FRE array elements with elf_x86_64_sframe_null_fre.  Use
elf_x86_64_sframe_pltgot_fre1 for PLT GOT.
(elf_x86_64_sframe_plt, elf_x86_64_sframe_ibt_plt): Use
elf_x86_64_sframe_pltgot_fre1 for PLT GOT.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 weeks agolibctf: doc: add __float128 and SIMD vector classification to spec.
Bruce McCulloch [Fri, 27 Jun 2025 16:21:52 +0000 (09:21 -0700)] 
libctf: doc: add __float128 and SIMD vector classification to spec.

This patch adds two additional distinct types (__float128 and the SIMD
vector type generated from the vector_size attribute) to the umbrella of
two existing types (long double and array, respectively). These types
were previously invalid, producing CTF_K_UNKNOWN in the case of
__float128 or a float in the case of the SIMD vector. This patch will
cleanly allow these types to be represented more accurately without
breaking back-compat.

Signed-off-by: Bruce McCulloch <bruce.mcculloch@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
4 weeks agolibctf: add root-visibility-addition test
Nick Alcock [Thu, 26 Jun 2025 14:48:41 +0000 (15:48 +0100)] 
libctf: add root-visibility-addition test

libctf/
* testsuite/libctf-writable/ctf-nonroot-addition.*: New test.

4 weeks agolibctf: create: check the right root-visible flag when adding enumerands
Nick Alcock [Thu, 26 Jun 2025 14:47:25 +0000 (15:47 +0100)] 
libctf: create: check the right root-visible flag when adding enumerands

The root-visible flag we're dealing with here is directly out of the dict,
not a flag passed in to the API, so it does not have the values CTF_ADD_ROOT
or CTF_ADD_NONROOT: instead it's simply zero for non-root-visible, nonzero
otherwise.  Fix the test.

libctf/
* ctf-create.c (ctf_add_enumerator): Fix root-visibility test.

4 weeks agolibctf: create: addition of non-root types should not return root types
Nick Alcock [Thu, 26 Jun 2025 14:45:31 +0000 (15:45 +0100)] 
libctf: create: addition of non-root types should not return root types

If you add a non-root type to a dict, you should always get a new, unique
type ID back, even if a root-visible type with the same name already exists.
Unfortunately, if the root-visible type is a forward, and you're adding a
non-root-visible struct, union, or enum, the machinery to detect forwards
and promote them to the concrete type fires in this case and returns the
root-visible type!  If this is an enum being inserted hidden because its
enumerands conflict with some other enum, this will lead to failure later
on: in any case, it's seriously counterintuitive to add a non-root- visible
type and get a root-visible one instead.

Fix this by checking the root-visible flag properly and only checking for
forwards if this type is root-visible.  (This may lead to a certain degree
of proliferation of non-root-visible forwards: we can add a cleanup pass for
those later if needed.)

libctf/
* ctf-create.c (ctf_add_struct_sized): Check the root-visible flag when
doing forward promotion.
(ctf_add_union_sized): Likewise.
(ctf_add_enum): Likewise.

Reviewed-by: Bruce McCulloch <bruce.mcculloch@oracle.com>
4 weeks agoMIPS: Fix addend handling with rela R_MIPS16_GOT16 and R_MICROMIPS_GOT16
Alan Modra [Tue, 1 Jul 2025 13:05:07 +0000 (14:05 +0100)] 
MIPS: Fix addend handling with rela R_MIPS16_GOT16 and R_MICROMIPS_GOT16

In rela howtos these relocations should not be using
_bfd_mips_elf_got16_reloc.  That special function is for extracting
addends from section contents, and only for that (ie. it doesn't
subtract gp).  Make these rela howtos like the corresponding
R_MIPS_GOT16 rela howto.

* elf64-mips.c (mips16_elf64_howto_table_rela <R_MIPS16_GOT16>):
Use _bfd_mips_elf_generic_reloc.
(micromips_elf64_howto_table_rela <R_MICROMIPS_GOT16>): Likewise.
* elfn32-mips.c (elf_mips16_howto_table_rela <R_MIPS16_GOT16>):
Likewise.
(elf_micromips_howto_table_rela <R_MICROMIPS_GOT16>): Likewise.

4 weeks agoAutomatic date update in version.in
GDB Administrator [Tue, 1 Jul 2025 00:01:40 +0000 (00:01 +0000)] 
Automatic date update in version.in

4 weeks agoRISC-V: [gprofng] Allow building gprofng without asm/hwprobe.h
WANG Xuerui [Mon, 16 Jun 2025 08:16:55 +0000 (16:16 +0800)] 
RISC-V: [gprofng] Allow building gprofng without asm/hwprobe.h

The code is actually able to gracefully fallback if the syscall number
of riscv_hwprobe is not available at build time, but it still depended
on the <asm/hwprobe.h> header unconditionally. In certain environments
such as one of crosstool-NG's Canadian Cross build step (binutils for
host), or one with very outdated kernel headers, the header will not be
present, causing the build to fail.

While the relevant projects/environments should be fixed nevertheless,
a configure-time check for <asm/hwprobe.h> is helpful for fixing gprofng
builds with released versions of ct-ng etc.

Signed-off-by: WANG Xuerui <git@xen0n.name>
4 weeks agoFix typos in binutils/dwarf.c
Vladimir Mezentsev [Sun, 29 Jun 2025 23:45:13 +0000 (16:45 -0700)] 
Fix typos in binutils/dwarf.c

binutils/ChangeLog
2025-06-29  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* dwarf.c: Change "/usrlib64/debug/usr" to "/usr/lib64/debug/usr/" and
.gun_debugaltlink to .gnu_debugaltlink.

4 weeks agoAutomatic date update in version.in
GDB Administrator [Mon, 30 Jun 2025 00:00:47 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agogdb/solib-target: move make_target_solib_ops out of HAVE_LIBEXPAT
Simon Marchi [Sat, 28 Jun 2025 12:08:33 +0000 (08:08 -0400)] 
gdb/solib-target: move make_target_solib_ops out of HAVE_LIBEXPAT

When building without expat, we get a missing make_target_solib_ops
error:

    /usr/bin/ld: arch-utils.o: in function `gdbarch::gdbarch()':
    /home/simark/src/binutils-gdb/gdb/gdbarch-gen.c:30:(.text+0x15be): undefined reference to `make_target_solib_ops()'

Fix it by moving make_target_solib_ops out of HAVE_LIBEXPAT.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33118
Change-Id: I76fe4698c6b71bd76096e6cdcbacf8de42a3eb43
Tested-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
4 weeks agoAutomatic date update in version.in
GDB Administrator [Sun, 29 Jun 2025 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agox86-64.exp: Correct pr26808.dump to pr27708.dump
H.J. Lu [Sat, 28 Jun 2025 22:41:05 +0000 (06:41 +0800)] 
x86-64.exp: Correct pr26808.dump to pr27708.dump

Change

verbose "cmp tmpdir/pr27708.out $srcdir/$subdir/pr26808.dump" 1

to

verbose "cmp tmpdir/pr27708.out $srcdir/$subdir/pr27708.dump" 1

* testsuite/binutils-all/x86-64/x86-64.exp: Correct pr26808.dump
to pr27708.dump.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 weeks ago[gdb/tdep] Add "maint set console-translation-mode <binary|text>" command
Tom de Vries [Sat, 28 Jun 2025 11:03:14 +0000 (13:03 +0200)] 
[gdb/tdep] Add "maint set console-translation-mode <binary|text>" command

On MSYS2, say we record a brief gdb session using TERM=dumb script:
...
$ gdb -q
(gdb) print 1
$1 = 1
(gdb) q
...

When looking at the resulting typescript, we notice something odd:
...
$ gdb -q^M
(gdb) print 1^M
$1 = 1^M^M
(gdb) q^M
...

For some reason, we have "$1 = 1\r\r\n(gdb) ".

Looking at the documentation of _setmode [1], it mentions translation mode
_O_TEXT as a mode in which "\n" is translated into "\r\n" on output.

So, it looks like this translation happens twice.

Add a command "maint set console-translation-mode <binary|text>" command that
allows us to set the translation mode of stdout/stderr to binary, such that we
get instead:
...
$ gdb -q -ex "maint set console-translation-mode binary"^M
(gdb) print 1^M
$1 = 1^M
(gdb) q^M
...

Since we run into this in the testsuite, add
"maint set console-translation-mode binary" to INTERNAL_GDBFLAGS.

Based on "maint set testsuite-mode on/off" from these patches [2][3] by Pierre
Muller.

Compared to that proposal, I dropped the name testsuite-mode, because the
behaviour is not specific to the testsuite.

Also I chose values binary/text instead of on/off because eventually there may
be other translation mode values that we need [4].

Co-Authored-By: Pierre Muller <muller@sourceware.org>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setmode
[2] https://sourceware.org/legacy-ml/gdb-patches/2013-09/msg00939.html
[3] https://sourceware.org/legacy-ml/gdb-patches/2013-09/msg00940.html
[4] https://learn.microsoft.com/en-us/cpp/c-runtime-library/translation-mode-constants