Commit Graph

119288 Commits

Author SHA1 Message Date
Jens Remus
42e6e6904b gas: Don't skip SFrame FDE if .cfi_register specifies SP register
Neither ".cfi_offset SP, <offset>", ".cfi_register SP, <regno>", nor
".cfi_val_offset SP, <offset>" alter the tracking information to recover
the stack pointer (SP). Doing so would need an explicit .cfi_def_cfa,
which SFrame tracks.

The stack pointer (SP) register contents on entry can be reconstructed
from the SFrame CFA tracking information using information from the
current and initial SFrame FREs of the SFrame FDE:

1. Compute CFA from the current CFA base register (SP or FP) and CFA
   offset from the SFrame CFA tracking information from the SFrame FRE
   for the current instruction address:

     CFA = <current_base_reg> + <current_cfa_offset>

2. Compute SP from the current CFA and the CFA offset from the SFrame
   CFA tracking information from the initial SFrame FRE of the FDE:

     SP = CFA - <initial_cfa_offset>

While at it add comments to the processing of .cfi_offset and
.cfi_val_offset that the SP can be reconstructed from the CFA tracking
information.

gas/
	* gen-sframe.c (sframe_xlate_do_register): Do not skip SFrame
	FDE if .cfi_register specifies SP register.
	(sframe_xlate_do_offset,sframe_xlate_do_val_offset): Add comment
	that this is likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
df174a6b76 gas: Don't skip SFrame FDE if .cfi_register specifies RA w/o tracking
Do not skip SFrame FDE if .cfi_register specifies RA register without
RA tracking being actually used. Without RA tracking the register
contents can always be restored from the stack using the fixed
RA offset from CFA.

gas/
	* gen-sframe.c (sframe_xlate_do_register): Do not skip SFrame
	FDE if .cfi_register specifies RA register without RA tracking
	being used.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
541d3b6458 gas: Skip SFrame FDE if .cfi_window_save
CFI opcode DW_CFA_AARCH64_negate_ra_state is multiplexed with
DW_CFA_GNU_window_save. Process DW_CFA_AARCH64_negate_ra_state on
AArch64. Skip generation of SFrame FDE otherwise with the following
warning message:

  skipping SFrame FDE; .cfi_window_save

gas/
	* gen-sframe.c: Skip SFrame FDE if .cfi_window_save.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
c6024caf0c gas: Skip SFrame FDE if FP without RA on stack
The SFrame format cannot represent the frame pointer (FP) being saved
on the stack without the return address (RA) also being saved on the
stack, if RA tracking is used.

A SFrame FDE is followed by 1-3 offsets with the following information:

Without RA tracking:
1. Offset from base pointer (SP or FP) to locate the CFA
2. Optional: Offset to CFA to restore the frame pointer (FP)

With RA tracking:
1. Offset from base pointer (SP or FP) to locate the CFA
2. Optional: Offset to CFA to restore the return address (RA)
3. Optional: Offset to CFA to restore the frame pointer (FP)

When RA tracking is used and a FDE is followed by two offsets the
SFrame format does not provide any information to distinguish whether
the second offset is the RA or FP offset. SFrame assumes the offset to
be the RA offset, which may be wrong.

Therefore skip generation of SFrame FDE information and print the
following warning, if RA tracking is used and the FP is saved on the
stack without the RA being saved as well:

  skipping SFrame FDE; FP without RA on stack

gas/
	* gen-sframe.c (sframe_do_fde): Skip SFrame FDE if FP without RA
	on stack, as the SFrame format cannot represent this case.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
536119a44c gas: User readable warnings if SFrame FDE is not generated
The following generic warning message, which is printed whenever the
assembler skips generation of SFrame FDE, is not very helpful for the
user:

  skipping SFrame FDE; CFI insn <name> (0x<hexval>)

Whenever possible print meaningful warning messages, when the assembler
skips generation of SFrame FDE:

- skipping SFrame FDE; non-SP/FP register <regno> in .cfi_def_cfa
- skipping SFrame FDE; non-SP/FP register <regno> in
  .cfi_def_cfa_register
- skipping SFrame FDE; .cfi_def_cfa_offset without CFA base register
  in effect
- skipping SFrame FDE; {FP|RA} register <regno> in .cfi_val_offset
- skipping SFrame FDE; {SP|FP|RA} register <regno> in in .cfi_register
- skipping SFrame FDE; .cfi_remember_state without prior SFrame FRE
  state
- skipping SFrame FDE; non-default RA register <regno>

gas/
	* gen-sframe.h (SFRAME_FRE_BASE_REG_INVAL): New macro for
	invalid SFrame FRE CFA base register value of -1.
	* gen-sframe.c: User readable warnings if SFrame FDE is not
	generated.

gas/testsuite/
	* gas/cfi-sframe/common-empty-1.d: Update generic SFrame test
	case to updated warning message texts.
	* gas/cfi-sframe/common-empty-2.d: Likewise.
	* gas/cfi-sframe/common-empty-3.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
397582abe7 gas: Refactor SFrame CFI opcode DW_CFA_register processing
Refactor SFrame processing of CFI opcode DW_CFA_register into a separate
function. This harmonizes the CFI opcode processing.

While at it reword the comment on CFI opcodes that are not processed.

This is a purely mechanical change.

gas/
	* gen-sframe.c (sframe_do_cfi_insn, sframe_xlate_do_register):
	Refactor SFrame CFI opcode DW_CFA_register processing.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
541b0fbbf2 gas: Warn if SFrame FDE is skipped due to non-default return column
Print a warning message if SFrame FDE is skipped due to a non-default
DWARF return column (i.e. return address (RA) register number). This
may be caused by the use of CFI directive .cfi_return_column with a
non-default return address (RA) register number in the processed
assembler source code.

  Warning: skipping SFrame FDE due to non-default DWARF return column

gas/
	* gen-sframe.c: Warn if SFrame FDE is skipped due to non-default
	DWARF return column.

gas/testsuite/
	* gas/cfi-sframe/common-empty-3.d: Update test case to expect
	for new warning message when SFrame FDE is skipped due to
	a non-default DWARF return column.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
e24992c334 gas: Skip SFrame FDE if CFI specifies non-FP/SP base register
Do not generate SFrame FDE if DWARF CFI directives .cfi_def_cfa or
.cfi_def_cfa_register specify a CFA base register number other than
the architecture-specific stack-pointer (SP) or frame-pointer (FP)
register numbers.

This also causes the assembler to print a warning message, so that
skipping of the SFrame FDE does not occur silently.

Update the generic ld SFrame test case to be architecture independent.
Do not use CFI directive .cfi_def_cfa, as the specified CFA base
register number is not a valid SP/FP register number on all
architectures. An invalid SP/FP register number will now cause the
assembler to print a warning message and skip SFrame FDE generation.
Remove the offending CFI directive, that cannot be coded architecture-
independent, as the test case requires SFrame information to be
generated. This was reported by the Linaro-TCWG-CI for AArch64.

gas/
	* gen-sframe.c: Skip SFrame generation if CFI specifies
	non-FP/SP base register.

ld/testsuite/
	* ld-sframe/discard.s: Update generic SFrame test case to be
	architecture independent.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
bdde1b34c4 gas: Print DWARF call frame insn name in SFrame warning message
SFrame generation prints the DWARF call frame instruction opcode in
hexadecimal. Leverage get_DW_CFA_name to additionally print the
DWARF call frame instruction name in human readable form, while also
respecting fake CFI types. Use "(unknown)", if the DWARF call frame
instruction name is not known.

While at it use the terminology "instruction" for these DW_CFA_*, as
suggested by Indu.

This changes the following assembler SFrame generation warning message
as follows:

Old:
Warning: skipping SFrame FDE due to DWARF CFI op 0x<hexval>

New:
Warning: skipping SFrame FDE; CFI insn <name> (0x<hexval>)

gas/
	* gen-sframe.c (sframe_get_cfi_name): New function to get the
	DWARF call frame instruction name for a DWARF call frame
	instruction opcode.
	(sframe_do_cfi_insn): Use sframe_get_cfi_name to print the
	DWARF call frame instruction name for the DWARF call frame
	instruction opcode in the warning message.

gas/testsuite/
	* gas/cfi-sframe/common-empty-1.d: Update expected SFrame
	warning message text for DWARF call frame insn name.
	* gas/cfi-sframe/common-empty-2.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
5c7f6da432 readelf/objdump: Display SFrame fixed RA offset as 'f' in dump
For the SFrame FRE frame-pointer (FP) offset from CFA a 'u' is displayed
if it is unavailable.

For the SFrame FRE return-address (RA) offset from CFA a 'u' was
displayed if the ABI uses a fixed RA offset from CFA. By chance a
'u' was also displayed if the RA offset is unavailable, as the string
buffer was not initialized after formatting the FP offset. Note that it
could not occur that the FP offset was erroneously displayed as RA
offset, as the SFrame format cannot have a FRE with FP offset without
RA offset.

For the FRE RA offset display 'f' if the ABI uses a fixed RA offset
from CFA. Display a 'u' if it is unavailable.

libsframe/
	* sframe-dump.c: Display SFrame fixed RA offset as 'f' in dump.

gas/testsuite/
	* gas/cfi-sframe/cfi-sframe-common-4.d: Test for RA displayed
	either as 'u' (if RA tracking) or as 'f' (fixed RA offset if no
	RA tracking).
	* gas/cfi-sframe/cfi-sframe-common-5.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-6.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-7.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-8.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-x86_64-1.d: Test for RA displayed
	as 'f' (fixed RA offset), as x86-64 does not use RA tracking.
	* gas/scfi/x86_64/scfi-cfi-sections-1.d: Likewise.
	* gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise.

ld/testsuite/
	* ld-x86-64/sframe-plt-1.d: Test for RA displayed as 'f' (fixed
	RA offset), as x86-64 does not use RA tracking.
	* ld-x86-64/sframe-simple-1.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
76f05e1dfb readelf/objdump: Dump SFrame CFA fixed FP and RA offsets
The SFrame format allows architectures to specify fixed offsets from the
CFA, if any, from which the frame pointer (FP) and/or return address
(RA) may be recovered. These offsets are stored in the SFrame header.

For instance the SFrame generation in the assembler for x86 AMD64
specifies a fixed offset from the CFA, from which the return address
(RA) may be recovered.

When dumping the SFrame header, for instance in readelf/objdump with
option --sframe, do also dump the specified fixed offsets from the CFA,
if any, from which the frame pointer (FP) and return address (RA) may
be recovered.

Update the common SFrame test case verification patterns to allow for
the optional dumping of the CFA fixed FP/RA offsets. Update the x86-
specific SFrame and SCFI test case verification patterns to require a
CFA fixed RA offset of -8.

libsframe/
	* sframe-dump.c: Dump CFA fixed FP and RA offsets.

gas/testsuite/
	* gas/cfi-sframe/cfi-sframe-common-1.d: Test for optional fixed
	FP and RA offsets.
	* gas/cfi-sframe/cfi-sframe-common-2.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-3.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-4.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-5.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-6.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-7.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-8.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-x86_64-1.d: Test for fixed
	RA offset.
	* gas/cfi-sframe/common-empty-1.d: Test for optional fixed
	FP and RA offsets.
	* gas/cfi-sframe/common-empty-2.d: Likewise.
	* gas/cfi-sframe/common-empty-3.d: Likewise.
	* gas/scfi/x86_64/scfi-cfi-sections-1.d: Test for SFrame fixed
	RA offset.
	* gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise.

ld/testsuite/
	* ld-x86-64/sframe-plt-1.d: Test for SFrame fixed RA offset.
	* ld-x86-64/sframe-simple-1.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
8086fe0b3d gas: Enhance arch-specific SFrame configuration descriptions
Explicitly mention "SFrame" in the descriptions for the architecture-
specific SFrame configuration macros, variables, and functions.

Use the term "frame pointer" (FP) instead of "base pointer". This aligns
with the terminology used in the SFrame specification. Additionally it
helps not to confuse "base-pointer register" with the term "BASE_REG"
used in the specification to denote either the SP or FP register.

Specify what the SFRAME_CFA_*_REG register numbers are used for:
- SP (stack pointer): CFA tracking
- FP (frame pointer): CFA and FP tracking
- RA (return address): RA tracking

Align the descriptions for definitions in the source files to the
declarations in the header files.

gas/
	* config/tc-aarch64.h: Enhance architecture-specific SFrame
	configuration descriptions.
	* config/tc-aarch64.c: Likewise.
	* config/tc-i386.h: Likewise.
	* config/tc-i386.c: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Jens Remus
73b56ef2fd x86: Remove unused SFrame CFI RA register variable
gas/
	* config/tc-i386.c (x86_sframe_cfa_ra_reg): Remove.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04 10:34:12 +02:00
Cui, Lili
b0dd832fa4 Support APX CFCMOV
The CMOVcc instruction proposed by EVEX has four different forms,
corresponding to the four possible combinations of EVEX.ND and EVEX.NF
values.

In the encoder part, when the CFCMOV template supports EVEX_NF, it means that
it requires EVEX.NF to be 1.

In the decoder part, CFCMOV_Fixup is used to reverse source and destination
operands in the 2-operand case.

gas/ChangeLog:

        * config/tc-i386.c (build_apx_evex_prefix): Set NF bit for cfcmov
        when the insn template supports EVEX_NF.
        * testsuite/gas/i386/x86-64-apx-inval.l: Add invalid tests for cfcmov.
        * testsuite/gas/i386/x86-64-apx-inval.s: Ditto.
        * testsuite/gas/i386/x86-64.exp: Add tests for cfcmov and cmov.
        * testsuite/gas/i386/x86-64-apx-cfcmov-intel.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-cfcmov.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-cfcmov.s: Ditto.

opcodes/ChangeLog:

        * i386-dis-evex-prefix.h: Add cfcmov instructions.
        * i386-dis.c (CFCMOV_Fixup): Special handling of cfcmov.
        (putop): Print 'cf' for cfcmov instructions.
        * i386-opc.h (EVEX_NF): New.
        * i386-opc.tbl: Add cfcmov instructions.
        * i386-mnem.h: Regerated.
        * i386-tbl.h: Regerated.
2024-07-04 15:55:00 +08:00
GDB Administrator
026eb0595f Automatic date update in version.in 2024-07-04 00:00:07 +00:00
Nelson Chu
14ea7f9b44 RISC-V: Tidy and complete testing of all architecture imply rules.
gas/
	* testsuite/gas/riscv/imply.s: New testcase for all imply cases.
	* testsuite/gas/riscv/imply.d: Likewise.
	* testsuite/gas/riscv/march-imply-i.s: Renamed to
	imply-zicsr-zifencei.s.
	* testsuite/gas/riscv/march-imply-i2p0-02.d: Renamed to
	imply-zicsr-zifencei-i2p0-misa-spec-2p2.d.
	* testsuite/gas/riscv/march-imply-i2p1-01.d/l: Renamed to
	imply-zicsr-zifencei-i2p1-misa-spec-20191213.d.
	* testsuite/gas/riscv/march-imply-i2p0-01.d: Removed.
	Combined into new imply testcase.
	* testsuite/gas/riscv/march-imply-i2p1-02.d: Likewise.
	* testsuite/gas/riscv/march-imply-a.d: Likewise.
	* testsuite/gas/riscv/march-imply-b.d: Likewise.
	* testsuite/gas/riscv/march-imply-f.d: Likewise.
	* testsuite/gas/riscv/march-imply-g.d: Likewise.
	* testsuite/gas/riscv/march-imply-h.d: Likewise.
	* testsuite/gas/riscv/march-imply-q.d: Likewise.
	* testsuite/gas/riscv/march-imply-smcsrind.d: Likewise.
	* testsuite/gas/riscv/march-imply-smstateen.d: Likewise.
	* testsuite/gas/riscv/march-imply-unsupported.d: Likewise.
	* testsuite/gas/riscv/march-imply-v.d: Likewise.
	* testsuite/gas/riscv/march-imply-zcd.d: Likewise.
	* testsuite/gas/riscv/march-imply-zcf.d: Likewise.
2024-07-03 16:05:59 +08:00
Alan Modra
5b714f5b6d Avoid possible signed overflow in decode_local_label_name
Matches what both fb_label_name and dollar_label_name use.

	* symbols.c (decode_local_label_name): Use unsigned variables.
2024-07-03 15:37:35 +09:30
Nelson Chu
aa8c6e6484 gas/doc/riscv: Fixed typo of `.insn cj' format
gas/
	* doc/c-riscv.texi: Fixed typo of `.insn cj' format.
2024-07-03 11:42:15 +08:00
Lingling Kong
2d5428d8cd x86-64: Support APX NF TLS IE with 2 operands
Support APX NF TLS IE with 2 operands.Verify it with ld and gold.

gas/

	* config/tc-i386.c (md_assemble): Allow APX NF TLS IE with
	2 operands.
	* testsuite/gas/i386/x86-64-gottpoff.d: Updated.
	* testsuite/gas/i386/x86-64-gottpoff.s: Add APX NF TLS IE
	tests with 2 operands.

gold/

	* testsuite/x86_64_ie_to_le.s: Add APX NF TLS IE tests with
	2 operands.
	* testsuite/x86_64_ie_to_le.sh: Updated.

ld/

	* testsuite/ld-x86-64/tlsbindesc.s: Add APX NF TLS IE tests
	with 2 operands.
	* testsuite/ld-x86-64/tlsbindesc.d: Updated.
	* testsuite/ld-x86-64/tlsbindesc.rd: Likewise.
2024-07-03 10:18:36 +08:00
Nelson Chu
0c43f0a1bc gas/doc/riscv: Fixed syntax of `.option arch' when reseting whole architecture
gas/
	* doc/c-riscv.texi: Fixed syntax of `.option arc'h when reseting whole
	architecture.  Don't need the `=' before ISA.
2024-07-03 09:52:34 +08:00
GDB Administrator
afa87be0fc Automatic date update in version.in 2024-07-03 00:00:16 +00:00
Tom Tromey
4401c3c098 Accept unnamed array in gdb.ada/limited-length.exp
Some compiler changes I'm working on cause a regression in
gdb.ada/limited-length.exp -- with the changes, the array type is
nameless and so is not mentioned in the max-value-size error message.

Because the array type is nameless in the source code, this seems like
an improvement to me, and so this patch changes the test to accept
either form.
2024-07-02 11:15:31 -06:00
Aditya Vidyadhar Kamath
d59d4e2f3a Use lwp field in ptid for AIX.
Currently in AIX, the private data is used to maintain the kernel thread ID.

This is a patch to trim the need to have another field in the private data of a thread in AIX.

We want to use the lwp field to represent the kernel thread ID to match or
make things similar to the Linux targets.
2024-07-02 17:27:31 +02:00
konglin1
eb5d719dd7 x86-64: Verify that TLS IE works with APX NF
Verify that

{nf} add %reg1, foo@gottpoff(%rip), %reg2
{nf} add foo@gottpoff(%rip), %reg, %reg2

work correctly with ld and gold.

gas/

	* testsuite/gas/i386/x86-64-gottpoff.d: Updated.
	* testsuite/gas/i386/x86-64-gottpoff.s: Add tests for
	"{nf} add %reg1, foo@gottpoff(%rip), %reg2" and
	"{nf} add foo@gottpoff(%rip), %reg, %reg2".

gold/

	* testsuite/x86_64_ie_to_le.s: Add tests for
	"{nf} add %reg1, foo@gottpoff(%rip), %reg2" and
	"{nf} add foo@gottpoff(%rip), %reg, %reg2".
	* testsuite/x86_64_ie_to_le.sh: Updated.

ld/

	* testsuite/ld-x86-64/tlsbindesc.s: Add R_X86_64_CODE_6_GOTTPOFF
	for APX NF tests.
	* testsuite/ld-x86-64/tlsbindesc.d: Updated.
	* testsuite/ld-x86-64/tlsbindesc.rd: Likewise.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-07-01 23:08:31 -07:00
GDB Administrator
aa0c55a966 Automatic date update in version.in 2024-07-02 00:00:52 +00:00
H.J. Lu
2539602136 ld: Move foo before delete in dl5.cc
* testsuite/ld-elf/dl5.cc (main): Move foo before delete.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-07-01 02:22:45 -07:00
Claudiu Zissulescu
7fafb57457 MAINTAINERS: Update my e-mail address
Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2024-07-01 10:58:17 +03:00
Xi Ruoyao
d8eca16715 LoongArch: Remove unused code in ld test suite
These seems some left over from MIPS code and they do not make any
sense for LoongArch.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-07-01 10:12:59 +08:00
Alan Modra
79674bfc36 PR31941 objcopy --globalize-symbol
I think FILE symbols are special, and I can't see why anyone would
want them to be made global.  The fact that no one has reported this
bug since commit 7b4a0685e8 in 2005 supports that claim.

	PR 31941
	* objcopy.c (filter_symbols): Don't allow BSF_FILE symbols to
	be made global.
2024-07-01 11:04:31 +09:30
GDB Administrator
d65111ff0a Automatic date update in version.in 2024-07-01 00:00:58 +00:00
H.J. Lu
adf584eb92 ld: Avoid folding new and delete pairs
GCC 15 may fold new and delete pairs, like

  A *bb = new A[10];
  delete [] bb;
  bb = new (std::nothrow) A [10];
  delete [] bb;

as shown in

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

Avoid folding new and delete pairs by adding a function call between new
and delete.

	* testsuite/ld-elf/dl5.cc: Include "dl5.h".
	(A): Removed.
	Call foo between new and delete.
	* testsuite/ld-elf/dl5.h: New file.
	* testsuite/ld-elf/new.cc: Include "dl5.h".
	(foo): New function.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-06-30 15:43:58 -07:00
Marcus Nilsson
ebe3f6d0f1 objcopy: Allow making symbol global and weak on same invocation
Previously objcopy had to be run twice in order to make a local symbol
weak, first once to globalize it, and once again to mark it as weak.

	* objcopy.c (filter_symbols): Weaken symbols after making
	local/global changes.
	* testsuite/binutils-all/symbols-5.d,
	* testsuite/binutils-all/symbols-5.s: New test.
2024-07-01 07:19:47 +09:30
Alan Modra
01a8854406 tweak latest vms-alpha.c change
It's that tiny bit nicer to have the "len" expression in order of
the components in the buffer.
2024-06-30 14:41:42 +09:30
Alan Modra
4b8c2aaf2d Assertion `(data) <= (end)' failed in read_bases
* dwarf.c (skip_attribute): Don't increment data past end.
	Use SKIP_{S,U}LEB rather than READ_{S,U}LEB.
2024-06-30 14:41:37 +09:30
Alan Modra
6e46bdf64e Re: Rewrite SHT_GROUP handling
Some more error tweaks.  Report a zero entry as "invalid entry.."
rather than "unknown type..", and allow a section to be mentioned
twice in a group.

	* elf.c (process_sht_group_entries): Tweak error messages, and
	allow a duplicate index in a group without reporting an error.
2024-06-30 14:41:37 +09:30
GDB Administrator
8891a9751f Automatic date update in version.in 2024-06-30 00:00:49 +00:00
Sam James
17c78a2349
ld: pass -g for ld-elf tests
The "DWARF parse during linker error" and "Build warn libbar.so" tests
require debug information.

configure defaults to "-O2 -g" but if overriding *FLAGS when building
tests, this might be lost. Explicitly pass -g given these tests require
it.

Originally reported downstream in Gentoo at https://bugs.gentoo.org/934149.

ld/
	* testsuite/ld-elf/dwarf.exp: Pass -g for "DWARF parse during linker error".
	* testsuite/ld-elf/shared.exp: Ditto for "Build warn libbar.so".
2024-06-29 17:13:14 +01:00
GDB Administrator
17de5033a2 Automatic date update in version.in 2024-06-29 00:00:35 +00:00
Claudio Bantaloukas
032eb4f718 aarch64: Add support for Armv9.5-A architecture
The new -march=armv9.5-a flag enables access to the
mandatory cpa, lut and faminmax extensions.
Existing test cases for features are extended to verify they
work without additional flags.
2024-06-28 14:52:30 +01:00
Jan Beulich
d5a0c0a308 ld/doc: drop stray blank
Old enough tools demand no blank between @option and the opening figure
brace. Re-wrap the paragraph as well while at it.
2024-06-28 13:16:14 +02:00
Lulu Cai
e4ed68e577 LoongArch: Do not check R_LARCH_SOP_PUSH_ABSOLUTE to avoid broken links to old object files
R_LARCH_SOP_PUSH_ABSOLUTE with -fPIC was heavily used in the era of gas-2.38.
We do not check this relocation to prevent broken links with old object
files.
2024-06-28 17:35:31 +08:00
Jan Beulich
2513312930 x86/APX: apply NDD-to-legacy transformation to further CMOVcc forms
With both sources being registers, these insns are almost commutative;
the only extra adjustment needed is inversion of the encoded condition.
2024-06-28 08:24:45 +02:00
Jan Beulich
7add993917 x86/APX: extend TEST-by-imm7 optimization to CTESTcc
The same properties apply there.
2024-06-28 08:24:12 +02:00
Jan Beulich
82e06fa803 x86/APX: optimize {nf}-form IMUL-by-power-of-2 to SHL
..., for differing only in the resulting EFLAGS, which are left
untouched anyway. That's a shorter encoding, available as long as
certain constraints on operands are met; see code comments. (SHL-by-1
forms may then be subject to further optimization that was introduced
earlier.)

Note that kind of as a side effect this also converts multiplication by
1 to shift by 0, which is a plain move or even no-op anyway. That could
be further shrunk (as could be presence of shifts/rotates by 0 in the
original code as  well as a fair set of other {nf}-form insns), yet the
expectation (for now) is that people won't write such code in the first
place.
2024-06-28 08:22:39 +02:00
Jan Beulich
2a7f257afb x86-64: restrict by-imm31 optimization
Avoid changing the encoding when there's no size gain: If there's a REX
or REX2 prefix anyway and the base opcode wouldn't be changed, dropping
just REX.W / REX2.W has no (size) effect. (Same for the AND-by-imm7 case
in the same big conditional.)

While there also pull out the .qword check: For the 2-register-operands
case whether that's done on the 1st or 2nd operand doesn't matter. Due
to reduction in necessary parentheses this improves readability a tiny
bit.
2024-06-28 08:21:48 +02:00
Jan Beulich
27ef4876f7 x86/APX: optimize certain {nf}-form insns to LEA
..., as that leaves EFLAGS untouched anyway. That's a shorter encoding,
available as long as certain constraints on operand size and registers
are met; see code comments.

Note that this requires deferring to derive encoding_evex from {nf}
presence, as in optimize_encoding() we want to avoid touching the insns
when {evex} was also used.

Note further that this requires want_disp32() to now also consider the
opcode: We don't want to replace i.tm.mnem_off, for diagnostics to still
report the original mnemonic (or else things can get confusing). While
there, correct adjacent mis-indentation.
2024-06-28 08:19:59 +02:00
Jan Beulich
c7eae03eab x86/APX: optimize {nf}-form rotate-by-width-less-1
Unlike for the legacy forms, where there's a difference in the resulting
EFLAGS.CF, for the NF variants the immediate can be got rid of in that
case by switching to a 1-bit rotate in the opposite direction.
2024-06-28 08:19:32 +02:00
Jan Beulich
0868b8999b x86/APX: optimize {nf} forms of ADD/SUB with specific immediates
Unlike for the legacy forms, where there's a difference in the resulting
EFLAGS, for the NF variants we can safely replace ones using 0x80 by the
respectively other insn while negating the immediate, saving 3 immediate
bytes (just 1 though for 16-bit operand size). Similarly we can replace
ones using 1 / -1 by INC/DEC (eliminating the immediate).
2024-06-28 08:18:40 +02:00
Jan Beulich
f63d85cc78 gas: .irp/.irpc are macro-like
... for the purposes of get_line_sb() and _find_end_of_line(): They
support \@ just like macros do, and hence the special casing there also
needs applying.
2024-06-28 08:17:41 +02:00
Nelson Chu
685dcd295a RISC-V: Shrink the riscv_implicit_subsets table.
Allow to add implicit extensions by using the syntax of `.option arch, +-', so
that the table is shrinked and more readable.

bfd/
	* elfxx-riscv.c (check_implicit_always): Removed the unused IMPLICIT
	parameter.
	(check_implicit_for_i): Likewise.
	(riscv_implicit_subsets): Shrink the table by allowing the syntax of
	`.option arch, +-' for implicit extensions.
	(riscv_update_subset1): New function, called from riscv_update_subset
	or riscv_parse_add_implicit_subsets.  It basically does the same thing
	as riscv_update_subset function before.
	(riscv_parse_add_implicit_subsets): Updated.
	(riscv_update_subset): Updated.
2024-06-28 13:37:08 +08:00