Skip to content

Commit

Permalink
checkpatch: add warning for avoiding .L prefix symbols in assembly files
Browse files Browse the repository at this point in the history
objtool requires that all code must be contained in an ELF symbol.  Symbol
names that have a '.L' prefix 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 for
'.S' files, if it denotes range of code via SYM_*_START/END annotation
pair.

Link: https://lkml.kernel.org/r/[email protected]
Link: https://lore.kernel.org/lkml/[email protected]
Signed-off-by: Aditya Srivastava <[email protected]>
Suggested-by: Mark Brown <[email protected]>
Acked-by: Joe Perches <[email protected]>
Acked-by: Nick Desaulniers <[email protected]>
Cc: Aditya Srivastava <[email protected]>
Cc: Lukas Bulwahn <[email protected]>
Cc: Dwaipayan Ray <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
AdityaSrivast authored and torvalds committed Feb 26, 2021
1 parent 0972b8b commit de93245
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3599,6 +3599,13 @@ sub process {
}
}

# check for .L prefix local symbols in .S files
if ($realfile =~ /\.S$/ &&
$line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
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);
}

# 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)$/);

Expand Down

0 comments on commit de93245

Please sign in to comment.