]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
12 months agogas: aarch64: testsuite: add new tests for SCFI users/ibhagat/try-scfi-aarch64-v5
Indu Bhagat [Mon, 11 Dec 2023 06:08:03 +0000 (22:08 -0800)] 
gas: aarch64: testsuite: add new tests for SCFI

[Changes in V5]
 - Rename the previously added testcase scfi-diag-3 for SVE memory op to
   scfi-unsupported-2.  This will help keep track of the work to be done
   in near future.
 - Add new testcase scfi-diag-3 where the insn " b symbol+1" leads to an
   error:
      "Error: SCFI: 0x14000000 op with non-zero addend to sym not supported"
 - Add "stg sp, [sp, 32]!" and "ldpsw x8, x15, [sp, -256]" to ginsn-ldst-1.
 - Add prfm, irg, addg ops to ginsn-misc-1.
 - Add ldrsw, ldpsw ops to ginsn-misc-1.
 - Adjust ginsn-ldst-1 as now S and W register loads and stores are
   skipped.
 - Added a new testcase scfi-ldstnap-1 which includes some insns from
   iclass ldstnapair_offs.
[End of changes in V5]

[Changes in V4]
 - New testcases for FP callee-saved registers.
   scfi-callee-saved-fp-1.s uses D registers, scfi-callee-saved-fp-2.s
   uses Q registers and is run with -mbig-endian.
 - Added new ops (movk, prfm) to ginsn-misc-1. These ops are not
   relevant for SCFI correctness; this testcase merely
   ensures graceful handling of ginsn creation for such insns.
 - Fixed ginsn-ldst-1 as it included some load / store ops with D
   registers, which we now handle.  Also added some insns using W and S
   registers.
 - Added a new test scfi-diag-3 where SCFI machinery reports the
   following error when it sees an SVE memory op with callee-saved
   register:
    "Error: SCFI: unhandled op 0xe5e0e000 may cause incorrect CFI"
[End of changes in V4]

[No changes in V3]

[Changes in V2]
 - new testcase scfi-cfg-4.s for the changes in cmp_scfi_state.
 - new testcase ginsn-arith-1.s for ginsn creation for various add sub insns.
 - removed redundant insns from ginsn-misc-1.s, some of those insns are
   now in ginsn-arith-1.s.
 - added more ld st opts in ginsn-ldst-1.s testcase.
[End of changes in V2]

Similar to the x86_64 testcases, some .s files contain the corresponding
CFI directives.  This helps in validating the synthesized CFI by running
those tests with and without the --scfi=experimental command line
option.

GAS issues some diagnostics, enabled by default, with
--scfi=experimental.  The diagnostics have been added with an intent to
help user correct inadvertent errors in their hand-written asm.  An
error is issued when GAS finds that input asm is not amenable to
accurate CFI synthesis.  The existing scfi-diag-*.s tests in the
gas/testsuite/gas/scfi/x86_64 directory test some SCFI diagnostics
already:

      - (#1) "Warning: SCFI: Asymetrical register restore"
      - (#2) "Error: SCFI: usage of REG_FP as scratch not supported"
      - (#3) "Error: SCFI: unsupported stack manipulation pattern"
      - (#4) "Error: untraceable control flow for func 'XXX'"

In the newly added aarch64 testsuite, further tests for additional
diagnostics have been added:
 - scfi-diag-1.s in this patch highlights an aarch64-specific diagnostic:
   (#5) "Warning: SCFI: ignored probable save/restore op with reg offset"

Additionally, some testcases are added to showcase the (currently)
unsupported patterns, e.g., scfi-unsupported-1.s
        mov     x16, 4384
        sub     sp, sp, x16

gas/testsuite/:
* gas/scfi/README: Update comment to include aarch64.
* gas/scfi/aarch64/scfi-aarch64.exp: New file.
* gas/scfi/aarch64/ginsn-arith-1.l: New test.
* gas/scfi/aarch64/ginsn-arith-1.s: New test.
* gas/scfi/aarch64/ginsn-cofi-1.l: New test.
* gas/scfi/aarch64/ginsn-cofi-1.s: New test.
* gas/scfi/aarch64/ginsn-ldst-1.l: New test.
* gas/scfi/aarch64/ginsn-ldst-1.s: New test.
* gas/scfi/aarch64/scfi-callee-saved-fp-1.d: New test.
* gas/scfi/aarch64/scfi-callee-saved-fp-1.l: New test.
* gas/scfi/aarch64/scfi-callee-saved-fp-1.s: New test.
* gas/scfi/aarch64/scfi-callee-saved-fp-2.d: New test.
* gas/scfi/aarch64/scfi-callee-saved-fp-2.l: New test.
* gas/scfi/aarch64/scfi-callee-saved-fp-2.s: New test.
* gas/scfi/aarch64/scfi-cb-1.d: New test.
* gas/scfi/aarch64/scfi-cb-1.l: New test.
* gas/scfi/aarch64/scfi-cb-1.s: New test.
* gas/scfi/aarch64/scfi-cfg-1.d: New test.
* gas/scfi/aarch64/scfi-cfg-1.l: New test.
* gas/scfi/aarch64/scfi-cfg-1.s: New test.
* gas/scfi/aarch64/scfi-cfg-2.d: New test.
* gas/scfi/aarch64/scfi-cfg-2.l: New test.
* gas/scfi/aarch64/scfi-cfg-2.s: New test.
* gas/scfi/aarch64/scfi-cfg-3.d: New test.
* gas/scfi/aarch64/scfi-cfg-3.l: New test.
* gas/scfi/aarch64/scfi-cfg-3.s: New test.
* gas/scfi/aarch64/scfi-cfg-4.l: New test.
* gas/scfi/aarch64/scfi-cfg-4.s: New test.
* gas/scfi/aarch64/scfi-cond-br-1.d: New test.
* gas/scfi/aarch64/scfi-cond-br-1.l: New test.
* gas/scfi/aarch64/scfi-cond-br-1.s: New test.
* gas/scfi/aarch64/scfi-diag-1.l: New test.
* gas/scfi/aarch64/scfi-diag-1.s: New test.
* gas/scfi/aarch64/scfi-diag-2.l: New test.
* gas/scfi/aarch64/scfi-diag-2.s: New test.
* gas/scfi/aarch64/scfi-diag-3.l: New test.
* gas/scfi/aarch64/scfi-diag-3.s: New test.
* gas/scfi/aarch64/scfi-ldrp-1.d: New test.
* gas/scfi/aarch64/scfi-ldrp-1.l: New test.
* gas/scfi/aarch64/scfi-ldrp-1.s: New test.
* gas/scfi/aarch64/scfi-ldrp-2.d: New test.
* gas/scfi/aarch64/scfi-ldrp-2.l: New test.
* gas/scfi/aarch64/scfi-ldrp-2.s: New test.
* gas/scfi/aarch64/scfi-ldstnap-1.d: New test.
* gas/scfi/aarch64/scfi-ldstnap-1.l: New test.
* gas/scfi/aarch64/scfi-ldstnap-1.s: New test.
* gas/scfi/aarch64/scfi-strp-1.d: New test.
* gas/scfi/aarch64/scfi-strp-1.l: New test.
* gas/scfi/aarch64/scfi-strp-1.s: New test.
* gas/scfi/aarch64/scfi-strp-2.d: New test.
* gas/scfi/aarch64/scfi-strp-2.l: New test.
* gas/scfi/aarch64/scfi-strp-2.s: New test.
* gas/scfi/aarch64/scfi-unsupported-1.l: New test.
* gas/scfi/aarch64/scfi-unsupported-1.s: New test.
* gas/scfi/aarch64/scfi-unsupported-2.l: New test.
* gas/scfi/aarch64/scfi-unsupported-2.s: New test.

12 months agogas: aarch64: add experimental support for SCFI
Indu Bhagat [Fri, 31 May 2024 22:54:08 +0000 (15:54 -0700)] 
gas: aarch64: add experimental support for SCFI

[Changes in V5]
 - Use aarch64_zero_register_p () to detect zero reg.  Get rid of bool
   sp_allowed_p argument of ginsn_dw2_regnum ().  Also update the
   handling for case AARCH64_OPND_CLASS_MODIFIED_REG and return
   opnd->addr.base_regno.
 - Do not generate GINSN_TYPE_LOAD / GINSN_TYPE_STORE for memory
   operations tagged with subclass flag F_SUBCLASS_OTHER in both
   aarch64_ginsn_ldstp () and aarch64_ginsn_ldstr (). Examples of such
   insns include prfm, stg*, ldpsw.
 - Restructure code in aarch64_ginsn_ldstp () and aarch64_ginsn_ldstr ()
   to move the compensating action of ginsn_ind next to the creation of
   ginsn_ind itself. Update code comments.
 - Carve out two different functions for mov: aarch64_ginsn_mov_imm ()
   and aarch64_ginsn_mov_reg ().
 - Use conditionals instead of asserts to handle "b 4" and "cbz x0, 4",
   or even "b symbol+1" and "cbz x0, symbol+1" in
   aarch64_ginsn_branch_uncond () and aarch64_ginsn_branch_cond ().
 - Now that addg, subg are sub-classified with F_SUBCLASS_OTHER, add a
   comment in addsum_imm case block around the same.
 - In aarch64_ginsn_unhandled (), carve out the check for sve_misc into
   its own conditional block.
 - Use aarch64_opcode_subclass_p () consistently.
 - In aarch64_ginsn_safe_to_skip_p (), detect irg op (for whitelisting)
   by means of subclass to make the code more robust as in future, new
   ops may be added with destination Rd_SP.
 - Punt on W and S loads and stores, since they cannot implement a full
   save & restore for CFI purposes.
 - Include ginsn generation for ldstnapair_offs iclass.  This was
   ignored until now, but it seems these ops can be used for save /
   restore ops.
 - Other minor code and code comment fixes.
[End of changes in V5]

[Changes in V4]
 - Use data types uniformly. Use 'unsigned int' instead of 'uint32_t'
   for DWARF register numbers.  Use offsetT where applicable.
 - Minor code restructuring in aarch64_ginsn_safe_to_skip_p (). Move
   common code out of switch case.
 - Add FP/Advanced SIMD registers to callee-saved registers too.
   Updated commit log to include some of the details.
 - Check for opnd type AARCH64_OPND_QLF_W or AARCH64_OPND_QLF_S_S in
   aarch64_ginsn_ldstp () to detect 32-bit word operations.
 - Skip generating ginsns for movk, movz, movn.  These do more work than
   just simple mov; Skip generating ginsn altogether for these.
 - ginsn_dw2_regnum () is now switch case on opnd_class.  Each case
   exposed by the current set of ginsn creation logic is handled.
 - Skip Z register usage altogether for now.  Skip sve_misc iclass but
   error out if callee-saved FP/Advanced SIMD registers or stack
   management are involved.
[End of changes in V4]

[No changes in V3]

[Changes in V2]
- Factored out the ginsn creation functionality from tc-aarch64.c into
tc-aarch64-ginsn.c.
- The switch case in aarch64_ginsn_new now is based on iclass rather
than (earlier) opcode.
- Rename aarch64_ginsn_jump / aarch64_ginsn_jump_cond to
aarch64_ginsn_branch_uncond / aarch64_ginsn_branch_cond respectively.
- Explicitly whitelist irg insn.
- Other minor code comment and readability fixes.
[End of changes in V2]

For synthesizing CFI (SCFI) for hand-written asm, the SCFI machinery in
GAS works on the generic GAS insns (ginsns).  This patch adds support in
the aarch64 backend to create ginsns for a subset of the supported
machine instructions.  The subset includes the minimal necessary
instructions to ensure SCFI correctness:

- Any potential register saves and unsaves.  Hence, process instructions
  belonging to a variety of iclasses involving str, ldr, stp, ldp.
- Any change of flow instructions.  This includes all conditional and
  unconditional branches, call (bl, blr, etc.) and return.
- Most importantly, any instruction that could affect the two registers
  of interest: REG_SP, REG_FP.  This set includes all pre-indexed and
  post-indexed memory operations, with writeback, on the stack.  This
  set must also include other instructions (e.g., arithmetic insns)
  where the destination register is one of the afore-mentioned registers.

With respect to callee-saved registers in Aarch64, FP/Advanced SIMD
registers D8-D15 are included along with the relevant GPRs.  Calculating
offsets for loads and stores especially for Q registers needs special
attention here.

As an example,
   str q8, [sp, #16]
On big-endian:
   STR Qn stores as a 128-bit integer (MSB first), hence, should record
   D8 as being saved at sp+24 rather than sp+16.
On little-endian:
   should record D8 as being saved at sp+16

D8-D15 are the low 64 bits of Q8-Q15, and of Z8-Z15 if SVE is used;
hence, they remain "interesting" for SCFI purposes in such cases.  A CFI
save slot always represents the low 64 bits, regardless of whether a
save occurs on D, Q or Z registers.  Currently, the ginsn creation
machinery can handle D and Q registers on little-endian and big-endian.

Apart from creating ginsn, another key responsibility of the backend is
to make sure there are safeguards in place to detect and alert if an
instruction of interest may have been skipped.  This is done via
aarch64_ginsn_unhandled () (similar to the x86 backend).  This function
, hence, is also intended to alert when future ISA changes may otherwise
render SCFI results incorrect, because of missing ginsns for the newly
added machine instructions.

At this time, becuase of the complexities wrt endianness in handling Z
register usage, skip sve_misc opclass altogether for now.  The SCFI
machinery will error out (using the aarch64_ginsn_unhandled () code
path) though if Z register usage affects correctness.

The current SCFI machinery does not currently synthesize the
PAC-related, aarch64-specific CFI directives: .cfi_b_key_frame.  The
support for this is planned for near future.

SCFI is enabled for ELF targets only.

gas/
* config/tc-aarch64-ginsn.c: New file.
* config/tc-aarch64.c (md_assemble): Include tc-aarch64-ginsn.c
file.  Invoke aarch64_ginsn_new.
* config/tc-aarch64.h (TARGET_USE_GINSN): Define for SCFI
enablement.
(TARGET_USE_SCFI): Likewise.
(SCFI_MAX_REG_ID): New definition.
(REG_FP): Likewise.
(REG_LR): Likewise.
(REG_SP): Likewise.
(SCFI_INIT_CFA_OFFSET): Likewise.
(SCFI_CALLEE_SAVED_REG_P): Likewise.
(aarch64_scfi_callee_saved_p): New declaration.

12 months agoopcodes: aarch64: enforce checks on subclass flags in aarch64-gen.c
Indu Bhagat [Sat, 29 Jun 2024 22:25:52 +0000 (15:25 -0700)] 
opcodes: aarch64: enforce checks on subclass flags in aarch64-gen.c

[No changes in V5]

[New in V4]

Enforce some checks on the newly added subclass flags:
  - If a subclass is set of one insn of an iclass, every insn of that
    iclass must have non-zero subclass field.
  - For all other iclasses, the subclass bits are zero for all insns.

include/
        * opcode/aarch64.h (enum aarch64_insn_class): Identify the
maximum iclass enum value.

opcodes/
        * aarch64-gen.c (iclass_has_subclasses_p): New array of bool.
        (read_table): Enforce checks on subclass flags.

12 months agoopcodes: aarch64: denote subclasses for insns of iclass dp_2src
Indu Bhagat [Wed, 10 Jul 2024 09:08:03 +0000 (02:08 -0700)] 
opcodes: aarch64: denote subclasses for insns of iclass dp_2src

[New in V5]

For detecting irg, add a subclass to identify it in the set of
instructions of iclass dp_2src.

opcodes/
* aarch64-tbl.h: Add subclass flag F_DP_TAG_ONLY for irg insn.

12 months agoopcodes: aarch64: add flags to denote subclasses of uncond branches
Indu Bhagat [Wed, 29 May 2024 00:56:13 +0000 (17:56 -0700)] 
opcodes: aarch64: add flags to denote subclasses of uncond branches

[No changes in V5]

[Changes in V4]
  - Use F_SUBCLASS_OTHER for instructions where F_BRANCH_CALL or
    F_BRANCH_RET does not apply.
[End of changes in V4]

[No changes in V3]

[New in V2]

Use the two new subclass flags: F_BRANCH_CALL, F_BRANCH_RET, to indicate
call to and return from subroutine respectively.

opcodes/
* aarch64-tbl.h: Use the new F_BRANCH_* flags.

12 months agoopcodes: aarch64: add flags to denote subclasses of arithmetic insns
Indu Bhagat [Sat, 29 Jun 2024 21:27:30 +0000 (14:27 -0700)] 
opcodes: aarch64: add flags to denote subclasses of arithmetic insns

[Changes in V5]
 - Use F_SUBCLASS_OTHER For addg, subg.
[End of changes in V5]

[Changes in V4]
- Specify subclasses only for those iclasses relevant to SCFI:
  addsub_imm, and addsub_ext
[End of changes in V4]

[No changes in V3]
[New in V2]

Use the three new subclass flags: F_ARITH_ADD, F_ARITH_SUB,
F_ARITH_MOV, to indicate add, sub and mov ops respectively.

These flags for subclasses will later be used for SCFI purposes to
create appropriate ginsns.  At this time, only those iclasses relevant
to SCFI have the new subclass flags specified.

For addg and subg insns, F_SUBCLASS_OTHER is more suitable because these
operations do more than just simple add or sub.

opcodes/
    * aarch64-tbl.h: Use the new F_ARITH_* flags.

12 months agoopcodes: aarch64: add flags to denote subclasses of ldst insns
Indu Bhagat [Sat, 29 Jun 2024 21:07:13 +0000 (14:07 -0700)] 
opcodes: aarch64: add flags to denote subclasses of ldst insns

[Changes in V5]
 - Use F_SUBCLASS_OTHER for stg* ops.  These operations only affect
   memory tag. They are not stores in a traditional sense.
 - Mark prfm as F_SUBCLASS_OTHER.
 - Use F_SUBCLASS_OTHER for ldpsw and ldrsw insns.
 - Add subclass flags for insns of iclass ldstnapair_offs.
[End of changes in V5]

[Changes in V4]
 - Specify subclasses only for those iclasses relevant to SCFI:
      ldst_imm9, ldst_pos, ldstpair_indexed, ldstpair_off
[End of changes in V4]

[Changes in V3]
- Use F_LDST_SWAP for lse_atomic ld/st ops.  Use of F_LDST_LOAD or
  F_LDST_STORE was incorrect.
[End of changes in V3]

[New in V2]

The existing iclass information tells us the general shape and purpose
of the instructions.  In some cases, however, we need to further disect
the iclass on the basis of other finer-grain information.  E.g., for the
purpose of SCFI, we need to know whether a given insn with iclass
of ldst_* is a load or a store.

At the moment, specify subclasses for only those iclasses relevant to
SCFI: ldst_imm9, ldst_pos, ldstpair_indexed, ldstpair_off and
ldstnapair_offs.

Some insns are best tagged with F_SUBCLASS_OTHER rather than F_LDST_LOAD
or F_LDST_STORE:
  - stg* ops (as they store tag only),
  - prfm,
  - ldpsw, ldrsw (32-bit loads with signed extended value.  Not useful
    for restore operations in context of SCFI.)

opcodes/
    * aarch64-tbl.h: Use the new F_LDST_* flags.

12 months agoinclude: opcodes: aarch64: define new subclasses
Indu Bhagat [Sat, 29 Jun 2024 21:06:11 +0000 (14:06 -0700)] 
include: opcodes: aarch64: define new subclasses

[Changes in V5]
 - Reinstate per-iclass enum for subclassification.
 - Add new subclass flag for insns which update the tag only (in case of
   data-processing insns), called F_DP_TAG_ONLY.
 - Adjust function-level comment of aarch64_opcode_subclass_p ().
[End of changes in V5]

[New in V4]

The existing iclass information tells us the general shape and purpose
of the instructions.  In some cases, however, we need to further disect
the iclass on the basis of other finer-grain information.  E.g., for the
purpose of SCFI, we need to know whether a given insn with iclass of
ldst_* is a load or a store.  Similarly, whether a particular arithmetic
insn is an add or sub or mov, etc.

This patch defines new flags to demarcate the insns.  Also provide an
access function for subclass lookup.

Later, we will enforce (in aarch64-gen.c) that if an iclass has at least
one instruction with a non-zero subclass, all instructions of the iclass
must have a non-zero subclass information.  If none of the defined
subclasses are applicable (or not required for SCFI purposes),
F_SUBCLASS_OTHER can be used for such instructions.

include/
        * opcode/aarch64.h (F_SUBCLASS): New flag.
        (F_SUBCLASS_OTHER): Likewise.
        (F_LDST_LOAD): Likewise.
        (F_LDST_STORE): Likewise.
        (F_ARITH_ADD): Likewise.
        (F_ARITH_SUB): Likewise.
        (F_ARITH_MOV): Likewise.
        (F_BRANCH_CALL): Likewise.
        (F_BRANCH_RET): Likewise.
(F_DP_TAG_ONLY): Likewise.
        (aarch64_opcode_subclass_p): New definition.

12 months agogas: scfi: make scfi_state_restore_reg function more precise
Indu Bhagat [Mon, 27 May 2024 22:40:39 +0000 (15:40 -0700)] 
gas: scfi: make scfi_state_restore_reg function more precise

[No changes in V3, V4, V5]

[New in V2]
 - This patch is orthogonal to aarch64 support.  It is included here
   because the testcase added for it is aarch64 specific.  It is a
   bugfix really.
[End of New in V2]

When the SCFI machinery detects that a register has been restored from
stack, it makes some state changes in the SCFI state object.

Prior to the patch, scfi_state_restore_reg () was setting a value of
(reg, CFI_IN_REG) for (base, state) respectively.  This was causing
issues in the cmp_scfi_state () function:
  - The default state of all (callee-saved) regs at the beginning of
    function is set to (0, CFI_UNDEFINED).
  - If a register is saved and restored on some control path, the state
    of reg is (reg, CFI_IN_REG) on that path.
  - On another control path where the register was perhaps not
    used (or saved/restored on stack) remains (0, CFI_UNDEFINED).
  - The two states should be treated equal, however, at the point in
    program after the register has been restored.

Fix this by resetting the state to (0, CFI_UNDEFINED) in
scfi_state_restore_reg ().

A testcase (scfi-cfg-4.s) for this is added in a subsequent commit.

gas/
        * scfi.c (scfi_state_restore_reg): Reset to 0, CFI_UNDEFINED
for base, state.

12 months agoRevert "MIPS: Use N64 by default for mips*64*-*-linux-gnuabi64"
Maciej W. Rozycki [Sat, 13 Jul 2024 05:00:44 +0000 (06:00 +0100)] 
Revert "MIPS: Use N64 by default for mips*64*-*-linux-gnuabi64"

This reverts commit d49f2dd78b08efa4e1ee51f5df5058846c2eb4fa.  It was
applied unapproved.

12 months agoRevert "MIPS/GAS: Omit LI 0 for condition trap"
Maciej W. Rozycki [Sat, 13 Jul 2024 05:00:43 +0000 (06:00 +0100)] 
Revert "MIPS/GAS: Omit LI 0 for condition trap"

This reverts commit bfa257b407270d1c808b31fbd97da779e0fd20d2.  It was
applied unapproved.

12 months agoLoongArch: Fix dwarf3 test cases from XPASS to PASS
Lulu Cai [Thu, 11 Jul 2024 11:00:43 +0000 (19:00 +0800)] 
LoongArch: Fix dwarf3 test cases from XPASS to PASS

In the past, the .align directive generated a label that did not match
the regular expression, and we set it to XFAIL.
But now it matches fine so it becomes XPASS. We fix it with PASS.

12 months agoAutomatic date update in version.in
GDB Administrator [Sat, 13 Jul 2024 00:00:11 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agolibiberty: sync with gcc
Sam James [Sat, 29 Jun 2024 17:11:52 +0000 (18:11 +0100)] 
libiberty: sync with gcc

This imports the following commits from GCC as of r15-1722-g7682d115402743:
ca2f7c84927f libiberty: Invoke D demangler when --format=auto
94792057ad4a Fix up duplicated words mostly in comments, part 1
20e57660e64e libiberty: Fix error return value in pex_unix_exec_child [PR113957].
52ac4c6be866 [libiberty] remove TBAA violation in iterative_hash, improve code-gen
53bb7145135c libiberty: Fix up libiberty_vprintf_buffer_size
65388b28656d c++, demangle: Implement https://github.com/itanium-cxx-abi/cxx-abi/issues/148 non-proposal

12 months agos390: Avoid reloc overflows on undefined weak symbols (cont)
Jens Remus [Fri, 12 Jul 2024 14:53:47 +0000 (16:53 +0200)] 
s390: Avoid reloc overflows on undefined weak symbols (cont)

This complements and reuses logic from Andreas Krebbel's commit
896a639babe2 ("s390: Avoid reloc overflows on undefined weak symbols").

Replace relative long addressing instructions of weak symbols, which
will definitely resolve to zero, with either a load address of 0 or a
a trapping insn.

This prevents the PLT32DBL relocation from overflowing in case the
binary will be loaded at 4GB or more.

bfd/
* elf64-s390.c (elf_s390_relocate_section): Replace
instructions using undefined weak symbols with relative
addressing to avoid relocation overflows.

ld/
* testsuite/ld-s390/s390.exp: Add new test.
* testsuite/ld-s390/weakundef-2.s: New test.
* testsuite/ld-s390/weakundef-2.dd: Likewise.

Reported-by: Alexander Gordeev <agordeev@linux.ibm.com>
Suggested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Suggested-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
12 months agos390: Do not replace brcth referencing undefined weak symbol
Jens Remus [Fri, 12 Jul 2024 14:53:47 +0000 (16:53 +0200)] 
s390: Do not replace brcth referencing undefined weak symbol

Branch Relative on Count High (brcth) is a conditional branch relative
instruction. It is not guaranteed that it only appears within loops
that sooner or later will take the branch. It may very well be used to
check a condition that will prevent the branch from ever being taken.

bfd/
* elf64-s390.c (elf_s390_relocate_section): Do not replace brcth
referencing undefined weak symbol with a trap.

ld/
* testsuite/ld-s390/weakundef-1.s: Update test case accordingly.
* testsuite/ld-s390/weakundef-1.dd: Likewise.

Fixes: 896a639babe2 ("s390: Avoid reloc overflows on undefined weak symbols")
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
12 months agoaarch64: Add support for sme2.1 zero instructions.
Srinath Parvathaneni [Mon, 8 Jul 2024 15:36:44 +0000 (16:36 +0100)] 
aarch64: Add support for sme2.1 zero instructions.

This patch adds support for following sme2.1 zero instructions and
the spec is available here [1].

1. ZERO (single-vector).
2. ZERO (double-vector).
3. ZERO (quad-vector).

The VECTOR GROUP symbols VGx2 and VGx4 are optional for the assembler
for most of the sme and sve instructions. But for few of the sme2.1
zero instruction variants VECTOR GROUP symbols VGx2 and VGx4 are mandatory.
To address this a bit "F_VG_REQ" is introduced in this patch, on setting
F_VG_REQ bit in flags of aarch64_opcode forces the assembler to accept
instruction operand only having VECTOR GROUP symbols.

[1]: https://developer.arm.com/documentation/ddi0602/2024-03/SME-Instructions?lang=en

12 months agoaarch64: Add support for sme2.1 movaz instructions.
Srinath Parvathaneni [Mon, 8 Jul 2024 15:36:42 +0000 (16:36 +0100)] 
aarch64: Add support for sme2.1 movaz instructions.

This patch adds support for following sme2.1 movaz instructions and
the spec is available here [1].

1. MOVAZ (array to vector, two registers).
2. MOVAZ (array to vector, four registers).
3. MOVAZ (tile to vector, single).

[1]: https://developer.arm.com/documentation/ddi0602/2024-03/SME-Instructions?lang=en

12 months agoaarch64: Add support for sme2.1 luti2 and luti4 instructions.
Srinath Parvathaneni [Mon, 8 Jul 2024 15:36:40 +0000 (16:36 +0100)] 
aarch64: Add support for sme2.1 luti2 and luti4 instructions.

This patch adds support for following sme2.1 luti2 and luti4 instructions, spec is
available here [1]

1. LUTI2 (two registers) strided.
2. LUTI2 (four registers) strided.
3. LUTI4 (two registers) strided.
4. LUTI4 (four registers) strided.

[1]: https://developer.arm.com/documentation/ddi0602/2024-03/SME-Instructions?lang=en

12 months agox86: drop unnecessary \() from bundle tests
Jan Beulich [Fri, 12 Jul 2024 10:28:50 +0000 (12:28 +0200)] 
x86: drop unnecessary \() from bundle tests

':' isn't permitted in macro parameter names, hence this separator
construct isn't necessary at the end of labels. Drop its use in such
cases, for being potentially confusing (and hampering readability, even
if only a little).

12 months agox86/APX: remove two inconsistencies
Jan Beulich [Fri, 12 Jul 2024 10:28:03 +0000 (12:28 +0200)] 
x86/APX: remove two inconsistencies

As indicated in earlier discussion, permitting GOTTPOFF uniformly for
all legacy non-SIMD insns while at the same time restricting to just
certain ADD forms when EVEX-encoded is inconsistent. Make promoted insns
"equal" to their legacy original ones. Doing that adjustment prevents
another inconsistency, too: In

data16 neg (%rax)
data16 neg (%r16)
data16 {nf} neg (%rax)

it is not logical why the last one shouldn't be permitted. Bypassing
that check requires other adjustments, though, to actually properly
consume (and then squash) the data size prefix.

While there also add the missing CMP and TEST cases to the test case
being modified.

12 months agox86/APX: correct TEST/CTESTcc with 1st operand being a memory one
Jan Beulich [Fri, 12 Jul 2024 10:27:19 +0000 (12:27 +0200)] 
x86/APX: correct TEST/CTESTcc with 1st operand being a memory one

While they properly inherited D and C, code processing the reversal of
operands wasn't updated accordingly (and "reversed" operands also
weren't tested anywhere).

12 months agoMIPS/GAS: Omit LI 0 for condition trap
YunQiang Su [Wed, 19 Jun 2024 16:52:25 +0000 (00:52 +0800)] 
MIPS/GAS: Omit LI 0 for condition trap

MIPSr6 removes condition trap instructions with imm, so we expand
the instruction like "tne $2,IMM" to
li $at,IMM
tne $2,$at
While if IMM is 0, we can use
tne $2,$zero
only.

12 months agoMIPS: Use N64 by default for mips*64*-*-linux-gnuabi64
YunQiang Su [Fri, 12 Jul 2024 10:18:59 +0000 (18:18 +0800)] 
MIPS: Use N64 by default for mips*64*-*-linux-gnuabi64

the ABI section of the triple explicitly asks for N64,
and in fact GCC also does so.

It can fix the test failure:
  FAIL: libdep test: did not get expected output from the linker
with Debian's mipsisa64r6el-linux-gnuabi64 toolchain.

12 months agoaarch64: disable feature b16b16
Matthieu Longo [Fri, 12 Jul 2024 08:02:08 +0000 (09:02 +0100)] 
aarch64: disable feature b16b16

Feature b16b16 is currently incomplete and requires re-work.

Disable the command line option for b16b16, and mark the associated
tests as XFAIL.

12 months agogprofng: add release notes for 2.43
Vladimir Mezentsev [Wed, 10 Jul 2024 22:57:50 +0000 (15:57 -0700)] 
gprofng: add release notes for 2.43

ChangeLog
2024-07-10  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>.

* binutils/NEWS (gprofng): Add release notes for 2.43

12 months agoRe: base64: Add support for targets with byte size > octet size.
Alan Modra [Fri, 12 Jul 2024 00:20:46 +0000 (09:50 +0930)] 
Re: base64: Add support for targets with byte size > octet size.

Three extra octets are now expected with the latest change to base64.s.
They happened to be covered by patterns allowing for zero padding at
the end of the section, but we don't want to allow fewer octets than
expected.

PR 31964
* testsuite/gas/all/base64.d: Adjust.

12 months agoAutomatic date update in version.in
GDB Administrator [Fri, 12 Jul 2024 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agobase64: Add support for targets with byte size > octet size.
Nick Clifton [Thu, 11 Jul 2024 11:51:16 +0000 (12:51 +0100)] 
base64: Add support for targets with byte size > octet size.

PR 31964

12 months agogas: don't open-code IS_WHITESPACE() / IS_NEWLINE()
Jan Beulich [Thu, 11 Jul 2024 10:27:18 +0000 (12:27 +0200)] 
gas: don't open-code IS_WHITESPACE() / IS_NEWLINE()

Better be consistent in use of the wrapper macros, which imo also helps
readability.

12 months agogas: multi-byte warning adjustments
Jan Beulich [Thu, 11 Jul 2024 10:26:36 +0000 (12:26 +0200)] 
gas: multi-byte warning adjustments

First input_scrub_next_buffer()'s invocation was wrong, leading to input
only being checked from the last newline till the end of the current
buffer. Correcting the invocation, however, leads to duplicate checking
unless -f (or the #NO_APP equivalent thereof) is in effect. Move the
invocation to input_file_give_next_buffer(), to restrict it accordingly.

Then, when macros contain multi-byte characters, warning about them
again in every expansion isn't useful. Suppress such warnings from
sb_scrub_and_add_sb().

12 months agogas: there's no scrubber state 12
Jan Beulich [Thu, 11 Jul 2024 10:25:26 +0000 (12:25 +0200)] 
gas: there's no scrubber state 12

Apparently (beyond what's [easily] visible in git history) when this was
added there was confusion about scrubber states vs lex[] contents. For
the purposes here LEX_IS_DOUBLEDASH_1ST (which happens to also resolve
to 12) alone is sufficient. "state" is never set to 12, and it being 12
also isn't handled anywhere.

12 months agogdb: add testcase for invalid record display
Kévin Le Gouguec [Thu, 4 Jul 2024 06:45:01 +0000 (08:45 +0200)] 
gdb: add testcase for invalid record display

More of a DWARF-generation non-regression test; fixed on the GCC side
with 2024-06-03 "Implement wrap-around arithmetics in DWARF
expressions" (f3d6d60d2ae).

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoX86: Update gas/NEWS for Intel APX.
Cui, Lili [Thu, 11 Jul 2024 06:35:24 +0000 (14:35 +0800)] 
X86: Update gas/NEWS for Intel APX.

gas/ChangeLog:

        * NEWS: Update gas/NEWS for Intel APX.

12 months agoRISC-V: Add platform property/capability extensions
Tsukasa OI [Wed, 26 Jul 2023 00:05:53 +0000 (00:05 +0000)] 
RISC-V: Add platform property/capability extensions

RISC-V Profiles document defines number of "extensions" that indicate
certain platform properties/capabilities just like 'Zkt' extension from the
RISC-V cryptography extensions.

This commit defines 20 platform property/capability extensions as defined
in the RISC-V Profiles documentation.

The only exception: 'Ssstateen' extension is defined separately because it
defines a subset (supervisor/hypervisor view) of the 'Smstateen' extension.

This is based on the ratified version of RISC-V Profiles:
<https://github.com/riscv/riscv-profiles/releases/tag/v1.0>

[Definition]

"Main memory regions":
    Main memory regions (in contrast to I/O or vacant memory regions) with
    both the cacheability and coherence PMAs.

[New Unprivileged Extensions]

1.  'Ziccif'
    "Main memory regions" support instruction fetch and any instruction
    fetches of naturally aligned power-of-2 sizes up to min(ILEN, XLEN)
    are atomic.
2.  'Ziccrse'
    "Main memory regions" provide the eventual success guarantee for
    LR/SC sequence (RsrvEventual).
3.  'Ziccamoa'
    "Main memory regions" support all currently-defined AMO operations
    including swap, logical and arithmetic operations (AMOArithmetic).
4.  'Za64rs'
    For LR/SC instructions, reservation sets are contiguous, naturally
    aligned and at most 64-bytes in size.
5.  'Za128rs'
    Likewise, but reservation sets are at most 128-bytes in size.
6.  'Zicclsm'
    Misaligned loads / stores to "main memory regions" are supported.
    Those include both regular scalar and vector accesses but does not
    include AMOs and other specialized forms of memory accesses.
7.  'Zic64b'
    Cache blocks are (exactly) 64-bytes in size and naturally aligned.

[New Privileged Extensions]

1.  'Svbare'
    "satp" mode Bare is supported.
2.  'Svade'
    Page-fault exceptions are raised when a page is accessed when A bit is
    clear, or written when D bit is clear.
3.  'Ssccptr'
    "Main memory regions" support hardware page-table reads.
4.  'Sstvecd'
    "stvec" mode Direct is supported.  When "stvec" mode is Direct,
    "stvec.BASE" is capable of holding any valid 4-byte aligned address.
5.  'Sstvala'
    "stval" is always written with a nonzero value whenever possible as
    specified in the Privileged Architecture documentation
    (version 20211203: see section 4.1.9).
6.  'Sscounterenw'
    For any "hpmcounter" that is not read-only zero, the corresponding bit
    in "scounteren" is writable.
7.  'Ssu64xl'
    "sstatus.UXL" is capable of holding the value 0b10
    (UXLEN==64 is supported).
8.  'Shcounterenw'
    Similar to 'Sscounterenw' but the same rule applies to "hcounteren".
9.  'Shvstvala'
    Similar to 'Sstvala' but the same rule applies to "vstval".
10. 'Shtvala'
    "htval" is written with the faulting guest physical address as long as
    permitted by the ISA (a bit similar to 'Sstvala' and 'Shvstvala').
11. 'Shvstvecd'
    Similar to 'Sstvecd' but the same rule applies to "vstvec".
12. 'Shvsatpa'
    All translation modes supported in "satp" are also supported in "vsatp".
13. 'Shgatpa'
    For each supported virtual memory scheme SvNN supported in "satp", the
    corresponding "hgatp" SvNNx4 mode is supported.  The "hgatp" mode Bare
    is also supported.

[Implications]

(Due to reservation set size constraints)
-   'Za64rs' -> 'Za128rs'

(Due to the fact that a privileged "extension" directly refers a CSR)
-   'Svbare'       -> 'Zicsr'
-   'Sstvecd'      -> 'Zicsr'
-   'Sstvala'      -> 'Zicsr'
-   'Sscounterenw' -> 'Zicsr'
-   'Ssu64xl'      -> 'Zicsr'

(Due to the fact that a privileged "extension" indirectly depends on CSRs)
-   'Svade' -> 'Zicsr'

(Due to the fact that a privileged "extension" is a hypervisor property)
-   'Shcounterenw' -> 'H'
-   'Shvstvala'    -> 'H'
-   'Shtvala'      -> 'H'
-   'Shvstvecd'    -> 'H'
-   'Shvsatpa'     -> 'H'
-   'Shgatpa'      -> 'H'

bfd/
* elfxx-riscv.c (riscv_implicit_subsets): Updated for property
and capability extensions.
(riscv_supported_std_z_ext): Added zic64b, ziccamoa, ziccif, zicclsm,
ziccrse, za64rs and za128rs extensions.
(riscv_supported_std_s_ext): Added shcounterenw, shgatpa, shtvala,
shvsatpa, shvstvala, shvstvecd, ssccptr, sscounterenw, sstvala,
sstvecd, ssu64xlm svade and svbare extensions.
gas/
* testsuite/gas/riscv/imply.d: Updated for property and capability
extensions.
* testsuite/gas/riscv/imply.s: Likewise.
* testsuite/gas/riscv/march-help.l: Likewse.

12 months agoRe: Add support for a .base64 pseudo-op to gas
Alan Modra [Thu, 11 Jul 2024 01:38:50 +0000 (11:08 +0930)] 
Re: Add support for a .base64 pseudo-op to gas

Fixes a failure on rx-elf where the standard data section isn't .data.
run_dump_test has machinery to translate .data in both options and
expected results for objdump, but not for readelf -x.

PR 31964
* testsuite/gas/all/base64.d: Dump .data with objdump.  Run on
all targets.

12 months agoLoongArch: Not alloc dynamic relocs if symbol is absolute
Jinyang He [Mon, 8 Jul 2024 03:27:52 +0000 (11:27 +0800)] 
LoongArch: Not alloc dynamic relocs if symbol is absolute

The absolute symbol should be resolved to const when link to dso or exe.
Alloc dynamic relocs will cause extra space and R_LARCH_NONE finally.

12 months agoAutomatic date update in version.in
GDB Administrator [Thu, 11 Jul 2024 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agox86-64: Skip -z mark-plt tests on MUSL
H.J. Lu [Wed, 10 Jul 2024 23:46:21 +0000 (16:46 -0700)] 
x86-64: Skip -z mark-plt tests on MUSL

Skip -z mark-plt tests, which are specific to glibc, on MUSL.

PR ld/31970
* ld/testsuite/ld-x86-64/x86-64.exp: Skip -z mark-plt tests on
MUSL.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
12 months agoRISC-V:[gprofng] Minimal support gprofng for riscv.
Yixuan Chen [Thu, 4 Jul 2024 09:16:59 +0000 (17:16 +0800)] 
RISC-V:[gprofng] Minimal support gprofng for riscv.

ChangeLog: Add target riscv to --enable-gprofng.

2024-07-04  Yixuan Chen  <chenyixuan@iscas.ac.cn>

        * configure: Add riscv.
        * configure.ac: Add riscv.

gprofng/ChangeLog: Minimal support gprofng for riscv.

2024-07-04  Yixuan Chen  <chenyixuan@iscas.ac.cn>

        * gprofng/common/core_pcbe.c (core_pcbe_init): Add RISC-V vendor conditon.
        (defined): Add riscv.
        * gprofng/common/cpuid.c (defined): Add risc-v hwprobe.
        * gprofng/common/gp-defs.h (TOK_A_RISCV): Add riscv.
        (defined): Add riscv.
        (ARCH_RISCV): Add riscv.
        * gprofng/common/hwc_cpus.h: Add RISC-V vendor.
        * gprofng/common/hwcfuncs.h (HW_INTERVAL_TYPE): Remove useless defination.
        * gprofng/configure: Add riscv.
        * gprofng/configure.ac: Add riscv.
        * gprofng/libcollector/hwprofile.h (ARCH): Add RISC-V register.
        (CONTEXT_PC): Add RISC-V register.
        (CONTEXT_FP): Add RISC-V register.
        (CONTEXT_SP): Add RISC-V register.
        (SETFUNCTIONCONTEXT):
        * gprofng/libcollector/libcol_util.c (__collector_util_init): Fix libc open condition.
        * gprofng/libcollector/libcol_util.h (ARCH): Add RISC-V.
        * gprofng/libcollector/unwind.c (ARCH): Add RISC-V register.
        (GET_PC): Add RISC-V register.
        (GET_SP): Add RISC-V register.
        (GET_FP): Add RISC-V register.
        (FILL_CONTEXT):
        * gprofng/src/DbeSession.cc (ARCH): Add RISC-V.
        * gprofng/src/Disasm.cc (Disasm::disasm_open): Add RISC-V.
        * gprofng/src/Experiment.cc (Experiment::ExperimentHandler::startElement): Add RISC-V.
        * gprofng/src/checks.cc (ARCH): Add RISC-V.
        * gprofng/src/collctrl.cc (defined): Set risc-v cpu frequency to 1000MHz as default for now, will fix when I find a better method to get cpu frequency.
        (read_cpuinfo): Add "mvendorid" condition according to risc-v /proc/cpuinfo file content.
        * gprofng/src/dbe_types.h (enum Platform_t): Add RISC-V.

12 months agoAdd support for a .base64 pseudo-op to gas
Nick Clifton [Wed, 10 Jul 2024 14:01:39 +0000 (15:01 +0100)] 
Add support for a .base64 pseudo-op to gas

  PR 31964

12 months agolibsframe: remove runstatedir in Makefile.in
Clément Chigot [Wed, 10 Jul 2024 08:24:45 +0000 (10:24 +0200)] 
libsframe: remove runstatedir in Makefile.in

The regeneration was made with Ubuntu automake which has this runstatedir
additional variable, compared to the usual automake.

12 months agolibsframe: accept --target configure option
Clément Chigot [Mon, 8 Jul 2024 08:55:48 +0000 (10:55 +0200)] 
libsframe: accept --target configure option

Libsframe was missing AC_CANONICAL_TARGET, meaning that --target was
ignored. This could prevent libsframe.a to be installed in some cases,
the host fetching its canonical value while the target isn't. Both
having a different value, INSTALL_LIBBFD would be false.

12 months agoAutomatic date update in version.in
GDB Administrator [Wed, 10 Jul 2024 00:00:36 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoelf: Add glibc version dependency only if needed
H.J. Lu [Tue, 9 Jul 2024 08:48:54 +0000 (01:48 -0700)] 
elf: Add glibc version dependency only if needed

There is no need to add a needed glibc version if the glibc base version
includes the needed glibc version.

PR ld/31966
* elflink.c (elf_link_add_glibc_verneed): Add glibc_minor_base.
Skip if the glibc base version includes the needed glibc version.
(_bfd_elf_link_add_glibc_version_dependency): Initialize
glibc_minor_base to INT_MAX and pass it to
elf_link_add_glibc_verneed.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
12 months agogprofng: add hardware counters for Intel Ice Lake processor
Vladimir Mezentsev [Mon, 8 Jul 2024 02:44:46 +0000 (19:44 -0700)] 
gprofng: add hardware counters for Intel Ice Lake processor

gprofng/ChangeLog
2024-07-07  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>.

* common/hwc_cpus.h: New constant for Intel Ice Lake processor.
* common/hwcdrv.c: Add a new argument to hwcfuncs_get_x86_eventsel.
Set config1 in perf_event_attr. Remove the use of memset.
* common/core_pcbe.c (core_pcbe_get_eventnum): Return 0.
* common/hwcentry.h: Add config1.
* src/collctrl.cc (Coll_Ctrl::build_data_desc):Set config1.
* common/hwcfuncs.c (process_data_descriptor): Set config1.
* common/hwctable.c: Add the hwc table for Intel Ice Lake processor.
* src/hwc_intel_icelake.h: New file.

12 months agodoc: sframe: add appendix for generating stack traces
Indu Bhagat [Wed, 26 Jun 2024 19:43:51 +0000 (12:43 -0700)] 
doc: sframe: add appendix for generating stack traces

Add an appendix to provide a rough outline to show how to generate stack
traces using the SFrame format.  Such content should hopefully aid the
reader assimmilate the information in the specification.

libsframe/
* doc/sframe-spec.texi: Add new appendix.

12 months agoinclude: sframe: update code comments around SFrame FRE stack offsets
Indu Bhagat [Fri, 19 Apr 2024 23:48:17 +0000 (16:48 -0700)] 
include: sframe: update code comments around SFrame FRE stack offsets

This also amends the incorrect comment:
    offset3 (intrepreted as FP = CFA + offset2)

If RA tracking is enabled,  the offset to recover FP is at the third
index.  The SFrame format (V2) has assumption that if FP is saved on
stack, RA must have been saved as well.  This is true for the currently
supported arch Aarch64.  For AMD64, RA tracking per SFrame FRE is not
necessary.

In future, when extending support for more architectures, this will
likely need to be revisited.

include/
* sframe.h: Make the comments clearer by enumerating what
happens per-ABI.

12 months agodoc: sframe: segregate the ABI/arch-specific components
Indu Bhagat [Thu, 23 May 2024 21:18:23 +0000 (14:18 -0700)] 
doc: sframe: segregate the ABI/arch-specific components

The recipe to interpret the SFrame FRE stack offsets is
ABI/arch-specific.

Although, there is other information in the specification that is
ABI-specific (like pauth_key usage in AArch64), those pieces of
information are now assimmilated in the SFrame specification in a way
that it is fairly difficult to carve then out into a ABI/arch-specific
section without confusing the readers.

For future though, the specification must strive to keep the generic
parts and ABI/arch-specific parts clearly laid out in separate sections.

libsframe/
* doc/sframe-spec.texi: Reorder and adapt the contents.

12 months agoLTO: Properly check wrapper symbol
H.J. Lu [Tue, 9 Jul 2024 08:30:19 +0000 (01:30 -0700)] 
LTO: Properly check wrapper symbol

Add wrapper_symbol to bfd_link_hash_entry and set it to true for wrapper
symbol. Set wrap_status to wrapper if wrapper_symbol is true in LTO.

Note: Calling unwrap_hash_lookup to check for the wrapper symbol works
only when there is a definition for the wrapped symbol since references
to the wrapped symbol have been redirected to the wrapper symbol.

bfd/

PR ld/31956
* linker.c (bfd_wrapped_link_hash_lookup): Set wrapper_symbol
for wrapper symbol.

include/

PR ld/31956
* bfdlink.h (bfd_link_hash_entry): Add wrapper_symbol.

ld/

PR ld/31956
* plugin.c (get_symbols): Set wrap_status to wrapper if
wrapper_symbol is set.
* testsuite/ld-plugin/lto.exp: Run PR ld/31956 tests.
* testsuite/ld-plugin/pr31956a.c: New file.
* testsuite/ld-plugin/pr31956b.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
12 months agoAutomatic date update in version.in
GDB Administrator [Tue, 9 Jul 2024 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoaarch64: Add support for sve2p1 pmov instruction.
srinath [Mon, 8 Jul 2024 16:44:33 +0000 (17:44 +0100)] 
aarch64: Add support for sve2p1 pmov instruction.

This patch adds support for followign SVE2p1 instruction, spec is available here [1].

1. PMOV (to vector)
2. PMOV (to predicate)

Both pmov (to vector) and pmov (to predicate) have destination scalable vector
register and source scalable vector register respectively as an operand with no
suffix and optional index. To handle this case we have added 8 new operands in
this patch.

AARCH64_OPND_SVE_Zn0_INDEX,      /* Zn[index], bits [9:5].  */
AARCH64_OPND_SVE_Zn1_17_INDEX,    /* Zn[index], bits [9:5,17].  */
AARCH64_OPND_SVE_Zn2_18_INDEX,    /* Zn[index], bits [9:5,18:17].  */
AARCH64_OPND_SVE_Zn3_22_INDEX,    /* Zn[index], bits [9:5,18:17,22].  */
AARCH64_OPND_SVE_Zd0_INDEX,      /* Zn[index], bits [4:0].  */
AARCH64_OPND_SVE_Zd1_17_INDEX,    /* Zn[index], bits [4:0,17].  */
AARCH64_OPND_SVE_Zd2_18_INDEX,    /* Zn[index], bits [4:0,18:17].  */
AARCH64_OPND_SVE_Zd3_22_INDEX,    /* Zn[index], bits [4:0,18:17,22].  */

Since the index of the <Zd> operand is optional, the index part is
dropped in disassembly in both the cases of "no index" or "zero index".

As per spec: PMOV <Zd>{[<imm>]}, <Pn>.D
             PMOV <Pn>.D, <Zd>{[<imm>]}

Example1:
Assembly: pmov z5[0], p6.d
Disassembly: pmov z5, p6.d

        Assembly: pmov z5, p6.d
        Disassembly: pmov z5, p6.d

Example2:
Assembly: pmov p4.b, z5[0]
Disassembly: pmov p4.b, z5

        Assembly: pmov p4.b, z5
        Disassembly: pmov p4.b, z5
[1]: https://developer.arm.com/documentation/ddi0602/2024-03/SVE-Instructions?lang=en

12 months agoaarch64: Add support for sve2p1 tbxq instruction.
Srinath Parvathaneni [Mon, 8 Jul 2024 16:44:29 +0000 (17:44 +0100)] 
aarch64: Add support for sve2p1 tbxq instruction.

This patch adds support for SVE2p1 "tbxq" instruction, spec is available here [1].
[1]: https://developer.arm.com/documentation/ddi0602/2024-03/SVE-Instructions?lang=en

12 months agoaarch64: Add support for sve2p1 zipq[1-2] instructions.
Srinath Parvathaneni [Mon, 8 Jul 2024 16:44:27 +0000 (17:44 +0100)] 
aarch64: Add support for sve2p1 zipq[1-2] instructions.

This patch adds support for SVE2p1 "zipq1" and "zipq2" instructions, spec is
available here [1].
[1]: https://developer.arm.com/documentation/ddi0602/2024-03/SVE-Instructions?lang=en

12 months agoaarch64: Add support for sve2p1 uzpq[1-2] instructions.
Srinath Parvathaneni [Mon, 8 Jul 2024 16:44:26 +0000 (17:44 +0100)] 
aarch64: Add support for sve2p1 uzpq[1-2] instructions.

This patch adds support for SVE2p1 "uzpq1" and "uzpq2" instructions, spec is
available here [1]
[1]: https://developer.arm.com/documentation/ddi0602/2024-03/SVE-Instructions?lang=en

12 months agoaarch64: Add support for sve2p1 tblq instruction.
Srinath Parvathaneni [Mon, 8 Jul 2024 16:44:24 +0000 (17:44 +0100)] 
aarch64: Add support for sve2p1 tblq instruction.

This patch adds support for SVE2p1 "tblq" instruction, spec is available here [1].
[1]: https://developer.arm.com/documentation/ddi0602/2024-03/SVE-Instructions?lang=en

12 months agoaarch64: Add support for sve2p1 orqv instruction.
Srinath Parvathaneni [Mon, 8 Jul 2024 16:44:20 +0000 (17:44 +0100)] 
aarch64: Add support for sve2p1 orqv instruction.

This patch adds support for SVE2p1 "orqv" instruction, spec available here [1].
[1]: https://developer.arm.com/documentation/ddi0602/2024-03/SVE-Instructions?lang=en

12 months agoAutomatic date update in version.in
GDB Administrator [Mon, 8 Jul 2024 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoAutomatic date update in version.in
GDB Administrator [Sun, 7 Jul 2024 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoRe: LoongArch: Add DT_RELR support
Alan Modra [Sat, 6 Jul 2024 02:00:38 +0000 (11:30 +0930)] 
Re: LoongArch: Add DT_RELR support

Fix commit d89ecf33ab testsuite breakage.

* testsuite/lib/binutils-common.exp (supports_dt_relr): Correct.

12 months agoobjcopy bfd_map_over_sections and global status
Alan Modra [Fri, 5 Jul 2024 13:11:49 +0000 (22:41 +0930)] 
objcopy bfd_map_over_sections and global status

This patch started life as a relatively simple change to fix some
unimportant objcopy memory leaks, but expanded into a larger patch
when I was annoyed by the awkwardness of passing data when using
bfd_map_over_sections.  A simple loop over sections is much more
convenient, and we really don't need the abstraction layer.  Sections
in a list isn't going to disappear any time soon.

The patch also removes use of the global "status" variable by all but
the top-level functions called from main.

* objcopy.c (filter_symbols): Return success as a bool.  Pass
symcount as a pointer, updated on return.
(merge_gnu_build_notes): Similarly return a bool and add newsize
param with updated smaller section size.
(setup_bfd_headers): Return bool success rather than setting
"status" on failure.
(setup_section): Likewise.
(copy_relocations_in_section, copy_section): Likewise, and adjust
params.
(mark_symbols_used_in_relocations): Likewise, and free memory
on failure path.  Don't call bfd_fatal.
(get_sections): Delete function.
(copy_object): Don't use bfd_map_over_sections, instead use a
loop allowing easy detection of failure status.  Free memory on
error paths.
(copy_archive): Return bool success rather than setting "status"
on failure.
(copy_file): Set "status" here.
* testsuite/binutils-all/strip-13.d: Adjust to suit.

12 months agoAutomatic date update in version.in
GDB Administrator [Sat, 6 Jul 2024 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoaarch64: add Debug Feature Register 2 (ID_AA64DFR2_EL1)
Matthieu Longo [Wed, 3 Jul 2024 17:37:45 +0000 (18:37 +0100)] 
aarch64: add Debug Feature Register 2 (ID_AA64DFR2_EL1)

This patch also adds relevant tests. Regression tested on aarch64-none-elf,
and no regression found.

12 months agoaarch64: add STEP2 feature and its associated registers
Matthieu Longo [Wed, 3 Jul 2024 17:36:26 +0000 (18:36 +0100)] 
aarch64: add STEP2 feature and its associated registers

AArch64 defines new registers for the feature step2 (Enhanced Software Step
Extension). step2 is an Armv9.5-A feature.

This patch also adds relevant tests. Regression tested on aarch64-none-elf,
and no regression found.

12 months agoaarch64: add SPMU2 feature and its associated registers
Matthieu Longo [Wed, 19 Jun 2024 19:10:22 +0000 (20:10 +0100)] 
aarch64: add SPMU2 feature and its associated registers

AArch64 defines new registers for the feature spmu2 (System Performance
Monitors Extension version 2). spmu2 is an Armv9.5-A feature.

This patch also adds relevant tests. Regression tested on aarch64-none-elf,
and no regression found.

12 months agoaarch64: add E3DSE feature and its associated registers
Matthieu Longo [Wed, 19 Jun 2024 19:08:17 +0000 (20:08 +0100)] 
aarch64: add E3DSE feature and its associated registers

AArch64 defines new registers for the feature e3dse (Delegated SError
exceptions for EL3): vdisr_el3 and vdisr_el3. e3dse is an Armv9.5-A
feature.

This patch also adds relevant tests. Regression tested on aarch64-none-elf,
and no regression found.

12 months agox86-64: Fix support for APX NF TLS IE with 2 operands
Lingling Kong [Thu, 4 Jul 2024 08:45:46 +0000 (16:45 +0800)] 
x86-64: Fix support for APX NF TLS IE with 2 operands

Added the restriction in assemble for APX TLS IE that the destination
can only be a register.

gas/

      * config/tc-i386.c (md_assemble): Added stricter restrictions
      for APX TLS IE.

12 months agoRISC-V: avoid use of match_opcode() in riscv_insn_types[]
Jan Beulich [Fri, 5 Jul 2024 06:39:28 +0000 (08:39 +0200)] 
RISC-V: avoid use of match_opcode() in riscv_insn_types[]

As of 27b33966b18e ("RISC-V: disallow x0 with certain macro-insns") the
.match_func field may be NULL for entries used for assembly only, which
is the case for the entire table. With .match and .mask both zero the
function would only ever succeed anyway. Save almost a hundred base
relocations in the final executable by using NULL instead.

12 months agoaarch64: fix build with old glibc
Jan Beulich [Fri, 5 Jul 2024 06:38:39 +0000 (08:38 +0200)] 
aarch64: fix build with old glibc

As was pointed out several times before, old glibc declares index(),
resulting in warnings from -Wshadow, in turn failing the build due to
-Werror.

12 months agoLoongArch: Add DT_RELR tests
Xi Ruoyao [Sun, 30 Jun 2024 07:18:25 +0000 (15:18 +0800)] 
LoongArch: Add DT_RELR tests

Most tests are ported from AArch64.

The relr-addend test is added to make sure the addend (link-time address)
is correctly written into the relocated section.  Doing so is not
strictly needed for RELA, but strictly needed for RELR).

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
12 months agoLoongArch: Add DT_RELR support
Xi Ruoyao [Sun, 30 Jun 2024 07:18:24 +0000 (15:18 +0800)] 
LoongArch: Add DT_RELR support

The logic is same as a71d87680110 ("aarch64: Add DT_RELR support").

As LoongArch does not have -z dynamic-undefined-weak, we don't need to
consider UNDEFWEAK_NO_DYNAMIC_RELOC.

The linker relaxation adds another layer of complexity.  When we delete
bytes in a section during relaxation, we need to fix up the offset in
the to-be-packed relative relocations against this section.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
12 months agoLoongArch: Make protected function symbols local for -shared
Xi Ruoyao [Sun, 30 Jun 2024 07:18:23 +0000 (15:18 +0800)] 
LoongArch: Make protected function symbols local for -shared

On LoongArch there is no reason to treat STV_PROTECTED STT_FUNC symbols
as preemptible.  See the comment above LARCH_REF_LOCAL for detailed
explanation.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
12 months agoLoongArch: Fix bad reloc with mixed visibility ifunc symbols in shared libraries
Xi Ruoyao [Sun, 30 Jun 2024 07:18:22 +0000 (15:18 +0800)] 
LoongArch: Fix bad reloc with mixed visibility ifunc symbols in shared libraries

With a simple test case:

    .globl  ifunc
    .globl  ifunc_hidden
    .hidden ifunc_hidden
    .type   ifunc, %gnu_indirect_function
    .type   ifunc_hidden, %gnu_indirect_function

    .text
    .align  2
    ifunc:  ret
    ifunc_hidden: ret

    test:
      bl ifunc
      bl ifunc_hidden

"ld -shared" produces a shared object with one R_LARCH_NONE (instead of
R_LARCH_JUMP_SLOT as we expect) to relocate the GOT entry of "ifunc".
It's because the indices in .plt and .rela.plt mismatches for
STV_DEFAULT STT_IFUNC symbols when another PLT entry exists for a
STV_HIDDEN STT_IFUNC symbol, and such a mismatch breaks the logic of
loongarch_elf_finish_dynamic_symbol.  Fix the issue by reordering .plt
so the indices no longer mismatch.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
12 months agoLoongArch: Reject R_LARCH_32 from becoming a runtime reloc in ELFCLASS64
Xi Ruoyao [Sun, 30 Jun 2024 07:18:21 +0000 (15:18 +0800)] 
LoongArch: Reject R_LARCH_32 from becoming a runtime reloc in ELFCLASS64

We were converting R_LARCH_32 to R_LARCH_RELATIVE for ELFCLASS64:

    $ cat t.s
    .data
    x:
        .4byte x
.4byte 0xdeadbeef
    $ as/as-new t.s -o t.o
    $ ld/ld-new -shared t.o
    $ objdump -R
    a.out:     file format elf64-loongarch

    DYNAMIC RELOCATION RECORDS
    OFFSET           TYPE              VALUE
    00000000000001a8 R_LARCH_RELATIVE  *ABS*+0x00000000000001a8

But this is just wrong: at runtime the dynamic linker will run
*(uintptr *)&x += load_address, clobbering the next 4 bytes of data
("0xdeadbeef" in the example).

If we keep the R_LARCH_32 reloc as-is in ELFCLASS64, it'll be rejected
by the Glibc dynamic linker anyway.  And it does not make too much sense
to modify Glibc to support it.  So we can just reject it like x86_64:

    relocation R_X86_64_32 against `.data' can not be used when making a
    shared object; recompile with -fPIC

or RISC-V:

    relocation R_RISCV_32 against non-absolute symbol `a local symbol'
    can not be used in RV64 when making a shared object

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
12 months agox86: Correct position of ".s" for CCMPcc in disassembler
Cui, Lili [Fri, 5 Jul 2024 01:55:41 +0000 (09:55 +0800)] 
x86: Correct position of ".s" for CCMPcc in disassembler

Added new macro %SW to CCMPcc to print ".s" after the mnemonic.

Before:
ccmpbl {dfv=}.s %edx,%eax

After:
ccmpbl.s {dfv=} %edx,%eax

gas/ChangeLog:

        * testsuite/gas/i386/x86-64-pseudos-apx.d: Add tests for CCMPcc.
        * testsuite/gas/i386/x86-64-pseudos-apx.s: Ditto.

opcodes/ChangeLog:

        * i386-dis-evex.h: Added %SW for CCMPcc swap operands.
        * i386-dis.c (struct dis386): Added %SW.
        (putop): Handle %SW.

12 months agox86: Add {load}/{store} tests for apx instructions.
Cui, Lili [Fri, 5 Jul 2024 01:55:41 +0000 (09:55 +0800)] 
x86: Add {load}/{store} tests for apx instructions.

gas/ChangeLog:

        * testsuite/gas/i386/x86-64.exp: Add {load}/{store} tests for apx
instructions.
        * testsuite/gas/i386/x86-64-pseudos-apx.d: New test.
        * testsuite/gas/i386/x86-64-pseudos-apx.s: Ditto.

12 months agoAutomatic date update in version.in
GDB Administrator [Fri, 5 Jul 2024 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoRISC-V: Fix BFD_RELOC_RISCV_PCREL_LO12_S patch issue
Sun Sunny [Thu, 4 Jul 2024 03:03:37 +0000 (03:03 +0000)] 
RISC-V: Fix BFD_RELOC_RISCV_PCREL_LO12_S patch issue

In commit dff565fcca8137954d6ad571ef39f6aec5c0429c, the fixups
for PCREL_LO12_I and PCREL_LO12_S were mixed, so the "IMM"
field were applied to incorrect position, this caused incorrect
src registers to be encoded.

gas/
* config/tc-riscv.c (md_apply_fix): Fix PCREL_LO12_S issue.
* testsuite/gas/riscv/ixup-local.s: Updated for PCREL_LO12_S cases.
* testsuite/gas/riscv/fixup-local-relax.d: Likewise.
* testsuite/gas/riscv/fixup-local-norelax.d: Likewise.

Signed-off-by: Jianwei Sun <sunny.sun@corelabtech.com>
12 months agoRISC-V: hash with segment id and pcrel_hi address while recording pcrel_hi
Lifang Xia [Thu, 4 Jul 2024 01:56:07 +0000 (09:56 +0800)] 
RISC-V: hash with segment id and pcrel_hi address while recording pcrel_hi

When the same address across different segments (sections) needs to be
recorded, it will overwrite the slot, leading to a memory leak. To ensure
uniqueness, the segment (section) ID needs to be included in the hash key
calculation.

gas/
* config/tc-riscv.c (riscv_pcrel_hi_fixup): New "const asection *sec".
(riscv_pcrel_fixup_hash): make sec->id and e->adrsess as the
hash key.
(riscv_pcrel_fixup_eq): Check sec->id at first.
(riscv_record_pcrel_fixup): New member "sec".
(md_apply_fix) <case BFD_RELOC_RISCV_PCREL_HI20>: Likewise.
(md_apply_fix) <case BFD_RELOC_RISCV_PCREL_LO12_I>: Likewise.

12 months agomve: Fix encoding for vcvt[bt] single-half float conversion instructions
Andre Vieira [Thu, 4 Jul 2024 12:45:53 +0000 (13:45 +0100)] 
mve: Fix encoding for vcvt[bt] single-half float conversion instructions

The encoding was previously not taking into account that the Quad vector
registers were being encoded using their Q-register numbers rather than their
D-register equivalent (multiply by 2).

gas/

* config/tc-arm.c (do_neon_cvttb_1): Use Q-register vector number
rather than their D-register equivalent.

gas/testsuite/

* gas/arm/mve-vcvt-3.d: Correct expected values in test.

12 months agogas: Validate SFrame RA tracking and fixed RA offset
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Validate SFrame RA tracking and fixed RA offset

Verify all architectures participating in SFrame generation do define
the mandatory SFrame return address (RA) tracking predicate function
sframe_ra_tracking_p. Do so by explicitly not testing for the macro
SFRAME_FRE_RA_TRACKING as otherwise required.

Verify that architectures not using SFrame RA tracking specify a valid
fixed RA offset.

gas/
* gen-sframe.c (output_sframe_internal): Validate SFrame
RA tracking and fixed RA offset.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
12 months agogas: Test predicate whether SFrame RA tracking is used
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
gas: Test predicate whether SFrame RA tracking is used

The existence of the macro SFRAME_FRE_RA_TRACKING only ensures the
existence of the macro SFRAME_CFA_RA_REG and the predicate function
sframe_ra_tracking_p. It does not indicate whether SFrame RA tracking
is actually used.

Test the return value of the SFrame RA tracking predicate function
sframe_ra_tracking_p to determine whether RA tracking is used.

This aligns the logic in functions get_fre_num_offsets and
output_sframe_row_entry to the one used in all other places.

gas/
* gen-sframe.c (get_fre_num_offsets, output_sframe_row_entry):
Test predicate to determine whether SFrame RA tracking is used.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
12 months agogas: Don't skip SFrame FDE if .cfi_register specifies SP register
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agogas: Don't skip SFrame FDE if .cfi_register specifies RA w/o tracking
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agogas: Skip SFrame FDE if .cfi_window_save
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agogas: Skip SFrame FDE if FP without RA on stack
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agogas: User readable warnings if SFrame FDE is not generated
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agogas: Refactor SFrame CFI opcode DW_CFA_register processing
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agogas: Warn if SFrame FDE is skipped due to non-default return column
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agogas: Skip SFrame FDE if CFI specifies non-FP/SP base register
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agogas: Print DWARF call frame insn name in SFrame warning message
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agoreadelf/objdump: Display SFrame fixed RA offset as 'f' in dump
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agoreadelf/objdump: Dump SFrame CFA fixed FP and RA offsets
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agogas: Enhance arch-specific SFrame configuration descriptions
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agox86: Remove unused SFrame CFI RA register variable
Jens Remus [Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)] 
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>
12 months agoSupport APX CFCMOV
Cui, Lili [Thu, 4 Jul 2024 07:49:16 +0000 (15:49 +0800)] 
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.

12 months agoAutomatic date update in version.in
GDB Administrator [Thu, 4 Jul 2024 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoRISC-V: Tidy and complete testing of all architecture imply rules.
Nelson Chu [Tue, 2 Jul 2024 07:37:42 +0000 (15:37 +0800)] 
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.

12 months agoAvoid possible signed overflow in decode_local_label_name
Alan Modra [Mon, 1 Jul 2024 14:32:33 +0000 (00:02 +0930)] 
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.

12 months agogas/doc/riscv: Fixed typo of `.insn cj' format
Nelson Chu [Wed, 3 Jul 2024 03:39:55 +0000 (11:39 +0800)] 
gas/doc/riscv: Fixed typo of `.insn cj' format

gas/
* doc/c-riscv.texi: Fixed typo of `.insn cj' format.