[Linux-kernel-mentees] [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files

Dwaipayan Ray dwaipayanray1 at gmail.com
Sat Jan 16 12:43:32 UTC 2021


On Sat, Jan 16, 2021 at 5:52 PM Aditya Srivastava <yashsri421 at gmail.com> wrote:
>
> 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 warning on finding the usage of '.L' symbols
> in '.S' files.
>
> Suggested-by: Mark Brown <broonie at kernel.org>
> Link: https://lore.kernel.org/lkml/20210112210154.GI4646@sirena.org.uk/
> Signed-off-by: Aditya Srivastava <yashsri421 at gmail.com>
> ---
>  scripts/checkpatch.pl | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 7030c4d6d126..87d96a039e64 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3590,6 +3590,12 @@ sub process {
>                         }
>                 }
>
> +# check for .L prefix local symbols in .S files
> +               if ($realfile =~ /\.S$/ && $line =~ /\.L\S+/) {
> +                       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)$/);
>
> --
> 2.17.1

>From an earlier conversation:
>   So basically, you can use an .L symbol *inside* a function or a code
>   segment, you just can't use the .L symbol to contain the code using a
>   SYM_*_START/END annotation pair.

So this check warns on all uses of the .L prefix
I think that might be incorrect.

Thanks,
Dwaipayan.


More information about the Linux-kernel-mentees mailing list