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: [PATCH,V3 2/2] gas: scfi: untraceable control flow should be a hard error
Date: Fri, 26 Jan 2024 01:19:17 -0800	[thread overview]
Message-ID: <20240126091917.3266816-3-indu.bhagat@oracle.com> (raw)
In-Reply-To: <20240126091917.3266816-1-indu.bhagat@oracle.com>

[Changes from V2]
  - Remove string "SCFI:" altogether from the error message
  - Adjust the commit message
[End of changes from V2]

[V1 - Non existent.  Sent first patch series tagged as V2 by mistake.]

PR gas/31284

Currently, if an indirect jump is seen, GCFG (a CFG of ginsns) cannot be
created, and the SCFI machinery bails out with a warning:
  "Warning: Untraceable control flow for func 'foo'; Skipping SCFI"

It is, however, better suited if this is a hard error.  Change it to a
hard error.  Also change the message to skip mentioning "SCFI", because
the error itself may also useful when ginsns are used for other passes
(distinct from SCFI) involving GCFG, like a pass to detect if there is
unreachable code.  Hence, simply say:
  "Error: untraceable control flow for func 'foo'"

gas/
PR gas/31284
	* ginsn.c (ginsn_data_end): Use as_bad instead of as_warn.

gas/testsuite/
PR gas/31284
	* gas/scfi/x86_64/ginsn-cofi-1.l: Adjust to the expected output
	in case of errors.
	* gas/scfi/x86_64/scfi-unsupported-cfg-1.l: Error not Warning.
---
 gas/ginsn.c                                    |  4 ++--
 gas/testsuite/gas/scfi/x86_64/ginsn-cofi-1.l   | 18 ++++++++++--------
 .../gas/scfi/x86_64/scfi-unsupported-cfg-1.l   |  2 +-
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/gas/ginsn.c b/gas/ginsn.c
index 5f6a67ce4f2..661f51d23c5 100644
--- a/gas/ginsn.c
+++ b/gas/ginsn.c
@@ -1161,8 +1161,8 @@ ginsn_data_end (const symbolS *label)
   /* Build the cfg of ginsn(s) of the function.  */
   if (!frchain_now->frch_ginsn_data->gcfg_apt_p)
     {
-      as_warn (_("Untraceable control flow for func '%s'; Skipping SCFI"),
-	       S_GET_NAME (func));
+      as_bad (_("untraceable control flow for func '%s'"),
+	      S_GET_NAME (func));
       goto end;
     }
 
diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-cofi-1.l b/gas/testsuite/gas/scfi/x86_64/ginsn-cofi-1.l
index fee76f9cc9b..ab6b50d47e8 100644
--- a/gas/testsuite/gas/scfi/x86_64/ginsn-cofi-1.l
+++ b/gas/testsuite/gas/scfi/x86_64/ginsn-cofi-1.l
@@ -1,3 +1,5 @@
+.*: Assembler messages:
+.*:20: Error: untraceable control flow for func 'foo'
 GAS LISTING .*
 
 
@@ -12,23 +14,23 @@ GAS LISTING .*
    8              	ginsn: SYM FUNC_BEGIN
    9              	foo:
    9              	ginsn: SYM foo
-  10 0000 4801D0   		addq    %rdx, %rax
+  10 \?\?\?\? 4801D0   		addq    %rdx, %rax
   10              	ginsn: ADD %r1, %r0, %r0
-  11 0003 E200     		loop    foo
+  11 \?\?\?\? E200     		loop    foo
   11              	ginsn: JCC 
-  12 0005 3EFFE0   		notrack jmp     \*%rax
+  12 \?\?\?\? 3EFFE0   		notrack jmp     \*%rax
   12              	ginsn: JMP %r0, 
-  13 0008 41FFD0   		call    \*%r8
+  13 \?\?\?\? 41FFD0   		call    \*%r8
   13              	ginsn: CALL
-  14 000b 67E305   		jecxz   .L179
+  14 \?\?\?\? 67E305   		jecxz   .L179
   14              	ginsn: JCC 
-  15 000e FF6730   		jmp     \*48\(%rdi\)
+  15 \?\?\?\? FF6730   		jmp     \*48\(%rdi\)
   15              	ginsn: JMP %r5, 
-  16 0011 7000     		jo      .L179
+  16 \?\?\?\? 7000     		jo      .L179
   16              	ginsn: JCC 
   17              	.L179:
   17              	ginsn: SYM .L179
-  18 0013 C3       		ret
+  18 \?\?\?\? C3       		ret
   18              	ginsn: RET
   19              	.LFE0:
   19              	ginsn: SYM .LFE0
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
index 1e138a102fe..c59ba93df45 100644
--- a/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-1.l
+++ b/gas/testsuite/gas/scfi/x86_64/scfi-unsupported-cfg-1.l
@@ -1,3 +1,3 @@
 .*Assembler messages:
 .*50: Warning: SCFI ignores most user-specified CFI directives
-.*52: Warning: Untraceable control flow for func 'foo'; Skipping SCFI
+.*52: Error: untraceable control flow for func 'foo'
-- 
2.43.0


  parent reply	other threads:[~2024-01-26  9:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26  9:19 [PATCH,V3 0/2] Testcase refactoring and fix PR gas/31284 Indu Bhagat
2024-01-26  9:19 ` [PATCH,V3 1/2] x86: testsuite: scfi: adjust COFI testcase Indu Bhagat
2024-01-26  9:19 ` Indu Bhagat [this message]
2024-01-26 11:57 ` [PATCH,V3 0/2] Testcase refactoring and fix PR gas/31284 Jan Beulich

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=20240126091917.3266816-3-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).