]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
5 months agoAutomatic date update in version.in
GDB Administrator [Fri, 24 Jan 2025 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agobfd: fix generation of bfd.texi in out-of-tree builds
Jose E. Marchesi [Thu, 23 Jan 2025 19:16:09 +0000 (20:16 +0100)] 
bfd: fix generation of bfd.texi in out-of-tree builds

[In the sequel TS means $(top_srcdir) and TB means $(top_builddir)]

The Texinfo file TS/bfd/doc/bfd.texi @includes many other .texi files
such as:

   bfdt.texi
   bfdio.texi
   section.texi
   ...

These .texi files are generated from the bfd/*.c source files, by a
program called `chew' that is distributed along with BFD, via some
default rules and macro magic in TS/bfd/doc/local.mk.  Important
point: the .texi files are generated in TB/bfd/doc/, not TS/bfd/doc.

Now, AM_MAKEINFOFLAGS in local.mk is defined as:

  AM_MAKEINFOFLAGS = --no-split -I "$(srcdir)/%D%" -I %D%

Where %D% is 'doc/' in this case.  Now, it looks like the directory
containing the .texi file is automatically inserted in the @include
search path, so the -I %D% above places TB/bfd/doc _after_ TS/bfd/doc.

Since currently TS/bfd/doc/bfdt.texi is outdated and is missing some
nodes, the error above happens.

This patch changes bfd/doc/local.mk to use -P to prepend the current
build directory to the @include search path, rather than -I, which
appends it.

bfd/ChangeLog:

2025-01-23  Jose E. Marchesi  <jose.marchesi@oracle.com>

* doc/local.mk (AM_MAKEINFOFLAGS): Prepend the build directory to
the @include search path.
* Makefile.in: Regenerate.

5 months ago[gdb/cli] Fix return from frame containing inline frame
Tom de Vries [Thu, 23 Jan 2025 13:13:16 +0000 (14:13 +0100)] 
[gdb/cli] Fix return from frame containing inline frame

Consider test-case gdb.base/return-3.exp:
...
$ gdb -q outputs/gdb.base/return-3/return-3
Reading symbols from outputs/gdb.base/return-3/return-3...
(gdb)
...

Function bar is an inlined function, and consequently we cannot return from
it:
...
(gdb) b bar
Breakpoint 1 at 0x4006ac: file return-3.c, line 25.
(gdb) r
Starting program: return-3
  ...
Breakpoint 1, bar () at return-3.c:25
25        c++;
(gdb) return
Can not force return from an inlined function.
(gdb)
...

However, function foo is not an inline function, and we should be able to
return from it, but we get the same error message:
...
(gdb) up
31        bar ();
(gdb) return
Can not force return from an inlined function.
(gdb)
...

Fix this by using the selected frame rather than the current frame in
return_command, such that we get instead:
...
(gdb) up
31        bar ();
(gdb) return
40        printf ("%d\n", c);
(gdb)
...

Tested on aarch64-linux.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
PR cli/32479
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32479

5 months agoPowerPC: Add support for RFC02657 - AES acceleration instructions
Surya Kumari Jangala [Thu, 12 Dec 2024 09:01:30 +0000 (04:01 -0500)] 
PowerPC: Add support for RFC02657 - AES acceleration instructions

opcodes/
* ppc-opc.c (insert_m2, extract_m2): New functions.
(AESM, PGF1, XX2M, XX3M, XX3GF, XX2AES_MASK, XX2AESM_MASK,
XX3AES_MASK, XX3AESM_MASK, XX3GF_MASK): New macros.
(UIM): Update for new macros.
(powerpc_opcodes): Add xxaes128encp, xxaes192encp, xxaes256encp,
xxaesencp, xxaes128decp, xxaes192decp, xxaes256decp, xxaesdecp,
xxaes128genlkp, xxaes192genlkp, xxaes256genlkp, xxaesgenlkp,
xxgfmul128gcm, xxgfmul128xts, xxgfmul128.

gas/
* testsuite/gas/ppc/future.s: New test.
* testsuite/gas/ppc/future.d: Likewise.

5 months agold: fix alignment issue for ARM thumb long branch stub using PureCode section
Torbjörn SVENSSON [Tue, 17 Dec 2024 17:56:10 +0000 (18:56 +0100)] 
ld: fix alignment issue for ARM thumb long branch stub using PureCode section

When pure-code option is activated. The linker creates for M-profile architecures
a 2-bytes branch instruction. This causes the section alignment to be set to 2-byte
alignment instead of 4-byte alignment. This is a problem for long branch stub
without pure-code section as it contains a 32-bit address as data, which is expected
to be 4-byte aligned. Hence creating a long branch stub for PureCode section followed
by a long branch stub will result in a misalignment for the 32-bit address.

An easy fix is to add a nop instruction after the branch to keep the section alignment
to 4 bytes.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Guillaume VACHERIAS <guillaume.vacherias@st.com>
5 months agold plugin bfd_make_readable leak
Alan Modra [Wed, 22 Jan 2025 23:54:46 +0000 (10:24 +1030)] 
ld plugin bfd_make_readable leak

bfd_make_readable leaks memory that could be freed by
_free_cached_info except that does too much in releasing all bfd
memory.  (The fact that we had to hack around keeping the bfd filename
also indicates that releasing all bfd memory was too much.)  So this
patch moves code releasing bfd_alloc'd memory to the COFF
_free_cached_info, where the syms and suchlike are released.  This is
the memory that archive handling wants to release in the call there to
bfd_free_cached_info.

* coffgen.c (_bfd_coff_free_cached_info): Release syms.
* opncls.c (_bfd_new_bfd): Correct error return path.
(_bfd_free_cached_info): Don't kill all abfd->memory.
(_bfd_delete_bfd): Adjust fallback for bfd_free_cached_info.
(bfd_make_readable): Call target bfd_free_cached_info and
_bfd_free_cached_info plus reinstate section_htab.

5 months agold compact eh-frame leak
Alan Modra [Wed, 22 Jan 2025 23:53:48 +0000 (10:23 +1030)] 
ld compact eh-frame leak

u.compact.extries wasn't being freed anywhere.  Free it when
destroying the linker hash table.  Also free u.dwarf.aray there in
case errors result in the linker not getting to the slightly earlier
free in write_dwarf_eh_frame_hdr.

* elf-eh-frame.c (write_dwarf_eh_frame_hdr): Don't exit without
freeing u.dwarf.array.
* elflink.c (_bfd_elf_link_hash_table_free): Free u.compact.entries
and u.dwarf.array.

5 months agold plugin.c concat leaks
Alan Modra [Wed, 22 Jan 2025 23:52:58 +0000 (10:22 +1030)] 
ld plugin.c concat leaks

* ldlang.c: Whitespace.
(stat_free, stat_concat): New functions.
* ldlang.h (stat_free, stat_concat): Declare.
* plugin.c (asymbol_from_plugin_symbol): Use stat_concat.

5 months agounusual eh_frame memory leak
Alan Modra [Tue, 21 Jan 2025 21:19:56 +0000 (07:49 +1030)] 
unusual eh_frame memory leak

This one happens with --gc-sections and a linker script that either
discards some or all .eh_frame sections (eg. ld-elf/pr14265 test) or
maps an input .eh_frame to some other named output section.  In that
case the discarded/renamed .eh_frame won't have local_cies freed.

* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Correct comment.
* elf.c (_bfd_elf_free_cached_info): Free eh_frame cies.

5 months agoAnother ldelf_before_allocation leak
Alan Modra [Tue, 21 Jan 2025 21:09:53 +0000 (07:39 +1030)] 
Another ldelf_before_allocation leak

This fixes an even more obvious leak.

* ldelf.c (ldelf_before_allocation): Free copied elf_dt_audit.
Simplify loop.

5 months agoMore ld testsuite fixes
Alan Modra [Tue, 21 Jan 2025 04:11:54 +0000 (14:41 +1030)] 
More ld testsuite fixes

* testsuite/ld-elf/indirect.exp: Run compiler capability checks
using run_host_noleak.
* testsuite/ld-ifunc/ifunc.exp: Don't exit without restoring
ASFLAGS.  Don't run ifuncmod5 twice.

5 months agold: fix bashism in scripttempl/elf.sc
Sam James [Thu, 23 Jan 2025 00:03:07 +0000 (00:03 +0000)] 
ld: fix bashism in scripttempl/elf.sc

ld/
PR ld/32580

* scripttempl/elf.sc: Fix '==' bashism.

5 months agoAutomatic date update in version.in
GDB Administrator [Thu, 23 Jan 2025 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoRemove gnatmake_version_at_least
Tom Tromey [Thu, 9 Jan 2025 20:08:49 +0000 (13:08 -0700)] 
Remove gnatmake_version_at_least

This removes gnatmake_version_at_least in favor of using the more
flexible gnat_version_compare.  I think these two version numbers
should be the same, as gnatmake is shipped with the compiler.

5 months agoAvoid crash with 'length
Tom Tromey [Tue, 21 Jan 2025 17:49:07 +0000 (10:49 -0700)] 
Avoid crash with 'length

While testing gnat-llvm, I found a gdb crash when applying 'length to
a non-array type.  This patch fixes the crash.

5 months agoPreserve local variables in another Ada test case
Tom Tromey [Tue, 21 Jan 2025 15:19:21 +0000 (08:19 -0700)] 
Preserve local variables in another Ada test case

I found another Ada test case where gnat-llvm optimizes away the local
variables.  This patch applies the same fix to it as previous patches.

5 months agobfd/doc: use abs_srcdir when creating symlinks
Andrew Burgess [Tue, 21 Jan 2025 13:06:18 +0000 (13:06 +0000)] 
bfd/doc: use abs_srcdir when creating symlinks

After commit:

  commit bd32be01c997f686ab0b53f0640eaa0aeb61fbd3
  Date:   Fri Dec 3 00:23:20 2021 -0500

      bfd: merge doc subdir up a level

And the follow-up commit:

  commit 98b1464bdf6306a8ab4614b5e9f76cdb2dd00b33
  Date:   Wed Oct 2 22:58:08 2024 +0300

      bfd: fix unnecessary bfd.info regen

There is still a problem building the bfd docs from a release tar
file.

As the release tar file contains the pre-generated .texi files we
expect the bfd/doc build stage to symlink to the pre-existing .texi
files in the source tree.

However, this is still not working as expected if $(srcdir) is
relative.  The problem is this line in REGEN_TEXI:

    test -e $$texi || test ! -f $(srcdir)/$$texi || $(LN_S) $(srcdir)/$$texi $$texi; \

This is executed from the build/bfd/ directory, so if $(srcdir) is
relative, then this will get you from the bfd/ directory in the build
tree to the corresponding bfd/ directory in the src tree.  However,
the symlink is created in the bfd/doc/ build directory.  The relative
path will then fail to take you to the bfd/ directory in the src
tree.

Fix this by using $(abs_srcdir) when creating the symlink.

Approved-By: Nick Clifton <nickc@redhat.com>
5 months ago[gdb/testsuite] Fix gdb.base/branch-to-self.exp on arm-linux
Tom de Vries [Wed, 22 Jan 2025 09:46:08 +0000 (10:46 +0100)] 
[gdb/testsuite] Fix gdb.base/branch-to-self.exp on arm-linux

On arm-linux (ubuntu 24.04 with gcc 13.3.0) with target board unix/-marm and
test-case gdb.base/branch-to-self.exp I run into:
...
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, main () at branch-to-self.c:38^M
38        for (;;); /* loop-line */^M
(gdb) PASS: $exp: single-step: continue to breakpoint: hit breakpoint
si^M
0x0040058c      38        for (;;); /* loop-line */^M
(gdb) FAIL: $exp: single-step: si
...

In contrast, on the same machine but with debian testing and gcc 14.2.0 we have:
...
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, main () at branch-to-self.c:38^M
38        for (;;); /* loop-line */^M
(gdb) PASS: $exp: single-step: continue to breakpoint: hit breakpoint
si^M
^M
Breakpoint 2, main () at branch-to-self.c:38^M
38        for (;;); /* loop-line */^M
(gdb) PASS: $exp: single-step: stepi
...

The difference is in the instruction(s) generated for the loop.

In the passing case, we have:
...
 588:   eafffffe        b       588 <main+0x24>
...
and in the failing case:
...
 588:   e320f000        nop     {0}
 58c:   eafffffd        b       588 <main+0x24>
...

The purpose of this part of the test-case is to:
- generate a branch instruction that jumps to itself, and
- set a breakpoint on it, and check that stepi-ing from that breakpoint
  triggers the breakpoint again.

As we can see, in the failing case we failed to generate a branch instruction
that jumps to itself, and consequently we cannot expect to hit the breakpoint
again after issuing a single si.

Fix this by issuing stepi until we hit the breakpoint.

Tested on arm-linux.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
5 months agox86/Solaris: correct support for Sun form of CMOV<size>.S
Jan Beulich [Wed, 22 Jan 2025 08:51:23 +0000 (09:51 +0100)] 
x86/Solaris: correct support for Sun form of CMOV<size>.S

PR gas/32579

The deprecated .s (swapped operand encoding) functionality got in the
way of properly recognizing this specific form. Move the Solaris-
specific code ahead of that.

5 months agold: replace another @progbits etc in an ELF testcase
Jan Beulich [Wed, 22 Jan 2025 08:51:00 +0000 (09:51 +0100)] 
ld: replace another @progbits etc in an ELF testcase

The canonical form (in the testsuite) is %progbits and alike.

5 months agox86: Add missing @tab to separate columns in c-i386.texi
timhu2011 [Wed, 22 Jan 2025 07:32:31 +0000 (08:32 +0100)] 
x86: Add missing @tab to separate columns in c-i386.texi

I have missed @tab for .gmiccs and .padlockphe2, so fix this doc error.

gas/ChangeLog:

* doc/c-i386.texi: Add the missing @tab for .gmiccs and
  .padlockphe2

5 months agoAutomatic date update in version.in
GDB Administrator [Wed, 22 Jan 2025 00:00:30 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months ago[gdb/symtab] Fix gdb.base/fission-macro.exp with unix/-m32
Tom de Vries [Tue, 21 Jan 2025 14:23:19 +0000 (15:23 +0100)] 
[gdb/symtab] Fix gdb.base/fission-macro.exp with unix/-m32

When running test-case gdb.base/fission-macro.exp on openSUSE Tumbleweed
(using gcc 14) with target board unix/-m32, I get:
...
(gdb) info macro FIRST^M
Defined at /data/vries/gdb/src/gdb/testsuite/gdb.base/fission-macro.c:0^M
-DFIRST=1^M
(gdb) FAIL: $exp: \
  dwarf_version=5: dwarf_bits=32: strict_dwarf=0: info macro FIRST
...
instead of the expected:
...
(gdb) info macro FIRST^M
Defined at /data/vries/gdb/src/gdb/testsuite/gdb.base/fission-macro.c:18^M
(gdb) PASS: $exp: \
  dwarf_version=5: dwarf_bits=32: strict_dwarf=0: info macro FIRST
...

A dwarf-5 .debug_str_offsets section starts with a header consisting of:
- an initial length (4 bytes for 32-bit and 12 bytes for 64-bit),
- a 2 byte version string, and
- 2 bytes padding
so in total 8 bytes for 32-bit and 16 bytes for 64-bit.

This offset is calculated here in dwarf_decode_macros:
...
      str_offsets_base = cu->header.addr_size;
...
which is wrong for both dwarf-5 cases (and also happens to be wrong for
dwarf-4).

Fix this by computing str_offsets_base correctly for dwarf-5, for both the
32-bit and 64-bit case.

Likewise, fix this for dwarf-4, using str_offsets_base 0.  We can only test
this with gcc-15, because gcc 14 and earlier don't have the fix for
PR debug/115066.

Tested on x86_64-linux.

Tested test-case using a current gcc trunk build, and gcc 14.

Approved-By: Tom Tromey <tom@tromey.com>
PR symtab/31897
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31897

5 months ago[gdb/testsuite] Use -g3 in gdb.base/lineinc.exp
Tom de Vries [Tue, 21 Jan 2025 11:41:39 +0000 (12:41 +0100)] 
[gdb/testsuite] Use -g3 in gdb.base/lineinc.exp

The stated intention of test-case gdb.base/lineinc.exp is:
...
 # Test macro handling of #included files.
...

However, the test-case does not produce any macro debug information.

Fix this by adding macros in the compilation flags.

Tested on x86_64-linux.

5 months agoMore updated translations
Nick Clifton [Tue, 21 Jan 2025 10:48:02 +0000 (10:48 +0000)] 
More updated translations

5 months agoAutomatic date update in version.in
GDB Administrator [Tue, 21 Jan 2025 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoSupport broken gcc test for gas string merge support
Alan Modra [Sat, 18 Jan 2025 12:09:05 +0000 (22:39 +1030)] 
Support broken gcc test for gas string merge support

On casual reading of older gcc configure scripts it might be supposed
that the test for gas string merge support tries with %progbits after
a fail on ARM with @progbits.  It doesn't succeed due to a bug.  So to
support building of older gcc's for ARM without users having to edit
gcc sources, add a hack to gas.  The hack can disappear in a few years
when building older gcc's likely requires other work too.

I've changed the docs to reflect what we actually allow for .section
syntax prior to this patch.  (No way should this hack be documented as
allowed!)

PR 32491
* config/obj-elf.c (obj_elf_section): Allow missing entsize
for ARM gcc configure bug.
* doc/as.texi: Correct syntax of ELF .section directive.
* testsuite/gas/elf/string.s,
* testsuite/gas/elf/string.d: Test it.

5 months agorun_dump_test warning/error regexp
Alan Modra [Sat, 18 Jan 2025 11:51:03 +0000 (22:21 +1030)] 
run_dump_test warning/error regexp

This allows you to specify a run_dump_test warning that may or may not
be present using
warning: (warning_text_goes_here)?
ie. the regexp matches an empty string.

5 months agoasan ld builds without detect_leaks=0
Alan Modra [Mon, 20 Jan 2025 07:28:00 +0000 (17:58 +1030)] 
asan ld builds without detect_leaks=0

I found that building binutils with -fsanitize=address,undefined
results in much of the testsuite not being run.  The problem is that
running gcc results in linker plugin memory leaks which of course are
errors, so the testsuite sees this as lack of compiler support.

* testsuite/lib/ld-lib.exp (run_host_noleak): New proc.
(check_compiler_available, check_lto_available),
(check_lto_fat_available, check_lto_shared_available),
(check_ifunc_available, check_ifunc_attribute_available),
(check_libdl_available, check_gnu2_tls_available),
(compile_one_cc): Use run_host_noleak.
* testsuite/config/default.exp (compiler_supports): Likewise.

5 months agoLD: Remove duplicate 2.44 NEWS marker
Maciej W. Rozycki [Mon, 20 Jan 2025 17:29:18 +0000 (17:29 +0000)] 
LD: Remove duplicate 2.44 NEWS marker

Delete an extra 2.44 NEWS marker that has crept in by chance.

5 months agoUpdate translations for various sub-directories
Nick Clifton [Mon, 20 Jan 2025 16:19:22 +0000 (16:19 +0000)] 
Update translations for various sub-directories

5 months agoUpdate release readme for gold-in-branches change
Nick Clifton [Mon, 20 Jan 2025 16:18:36 +0000 (16:18 +0000)] 
Update release readme for gold-in-branches change

5 months agogas/NEWS,ld/NEWS: Announce LoongArch changes in 2.44
Lulu Cai [Mon, 20 Jan 2025 15:04:36 +0000 (15:04 +0000)] 
gas/NEWS,ld/NEWS: Announce LoongArch changes in 2.44

5 months agogdb/testsuite: Fix file location for gdb.base/backtrace-through-cu-nodebug
Guinevere Larsen [Mon, 20 Jan 2025 12:20:59 +0000 (09:20 -0300)] 
gdb/testsuite: Fix file location for gdb.base/backtrace-through-cu-nodebug

The newly added test gdb.base/backtrace-through-cu-nodebug.exp had a
problem in the call to gdb_compile, that caused the .o files to be
outputted in the GDB file tree. This commit fixes the issues in the calls.

Reported-By: Tom de Vries <tdevries@suse.de>
Approved-By: Tom de Vries <tdevries@suse.de>
5 months agoUpdate how-to-make-a-release document after creating the 2.44 branch
Nick Clifton [Mon, 20 Jan 2025 10:29:59 +0000 (10:29 +0000)] 
Update how-to-make-a-release document after creating the 2.44 branch

5 months agogas: elf: Relax rules for SHF_STRING sections
Richard Earnshaw [Fri, 17 Jan 2025 15:03:47 +0000 (15:03 +0000)] 
gas: elf: Relax rules for SHF_STRING sections

Commit af3394d97a8c5187085c0eec5fb03e8da88db5fb allowed sections
declared with "S" (SHF_STRING) to specify the entity size, but then
would warn if the entity size was omitted, as with the old syntax.

Unfortunately, since specifying the entity size is incompatible with
binutils 2.43 or earlier, this makes it impossible to specify a
strings section in source code without generating an assembly warning
(the new syntax isn't supported in older assemblers and the old syntax
generates warnings).

Nevertheless, the old code was wrong in that it did not set the entity
size at all, in contravention of the ELF specification (though to date
there are no known cases where this mattered outside of mergeable
sections).

Fix this by permitting the original syntax without a warning again,
but by defaulting the entity size to 1.  This is compatible with the
most common case of strings being byte-based.

Added some tests for the various flavours of declaration that we
support.

5 months agoldelf_before_allocation leak
Alan Modra [Mon, 20 Jan 2025 07:11:56 +0000 (17:41 +1030)] 
ldelf_before_allocation leak

ldelf_before_allocation is passed the audit and depaudit strings built
from command line args, then possibly adds to the depaudit string,
freeing the original.  The new string isn't freed.  Fix this leak by
keeping the string attached to the static vars.

* ldelf.c (ldelf_before_allocation): Pass char** for audit
and depaudit.  Adjust uses.
* ldelf.h (ldelf_before_allocation): Update prototype.
* gld${EMULATION_NAME}_before_allocation: Update call.

5 months agoRe: elflink.c memory leaks
Alan Modra [Mon, 20 Jan 2025 01:03:49 +0000 (11:33 +1030)] 
Re: elflink.c memory leaks

* elflink.c (elf_link_add_object_symbols): Free old_strtab
in another code path.  Revert one unnecessary change in last
patch.

5 months ago_bfd_elf_get_dynamic_symbols
Alan Modra [Sat, 18 Jan 2025 22:05:22 +0000 (08:35 +1030)] 
_bfd_elf_get_dynamic_symbols

This fixes an error path in _bfd_elf_get_dynamic_symbols, fixes the
minimum size required when reading DT_HASH header, and tidies
formatting in a few places.  Nit-fixes all.

Very likely we shouldn't be trying to mmap DT_DYNAMIC as it won't be
large enough for the mmap size threshold.

* elf.c (_bfd_elf_get_dynamic_symbols): Use _bfd_munmap_temporary
in error return path rather than free.  Corrent size passed to
offset_from_vma when reading DT_HASH header.  Formatting.

5 months ago[gdb/testsuite] Fix gdb.cp/non-trivial-retval.exp on arm-linux with gcc 13
Tom de Vries [Mon, 20 Jan 2025 04:41:01 +0000 (05:41 +0100)] 
[gdb/testsuite] Fix gdb.cp/non-trivial-retval.exp on arm-linux with gcc 13

On arm-linux, with target board unix/-mthumb, we get:
...
(gdb) PASS: gdb.cp/non-trivial-retval.exp: continue to breakpoint: Break here
p f1 (i1, i2)^M
$1 = {a = -136274256}^M
(gdb) FAIL: gdb.cp/non-trivial-retval.exp: gdb-command<p f1 (i1, i2)>
...

This is not a problem with the inferior call, which works fine:
...
(gdb) p f1 (23, 100)
$3 = {a = 123}
...
but instead it's a problem with the location information:
...
(gdb) p i1
$1 = -136274356
(gdb) p i2
$2 = 100
...
which tells us to find the value of i1 in (DW_OP_fbreg: -12).

The test-case passes if we drop -fvar-tracking, in which case the debug info
tells us to find the value of i1 in (DW_OP_fbreg: -20).

This is with gcc 13.3.0 on Ubuntu 24.04.  With gcc 14.2.0 on Debian testing,
the code is the same, but -fvar-tracking does use the correct
'(DW_OP_fbreg: -20)'.

There seems to be some bugfix in -fvar-tracking for gcc 14.

Workaround the bug by using constants 23 and 100 instead of i1 and i2 when
using -fvar-tracking and gcc < 14.

Tested on arm-linux.

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

5 months agoAutomatic date update in version.in
GDB Administrator [Mon, 20 Jan 2025 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoreloc caching
Alan Modra [Mon, 13 Jan 2025 10:03:54 +0000 (20:33 +1030)] 
reloc caching

This arranges to free section relocs cached in elf_section_data.  To
do that, some relocs stored there need to use bfd_malloc buffers
rather than bfd_alloc ones.

* elf.c (_bfd_elf_free_cached_info): Free relocs.
* elf32-ppc.c (ppc_elf_relax_section): Realloc relocs rather
than malloc, copy, free old.
* elf64-ppc.c (get_relocs): bfd_malloc relocs.
* elflink.c (_bfd_elf_link_info_read_relocs): Always
bfd_malloc relocs.

5 months agosec->alloced and freeing section contents
Alan Modra [Sat, 11 Jan 2025 05:50:36 +0000 (16:20 +1030)] 
sec->alloced and freeing section contents

This modifies _bfd_elf_free_cached_info to unmap/free section
contents.  To do that we need to *not* free sections where contents
are bfd_alloc'd or point to constant strings or somesuch.  I've chosen
to implement this be adding another flag to struct bfd_section,
"alloced" to say the section contents can't be freed.  Most of the
patch is about setting that flag in many places.

5 months ago_bfd_elf_munmap_section_contents
Alan Modra [Sun, 12 Jan 2025 04:03:33 +0000 (14:33 +1030)] 
_bfd_elf_munmap_section_contents

Do unmap/free cached contents to avoid some memory leaks we'd
otherwise see.

* elf.c (_bfd_elf_munmap_section_contents): Clear pointers to
contents that we unmap/free rather than not unmapping/freeing.

5 months agoReplace xmalloc with stat_alloc in ld parser
Alan Modra [Sat, 11 Jan 2025 05:49:09 +0000 (16:19 +1030)] 
Replace xmalloc with stat_alloc in ld parser

A few place dealing with ld script handling made some attempt to free
memory, but this was generally ignored and would be quite a lot of
work to implement.  Instead, use the stat_obstack rather than
mallocing in many more cases.

* ldexp.c (exp_get_fill): Use stat_alloc for fill.
* ldfile.c (ldfile_try_open_bfd): Don't free yylval fields.
* ldgram.y: Replace xmalloc with stat_alloc throughout.
* ldlang.c (stat_memdup, stat_strdup): New functions.
(ldirname): Use stat_memdup.  Don't strdup ".".
(output_section_callback_sort): Use stat_alloc.
(output_section_callback_tree_to_list): Don't free.
(lang_memory_region_lookup): Use stat_strdup.
(lang_memory_region_alias): Likewise.
(add_excluded_libs): Use stat_alloc and stat_memdup.
(ldlang_add_undef, ldlang_add_require_defined): Use stat_strdup.
(lang_add_nocrossref, lang_leave_overlay): Use stat_alloc.
(realsymbol): Use stat_strdup for return value and always
free symbol.
(lang_new_vers_pattern, lang_new_vers_node): Use stat_alloc.
(lang_finalize_version_expr_head): Don't free.  Delete FIXME.
(lang_register_vers_node): Don't free.
(lang_add_vers_depend): Use stat_alloc.
(lang_do_version_exports_section): Likewise.
(lang_add_unique): Use stat_alloc and stat_strdup.
(lang_append_dynamic_list): Use stat_alloc.
* ldlang.h (stat_memdup, stat_strdup): Declare.
* ldlex.l: Replace xstrdup with stat_strdup throughout.
Replace xmemdup with stat_memdup too.
* lexsup.c (parse_args): Don't free export list or dynamic
list.

5 months agoUse stat_alloc in plugin
Alan Modra [Thu, 16 Jan 2025 12:27:43 +0000 (22:57 +1030)] 
Use stat_alloc in plugin

We never free the tv array.

* plugin.c (plugin_load_plugins): Use stat_alloc.

5 months agoChange version to 2.44.50 and regenerate files
Nick Clifton [Sun, 19 Jan 2025 12:40:46 +0000 (12:40 +0000)] 
Change version to 2.44.50 and regenerate files

5 months agoAdd name of 2.44 branch
Nick Clifton [Sun, 19 Jan 2025 12:09:35 +0000 (12:09 +0000)] 
Add name of 2.44 branch

5 months agoAdd markers for bihnutils 2.44 branch
Nick Clifton [Sun, 19 Jan 2025 12:09:01 +0000 (12:09 +0000)] 
Add markers for bihnutils 2.44 branch

5 months agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Jan 2025 00:00:43 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoRe: binary outsymbols
Alan Modra [Sat, 18 Jan 2025 00:25:22 +0000 (10:55 +1030)] 
Re: binary outsymbols

The "of course to free outsymbols" turned out to be wrong.  outsymbols
belongs to objcopy which frees them, so commit 6ca01b0bdd59 introduced
a double free.

* srec.c (srec_write_symbols): Don't free outsymbols.
* tekhex.c (tekhex_write_object_contents): Likewise.

5 months agoAutomatic date update in version.in
GDB Administrator [Sat, 18 Jan 2025 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoSimplify get_frame_unwind_table
Tom Tromey [Fri, 17 Jan 2025 19:01:38 +0000 (12:01 -0700)] 
Simplify get_frame_unwind_table

This simplifies get_frame_unwind_table, changing it to use the
registry 'emplace' method and to pass the initialization iterators to
the constructor.  This fixes a build problem on x86 -- reported by the
auto-builder -- as a side effect.

Tested-By: Guinevere Larsen <guinevere@redhat.com>
5 months agogdb/reverse: Fix recording vmov[u|a]p[s|d] instructions
Guinevere Larsen [Wed, 15 Jan 2025 20:32:23 +0000 (17:32 -0300)] 
gdb/reverse: Fix recording vmov[u|a]p[s|d] instructions

Tom de Vries reported that some of the test for the vmov[u|a]p[s|d] were
failing. In my machine xmm3 was consistently set to 0x54, but apparently
that is different depending on the system. This commit zeroes out xmm3
at the start of the test instead.

While debugging the test failures, I also noticed an issue where the
recording wasn't saving all the required memory. That happened because
vmovs[s|d] shares its opcode with vmovap[s|d], meaning they seem to
share code paths, but the latter encodes memory modification size on
VEX.L whereas the former encodes in VEX.pp. So this commit fixed that,
and made the relevant tests more robust and complete.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32561
Approved-By: Guinevere Larsen <guinevere@redhat.com>
5 months agoFix self-test crash
Tom Tromey [Fri, 17 Jan 2025 17:49:24 +0000 (10:49 -0700)] 
Fix self-test crash

My earlier changes introduced a self-test crash.  This patch fixes the
bug by introducing a new method overload into mock_mapped_index.

5 months agogdb/doc: some more details in the README file
Andrew Burgess [Sat, 12 Oct 2024 10:08:04 +0000 (11:08 +0100)] 
gdb/doc: some more details in the README file

After some recent discussions on the mailing list, I've made some
changes to the README to (I hope) provide more clarity.

The changes I made are:

  1. Removed the use of a lone 'HOST' on the configure line.  I tried
  this and 'configure' gave me a warning:

    configure: WARNING: you should use --build, --host, --target

  So I don't think this is approved practice any more.  We should
  encourage users to use `--host` instead.

  2. Added and reworded the --host, --target, and --enable-targets
  descriptions in the 'configure options' section.  My goals here are
  to clarify that 'cross-debugging' is really the same as 'remote
  debugging', and also to make it clearer what the defaults are.

  3. Added some additional text to the 'Remote debugging' section
  mentioning that 'remote debugging' is basically the same as 'cross
  debugging', given that we use 'cross-debugging' in the text above.

Reviewed-By: Keith Seitz <keiths@redhat.com>
5 months agogdb: quote inferior arguments, if needed, when opening a core file
Andrew Burgess [Wed, 15 Jan 2025 11:12:46 +0000 (11:12 +0000)] 
gdb: quote inferior arguments, if needed,  when opening a core file

This commit fixes an issue with the commit:

  commit d3d13bf876aae425ae0eff2ab0f1af9f7da0264a
  Date:   Thu Apr 25 09:36:43 2024 +0100

      gdb: add gdbarch method to get execution context from core file

The above commit improves GDB's ability to display inferior arguments
when opening a core file, however, if an argument includes white
space, then this is not displayed as well as it should be.  For
example:

  (gdb) core-file /tmp/corefile-exec-context.2.core
  [New LWP 4069711]
  Reading symbols from /tmp/corefile-exec-context...
  Core was generated by `/tmp/corefile-exec-context aaaaa bbbbb ccccc ddddd e e e e e'.
  Program terminated with signal SIGABRT, Aborted.
  #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
  50   return ret;
  (gdb) show args
  Argument list to give program being debugged when it is started is "aaaaa bbbbb ccccc ddddd e\ e\ e\ e\ e".
  (gdb)

Notice the 'Core was generated by ...' line.  In this case it is not
clear if the "e e e e e" is a single argument containing white space,
or 5 single arguments.

But when we 'show args' it is immediately clear that this is a single
argument, as the white space is now escaped.

This problem was caused by the above commit building the argument
string itself, and failing to consider white space escaping.

This commit changes things around, first we place the arguments into
the inferior, then, to print the 'Core was generated by ...' line, we
ask the inferior for the argument string.  In this way the quoting is
handled just as it is for 'show args'.  The initial output is now:

  (gdb) core-file /tmp/corefile-exec-context.2.core
  [New LWP 4069711]
  Reading symbols from /tmp/corefile-exec-context...
  Core was generated by `/tmp/corefile-exec-context aaaaa bbbbb ccccc ddddd e\ e\ e\ e\ e'.
  Program terminated with signal SIGABRT, Aborted.
  #0  0x00007f4f007af625 in raise () from /lib64/libc.so.6
  (gdb)

Much better.  The existing test is extended to cover this case.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
5 months agogprofng: update binutils/NEWS for 2.44
Vladimir Mezentsev [Fri, 17 Jan 2025 04:41:42 +0000 (20:41 -0800)] 
gprofng: update binutils/NEWS for 2.44

ChangeLog
2025-01-16  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* binutils/NEWS: Updated.

5 months agogprofng: fix Segmentation Fault in DbeInstr::mapPCtoLine
Vladimir Mezentsev [Fri, 17 Jan 2025 04:29:34 +0000 (20:29 -0800)] 
gprofng: fix Segmentation Fault in DbeInstr::mapPCtoLine

The bug was filed against gprofng-gui (https://savannah.gnu.org/bugs/?66560).

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

* src/Hist_data.cc (DbeInstr::mapPCtoLine): Check for null pointer.

5 months agoaarch64: Fix sve2p1 gating and add missing instructions
Andrew Carlotti [Thu, 16 Jan 2025 02:34:44 +0000 (02:34 +0000)] 
aarch64: Fix sve2p1 gating and add missing instructions

Many FEAT_SVE2p1 instructions need to be enabled by either of two
different features (one for streaming mode, and one for non-streaming
mode).  This patch adds correct gating conditions for these
instructions.

There were also a few sve2p1 instructions missing altogether, so add
those as well.

The testsuite is modified to check for all alternative enablement
conditions.  In many cases this is done by adding an alternative
assembler commands to existing test files.  For some SME/SME2 tests,
only some of the instructions are enabled by +sve2p1, so these are
copied into a separate test.  For original SVE2p1 tests, the non-SME2p1
instructions have been moved to a separate test file.

There are also new tests for the newly added instructions.  These
include a couple of fixme comments relating to bad error reporting,
which should be investigated later.

5 months agoRemove mapped_index_base
Tom Tromey [Wed, 15 Jan 2025 23:18:15 +0000 (16:18 -0700)] 
Remove mapped_index_base

The base class mapped_index_base is no longer needed.  Previously it
was used by both the .gdb_index and .debug_names readers, but the
latter now uses the cooked index instead.

This patch removes mapped_index_base, merging it into
mapped_gdb_index.  Supporting code that is specific to .gdb_index is
also moved into read-gdb-index.c.  This shrinks dwarf2/read.c a bit,
which is nice.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32504
Approved-By: Andrew Burgess <aburgess@redhat.com>
5 months agoRemove gdb_index_unpack
Tom Tromey [Wed, 15 Jan 2025 23:18:29 +0000 (16:18 -0700)] 
Remove gdb_index_unpack

gdb_index_unpack is not used and can be removed.  The include of
extract-store-integer.h is also no longer needed by this file.

Approved-By: Andrew Burgess <aburgess@redhat.com>
5 months agoAdd missing includes of extract-store-integer.h
Tom Tromey [Thu, 16 Jan 2025 12:56:04 +0000 (05:56 -0700)] 
Add missing includes of extract-store-integer.h

I found a number of .c files that need to include
extract-store-integer.h but that were only including it indirectly.
This patch adds the missing includes.  This change enables the next
patch.

Approved-By: Andrew Burgess <aburgess@redhat.com>
5 months agogdb/testsuite: Test for a backtrace through object without debuginfo
Guinevere Larsen [Thu, 14 Mar 2024 15:14:29 +0000 (16:14 +0100)] 
gdb/testsuite: Test for a backtrace through object without debuginfo

Fedora has been carrying this test since back in the Project Archer
days. A change back then caused GDB to stop being able to backtrace when
only some of the object files had debug information. Even though the
changed code never seems to have made its way into the main GDB project,
I think it makes sense to bring the test along to ensure something like
this doesn't pass unnoticed.

Co-Authored-By: Jan Kratochvil <jan@jankratochvil.net>
Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
5 months agogdb: introduce ability to disable frame unwinders
Guinevere Larsen [Thu, 14 Mar 2024 15:14:28 +0000 (16:14 +0100)] 
gdb: introduce ability to disable frame unwinders

Sometimes, in the GDB testsuite, we want to test the ability of specific
unwinders to handle some piece of code. Usually this is done by trying
to outsmart GDB, or by coercing the compiler to remove information that
GDB would rely on.  Both approaches have problems as GDB gets smarter
with time, and that compilers might differ in version and behavior, or
simply introduce new useful information. This was requested back in 2003
in PR backtrace/8434.

To improve our ability to thoroughly test GDB, this patch introduces a
new maintenance command that allows a user to disable some unwinders,
based on either the name of the unwinder or on its class. With this
change, it will now be possible for GDB to not find any frame unwinders
for a given frame, which would previously cause GDB to assert. GDB will
now check if any frame unwinder has been disabled, and if some has, it
will just error out instead of asserting.

Unwinders can be disabled or re-enabled in 3 different ways:
* Disabling/enabling all at once (using '-all').
* By specifying an unwinder class to be disabled (option '-class').
* By specifying the name of an unwinder (option '-name').

If you give no options to the command, GDB assumes the input is an
unwinder class. '-class' would make no difference if used, is just here
for completeness.

This command is meant to be used once the inferior is already at the
desired location for the test. An example session would be:

(gdb) start
Temporary breakpoint 1, main () at omp.c:17
17          func();
(gdb) maint frame-unwinder disable ARCH
(gdb) bt
\#0  main () at omp.c:17
(gdb) maint frame-unwinder enable ARCH
(gdb) cont
Continuing.

This commit is a more generic version of commit 3c3bb0580be0,
and so, based on the final paragraph of the commit message:
    gdb: Add switch to disable DWARF stack unwinders
<...>
    If in the future we find ourselves adding more switches to disable
    different unwinders, then we should probably move to a more generic
    solution, and remove this patch.
this patch also reverts 3c3bb0580be0

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=8434
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
temp adding completion

5 months agogdb: Migrate frame unwinders to use C++ classes
Guinevere Larsen [Thu, 14 Mar 2024 15:14:27 +0000 (16:14 +0100)] 
gdb: Migrate frame unwinders to use C++ classes

Frame unwinders have historically been a structure populated with
callback pointers, so that architectures (or other specific unwinders)
could install their own way to handle the inferior. However, since
moving to C++, we could use polymorphism to get the same functionality
in a more readable way. Polymorphism also makes it simpler to add new
functionality to all frame unwinders, since all that's required is
adding it to the base class.

As part of the changes to add support to disabling frame unwinders,
this commit makes the first baby step in  using polymorphism for the
frame unwinders, by making frame_unwind a virtual class, and adds a
couple of new classes. The main class added is frame_unwind_legacy,
which works the same as the previous structs, using function pointers
as callbacks. This class was added to allow the transition to happen
piecemeal. New unwinders should instead follow the lead of the other
classes implemented.

2 of the others, frame_unwind_python and frame_unwind_trampoline, were added
because it seemed simpler at the moment to do that instead of reworking
the dynamic allocation to work with the legacy class, and can be used as
an example to future implementations.

Finally, the cygwin unwinder was converted to a class since it was most
of the way there already.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
5 months agogdb: add "unwinder class" to frame unwinders
Guinevere Larsen [Thu, 14 Mar 2024 15:14:26 +0000 (16:14 +0100)] 
gdb: add "unwinder class" to frame unwinders

A future patch will add a way to disable certain unwinders based on
different characteristics. This patch aims to make it more convenient
to disable related unwinders in bulk, such as architecture specific
ones, by identifying all unwinders by which part of the code adds it.
The classes, and explanations, are as follows:

* GDB: An internal unwinder, added by GDB core, such as the unwinder
  for dummy frames;
* EXTENSION: Unwinders added by extension languages;
* DEBUGINFO: Unwinders installed by the debug info reader;
* ARCH: Unwinders installed by the architecture specific code.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
5 months agogdb: make gdbarch store a vector of frame unwinders
Guinevere Larsen [Thu, 14 Mar 2024 15:14:25 +0000 (16:14 +0100)] 
gdb: make gdbarch store a vector of frame unwinders

Before this commit, all frame unwinders would be stored in the obstack
of a gdbarch and accessed by using the registry system. This made for
unwieldy code, and unnecessarily complex logic in the frame_unwinder
implementation, along with making frame_unwind structs be unable to have
non-trivial destructors.

Seeing as a future patch of this series wants to refactor the
frame_unwind struct to use inheritance, and we'd like to not restrict
the future derived classes on what destructors are allowed. In
preparation for that change, this commit changes the registry in gdbarch
to instead store an std::vector, which doesn't require using an obstack
and doesn't rely on a linked list.

There should be no user-visible changes.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
5 months agox86: Add CpuGMISM2 and CpuGMICCS
MayShao-oc [Fri, 17 Jan 2025 14:33:59 +0000 (15:33 +0100)] 
x86: Add CpuGMISM2 and CpuGMICCS

There are separate CPUID feature bits for SM2 and CCS instructions.
CCS is the acronym of Chinese Cipher System, it includes SM3 and SM4
instructions. This patch adds CpuGMISM2 and CpuGMICCS to replace CpuGMI on
corresponding instructions.

gas/ChangeLog:

* config/tc-i386.c: Add gmism2 and gmiccs to replace gmi.
* doc/c-i386.texi: Ditto.

opcodes/ChangeLog:

* i386-gen.c: Add GMISM2 and GMICCS to replace GMI.
* i386-opc.h (enum i386_cpu): Add  CpuGMISM2 and CpuGMICCS to
  replace CpuGMI.
* i386-opc.tbl: Replace GMI with GMISM2 on sm2 instruction. Replace GMI
  with GMICCS on sm3 and sm4 instructions.
* i386-tbl.h: Regenerated.
* i386-mnem.h: Ditto.
* i386-init.h: Ditto.

5 months agoLoongArch: Allocate GOT entry for TLS DESC when -mno-relax is enabled
Lulu Cai [Tue, 14 Jan 2025 13:13:01 +0000 (21:13 +0800)] 
LoongArch: Allocate GOT entry for TLS DESC when -mno-relax is enabled

The type transition of TLSDESC is only done when -mrelax is enabled.
So when -mno-relax is enabled, keep GOT_TLS_GDESC to allocate the
GOT entry instead of just keeping GOT_TLS_IE.

5 months agoSync config.guess and config.sub with latest versions from the config project.
Nick Clifton [Fri, 17 Jan 2025 10:17:57 +0000 (10:17 +0000)] 
Sync config.guess and config.sub with latest versions from the config project.

5 months agox86/APX: convert runtime special case to build-time one
Jan Beulich [Fri, 17 Jan 2025 09:28:15 +0000 (10:28 +0100)] 
x86/APX: convert runtime special case to build-time one

cpu_flags_match() is a hot path. Move the special casing that
b7267244a355 ("Support Intel AMX-MOVRS") added there to i386-gen, thus
affecting only build time performance.

5 months agox86: have .insn correctly consider AVX10.2's 256-bit embedded rounding
Jan Beulich [Fri, 17 Jan 2025 09:27:54 +0000 (10:27 +0100)] 
x86: have .insn correctly consider AVX10.2's 256-bit embedded rounding

Deriving operand size may no longer assume 512-bit vector size when
embedded rounding is in use. In fact it was apparently wrong to do so
in the first place, as that's not correct for scalar insns. Drop the
rounding type check altogether; we fall back to EVEX.LIG when no
suitable operand was specified anyway, later in the function (and, btw,
similarly for VEX encodings).

5 months agoRISC-V: PR32499, Fix PR18841 segfault caused by ifunc relocation ordering
Nelson Chu [Tue, 14 Jan 2025 06:16:48 +0000 (14:16 +0800)] 
RISC-V: PR32499, Fix PR18841 segfault caused by ifunc relocation ordering

Even though the relocation isn't IRELATIVE, it still should be come last if
refering to ifunc symbol.  In order to get the ifunc relocs properly sorted
the correct class needs to be returned.  The code mimics what has been done
for x86, sparc, aarch64 and arm32.

bfd/
PR 18841
PR 32499
* elfnn-riscv.c (riscv_reloc_type_class): Handle ifunc relocation
ordering, even though it's not IRELATIVE, it still should be come
last if refering ifunc symbol.

5 months agocmdline_add_object_only_section leak
Alan Modra [Fri, 17 Jan 2025 00:20:51 +0000 (10:50 +1030)] 
cmdline_add_object_only_section leak

Free ofilename on error path.  Don't bother testing "if (foo)" before
"free (foo)".

5 months agobuffer overflow in cmdline_add_object_only_section
Alan Modra [Fri, 17 Jan 2025 08:30:41 +0000 (19:00 +1030)] 
buffer overflow in cmdline_add_object_only_section

Seen running ld-plugin/lto-4r-c on x86_64-w64-mingw32

* ldlang.c (cmdline_add_object_only_section): Allocate one more
for output symbol buffer.

5 months agoSilence asan warnings in resolve_symbol_value
Alan Modra [Fri, 17 Jan 2025 07:27:48 +0000 (17:57 +1030)] 
Silence asan warnings in resolve_symbol_value

The ".quad with division (fwdref)" gas test fails with asan warning
negation of -9223372036854775808 cannot be represented in type 'long int'
Fix this and another similar case.

* symbols.c (resolve_symbol_value): Cast "left" to valueT
before negating.

5 months agold: Load the object only section when opening the mixed object file
H.J. Lu [Thu, 16 Jan 2025 23:22:04 +0000 (07:22 +0800)] 
ld: Load the object only section when opening the mixed object file

Load the object only section when opening the mixed object file, instead
of loading it after all other input files have been loaded. This fixed

.../ld/collect-ld: /tmp/ccZAoUIW.obj-only.o: in function `main':
.../ld/testsuite/ld-plugin/lto-10a.c:4: multiple definition of `main'; /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o):(.text.startup+0x0): first defined here
.../ld/collect-ld: /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o):(.text.startup+0xc5): undefined reference to `WinMain'
collect2: error: ld returned 1 exit status
...
FAIL: LTO 10

for x86_64-w64-mingw32 so that mixing LTO and non-LTO relocatable files
for "ld -r" works for both ELF and non-ELF platforms.

* ld.texi: Remove "On ELF platforms" from documentation of mixing
LTO and non-LTO relocatable files for "ld -r".
* ldlang.c (cmdline_load_object_only_section): New.
(cmdline_check_object_only_section): Call it.
* testsuite/ld-plugin/lto.exp: Enable mixed LTO and non-LTO
relocatable output tests for all.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 months agobuffer overflow in score_elf_create_dynamic_relocation
Alan Modra [Fri, 17 Jan 2025 05:25:12 +0000 (15:55 +1030)] 
buffer overflow in score_elf_create_dynamic_relocation

score_elf_create_dynamic_relocation sets up three output dynamic
relocs from rel[0], rel[1] and rel[2].  When rel[0] is the last reloc
in a section this of course results in a buffer overflow.  It's a
weird thing to do given that only one relocation is output.

* elf32-score.c (score_elf_create_dynamic_relocation): Do not
set up three dynamic relocations when only one is output.
* elf32-score7.c: Likewise.

5 months agobuffer overflow in mmix_elf_relocate_section
Alan Modra [Fri, 17 Jan 2025 04:11:39 +0000 (14:41 +1030)] 
buffer overflow in mmix_elf_relocate_section

* elf64-mmix.c (mmix_elf_relocate_section): Correct size of
relocs shuffled by memmove.

5 months agoxtensa unnecessary free
Alan Modra [Thu, 16 Jan 2025 23:13:34 +0000 (09:43 +1030)] 
xtensa unnecessary free

No path to "cleanup" label has internal_relocs malloc'd.

* emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Don't
free internal_relocs in cleanup.

5 months agoRISC-V: Added lost zcmt in gas imply testcase.
Nelson Chu [Fri, 17 Jan 2025 04:30:00 +0000 (12:30 +0800)] 
RISC-V: Added lost zcmt in gas imply testcase.

5 months agogas/NEWS: Updated risc-v assembler support in 2.44.
Nelson Chu [Fri, 17 Jan 2025 04:20:30 +0000 (12:20 +0800)] 
gas/NEWS: Updated risc-v assembler support in 2.44.

5 months agoRISC-V: Use t2 for tail if Zicfilp enabled
Kito Cheng [Fri, 17 Jan 2025 01:53:01 +0000 (09:53 +0800)] 
RISC-V: Use t2 for tail if Zicfilp enabled

This change is to make tail conform with software guarded jump of Zicfilp. The
reason to not choose t1 as the label register is that t1 is also as .got.plt
offset of _dl_runtime_resolve in PLT.

See more: https://github.com/riscv-non-isa/riscv-asm-manual/pull/93

5 months agoRISC-V: Support CFI Zicfiss and Zicfilp instructions and CSR.
Monk Chiang [Fri, 17 Jan 2025 01:53:00 +0000 (09:53 +0800)] 
RISC-V: Support CFI Zicfiss and Zicfilp instructions and CSR.

https://github.com/riscv/riscv-cfi/releases/tag/v1.0

This patch only support the CFI instructions and CSR in assembler.

5 months agoRISC-V: Support ssctr/smctr extensions with version 1.0.
Nelson Chu [Tue, 18 Jun 2024 04:48:26 +0000 (12:48 +0800)] 
RISC-V: Support ssctr/smctr extensions with version 1.0.

https://github.com/riscv/riscv-control-transfer-records/releases/tag/v1.0

The privileged spec v1.10 already removed the sfence.vm instruction, and the
encoding of sfence.vm instruction is overlapped with the sctrclr instruction
of ssctr/smctr.  But since the privileged spec v1.10 already removed the
sfence.vm, and we no longer support the privileged spec v1.9.1 for now, we
had to remove the sfence.vm.

bfd/
* elfxx-riscv.c (riscv_implicit_subsets): Imply zicsr for ssctr/smctr.
(riscv_supported_std_s_ext): Added ssctr/smctr with version 1.0.
(riscv_multi_subset_supports): Handle INSN_CLASS for ssctr/smctr.
(riscv_multi_subset_supports_ext): Likewise.
gas/
* config/tc-riscv.c (enum riscv_csr_class, riscv_csr_address):
Added and handle CSR_CLASS_SSCTR and CSR_CLASS_SMCTR.
(riscv_is_priv_insn): Removed SFENCE_VM check.
* testsuite/gas/riscv/attribute-14e.d: Removed since sfence.vm is no
longer supported since privileged spec v1.10.
* testsuite/gas/riscv/attribute-14.s: Likewise.
* testsuite/gas/riscv/csr-version-1p10.d: Updated for ssctr/smctr CSRs.
* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
* testsuite/gas/riscv/csr-version-1p11.d: Likewise.
* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
* testsuite/gas/riscv/csr-version-1p12.d: Likewise.
* testsuite/gas/riscv/csr-version-1p12.l: Likewise.
* testsuite/gas/riscv/csr.s: Likewise.
* testsuite/gas/riscv/csr-dw-regnums.d: Likewise.
* testsuite/gas/riscv/csr-dw-regnums.s: Likewise.
* testsuite/gas/riscv/march-help.l: Updated for ssctr/smctr.
* testsuite/gas/riscv/smctr-ssctr.d: New testcase for sctr instruction.
* testsuite/gas/riscv/smctr-ssctr.s: Likewise.
include/
* opcode/riscv-opc.h: Added encoding macro for sctrclr, but removed
encoding macro for sfence.vm since encoding conflict.  Added CSR
numbers for ssctr/smctr CSRs.
* opcode/riscv.h (enum riscv_insn_class): Added
INSN_CLASS_SMCTR_OR_SSCTR for sctrclr.
opcodes/
* riscv-opc.c (riscv_opcodes): Added sctrclr, but removed sfence.vm
since encoding conflict.

5 months agogprofng: don't check Elf when file is in archive
Vladimir Mezentsev [Thu, 16 Jan 2025 03:42:43 +0000 (19:42 -0800)] 
gprofng: don't check Elf when file is in archive

map.xml contains a checksum for all Elf files.
gprofng-archive archives a file only with the same checksum.
In gprofng-display-text no additional check is required.

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

* src/parse.cc: Don't check Elf when file is in archive.

5 months agoRe: ld parser buffer leak
Alan Modra [Fri, 17 Jan 2025 03:53:43 +0000 (14:23 +1030)] 
Re: ld parser buffer leak

Apparently reflex doesn't have yyalloc.

* ldlex.l (yy_create_string_buffer): Revert last change.

5 months agox86: Ignore rounding for vcvt[,u]si2sd under r32 and vcvt[,u]dq2pd instead of reporti...
Haochen Jiang [Tue, 14 Jan 2025 08:18:50 +0000 (16:18 +0800)] 
x86: Ignore rounding for vcvt[,u]si2sd under r32 and vcvt[,u]dq2pd instead of reporting bad for disassembler

According to SDM, vcvt[,u]si2sd under r32 and vcvt[,u]dq2pd treat
Rounding as Ignored when trying to using them. Thus, disassembler
should accept bytecode with rounding instead of reporting bad.

For assembler, it needs some more time to decide how to deal
with that.

gas/ChangeLog:

* testsuite/gas/i386/evex.d: Add new testcase for vcvt[,u]dq2pd.
Change the output for vcvt[,u]si2sd.
* testsuite/gas/i386/evex.s: Ditto.
* testsuite/gas/i386/x86-64-evex.d: Ditto.

opcodes/ChangeLog:

* i386-dis-evex-w.h: Add EXxEVexR64 for vcvt[,u]dq2pd.
* i386-dis.c (OP_Rounding): Mark EVEX_b as used to change the handle
for ignored rounding.

5 months agoAutomatic date update in version.in
GDB Administrator [Fri, 17 Jan 2025 00:00:28 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoplugin_get_ir_dummy_bfd leak
Alan Modra [Sat, 11 Jan 2025 05:47:20 +0000 (16:17 +1030)] 
plugin_get_ir_dummy_bfd leak

* plugin.c (plugin_get_ir_dummy_bfd): Free bfd filename.

5 months agold parser buffer leak
Alan Modra [Sat, 11 Jan 2025 05:46:14 +0000 (16:16 +1030)] 
ld parser buffer leak

* ldlex.l (<<EOF>>): yy_delete_buffer current.
(yy_create_string_buffer): Use yyalloc.

5 months agowrite_build_id and write_package_metadata leaks
Alan Modra [Sat, 11 Jan 2025 05:43:51 +0000 (16:13 +1030)] 
write_build_id and write_package_metadata leaks

There isn't much sense in stashing contents in sec->contents
after those contents have been written.

* ldelf.c (write_build_id): Don't assign sec->contents.
Free contents if malloc'd here.
(write_package_metadata): Likewise.

5 months agoldelf_search_needed leak
Alan Modra [Sat, 11 Jan 2025 05:42:42 +0000 (16:12 +1030)] 
ldelf_search_needed leak

* ldelf.c (ldelf_search_needed): Free filename before returning.

5 months agofree ldfile search paths
Alan Modra [Sat, 11 Jan 2025 05:35:06 +0000 (16:05 +1030)] 
free ldfile search paths

* ldfile.c (ldfile_remap_input_free): Make static, call from..
(ldfile_free): ..here.  New function.
(ldfile_library_path_free, ldfile_script_free),
( ldfile_arch_free): New functions.
(ldfile_find_command_file): Free script_dir.  Move
script_search to file scope.
(ldfile_open_command_file_1): Delete FIXME comment.
* ldfile.h (ldfile_remap_input_free): Delete.
(ldfile_free): Declare.
* ldlang.c (lang_finish): Update.

5 months agooutput_section_statement leak
Alan Modra [Sat, 11 Jan 2025 05:30:55 +0000 (16:00 +1030)] 
output_section_statement leak

This frees output_section_statement data, which is currently only used
by elf targets but doing so for all targets is simpler and more
future proof than adding ths to ldelf_finish.  (Doing it there
requires moving the function to ldelfgen.c.)

* ldemul.c (finish_default): Free os->data.

5 months agoNEWS: Mention mixed LTO and non-LTO output support for ld -r
H.J. Lu [Thu, 16 Jan 2025 10:58:29 +0000 (18:58 +0800)] 
NEWS: Mention mixed LTO and non-LTO output support for ld -r

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 months agoCopy gcc commit e76df3586417d645dd84e8a1ab165605a8924796 to sourceware
Nick Clifton [Thu, 16 Jan 2025 15:51:52 +0000 (15:51 +0000)] 
Copy gcc commit e76df3586417d645dd84e8a1ab165605a8924796  to sourceware

5 months agoHave readelf sanitize the program interpreter string before displaying it.
Nick Clifton [Thu, 16 Jan 2025 15:48:40 +0000 (15:48 +0000)] 
Have readelf sanitize the program interpreter string before displaying it.

5 months ago[gdb/testsuite] Fix gdb.dwarf2/implptr.exp regression
Tom de Vries [Thu, 16 Jan 2025 14:00:11 +0000 (15:00 +0100)] 
[gdb/testsuite] Fix gdb.dwarf2/implptr.exp regression

When running test-case gdb.dwarf2/implptr.exp on target board unix/-m32, we
get:
...
(gdb) PASS: gdb.dwarf2/implptr.exp: print ***l in implptr:bar
break implptr.c:34^M
No compiled code for line 34 in file "implptr.c".^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) FAIL: $exp: set baz breakpoint for implptr (got interactive prompt)
...

This is a regression since commit dcaa85e58c4 ("gdb: reject inserting
breakpoints between functions").

The .debug_line info does not contain an entry with a line number lower than
36, so gdb cannot map it to an address.

Fix this by setting a breakpoint at the function containing line 34 instead.

Tested on x86_64-linux.

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