Commit Graph

120714 Commits

Author SHA1 Message Date
Clément Chigot
7edefdf710 ld/testsuite: move board flags to ld_link
Both CFLAGS and LDFLAGS provided by dejagnu board configuration could be
required to perform a link.

Up to now, those flags were pulled with run_cc_link_tests and
run_ld_link_exec_tests and then passed to ld_link process as arguments.
This means that calling `ld_link` outside those functions must remember
to manually pass them.
2025-01-06 14:01:09 +01:00
Clément Chigot
e88c452e6f ld/testsuite/lto: replace manual links by ld_link helper
Some tests are calling run_host_cmd in order to retrieve the
errors/warnings messages generated.
ld_link is also making them available through exec_output global
variable but as the advantages of taking the board configuration into
account unlike run_host_cmd.
2025-01-06 14:01:09 +01:00
Clément Chigot
05dce2c841 ld/testsuite: centralize board_cflags and board_ldflags
Those flags are retrieving the CFLAGS or LDFLAGS defined by the dejagnu
board. The same pattern was repeated many times.
2025-01-06 14:01:09 +01:00
Tom de Vries
a189db13c4 [gdb/build] Use const_cast in fd_copy
Recent commit 6ab5d62ebc ("[gdb] Fix compilation error in event-top.c") did:
...
 fd_copy (fd_set *dst, const fd_set *src, int n)
 {
   FD_ZERO (dst);
   for (int i = 0; i < n; ++i)
-    if (FD_ISSET (i, src))
+    if (FD_ISSET (i, (fd_set *)src))
...
but according to [1] only const_cast may be used to cast away constness.

Fix this by using const_cast.

Tested by rebuilding on x86_64-linux.

[1] https://en.cppreference.com/w/cpp/language/const_cast
2025-01-06 09:53:26 +01:00
Alan Modra
f832531609 ar and foreign object files
ar is supposed to make archives containing any sort of file, and it
generally does that.  It also tries to make archives suited to target
object files stored.  Some targets have peculiar archives.

In one particular case we get into trouble trying to suit archives to
object files: where the target object file is recognised but that
target doesn't happen to support archives, and the default target has
a special archive format.  For example, we'll get failures on
rs6000-aix if trying to add tekhex objects to a new archive.  What
happens in that the tekhex object is recognised and its target vector
used to create an empty archive, ie. with _bfd_generic_mkarchive and
_bfd_write_archive_contents.  An attempt is then made to open the
newly created archive.  The tekhex target vector does not have a
check_format function to recognise generic archives, nor as it happens
do any of the xcoff or other targets built for rs6000-aix.

It seems to me the simplest fix is to not use any target vector to
create archives where that vector can't also recognise them.  That's
what this patch does, and to reinforce that I've removed target vector
support for creating empty archives from such targets.

bfd/
	* i386msdos.c (i386_msdos_vec): Remove support for creating
	empty archives.
	* ihex.c (ihex_vec): Likewise.
	* srec.c (srec_vec, symbolsrec_vec): Likewise.
	* tekhex.c (tekhex_vec): Likewise.
	* wasm-module.c (wasm_vec): Likewise.
	* ptrace-core.c (core_ptrace_vec): Tidy.
	* targets.c (bfd_target_supports_archives): New inline function.
	* bfd-in2.h: Regenerate.
binutils/
	* ar.c (open_inarch): Don't select a target from the first
	object file that can't read archives.  Set output_filename
	earlier.
	* testsuite/binutils-all/ar.exp (thin_archive_with_nested):
	Don't repeat --thin test using T.
	(foreign_object): New test.
	* testsuite/binutils-all/tek1.obj,
	* testsuite/binutils-all/tek2.obj: New files.
2025-01-06 14:09:32 +10:30
Xiao Zeng
a61beb42b0 RISC-V: Eliminate redundant instruction macro
include/ChangeLog:

	* opcode/riscv.h: Eliminate redundant instruction macro M_j.

Signed-off-by: Xiao Zeng <zengxiao@eswincomputing.com>
2025-01-06 11:04:40 +08:00
GDB Administrator
6a83ffd4e9 Automatic date update in version.in 2025-01-06 00:00:37 +00:00
Tom Tromey
2cf6f57319 Some small cleanups in add_symbol_overload_list_qualified
This applies some more cleanups to add_symbol_overload_list_qualified,
consolidating calls to get_selected_block.

It also moves the symtab expansion call after the code that walks up
from the selected block, merging two loops.
2025-01-05 12:00:16 -07:00
Tom Tromey
64800e8954 Fix latent bug in Ada import symbol handling
The code in dwarf2/read.c:new_symbol that handles Ada 'import' symbols
has a bug.  It uses the current scope, which by default this is the
file scope -- even for a global symbol like:

 <1><1186>: Abbrev Number: 4 (DW_TAG_variable)
    <1187>   DW_AT_name        : (indirect string, offset: 0x1ad2): pkg__imported_var_ada
...
    <1196>   DW_AT_external    : 1

This disagrees with the scope computed by the DWARF indexer.

Now, IMO new_symbol and its various weirdness really has to go.  And,
ideally, this information would come from the indexer rather than
perhaps being erroneously recomputed.  But meanwhile, this patch fixes
the issue at hand.

This came up while working on another change that exposes the bug.

Reviewed-By: Tom de Vries <tdevries@suse.de>
2025-01-05 11:58:49 -07:00
GDB Administrator
05248f5ff0 Automatic date update in version.in 2025-01-05 00:00:26 +00:00
Tom de Vries
deea250ab6 [gdb/testsuite] Add gdb.python/py-commands-breakpoint.exp
A recent discussion about what commands are allowed during
gdb.Breakpoint.stop, made me wonder if there would be less restrictions if
we'd do those commands as part of a breakpoint command list instead.

Attribute gdb.Breakpoint.commands is a string with gdb commands, so I
tried implementing a new class PyCommandsBreakpoint, derived from
gdb.Breakpoint, that supports a py_commands method.

My original idea was to forbid setting PyCommandsBreakpoint.commands, and do:
...
    def py_commands(self):
        print("VAR: %d" % self.var)
        self.var += 1
	gdb.execute("continue")
...
but as it turns out 'gdb.execute("continue")' does not behave the same way as
continue.  I've filed PR python/32454 about this.

So the unsatisfactory solution is to first execute
PyCommandsBreakpoint.py_commands:
...
    def py_commands(self):
        print("VAR: %d" % self.var)
        self.var += 1
...
and then:
...
        self.commands = "continue"
...

I was hoping for a better outcome, but having done the work of writing this, I
suppose it has use as a test-case, perhaps also as an example of how to work
around PR python/32454.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32454
2025-01-04 12:10:42 +01:00
Tom de Vries
09859118ff [gdb/tdep] Fix gdb.base/finish-pretty.exp on s390x
On s390x-linux, with test-case gdb.base/finish-pretty.exp I ran into:
...
(gdb) finish
Run till exit from #0  foo () at finish-pretty.c:28
main () at finish-pretty.c:40
40	  return v.a + v.b;
Value returned has type: struct s. Cannot determine contents
(gdb) FAIL: $exp: finish foo prettyprinted function result
...

The function being finished is foo, which returns a value of type struct s.

The ABI [1] specifies:
- that the value is returned in a storage buffer allocated by the caller, and
- that the address of this buffer is passed as a hidden argument in r2.

GDB fails to print the value when finishing foo, because it doesn't know the
address of the buffer.

Implement the gdbarch_get_return_buf_addr hook for s390x to fix this.

This is based on ppc_sysv_get_return_buf_addr, the only other implementation
of gdbarch_get_return_buf_addr.  For readability I've factored out
dwarf_reg_on_entry.

There is one difference with ppc_sysv_get_return_buf_addr: only
NO_ENTRY_VALUE_ERROR is caught.  If this patch is approved, I intend to submit
a follow-up patch to fix this in ppc_sysv_get_return_buf_addr as well.

The hook is not guaranteed to work, because it attempts to get the value r2
had at function entry.

The hook can be called after function entry, and the ABI doesn't guarantee
that r2 is the same throughout the function.

Using -fvar-tracking adds debug information, which allows the hook to succeed
more often, and indeed after adding this to the test-case, it passes.

Do likewise in one more test-case.

Tested on s390x-linux.

Fixes:
- gdb.ada/finish-large.exp
- gdb.base/finish-pretty.exp
- gdb.base/retval-large-struct.exp
- gdb.cp/non-trivial-retval.exp
- gdb.ada/array_return.exp

AFAICT, I've also enabled the hook for s390 and from the ABI I get the
impression that it should work, but I haven't been able to test it.

[1] https://github.com/IBM/s390x-abi
2025-01-04 11:31:02 +01:00
Eli Zaretskii
d46fdacc09 [gdb/readline] Fix link error on MinGW due to missing 'alarm'
The previous solution used symbols that exist only in MinGW64.
  Add a stub implementation of 'alarm' for mingw.org's MinGW.
2025-01-04 12:19:55 +02:00
Eli Zaretskii
c1023d9567 [gdb/selftest] Fix 'help_doc_invariants' self-test
Running selftest help_doc_invariants.
  help doc broken invariant: command 'signal-event' help doc has over-long line
  Self test failed: self-test failed at unittests/command-def-selftests.c:121

  The reason is that doc string of 'signal-event' doesn't have
  newlines at end of its line.  Fix by adding newlines.
2025-01-04 12:13:04 +02:00
Eli Zaretskii
6ab5d62ebc [gdb] Fix compilation error in event-top.c
CXX    event-top.o
     In file included from d:\usr\include\winsock2.h:69,
		      from ./../gdbsupport/gdb_select.h:30,
		      from event-top.c:43:
     event-top.c: In function 'fd_set* fd_copy(fd_set*, const fd_set*, int)':
     event-top.c:1279:22: error: invalid conversion from 'const fd_set*' to 'fd_set*' [-fpermissive]
      1279 |     if (FD_ISSET (i, src))
	   |                      ^
	   |                      |
	   |                      const fd_set*
     d:\usr\include\winsock.h:164:50: note:   initializing argument 2 of 'int __FD_ISSET(SOCKET, fd_set*)'
       164 | __CRT_ALIAS int __FD_ISSET( SOCKET __fd, fd_set *__set )
	   |                                          ~~~~~~~~^~~~~

  Use an explicit type cast to prevent this.

      * gdb/event-top.c (fd_copy): Type-cast in call to FD_ISSET.
2025-01-04 12:09:12 +02:00
Tom de Vries
9e2d0e2f53 [gdb/cli] Warn about forced return from signal trampoline
The Linaro CI reported a regression on arm-linux in test-case
gdb.base/sigstep.exp following commit 7b46460a61 ("[gdb/symtab] Apply
workaround for PR gas/31115 a bit more") [1]:
...
(gdb) return^M
Make __default_sa_restorer return now? (y or n) n^M
Not confirmed^M
(gdb) FAIL: $exp: return from handleri: \
  leave signal trampoline (got interactive prompt)
...

After installing package glibc-debuginfo and adding --with-separate-debug-dir
to the configure flags, I managed to reproduce the FAIL.

The regression seems to be a progression in the sense that the function name
for the signal trampoline is found.

After reading up on the signal trampoline [2] and the return command [3], my
understanding is that forced returning from the signal trampoline is
potentially unsafe, given that for instance the process signal mask won't be
restored.

Fix this by:
- rather than using the name, using "signal trampoline" in the query, and
- adding a warning about returning from a signal trampoline,
giving us:
...
(gdb) return^M
warning: Returning from signal trampoline does not fully restore pre-signal \
  state, such as process signal mask.^M
Make signal trampoline return now? (y or n) y^M
87            dummy = 0; dummy = 0; while (!done);^M
(gdb) PASS: $exp: return from handleri: leave signal trampoline (in main)
...

Tested on x86_64-linux.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>

[1] https://linaro.atlassian.net/browse/GNU-1459
[2] https://man7.org/linux/man-pages/man2/sigreturn.2.html
[3] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Returning.html
2025-01-04 10:19:37 +01:00
Alan Modra
003ced705f ELF sec_info memory leaks
Use the bfd's objalloc memory so we don't need to free anything
attached to elf_section_data sec_info.  Other uses of sec_info that
need to allocate memory already use bfd_alloc.

	* elf-eh-frame.c (_bfd_elf_parse_eh_frame): bfd_alloc sec_info.
	* elf-sframe.c (_bfd_elf_parse_sframe): Likewise.
2025-01-04 19:15:56 +10:30
Alan Modra
c232d080c4 _bfd_write_ar_hdr
This has been broken since commit 8f95b6e449 in 2010, and apparently
nobody has noticed.  How we write archive headers depends on the
archive, not the contents.

	* libbfd-in.h (_bfd_write_ar_hdr): Correct.
	* libbfd.h: Regenerate.
2025-01-04 19:15:56 +10:30
Tom de Vries
d68afffbaa [gdb/testsuite] Skip stabs board in make-check-all.sh
I ran make-check-all.sh with gdb.linespec/explicit.exp, and the only problems
were found with target board stabs.

With target board unix the test-case runs in two seconds, but with target
board stabs it takes 12 seconds due to a timeout.

Stabs support in gdb has been unmaintained for a while, and there's an ongoing
discussion to deprecate and remove it (PR symtab/31210).

It seems unnecessary to excercise this unmaintained feature in
make-check-all.sh, so drop it.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31210
2025-01-04 09:41:35 +01:00
Fangrui Song
02646a4c56 skip -gfile: call fnmatch without FNM_FILE_NAME
fnmatch is called with the FNM_FILE_NAME flag so that `skip -gfi /usr/*`
doesn't match /usr/include/*.  This makes the file matching feature not
useful for STL headers that reside in multiple directories.  In
addition, the user cannot use a single `*` to match multiple leading
path components.

Let's drop the FNM_FILE_NAME flag and remove the assertion from
gdb_filename_fnmatch (originally for the auto-load feature).
2025-01-03 21:15:32 -08:00
Alan Modra
d8d3ed295e bfd_set_input_error
My recent change to closing archives showed some problems with the way
we stash errors for archive elements.  The most obvious thing found
by oss-fuzz, is that if output archive elements are closed during
bfd_close of an archive, then we can't access the element filename
when printing the element.  So change bfd_set_input_error to stash the
entire error message instead of input bfd and input error.

	* bfd.c (input_bfd, input_error): Delete.
	(bfd_error, _bfd_error_buf): Move.
	(_bfd_clear_error_data): Move.  Make static.  Clear bfd_error too.
	(bfd_set_input_error): Print the error use bfd_asprintf here..
	(bfd_errmsg): ..not here.
	(bfd_init): Update.
	* opncls.c (bfd_close_all_done): Don't call _bfd_clear_error_data.
	* libbfd.h: Regenerate.
2025-01-04 11:31:35 +10:30
GDB Administrator
879bde78c2 Automatic date update in version.in 2025-01-04 00:00:32 +00:00
Alan Modra
c935dfcc79 macro nesting testcases
Fix a bunch of regressions.  Don't start anything besides a label in
first column, don't name macros the same as directives, and make
labels global.
2025-01-03 13:21:47 +10:30
GDB Administrator
abbdd72489 Automatic date update in version.in 2025-01-03 00:00:39 +00:00
Vladimir Mezentsev
63eb193ca4 gprofng: remove the old archiver
The first versions of Performance Analyzer archived only function names.
This is no longer used. We need a real elf-file.

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

	* src/LoadObject.cc: Remove LoadObject::read_archive.
	* src/LoadObject.h: Likewise.
	* src/data_pckts.h: Remove unused declarations.
	* src/parse.cc (process_seg_map_cmd): Don't look for the old archive.
2025-01-02 15:46:48 -08:00
H.J. Lu
7476049749 nesting[123].d: Replace Sone with Some in comment
* testsuite/gas/macros/nesting1.d: Replace Sone with Some in
	comment.
	* testsuite/gas/macros/nesting2.d: Likewise.
	* testsuite/gas/macros/nesting3.d: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-03 06:25:57 +08:00
H.J. Lu
f087e2e3f6 gas: Revert PR 32391 related commits to fix 3 regressions
9f2e3c21f6 Fix the handling or arguments and macro pseudo-variables inside nested assembler macros.

introduced 3 regressions of PR gas/32484, PR gas/32486 and PR gas/32487.
Revert all PR 32391 related commits and add tests for PR gas/32484,
PR gas/32486, PR gas/32487.

	PR gas/32484
	PR gas/32486
	PR gas/32487
	* testsuite/gas/macros/macros.exp: Run nesting1, nesting2 and
	nesting3.
	* testsuite/gas/macros/nesting1.d: New file.
	* testsuite/gas/macros/nesting1.s: Likewise.
	* testsuite/gas/macros/nesting2.d: Likewise.
	* testsuite/gas/macros/nesting2.s: Likewise.
	* testsuite/gas/macros/nesting3.d: Likewise.
	* testsuite/gas/macros/nesting3.s: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-02 14:58:48 +08:00
Haochen Jiang
434deed44d Support Intel AMX-TF32
In this patch, we will support AMX-TF32. It is a simple ISA
comparing to the previous ones, so there is no special handling.

gas/ChangeLog:

	* config/tc-i386.c: Add amx_tf32.
	* doc/c-i386.texi: Document .amx_tf32.
	* testsuite/gas/i386/x86-64.exp: Run AMX-TF32 tests.
	* testsuite/gas/i386/x86-64-amx-tf32-bad.d: New test.
	* testsuite/gas/i386/x86-64-amx-tf32-bad.s: Ditto.
	* testsuite/gas/i386/x86-64-amx-tf32-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-amx-tf32-inval.l: Ditto.
	* testsuite/gas/i386/x86-64-amx-tf32-inval.s: Ditto.
	* testsuite/gas/i386/x86-64-amx-tf32.d: Ditto.
	* testsuite/gas/i386/x86-64-amx-tf32.s: Ditto.

opcodes/ChangeLog:

	* i386-dis.c (PREFIX_VEX_0F3848_X86_64_W_0_L_0): New.
	(X86_64_VEX_0F3848): Ditto.
	(VEX_LEN_0F3848_X86_64_W_0): Ditto.
	(VEX_W_0F3848_X86_64): Ditto.
	(prefix_table): Add PREFIX_VEX_0F3848_X86_64_W_0_L_0.
	(x86_64_table): Add X86_64_VEX_0F3848.
	(vex_len_table): Add VEX_LEN_0F3848_X86_64_W_0.
	(vex_w_table): Add VEX_W_0F3848_X86_64.
	* i386-gen.c (isa_dependencies): Add AMX_TF32.
	(cpu_flags): Ditto.
	* i386-init.h: Regenerated.
	* i386-mnem.h: Ditto.
	* i386-opc.h (CpuAMX_TF32): New.
	(i386_cpu_flags): Add cpuamx_tf32.
	* i386-opc.tbl: Add AMX-TF32 instructions.
	* i386-tbl.h: Regenerated.
2025-01-02 10:17:39 +08:00
Haochen Jiang
1fa0873f1d Support Intel AMX-TRANSPOSE
In this patch, we will support AMX-TRANSPOSE. Since AMX-TRANSPOSE
will be used with other CPUIDs very often, we put it into
CPU_FLAGS_COMMON.

To implement TMM pair, we reused ImplicitGroup and adjust the condition
in process_operands for the instructions.

APX_F extension is also handled in this patch, where it extends
T2RPNTLVW[Z0,Z1][,T1] to EVEX.128.NP/66.0F38.W0 6E/6F !(11):rrr:100
with NF=0.

Also, TTDPFP16PS should base on AMX_FP16, not AMX_BF16 in ISE055.
It would be fixed in ISE056.

gas/ChangeLog:

	* config/tc-i386.c (cpu_arch): Add amx_transpose.
	(_is_cpu): Ditto.
	(process_operands): Adjust the condition for AMX-TRANSPOSE.
	* doc/c-i386.texi: Document .amx_transpose.
	* testsuite/gas/i386/x86-64.exp: Run AMX-TRANSPOSE tests.
	* testsuite/gas/i386/x86-64-amx-transpose-bad.d: New test.
	* testsuite/gas/i386/x86-64-amx-transpose-bad.s: Ditto.
	* testsuite/gas/i386/x86-64-amx-transpose-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-amx-transpose-inval.l: Ditto.
	* testsuite/gas/i386/x86-64-amx-transpose-inval.s: Ditto.
	* testsuite/gas/i386/x86-64-amx-transpose.d: Ditto.
	* testsuite/gas/i386/x86-64-amx-transpose.s: Ditto.

opcodes/ChangeLog:

	* i386-dis.c (MOD_VEX_0F386E_X86_64_W_0): New.
	(MOD_VEX_0F386F_X86_64_W_0): Ditto.
	(PREFIX_VEX_0F385F_X86_64_W_0_L_0): Ditto.
	(PREFIX_VEX_0F386B_X86_64_W_0_L_0): Ditto.
	(PREFIX_VEX_0F386E_X86_64_W_0_M_0_L_0): Ditto.
	(PREFIX_VEX_0F386F_X86_64_W_0_M_0_L_0): Ditto.
	(X86_64_VEX_0F385F): Ditto.
	(X86_64_VEX_0F386B): Ditto.
	(X86_64_VEX_0F386E): Ditto.
	(X86_64_VEX_0F386F): Ditto.
	(VEX_LEN_0F385F_X86_64_W_0): Ditto.
	(VEX_LEN_0F386B_X86_64_W_0): Ditto.
	(VEX_LEN_0F386E_X86_64_W_0_M_0): Ditto.
	(VEX_LEN_0F386F_X86_64_W_0_M_0): Ditto.
	(VEX_W_0F385F_X86_64): Ditto.
	(VEX_W_0F386B_X86_64): Ditto.
	(VEX_W_0F386E_X86_64): Ditto.
	(VEX_W_0F386F_X86_64): Ditto.
	(mod_table): Add MOD_VEX_0F386E_X86_64_W_0,
	MOD_VEX_0F386F_X86_64_W_0.
	(prefix_table): Add PREFIX_VEX_0F386E_X86_64_W_0_M_0_L_0,
	PREFIX_VEX_0F386F_X86_64_W_0_M_0_L_0.
	Add new instructions for PREFIX_VEX_0F386C_X86_64_W_0_L_0.
	(x86_64_table): Add X86_64_VEX_0F385F, X86_64_VEX_0F386B,
	X86_64_VEX_0F386E, X86_64_VEX_0F386F.
	(vex_len_table): Add VEX_LEN_0F385F_X86_64_W_0,
	VEX_LEN_0F386B_X86_64_W_0, VEX_LEN_0F386E_X86_64_W_0_M_0,
	VEX_LEN_0F386F_X86_64_W_0_M_0.
	(vex_w_table): Add VEX_W_0F385F_X86_64, VEX_W_0F386B_X86_64,
	VEX_W_0F386E_X86_64, VEX_W_0F386F_X86_64.
	* i386-gen.c (cpu_flag_init): Add AMX_TRANSPOSE.
	(cpu_flags): Add CpuAMX_TRANSPOSE.
	* i386-init.h: Regenerated.
	* i386-mnem.h: Ditto.
	* i386-opc.h (CpuAMX_TRANSPOSE): New.
	(i386_cpu): Add cpuamx_transpose.
	* i386-opc.tbl: Add AMX-TRANSPOSE instructions.
	* i386-tbl.h: Regenerated.

Co-authored-by: Hu, Lin1 <lin1.hu@intel.com>
2025-01-02 10:14:37 +08:00
GDB Administrator
64273f18ec Automatic date update in version.in 2025-01-02 00:00:25 +00:00
Alan Modra
94e2b2a770 readelf memory leaks
This fixes multiple readelf memory leaks:
- The check functions used to validate separate debug info files
  opened and read file data but didn't release the memory nor close
  the file.
- A string table was being re-read into a buffer, leaking the old
  contents.
- Decompressed section contents leaked.

	* dwarf.c (check_gnu_debuglink): Always call close_debug_file.
	(check_gnu_debugaltlink): Likewise.
	* readelf.c (process_section_headers): Don't read string_table
	again if we already have it.
	(maybe_expand_or_relocate_section): Add decomp_buf param to
	return new uncompressed buffer.
	(dump_section_as_strings, filedata->string_table): Free any
	uncompressed buffer.
	(process_file): Call close_debug_file rather than freeing
	various filedata components.
2025-01-01 22:52:59 +10:30
Alan Modra
0e4e9aa0a7 objdump sym memory leak
The sym array should be freed even with a symcount of zero.

	* objdump.c (dump_bfd): Free syms before replacing with
	extra_syms.  Free extra_syms after adding to syms.
2025-01-01 22:52:51 +10:30
Alan Modra
822bda23f6 gnu_debuglink related memory leak
* opncls.c (bfd_fill_in_gnu_debuglink_section): Free section
	contents on success too.
2025-01-01 22:52:41 +10:30
Alan Modra
4739b9137e Close elements of output archive
When cleaning up an archive, close all its elements.  This fixes a
number of ar memory leaks.

bfd/
	* archive.c (_bfd_archive_close_and_cleanup): Close elements
	of an archive open for writing.
binutils/
	* objcopy.c (copy_archive): Don't close output archive
	elements here.
	* dlltool.c (gen_lib_file): Likewise.
ld/
	* pe-dll.c (pe_dll_generate_implib): Don't close output
	archive elements here.
2025-01-01 22:52:06 +10:30
Alan Modra
d58fbef40d ar.c memory leak fixme
Cure the leak by always mallocing the string in output_filename,
and freeing the old one any time we assign output_filename.
2025-01-01 22:51:53 +10:30
Alan Modra
c5e10fb2eb bfdtest1 loop check
Add a check that next_archived_file doesn't return the same element.
Seen with the following, which I think shows a bug with "ar r" and
thin archives as you get two copies of artest.a in artest2.a.

$ rm tmpdir/artest*
$ ./ar rc tmpdir/artest.a tmpdir/bintest.o
$ ./ar rcT tmpdir/artest2.a tmpdir/artest.a
$ ./bfdtest1 tmpdir/artest.a
$ ./bfdtest1 tmpdir/artest2.a
$ ./ar rcT tmpdir/artest2.a tmpdir/artest.a
$ ./bfdtest1 tmpdir/artest2.a
oops: next_archived_file
2025-01-01 22:51:44 +10:30
Alan Modra
bc67f5df70 thin archive with nested archive memory leak
The only reason to keep new_areldata around was for access to the
filename, but we now always take a copy in alloc'd memory.

	* archive.c (_bfd_get_elt_at_filepos): Free new_areldata when
	it is not attached to bfd.
2025-01-01 22:51:34 +10:30
Alan Modra
50dd43e6e3 memory leak in gas dwarf2dbg.c
Found when running the pr27355 testcase.

	PR 27355
	PR 27426
	* dwarf2dbg.c (allocate_filename_to_slot): Update dirs_in_use.
2025-01-01 22:50:29 +10:30
Alan Modra
e2783a90c8 gas obj-elf.c memory leaks
* config/obj-elf.c (obj_elf_section): Use notes_memdup for
	linked_to_symbol_name.
	(obj_elf_find_and_add_versioned_name): Use notes_alloc for
	versioned_name.
2025-01-01 22:50:17 +10:30
Alan Modra
599739cc1c PR 32391 memory leak
* macro.c (sub_actual): Free newadd.
2025-01-01 22:49:59 +10:30
Alan Modra
d4faef1077 gas reloc_list memory leaks
Put these on the notes obstack too.

	* config/tc-wasm32.c (wasm32_leb128): Use notes_alloc for
	reloc_list vars.
	* read.c (s_reloc): Likewise.
	* write.c (create_note_reloc): Likewise.
	(write_object_file): Reset reloc_list after write_relocs.
2025-01-01 22:49:48 +10:30
Alan Modra
3fb6f5457e gas tc_gen_reloc memory leaks
This makes all the tc_gen_reloc functions and the associated array in
write.c:write_relocs use notes_alloc rather than malloc.  tc-hppa.c
tc_gen_reloc gets a few more changes, deleting some dead code, and
tidying code that duplicates prior initialisation.
2025-01-01 22:49:04 +10:30
Alan Modra
443101612d gas gen-sframe memory leaks
More freeing required.

	* gen-sframe.c (all_sframe_fdes, last_sframe_fde): Move earlier,
	make file scope.
	(sframe_row_entry_new): Move earlier.
	(sframe_row_entry_free): New function.
	(sframe_fde_alloc, sframe_fde_free): Move earlier.
	(sframe_fde_link): Delete.  Expand into..
	(create_sframe_all): ..here.
	(output_sframe_internal): Delete silly sframe_flags init.
	Free fdes.  Reset static vars.
	(sframe_xlate_ctx_cleanup): Use sframe_row_entry_free.  Free
	remember_fre too.  Don't re-init xlate_ctx we're about to drop.
	* gen-sframe.h (all_sframe_fdes): Don't declare.
2025-01-01 22:48:38 +10:30
Alan Modra
597de453a2 gas dw2gencfi memory leaks
Some of these could have remained as malloc'd memory, but that would
require quite a bit of code to traverse frch_cfi_data for example, and
would rely on matching cfi directives (ie. valid input).  Just put
them on the notes obstack instead.

	* dw2gencfi.c (alloc_fde_entry): Use notes_calloc.
	(alloc_cfi_insn_data): Likewise.
	(cfi_end_fde): Don't free frch_cfi_data.
	(cfi_add_label): Use notes_strdup.
	(cfi_add_CFA_remember_state): Use notes_alloc.
	(cfi_add_CFA_restore_state): Don't free.
	(dot_cfi_escape): Use notes_alloc.
	(cfi_finish): Free cies after each pass, not before.  Clear
	out static vars too.
2025-01-01 22:47:16 +10:30
Alan Modra
b492153908 gas include_dirs memory leak
This is the first of a series of patches aimed at making it possible
to configure with CFLAGS="-g -O2 -fsanitize=address,undefined" and run
the binutils and gas testsuite on x86_64-linux without using
ASAN_OPTIONS=detect_leaks=0.  ie. the patch series is aimed at fixing
common gas, ar, objcopy, objdump, and readelf leaks.

	* config/tc-tic54x.c (md_begin): Make use of notes_strdup rather
	than xstrdup to copy entries added to include_dirs.
	* read.c (read_end): Free include_dirs array.
2025-01-01 22:38:44 +10:30
Alan Modra
1d2becbb32 gas totalfrags
Avoid any possibility of signed overflow.  (Seen on oss-fuzz).

	* frags.c (totalfrags): Make unsigned.
	(get_frag_count): Return unsigned.
	* frags.h (get_frag_count): Likewise.
2025-01-01 22:38:03 +10:30
Alan Modra
b38cf91f23 PR 32507, PRIx64 in error messages on 32-bit mingw
People, including me, had forgotten that the bfd_error_handler just
handled standard printf format strings, not MSC %I64 and suchlike.
Using PRIx64 and similar in errors does not work if the host compiler
headers define those formats as the Microsoft %I64 variety.  (We
handled %ll OK, editing it to %I64 on such hosts.)

	PR 32507
	* bfd.c (_bfd_doprnt, _bfd_doprnt_scan): Handle %I64 and %I32
	in input strings if the host defines PRId64 as "I64d".
	Edit %ll to %I64 on detecting PRId64 as "I64d" rather than on
	a preprocessor define.
2025-01-01 22:31:50 +10:30
Alan Modra
5e04003fac Regen gprofng after copyright update 2025-01-01 22:19:36 +10:30
Alan Modra
e8e7cf2abe Update year range in copyright notice of binutils files 2025-01-01 18:29:57 +10:30
GDB Administrator
a21a6dbe63 Automatic date update in version.in 2025-01-01 00:00:37 +00:00