diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-11-13 11:26:34 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-11-13 15:00:09 +0000 |
| commit | 12db6bb497226c7de224a55ec91f863f2a444439 (patch) | |
| tree | 7aaea1c57f8b80a719a462e67e4698ed8e8a6cf4 /tools | |
| parent | 4dfba277487a7023ab9f5783302da4a9b5e9bef8 (diff) | |
tools/syz-declextract: refine kernel file check
Some kernel build systems build some additional host files
that are not part of the kernel. Also check for -DKBUILD_BASENAME
define to filter them out.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/syz-declextract/run.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/syz-declextract/run.go b/tools/syz-declextract/run.go index 2feddfec8..e185d65fb 100644 --- a/tools/syz-declextract/run.go +++ b/tools/syz-declextract/run.go @@ -75,10 +75,7 @@ func main() { } for _, cmd := range cmds { - // Files compiled with gcc are not a part of the kernel - // (assuming compile commands were generated with make CC=clang). - // They are probably a part of some host tool. - if !strings.HasSuffix(cmd.File, ".c") || strings.HasPrefix(cmd.Command, "gcc") { + if !cmd.isKernel() { outputs <- nil continue } @@ -134,6 +131,18 @@ type compileCommand struct { File string } +// isKernel says if the command refers to a kernel object file +// rather than some host tools, etc. +func (cmd *compileCommand) isKernel() bool { + return strings.HasSuffix(cmd.File, ".c") && + // Files compiled with gcc are not a part of the kernel + // (assuming compile commands were generated with make CC=clang). + // They are probably a part of some host tool. + !strings.HasPrefix(cmd.Command, "gcc") && + // KBUILD should add this define all kernel files. + strings.Contains(cmd.Command, "-DKBUILD_BASENAME") +} + type output struct { file string output []byte |
