All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-20  7:25 ` Aditya Srivastava
  0 siblings, 0 replies; 32+ messages in thread
From: Aditya Srivastava @ 2021-01-20  7:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: yashsri421, lukas.bulwahn, dwaipayanray1, broonie, joe,
	linux-kernel-mentees, clang-built-linux

Local symbols prefixed with '.L' do not emit symbol table entries, as
they have special meaning for the assembler.

'.L' prefixed symbols can be used within a code region, but should be
avoided for denoting a range of code via 'SYM_*_START/END' annotations.

Add a new check to emit a warning on finding the usage of '.L' symbols
in '.S' files, if it lies within SYM_*_START/END annotation pair.

Suggested-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/lkml/20210112210154.GI4646@sirena.org.uk/
Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
---
 scripts/checkpatch.pl | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7030c4d6d126..858b5def61e9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2501,6 +2501,9 @@ sub process {
 
 	my $checklicenseline = 1;
 
+	# record SYM_*_START/END annotation pair count, for AVOID_L_PREFIX
+	my $sym_start_block = 0;
+
 	sanitise_line_reset();
 	my $line;
 	foreach my $rawline (@rawlines) {
@@ -3590,6 +3593,25 @@ sub process {
 			}
 		}
 
+# check for .L prefix local symbols in .S files
+		if ($realfile =~ /\.S$/) {
+			if ($line =~ /SYM_.*_START/ ||
+			    (defined $context_function && $context_function =~ /SYM_.*_START/)) {
+				$sym_start_block++;
+			}
+
+			if ($line=~ /\.L\S+/ &&		# line contains .L prefixed local symbol
+			    $sym_start_block > 0) {	# lies between SYM_*_START and SYM_*_END pair
+				WARN("AVOID_L_PREFIX",
+					"Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
+			}
+
+			if ($line =~ /SYM_.*_END/ ||
+			    (defined $context_function && $context_function =~ /SYM_.*_END/)) {
+				$sym_start_block--;
+			}
+		}
+
 # check we are in a valid source file C or perl if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2021-01-25 18:22 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20  7:25 [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files Aditya Srivastava
2021-01-20  7:25 ` [Linux-kernel-mentees] " Aditya Srivastava
2021-01-20  9:21 ` Joe Perches
2021-01-20  9:21   ` [Linux-kernel-mentees] " Joe Perches
2021-01-20 12:53   ` Aditya
2021-01-20 12:53     ` [Linux-kernel-mentees] " Aditya
2021-01-20 18:43     ` Joe Perches
2021-01-20 18:43       ` [Linux-kernel-mentees] " Joe Perches
2021-01-20 18:57       ` Nick Desaulniers
2021-01-20 18:57         ` [Linux-kernel-mentees] " Nick Desaulniers via Linux-kernel-mentees
2021-01-20 22:59         ` Josh Poimboeuf
2021-01-20 22:59           ` [Linux-kernel-mentees] " Josh Poimboeuf
2021-01-22 13:18       ` Aditya
2021-01-22 13:18         ` [Linux-kernel-mentees] " Aditya
2021-01-22 19:10         ` Joe Perches
2021-01-22 19:10           ` [Linux-kernel-mentees] " Joe Perches
2021-01-22 20:13           ` Aditya
2021-01-22 20:13             ` [Linux-kernel-mentees] " Aditya
2021-01-22 20:36             ` Fāng-ruì Sòng
2021-01-22 20:36               ` [Linux-kernel-mentees] " Fāng-ruì Sòng via Linux-kernel-mentees
2021-01-23 15:14             ` [PATCH v2] " Aditya Srivastava
2021-01-23 15:14               ` [Linux-kernel-mentees] " Aditya Srivastava
2021-01-23 17:21               ` Joe Perches
2021-01-23 17:21                 ` [Linux-kernel-mentees] " Joe Perches
2021-01-23 18:23                 ` Aditya
2021-01-23 18:23                   ` [Linux-kernel-mentees] " Aditya
2021-01-23 19:04                   ` [PATCH v3] " Aditya Srivastava
2021-01-23 19:04                     ` [Linux-kernel-mentees] " Aditya Srivastava
2021-01-23 21:01                     ` Joe Perches
2021-01-23 21:01                       ` [Linux-kernel-mentees] " Joe Perches
2021-01-25 18:15                       ` Nick Desaulniers
2021-01-25 18:15                         ` [Linux-kernel-mentees] " Nick Desaulniers via Linux-kernel-mentees

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.