Commit Graph

123878 Commits

Author SHA1 Message Date
Jens Remus
5079bf8959 gas: sframe: Represent .cfi_undefined RA as FRE without offsets
In DWARF CFI an "undefined" register rule for the return address (RA)
register indicates that there is no return address and the stack trace
is complete.

Represent DW_CFA_undefined as SFrame FRE without any offsets, so that a
stack tracer implementation can use this as indication that an outermost
frame has been reached and the stack trace is complete.

This representation is backward compatible, as existing stack tracers
should already deal with the case, that an SFrame FRE a so far invalid
offset count of zero and stop the trace.

include/
	* sframe.h (SFRAME_V2_FRE_RA_UNDEFINED_P): New macro to test
	FRE info word for RA undefined (FRE without any offsets).

binutils/
	* NEWS: Mention SFrame can represent an undefined RA as FRE
	without	any offsets.

gas/
	* gen-sframe.h (struct sframe_row_entry): Add ra_undefined_p
	flag.
	* gen-sframe.c (sframe_row_entry_new): Initialize ra_undefined_p
	flag to not set.
	(sframe_row_entry_initialize): Treat ra_undefined_p flag as
	sticky.
	(sframe_fre_set_ra_track): Reset ra_undefined_p flag.
	(sframe_xlate_do_restore): Reset ra_undefined_p flag to saved
	state.
	(sframe_xlate_do_same_value): Reset ra_undefined_p flag.
	(sframe_xlate_do_cfi_undefined): For RA set ra_undefined_p flag.
	(output_sframe_row_entry): Represent RA undefined as SFrame FRE
	without any offsets and FRE info word fields zeroed.
	* NEWS: Mention assembler represents .cfi_undefined RA in SFrame
	as FRE without any offsets.

libsframe/
	* doc/sframe-spec.texi (Changes from Version 1 to Version 2):
	Mention that a SFrame FRE without any offsets flag indicates an
	outermost frame with an undefined RA.
	(fre_offset_count): Document that a FRE offset count of zero
	indicates an outermost frame with an undefined RA.
	* sframe.c (sframe_get_fre_ra_undefined_p): Use macro
	SFRAME_V2_FRE_RA_UNDEFINED_P.
	(sframe_fre_get_fp_offset, sframe_fre_get_ra_offset): Do not
	return fixed FP/RA offset if RA undefined.
	* sframe-dump.c (dump_sframe_func_with_fres): Show FRE without
	any offsets as "RA undefined".

gas/testsuite/
	* gas/cfi-sframe/cfi-sframe.exp: Run tests for .cfi_undefined RA
	on AArch64, s390x, and x86-64.
	* gas/cfi-sframe/cfi-sframe-aarch64-ra-undefined-1.d: Add test
	for .cfi_undefined RA on AArch64.
	* gas/cfi-sframe/cfi-sframe-aarch64-ra-undefined-1.s: Likewise.
	* as/cfi-sframe/cfi-sframe-s390x-ra-undefined-1.d: Add test
	for .cfi_undefined RA on s390x.
	* gas/cfi-sframe/cfi-sframe-s390x-ra-undefined-1.s: Likewise.
	* gas/cfi-sframe/cfi-sframe-x86_64-ra-undefined-1.d: Add test
	for .cfi_undefined RA on x86-64.
	* gas/cfi-sframe/cfi-sframe-x86_64-ra-undefined-1.s: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-10-15 17:45:48 +02:00
Jens Remus
6ca8915c61 include: libsframe: Add API to get RA undefined
SFrame FREs without any offsets will later be used to represent an
undefined return address (RA) in SFrame.  This API can then be used,
for instance by libsframe when dumping SFrame stack trace information
(e.g. in objdump and readelf), to test for RA undefined.  Other users
of libsframe need the same capability.

include/
	* sframe-api.h (sframe_fre_get_ra_undefined_p): New declaration.

libsframe/
	* libsframe.ver (sframe_fre_get_ra_undefined_p): List new API.
	* sframe.c (sframe_fre_get_ra_undefined_p): New definition.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-10-15 17:45:48 +02:00
Jens Remus
52308aeca8 libsframe: s390: No further decode if sframe_get_fre_offset returns err
SFrame FREs without any offsets will later be used to represent
.cfi_undefined RA in SFrame.

As a result the API to get the CFA offset can return an error value, if
there are no offsets.  Do not apply the s390x-specific decoding of CFA
offset on the error return value.

libsframe/
	* sframe.c (sframe_fre_get_cfa_offset): Do not apply s390x-
	specific decoding to error return value.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-10-15 17:45:48 +02:00
Jens Remus
c47ec3b44a gas: ld: libsframe: Support for SFrame FDEs without any FREs
Allow SFrame sections without any FREs, that can occur if they solely
contain FDEs without any FREs.  For FDEs without and FREs set the
offset to the first FRE to zero.

libsframe/
	* sframe.c (sframe_encoder_write_sframe): Allow SFrame sections
	without any FREs.  For FDEs without any FREs set the offset to
	the first FRE to zero.

gas/
	* gen-sframe.c (output_sframe_funcdesc): For FDEs without any
	FREs set the offset to the first FRE to zero.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-10-15 17:45:48 +02:00
Matthieu Longo
abe6b29caf gdb: add experimental option --enable-py-limited-api
Today, GDB links against the Python library using the unstable API. This
approach causes portability issues of the generated GDB artifact. Indeed
the built artifact is tighly coupled with the specific version of Python
that it was compiled with. Using a slighly minor version of Python can
cause unpredictable crashes at runtime due to ABI instability between
the Python versions, even minor ones.

The solution would consist in restricting the usage of Python functions
to the limited C API controlled via Py_LIMITED_API that must be defined
before the inclusion of <Python.h>.

This patch does not aim at porting the whole GDB codebase to the Python
limited C API, but rather enabling a development mode where developers
can experiment with the Python limited C API, and fix issues.
This development mode is accessible with the configure option
--enable-py-limited-api which is set by default to 'no'.

Note: the version of the Python limited API is currently set to 3.11
because of PyBuffer_FillInfo and PyBuffer_Release. This choice is not
frozen, and could be reviewed later on depending on newly discovered
issues during the migration.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23830
Approved-By: Tom Tromey <tom@tromey.com>
2025-10-15 16:23:21 +01:00
Matthieu Longo
5643188363 gdb: make Python conftest compatible with Python limited C API
The current test to check the support of '--dynamic-list' linker flag
uses PyRun_SimpleString (), which is part of the unstable API. As it is
now, the test will systematically fail due to the undefined symbol
rather than testing the import of ctypes.
This patch replaces PyRun_SimpleString () by an equivalent code relying
on the limited C API, and compatible with Python 3.4.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23830
Approved-By: Tom Tromey <tom@tromey.com>
2025-10-15 16:23:13 +01:00
GDB Administrator
3510e35e96 Automatic date update in version.in 2025-10-15 00:00:31 +00:00
Simon Marchi
6f889f9402 gdb/linespec: make symbol_to_sal return an optional
Return an optional, instead of a bool + the actual value by parameter.
I think this makes it a bit easier to understand what's going on.

Change-Id: Idf65f4a026cab6eebfb81c4efda406aeb65d0813
Approved-By: Tom Tromey <tom@tromey.com>
2025-10-14 15:44:42 -04:00
Simon Marchi
c4e3b73c36 gdb/linespec: take some parameters by reference
Change the `sal` parameter of add_sal_to_sals to be a reference.  This
will make things a bit cleaner in a following patch (and it would be a
good change on its own anyway).

Change the `sals` parameter to a reference as well, while at it, which
trickles up to minsym_found.

Change-Id: I348414308940c14fa6030bc41c52f507aa6d1c12
Approved-By: Tom Tromey <tom@tromey.com>
2025-10-14 15:44:42 -04:00
Simon Marchi
927cb4b778 gdb: remove unnecessary use of symtab_and_line in create_sals_line_offset
create_sals_line_offset uses a symtab_and_line essentially just to hold
a line number and pass it down to decode_digits_list_mode.  Change the
local variable to be an int, and change decode_digits_list_mode to
accept an int, instead of a symtab_and_line.  I think this makes the
code a bit simpler.

Change-Id: I445d2473f042693c3a4f2693877408f85100cd1f
Approved-By: Tom Tromey <tom@tromey.com>
2025-10-14 14:07:58 -04:00
Simon Marchi
71adb55542 gdb/symtab: declare variables on first use in skip_prologue_sal
I'm currently looking at this function, and think it makes it easier to
process if the variables are declared when actually used.

I turned one while loop into a for, in order to be able to declare the
loop variable in the for loop.

Change-Id: I70258a94f39acb3d56e5b8e85cdfadc2f7687bc4
Approved-By: Tom Tromey <tom@tromey.com>
2025-10-14 13:46:29 -04:00
Simon Marchi
d39a6e7c1b gdb/symtab: declare variables on first use in find_pc_sect_line
I'm currently looking at this function, and think it makes it easier to
process if the variables are declared when actually used.

Change-Id: Ie950fc3a7241e55e66ae96a578f79df3a9b45c69
Approved-By: Tom Tromey <tom@tromey.com>
2025-10-14 13:46:29 -04:00
Tom Tromey
f283e80fed Fix use of "main" marker in gdb index
Tom de Vries noticed that with .gdb_index, the "main" marker would
sometimes seemingly be ignored.

I tracked this down to an interaction between the rewritten reader and
the "main"-finding code in cooked_index.  With the ordinary DWARF
scanner, a C "main" won't be marked as IS_MAIN; whereas with
.gdb_index this can happen.  In this case, the code thinks that C
requires canonicalization (which is only true for types), and skips
using the symbol.

This patch fixes the problem and adds some comments explaining what is
going on.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33441
2025-10-14 10:18:09 -06:00
Tom de Vries
94a0adaca0 Fix gdb.ada/extended-access.exp on riscv64-linux
On riscv64-linux, I ran into:
...
(gdb) print the_array.all^M
Cannot access memory at address 0x0^M
(gdb) FAIL: gdb.ada/extended-access.exp: print the_array.all
...

The problem is that the_array.p_array is set by a dynamic relocation:
...
0000000000002010 <array_data>:
        ...

0000000000002028 <the_array>:
        ...
                        2028: R_RISCV_RELATIVE  *ABS*+0x2010
...
which doesn't seem to get its value until we arrive in main.

Fix this by running to main before trying to print the_array.

Tested on riscv64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2025-10-14 18:09:36 +02:00
Tom de Vries
9b38e80ce8 [gdb/testsuite] Fix xfail in gdb.ada/variant_record_field.exp
On ppc64-linux (debian 14) I run into:
...
(gdb) print p_record^M
$1 = (kind => five, i => <error reading variable: \
  access outside bounds of object>^M
(gdb) gdb_do_cache: get_compiler_info_1 ( c )
get_compiler_info: gcc-15-2-0
gdb_do_cache: get_compiler_info_1 ( c )
FAIL: gdb.ada/variant_record_field.exp: print p_record
...

The test-case contains an xfail for "[gcc_major_version] <= 14", which doesn't
trigger because gcc has version 15.2.0, while gnatmake does have version
14.3.0:
...
$ gcc --version
gcc (Debian 15.2.0-4) 15.2.0
  ...
$ gnatmake --version
GNATMAKE 14.3.0
...

Fix this by using "[gnat_version_compare < 15]" instead.

Tested on ppc64-linux and x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2025-10-14 18:00:48 +02:00
Lancelot SIX
93f536d813 gdb/corelow: Fix use-after-free in gdb_read_core_file_mappings
A recent refactor (fc8e5a565b -- gdb: make structured core file
mappings processing global) in gdb/corelow.c:gdb_read_core_file_mappings
introduced a use-after-free bug detected by address sanitizer.

In this change, a cache is built which holds addresses to elements of a
std::vector.  However, as elements as inserted in the vector, the
addresses in the cache should be invalidated, but are not, leading to
the use-after-free issue.

This patch proposes to store the index in the vector in the cache
instead of the address of the element, solving the invalidation issue.
An alternative approach could be to use a std::list which does not need
invalidation of addresses/references/iterators as the container is
grown.

Change-Id: Ib57d87c5d0405ffa3b7d38557fb33f7283c5d063
Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-10-14 15:20:18 +01:00
Tom de Vries
96d73418e9 [gdb/build] Fix buildbreaker on x86_64-freebsd in gdb/fbsd-nat.c
Following commit 1ad8737b3c ("gdb: change inf_threads_iterator to yield
references"), we're running into a build breaker on x86_64-freebsd, in
gdb/fbsd-nat.c.

Fix this.

Tested by completing a build on x86_64-freebsd and running the TUI test-cases.
2025-10-14 11:51:50 +02:00
Tom de Vries
f955cf6a1a [gdb/testsuite] Fix ERROR in gdb.tui/corefile-run.exp
When running test-case gdb.tui/corefile-run.exp on x86_64-freebsd, we run into
PR tdep/33176:
...
PASS: gdb.tui/corefile-run.exp: load corefile
run<SNIP>gdb/fbsd-nat.c:1381: internal-error: wait_1: \
  Assertion `fbsd_inf != nullptr || pl.pl_flags & PL_FLAG_CHILD' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
ERROR: FIXME scroll
...

Skip the ERROR by:
- running the test-case twice, once with CLI and once with TUI, and
- only running the TUI variant if the CLI one succeeds.

While we're at it, add a KFAIL for the PR.

Tested on x86_64-freebsd and x86_64-linux.
2025-10-14 11:34:51 +02:00
Natanael Copa
a8a65f0dc7 gcore: Remove bashisms and use POSIX sh
- Switch script shebang to /bin/sh
- Remove unnecessary `function` keywords
- Replace bash arrays with simple scalar variables
- Use $(uname -s) instead of bash specific $OSINFO

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-10-14 00:45:35 -04:00
Tom Tromey
4109b06814 Fix use-after-free when destroying objfile
The recent patch to heap-allocate compunit_symtabs introduced a
use-after-free that can occur when destroying an objfile.  The bug
here is that the objfile obstack is destroyed before compunit_symtabs;
but the compunit_symtabs destructor refers to the symtabs, which are
allocated on the obstack.

This patch fixes the problem.  This was reported using ASAN, but I
reproduced it with valgrind and verified that this fixes the problem.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33435
2025-10-13 21:40:19 -06:00
GDB Administrator
2358bcf045 Automatic date update in version.in 2025-10-14 00:00:22 +00:00
Maciej W. Rozycki
3c33c8c7c7 LD/PE: Remove remains of MIPS target support
Support for ECOFF MIPS targets, including `mips*-*-pe*' among others,
has been removed from GAS and LD with commit e8044f355d ("Remove gas
and ld support for MIPS ECOFF"),
<https://inbox.sourceware.org/binutils/8761x65bzx.fsf@talisman.default/>.
However bits in PEI-format DLL support code have been left behind.

Remove the relevant pieces then, originally from commit 344a211f99
("Add support for WinCE based toolchains."), including MIPS architecture
parts and HIGHADJ relocation support in particular.  Retain code for LOW
relocation however, even though included with said commit, as it remains
usable by ARM, i386 and x86-64 targets.

Add test cases for LOW, HIGHLOW, and DIR64 relocations handled by code
being modified.  The MCore target currently fails to produce a .reloc
image section owing to missing support, so XFAIL the HIGHLOW test.
2025-10-13 22:02:30 +01:00
Maciej W. Rozycki
68d4661014 LD/PE: Make arch identifiers enumeration constants
Convert internal PE architecture identifiers from macros to enumeration
constants so as to make any further updates less disruptive to code.

Add a PE_ARCH_none dummy placeholder so as to start the numbering of
actual architectures from 1 without the need to specify the numeric
value for any of the constants.

No functional change.  Suggested by Richard Earnshaw.
2025-10-13 22:02:30 +01:00
Tom de Vries
5460375039 [gdb/testsuite] Use expect_build_id_in_core_file a bit more
Recent commit c1950dcc04 ("gdb/testsuite: fix failure from
gdb.python/py-corefile.exp") introduced proc expect_build_id_in_core_file,
which detects the problem that:
...
    ... some versions of the linker didn't place the build-id within the first
    page of an ELF.  As a result, the Linux kernel would not include the
    build-id in the generated core file, ...
...

Use this proc in a few more test-cases, to deal with the same problem.

Tested on x86_64-linux, openSUSE Tumbleweed with ld 2.43.1.

Approved-By: Andrew Burgess <aburgess@redhat.com>

PR testsuite/33528
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33528
2025-10-13 20:54:43 +02:00
Nick Clifton
c0316a54b4 Add a position statement about LLM generated content 2025-10-13 15:16:12 +01:00
Nick Clifton
f039dfba55 Add note about how to obtain permission to upload new releases 2025-10-13 15:14:42 +01:00
GDB Administrator
e60bd80314 Automatic date update in version.in 2025-10-13 00:00:07 +00:00
Andrew Burgess
20a08d9851 gdb/remote: replace use of std::pair with an actual struct
Commit:

  commit 5edcbe2277
  Date:   Mon Jul 24 17:35:54 2023 +0100

      gdb: detect when gdbserver has no default executable set

Introduced a use of std::pair as a data structure to hold some per
program space information within the program space registry.

It was pointed out during review of a later patch[1][2] that the code
would be easier to understand if the std::pair was replaced with a
struct with named fields.

That is what this commit does.  Replace the std::pair with a struct,
and update all accesses to use the named fields.

There should be no user visible changes after this commit.

[1] https://inbox.sourceware.org/gdb-patches/69681489-d556-4496-9e3b-8273cab3d8f5@simark.ca
[2] https://inbox.sourceware.org/gdb-patches/469655a7-2bcc-4f27-b2d7-3fa8808ca5b5@simark.ca

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-10-12 13:46:12 +01:00
GDB Administrator
def8befb9d Automatic date update in version.in 2025-10-12 00:00:06 +00:00
Tom Tromey
906678d08e Return references from compunit_symtab iterator
This changes the compunit_symtab iterator to return references rather
than pointers, following the style of some other recent changes.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-10-11 13:40:32 -06:00
Tom Tromey
61a98786bf Use std::unique_ptr in compunit_symtab
Now that compunit_symtab can have a destructor, it can use
std::unique_ptr rather than an explicit 'delete'.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-10-11 13:27:36 -06:00
Tom Tromey
23e3008c3e Allocate compunit_symtab on heap
This patch changes compunit_symtab to be allocated on the heap, using
'new'.  It also changes the container that holds these in the objfile.
I chose to use an intrusive_list to store compunit_symtab because I
think pointer stability is needed here.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33435
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-10-11 13:27:10 -06:00
Simon Marchi
6b0581fc92 gdb/symtab: remove section parameter from find_function_start_sal
All 2 callers of this overload pass NULL.  Remove the parameter and pass
nullptr explicitly to find_function_start_sal_1.

Change-Id: Ie20e7c8ad980cd7af99b6ba9c23f4da19febc1bc
2025-10-11 00:04:09 -04:00
GDB Administrator
e3da6edc98 Automatic date update in version.in 2025-10-11 00:00:07 +00:00
Jan Vrany
5aff891135 gdb: introduce new function create_function_type
While working on new Python API to create new function types I realized
that there's no easy way to create a new function type and control where
it is going to be allocated (whether in gdbarch's obstack or objfile's).
Functions lookup_function_type and lookup_function_type_with_arguments
always allocate at the same obstack as its return type.

This is not sufficient for the new Python API - the user may use any
type it can get hold of. For example, one may want to create a function
returning arch-owned type and taking one argument of objfile-owned type.
In that case we need to allocate the new type on that very objfile's
obstack.

This commit introduces new function - create_function_type - that takes
type_allocator as first parameter, allowing caller to control the
allocation. Existing functions (lookup_function_type and
lookup_function_type_with_arguments) are reimplemented by means of new
create_function_type.

Approved-By: Tom Tromey <tom@tromey.com>
2025-10-10 21:38:44 +01:00
Jan Beulich
1ff5a44762 bfd/PE: make local array in _bfd_XXi_swap_scnhdr_out() static
... and const. There's no reason to have the compiler copy an anonymous
.rodata object onto the stack. And there's also no reason to allow the
array to be modifiable.
2025-10-10 16:03:15 +02:00
Jan Beulich
8c41c5e09d bfd/PE: respect SEC_ALLOC when deciding whether to force IMAGE_SCN_MEM_DISCARDABLE
While in the common case sections like .reloc don't need to be accessed
by a binary (that's the job of the loader), there are rare cases where
the situation is different. Unconditionally forcing the discardable flag
is therefore unhelpful. Avoid doing so when SEC_ALLOC is set, which
would in particular be the case when .reloc isn't (solely) linker-
generated.

While adjusting the comment, drop the wrong (stale?) following sentence:
.rsrc, as per its table entry, doesn't need to be writable. And
commenting on it wanting to be readable would then need to be repeated
for all other sections as well.
2025-10-10 16:02:50 +02:00
Jan Beulich
6b7bbb6942 bfd / PE/COFF: permit SEC_READONLY and consolidate
Without SEC_READONLY, even the default .text section would end up with
the IMAGE_SCN_MEM_WRITE flag, which is clearly wrong. (Afaict the flag,
oddly enough, doesn't affect the final linked binary, so there likely
are more anomalies.)

However, as suggested by Richard Earnshaw, PE's requirements are really
target independent. Consolidate SEC_CODE, SEC_DATA, SEC_READONLY,
SEC_LINK_ONCE, and SEC_LINK_DUPLICATES into target-independent code. Yet
of course targets not using CREATE_*_COFF_TARGET_VEC() won't benefit.

Note that in coff-arm.c the EXTRA_S_FLAGS conditional was also stale
(leftover from EPOC removal), and hence can go away.
2025-10-10 16:01:16 +02:00
Jan Beulich
c0f8a4a25e gas/SH: respect --no-pad-sections
This is once again just so the target won't need excluding in a
forthcoming new testcase, which requires no padding at the end of at
least some of the sections.
2025-10-10 16:00:44 +02:00
Jan Beulich
023d89bf4b gas/SH: support BFD_RELOC_RVA in the PE/COFF case
This is just so the target won't need excluding in a forthcoming new
testcase, which uses the .rva directive.
2025-10-10 16:00:30 +02:00
Jan Beulich
2817be508d ld/PE: respect --enable-reloc-section even when .reloc isn't created by default
Even when !DLL_SUPPORT, an executable may still want to have base
relocations created. Avoid doing so by default, though, to not alter
prior behavior.

With this, an xfail can (and actually should) go away (or else we end up
with an XPASS).
2025-10-10 16:00:04 +02:00
Jan Beulich
f72471128d ld/PE: adjust pe_detail_list[]
M*Core uses pe-dll.c, but has no entry in the table. Add both big and
little endian ones. Many of the entries aren't relevant when targeting
PE+; move the #endif accordingly. The MIPS entry is actually
questionable altogether: No mips*-*-* target uses pe-dll.c or pep-dll.c.

As I lack sufficient knowledge of the target, introduction of
jmp_mcore_bytes[] will need to be handled by someone else.
2025-10-10 15:59:44 +02:00
Jan Beulich
b8c152b9a9 objdump: enable PE support for Interix
This is just so the target won't need excluding in a forthcoming new
testcase. Without doing so objdump would fail saying "option -P/--private
not supported by this file".
2025-10-10 15:59:18 +02:00
Jan Beulich
5f51d87cc0 bfd/COFF: optionally pass BFD section into swap_scnhdr_out() hook
_bfd_XXi_swap_scnhdr_out() will want to use the section's flags. Some
call sites don't have a BFD section available, and hence pass NULL. Code
using the parameter will therefore need to apply appropriate care.
2025-10-10 15:58:55 +02:00
Jan Beulich
ef3816215d bfd / PE/COFF: avoid setting SEC_ALLOC when finding IMAGE_SCN_MEM_DISCARDABLE
Before teaching _bfd_XXi_swap_scnhdr_out() to respect SEC_ALLOC when
considering whether to force IMAGE_SCN_MEM_DISCARDABLE for a section,
make sure we won't "invert" present wrong behavior when transforming an
incoming object's section attributes to an outgoing one's (objcopy or
"ld -r"): Right now, IMAGE_SCN_MEM_DISCARDABLE would appear out of the
blue for certain sections. We don't want the opposite, though, i.e. we
want avoid silently dropping IMAGE_SCN_MEM_DISCARDABLE when it's present
for an incoming object's section.
2025-10-10 15:58:30 +02:00
Jan Beulich
6e870bea5f gas/COFF: extend use of SEC_ALLOC
In line with bfd's styp_to_sec_flags(), set SEC_ALLOC for code/data
sections. Tie the setting to SEC_LOAD, not avoid inadvertently producing
a .bss-like section.
2025-10-10 15:58:03 +02:00
Jan Beulich
3f80863fbf ld/PE: adjust .reloc and .edata section flags
Both really want to be SEC_DATA, even if _bfd_XXi_swap_scnhdr_out()
makes sure that IMAGE_SCN_CNT_INITIALIZED_DATA is set in the final
section header. Otoh, .reloc - being IMAGE_SCN_MEM_DISCARDABLE at least
by default - shouldn't have SEC_ALLOC set.

In an early form of the patch I also dropped SEC_ALLOC for .reloc. While
I've undone that, I think the then necessary testsuite adjustments still
want retaining:

1) I can't explain why the removal of _both_ SEC_ALLOC and SEC_LOAD for
.reloc causes ld-scripts/provide-8 to XPASS on PE targets. Placing a
symbol outside of the image isn't well-defined in PE anyway though, so
convert the xfail-s to notarget-s.

2) The ld-pe/pe-aarch64 fragility is now dealt with in a separate patch.
2025-10-10 15:57:36 +02:00
Aditya Vidyadhar Kamath
16ca38abaa Fix AIX CI build break.
Recently AIX internal CI is broken.

The error is as follows:
--------------------------------
aix-thread.c: In function 'void sync_threadlists(pid_t)':
aix-thread.c:857:53: error: cannot convert 'thread_info' to 'thread_info*' in initialization
  857 |     for (struct thread_info *it : all_threads_safe ())
      |                                                     ^
aix-thread.c: In lambda function:
aix-thread.c:899:61: warning: declaration of 'thread' shadows a previous local [-Wshadow=compatible-local]
  899 |     thread = iterate_over_threads ([&] (struct thread_info *thread)

----------------------------------

This patch is similar to the commit https://urldefense.proofpoint.com/v2/url?u=https-3A__sourceware.org_git_-3Fp-3Dbinutils-2Dgdb.git-3Ba-3Dcommitdiff-3Bh-3D675a17a8a5cde1d8be86536df2ae6366ef0ec759&d=DwIDAg&c=BSDicqBQBDjDI9RkVyTcHQ&r=f-oUQ8ByG1nZ71OI9p76qywCPh7mxzU69hBYnkP9Nis&m=qpgW6gyN_lC_b0fBRhcWkqlvNDmUtHBTvyqGcCZxnuN6vnvJaehZ2WVuFVicJ9oD&s=UtdzAKmXnBH1ZTFOUTmFC9vTwxxralJIDjbYWsCsLYA&e=

all_threads_safe() returns an all_threads_safe_range which is like an iterator to iterate for loops.

AIX is adjusting its code in aix-thread.c for the same.

After applying this patch,
Sample test case output:

------------
gmake check RUNTESTFLAGS='gdb.threads/thread_events.exp  CC_FOR_TARGET="/opt/freeware/bin/gcc" CXX_FOR_TARGET="/opt/freeware/bin/g++" CXXFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64" CFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64"'
gmake check-single
gmake[1]: Entering directory '/upstream_gdb/binutils-gdb/gdb/testsuite'
rm -f *core* gdb.sum gdb.log
   === gdb tests ===

Schedule of variations:
    unix

Running target unix
Using /opt/freeware/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /opt/freeware/share/dejagnu/config/unix.exp as generic interface file for target.
Using /upstream_gdb/binutils-gdb/gdb/testsuite/config/unix.exp as tool-and-target-specific interface file.
Running /upstream_gdb/binutils-gdb/gdb/testsuite/gdb.threads/thread_events.exp ...

                === gdb Summary ===

/upstream_gdb/binutils-gdb/gdb/gdb version  18.0.50.20251010-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /upstream_gdb/binutils-gdb/gdb/data-directory -iex "set interactive-mode on"

                === gdb Summary ===

/upstream_gdb/binutils-gdb/gdb/gdb version  18.0.50.20251010-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /upstream_gdb/binutils-gdb/gdb/data-directory -iex "set interactive-mode on"

gmake[1]: Leaving directory '/upstream_gdb/binutils-gdb/gdb/testsuite'

Approved By: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2025-10-10 06:31:06 -05:00
Jan Beulich
6e3954c79e x86: introduce PadLock predicate
By, at least for now, (ab)using the PrefixRepe attribute, the other two
PadLock checks can be simplified.
2025-10-10 09:26:44 +02:00
Jan Beulich
5690a49ac7 x86: PadLock adjustments
For one, all PadLock insns depend on CR4.FXSR to be enabled, which means
they ought to be taking FXSR as a prereq.

Furthermore none of them permits a REPNE prefix; such forms are documented
to cause #UD. (This is mainly relevant for XSTORE, which doesn't include a
REP prefix in its base encoding. For the others this merely is a change in
what diagnostic is issued.)

Finally it is documented that an operand size prefix also causes #UD.
2025-10-10 09:26:24 +02:00