Commit Graph

12475 Commits

Author SHA1 Message Date
Andre Vieira
94861aa1c0 aarch64, gas: Relax Armv9.6-A mandatory feature set
Remove FPRCVT and SVE2p2 from the set of mandatory features for Armv9.6-A.
2025-10-08 11:30:56 +01:00
Maciej W. Rozycki
6d80adb93c TIC6X/GAS: Work around array bounds compilation error
Work around a compilation error:

.../gas/config/tc-tic6x.c: In function 'tic6x_start_unwind_section':
.../gas/config/tc-tic6x.c:4632:17: error: offset '16' outside bounds of constant string [-Werror=array-bounds]
 4632 |       text_name += strlen (".gnu.linkonce.t.");
      |       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

observed with GCC 10.
2025-10-06 21:37:27 +01:00
Maciej W. Rozycki
7495d2d21d IA-64/GAS: Work around format truncation compilation errors
Work around compilation errors:

.../gas/config/tc-ia64.c: In function 'declare_register_set':
.../gas/config/tc-ia64.c:5375:41: error: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size 8 [-Werror=format-truncation=]
 5375 |       snprintf (name, sizeof (name), "%s%u", prefix, i);
      |                                         ^~
.../gas/config/tc-ia64.c:5375:38: note: directive argument in the range [0, 4294967294]
 5375 |       snprintf (name, sizeof (name), "%s%u", prefix, i);
      |                                      ^~~~~~
.../gas/config/tc-ia64.c:5375:7: note: 'snprintf' output 2 or more bytes (assuming 11) into a destination of size 8
 5375 |       snprintf (name, sizeof (name), "%s%u", prefix, i);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

observed with GCC 10.  Pick 16 for a round 64-bit stack frame size.
2025-10-06 21:37:27 +01:00
Matthieu Longo
dde707a0c4 aarch64: GICv5 hypervisor control system registers
This patch adds support for hypervisor control registers on AArch64,
available via the Generic Interrupt Controller v5 feature, and enabled
via the +gcie flag.

- ich_apr_el2
- ich_contextr_el2
- ich_hfgitr_el2
- ich_hfgrtr_el2
- ich_hfgwtr_el2
- ich_hppir_el2 (RO)
- ich_ppi_activer[0,1]_el2
- ich_ppi_dvir[0,1]_el2
- ich_ppi_enabler[0,1]_el2
- ich_ppi_pendr[0,1]_el2
- ich_ppi_priorityr[0,15]_el2
- ich_vctlr_el2
- ich_vmcr_el2
2025-10-06 17:56:26 +00:00
Matthieu Longo
84835d6288 aarch64: GICv5 PPI system registers
This patch adds support for PPI registers on AArch64, available via the
Generic Interrupt Controller v5 feature, and enabled via the +gcie flag.

- icc_ppi_cactiver[0,1]_el1
- icc_ppi_cpendr[0,1]_el1
- icc_ppi_enabler[0,1]_el1
- icc_ppi_hmr[0,1]_el1 (RO)
- icc_ppi_priorityr[0,15]_el1
- icc_ppi_sactiver[0,1]_el1
- icc_ppi_spendr[0,1]_el1

Also, the new system register 'icc_ppi_priorityr8_el1' clashed with the
encoding of 's3_0_c12_c15_0' used in a test for the generic syntax of
system registers using mrs and msr.
This patch replaces 's3_0_c12_c15_0' in the test by an unused encoding:
s3_7_c0_c15_0.
2025-10-06 17:56:26 +00:00
Matthieu Longo
e4b118633a aarch64: GICv5 CPU interface system registers
This patch adds support for 13 new AArch64 system registers for the CPU
interface, which are enabled on using Generic Interrupt Controller v5
(+gcie flag) feature:
- 7 R/W registers: ICC_APR_EL1, ICC_APR_EL3, ICC_CR0_EL1, ICC_CR0_EL3
  ICC_ICSR_EL1, ICC_PCR_EL1, ICC_PCR_EL3.
- 6 RO registers: ICC_DOMHPPIR_EL3, ICC_HAPR_EL1, ICC_HPPIR_EL1,
  ICC_HPPIR_EL3, ICC_IAFFIDR_EL1, ICC_IDR0_EL1.

Note: the already-existing ID_AA64PFR2_EL1 register is required by the
GICv5 feature.
2025-10-06 17:56:26 +00:00
Saurabh Jha
a149def232 gas: aarch64: Add instructions for GICv5
Add new instructions from the Generic Interrupt Controller, GICv5,
extension. These instructions are aliases to system instructions and are
the following:

* gic <operation>, <reg>
* gicr <reg>, <operation>
* gsb <operation>
2025-10-06 17:56:26 +00:00
Saurabh Jha
c3954fc3a1 gas: aarch64: Add flag for GICv5
Generic Interrupt Controller v5, GICv5, adds new system registers
and system instructions. These are enabled with the +gcie flag, where
gcie stands for GICv5 (Generic Interrupt Controller) CPU Interrupt
Extension.
2025-10-06 17:56:26 +00:00
Alan Modra
3fc9616817 mips gas: expression initialisation
There is a make_expr_symbol in append_insn, which gets called from
macro_build, which is all over the place.  Many of these set up an
expression without initialising all fields.  Now the uninitialised
fields should not be accessed in a properly functioning assembler,
but I'm inclined to think anything copied ought to be initialised.

	* config/tc-mips.c (fix_loongson2f_jump, load_register),
	(add_got_offset, add_got_offset_hilo, macro_build_branch_likely),
	(macro, mips16_macro, s_cpload, s_cpsetup, s_cprestore)
	(s_cpreturn): Use structure initialiser to ensure all fields of
	expression are initialised.
	(load_address): Copy entire structure for the same reason.
2025-10-04 09:39:02 +09:30
Alan Modra
e3f9c2f90e gas: more expression initialisation
There are many more places that copy an uninitialised expressionS to a
symbol via symbol_set_value_expression and make_expr_symbol.  This
patch focuses on general gas code that does that, and a few backends.

Note that unlike the i386 case that oss-fuzz found, it is likely that
the tc-alpha.c, tc-ppc.c and tc-tic54x.c changes are not fixing bugs,
alpha and tic54x because they don't use X_md, ppc because it carefully
handles X_md.  Also, as an example an O_constant expression should
only ever have its X_add_number field accessed, therefore the other
fields can stay uninitialised.  However, I think that copying
uninitialised struct fields around is not good practice.  If nothing
else it can be confusing when examining symbols under gdb.

I also replaced gen-sframe.c "#ifdef SFRAME_FRE_TYPE_SELECTION_OPT"
with "if (SFRAME_FRE_TYPE_SELECTION_OPT)" so code in the false
branches is compiled and thus less likely to bitrot.  (As far as I can
see, SFRAME_FRE_TYPE_SELECTION_OPT is always 1.)

	* cgen.c (expr_build_binary): Use structure initialiser to
	ensure all fields of expression are initialised.
	* config/obj-coff.c (obj_coff_val): Likewise.
	* config/tc-alpha.c (add_to_link_pool): Likewise.
	* config/tc-i386-intel.c (i386_intel_simplify): Likewise.
	* config/tc-mips.c (fix_loongson2f_jump, load_register),
	(load_address, add_got_offset, add_got_offset_hilo),
	(macro_build_branch_likely, macro, mips16_macro),
	(s_cpload, s_cpsetup, s_cprestore, s_cpreturn): Likewise.
	* config/tc-ppc.c (ppc_function): Likewise.
	* config/tc-tic54x.c (tic54x_field): Likewise.
	* dw2gencfi.c (output_cfi_insn): Likewise.
	* expr.c (expr_build_uconstant): Likewise.
	* read.c (s_mri_common): Likewise.
	* gen-sframe.c (create_fre_start_addr_exp),
	(create_func_info_exp, output_sframe_row_entry): Likewise.
	Don't conditionally compile via SFRAME_FRE_TYPE_SELECTION_OPT.
	* cgen.c (gas_cgen_parse_operand): Use md_expr_init_rest.
	* config/tc-microblaze.c (microblaze_s_weakext): Likewise.
	* ecoff.c (ecoff_directive_weakext, ecoff_stab): Likewise.
	* read.c (pseudo_set): Likewise.
2025-10-04 09:39:02 +09:30
Alan Modra
aa89566392 gas: initialisation of expressionS in operand()
This patch removes clean_up_expression which runs just before operand()
returns.  clean_up_expression sets as yet uninitialised fields of
expressionS.  Well, it sets fields based on the value of X_op,
trusting that others have been written, and has one notable exception:
X_md is not initialised.

Instead initialise expressionS fully inside operand(), which is called
at the start of expr(), and introduce md_expr_init for the odd
backends that want to mess with X_md.

This is in response to an oss-fuzz report that read.c:pseudo_set calls
expr() leaving exp.X_md uninitialised and can copy that to a symbol
via symbol_set_value_expression.  tc-i386-intel.c:565 is one place
that later tests the uninitialised X_md.

	* config/tc-z80.h (md_expr_init, md_expr_init_rest): Define.
	* config/tc-microblaze.h: Likewise.
	* expr.c (clean_up_expression): Delete.
	(operand): Init expression early.
	(expr): Use md_expr_init_rest to init X_md when necessary.
2025-10-04 09:39:02 +09:30
Alan Modra
4208f50c6d arc gas: don't use X_md as input to expression()
tc-arc.c:tokenize_arguments tweaks expression() parsing, controlling
whether arc_parse_name does anything by setting X_op and X_md in the
expressionS argument passed to expression().  I want to change expr()
to always fully initialise its result, and that means either a special
expression initialiser for arc, or controlling arc_parse_name by some
other means.  Since arc_parse_name already tests "assembling_insn" and
no other code does, change "assembling_insn" to directly control
arc_parse_name.  Doing it this way also stops a possible uninitialised
access to right.X_op from expr() in arc_parse_name with current gas.
The next patch in this series will also stop such uninitialised
accesses.

	* config/tc-arc.c (assembling_insn): Update comment.
	(tokenize_arguments): Don't set X_op and X_md to control
	expression(), instead just use assembling_insn.
	(md_operand): Similarly.
	(arc_parse_name): Don't test X_op and X_md.
	(md_assemble): Don't set assembling_insn here.
2025-10-04 09:39:02 +09:30
Rainer Orth
d69c70ce89 gas: Default to V8+ on 32-bit Solaris/SPARC
While compilers default to v8plus on 32-bit Solaris/SPARC (gcc at least
since 4.4 in 2009, cc since at least Stdio 9 in 2010), gas still uses a
sparclite default.  While this doesn't cause issue for gcc (it passes
-Av8plus as necessary), it repeatedly lead to problems in the testsuite
which has to be sprinkled with setting ASFLAGS accordingly since gas cannot
assemble the gcc output by default.

This patch switches the default to v8plus on Solaris to match gcc.
I had to introduce a new arch value, v8plus-32, matching v9-64, to allow
for this.

I cannot reliably tell if other SPARC targets are similarly affected, so
this patch restricts the change to Solaris.

Tested on sparc-sun-solaris2.11 and sparcv9-sun-solaris2.11.

2025-09-25  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gas:
	* config/tc-sparc.c (sparc_arch_table): Introduce v8plus-32.
	* configure.tgt (generic_target) <sparc-*-solaris*>: Set arch to
	v8plus-32 for 32-bit sparc.
	* testsuite/gas/sparc/v8plus.rd, testsuite/gas/sparc/v8plus.s: New
	test.
	* testsuite/gas/sparc/sparc.exp: Run it on sparc*-*-solaris2*.
2025-09-30 13:06:50 +02:00
H.J. Lu
4f62e7d83f Binutils: Add clang LTO support to AR and RANLIB
Detect the clang plugin file and and pass it to --plugin for ar and ranlib
so that binutils can be built with clang LTO.

bfd/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

binutils/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

gas/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

gprof/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.
	* testsuite/Makefile.in: Likewise.

gprofng/

	PR binutils/33470
	* Makefile.am (ACLOCAL_AMFLAGS): Add -I ../config.
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.
	* gp-display-html/Makefile.in: Likewise.
	* libcollector/Makefile.in: Likewise.
	* libcollector/aclocal.m4: Likewise.
	* libcollector/configure: Likewise.
	* src/Makefile.in: Likewise.
	* libcollector/Makefile.am (ACLOCAL_AMFLAGS): Add -I ../../config.

ld/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

libctf/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

libsframe/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

opcodes/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-09-25 12:30:13 +08:00
Alice Carlotti
1b28f5f095 aarch64: Remove unused feature bits
Many feature bits were unnecessarily added for features with no command
line flags, and effectively acted as aliases of the architecture version
bit they were linked to.  The system register regating patch removed all
uses of these feature bits, so we can just remove them.
2025-09-23 19:42:45 +01:00
Alice Carlotti
2742455bf4 aarch64: Update system register gating
Historically we have been inconsistent and overly restrictive in our
choice of features to gate system register accesses.  (Originally this
gating was always applied, but now it is disabled unless the
--menable-sysreg-checking option is specified).

This patch updates these constraints, following the principle that we
should only reject a system register access if it requires some
architecture feature or version whose corresponding command line
extension has not been enabled.

The most common change in this patch concerns system registers that
were:
- part of a feature FEAT_X with no corresponding command line extension;
- introduced in a newer architecture version ArmvX.Z;
- permitted to be implemented from an earlier version ArmvX.Y.
Previously these system registers tended to be gated on ArmvX.Z or left
ungated, but following the above principle they are now gated on ArmvX.Y
instead.
2025-09-23 19:42:44 +01:00
Alice Carlotti
ab1f841c47 aarch64: Remove CSRE system registers
Most support for CSRE was removed from Binutils in 2021 after it was
removed from the architecture.  This patch removes the remaining system
registers and test files.
2025-09-23 19:42:44 +01:00
Alice Carlotti
8c0024ca8f aarch64: Remove teecr32_el1 and teehbr32_el1
These system registers were removed from the architecture over a decade
ago, so there's no need to continue supporting them.
2025-09-23 19:42:44 +01:00
Alice Carlotti
9ca0278eee aarch64: Relax sysreg-1.d test expectations
Accept any instruction address in each line - this will simplify the
removal of instructions from this file in a later patch.
2025-09-23 19:42:44 +01:00
Alice Carlotti
6fc99d53ba aarch64: Add missing system registers
This adds all of the system registers present in the 2025-03 release of
the Architecture Registers spec (DDI0601) that were missing from
Binutils.
2025-09-23 19:42:44 +01:00
Alice Carlotti
caafd84845 aarch64: Add FEAT_SRMASK system registers 2025-09-23 19:42:43 +01:00
Alice Carlotti
563f417352 aarch64: Make spmzr_el0 write-only
Remove all test cases that expect spmzr_el0 to be readable, and remove
some redundant default macro values from armv9_5-a-sysregs.s while we're
there.

Add a read of spmzr_el0 to sysreg-diagnostics.s.  This turns out to be
the first test for the "reading from a write-only register" note.
Also remove the recently added -menable-sysreg-checking option from this
test, both to simplify the addition of spmzr_el0 to the test, and to
verify that read/write diagnostics don't depend on that option.
2025-09-23 19:42:43 +01:00
Alice Carlotti
22c3912a11 aarch64: Remove F_ARCHEXT flag
The flag is unnecessary, because we can just unconditionally check the
features field every time.  Having the information duplicated in two
separate fields makes it harder to maintain, particularly in the context
of the upcoming regating patch.

The reg_flags parameter of aarch64_sys_ins_reg_supported_p is now
unused, so remove that as well.
2025-09-23 19:42:43 +01:00
Rainer Orth
1fcb94ed75 Remove remnants of Solaris/PowerPC support
When removing Solaris/PowerPC support, I missed a couple of references.
This patch removes them.

Tested with crosses to ppc-unknown-linux-gnu and powerpc-ibm-aix7.

2025-09-17  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* configure.ac <powerpcle-*-solaris*>: Remove.
	* configure: Regenerate.

	bfd:
	* config.bfd <powerpcle-*-solaris2*>: Remove.

	gas:
	* configure.tgt <ppc-*-solaris*>: Remove.
2025-09-18 16:17:14 +02:00
Nick Clifton
3b465bc232 Updated and new translations for the binutils 2025-09-18 11:56:52 +01:00
Richard Earnshaw
36d3a92d97 gas: testsuite: aarch64: Resolve duplicate testrun names.
These are all simple typos in the test names.
2025-09-16 15:46:25 +01:00
Richard Earnshaw
3ce20eee24 gas: testsuite: aarch64: Remove duplicate test from sv2p1-5.d
This test runs with the assembler options '-march=armv9.4-a' twice.
Looking at the related tests in this set, this appears to be redundant
rather than a typo, so remove the second run.
2025-09-16 15:46:25 +01:00
Nick Clifton
2bd154966a gas: Define comment_chars for non-ELF PowerPC targets 2025-09-16 14:46:01 +01:00
Richard Earnshaw
8c65d27b7d gas: testsuite: all: Avoid clashing names in err-sizeof.s
The first junk test in this file was missing "junk" in the test name,
which resulted in a duplicate test name when comparing with the real
test on line 3.
2025-09-16 10:31:11 +01:00
Richard Earnshaw
33c2a7b90d gas: testsuite: elf: avoid clashing mbind test names
The section12b.d test has the wrong name, leading to a clash with the
section 16b.d test.  Fix that up.
2025-09-16 10:31:11 +01:00
Richard Earnshaw
a2b55b8fde gas: testsuite: all: use unique test names for multibyte3 tests
There are two tests of the mutibyte3 source file, with different
options.  As things stand this results in two distinct tests in the
logs with the same name.  Avoid this by adding the optional testname
option to the second test.
2025-09-16 10:31:10 +01:00
Rainer Orth
97ea2d2514 Remove Solaris/PowerPC support
Solaris/PowerPC was a shortlived Solaris port with limited hardware
support.  It was released with Solaris 2.5.1 back in 1996, with support
removed again only a year later in Solaris 2.6.  Since this is long
obsolete, this patch removes the remains of the support.

Tested by a cross to ppc-unknown-linux-gnu to ascertain the build didn't
get broken.

2025-09-15  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	bfd:
	* config.bfd <powerpc-*-solaris2*>: Remove.

	gas:
	* NEWS: Mention Solaris/PowerPC removal.

	* configure.ac <ppc-*-solaris*>: Remove.
	* configure: Regenerate.
	* configure.in: Regenerate.
	* configure.tgt <ppc-*-solaris*>: Remove.

	* config/tc-ppc.c (ppc_solaris_comment_chars): Remove.
	(ppc_eabi_comment_chars): Remove.
	(SOLARIS_P): Remove.
	(msolaris): Remove.
	(md_parse_option): Remove "solaris", "no-solaris" hangling.
	(md_show_usage): Likewise.
	(md_begin): Remove msolaris handling.
	* config/tc-ppc.h (ppc_comment_chars): Fix declaration.
	* stabs.c (s_stab_generic) [TC_PPC && OBJ_ELF]: Remove 4-arg
	.stabd support.

	* doc/as.texi (Overview, Target PowerPC options): Remove
	-msolaris, -mno-solaris.
	* doc/c-ppc.texi (PowerPC-Opts): Remove -msolaris, -mno-solaris.
	(PowerPC-Chars): Remove ! as line comment character.

	ld:
	* configure.tgt <powerpc*-*-solaris*>: Remove.
2025-09-16 09:56:38 +02:00
Alan Modra
48a3ce61a0 gas/expr.h fixme
* expr.h (expressionS): Adjust comments.  Use ENUM_BITFIELD
	for X_op.
	(enum operatorT): Define.
2025-09-16 10:47:17 +09:30
Alan Modra
c12d64bbd5 Delete gas/po/gas.es.po
es.po is newer, and this file is wrongly named.
2025-09-16 10:45:44 +09:30
Richard Earnshaw
986d1a5c29 arm: Rename some tests to avoid duplicate tests names
A number of arm-specific tests print the same name.  This can cause problems
if one of those tests fails, since then comparing tests with GCC's
compare_tests script can result in ambiguities in the changes summary.

Avoid this by giving tests unique names.

Still to do is where a test is run more than once (eg by having multiple
'#as: ' lines).  This will require a tweak to the framework.
2025-09-15 11:42:52 +01:00
Dongyan Chen
6affec82bd RISC-V: Add support for sdtrig and ssstrict extensions.
This implements the sdtrig extension, version 1.0[1] and ssstrict
extension, version 1.0[2].

[1]https://github.com/riscv/riscv-debug-spec/blob/main/Sdtrig.adoc
[2]https://github.com/riscv/riscv-profiles/issues/173

bfd/ChangeLog:

	* elfxx-riscv.c: Added sdtrig and ssstrict v1.0, and imply rules.

gas/ChangeLog:

	* NEWS: Updated for sdtrig and ssstrict.
	* testsuite/gas/riscv/imply.d: DItto.
	* testsuite/gas/riscv/imply.s: Ditto.
	* testsuite/gas/riscv/march-help.l: Ditto.
2025-09-15 10:04:24 +08:00
Nelson Chu
0f0b6cec20 RISC-V: Fixed more testcases for --with-arch and --with-abi
Same as cabae1c1c8
2025-09-12 11:56:47 +08:00
Jiawei
cabae1c1c8 testsuite: RISC-V: Add '.option norvc' to ensure consistent results.
Add `.option norvc` to several RISC-V tests to avoid compressed
instruction generation.  This ensures consistent disassembly and
alignment behavior regardless of assembler default options.

Discussion see:
https://patchwork.sourceware.org/project/binutils/patch/20250910120916.1103023-1-jiawei@iscas.ac.cn/

gas/ChangeLog:

	* testsuite/gas/riscv/dis-partial-insn.s: Limit compressed.
	* testsuite/gas/riscv/no-relax-align.s: Ditto.
	* testsuite/gas/riscv/odd-padding.s: Ditto.
	* testsuite/gas/riscv/t_insns.s: Ditto.
	* testsuite/gas/riscv/tlsdesc.s: Ditto.
2025-09-11 12:03:43 +08:00
Nelson Chu
d0f2ab89ab RISC-V: Remove ^M for odd-padding.s testcase 2025-09-11 12:03:04 +08:00
Indu Bhagat
84c1e5cec0 gas: sframe: skip DW_CFA_GNU_args_size when safe to ignore
Currently, gas warns and skips generating SFrame FDE when it sees:
     .cfi_escape 0x2e,XX

From the documentation of DW_CFA_GNU_args_size:
 "The DW_CFA_GNU_args_size instruction takes an unsigned LEB128 operand
  representing an argument size. This instruction specifies the total of
  the size of the arguments which have been pushed onto the stack."

With origins seemingly for VAX architecture, the usage of
DW_CFA_GNU_args_size seems to have evolved.  The purpose of
DW_CFA_GNU_args_size is to adjust SP when performing stack unwinding for
exception handling.

For the purpose of stack tracing using SFrame, DW_CFA_GNU_args_size is
safe to skip, especially when the CFA restoration is known to be FP
based.  A previous summary of the reasoning and intent was indicated
here [1].

[1] https://sourceware.org/pipermail/binutils/2025-August/143829.html

This fixes PR gas/33414 - sframe: handle DW_CFA_GNU_args_size in gas better

gas/
	PR gas/33414
	* gen-sframe.c (sframe_xlate_do_escape_gnu_args_size): New
	definition.
	(sframe_xlate_do_cfi_escape): Handle DW_CFA_GNU_args_size.
gas/testsuite/
	PR gas/33414
	* gas/cfi-sframe/cfi-sframe.exp: New test.
	* gas/cfi-sframe/cfi-sframe-common-12.d: New test.
	* gas/cfi-sframe/cfi-sframe-common-12.s: New test.
	* gas/cfi-sframe/cfi-sframe-x86_64-3.d: New test.
	* gas/cfi-sframe/cfi-sframe-x86_64-3.s: New test.
2025-09-10 11:13:21 -07:00
Jan Beulich
5d0ac9ee8f x86: constrain and fix use of the "nojumps" .arch modifier
As said by the paragraph of the description that isn't modified here (a
few lines up), this was only ever supposed to be used with 16-bit
architectures. Actually enforcing this allows code in
md_estimate_size_before_relax() to move to a less frequently used code
path. (For backwards compatibility, keep accepting "jumps" also with 32-
or 64-bit architectures.)

Repeat the constraint also in the 2nd paragraph of the doc on this
subject. And while there also insert a missing insn in the related
i386-Jumps section.

Furthermore checking a global variable during late processing is wrong. We
need to record the state in the fragment, and use that rather than the
state of the variable at the end of parsing all input.

Seeing that there's no testing of the functionality at all, add a testcase
as well.
2025-09-08 11:11:51 +02:00
Jan Beulich
149e0b44f3 x86: make TC_FRAG_INIT() resolve to a function call
This way we can avoid making various global variables non-static. Their
set is to only ever grow, really.
2025-09-08 11:10:55 +02:00
Jan Beulich
496e01123d x86: check reloc types for relaxable branches
Bypassing _reloc() isn't a good idea, as there are various errors
checked for there. For example 16-bit JMP or Jcc may not use the @plt
form (resulting in a 32-bit relocation to be emitted for a 16-bit
field), which so far we only reject for 16-bit CALL. In exchange this
allows simplifying the setting up of the "reloc_type" local variable.
2025-09-05 08:33:27 +02:00
Jan Beulich
16d95f5ccf x86: make reloc() usable during late phases of assembly
Introduce a clone with extra parameters, to allow subsequent use from
md_estimate_size_before_relax() (or elsewhere, should that turn out
necessary). There flag_code cannot be used and location information
needs to be provided for diagnostics.
2025-09-05 08:32:25 +02:00
Nelson Chu
cea397848b RISC-V: Fixed missed GOT relocation against a symbol that has a defined value
SImilar to aarch64, commit eac4eb8ecb

There are two problems when GOT relocation against a symbol that has a defined
value,
1. Pesudo la with pic and pseudo lga lost the relocations.
2. %got_pcrel_hi generates R_RISCV_GOT_HI20 with addend, which is wrong since
   commit 50331d64f1.

The solution is to use deferred_expression for GOT relocation.  Maybe other
relocations also have same problem and need the deferred_expression, but we can
add in the future patches.
2025-09-04 16:32:18 +08:00
Alan Modra
5e2ebcf1ea mips: remove unnecessary obstack_finish
It isn't necessary to call obstack_finish before obstack_free of an
unwanted string.

	* config/tc-mips.c (mips_parse_arguments): Replace obstack_finsih
	with obstack_base.
2025-09-04 07:36:08 +09:30
Alan Modra
98583463ab Disable eh_frame optimisation if code detected in .eh_frame
Fuzzers stress the assembler in ways no sane programmer would ever do.
One x86 oss-fuzz testcase (cleaned up a litte) was:
 .sect .debug_frame
 call x
 .long x,0
 .space 1
 .long 0,0
The call insn leaves the frag data corresponding to a CIE
uninitialised until later in assembly, leading to reports of
uninitialised data access in ehopt.c:check_eh_frame.

Hack around this problem by noticing an insn has been assembled in
dwarf2_emit_insn.  The existing frag has_code can't be used as that
leads to alignment complaints, so add a new segment_info flag.

	* subsegs.h (struct segment_info_struct): Move bss and hadone
	later.  Rename hadone to stab_seen.  Add insn_seen bitfield.
	* dwarf2dbg.c (dwarf2_emit_insn): Set insn_seen.
	* ehopt.c (check_eh_frame): Disable optimisation if insn_seen.
	* stabs.c (s_stab_generic): Adjust for hadone rename.
2025-09-03 11:22:06 +09:30
Alan Modra
180075d14f frag_alloc use of obstack_alloc
Avoid the alignment hackery necessary when obstack_alloc is used.
obstack_alloc expands to obstack_blank plus obstack_finish, and the
latter call is where alignment of the tail of the obstack happens.

The docs say obstack_alloc "is invoked almost like malloc", which
implies a fixed size allocation and you don't need other obstack calls
in its use.  So I think trying to use obstack_alloc in frag_alloc was
always a poor choice.

	* frags.c (frag_alloc): Replace obstack_alloc with obstack_blank.
2025-09-03 11:14:21 +09:30
Alan Modra
fcd717899e Explain frag alignment hacks
"the weird alignment hackery" comment doesn't help anyone understand
the code.  Explain what is going on.  Replace the zero length
obstack_alloc with obstack_finish, which by inspection of obstack.h is
all the zero length alloc does.

	* frags.c (frag_alloc): Comment.  Replace zero length
	obstack_alloc with obstack_finish.
	(frag_new): Remove unnecessary obstack_finish.
	* write.c (compress_frag, compress_debug): Likewise.
2025-09-03 10:31:35 +09:30
Alan Modra
11e5824cda make frag fr_type a bitfield
For better packing of struct frag.

	* frags.h (struct frag <fr_type>): Use ENUM_BITFIELD.
2025-09-03 10:30:47 +09:30