Message ID | 20210123190459.9701-1-yashsri421@gmail.com |
---|---|
State | Accepted |
Commit | de93245c00a44578ae73964b7e36607d04fed5b3 |
Headers | show |
Series |
|
Related | show |
On Sun, 2021-01-24 at 00:34 +0530, Aditya Srivastava wrote: > 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. > > 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> Acked-by: Joe Perches <joe@perches.com> > --- > * Applies perfectly on next-20210122 > > Changes in v3: > - Modify regex for SYM_*_START/END pair > - remove check for arch/x86/entry/* and arch/x86/lib/* > - change 'Link:' in commit message to lkml > - Modify commit description accordingly > > Changes in v2: > - Reduce the check to only SYM_*_START/END lines > - Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick > - Modify commit message > > scripts/checkpatch.pl | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 7030c4d6d126..4a03326c87b6 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -3590,6 +3590,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)$/); > >
On Sat, Jan 23, 2021 at 1:01 PM Joe Perches <joe@perches.com> wrote: > > On Sun, 2021-01-24 at 00:34 +0530, Aditya Srivastava wrote: > > 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. > > > > 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> > > Acked-by: Joe Perches <joe@perches.com> Acked-by: Nick Desaulniers <ndesaulniers@google.com> Thanks for the patch Aditya! > > > --- > > * Applies perfectly on next-20210122 > > > > Changes in v3: > > - Modify regex for SYM_*_START/END pair > > - remove check for arch/x86/entry/* and arch/x86/lib/* > > - change 'Link:' in commit message to lkml > > - Modify commit description accordingly > > > > Changes in v2: > > - Reduce the check to only SYM_*_START/END lines > > - Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick > > - Modify commit message > > > > scripts/checkpatch.pl | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > index 7030c4d6d126..4a03326c87b6 100755 > > --- a/scripts/checkpatch.pl > > +++ b/scripts/checkpatch.pl > > @@ -3590,6 +3590,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)$/); > > > > > >
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7030c4d6d126..4a03326c87b6 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3590,6 +3590,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)$/);
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. 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> --- * Applies perfectly on next-20210122 Changes in v3: - Modify regex for SYM_*_START/END pair - remove check for arch/x86/entry/* and arch/x86/lib/* - change 'Link:' in commit message to lkml - Modify commit description accordingly Changes in v2: - Reduce the check to only SYM_*_START/END lines - Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick - Modify commit message scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+)