diff options
author | Emese Revfy <re.emese@gmail.com> | 2016-05-23 18:09:38 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.com> | 2016-06-07 16:57:10 -0400 |
commit | 6b90bd4ba40b38dc13c2782469c1c77e4ed79915 (patch) | |
tree | 02d65b38b76e3543d33088ae9149010bae0290b0 /Makefile | |
parent | 24403874316a7180d367e51d7f7e25d5de1f78dd (diff) |
GCC plugin infrastructure
This patch allows to build the whole kernel with GCC plugins. It was ported from
grsecurity/PaX. The infrastructure supports building out-of-tree modules and
building in a separate directory. Cross-compilation is supported too.
Currently the x86, arm, arm64 and uml architectures enable plugins.
The directory of the gcc plugins is scripts/gcc-plugins. You can use a file or a directory
there. The plugins compile with these options:
* -fno-rtti: gcc is compiled with this option so the plugins must use it too
* -fno-exceptions: this is inherited from gcc too
* -fasynchronous-unwind-tables: this is inherited from gcc too
* -ggdb: it is useful for debugging a plugin (better backtrace on internal
errors)
* -Wno-narrowing: to suppress warnings from gcc headers (ipa-utils.h)
* -Wno-unused-variable: to suppress warnings from gcc headers (gcc_version
variable, plugin-version.h)
The infrastructure introduces a new Makefile target called gcc-plugins. It
supports all gcc versions from 4.5 to 6.0. The scripts/gcc-plugin.sh script
chooses the proper host compiler (gcc-4.7 can be built by either gcc or g++).
This script also checks the availability of the included headers in
scripts/gcc-plugins/gcc-common.h.
The gcc-common.h header contains frequently included headers for GCC plugins
and it has a compatibility layer for the supported gcc versions.
The gcc-generate-*-pass.h headers automatically generate the registration
structures for GIMPLE, SIMPLE_IPA, IPA and RTL passes.
Note that 'make clean' keeps the *.so files (only the distclean or mrproper
targets clean all) because they are needed for out-of-tree modules.
Based on work created by the PaX Team.
Signed-off-by: Emese Revfy <re.emese@gmail.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Michal Marek <mmarek@suse.com>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -552,7 +552,7 @@ ifeq ($(KBUILD_EXTMOD),) | |||
552 | # in parallel | 552 | # in parallel |
553 | PHONY += scripts | 553 | PHONY += scripts |
554 | scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \ | 554 | scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \ |
555 | asm-generic | 555 | asm-generic gcc-plugins |
556 | $(Q)$(MAKE) $(build)=$(@) | 556 | $(Q)$(MAKE) $(build)=$(@) |
557 | 557 | ||
558 | # Objects we will link into vmlinux / subdirs we need to visit | 558 | # Objects we will link into vmlinux / subdirs we need to visit |
@@ -631,6 +631,15 @@ endif | |||
631 | # Tell gcc to never replace conditional load with a non-conditional one | 631 | # Tell gcc to never replace conditional load with a non-conditional one |
632 | KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) | 632 | KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) |
633 | 633 | ||
634 | PHONY += gcc-plugins | ||
635 | gcc-plugins: scripts_basic | ||
636 | ifdef CONFIG_GCC_PLUGINS | ||
637 | $(Q)$(MAKE) $(build)=scripts/gcc-plugins | ||
638 | endif | ||
639 | @: | ||
640 | |||
641 | include scripts/Makefile.gcc-plugins | ||
642 | |||
634 | ifdef CONFIG_READABLE_ASM | 643 | ifdef CONFIG_READABLE_ASM |
635 | # Disable optimizations that make assembler listings hard to read. | 644 | # Disable optimizations that make assembler listings hard to read. |
636 | # reorder blocks reorders the control in the function | 645 | # reorder blocks reorders the control in the function |
@@ -1026,7 +1035,7 @@ prepare1: prepare2 $(version_h) include/generated/utsrelease.h \ | |||
1026 | 1035 | ||
1027 | archprepare: archheaders archscripts prepare1 scripts_basic | 1036 | archprepare: archheaders archscripts prepare1 scripts_basic |
1028 | 1037 | ||
1029 | prepare0: archprepare | 1038 | prepare0: archprepare gcc-plugins |
1030 | $(Q)$(MAKE) $(build)=. | 1039 | $(Q)$(MAKE) $(build)=. |
1031 | 1040 | ||
1032 | # All the preparing.. | 1041 | # All the preparing.. |
@@ -1507,6 +1516,7 @@ clean: $(clean-dirs) | |||
1507 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ | 1516 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ |
1508 | -o -name '*.symtypes' -o -name 'modules.order' \ | 1517 | -o -name '*.symtypes' -o -name 'modules.order' \ |
1509 | -o -name modules.builtin -o -name '.tmp_*.o.*' \ | 1518 | -o -name modules.builtin -o -name '.tmp_*.o.*' \ |
1519 | -o -name '*.c.[012]*.*' \ | ||
1510 | -o -name '*.gcno' \) -type f -print | xargs rm -f | 1520 | -o -name '*.gcno' \) -type f -print | xargs rm -f |
1511 | 1521 | ||
1512 | # Generate tags for editors | 1522 | # Generate tags for editors |