forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/gi…
…t/mmarek/kbuild Pull kbuild updates from Michal Marek: - GCC plugin support by Emese Revfy from grsecurity, with a fixup from Kees Cook. The plugins are meant to be used for static analysis of the kernel code. Two plugins are provided already. - reduction of the gcc commandline by Arnd Bergmann. - IS_ENABLED / IS_REACHABLE macro enhancements by Masahiro Yamada - bin2c fix by Michael Tautschnig - setlocalversion fix by Wolfram Sang * 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: gcc-plugins: disable under COMPILE_TEST kbuild: Abort build on bad stack protector flag scripts: Fix size mismatch of kexec_purgatory_size kbuild: make samples depend on headers_install Kbuild: don't add obj tree in additional includes Kbuild: arch: look for generated headers in obtree Kbuild: always prefix objtree in LINUXINCLUDE Kbuild: avoid duplicate include path Kbuild: don't add ../../ to include path vmlinux.lds.h: replace config_enabled() with IS_ENABLED() kconfig.h: allow to use IS_{ENABLE,REACHABLE} in macro expansion kconfig.h: use already defined macros for IS_REACHABLE() define export.h: use __is_defined() to check if __KSYM_* is defined kconfig.h: use __is_defined() to check if MODULE is defined kbuild: setlocalversion: print error to STDERR Add sancov plugin Add Cyclomatic complexity GCC plugin GCC plugin infrastructure Shared library support
- Loading branch information
Showing
43 changed files
with
2,252 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ modules.builtin | |
Module.symvers | ||
*.dwo | ||
*.su | ||
*.c.[012]*.* | ||
|
||
# | ||
# Top-level generic files | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
*.bc | ||
*.bin | ||
*.bz2 | ||
*.c.[012]*.* | ||
*.cis | ||
*.cpio | ||
*.csp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
GCC plugin infrastructure | ||
========================= | ||
|
||
|
||
1. Introduction | ||
=============== | ||
|
||
GCC plugins are loadable modules that provide extra features to the | ||
compiler [1]. They are useful for runtime instrumentation and static analysis. | ||
We can analyse, change and add further code during compilation via | ||
callbacks [2], GIMPLE [3], IPA [4] and RTL passes [5]. | ||
|
||
The GCC plugin infrastructure of the kernel supports all gcc versions from | ||
4.5 to 6.0, building out-of-tree modules, cross-compilation and building in a | ||
separate directory. | ||
Plugin source files have to be compilable by both a C and a C++ compiler as well | ||
because gcc versions 4.5 and 4.6 are compiled by a C compiler, | ||
gcc-4.7 can be compiled by a C or a C++ compiler, | ||
and versions 4.8+ can only be compiled by a C++ compiler. | ||
|
||
Currently the GCC plugin infrastructure supports only the x86, arm and arm64 | ||
architectures. | ||
|
||
This infrastructure was ported from grsecurity [6] and PaX [7]. | ||
|
||
-- | ||
[1] https://gcc.gnu.org/onlinedocs/gccint/Plugins.html | ||
[2] https://gcc.gnu.org/onlinedocs/gccint/Plugin-API.html#Plugin-API | ||
[3] https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html | ||
[4] https://gcc.gnu.org/onlinedocs/gccint/IPA.html | ||
[5] https://gcc.gnu.org/onlinedocs/gccint/RTL.html | ||
[6] https://grsecurity.net/ | ||
[7] https://pax.grsecurity.net/ | ||
|
||
|
||
2. Files | ||
======== | ||
|
||
$(src)/scripts/gcc-plugins | ||
This is the directory of the GCC plugins. | ||
|
||
$(src)/scripts/gcc-plugins/gcc-common.h | ||
This is a compatibility header for GCC plugins. | ||
It should be always included instead of individual gcc headers. | ||
|
||
$(src)/scripts/gcc-plugin.sh | ||
This script checks the availability of the included headers in | ||
gcc-common.h and chooses the proper host compiler to build the plugins | ||
(gcc-4.7 can be built by either gcc or g++). | ||
|
||
$(src)/scripts/gcc-plugins/gcc-generate-gimple-pass.h | ||
$(src)/scripts/gcc-plugins/gcc-generate-ipa-pass.h | ||
$(src)/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h | ||
$(src)/scripts/gcc-plugins/gcc-generate-rtl-pass.h | ||
These headers automatically generate the registration structures for | ||
GIMPLE, SIMPLE_IPA, IPA and RTL passes. They support all gcc versions | ||
from 4.5 to 6.0. | ||
They should be preferred to creating the structures by hand. | ||
|
||
|
||
3. Usage | ||
======== | ||
|
||
You must install the gcc plugin headers for your gcc version, | ||
e.g., on Ubuntu for gcc-4.9: | ||
|
||
apt-get install gcc-4.9-plugin-dev | ||
|
||
Enable a GCC plugin based feature in the kernel config: | ||
|
||
CONFIG_GCC_PLUGIN_CYC_COMPLEXITY = y | ||
|
||
To compile only the plugin(s): | ||
|
||
make gcc-plugins | ||
|
||
or just run the kernel make and compile the whole kernel with | ||
the cyclomatic complexity GCC plugin. | ||
|
||
|
||
4. How to add a new GCC plugin | ||
============================== | ||
|
||
The GCC plugins are in $(src)/scripts/gcc-plugins/. You can use a file or a directory | ||
here. It must be added to $(src)/scripts/gcc-plugins/Makefile, | ||
$(src)/scripts/Makefile.gcc-plugins and $(src)/arch/Kconfig. | ||
See the cyc_complexity_plugin.c (CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) GCC plugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5094,6 +5094,15 @@ L: [email protected] | |
S: Odd Fixes (e.g., new signatures) | ||
F: drivers/scsi/fdomain.* | ||
|
||
GCC PLUGINS | ||
M: Kees Cook <[email protected]> | ||
R: Emese Revfy <[email protected]> | ||
L: [email protected] | ||
S: Maintained | ||
F: scripts/gcc-plugins/ | ||
F: scripts/gcc-plugin.sh | ||
F: Documentation/gcc-plugins.txt | ||
|
||
GCOV BASED KERNEL PROFILING | ||
M: Peter Oberparleiter <[email protected]> | ||
S: Maintained | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,6 +357,43 @@ config SECCOMP_FILTER | |
|
||
See Documentation/prctl/seccomp_filter.txt for details. | ||
|
||
config HAVE_GCC_PLUGINS | ||
bool | ||
help | ||
An arch should select this symbol if it supports building with | ||
GCC plugins. | ||
|
||
menuconfig GCC_PLUGINS | ||
bool "GCC plugins" | ||
depends on HAVE_GCC_PLUGINS | ||
depends on !COMPILE_TEST | ||
help | ||
GCC plugins are loadable modules that provide extra features to the | ||
compiler. They are useful for runtime instrumentation and static analysis. | ||
|
||
See Documentation/gcc-plugins.txt for details. | ||
|
||
config GCC_PLUGIN_CYC_COMPLEXITY | ||
bool "Compute the cyclomatic complexity of a function" | ||
depends on GCC_PLUGINS | ||
help | ||
The complexity M of a function's control flow graph is defined as: | ||
M = E - N + 2P | ||
where | ||
|
||
E = the number of edges | ||
N = the number of nodes | ||
P = the number of connected components (exit nodes). | ||
|
||
config GCC_PLUGIN_SANCOV | ||
bool | ||
depends on GCC_PLUGINS | ||
help | ||
This plugin inserts a __sanitizer_cov_trace_pc() call at the start of | ||
basic blocks. It supports all gcc versions with plugin support (from | ||
gcc-4.5 on). It is based on the commit "Add fuzzing coverage support" | ||
by Dmitry Vyukov <[email protected]>. | ||
|
||
config HAVE_CC_STACKPROTECTOR | ||
bool | ||
help | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.