public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Indu Bhagat <indu.bhagat@oracle.com>
To: binutils@sourceware.org
Cc: Indu Bhagat <indu.bhagat@oracle.com>
Subject: [COMMITTED 14/15] gas: testsuite: add an x86 testsuite for SCFI
Date: Mon, 15 Jan 2024 04:07:28 -0800	[thread overview]
Message-ID: <20240115120729.29771-15-indu.bhagat@oracle.com> (raw)
In-Reply-To: <20240115120729.29771-1-indu.bhagat@oracle.com>

The testsuite for SCFI contains target-specific tests.

When a test is executed with --scfi=experimental command line option,
the CFI annotations in the test .s files are skipped altogether by the
GAS for processing.  The CFI directives in the input assembly files are,
however, validated by running the assembler one more time without
--scfi=experimental.

Some testcases are used to highlight those asm constructs that the SCFI
machinery in GAS currently does not support:

  - Only System V AMD64 ABI is supported for now. Using either --32 or
    --x32 with SCFI results in hard error.
    See scfi-unsupported-1.s.

  - Untraceable stack-pointer manipulation in function epilougue and prologue.
    See scfi-unsupported-2.s.

  - Using Dynamically Realigned Arguement Pointer (DRAP) register to
    realign the stack.  For SCFI, the CFA must be only REG_SP or REG_FP
    based.  See scfi-unsupported-drap-1.s

Some testcases are used to highlight some diagnostics that the SCFI
machinery in GAS currently issues, 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 correct CFI synthesis.

  - (#1) "Warning: SCFI: Asymetrical register restore"
  - (#2) "Error: SCFI: usage of REG_FP as scratch not supported"
  - (#3) "Error: SCFI: unsupported stack manipulation pattern"

In case of (#2) and (#3), SCFI generation is skipped for the respective
function.  Above is a subset of the warnings/errors implemented in the
code.

gas/testsuite/:
	* gas/scfi/README: New test.
	* gas/scfi/x86_64/ginsn-add-1.l: New test.
	* gas/scfi/x86_64/ginsn-add-1.s: New test.
	* gas/scfi/x86_64/ginsn-dw2-regnum-1.l: New test.
	* gas/scfi/x86_64/ginsn-dw2-regnum-1.s: New test.
	* gas/scfi/x86_64/ginsn-pop-1.l: New test.
	* gas/scfi/x86_64/ginsn-pop-1.s: New test.
	* gas/scfi/x86_64/ginsn-push-1.l: New test.
	* gas/scfi/x86_64/ginsn-push-1.s: New test.
	* gas/scfi/x86_64/scfi-add-1.d: New test.
	* gas/scfi/x86_64/scfi-add-1.l: New test.
	* gas/scfi/x86_64/scfi-add-1.s: New test.
	* gas/scfi/x86_64/scfi-add-2.d: New test.
	* gas/scfi/x86_64/scfi-add-2.l: New test.
	* gas/scfi/x86_64/scfi-add-2.s: New test.
	* gas/scfi/x86_64/scfi-asm-marker-1.d: New test.
	* gas/scfi/x86_64/scfi-asm-marker-1.l: New test.
	* gas/scfi/x86_64/scfi-asm-marker-1.s: New test.
	* gas/scfi/x86_64/scfi-asm-marker-2.d: New test.
	* gas/scfi/x86_64/scfi-asm-marker-2.l: New test.
	* gas/scfi/x86_64/scfi-asm-marker-2.s: New test.
	* gas/scfi/x86_64/scfi-asm-marker-3.d: New test.
	* gas/scfi/x86_64/scfi-asm-marker-3.l: New test.
	* gas/scfi/x86_64/scfi-asm-marker-3.s: New test.
	* gas/scfi/x86_64/scfi-bp-sp-1.d: New test.
	* gas/scfi/x86_64/scfi-bp-sp-1.l: New test.
	* gas/scfi/x86_64/scfi-bp-sp-1.s: New test.
	* gas/scfi/x86_64/scfi-bp-sp-2.d: New test.
	* gas/scfi/x86_64/scfi-bp-sp-2.l: New test.
	* gas/scfi/x86_64/scfi-bp-sp-2.s: New test.
	* gas/scfi/x86_64/scfi-callee-saved-1.d: New test.
	* gas/scfi/x86_64/scfi-callee-saved-1.l: New test.
	* gas/scfi/x86_64/scfi-callee-saved-1.s: New test.
	* gas/scfi/x86_64/scfi-callee-saved-2.d: New test.
	* gas/scfi/x86_64/scfi-callee-saved-2.l: New test.
	* gas/scfi/x86_64/scfi-callee-saved-2.s: New test.
	* gas/scfi/x86_64/scfi-callee-saved-3.d: New test.
	* gas/scfi/x86_64/scfi-callee-saved-3.l: New test.
	* gas/scfi/x86_64/scfi-callee-saved-3.s: New test.
	* gas/scfi/x86_64/scfi-callee-saved-4.d: New test.
	* gas/scfi/x86_64/scfi-callee-saved-4.l: New test.
	* gas/scfi/x86_64/scfi-callee-saved-4.s: New test.
	* gas/scfi/x86_64/scfi-cfg-1.d: New test.
	* gas/scfi/x86_64/scfi-cfg-1.l: New test.
	* gas/scfi/x86_64/scfi-cfg-1.s: New test.
	* gas/scfi/x86_64/scfi-cfg-2.d: New test.
	* gas/scfi/x86_64/scfi-cfg-2.l: New test.
	* gas/scfi/x86_64/scfi-cfg-2.s: New test.
	* gas/scfi/x86_64/scfi-cfi-label-1.d: New test.
	* gas/scfi/x86_64/scfi-cfi-label-1.l: New test.
	* gas/scfi/x86_64/scfi-cfi-label-1.s: New test.
	* gas/scfi/x86_64/scfi-cfi-sections-1.d: New test.
	* gas/scfi/x86_64/scfi-cfi-sections-1.l: New test.
	* gas/scfi/x86_64/scfi-cfi-sections-1.s: New test.
	* gas/scfi/x86_64/scfi-cofi-1.d: New test.
	* gas/scfi/x86_64/scfi-cofi-1.l: New test.
	* gas/scfi/x86_64/scfi-cofi-1.s: New test.
	* gas/scfi/x86_64/scfi-diag-1.l: New test.
	* gas/scfi/x86_64/scfi-diag-1.s: New test.
	* gas/scfi/x86_64/scfi-diag-2.l: New test.
	* gas/scfi/x86_64/scfi-diag-2.s: New test.
	* gas/scfi/x86_64/scfi-dyn-stack-1.d: New test.
	* gas/scfi/x86_64/scfi-dyn-stack-1.l: New test.
	* gas/scfi/x86_64/scfi-dyn-stack-1.s: New test.
	* gas/scfi/x86_64/scfi-enter-1.d: New test.
	* gas/scfi/x86_64/scfi-enter-1.l: New test.
	* gas/scfi/x86_64/scfi-enter-1.s: New test.
	* gas/scfi/x86_64/scfi-fp-diag-2.l: New test.
	* gas/scfi/x86_64/scfi-fp-diag-2.s: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-1.d: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-1.l: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-1.s: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-2.d: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-2.l: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-2.s: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-3.d: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-3.l: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-3.s: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-4.d: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-4.l: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-4.s: New test.
	* gas/scfi/x86_64/scfi-indirect-mov-5.s: New test.
	* gas/scfi/x86_64/scfi-lea-1.d: New test.
	* gas/scfi/x86_64/scfi-lea-1.l: New test.
	* gas/scfi/x86_64/scfi-lea-1.s: New test.
	* gas/scfi/x86_64/scfi-leave-1.d: New test.
	* gas/scfi/x86_64/scfi-leave-1.l: New test.
	* gas/scfi/x86_64/scfi-leave-1.s: New test.
	* gas/scfi/x86_64/scfi-pushq-1.d: New test.
	* gas/scfi/x86_64/scfi-pushq-1.l: New test.
	* gas/scfi/x86_64/scfi-pushq-1.s: New test.
	* gas/scfi/x86_64/scfi-pushsection-1.d: New test.
	* gas/scfi/x86_64/scfi-pushsection-1.l: New test.
	* gas/scfi/x86_64/scfi-pushsection-1.s: New test.
	* gas/scfi/x86_64/scfi-pushsection-2.d: New test.
	* gas/scfi/x86_64/scfi-pushsection-2.l: New test.
	* gas/scfi/x86_64/scfi-pushsection-2.s: New test.
	* gas/scfi/x86_64/scfi-selfalign-func-1.d: New test.
	* gas/scfi/x86_64/scfi-selfalign-func-1.l: New test.
	* gas/scfi/x86_64/scfi-selfalign-func-1.s: New test.
	* gas/scfi/x86_64/scfi-simple-1.d: New test.
	* gas/scfi/x86_64/scfi-simple-1.l: New test.
	* gas/scfi/x86_64/scfi-simple-1.s: New test.
	* gas/scfi/x86_64/scfi-simple-2.d: New test.
	* gas/scfi/x86_64/scfi-simple-2.l: New test.
	* gas/scfi/x86_64/scfi-simple-2.s: New test.
	* gas/scfi/x86_64/scfi-sub-1.d: New test.
	* gas/scfi/x86_64/scfi-sub-1.l: New test.
	* gas/scfi/x86_64/scfi-sub-1.s: New test.
	* gas/scfi/x86_64/scfi-sub-2.d: New test.
	* gas/scfi/x86_64/scfi-sub-2.l: New test.
	* gas/scfi/x86_64/scfi-sub-2.s: New test.
	* gas/scfi/x86_64/scfi-unsupported-1.l: New test.
	* gas/scfi/x86_64/scfi-unsupported-1.s: New test.
	* gas/scfi/x86_64/scfi-unsupported-2.l: New test.
	* gas/scfi/x86_64/scfi-unsupported-2.s: New test.
	* gas/scfi/x86_64/scfi-unsupported-3.l: New test.
	* gas/scfi/x86_64/scfi-unsupported-3.s: New test.
	* gas/scfi/x86_64/scfi-unsupported-4.l: New test.
	* gas/scfi/x86_64/scfi-unsupported-4.s: New test.
	* gas/scfi/x86_64/scfi-unsupported-cfg-1.l: New test.
	* gas/scfi/x86_64/scfi-unsupported-cfg-1.s: New test.
	* gas/scfi/x86_64/scfi-unsupported-cfg-2.l: New test.
	* gas/scfi/x86_64/scfi-unsupported-cfg-2.s: New test.
	* gas/scfi/x86_64/scfi-unsupported-drap-1.l: New test.
	* gas/scfi/x86_64/scfi-unsupported-drap-1.s: New test.
	* gas/scfi/x86_64/scfi-unsupported-insn-1.l: New test.
	* gas/scfi/x86_64/scfi-unsupported-insn-1.s: New test.
	* gas/scfi/x86_64/scfi-x86-64.exp: New file.
---
 gas/testsuite/gas/scfi/README                 |  16 +++
 gas/testsuite/gas/scfi/x86_64/ginsn-add-1.l   |  49 ++++++++
 gas/testsuite/gas/scfi/x86_64/ginsn-add-1.s   |  27 +++++
 .../gas/scfi/x86_64/ginsn-dw2-regnum-1.l      |  69 +++++++++++
 .../gas/scfi/x86_64/ginsn-dw2-regnum-1.s      |  33 +++++
 gas/testsuite/gas/scfi/x86_64/ginsn-pop-1.l   |  41 +++++++
 gas/testsuite/gas/scfi/x86_64/ginsn-pop-1.s   |  16 +++
 gas/testsuite/gas/scfi/x86_64/ginsn-push-1.l  |  44 +++++++
 gas/testsuite/gas/scfi/x86_64/ginsn-push-1.s  |  17 +++
 gas/testsuite/gas/scfi/x86_64/scfi-add-1.d    |  26 ++++
 gas/testsuite/gas/scfi/x86_64/scfi-add-1.l    |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-add-1.s    |  13 ++
 gas/testsuite/gas/scfi/x86_64/scfi-add-2.d    |  37 ++++++
 gas/testsuite/gas/scfi/x86_64/scfi-add-2.l    |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-add-2.s    |  48 ++++++++
 .../gas/scfi/x86_64/scfi-asm-marker-1.d       |  29 +++++
 .../gas/scfi/x86_64/scfi-asm-marker-1.l       |   3 +
 .../gas/scfi/x86_64/scfi-asm-marker-1.s       |  27 +++++
 .../gas/scfi/x86_64/scfi-asm-marker-2.d       |  25 ++++
 .../gas/scfi/x86_64/scfi-asm-marker-2.l       |   3 +
 .../gas/scfi/x86_64/scfi-asm-marker-2.s       |  11 ++
 .../gas/scfi/x86_64/scfi-asm-marker-3.d       |  32 +++++
 .../gas/scfi/x86_64/scfi-asm-marker-3.l       |   2 +
 .../gas/scfi/x86_64/scfi-asm-marker-3.s       |  38 ++++++
 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.d  |  32 +++++
 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.l  |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.s  |  21 ++++
 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.d  |  58 +++++++++
 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.l  |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.s  |  52 ++++++++
 .../gas/scfi/x86_64/scfi-callee-saved-1.d     |  41 +++++++
 .../gas/scfi/x86_64/scfi-callee-saved-1.l     |   2 +
 .../gas/scfi/x86_64/scfi-callee-saved-1.s     |  25 ++++
 .../gas/scfi/x86_64/scfi-callee-saved-2.d     |  42 +++++++
 .../gas/scfi/x86_64/scfi-callee-saved-2.l     |   2 +
 .../gas/scfi/x86_64/scfi-callee-saved-2.s     |  40 +++++++
 .../gas/scfi/x86_64/scfi-callee-saved-3.d     |  43 +++++++
 .../gas/scfi/x86_64/scfi-callee-saved-3.l     |   3 +
 .../gas/scfi/x86_64/scfi-callee-saved-3.s     |  39 ++++++
 .../gas/scfi/x86_64/scfi-callee-saved-4.d     |  41 +++++++
 .../gas/scfi/x86_64/scfi-callee-saved-4.l     |   3 +
 .../gas/scfi/x86_64/scfi-callee-saved-4.s     |  55 +++++++++
 gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.d    |  37 ++++++
 gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.l    |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.s    |  47 ++++++++
 gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.d    |  29 +++++
 gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.l    |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.s    |  21 ++++
 .../gas/scfi/x86_64/scfi-cfi-label-1.d        |  38 ++++++
 .../gas/scfi/x86_64/scfi-cfi-label-1.l        |   2 +
 .../gas/scfi/x86_64/scfi-cfi-label-1.s        |  19 +++
 .../gas/scfi/x86_64/scfi-cfi-sections-1.d     |  24 ++++
 .../gas/scfi/x86_64/scfi-cfi-sections-1.l     |   2 +
 .../gas/scfi/x86_64/scfi-cfi-sections-1.s     |  22 ++++
 gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.d   |   5 +
 gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.l   |   3 +
 gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.s   |  24 ++++
 gas/testsuite/gas/scfi/x86_64/scfi-diag-1.l   |   4 +
 gas/testsuite/gas/scfi/x86_64/scfi-diag-1.s   |  22 ++++
 gas/testsuite/gas/scfi/x86_64/scfi-diag-2.l   |   4 +
 gas/testsuite/gas/scfi/x86_64/scfi-diag-2.s   |  28 +++++
 .../gas/scfi/x86_64/scfi-dyn-stack-1.d        |  24 ++++
 .../gas/scfi/x86_64/scfi-dyn-stack-1.l        |   2 +
 .../gas/scfi/x86_64/scfi-dyn-stack-1.s        |  50 ++++++++
 gas/testsuite/gas/scfi/x86_64/scfi-enter-1.d  |  36 ++++++
 gas/testsuite/gas/scfi/x86_64/scfi-enter-1.l  |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-enter-1.s  |  24 ++++
 .../gas/scfi/x86_64/scfi-fp-diag-2.l          |   3 +
 .../gas/scfi/x86_64/scfi-fp-diag-2.s          |  55 +++++++++
 .../gas/scfi/x86_64/scfi-indirect-mov-1.d     |  52 ++++++++
 .../gas/scfi/x86_64/scfi-indirect-mov-1.l     |   2 +
 .../gas/scfi/x86_64/scfi-indirect-mov-1.s     |  48 ++++++++
 .../gas/scfi/x86_64/scfi-indirect-mov-2.d     |  42 +++++++
 .../gas/scfi/x86_64/scfi-indirect-mov-2.l     |   2 +
 .../gas/scfi/x86_64/scfi-indirect-mov-2.s     |  38 ++++++
 .../gas/scfi/x86_64/scfi-indirect-mov-3.d     |  42 +++++++
 .../gas/scfi/x86_64/scfi-indirect-mov-3.l     |   2 +
 .../gas/scfi/x86_64/scfi-indirect-mov-3.s     |  38 ++++++
 .../gas/scfi/x86_64/scfi-indirect-mov-4.d     |  64 ++++++++++
 .../gas/scfi/x86_64/scfi-indirect-mov-4.l     |   3 +
 .../gas/scfi/x86_64/scfi-indirect-mov-4.s     |  68 +++++++++++
 .../gas/scfi/x86_64/scfi-indirect-mov-5.s     |  35 ++++++
 gas/testsuite/gas/scfi/x86_64/scfi-lea-1.d    |  38 ++++++
 gas/testsuite/gas/scfi/x86_64/scfi-lea-1.l    |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-lea-1.s    |  39 ++++++
 gas/testsuite/gas/scfi/x86_64/scfi-leave-1.d  |  37 ++++++
 gas/testsuite/gas/scfi/x86_64/scfi-leave-1.l  |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-leave-1.s  |  25 ++++
 gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.d  |  36 ++++++
 gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.l  |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.s  |  23 ++++
 .../gas/scfi/x86_64/scfi-pushsection-1.d      |  43 +++++++
 .../gas/scfi/x86_64/scfi-pushsection-1.l      |   2 +
 .../gas/scfi/x86_64/scfi-pushsection-1.s      |  40 +++++++
 .../gas/scfi/x86_64/scfi-pushsection-2.d      |  40 +++++++
 .../gas/scfi/x86_64/scfi-pushsection-2.l      |   2 +
 .../gas/scfi/x86_64/scfi-pushsection-2.s      |  40 +++++++
 .../gas/scfi/x86_64/scfi-selfalign-func-1.d   |  32 +++++
 .../gas/scfi/x86_64/scfi-selfalign-func-1.l   |   2 +
 .../gas/scfi/x86_64/scfi-selfalign-func-1.s   |  36 ++++++
 gas/testsuite/gas/scfi/x86_64/scfi-simple-1.d |  27 +++++
 gas/testsuite/gas/scfi/x86_64/scfi-simple-1.l |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-simple-1.s |  15 +++
 gas/testsuite/gas/scfi/x86_64/scfi-simple-2.d |  31 +++++
 gas/testsuite/gas/scfi/x86_64/scfi-simple-2.l |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-simple-2.s |  16 +++
 gas/testsuite/gas/scfi/x86_64/scfi-sub-1.d    |  26 ++++
 gas/testsuite/gas/scfi/x86_64/scfi-sub-1.l    |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-sub-1.s    |  12 ++
 gas/testsuite/gas/scfi/x86_64/scfi-sub-2.d    |  32 +++++
 gas/testsuite/gas/scfi/x86_64/scfi-sub-2.l    |   2 +
 gas/testsuite/gas/scfi/x86_64/scfi-sub-2.s    |  29 +++++
 .../gas/scfi/x86_64/scfi-unsupported-1.l      |   2 +
 .../gas/scfi/x86_64/scfi-unsupported-1.s      |   9 ++
 .../gas/scfi/x86_64/scfi-unsupported-2.l      |   3 +
 .../gas/scfi/x86_64/scfi-unsupported-2.s      |  13 ++
 .../gas/scfi/x86_64/scfi-unsupported-3.l      |   3 +
 .../gas/scfi/x86_64/scfi-unsupported-3.s      |  13 ++
 .../gas/scfi/x86_64/scfi-unsupported-4.l      |   4 +
 .../gas/scfi/x86_64/scfi-unsupported-4.s      |  22 ++++
 .../gas/scfi/x86_64/scfi-unsupported-cfg-1.l  |   3 +
 .../gas/scfi/x86_64/scfi-unsupported-cfg-1.s  |  52 ++++++++
 .../gas/scfi/x86_64/scfi-unsupported-cfg-2.l  |   4 +
 .../gas/scfi/x86_64/scfi-unsupported-cfg-2.s  |  14 +++
 .../gas/scfi/x86_64/scfi-unsupported-drap-1.l |   4 +
 .../gas/scfi/x86_64/scfi-unsupported-drap-1.s |  75 ++++++++++++
 .../gas/scfi/x86_64/scfi-unsupported-insn-1.l |   7 ++
 .../gas/scfi/x86_64/scfi-unsupported-insn-1.s |  16 +++
 gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp | 113 ++++++++++++++++++
 129 files changed, 3074 insertions(+)
 create mode 100644 gas/testsuite/gas/scfi/README
 create mode 100644 gas/testsuite/gas/scfi/x86_64/ginsn-add-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/ginsn-add-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/ginsn-dw2-regnum-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/ginsn-dw2-regnum-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/ginsn-pop-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/ginsn-pop-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/ginsn-push-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/ginsn-push-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-add-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-add-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-add-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-add-2.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-add-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-add-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-diag-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-diag-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-diag-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-diag-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-enter-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-enter-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-enter-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-fp-diag-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-fp-diag-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-5.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-lea-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-lea-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-lea-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-leave-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-leave-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-leave-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-simple-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-simple-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-simple-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-simple-2.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-simple-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-simple-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-sub-1.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-sub-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-sub-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-sub-2.d
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-sub-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-sub-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-3.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-3.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-4.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-4.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-2.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-2.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-drap-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-drap-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-insn-1.l
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-unsupported-insn-1.s
 create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp

diff --git a/gas/testsuite/gas/scfi/README b/gas/testsuite/gas/scfi/README
new file mode 100644
index 00000000000..91191634769
--- /dev/null
+++ b/gas/testsuite/gas/scfi/README
@@ -0,0 +1,16 @@
+Notes on the SCFI testsuite in GAS:
+
+* At this time, SCFI machinery is only supported for x86_64.
+
+* When adding more tests, please keep CFI annotations updated in the .s files.
+  Ideally the test should be run with and without --scfi (as is done currently
+  for the core SCFI tests); Such workflow ensures sanity checking of the CFI
+  annotations. 
+
+* Note that GAS issues a warning:
+    "Warning: --scfi=all ignores some user-specified CFI directive"
+  when it encounters CFI directives in the input assembly and --scfi (=all) is
+  active.  To bypass the noise from this warning, while keeping the testcases
+  useful/understandable, most tests are run twice. E.g.,
+     - run_dump_test "scfi-cfi-add-1" // ignores warnings
+     - run_list_test "scfi-cfi-add-1" "--scfi --warn" // tests warnings
diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-add-1.l b/gas/testsuite/gas/scfi/x86_64/ginsn-add-1.l
new file mode 100644
index 00000000000..ff078d4d883
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/ginsn-add-1.l
@@ -0,0 +1,49 @@
+GAS LISTING .*
+
+
+   1              	## Testcase with a variety of add.
+   2              	## Some add insns valid in 64-bit mode may not be processed for SCFI.
+   3              		.text
+   4              		.globl foo
+   5              		.type foo, @function
+   5              	ginsn: SYM FUNC_BEGIN
+   6              	foo:
+   6              	ginsn: SYM foo
+   7 0000 54       		push %rsp
+   7              	ginsn: SUB %r7, 8, %r7
+   7              	ginsn: STORE %r7, \[%r7\+0\]
+   8 0001 4889E5   		movq %rsp, %rbp
+   8              	ginsn: MOV %r7, %r6
+   9              	
+  10 0004 48010425 		addq %rax, symbol
+  10      00000000 
+  11 000c 03042500 		add symbol, %eax
+  11      000000
+  12 0013 670320   		add \(%eax\), %esp
+  12              	ginsn: ADD \[%r0\+0\], %r7, %r7
+  13 0016 67012405 		add %esp, \(,%eax\)
+  13      00000000 
+  14 001e 67032405 		add \(,%eax\), %esp
+  14      00000000 
+  14              	ginsn: ADD \[%r0\+0\], %r7, %r7
+  15              	
+  16 0026 4801C3   		addq %rax, %rbx
+  16              	ginsn: ADD %r0, %r3, %r3
+  17 0029 01C3     		add %eax, %ebx
+  17              	ginsn: ADD %r0, %r3, %r3
+  18              	
+  19 002b 4883D408 		adc \$8, %rsp
+  19              	ginsn: OTH 0, 0, %r7
+  20              	
+  21 002f 488345F0 		addq \$1, -16\(%rbp\)
+  21      01
+  22              	
+  23 0034 4803D8   		\{load\} addq %rax, %rbx
+  23              	ginsn: ADD %r0, %r3, %r3
+  24              	
+  25 0037 C3       		ret
+  25              	ginsn: RET
+  26              	.LFE0:
+  26              	ginsn: SYM .LFE0
+  27              		.size foo, .-foo
+  27              	ginsn: SYM FUNC_END
diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-add-1.s b/gas/testsuite/gas/scfi/x86_64/ginsn-add-1.s
new file mode 100644
index 00000000000..f9398369531
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/ginsn-add-1.s
@@ -0,0 +1,27 @@
+## Testcase with a variety of add.
+## Some add insns valid in 64-bit mode may not be processed for SCFI.
+	.text
+	.globl foo
+	.type foo, @function
+foo:
+	push %rsp
+	movq %rsp, %rbp
+
+	addq %rax, symbol
+	add symbol, %eax
+	add (%eax), %esp
+	add %esp, (,%eax)
+	add (,%eax), %esp
+
+	addq %rax, %rbx
+	add %eax, %ebx
+
+	adc $8, %rsp
+
+	addq $1, -16(%rbp)
+
+	{load} addq %rax, %rbx
+
+	ret
+.LFE0:
+	.size foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-dw2-regnum-1.l b/gas/testsuite/gas/scfi/x86_64/ginsn-dw2-regnum-1.l
new file mode 100644
index 00000000000..f242e1f2171
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/ginsn-dw2-regnum-1.l
@@ -0,0 +1,69 @@
+GAS LISTING .*
+
+
+.*# Testcase for DWARF regnum ginsn API
+   2              		.text
+   3              		.globl  foo
+   4              		.type   foo, @function
+   4              	ginsn: SYM FUNC_BEGIN
+   5              	foo:
+   5              	ginsn: SYM foo
+   6 0000 0408     		add    \$8, %al
+   7 0002 80C108   		add    \$8, %cl
+   7              	ginsn: ADD %r2, 8, %r2
+   8 0005 80C208   		add    \$8, %dl
+   8              	ginsn: ADD %r1, 8, %r1
+   9 0008 80C408   		add    \$8, %ah
+   9              	ginsn: ADD %r0, 8, %r0
+  10 000b 80C508   		add    \$8, %ch
+  10              	ginsn: ADD %r2, 8, %r2
+  11 000e 80C608   		add    \$8, %dh
+  11              	ginsn: ADD %r1, 8, %r1
+  12 0011 80C708   		add    \$8, %bh
+  12              	ginsn: ADD %r3, 8, %r3
+  13              	
+  14 0014 4080C008 		add    \$8, %axl
+  14              	ginsn: ADD %r0, 8, %r0
+  15 0018 4080C408 		add    \$8, %spl
+  15              	ginsn: ADD %r7, 8, %r7
+  16              	
+  17 001c 6683C008 		add    \$8, %ax
+  17              	ginsn: ADD %r0, 8, %r0
+  18 0020 664183C0 		add    \$8, %r8w
+  18      08
+  18              	ginsn: ADD %r8, 8, %r8
+  19 0025 6683C408 		add    \$8, %sp
+  19              	ginsn: ADD %r7, 8, %r7
+  20              	
+  21 0029 83C008   		add    \$8, %eax
+  21              	ginsn: ADD %r0, 8, %r0
+  22 002c 4183C008 		add    \$8, %r8d
+  22              	ginsn: ADD %r8, 8, %r8
+  23 0030 81C40040 		add    \$16384, %esp
+  23      0000
+  23              	ginsn: ADD %r7, 16384, %r7
+  24              	
+  25 0036 4883C508 		add    \$8, %rbp
+  25              	ginsn: ADD %r6, 8, %r6
+  26              	
+  27 003a 488D05FE 		lea    -0x2\(%rip\), %rax
+  27      FFFFFF
+  27              	ginsn: ADD %r4, -2, %r0
+  28 0041 67488905 		mov    %rax, 0x2\(%eip\)
+  28      02000000 
+  28              	ginsn: MOV %r0, \[%r4\+2\]
+  29 0049 67488B05 		mov    -0x2\(%eip\), %rax
+  29      FEFFFFFF 
+  29              	ginsn: MOV \[%r4\+-2\], %r0
+  30              	
+  31 0051 C3       		ret
+  31              	ginsn: RET
+\fGAS LISTING .*
+
+
+  32              	.LFE0:
+  32              	ginsn: SYM .LFE0
+  33              		.size   foo, .-foo
+  33              	ginsn: SYM FUNC_END
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-dw2-regnum-1.s b/gas/testsuite/gas/scfi/x86_64/ginsn-dw2-regnum-1.s
new file mode 100644
index 00000000000..383c60f635b
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/ginsn-dw2-regnum-1.s
@@ -0,0 +1,33 @@
+# Testcase for DWARF regnum ginsn API
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	add    $8, %al
+	add    $8, %cl
+	add    $8, %dl
+	add    $8, %ah
+	add    $8, %ch
+	add    $8, %dh
+	add    $8, %bh
+
+	add    $8, %axl
+	add    $8, %spl
+
+	add    $8, %ax
+	add    $8, %r8w
+	add    $8, %sp
+
+	add    $8, %eax
+	add    $8, %r8d
+	add    $16384, %esp
+
+	add    $8, %rbp
+
+	lea    -0x2(%rip), %rax
+	mov    %rax, 0x2(%eip)
+	mov    -0x2(%eip), %rax
+
+	ret
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-pop-1.l b/gas/testsuite/gas/scfi/x86_64/ginsn-pop-1.l
new file mode 100644
index 00000000000..f1161db55fa
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/ginsn-pop-1.l
@@ -0,0 +1,41 @@
+GAS LISTING .*
+
+
+   1              	## Testcase with a variety of pop.
+   2              	## all pop insns valid in 64-bit mode must be processed for SCFI.
+   3              		.text
+   4              		.globl  foo
+   5              		.type   foo, @function
+   5              	ginsn: SYM FUNC_BEGIN
+   6              	foo:
+   6              	ginsn: SYM foo
+   7 0000 660FA1   		popw    %fs
+   7              	ginsn: LOAD \[%r7\+0\], %r54
+   7              	ginsn: ADD %r7, 2, %r7
+   8 0003 660FA9   		popw    %gs
+   8              	ginsn: LOAD \[%r7\+0\], %r55
+   8              	ginsn: ADD %r7, 2, %r7
+   9 0006 669D     		popfw
+   9              	ginsn: LOAD \[%r7\+0\], %r49
+   9              	ginsn: ADD %r7, 2, %r7
+  10 0008 66418F42 		popw    -8\(%r10\)
+  10      F8
+  10              	ginsn: LOAD \[%r7\+0\], \[%r10\+0\]
+  10              	ginsn: ADD %r7, 2, %r7
+  11 000d 428F0415 		popq    -8\(,%r10\)
+  11      F8FFFFFF 
+  11              	ginsn: LOAD \[%r7\+0\], \[%r10\+0\]
+  11              	ginsn: ADD %r7, 8, %r7
+  12 0015 8F042500 		pop     symbol
+  12      000000
+  12              	ginsn: LOAD \[%r7\+0\], \[%r4\+0\]
+  12              	ginsn: ADD %r7, 8, %r7
+  13 001c 58       		popq    %rax
+  13              	ginsn: LOAD \[%r7\+0\], %r0
+  13              	ginsn: ADD %r7, 8, %r7
+  14 001d C3       		ret
+  14              	ginsn: RET
+  15              	.LFE0:
+  15              	ginsn: SYM .LFE0
+  16              		.size   foo, .-foo
+  16              	ginsn: SYM FUNC_END
diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-pop-1.s b/gas/testsuite/gas/scfi/x86_64/ginsn-pop-1.s
new file mode 100644
index 00000000000..30ec3ed2414
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/ginsn-pop-1.s
@@ -0,0 +1,16 @@
+## Testcase with a variety of pop.
+## all pop insns valid in 64-bit mode must be processed for SCFI.
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	popw    %fs
+	popw    %gs
+	popfw
+	popw    -8(%r10)
+	popq    -8(,%r10)
+	pop     symbol
+	popq    %rax
+	ret
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-push-1.l b/gas/testsuite/gas/scfi/x86_64/ginsn-push-1.l
new file mode 100644
index 00000000000..cd49f8e18d1
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/ginsn-push-1.l
@@ -0,0 +1,44 @@
+GAS LISTING .*
+
+
+   1              	## Testcase with a variety of push.
+   2              	## all push insns valid in 64-bit mode must be processed for SCFI.
+   3              		.text
+   4              		.globl  foo
+   5              		.type   foo, @function
+   5              	ginsn: SYM FUNC_BEGIN
+   6              	foo:
+   6              	ginsn: SYM foo
+   7 0000 660FA0   		pushw   %fs
+   7              	ginsn: SUB %r7, 2, %r7
+   7              	ginsn: STORE %r54, \[%r7\+0\]
+   8 0003 660FA8   		pushw   %gs
+   8              	ginsn: SUB %r7, 2, %r7
+   8              	ginsn: STORE %r55, \[%r7\+0\]
+   9 0006 666A28   		pushw   \$40
+   9              	ginsn: SUB %r7, 2, %r7
+   9              	ginsn: STORE 0, \[%r7\+0\]
+  10 0009 6641FF72 		pushw   -8\(%r10\)
+  10      F8
+  10              	ginsn: SUB %r7, 2, %r7
+  10              	ginsn: STORE \[%r10\+0\], \[%r7\+0\]
+  11 000e 42FF3415 		pushq   -8\(,%r10\)
+  11      F8FFFFFF 
+  11              	ginsn: SUB %r7, 8, %r7
+  11              	ginsn: STORE \[%r10\+0\], \[%r7\+0\]
+  12 0016 669C     		pushfw
+  12              	ginsn: SUB %r7, 2, %r7
+  12              	ginsn: STORE %r49, \[%r7\+0\]
+  13 0018 FF342500 		push    symbol
+  13      000000
+  13              	ginsn: SUB %r7, 8, %r7
+  13              	ginsn: STORE \[%r4\+0\], \[%r7\+0\]
+  14 001f 50       		push    %rax
+  14              	ginsn: SUB %r7, 8, %r7
+  14              	ginsn: STORE %r0, \[%r7\+0\]
+  15 0020 C3       		ret
+  15              	ginsn: RET
+  16              	.LFE0:
+  16              	ginsn: SYM .LFE0
+  17              		.size   foo, .-foo
+  17              	ginsn: SYM FUNC_END
diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-push-1.s b/gas/testsuite/gas/scfi/x86_64/ginsn-push-1.s
new file mode 100644
index 00000000000..bc88b8a5c31
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/ginsn-push-1.s
@@ -0,0 +1,17 @@
+## Testcase with a variety of push.
+## all push insns valid in 64-bit mode must be processed for SCFI.
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	pushw   %fs
+	pushw   %gs
+	pushw   $40
+	pushw   -8(%r10)
+	pushq   -8(,%r10)
+	pushfw
+	push    symbol
+	push    %rax
+	ret
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-add-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-add-1.d
new file mode 100644
index 00000000000..383acf5bf66
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-add-1.d
@@ -0,0 +1,26 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for add insn 1
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0014 0+001c FDE cie=0+0000 pc=0+0000..0+0005
+  DW_CFA_advance_loc: 4 to 0+0004
+  DW_CFA_def_cfa_offset: 0
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-add-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-add-1.l
new file mode 100644
index 00000000000..bcf3095a9bb
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-add-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-add-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-add-1.s
new file mode 100644
index 00000000000..d29c444f41c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-add-1.s
@@ -0,0 +1,13 @@
+# Testcase for add instruction.
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	addq    $8, %rsp
+	.cfi_def_cfa_offset 0
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
+
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-add-2.d b/gas/testsuite/gas/scfi/x86_64/scfi-add-2.d
new file mode 100644
index 00000000000..738ddef9c89
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-add-2.d
@@ -0,0 +1,37 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for add insn 2
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0024 0+001c FDE cie=0+0000 pc=0+0000..0+0035
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 3 to 0+0004
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 2 to 0+0006
+  DW_CFA_offset: r12 \(r12\) at cfa-24
+  DW_CFA_advance_loc: 45 to 0+0033
+  DW_CFA_restore: r12 \(r12\)
+  DW_CFA_advance_loc: 1 to 0+0034
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-add-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-add-2.l
new file mode 100644
index 00000000000..8523c720565
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-add-2.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*14: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-add-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-add-2.s
new file mode 100644
index 00000000000..376fab2871e
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-add-2.s
@@ -0,0 +1,48 @@
+	.section        .rodata
+	.type   simd_cmp_op, @object
+	.size   simd_cmp_op, 8
+simd_cmp_op:
+	.long   2
+	.zero   4
+
+# Testcase for add instruction.
+# add reg, reg instruction
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	pushq   %r12
+	.cfi_offset %r12, -24
+	mov     %rsp, %r12
+# Stack manipulation is permitted if the base register for
+# tracking CFA has been changed to FP.
+	addq    %rdx, %rsp
+	addq    %rsp, %rax
+# Some add instructions may access the stack indirectly.  Such
+# accesses do not make REG_FP untraceable.
+	addl    %eax, -84(%rbp)
+# Other kind of add instructions should not error out in the
+# x86_64 -> ginsn translator
+	addq    $simd_cmp_op+8, %rdx
+	addq    $1, symbol
+	addl    %edx, -32(%rsp)
+	addl    $1, fb_low_counter(,%rbx,4)
+	mov     %r12, %rsp
+# Popping a callee-saved register.
+# RSP must be traceable.
+	pop     %r12
+	.cfi_restore %r12
+	leave
+	.cfi_def_cfa_register %rsp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.d
new file mode 100644
index 00000000000..1af1eb88f72
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.d
@@ -0,0 +1,29 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for demarcated code blocks 1
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000018 0+0010 0000001c FDE cie=00000000 pc=0+0000..0+000f
+  DW_CFA_nop
+  DW_CFA_nop
+  DW_CFA_nop
+
+0000002c 0+0010 00000030 FDE cie=00000000 pc=0+0000..0+0006
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.l
new file mode 100644
index 00000000000..322191f02a6
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.l
@@ -0,0 +1,3 @@
+.*Assembler messages:
+.*8: Warning: SCFI ignores most user-specified CFI directives
+.*10: Warning: missing label '.L3' in func 'foo' may result in imprecise cfg
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.s
new file mode 100644
index 00000000000..8a98d1edf1c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-1.s
@@ -0,0 +1,27 @@
+# Testcase where a user may define hot and cold areas of function
+# Note how the .type, and .size directives may be placed differently
+# than a regular function.
+
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	testl   %edi, %edi
+	je      .L3
+	movl    b(%rip), %eax
+	ret
+	.cfi_endproc
+	.section        .text.unlikely
+	.cfi_startproc
+	.type   foo.cold, @function
+foo.cold:
+.L3:
+	pushq   %rax
+	.cfi_def_cfa_offset 16
+	call    abort
+	.cfi_endproc
+.LFE11:
+	.text
+	.size   foo, .-foo
+	.section        .text.unlikely
+	.size   foo.cold, .-foo.cold
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.d b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.d
new file mode 100644
index 00000000000..1199e12091b
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.d
@@ -0,0 +1,25 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for demarcated code blocks 2
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000018 0+0014 0000001c FDE cie=00000000 pc=0+0000..0+000f
+  DW_CFA_nop
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.l
new file mode 100644
index 00000000000..f8c42ffd51a
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.l
@@ -0,0 +1,3 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
+.*8: Warning: missing label '.L3' in func 'foo' may result in imprecise cfg
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.s
new file mode 100644
index 00000000000..2046b7e4078
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-2.s
@@ -0,0 +1,11 @@
+# A programmer may not bother to set the size of the 
+# function symbols via an explicit .size directive.
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	testl   %edi, %edi
+	je      .L3
+	movl    b(%rip), %eax
+	ret
+	.cfi_endproc
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.d b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.d
new file mode 100644
index 00000000000..79b7619abe2
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.d
@@ -0,0 +1,32 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for demarcated code blocks 3
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000018 0+001c 0000001c FDE cie=00000000 pc=0+0000..0+0035
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 3 to 0+0004
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 48 to 0+0034
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.l b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.l
new file mode 100644
index 00000000000..6ec24387b8c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*7: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.s b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.s
new file mode 100644
index 00000000000..692601dbd4b
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-asm-marker-3.s
@@ -0,0 +1,38 @@
+# Testcase where the input may have interleaved sections,
+# possibly even text and data.
+	.globl  main
+	.type   main, @function
+main:
+.LFB1:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	subq    $16, %rsp
+	movl    $17, %esi
+	movl    $5, %edi
+	call    add
+	.section        .rodata
+	.align 16
+	.type   __test_obj.0, @object
+	.size   __test_obj.0, 24
+__test_obj.0:
+	.string "test_elf_objs_in_rodata"
+.LC0:
+	.string "the result is = %d\n"
+	.text
+	movl    %eax, -4(%rbp)
+	movl    -4(%rbp), %eax
+	movl    %eax, %esi
+	movl    $.LC0, %edi
+	movl    $0, %eax
+	call    printf
+	movl    $0, %eax
+	leave
+	.cfi_def_cfa_register %rsp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.d
new file mode 100644
index 00000000000..10a3c392e59
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.d
@@ -0,0 +1,32 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for SP/FP based CFA switching 1
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+0000..0+000c
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 3 to 0+0004
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 6 to 0+000a
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_advance_loc: 1 to 0+000b
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.l
new file mode 100644
index 00000000000..bcf3095a9bb
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.s
new file mode 100644
index 00000000000..f827f8d440f
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-1.s
@@ -0,0 +1,21 @@
+# Testcase for switching between sp/fp based CFA.
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	addq    %rax, %rdi
+	mov     %rbp, %rsp
+	.cfi_def_cfa_register %rsp
+	pop     %rbp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.d b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.d
new file mode 100644
index 00000000000..da44fc8f8a0
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.d
@@ -0,0 +1,58 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for SP/FP based CFA switching 2
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000018 0+0044 0000001c FDE cie=00000000 pc=0+0000..0+0021
+  DW_CFA_advance_loc: 2 to 0+0002
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r14 \(r14\) at cfa-16
+  DW_CFA_advance_loc: 2 to 0+0004
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_offset: r13 \(r13\) at cfa-24
+  DW_CFA_advance_loc: 2 to 0+0006
+  DW_CFA_def_cfa_offset: 32
+  DW_CFA_offset: r12 \(r12\) at cfa-32
+  DW_CFA_advance_loc: 1 to 0+0007
+  DW_CFA_def_cfa_offset: 40
+  DW_CFA_offset: r6 \(rbp\) at cfa-40
+  DW_CFA_advance_loc: 1 to 0+0008
+  DW_CFA_def_cfa_offset: 48
+  DW_CFA_offset: r3 \(rbx\) at cfa-48
+  DW_CFA_advance_loc: 7 to 0+000f
+  DW_CFA_def_cfa_offset: 80
+  DW_CFA_advance_loc: 3 to 0+0012
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 7 to 0+0019
+  DW_CFA_restore: r3 \(rbx\)
+  DW_CFA_advance_loc: 1 to 0+001a
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_def_cfa_offset: 40
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 32
+  DW_CFA_advance_loc: 2 to 0+001c
+  DW_CFA_restore: r12 \(r12\)
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_advance_loc: 2 to 0+001e
+  DW_CFA_restore: r13 \(r13\)
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_advance_loc: 2 to 0+0020
+  DW_CFA_restore: r14 \(r14\)
+  DW_CFA_def_cfa_offset: 8
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.l
new file mode 100644
index 00000000000..23ca73422b5
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*9: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.s
new file mode 100644
index 00000000000..afc4313427e
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-bp-sp-2.s
@@ -0,0 +1,52 @@
+# Testcase for switching between sp/fp based CFA.
+# Although there is stack usage between push %rbp and mov %rsp, %rbp,
+# this is a valid ABI/calling convention complaint pattern; It ought to
+# work for SCFI.
+	.text
+	.globl   foo
+	.type    foo, @function
+foo:
+	.cfi_startproc
+	pushq   %r14
+	.cfi_def_cfa_offset 16
+	.cfi_offset %r14, -16
+	pushq   %r13
+	.cfi_def_cfa_offset 24
+	.cfi_offset %r13, -24
+	pushq   %r12
+	.cfi_def_cfa_offset 32
+	.cfi_offset %r12, -32
+	pushq   %rbp
+	.cfi_def_cfa_offset 40
+	.cfi_offset %rbp, -40
+	pushq   %rbx
+	.cfi_def_cfa_offset 48
+	.cfi_offset %rbx, -48
+	movq    %rdi, %rbx
+	subq    $32, %rsp
+	.cfi_def_cfa_offset 80
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	xorl    %eax, %eax
+	addq    $32, %rsp
+	popq    %rbx
+	.cfi_restore %rbx
+# The SCFI machinery must be able to figure out the offset for CFA
+# as it switches back to REG_SP based tracking after this instruction.
+	popq    %rbp
+	.cfi_def_cfa_register %rsp
+	.cfi_def_cfa_offset 40
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 32
+	popq    %r12
+	.cfi_restore %r12
+	.cfi_def_cfa_offset 24
+	popq    %r13
+	.cfi_restore %r13
+	.cfi_def_cfa_offset 16
+	popq    %r14
+	.cfi_restore %r14
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.d
new file mode 100644
index 00000000000..06e7eb6e3b8
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.d
@@ -0,0 +1,41 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: SCFI for callee-saved registers 1
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0002c 0+0001c FDE cie=0+0000 pc=0+0000..0+0007
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_advance_loc: 1 to 0+0002
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_offset: r3 \(rbx\) at cfa-24
+  DW_CFA_advance_loc: 1 to 0+0003
+  DW_CFA_def_cfa_offset: 32
+  DW_CFA_offset: r6 \(rbp\) at cfa-32
+  DW_CFA_advance_loc: 1 to 0+0004
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_advance_loc: 1 to 0+0005
+  DW_CFA_restore: r3 \(rbx\)
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_advance_loc: 1 to 0+0006
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.l
new file mode 100644
index 00000000000..abca835a642
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*5: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.s
new file mode 100644
index 00000000000..e1c5b70995c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-1.s
@@ -0,0 +1,25 @@
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rax
+	.cfi_def_cfa_offset 16
+	push    %rbx
+	.cfi_def_cfa_offset 24
+	.cfi_offset %rbx, -24
+	pushq   %rbp
+	.cfi_def_cfa_offset 32
+	.cfi_offset %rbp, -32
+	popq    %rbp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 24
+	popq    %rbx
+	.cfi_restore %rbx
+	.cfi_def_cfa_offset 16
+	popq    %rax
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.d b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.d
new file mode 100644
index 00000000000..c6fe36bca43
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.d
@@ -0,0 +1,42 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: SCFI for callee-saved registers 2
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000018 0+002c 0000001c FDE cie=00000000 pc=0+0000..0+0017
+  DW_CFA_advance_loc: 2 to 0+0002
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r12 \(r12\) at cfa-16
+  DW_CFA_advance_loc: 2 to 0+0004
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_offset: r13 \(r13\) at cfa-24
+  DW_CFA_advance_loc: 9 to 0+000d
+  DW_CFA_def_cfa_offset: 32
+  DW_CFA_advance_loc: 1 to 0+000e
+  DW_CFA_def_cfa_offset: 40
+  DW_CFA_advance_loc: 4 to 0+0012
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_advance_loc: 2 to 0+0014
+  DW_CFA_restore: r13 \(r13\)
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_advance_loc: 2 to 0+0016
+  DW_CFA_restore: r12 \(r12\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.l
new file mode 100644
index 00000000000..5ff6048bef0
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*8: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.s
new file mode 100644
index 00000000000..cac4700d35e
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-2.s
@@ -0,0 +1,40 @@
+# Testcase for save reg ops for callee-saved registers
+# These latter two pushq's of callee-saved regs must NOT generate
+# .cfi_offset.
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %r12
+	.cfi_def_cfa_offset 16
+	.cfi_offset %r12, -16
+	pushq   %r13
+	.cfi_def_cfa_offset 24
+	.cfi_offset %r13, -24
+# The function may use callee-saved registers for its use, and may even
+# chose to spill them to stack if necessary.
+	addq    %rax, %r13
+	subq    $8, %r13
+# These two pushq's of callee-saved regs must NOT generate
+# .cfi_offset.
+	pushq   %r13
+	.cfi_def_cfa_offset 32
+	pushq   %rax
+	.cfi_def_cfa_offset 40
+# Adjust the REG_SP to get rid of local stack usage.
+	addq    $16, %rsp
+	.cfi_def_cfa_offset 24
+# The SCFI machinery keeps track of where the callee-saved registers
+# are on the stack.  It generates a restore operation if the stack
+# offsets match.
+	popq    %r13
+	.cfi_restore %r13
+	.cfi_def_cfa_offset 16
+	popq    %r12
+	.cfi_restore %r12
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.d b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.d
new file mode 100644
index 00000000000..9720a93caa3
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.d
@@ -0,0 +1,43 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: SCFI for callee-saved registers 3
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000018 0+002c 0000001c FDE cie=00000000 pc=0+0000..0+0016
+  DW_CFA_advance_loc: 2 to 0+0002
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r12 \(r12\) at cfa-16
+  DW_CFA_advance_loc: 2 to 0+0004
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_offset: r13 \(r13\) at cfa-24
+  DW_CFA_advance_loc: 9 to 0+000d
+  DW_CFA_def_cfa_offset: 32
+  DW_CFA_advance_loc: 1 to 0+000e
+  DW_CFA_def_cfa_offset: 40
+  DW_CFA_advance_loc: 1 to 0+000f
+  DW_CFA_def_cfa_offset: 32
+  DW_CFA_advance_loc: 2 to 0+0011
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_advance_loc: 2 to 0+0013
+  DW_CFA_restore: r13 \(r13\)
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_advance_loc: 2 to 0+0015
+  DW_CFA_restore: r12 \(r12\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.l b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.l
new file mode 100644
index 00000000000..71559d4ea0e
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.l
@@ -0,0 +1,3 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
+.*25: Warning: SCFI: asymetrical register restore
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.s b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.s
new file mode 100644
index 00000000000..e7015fae11d
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-3.s
@@ -0,0 +1,39 @@
+# Testcase for save reg ops for callee-saved registers
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %r12
+	.cfi_def_cfa_offset 16
+	.cfi_offset %r12, -16
+	pushq   %r13
+	.cfi_def_cfa_offset 24
+	.cfi_offset %r13, -24
+# The program may use callee-saved registers for its use, and may even
+# chose to spill them to stack if necessary.
+	addq    %rax, %r13
+	subq    $8, %r13
+# These two pushq's of callee-saved regs must NOT generate
+# .cfi_offset.
+	pushq   %r13
+	.cfi_def_cfa_offset 32
+	pushq   %rax
+	.cfi_def_cfa_offset 40
+	popq    %rax
+	.cfi_def_cfa_offset 32
+	popq    %r13
+	.cfi_def_cfa_offset 24
+# The SCFI machinery keeps track of where the callee-saved registers
+# are on the stack.  It generates a restore operation if the stack
+# offsets match.
+	popq    %r13
+	.cfi_restore %r13
+	.cfi_def_cfa_offset 16
+	popq    %r12
+	.cfi_restore %r12
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.d b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.d
new file mode 100644
index 00000000000..677146953cb
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.d
@@ -0,0 +1,41 @@
+#as: -W --scfi=experimental
+#as:
+#objdump: -Wf
+#name: SCFI for callee-saved registers 4
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000018 0+002c 0000001c FDE cie=00000000 pc=0+0000..0+005e
+  DW_CFA_advance_loc: 5 to 0+0005
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 3 to 0+0008
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 2 to 0+000a
+  DW_CFA_offset: r12 \(r12\) at cfa-24
+  DW_CFA_advance_loc: 1 to 0+000b
+  DW_CFA_offset: r3 \(rbx\) at cfa-32
+  DW_CFA_advance_loc1: 79 to 0+005a
+  DW_CFA_restore: r3 \(rbx\)
+  DW_CFA_advance_loc: 2 to 0+005c
+  DW_CFA_restore: r12 \(r12\)
+  DW_CFA_advance_loc: 1 to 0+005d
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.l b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.l
new file mode 100644
index 00000000000..098f70f9ffe
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.l
@@ -0,0 +1,3 @@
+.*Assembler messages:
+.*4: Warning: SCFI ignores most user-specified CFI directives
+.*24: Warning: SCFI: asymetrical register restore
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.s b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.s
new file mode 100644
index 00000000000..bad56d82133
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-callee-saved-4.s
@@ -0,0 +1,55 @@
+	.type byte_insert_op1, @function
+byte_insert_op1:
+.LFB10:
+	.cfi_startproc
+	endbr64
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq   %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	pushq   %r12
+	.cfi_offset %r12, -24
+	pushq   %rbx
+	.cfi_offset %rbx, -32
+	subq   $24, %rsp
+	movl   %edi, -20(%rbp)
+	movq   %rsi, -32(%rbp)
+	movl   %edx, -24(%rbp)
+	movq   %rcx, -40(%rbp)
+# The program may use callee-saved registers for its use, and may even
+# chose to read them from stack if necessary.  The following use should
+# not be treated as reg restore for SCFI purposes (because rbx has been
+# saved to -16(%rbp).
+	movq   -40(%rbp), %rbx
+	movq   -40(%rbp), %rax
+	leaq   3(%rax), %r12
+	jmp   .L563
+.L564:
+	subq   $1, %rbx
+	subq   $1, %r12
+	movzbl (%rbx), %eax
+	movb   %al, (%r12)
+.L563:
+	cmpq   -32(%rbp), %rbx
+	jne   .L564
+	movl   -24(%rbp), %edx
+	movq   -32(%rbp), %rcx
+	movl   -20(%rbp), %eax
+	movq   %rcx, %rsi
+	movl   %eax, %edi
+	call   byte_store_op1
+	nop
+	addq   $24, %rsp
+	popq   %rbx
+	.cfi_restore %rbx
+	popq   %r12
+	.cfi_restore %r12
+	popq   %rbp
+	.cfi_def_cfa_register %rsp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE10:
+	.size   byte_insert_op1, .-byte_insert_op1
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.d
new file mode 100644
index 00000000000..8223205d50d
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.d
@@ -0,0 +1,37 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI in presence of control flow 1
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0024 0000001c FDE cie=00000000 pc=0+0000..0+003a
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r3 \(rbx\) at cfa-16
+  DW_CFA_advance_loc: 37 to 0+0026
+  DW_CFA_remember_state
+  DW_CFA_advance_loc: 1 to 0+0027
+  DW_CFA_restore: r3 \(rbx\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_advance_loc: 1 to 0+0028
+  DW_CFA_restore_state
+  DW_CFA_advance_loc: 9 to 0+0031
+  DW_CFA_restore: r3 \(rbx\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.l
new file mode 100644
index 00000000000..6081b486ca7
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*15: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.s
new file mode 100644
index 00000000000..5eaf20abf31
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-1.s
@@ -0,0 +1,47 @@
+# Testcase with one dominator bb and two exit bbs
+# Something like for: return ferror (f) || fclose (f) != 0;
+	.text
+	.section .rodata.str1.1,"aMS",@progbits,1
+.LC0:
+	.string "w"
+.LC1:
+	.string "conftest.out"
+	.section .text.startup,"ax",@progbits
+	.p2align 4
+	.globl  main
+	.type   main, @function
+main:
+.LFB11:
+	.cfi_startproc
+	pushq   %rbx
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbx, -16
+	movl   $.LC0, %esi
+	movl   $.LC1, %edi
+	call   fopen
+	movq   %rax, %rdi
+	movq   %rax, %rbx
+	call   ferror
+	movl   %eax, %edx
+	movl   $1, %eax
+	testl  %edx, %edx
+	je     .L7
+	.cfi_remember_state
+	popq   %rbx
+	.cfi_restore %rbx
+	.cfi_def_cfa_offset 8
+	ret
+.L7:
+	.cfi_restore_state
+	movq    %rbx, %rdi
+	call    fclose
+	popq    %rbx
+	.cfi_restore %rbx
+	.cfi_def_cfa_offset 8
+	testl   %eax, %eax
+	setne   %al
+	movzbl  %al, %eax
+	ret
+	.cfi_endproc
+.LFE11:
+	.size   main, .-main
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.d b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.d
new file mode 100644
index 00000000000..82e8b5d9e91
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.d
@@ -0,0 +1,29 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI in presence of control flow 2
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0001c 0+001c FDE cie=00000000 pc=0000000000000000..0000000000000016
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 3 to 0+0004
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.l
new file mode 100644
index 00000000000..5ff6048bef0
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*8: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.s
new file mode 100644
index 00000000000..ee293d6d2de
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfg-2.s
@@ -0,0 +1,21 @@
+# Testcase for CFG creation of ginsns
+# This testcase has no return instruction at the end.
+	.text
+	.globl  main
+	.type   main, @function
+main:
+.LFB7:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq   %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	call   foo
+	shrl   $31, %eax
+	movzbl %al, %eax
+	movl   %eax, %edi
+	call   exit
+	.cfi_endproc
+.LFE7:
+	.size   main, .-main
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.d
new file mode 100644
index 00000000000..7a1d1715262
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.d
@@ -0,0 +1,38 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -tWf
+#name: SCFI no ignore .cfi_label
+#...
+.*\.o:     file format elf.*
+
+SYMBOL TABLE:
+0+0000 l    d  \.text	0+0000 \.text
+0+002b l       \.eh_frame	0+0000 cfi2
+0+0000 g     F \.text	0+0008 foo
+0+002a g       \.eh_frame	0+0000 cfi1
+
+
+Contents of the .eh_frame section:
+
+
+00000000 0+0014 00000000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     1b
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000018 0+0014 0000001c FDE cie=00000000 pc=0+0000..0+0008
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_advance_loc: 1 to 0+0002
+  DW_CFA_advance_loc: 1 to 0+0003
+  DW_CFA_advance_loc: 4 to 0+0007
+  DW_CFA_def_cfa_offset: 0
+  DW_CFA_nop
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.l
new file mode 100644
index 00000000000..bcf3095a9bb
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.s
new file mode 100644
index 00000000000..f95e6dc2206
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-label-1.s
@@ -0,0 +1,19 @@
+# Testcase for .cfi_label directives
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	nop
+	.globl cfi1
+	.cfi_label cfi1
+	nop
+	.cfi_label cfi2
+	nop
+	.cfi_label .Lcfi3
+	addq    $8, %rsp
+	.cfi_def_cfa_offset 0
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d
new file mode 100644
index 00000000000..5962980256c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d
@@ -0,0 +1,24 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: --sframe
+#name: Synthesize CFI with .cfi_sections
+#...
+Contents of the SFrame section .sframe:
+  Header :
+
+    Version: SFRAME_VERSION_2
+    Flags: NONE
+    Num FDEs: 1
+    Num FREs: 5
+
+  Function Index :
+
+    func idx \[0\]: pc = 0x0, size = 12 bytes
+    STARTPC + CFA + FP + RA +
+    0+0000 +sp\+8 +u +u +
+    0+0001 +sp\+16 +c\-16 +u +
+    0+0004 +fp\+16 +c-16 +u +
+    0+000a +sp\+16 +c\-16 +u +
+    0+000b +sp\+8 +u +u +
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.l
new file mode 100644
index 00000000000..6ec24387b8c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*7: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.s
new file mode 100644
index 00000000000..b08dcfc4279
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.s
@@ -0,0 +1,22 @@
+# Testcase for switching between sp/fp based CFA.
+	.text
+	.globl  foo
+	.type   foo, @function
+	.cfi_sections .sframe
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	addq    %rax, %rdi
+	mov     %rbp, %rsp
+	.cfi_def_cfa_register %rsp
+	pop     %rbp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size  foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.d
new file mode 100644
index 00000000000..53cc124d860
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.d
@@ -0,0 +1,5 @@
+#as: --scfi=experimental -W
+#objdump: -Wf
+#name: Synthesize CFI for add insn
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.l
new file mode 100644
index 00000000000..61c29da2d9a
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.l
@@ -0,0 +1,3 @@
+.*Assembler messages:
+.*12: Warning: SCFI ignores most user-specified CFI directives
+.*24: Warning: Untraceable control flow for func 'foo'; Skipping SCFI
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.s
new file mode 100644
index 00000000000..0ea32d4bbe6
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-cofi-1.s
@@ -0,0 +1,24 @@
+# Testcase with a variety of "change of flow instructions"
+#
+# Must be run with -W so it remains warning free.
+#
+# This test does not have much going on wrt synthesis of CFI;
+# it just aims to ensure x8_64 -> ginsn decoding behaves
+# gracefully for these "change of flow instructions"
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	addq    %rdx, %rax
+	loop    foo
+	notrack jmp     *%rax
+	call    *%r8
+	jecxz   .L179
+	jmp     *48(%rdi)
+	jo      .L179
+.L179:
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-diag-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-diag-1.l
new file mode 100644
index 00000000000..0436cfe918b
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-diag-1.l
@@ -0,0 +1,4 @@
+.*Assembler messages:
+.*7: Warning: SCFI ignores most user-specified CFI directives
+.*14: Error: SCFI: usage of REG_FP as scratch not supported
+.*22: Error: SCFI: forward pass failed for func 'foo'
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-diag-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-diag-1.s
new file mode 100644
index 00000000000..5ec24993f0e
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-diag-1.s
@@ -0,0 +1,22 @@
+# Testcase for REG_FP based CFA
+# and using REG_FP as scratch.
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+# The following add causes REG_FP to become untraceable
+	addq    %rax, %rbp
+# CFA cannot be recovered via REG_FP anymore
+	pop     %rbp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-diag-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-diag-2.l
new file mode 100644
index 00000000000..79539680b91
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-diag-2.l
@@ -0,0 +1,4 @@
+.*Assembler messages:
+.*5: Warning: SCFI ignores most user-specified CFI directives
+.*21: Warning: SCFI: asymetrical register restore
+.*22: Warning: SCFI: asymetrical register restore
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-diag-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-diag-2.s
new file mode 100644
index 00000000000..8d6066897e7
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-diag-2.s
@@ -0,0 +1,28 @@
+# Testcase for a diagnostic around asymetrical restore
+	.type   foo, @function
+foo:
+.LFB10:
+	.cfi_startproc
+	endbr64
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	pushq   %r12
+	pushq   %rbx
+	subq    $24, %rsp
+	.cfi_offset %r12, -24
+	.cfi_offset %rbx, -32
+	addq    $24, %rsp
+# Note that the order of r12 and rbx restore does not match
+# order of the corresponding save(s).
+# The SCFI machinery warns the user.
+	popq    %r12
+	popq    %rbx
+	popq    %rbp
+	.cfi_def_cfa %rsp, 8
+	ret
+	.cfi_endproc
+.LFE10:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d
new file mode 100644
index 00000000000..b51546af149
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d
@@ -0,0 +1,24 @@
+#as: --scfi=experimental --gsframe -W
+#as: --gsframe
+#objdump: --sframe
+#name: SCFI for dynamic alloc stack
+#...
+
+Contents of the SFrame section .sframe:
+  Header :
+
+    Version: SFRAME_VERSION_2
+    Flags: NONE
+    Num FDEs: 1
+    Num FREs: 4
+
+  Function Index :
+
+    func idx \[0\]: pc = 0x0, size = 87 bytes
+    STARTPC + CFA + FP + RA           
+    0+0000 + sp\+8 + u + u            
+    0+0001 + sp\+16 + c-16 + u            
+    0+0004 + fp\+16 + c-16 + u            
+    0+0056 + sp\+8 + u + u            
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.l
new file mode 100644
index 00000000000..abca835a642
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*5: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.s
new file mode 100644
index 00000000000..7e649b92ad1
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.s
@@ -0,0 +1,50 @@
+	.text
+	.globl   foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq   %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	pushq   %r13
+	pushq   %r12
+	pushq   %rbx
+	subq    $8, %rsp
+	.cfi_offset %r13, -24
+	.cfi_offset %r12, -32
+	.cfi_offset %rbx, -40
+	call    read_user
+	testl   %eax, %eax
+	jle    .L2
+	cltq
+	xorl   %ebx, %ebx
+	leaq   0(,%rax,4), %r13
+	.p2align 4,,10
+	.p2align 3
+.L3:
+	leaq   15(%rbx), %rax
+	movq   %rsp, %r12
+	addq   $4, %rbx
+	andq   $-16, %rax
+	subq   %rax, %rsp
+	movq   %rsp, %rdi
+	call   foo
+	movq   %r12, %rsp
+	cmpq   %r13, %rbx
+	jne   .L3
+.L2:
+	leaq   -24(%rbp), %rsp
+	xorl   %eax, %eax
+	popq   %rbx
+	popq   %r12
+	popq   %r13
+	popq   %rbp
+	.cfi_restore %rbp
+	.cfi_def_cfa_register %rsp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-enter-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-enter-1.d
new file mode 100644
index 00000000000..f38473d01ad
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-enter-1.d
@@ -0,0 +1,36 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for enter insn
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0024 0+001c FDE cie=0+0000 pc=0+0000..0+000a
+  DW_CFA_advance_loc: 4 to 0+0004
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 1 to 0+0005
+  DW_CFA_offset: r3 \(rbx\) at cfa-24
+  DW_CFA_advance_loc: 3 to 0+0008
+  DW_CFA_restore: r3 \(rbx\)
+  DW_CFA_advance_loc: 1 to 0+0009
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-enter-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-enter-1.l
new file mode 100644
index 00000000000..bcf3095a9bb
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-enter-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-enter-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-enter-1.s
new file mode 100644
index 00000000000..b6aed87d2dd
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-enter-1.s
@@ -0,0 +1,24 @@
+# Testcase for leave insn
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	enter   $0,$0
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	.cfi_def_cfa_register %rbp
+	push    %rbx
+	.cfi_offset %rbx, -24
+	push    %rdi
+	pop     %rdi
+	pop     %rbx
+	.cfi_restore %rbx
+	leave
+	.cfi_def_cfa_register %rsp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-fp-diag-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-fp-diag-2.l
new file mode 100644
index 00000000000..8bf0dc31b69
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-fp-diag-2.l
@@ -0,0 +1,3 @@
+.*Assembler messages:
+.*7: Warning: SCFI ignores most user-specified CFI directives
+.*28: Warning: SCFI: asymetrical register restore
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-fp-diag-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-fp-diag-2.s
new file mode 100644
index 00000000000..0a25324430c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-fp-diag-2.s
@@ -0,0 +1,55 @@
+# Testcase for a diagnostic around asymetrical restore
+# Testcase inspired by byte_insert_op1 in libiberty
+# False positive for the diagnostic
+	.type   foo, @function
+foo:
+.LFB10:
+	.cfi_startproc
+	endbr64
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq   %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	pushq   %r12
+	pushq   %rbx
+	subq   $24, %rsp
+	.cfi_offset %r12, -24
+	.cfi_offset %rbx, -32
+	movl   %edi, -20(%rbp)
+	movq   %rsi, -32(%rbp)
+	movl   %edx, -24(%rbp)
+	movq   %rcx, -40(%rbp)
+# The assembler cannot differentiate that the following
+# mov to %rbx is not a true restore operation, but simply
+# %rbx register usage as a scratch reg of some sort.
+# The assembler merely warns of a possible asymetric restore operation
+# In this case, its noise for the user unfortunately.
+	movq   -40(%rbp), %rbx
+	movq   -40(%rbp), %rax
+	leaq   3(%rax), %r12
+	jmp   .L563
+.L564:
+	subq   $1, %rbx
+	subq   $1, %r12
+	movzbl   (%rbx), %eax
+	movb   %al, (%r12)
+.L563:
+	cmpq   -32(%rbp), %rbx
+	jne   .L564
+	movl   -24(%rbp), %edx
+	movq   -32(%rbp), %rcx
+	movl   -20(%rbp), %eax
+	movq   %rcx, %rsi
+	movl   %eax, %edi
+	call   byte_store_op1
+	nop
+	addq   $24, %rsp
+	popq   %rbx
+	popq   %r12
+	popq   %rbp
+	.cfi_def_cfa %rsp, 8
+	ret
+	.cfi_endproc
+.LFE10:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.d
new file mode 100644
index 00000000000..732768c1d1c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.d
@@ -0,0 +1,52 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for indirect mem op to stack 1
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0034 0+001c FDE cie=00000000 pc=0+0000..0+005b
+  DW_CFA_advance_loc: 4 to 0+0004
+  DW_CFA_def_cfa_offset: 64
+  DW_CFA_advance_loc: 4 to 0+0008
+  DW_CFA_offset: r3 \(rbx\) at cfa-64
+  DW_CFA_advance_loc: 5 to 0+000d
+  DW_CFA_offset: r6 \(rbp\) at cfa-56
+  DW_CFA_advance_loc: 5 to 0+0012
+  DW_CFA_offset: r12 \(r12\) at cfa-48
+  DW_CFA_advance_loc: 5 to 0+0017
+  DW_CFA_offset: r13 \(r13\) at cfa-40
+  DW_CFA_advance_loc: 5 to 0+001c
+  DW_CFA_offset: r14 \(r14\) at cfa-32
+  DW_CFA_advance_loc: 5 to 0+0021
+  DW_CFA_offset: r15 \(r15\) at cfa-24
+  DW_CFA_advance_loc: 29 to 0+003e
+  DW_CFA_restore: r15 \(r15\)
+  DW_CFA_advance_loc: 5 to 0+0043
+  DW_CFA_restore: r14 \(r14\)
+  DW_CFA_advance_loc: 5 to 0+0048
+  DW_CFA_restore: r13 \(r13\)
+  DW_CFA_advance_loc: 5 to 0+004d
+  DW_CFA_restore: r12 \(r12\)
+  DW_CFA_advance_loc: 5 to 0+0052
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_advance_loc: 4 to 0+0056
+  DW_CFA_restore: r3 \(rbx\)
+  DW_CFA_advance_loc: 4 to 0+005a
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.l
new file mode 100644
index 00000000000..8662e445edf
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*4: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.s
new file mode 100644
index 00000000000..53c55330321
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-1.s
@@ -0,0 +1,48 @@
+# An example of static stack allocation by hand
+	.type foo, @function
+foo:
+	.cfi_startproc
+	/* Allocate space for 7 registers.  */
+	subq   $56,%rsp
+	.cfi_adjust_cfa_offset 56
+	movq   %rbx,(%rsp)
+   .cfi_rel_offset %rbx, 0
+	movq   %rbp,8(%rsp)
+	.cfi_rel_offset %rbp, 8
+	movq   %r12,16(%rsp)
+	.cfi_rel_offset %r12, 16
+	movq   %r13,24(%rsp)
+	.cfi_rel_offset %r13, 24
+	movq   %r14,32(%rsp)
+	.cfi_rel_offset %r14, 32
+	movq   %r15,40(%rsp)
+	.cfi_rel_offset %r15, 40
+	movq   %r9,48(%rsp)
+
+	/* Setup parameter for __foo_internal.  */
+	/* selfpc is the return address on the stack.  */
+	movq   56(%rsp),%rsi
+	/* Get frompc via the frame pointer.  */
+	movq   8(%rbp),%rdi
+	call __foo_internal
+	/* Pop the saved registers.  Please note that `foo' has no
+	   return value.  */
+	movq   48(%rsp),%r9
+
+	movq   40(%rsp),%r15
+	.cfi_restore %r15
+	movq   32(%rsp),%r14
+	.cfi_restore %r14
+	movq   24(%rsp),%r13
+	.cfi_restore %r13
+	movq   16(%rsp),%r12
+	.cfi_restore %r12
+	movq   8(%rsp),%rbp
+	.cfi_restore %rbp
+	movq   (%rsp),%rbx
+	.cfi_restore %rbx
+	addq   $56,%rsp
+	.cfi_adjust_cfa_offset -56
+	ret
+	.cfi_endproc
+	.size foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.d b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.d
new file mode 100644
index 00000000000..d5e26cd925b
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.d
@@ -0,0 +1,42 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for indirect mem op to stack 2
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+002c 0+001c FDE cie=00000000 pc=0+0000..0+0026
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 3 to 0+0004
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 8 to 0+000c
+  DW_CFA_offset: r3 \(rbx\) at cfa-32
+  DW_CFA_advance_loc: 4 to 0+0010
+  DW_CFA_offset: r12 \(r12\) at cfa-24
+  DW_CFA_advance_loc: 9 to 0+0019
+  DW_CFA_restore: r3 \(rbx\)
+  DW_CFA_advance_loc: 4 to 0+001d
+  DW_CFA_restore: r12 \(r12\)
+  DW_CFA_advance_loc: 7 to 0+0024
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_advance_loc: 1 to 0+0025
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.l
new file mode 100644
index 00000000000..bcf3095a9bb
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.s
new file mode 100644
index 00000000000..cf63fdba45f
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-2.s
@@ -0,0 +1,38 @@
+# Testcase for movq instructions
+	.text
+	.globl   foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+
+	subq   $16,%rsp
+
+# store rbx at %rsp; rsp = rbp - 16;
+	movq   %rbx, -16(%rbp)
+	.cfi_rel_offset %rbx, -16
+# store r12 at %rsp + 8; rsp = rbp -16;
+	movq   %r12, -8(%rbp)
+	.cfi_rel_offset %r12, -8
+
+	call bar
+
+	movq   -16(%rbp), %rbx
+	.cfi_restore %rbx
+	movq   -8(%rbp), %r12
+	.cfi_restore %r12
+
+	addq   $16,%rsp
+
+	mov   %rbp, %rsp
+	.cfi_def_cfa_register %rsp
+	pop   %rbp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.d b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.d
new file mode 100644
index 00000000000..241b6289974
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.d
@@ -0,0 +1,42 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for indirect mem op to stack 3
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+002c 0+001c FDE cie=00000000 pc=0+0000..0+0028
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 3 to 0+0004
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 8 to 0+000c
+  DW_CFA_offset: r3 \(rbx\) at cfa-32
+  DW_CFA_advance_loc: 5 to 0+0011
+  DW_CFA_offset: r12 \(r12\) at cfa-24
+  DW_CFA_advance_loc: 9 to 0+001a
+  DW_CFA_restore: r3 \(rbx\)
+  DW_CFA_advance_loc: 5 to 0+001f
+  DW_CFA_restore: r12 \(r12\)
+  DW_CFA_advance_loc: 7 to 0+0026
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_advance_loc: 1 to 0+0027
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.l b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.l
new file mode 100644
index 00000000000..bcf3095a9bb
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.s b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.s
new file mode 100644
index 00000000000..c6247f74370
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-3.s
@@ -0,0 +1,38 @@
+# Testcase for movq instructions
+	.text
+	.globl   foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+
+	subq   $16,%rsp
+
+# store rbx at %rsp; rsp = rbp - 16; rsp = CFA - 32
+	movq   %rbx, (%rsp)
+	.cfi_rel_offset %rbx, -16
+# store r12 at %rsp + 8; rsp = CFA - 32
+	movq   %r12, 8(%rsp)
+	.cfi_rel_offset %r12, -8
+
+	call bar
+
+	movq   (%rsp), %rbx
+	.cfi_restore %rbx
+	movq   8(%rsp), %r12
+	.cfi_restore %r12
+
+	addq   $16,%rsp
+
+	mov   %rbp, %rsp
+	.cfi_def_cfa_register %rsp
+	pop   %rbp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.d b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.d
new file mode 100644
index 00000000000..614be3b5dce
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.d
@@ -0,0 +1,64 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for indirect mem op to stack 3
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000018 0+004c 0000001c FDE cie=00000000 pc=0+0000..0+003d
+  DW_CFA_advance_loc: 2 to 0+0002
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r15 \(r15\) at cfa-16
+  DW_CFA_advance_loc: 2 to 0+0004
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_offset: r14 \(r14\) at cfa-24
+  DW_CFA_advance_loc: 5 to 0+0009
+  DW_CFA_def_cfa_offset: 32
+  DW_CFA_offset: r13 \(r13\) at cfa-32
+  DW_CFA_advance_loc: 5 to 0+000e
+  DW_CFA_def_cfa_offset: 40
+  DW_CFA_offset: r12 \(r12\) at cfa-40
+  DW_CFA_advance_loc: 4 to 0+0012
+  DW_CFA_def_cfa_offset: 48
+  DW_CFA_offset: r6 \(rbp\) at cfa-48
+  DW_CFA_advance_loc: 4 to 0+0016
+  DW_CFA_def_cfa_offset: 56
+  DW_CFA_offset: r3 \(rbx\) at cfa-56
+  DW_CFA_advance_loc: 7 to 0+001d
+  DW_CFA_def_cfa_offset: 96
+  DW_CFA_advance_loc: 21 to 0+0032
+  DW_CFA_def_cfa_offset: 56
+  DW_CFA_advance_loc: 1 to 0+0033
+  DW_CFA_restore: r3 \(rbx\)
+  DW_CFA_def_cfa_offset: 48
+  DW_CFA_advance_loc: 1 to 0+0034
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 40
+  DW_CFA_advance_loc: 2 to 0+0036
+  DW_CFA_restore: r12 \(r12\)
+  DW_CFA_def_cfa_offset: 32
+  DW_CFA_advance_loc: 2 to 0+0038
+  DW_CFA_restore: r13 \(r13\)
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_advance_loc: 2 to 0+003a
+  DW_CFA_restore: r14 \(r14\)
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_advance_loc: 2 to 0+003c
+  DW_CFA_restore: r15 \(r15\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.l b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.l
new file mode 100644
index 00000000000..d87f01ac77e
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.l
@@ -0,0 +1,3 @@
+.*Assembler messages:
+.*7: Warning: SCFI ignores most user-specified CFI directives
+.*41: Warning: SCFI: asymetrical register restore
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.s b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.s
new file mode 100644
index 00000000000..988ca3f78a7
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-4.s
@@ -0,0 +1,68 @@
+# Testcase for save/unsave of callee-saved registers
+# Must be run -W as there is an expected warning as
+# noted below
+	.type   foo, @function
+foo:
+.LFB118:
+	.cfi_startproc
+	pushq   %r15
+	.cfi_def_cfa_offset 16
+	.cfi_offset %r15, -16
+	pushq   %r14
+	.cfi_def_cfa_offset 24
+	.cfi_offset %r14, -24
+	movl    %r8d, %r14d
+	pushq   %r13
+	.cfi_def_cfa_offset 32
+	.cfi_offset %r13, -32
+	movq    %rdi, %r13
+	pushq   %r12
+	.cfi_def_cfa_offset 40
+	.cfi_offset %r12, -40
+	movq    %rsi, %r12
+	pushq   %rbp
+	.cfi_def_cfa_offset 48
+	.cfi_offset %rbp, -48
+	movq    %rcx, %rbp
+	pushq   %rbx
+	.cfi_def_cfa_offset 56
+	.cfi_offset %rbx, -56
+	movq   %rdx, %rbx
+	subq   $40, %rsp
+	.cfi_def_cfa_offset 96
+	testb   $1, 37(%rdx)
+	je   .L2
+.L3:
+# The following is not a restore of r15: rbp has been used as
+# scratch register already.  The SCFI machinery must know that
+# REG_FP is not traceable.
+# A warning here is expected:
+# 41: Warning: SCFI: asymetrical register restore
+	movq   32(%rbp), %r15
+	cmpq   $0, 64(%r15)
+	je   .L2
+.L2:
+	addq   $40, %rsp
+	.cfi_def_cfa_offset 56
+	popq   %rbx
+	.cfi_restore %rbx
+	.cfi_def_cfa_offset 48
+	popq   %rbp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 40
+	popq   %r12
+	.cfi_restore %r12
+	.cfi_def_cfa_offset 32
+	popq   %r13
+	.cfi_restore %r13
+	.cfi_def_cfa_offset 24
+	popq   %r14
+	.cfi_restore %r14
+	.cfi_def_cfa_offset 16
+	popq   %r15
+	.cfi_restore %r15
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE118:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-5.s b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-5.s
new file mode 100644
index 00000000000..9efff69cfa1
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-indirect-mov-5.s
@@ -0,0 +1,35 @@
+# An example of static stack allocation by hand
+	.type foo, @function
+foo:
+	.cfi_startproc
+	/* Allocate space for 7 registers.  */
+	subq   $56,%rsp
+	.cfi_adjust_cfa_offset 56
+	movq   %rsp, %rax
+	movq   %rbx,(%rax)
+	.cfi_rel_offset %rbx, 0
+	movq   %rbp,8(%rax)
+	.cfi_rel_offset %rbp, 8
+	movq   %r12,16(%rax)
+	.cfi_rel_offset %r12, 16
+
+	/* Setup parameter for __foo_internal.  */
+	/* selfpc is the return address on the stack.  */
+	movq   56(%rsp),%rsi
+	/* Get frompc via the frame pointer.  */
+	movq   8(%rbp),%rdi
+	call __foo_internal
+	/* Pop the saved registers.  Please note that `foo' has no
+	   return value.  */
+
+	movq   16(%rax),%r12
+	.cfi_restore %r12
+	movq   8(%rax),%rbp
+	.cfi_restore %rbp
+	movq   (%rsp),%rbx
+	.cfi_restore %rbx
+	addq   $56,%rsp
+	.cfi_adjust_cfa_offset -56
+	ret
+	.cfi_endproc
+	.size foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-lea-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-lea-1.d
new file mode 100644
index 00000000000..cf56fc27a48
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-lea-1.d
@@ -0,0 +1,38 @@
+#as: --scfi=experimental -W -O2
+#as: -O2
+#objdump: -Wf
+#name: Synthesize CFI for various lea instructions (-O2)
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0024 0+001c FDE cie=00000000 pc=0+0000..0+0029
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 3 to 0+0004
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 2 to 0+0006
+  DW_CFA_offset: r13 \(r13\) at cfa-24
+  DW_CFA_advance_loc: 33 to 0+0027
+  DW_CFA_restore: r13 \(r13\)
+  DW_CFA_advance_loc: 1 to 0+0028
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-lea-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-lea-1.l
new file mode 100644
index 00000000000..5ff6048bef0
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-lea-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*8: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-lea-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-lea-1.s
new file mode 100644
index 00000000000..a31f8593732
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-lea-1.s
@@ -0,0 +1,39 @@
+## Testcase with a variety of lea.
+## This test is run with -O2 by default to check
+## SCFI in wake of certain target optimizations.
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+# This lea gets transformed to mov %rsp, %rbp when -O2.
+# The SCFI machinery must see it as such.
+	lea    (%rsp), %rbp
+	.cfi_def_cfa_register %rbp
+	push   %r13
+	.cfi_offset %r13, -24
+	subq   $8, %rsp
+	testl  %eax, %eax
+	jle   .L2
+.L3:
+	movq   %rsp, %r12
+	lea    -0x2(%r13),%rax
+	lea    0x8(%r12,%rdx,4),%r8
+	movq   %r12, %rsp
+	jne   .L3
+.L2:
+	leaq   -8(%rbp), %rsp
+	xorl   %eax, %eax
+	popq   %r13
+	.cfi_restore %r13
+	popq   %rbp
+	.cfi_def_cfa_register %rsp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-leave-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-leave-1.d
new file mode 100644
index 00000000000..7b0a4667849
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-leave-1.d
@@ -0,0 +1,37 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for leave insn
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0024 0+001c FDE cie=0+0000 pc=0+0000..0+000a
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 3 to 0+0004
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 1 to 0+0005
+  DW_CFA_offset: r3 \(rbx\) at cfa-24
+  DW_CFA_advance_loc: 3 to 0+0008
+  DW_CFA_restore: r3 \(rbx\)
+  DW_CFA_advance_loc: 1 to 0+0009
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-leave-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-leave-1.l
new file mode 100644
index 00000000000..bcf3095a9bb
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-leave-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-leave-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-leave-1.s
new file mode 100644
index 00000000000..d86d944769b
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-leave-1.s
@@ -0,0 +1,25 @@
+# Testcase for leave insn
+	.text
+	.globl   foo
+	.type    foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	push    %rbx
+	.cfi_offset %rbx, -24
+	push    %rdi
+	pop     %rdi
+	pop     %rbx
+	.cfi_restore %rbx
+	leave
+	.cfi_def_cfa_register %rsp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.d
new file mode 100644
index 00000000000..78afef3a940
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.d
@@ -0,0 +1,36 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for pushq insns
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0024 0+001c FDE cie=0+0000 pc=0+0000..0+000f
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_advance_loc: 3 to 0+0004
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_advance_loc: 5 to 0+0009
+  DW_CFA_def_cfa_offset: 32
+  DW_CFA_advance_loc: 2 to 0+000b
+  DW_CFA_def_cfa_offset: 40
+  DW_CFA_advance_loc: 2 to 0+0000d
+  DW_CFA_def_cfa_offset: 48
+  DW_CFA_advance_loc: 1 to 0+0000e
+  DW_CFA_def_cfa_offset: 56
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.l
new file mode 100644
index 00000000000..6ec24387b8c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*7: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.s
new file mode 100644
index 00000000000..7be53a41d5f
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-pushq-1.s
@@ -0,0 +1,23 @@
+## Testcase with a variety of pushq.
+## all push insns valid in 64-bit mode must be processed for SCFI.
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rax
+	.cfi_def_cfa_offset 16
+	pushq   16(%rax)
+	.cfi_def_cfa_offset 24
+	push   $1048576
+	.cfi_def_cfa_offset 32
+	pushq   %fs
+	.cfi_def_cfa_offset 40
+	pushq   %gs
+	.cfi_def_cfa_offset 48
+	pushf
+	.cfi_def_cfa_offset 56
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.d
new file mode 100644
index 00000000000..8056e02eb16
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.d
@@ -0,0 +1,43 @@
+#as: --scfi=experimental -W
+#objdump: -Wf
+#name: Synthesize CFI with pushsection 1
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000018 0+0010 0000001c FDE cie=00000000 pc=0+0000..0+0005
+  DW_CFA_advance_loc: 4 to 0+0004
+  DW_CFA_def_cfa_offset: 48
+
+0000002c 0+0028 00000030 FDE cie=00000000 pc=0+0000..0+0014
+  DW_CFA_advance_loc: 2 to 0+0002
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r12 \(r12\) at cfa-16
+  DW_CFA_advance_loc: 2 to 0+0004
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_offset: r13 \(r13\) at cfa-24
+  DW_CFA_advance_loc: 4 to 0+0008
+  DW_CFA_def_cfa_offset: 32
+  DW_CFA_advance_loc: 7 to 0+000f
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_advance_loc: 2 to 0+0011
+  DW_CFA_restore: r13 \(r13\)
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_advance_loc: 2 to 0+0013
+  DW_CFA_restore: r12 \(r12\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.l
new file mode 100644
index 00000000000..6ec24387b8c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*7: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.s
new file mode 100644
index 00000000000..e421ef6d86f
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-1.s
@@ -0,0 +1,40 @@
+# Testcase for pushsection directive and SCFI.
+# The .pushsection directive must cause creation of a new FDE.
+        .text
+        .globl  foo
+        .type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %r12
+	.cfi_def_cfa_offset 16
+	.cfi_offset %r12, -16
+	pushq   %r13
+	.cfi_def_cfa_offset 24
+	.cfi_offset %r13, -24
+	subq    $8, %rsp
+	.cfi_def_cfa_offset 32
+	mov   %rax, %rbx
+	.pushsection .text2
+# It's the .type directive here that enforces SCFI generation
+# for the code block that follows
+	.type   foo2, @function
+foo2:
+	.cfi_startproc
+	subq    $40, %rsp
+	.cfi_def_cfa_offset 48
+	ret
+	.cfi_endproc
+	.size foo2, .-foo2
+	.popsection
+	addq   $8, %rsp
+	.cfi_def_cfa_offset 24
+	popq    %r13
+	.cfi_restore %r13
+	.cfi_def_cfa_offset 16
+	popq    %r12
+	.cfi_restore %r12
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.d b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.d
new file mode 100644
index 00000000000..abddd9dedd6
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.d
@@ -0,0 +1,40 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for demarcated code blocks 2
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+00000018 0+002c 0000001c FDE cie=00000000 pc=0+0000..0+0014
+  DW_CFA_advance_loc: 2 to 0+0002
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r12 \(r12\) at cfa-16
+  DW_CFA_advance_loc: 2 to 0+0004
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_offset: r13 \(r13\) at cfa-24
+  DW_CFA_advance_loc: 4 to 0+0008
+  DW_CFA_def_cfa_offset: 32
+  DW_CFA_advance_loc: 7 to 0+000f
+  DW_CFA_def_cfa_offset: 24
+  DW_CFA_advance_loc: 2 to 0+0011
+  DW_CFA_restore: r13 \(r13\)
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_advance_loc: 2 to 0+0013
+  DW_CFA_restore: r12 \(r12\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.l
new file mode 100644
index 00000000000..bcf3095a9bb
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.s
new file mode 100644
index 00000000000..65eb63e6375
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-pushsection-2.s
@@ -0,0 +1,40 @@
+# Testcase for pushsection directive and SCFI.
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %r12
+	.cfi_def_cfa_offset 16
+	.cfi_offset %r12, -16
+	pushq   %r13
+	.cfi_def_cfa_offset 24
+	.cfi_offset %r13, -24
+	subq    $8, %rsp
+	.cfi_def_cfa_offset 32
+	mov     %rax, %rbx
+# The .pushsection directive creates a new code block,
+# which must not contribute ginsn to the existing one.
+	.pushsection .text2
+# For CFI to be synthesized for this block, the user should have # demarcated
+# the beginning with a .type name, @function.  Note that, the test when run
+# without --scfi=experimental will, however, generate the DWARF FDE if the CFI
+# annotations exist.  Hence, comment them out for now.
+#	.cfi_startproc
+	subq    $40, %rsp
+#	.cfi_def_cfa_offset 48
+	ret
+#	.cfi_endproc
+	.popsection
+	addq    $8, %rsp
+	.cfi_def_cfa_offset 24
+	popq    %r13
+	.cfi_restore %r13
+	.cfi_def_cfa_offset 16
+	popq    %r12
+	.cfi_restore %r12
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.d
new file mode 100644
index 00000000000..fb09269f6cd
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.d
@@ -0,0 +1,32 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for self-aligning func
+#...
+Contents of the .eh_frame section:
+
+0+0000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+001c 0000001c FDE cie=00000000 pc=0+0000..0+002f
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 3 to 0+0004
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 42 to 0+002e
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.l
new file mode 100644
index 00000000000..6ec24387b8c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*7: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.s
new file mode 100644
index 00000000000..1068332c988
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-selfalign-func-1.s
@@ -0,0 +1,36 @@
+# If it is known that the caller of self_aligning_foo may have had
+# the stack pointer unaligned to 16-bytes boundary,  such self-aligning
+# functions may be used by asm programmers.
+	.globl  self_aligning_foo
+	.type   self_aligning_foo, @function
+self_aligning_foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+# The following 'and' op aligns the stack pointer.
+# At the same time, it causes REG_SP to become non-traceable
+# for SCFI purposes.  But no warning is issued as no further stack
+# size tracking is needed for SCFI purposes.
+	andq    $-16, %rsp
+	subq    $32, %rsp
+	movl    %edi, 12(%rsp)
+	movl    %esi, 8(%rsp)
+	movl    $0, %eax
+	call    vector_using_function
+	movaps  %xmm0, 16(%rsp)
+	movl    12(%rsp), %edx
+	movl    8(%rsp), %eax
+	addl    %edx, %eax
+	leave
+# GCC typically generates a '.cfi_def_cfa 7, 8' for leave
+# insn.  The SCFI however, will generate the following:
+	.cfi_def_cfa_register %rsp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   self_aligning_foo, .-self_aligning_foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-simple-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-simple-1.d
new file mode 100644
index 00000000000..819a1299b53
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-simple-1.d
@@ -0,0 +1,27 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI simple test 1
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0014 0+001c FDE cie=0+0000 pc=0+0000..0+0002
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_nop
+  DW_CFA_nop
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-simple-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-simple-1.l
new file mode 100644
index 00000000000..6ec24387b8c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-simple-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*7: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-simple-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-simple-1.s
new file mode 100644
index 00000000000..6fc2b7b8707
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-simple-1.s
@@ -0,0 +1,15 @@
+# Simple test
+# A wierd function, but SCFI machinery does not complain yet.
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
+
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-simple-2.d b/gas/testsuite/gas/scfi/x86_64/scfi-simple-2.d
new file mode 100644
index 00000000000..de8c3ae7fd2
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-simple-2.d
@@ -0,0 +1,31 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI simple test 2
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0001c 0+0001c FDE cie=0+0000 pc=0+0000..0+0003
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 1 to 0+0002
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-simple-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-simple-2.l
new file mode 100644
index 00000000000..abca835a642
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-simple-2.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*5: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-simple-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-simple-2.s
new file mode 100644
index 00000000000..7055fc10b23
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-simple-2.s
@@ -0,0 +1,16 @@
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset 6, -16
+	popq    %rbp
+	.cfi_restore 6
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
+
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-sub-1.d b/gas/testsuite/gas/scfi/x86_64/scfi-sub-1.d
new file mode 100644
index 00000000000..042ce33cd38
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-sub-1.d
@@ -0,0 +1,26 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for sub insn 1
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+0014 0+001c FDE cie=0+0000 pc=0+0000..0+0008
+  DW_CFA_advance_loc: 7 to 0+0007
+  DW_CFA_def_cfa_offset: 120016
+  DW_CFA_nop
+#...
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-sub-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-sub-1.l
new file mode 100644
index 00000000000..bcf3095a9bb
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-sub-1.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-sub-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-sub-1.s
new file mode 100644
index 00000000000..aabd1e7a50f
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-sub-1.s
@@ -0,0 +1,12 @@
+# Testcase for sub instruction.
+	.text
+	.globl   foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+	subq    $120008, %rsp
+	.cfi_def_cfa_offset 120016
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-sub-2.d b/gas/testsuite/gas/scfi/x86_64/scfi-sub-2.d
new file mode 100644
index 00000000000..a1481056a4c
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-sub-2.d
@@ -0,0 +1,32 @@
+#as: --scfi=experimental -W
+#as:
+#objdump: -Wf
+#name: Synthesize CFI for sub insn 2
+#...
+Contents of the .eh_frame section:
+
+00000000 0+0014 0+0000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 1
+  Data alignment factor: -8
+  Return address column: 16
+  Augmentation data:     [01][abc]
+  DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+  DW_CFA_offset: r16 \(rip\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+0000..0+001d
+  DW_CFA_advance_loc: 1 to 0+0001
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r6 \(rbp\) at cfa-16
+  DW_CFA_advance_loc: 3 to 0+0004
+  DW_CFA_def_cfa_register: r6 \(rbp\)
+  DW_CFA_advance_loc: 24 to 0+001c
+  DW_CFA_def_cfa_register: r7 \(rsp\)
+  DW_CFA_restore: r6 \(rbp\)
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_nop
+
+#pass
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-sub-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-sub-2.l
new file mode 100644
index 00000000000..bcf3095a9bb
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-sub-2.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-sub-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-sub-2.s
new file mode 100644
index 00000000000..c8e0512d4a8
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-sub-2.s
@@ -0,0 +1,29 @@
+# Testcase for sub reg, reg instruction.
+	.text
+	.globl   foo
+	.type    foo, @function
+foo:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	subq    %rax, %rsp
+# SCFI: Stack-pointer manipulation after switching
+# to RBP based tracking is OK.
+	addq   %rax, %rsp
+# Other kind of sub instructions should not error out in the
+# x86_64 -> ginsn translator
+	subq    (%r12), %rax
+	subq    $1,(%rdi)
+	subq    %rax, 40(%r12)
+	subl    %edx, -32(%rsp)
+	leave
+	.cfi_def_cfa_register %rsp
+	.cfi_restore %rbp
+	.cfi_def_cfa_offset 8
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-1.l
new file mode 100644
index 00000000000..fc26b86a281
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-1.l
@@ -0,0 +1,2 @@
+Assembler messages:
+Fatal error: SCFI is not supported for this ABI
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-1.s
new file mode 100644
index 00000000000..74a46dfa9e4
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-1.s
@@ -0,0 +1,9 @@
+# Testcase run with --32 and --x32 (Either not supported with SCFI).
+	.text
+	.globl   foo
+	.type    foo, @function
+foo:
+	pushq   %rbp
+	ret
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-2.l
new file mode 100644
index 00000000000..98a7ac67ec0
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-2.l
@@ -0,0 +1,3 @@
+.*Assembler messages:
+.*8: Error: SCFI: unsupported stack manipulation pattern
+.*13: Error: SCFI: forward pass failed for func 'foo'
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-2.s
new file mode 100644
index 00000000000..f0ff42fb796
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-2.s
@@ -0,0 +1,13 @@
+	.text
+	.globl   foo
+	.type    foo, @function
+foo:
+	addq    %rdx, %rax
+# Stack manipulation without switching to RBP
+# based tracking is not supported for SCFI.
+	addq    %rax, %rsp
+	push    %rdi
+	leave
+	ret
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-3.l b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-3.l
new file mode 100644
index 00000000000..98a7ac67ec0
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-3.l
@@ -0,0 +1,3 @@
+.*Assembler messages:
+.*8: Error: SCFI: unsupported stack manipulation pattern
+.*13: Error: SCFI: forward pass failed for func 'foo'
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-3.s b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-3.s
new file mode 100644
index 00000000000..b0cf59ecadf
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-3.s
@@ -0,0 +1,13 @@
+	.text
+	.globl  foo
+	.type   foo, @function
+foo:
+	addq    %rdx, %rax
+# Stack manipulation without switching to RBP
+# based tracking is not supported for SCFI.
+	movq    %rax, %rsp
+	push    %rdi
+	leave
+	ret
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-4.l b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-4.l
new file mode 100644
index 00000000000..4ee445e7ebf
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-4.l
@@ -0,0 +1,4 @@
+.*Assembler messages:
+.*4: Warning: SCFI ignores most user-specified CFI directives
+.*14: Error: SCFI: unsupported stack manipulation pattern
+.*22: Error: SCFI: forward pass failed for func 'foo'
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-4.s b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-4.s
new file mode 100644
index 00000000000..eff5a29fad7
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-4.s
@@ -0,0 +1,22 @@
+	.type   foo, @function
+foo:
+.LFB16:
+	.cfi_startproc
+	pushq   %rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq    %rsp, %rbp
+# The following stack manipulation is OK to do, as CFA tracking
+# REG_FP based.
+	movq   %rax, %rsp
+# But...not quite, if there is a follow up usage of stack
+# like a register save of a callee-saved register.
+	push   %rbx
+	mov    %rbp, %rsp
+	popq   %rbp
+	.cfi_def_cfa %rsp, 8
+	.cfi_restore %rbp
+	ret
+	.cfi_endproc
+.LFE16:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-1.l
new file mode 100644
index 00000000000..1e138a102fe
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-1.l
@@ -0,0 +1,3 @@
+.*Assembler messages:
+.*50: Warning: SCFI ignores most user-specified CFI directives
+.*52: Warning: Untraceable control flow for func 'foo'; Skipping SCFI
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-1.s
new file mode 100644
index 00000000000..1c6eb63740e
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-1.s
@@ -0,0 +1,52 @@
+# Testcase with an indirect jump
+# Indirect jumps, when present, make the list of ginsn an invalid
+# candidate for CFG creation.  Hence, no SCFI can be generated either.
+#
+# The testcase is rather long to showcase a simple concept.  The reason of
+# such a long testcase is to discuss if it is important to deal with these
+# patterns.  It may be possible to deal with this, if we allow some special
+# directives for helping the assembler with the indirect jump (jump table).
+	.text
+	.globl   foo
+	.type   foo, @function
+foo:
+	pushq   %rbp
+	movq    %rsp, %rbp
+	movl    %edi, -4(%rbp)
+	cmpl    $5, -4(%rbp)
+	ja      .L2
+	movl    -4(%rbp), %eax
+	movq    .L4(,%rax,8), %rax
+	jmp     *%rax
+.L4:
+	.quad   .L9
+	.quad   .L8
+	.quad   .L7
+	.quad   .L6
+	.quad   .L5
+	.quad   .L3
+.L9:
+	movl    $43, %eax
+	jmp     .L1
+.L8:
+	movl    $42, %eax
+	jmp     .L1
+.L7:
+	movl    $45, %eax
+	jmp     .L1
+.L6:
+	movl    $47, %eax
+	jmp     .L1
+.L5:
+	movl    $37, %eax
+	jmp     .L1
+.L3:
+	movl    $63, %eax
+	jmp     .L1
+.L2:
+.L1:
+	popq    %rbp
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-2.l b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-2.l
new file mode 100644
index 00000000000..84cf95fb5cd
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-2.l
@@ -0,0 +1,4 @@
+.*Assembler messages:
+.*6: Warning: SCFI ignores most user-specified CFI directives
+.*9: Error: SCFI: `jmp' insn with non-zero addend to sym not supported
+.*9: Error: SCFI: unhandled op 0xeb may cause incorrect CFI
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-2.s b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-2.s
new file mode 100644
index 00000000000..611041ef3f1
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-2.s
@@ -0,0 +1,14 @@
+# Testcase with unsupported jmp instructions
+	.text
+	.globl   foo
+	.type   foo, @function
+foo:
+	.cfi_startproc
+# The non-zero addend makes control flow tracking not impossible, but
+# difficult.  SCFI for such functions is not attempted.
+        jmp RangeLimit+1;
+RangeLimit:
+        nop
+        ret
+	.cfi_endproc
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-drap-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-drap-1.l
new file mode 100644
index 00000000000..ea0fc73fac1
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-drap-1.l
@@ -0,0 +1,4 @@
+.*Assembler messages:
+.*16: Warning: SCFI ignores most user-specified CFI directives
+.*19: Error: SCFI: unsupported stack manipulation pattern
+.*75: Error: SCFI: forward pass failed for func 'drap_foo'
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-drap-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-drap-1.s
new file mode 100644
index 00000000000..3809e9054c0
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-drap-1.s
@@ -0,0 +1,75 @@
+# Testcase with Dynamically Realigned Argument Pointer (DRAP)
+# register usage.
+#
+# There are two reasons why this cannot be supported with the current
+# SCFI machinery
+# 1. Not allowed: REG_CFA is r10 based for the few insns after
+#    'leaq    8(%rsp), %r10'.
+# 2. Untraceable stack size after 'andq    $-16, %rsp'
+# Both of these shortcomings may be worked out. FIXME DISCUSS Keep the rather
+# long testcase until then.
+	.text
+	.globl  drap_foo
+	.type   drap_foo, @function
+drap_foo:
+.LFB0:
+	.cfi_startproc
+	leaq    8(%rsp), %r10
+	.cfi_def_cfa %r10, 0
+	andq    $-16, %rsp
+	pushq   -8(%r10)
+	.cfi_def_cfa %rsp, 8
+	pushq   %rbp
+	.cfi_offset %rbp, -16
+	movq   %rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	pushq   %r15
+	pushq   %r14
+	pushq   %r13
+	pushq   %r12
+	pushq   %r10
+	.cfi_offset %r15, -24
+	.cfi_offset %r14, -32
+	.cfi_offset %r13, -40
+	.cfi_offset %r12, -48
+	pushq   %rbx
+	.cfi_offset %rbx, -64
+	subq    $32, %rsp
+	movq    $0, (%rdx)
+	cmpq    $0, (%rdi)
+	movq    $0, -56(%rbp)
+	je      .L21
+	movq    %rdi, %rbx
+	movq    %rsi, %rdi
+	movq    %rsi, %r12
+	call    func2@PLT
+	movq    (%rbx), %rdi
+	leaq    -56(%rbp), %rdx
+	movslq  %eax, %rsi
+	call    func1@PLT
+	testl   %eax, %eax
+	je      .L21
+	movq    -56(%rbp), %r13
+.L21:
+	addq    $32, %rsp
+	xorl    %eax, %eax
+	popq    %rbx
+	.cfi_restore %rbx3
+	popq    %r10
+	popq    %r12
+	.cfi_restore %r12
+	popq    %r13
+	.cfi_restore %r13
+	popq    %r14
+	.cfi_restore %r14
+	popq    %r15
+	.cfi_restore %r15
+	popq    %rbp
+	.cfi_restore %rbp
+	.cfi_def_cfa_register %rsp
+	.cfi_def_cfa_offset 8
+	leaq    -8(%r10), %rsp
+	ret
+	.cfi_endproc
+.LFE0:
+	.size   drap_foo, .-drap_foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-insn-1.l b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-insn-1.l
new file mode 100644
index 00000000000..d66a4c461c3
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-insn-1.l
@@ -0,0 +1,7 @@
+.*Assembler messages:
+.*7: Error: SCFI: unsupported APX op 0x8f may cause incorrect CFI
+.*8: Error: SCFI: unsupported APX op 0x8f may cause incorrect CFI
+.*9: Error: SCFI: unsupported APX op 0xff may cause incorrect CFI
+.*10: Error: SCFI: unsupported APX op 0xff may cause incorrect CFI
+.*11: Error: SCFI: unsupported APX op 0x11 may cause incorrect CFI
+.*13: Error: SCFI: hand-crafting instructions not supported
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-insn-1.s b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-insn-1.s
new file mode 100644
index 00000000000..97728bee49e
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-insn-1.s
@@ -0,0 +1,16 @@
+# Certain APX instructions are not supported currently
+# Also, hand-crafting instructions using .insn directive is not supported.
+	.text
+	.globl   foo
+	.type   foo, @function
+foo:
+	pop2p  %r12, %rax
+	pop2   %r12, %rax
+	push2  %r12, %rax
+	push2p %rax, %r17
+	adc %rsp, %r17, %rsp
+	# test $0x4,%ecx
+	.insn 0xf7/1, $4{:u32}, %ecx
+	ret
+.LFE0:
+	.size   foo, .-foo
diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp b/gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp
new file mode 100644
index 00000000000..460d5fd2bca
--- /dev/null
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp
@@ -0,0 +1,113 @@
+# Copyright (C) 2022-2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+
+if { ![is_elf_format] } then {
+    return
+}
+
+# common tests
+if  { ([istarget "x86_64-*-*"]) } then {
+
+    global ASFLAGS
+    set old_ASFLAGS "$ASFLAGS"
+
+    run_list_test "ginsn-dw2-regnum-1" "--scfi=experimental -ali"
+    run_list_test "ginsn-add-1" "--scfi=experimental -ali"
+    run_list_test "ginsn-pop-1" "--scfi=experimental -ali"
+    run_list_test "ginsn-push-1" "--scfi=experimental -ali"
+
+    run_dump_test "scfi-cfi-label-1"
+    run_list_test "scfi-cfi-label-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-cfi-sections-1"
+    run_list_test "scfi-cfi-sections-1" "--scfi=experimental --warn"
+
+    run_list_test "scfi-diag-1" "--scfi=experimental"
+    run_list_test "scfi-fp-diag-2" "--scfi=experimental"
+    run_list_test "scfi-diag-2" "--scfi=experimental"
+
+    run_list_test "scfi-unsupported-1" "--32 --scfi=experimental"
+    run_list_test "scfi-unsupported-1" "--x32 --scfi=experimental"
+    run_list_test "scfi-unsupported-insn-1" "--scfi=experimental"
+    run_list_test "scfi-unsupported-2" "--scfi=experimental"
+    run_list_test "scfi-unsupported-3" "--scfi=experimental"
+    run_list_test "scfi-unsupported-4" "--scfi=experimental"
+    run_list_test "scfi-unsupported-drap-1" "--scfi=experimental"
+    run_list_test "scfi-unsupported-cfg-1" "--scfi=experimental"
+    run_list_test "scfi-unsupported-cfg-2" "--scfi=experimental"
+
+    run_dump_test "scfi-add-1"
+    run_list_test "scfi-add-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-add-2"
+    run_list_test "scfi-add-2" "--scfi=experimental --warn"
+    run_dump_test "scfi-cfg-1"
+    run_list_test "scfi-cfg-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-cfg-2"
+    run_list_test "scfi-cfg-2" "--scfi=experimental --warn"
+    run_dump_test "scfi-asm-marker-1"
+    run_list_test "scfi-asm-marker-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-asm-marker-2"
+    run_list_test "scfi-asm-marker-2" "--scfi=experimental --warn"
+    run_dump_test "scfi-asm-marker-3"
+    run_list_test "scfi-asm-marker-3" "--scfi=experimental --warn"
+    run_dump_test "scfi-pushsection-1"
+    run_list_test "scfi-pushsection-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-pushsection-2"
+    run_list_test "scfi-pushsection-2" "--scfi=experimental --warn"
+
+    run_dump_test "scfi-cofi-1"
+    run_list_test "scfi-cofi-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-sub-1"
+    run_list_test "scfi-sub-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-sub-2"
+    run_list_test "scfi-sub-2" "--scfi=experimental --warn"
+    run_dump_test "scfi-simple-1"
+    run_list_test "scfi-simple-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-simple-2"
+    run_list_test "scfi-simple-2" "--scfi=experimental --warn"
+    run_dump_test "scfi-pushq-1"
+    run_list_test "scfi-pushq-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-lea-1"
+    run_list_test "scfi-lea-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-enter-1"
+    run_list_test "scfi-enter-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-leave-1"
+    run_list_test "scfi-leave-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-bp-sp-1"
+    run_list_test "scfi-bp-sp-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-bp-sp-2"
+    run_list_test "scfi-bp-sp-2" "--scfi=experimental --warn"
+    run_dump_test "scfi-callee-saved-1"
+    run_list_test "scfi-callee-saved-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-callee-saved-2"
+    run_list_test "scfi-callee-saved-2" "--scfi=experimental --warn"
+    run_dump_test "scfi-callee-saved-3"
+    run_list_test "scfi-callee-saved-3" "--scfi=experimental --warn"
+    run_dump_test "scfi-callee-saved-4"
+    run_list_test "scfi-callee-saved-4" "--scfi=experimental --warn"
+    run_dump_test "scfi-dyn-stack-1"
+    run_list_test "scfi-dyn-stack-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-indirect-mov-1"
+    run_list_test "scfi-indirect-mov-1" "--scfi=experimental --warn"
+    run_dump_test "scfi-indirect-mov-2"
+    run_list_test "scfi-indirect-mov-2" "--scfi=experimental --warn"
+    run_dump_test "scfi-indirect-mov-3"
+    run_list_test "scfi-indirect-mov-3" "--scfi=experimental --warn"
+    run_dump_test "scfi-indirect-mov-4"
+    run_list_test "scfi-indirect-mov-4" "--scfi=experimental --warn"
+    run_dump_test "scfi-selfalign-func-1"
+    run_list_test "scfi-selfalign-func-1" "--scfi=experimental --warn"
+}
+
-- 
2.41.0


  parent reply	other threads:[~2024-01-15 12:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15 12:07 [COMMITTED 00/15] Experimental support for synthesizing CFI for hand-written asm Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 01/15] gas: dw2gencfi: minor rejig for cfi_sections_set and all_cfi_sections Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 02/15] gas: dw2gencfi: use all_cfi_sections instead of cfi_sections Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 03/15] gas: dw2gencfi: expose a new cfi_set_last_fde API Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 04/15] gas: dw2gencfi: move some tc_* defines to the header file Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 05/15] gas: dw2gencfi: expose dot_cfi_sections for scfidw2gen Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 06/15] gas: dw2gencfi: externalize the all_cfi_sections Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 07/15] gas: add new command line option --scfi=experimental Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 08/15] gas: scfidw2gen: new functionality to prepare for SCFI Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 09/15] opcodes: gas: x86: define and use Rex2 as attribute not constraint Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 10/15] opcodes: x86: new marker for insns that implicitly update stack pointer Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 11/15] gas: x86: synthesize CFI for hand-written asm Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 12/15] gas: doc: update documentation for the new listing option Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 13/15] opcodes: i386-reg.tbl: Add a comment to reflect dependency on ordering Indu Bhagat
2024-01-15 12:07 ` Indu Bhagat [this message]
2024-01-15 12:07 ` [COMMITTED 15/15] gas/NEWS: announce the new SCFI command line option Indu Bhagat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240115120729.29771-15-indu.bhagat@oracle.com \
    --to=indu.bhagat@oracle.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).