Skip to content

Commit 6b90bd4

Browse files
ephox-gcc-pluginsMichal Marek
authored and
Michal Marek
committedJun 7, 2016
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 <[email protected]> Acked-by: Kees Cook <[email protected]> Signed-off-by: Michal Marek <[email protected]>
1 parent 2440387 commit 6b90bd4

22 files changed

+1872
-5
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ modules.builtin
3737
Module.symvers
3838
*.dwo
3939
*.su
40+
*.c.[012]*.*
4041

4142
#
4243
# Top-level generic files

‎Documentation/dontdiff

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*.bc
44
*.bin
55
*.bz2
6+
*.c.[012]*.*
67
*.cis
78
*.cpio
89
*.csp

‎Documentation/gcc-plugins.txt

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
GCC plugin infrastructure
2+
=========================
3+
4+
5+
1. Introduction
6+
===============
7+
8+
GCC plugins are loadable modules that provide extra features to the
9+
compiler [1]. They are useful for runtime instrumentation and static analysis.
10+
We can analyse, change and add further code during compilation via
11+
callbacks [2], GIMPLE [3], IPA [4] and RTL passes [5].
12+
13+
The GCC plugin infrastructure of the kernel supports all gcc versions from
14+
4.5 to 6.0, building out-of-tree modules, cross-compilation and building in a
15+
separate directory.
16+
Plugin source files have to be compilable by both a C and a C++ compiler as well
17+
because gcc versions 4.5 and 4.6 are compiled by a C compiler,
18+
gcc-4.7 can be compiled by a C or a C++ compiler,
19+
and versions 4.8+ can only be compiled by a C++ compiler.
20+
21+
Currently the GCC plugin infrastructure supports only the x86, arm and arm64
22+
architectures.
23+
24+
This infrastructure was ported from grsecurity [6] and PaX [7].
25+
26+
--
27+
[1] https://gcc.gnu.org/onlinedocs/gccint/Plugins.html
28+
[2] https://gcc.gnu.org/onlinedocs/gccint/Plugin-API.html#Plugin-API
29+
[3] https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html
30+
[4] https://gcc.gnu.org/onlinedocs/gccint/IPA.html
31+
[5] https://gcc.gnu.org/onlinedocs/gccint/RTL.html
32+
[6] https://grsecurity.net/
33+
[7] https://pax.grsecurity.net/
34+
35+
36+
2. Files
37+
========
38+
39+
$(src)/scripts/gcc-plugins
40+
This is the directory of the GCC plugins.
41+
42+
$(src)/scripts/gcc-plugins/gcc-common.h
43+
This is a compatibility header for GCC plugins.
44+
It should be always included instead of individual gcc headers.
45+
46+
$(src)/scripts/gcc-plugin.sh
47+
This script checks the availability of the included headers in
48+
gcc-common.h and chooses the proper host compiler to build the plugins
49+
(gcc-4.7 can be built by either gcc or g++).
50+
51+
$(src)/scripts/gcc-plugins/gcc-generate-gimple-pass.h
52+
$(src)/scripts/gcc-plugins/gcc-generate-ipa-pass.h
53+
$(src)/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h
54+
$(src)/scripts/gcc-plugins/gcc-generate-rtl-pass.h
55+
These headers automatically generate the registration structures for
56+
GIMPLE, SIMPLE_IPA, IPA and RTL passes. They support all gcc versions
57+
from 4.5 to 6.0.
58+
They should be preferred to creating the structures by hand.
59+
60+
61+
3. Usage
62+
========
63+
64+
You must install the gcc plugin headers for your gcc version,
65+
e.g., on Ubuntu for gcc-4.9:
66+
67+
apt-get install gcc-4.9-plugin-dev
68+
69+
Enable a GCC plugin based feature in the kernel config:
70+
71+
CONFIG_GCC_PLUGIN_CYC_COMPLEXITY = y
72+
73+
To compile only the plugin(s):
74+
75+
make gcc-plugins
76+
77+
or just run the kernel make and compile the whole kernel with
78+
the cyclomatic complexity GCC plugin.
79+
80+
81+
4. How to add a new GCC plugin
82+
==============================
83+
84+
The GCC plugins are in $(src)/scripts/gcc-plugins/. You can use a file or a directory
85+
here. It must be added to $(src)/scripts/gcc-plugins/Makefile,
86+
$(src)/scripts/Makefile.gcc-plugins and $(src)/arch/Kconfig.
87+
See the cyc_complexity_plugin.c (CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) GCC plugin.

‎MAINTAINERS

+9
Original file line numberDiff line numberDiff line change
@@ -4979,6 +4979,15 @@ L: linux-scsi@vger.kernel.org
49794979
S: Odd Fixes (e.g., new signatures)
49804980
F: drivers/scsi/fdomain.*
49814981

4982+
GCC PLUGINS
4983+
M: Kees Cook <keescook@chromium.org>
4984+
R: Emese Revfy <re.emese@gmail.com>
4985+
L: kernel-hardening@lists.openwall.com
4986+
S: Maintained
4987+
F: scripts/gcc-plugins/
4988+
F: scripts/gcc-plugin.sh
4989+
F: Documentation/gcc-plugins.txt
4990+
49824991
GCOV BASED KERNEL PROFILING
49834992
M: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
49844993
S: Maintained

‎Makefile

+12-2
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ ifeq ($(KBUILD_EXTMOD),)
552552
# in parallel
553553
PHONY += scripts
554554
scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \
555-
asm-generic
555+
asm-generic gcc-plugins
556556
$(Q)$(MAKE) $(build)=$(@)
557557

558558
# Objects we will link into vmlinux / subdirs we need to visit
@@ -631,6 +631,15 @@ endif
631631
# Tell gcc to never replace conditional load with a non-conditional one
632632
KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
633633

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+
634643
ifdef CONFIG_READABLE_ASM
635644
# Disable optimizations that make assembler listings hard to read.
636645
# reorder blocks reorders the control in the function
@@ -1026,7 +1035,7 @@ prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
10261035

10271036
archprepare: archheaders archscripts prepare1 scripts_basic
10281037

1029-
prepare0: archprepare
1038+
prepare0: archprepare gcc-plugins
10301039
$(Q)$(MAKE) $(build)=.
10311040

10321041
# All the preparing..
@@ -1507,6 +1516,7 @@ clean: $(clean-dirs)
15071516
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
15081517
-o -name '*.symtypes' -o -name 'modules.order' \
15091518
-o -name modules.builtin -o -name '.tmp_*.o.*' \
1519+
-o -name '*.c.[012]*.*' \
15101520
-o -name '*.gcno' \) -type f -print | xargs rm -f
15111521

15121522
# Generate tags for editors

‎arch/Kconfig

+15
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,21 @@ config SECCOMP_FILTER
357357

358358
See Documentation/prctl/seccomp_filter.txt for details.
359359

360+
config HAVE_GCC_PLUGINS
361+
bool
362+
help
363+
An arch should select this symbol if it supports building with
364+
GCC plugins.
365+
366+
menuconfig GCC_PLUGINS
367+
bool "GCC plugins"
368+
depends on HAVE_GCC_PLUGINS
369+
help
370+
GCC plugins are loadable modules that provide extra features to the
371+
compiler. They are useful for runtime instrumentation and static analysis.
372+
373+
See Documentation/gcc-plugins.txt for details.
374+
360375
config HAVE_CC_STACKPROTECTOR
361376
bool
362377
help

‎arch/arm/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ config ARM
5454
select HAVE_FTRACE_MCOUNT_RECORD if (!XIP_KERNEL)
5555
select HAVE_FUNCTION_GRAPH_TRACER if (!THUMB2_KERNEL)
5656
select HAVE_FUNCTION_TRACER if (!XIP_KERNEL)
57+
select HAVE_GCC_PLUGINS
5758
select HAVE_GENERIC_DMA_COHERENT
5859
select HAVE_HW_BREAKPOINT if (PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7))
5960
select HAVE_IDE if PCI || ISA || PCMCIA

‎arch/arm64/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ config ARM64
7676
select HAVE_FTRACE_MCOUNT_RECORD
7777
select HAVE_FUNCTION_TRACER
7878
select HAVE_FUNCTION_GRAPH_TRACER
79+
select HAVE_GCC_PLUGINS
7980
select HAVE_GENERIC_DMA_COHERENT
8081
select HAVE_HW_BREAKPOINT if PERF_EVENTS
8182
select HAVE_IRQ_TIME_ACCOUNTING

‎arch/um/Kconfig.common

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ config UML
99
select GENERIC_CPU_DEVICES
1010
select GENERIC_IO
1111
select GENERIC_CLOCKEVENTS
12+
select HAVE_GCC_PLUGINS
1213
select TTY # Needed for line.c
1314

1415
config MMU

‎arch/x86/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ config X86
111111
select HAVE_FUNCTION_GRAPH_FP_TEST
112112
select HAVE_FUNCTION_GRAPH_TRACER
113113
select HAVE_FUNCTION_TRACER
114+
select HAVE_GCC_PLUGINS
114115
select HAVE_GENERIC_DMA_COHERENT if X86_32
115116
select HAVE_HW_BREAKPOINT
116117
select HAVE_IDE

‎arch/x86/entry/vdso/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
7575
-fno-omit-frame-pointer -foptimize-sibling-calls \
7676
-DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
7777

78-
$(vobjs): KBUILD_CFLAGS += $(CFL)
78+
$(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) $(CFL)
7979

8080
#
8181
# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
@@ -145,6 +145,7 @@ KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
145145
KBUILD_CFLAGS_32 := $(filter-out -mcmodel=kernel,$(KBUILD_CFLAGS_32))
146146
KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32))
147147
KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KBUILD_CFLAGS_32))
148+
KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32))
148149
KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic
149150
KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector)
150151
KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)

‎scripts/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ subdir-$(CONFIG_DTC) += dtc
4747
subdir-$(CONFIG_GDB_SCRIPTS) += gdb
4848

4949
# Let clean descend into subdirs
50-
subdir- += basic kconfig package
50+
subdir- += basic kconfig package gcc-plugins

‎scripts/Makefile.gcc-plugins

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ifdef CONFIG_GCC_PLUGINS
2+
__PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC))
3+
PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)")
4+
5+
GCC_PLUGINS_CFLAGS := $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y))
6+
7+
export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN
8+
9+
ifeq ($(PLUGINCC),)
10+
ifneq ($(GCC_PLUGINS_CFLAGS),)
11+
ifeq ($(call cc-ifversion, -ge, 0405, y), y)
12+
PLUGINCC := $(shell $(CONFIG_SHELL) -x $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)")
13+
$(warning warning: your gcc installation does not support plugins, perhaps the necessary headers are missing?)
14+
else
15+
$(warning warning: your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least)
16+
endif
17+
endif
18+
endif
19+
20+
KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
21+
GCC_PLUGIN := $(gcc-plugin-y)
22+
23+
endif

‎scripts/gcc-plugin.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/sh
2+
srctree=$(dirname "$0")
3+
gccplugins_dir=$($3 -print-file-name=plugin)
4+
plugincc=$($1 -E -x c++ - -o /dev/null -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <<EOF
5+
#include "gcc-common.h"
6+
#if BUILDING_GCC_VERSION >= 4008 || defined(ENABLE_BUILD_WITH_CXX)
7+
#warning $2 CXX
8+
#else
9+
#warning $1 CC
10+
#endif
11+
EOF
12+
)
13+
14+
if [ $? -ne 0 ]
15+
then
16+
exit 1
17+
fi
18+
19+
case "$plugincc" in
20+
*"$1 CC"*)
21+
echo "$1"
22+
exit 0
23+
;;
24+
25+
*"$2 CXX"*)
26+
# the c++ compiler needs another test, see below
27+
;;
28+
29+
*)
30+
exit 1
31+
;;
32+
esac
33+
34+
# we need a c++ compiler that supports the designated initializer GNU extension
35+
plugincc=$($2 -c -x c++ -std=gnu++98 - -fsyntax-only -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <<EOF
36+
#include "gcc-common.h"
37+
class test {
38+
public:
39+
int test;
40+
} test = {
41+
.test = 1
42+
};
43+
EOF
44+
)
45+
46+
if [ $? -eq 0 ]
47+
then
48+
echo "$2"
49+
exit 0
50+
fi
51+
exit 1

‎scripts/gcc-plugins/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
2+
3+
ifeq ($(PLUGINCC),$(HOSTCC))
4+
HOSTLIBS := hostlibs
5+
HOST_EXTRACFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu99 -ggdb
6+
export HOST_EXTRACFLAGS
7+
else
8+
HOSTLIBS := hostcxxlibs
9+
HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti
10+
HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb
11+
HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable
12+
export HOST_EXTRACXXFLAGS
13+
endif
14+
15+
export GCCPLUGINS_DIR HOSTLIBS
16+
17+
$(HOSTLIBS)-y := $(GCC_PLUGIN)
18+
always := $($(HOSTLIBS)-y)
19+
20+
clean-files += *.so

‎scripts/gcc-plugins/gcc-common.h

+830
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/*
2+
* Generator for GIMPLE pass related boilerplate code/data
3+
*
4+
* Supports gcc 4.5-6
5+
*
6+
* Usage:
7+
*
8+
* 1. before inclusion define PASS_NAME
9+
* 2. before inclusion define NO_* for unimplemented callbacks
10+
* NO_GATE
11+
* NO_EXECUTE
12+
* 3. before inclusion define PROPERTIES_* and TODO_FLAGS_* to override
13+
* the default 0 values
14+
* 4. for convenience, all the above will be undefined after inclusion!
15+
* 5. the only exported name is make_PASS_NAME_pass() to register with gcc
16+
*/
17+
18+
#ifndef PASS_NAME
19+
#error at least PASS_NAME must be defined
20+
#else
21+
#define __GCC_PLUGIN_STRINGIFY(n) #n
22+
#define _GCC_PLUGIN_STRINGIFY(n) __GCC_PLUGIN_STRINGIFY(n)
23+
#define _GCC_PLUGIN_CONCAT2(x, y) x ## y
24+
#define _GCC_PLUGIN_CONCAT3(x, y, z) x ## y ## z
25+
26+
#define __PASS_NAME_PASS_DATA(n) _GCC_PLUGIN_CONCAT2(n, _pass_data)
27+
#define _PASS_NAME_PASS_DATA __PASS_NAME_PASS_DATA(PASS_NAME)
28+
29+
#define __PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT2(n, _pass)
30+
#define _PASS_NAME_PASS __PASS_NAME_PASS(PASS_NAME)
31+
32+
#define _PASS_NAME_NAME _GCC_PLUGIN_STRINGIFY(PASS_NAME)
33+
34+
#define __MAKE_PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT3(make_, n, _pass)
35+
#define _MAKE_PASS_NAME_PASS __MAKE_PASS_NAME_PASS(PASS_NAME)
36+
37+
#ifdef NO_GATE
38+
#define _GATE NULL
39+
#define _HAS_GATE false
40+
#else
41+
#define __GATE(n) _GCC_PLUGIN_CONCAT2(n, _gate)
42+
#define _GATE __GATE(PASS_NAME)
43+
#define _HAS_GATE true
44+
#endif
45+
46+
#ifdef NO_EXECUTE
47+
#define _EXECUTE NULL
48+
#define _HAS_EXECUTE false
49+
#else
50+
#define __EXECUTE(n) _GCC_PLUGIN_CONCAT2(n, _execute)
51+
#define _EXECUTE __EXECUTE(PASS_NAME)
52+
#define _HAS_EXECUTE true
53+
#endif
54+
55+
#ifndef PROPERTIES_REQUIRED
56+
#define PROPERTIES_REQUIRED 0
57+
#endif
58+
59+
#ifndef PROPERTIES_PROVIDED
60+
#define PROPERTIES_PROVIDED 0
61+
#endif
62+
63+
#ifndef PROPERTIES_DESTROYED
64+
#define PROPERTIES_DESTROYED 0
65+
#endif
66+
67+
#ifndef TODO_FLAGS_START
68+
#define TODO_FLAGS_START 0
69+
#endif
70+
71+
#ifndef TODO_FLAGS_FINISH
72+
#define TODO_FLAGS_FINISH 0
73+
#endif
74+
75+
#if BUILDING_GCC_VERSION >= 4009
76+
namespace {
77+
static const pass_data _PASS_NAME_PASS_DATA = {
78+
#else
79+
static struct gimple_opt_pass _PASS_NAME_PASS = {
80+
.pass = {
81+
#endif
82+
.type = GIMPLE_PASS,
83+
.name = _PASS_NAME_NAME,
84+
#if BUILDING_GCC_VERSION >= 4008
85+
.optinfo_flags = OPTGROUP_NONE,
86+
#endif
87+
#if BUILDING_GCC_VERSION >= 5000
88+
#elif BUILDING_GCC_VERSION == 4009
89+
.has_gate = _HAS_GATE,
90+
.has_execute = _HAS_EXECUTE,
91+
#else
92+
.gate = _GATE,
93+
.execute = _EXECUTE,
94+
.sub = NULL,
95+
.next = NULL,
96+
.static_pass_number = 0,
97+
#endif
98+
.tv_id = TV_NONE,
99+
.properties_required = PROPERTIES_REQUIRED,
100+
.properties_provided = PROPERTIES_PROVIDED,
101+
.properties_destroyed = PROPERTIES_DESTROYED,
102+
.todo_flags_start = TODO_FLAGS_START,
103+
.todo_flags_finish = TODO_FLAGS_FINISH,
104+
#if BUILDING_GCC_VERSION < 4009
105+
}
106+
#endif
107+
};
108+
109+
#if BUILDING_GCC_VERSION >= 4009
110+
class _PASS_NAME_PASS : public gimple_opt_pass {
111+
public:
112+
_PASS_NAME_PASS() : gimple_opt_pass(_PASS_NAME_PASS_DATA, g) {}
113+
114+
#ifndef NO_GATE
115+
#if BUILDING_GCC_VERSION >= 5000
116+
virtual bool gate(function *) { return _GATE(); }
117+
#else
118+
virtual bool gate(void) { return _GATE(); }
119+
#endif
120+
#endif
121+
122+
virtual opt_pass * clone () { return new _PASS_NAME_PASS(); }
123+
124+
#ifndef NO_EXECUTE
125+
#if BUILDING_GCC_VERSION >= 5000
126+
virtual unsigned int execute(function *) { return _EXECUTE(); }
127+
#else
128+
virtual unsigned int execute(void) { return _EXECUTE(); }
129+
#endif
130+
#endif
131+
};
132+
}
133+
134+
opt_pass *_MAKE_PASS_NAME_PASS(void)
135+
{
136+
return new _PASS_NAME_PASS();
137+
}
138+
#else
139+
struct opt_pass *_MAKE_PASS_NAME_PASS(void)
140+
{
141+
return &_PASS_NAME_PASS.pass;
142+
}
143+
#endif
144+
145+
/* clean up user provided defines */
146+
#undef PASS_NAME
147+
#undef NO_GATE
148+
#undef NO_EXECUTE
149+
150+
#undef PROPERTIES_DESTROYED
151+
#undef PROPERTIES_PROVIDED
152+
#undef PROPERTIES_REQUIRED
153+
#undef TODO_FLAGS_FINISH
154+
#undef TODO_FLAGS_START
155+
156+
/* clean up generated defines */
157+
#undef _EXECUTE
158+
#undef __EXECUTE
159+
#undef _GATE
160+
#undef __GATE
161+
#undef _GCC_PLUGIN_CONCAT2
162+
#undef _GCC_PLUGIN_CONCAT3
163+
#undef _GCC_PLUGIN_STRINGIFY
164+
#undef __GCC_PLUGIN_STRINGIFY
165+
#undef _HAS_EXECUTE
166+
#undef _HAS_GATE
167+
#undef _MAKE_PASS_NAME_PASS
168+
#undef __MAKE_PASS_NAME_PASS
169+
#undef _PASS_NAME_NAME
170+
#undef _PASS_NAME_PASS
171+
#undef __PASS_NAME_PASS
172+
#undef _PASS_NAME_PASS_DATA
173+
#undef __PASS_NAME_PASS_DATA
174+
175+
#endif /* PASS_NAME */
+289
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
/*
2+
* Generator for IPA pass related boilerplate code/data
3+
*
4+
* Supports gcc 4.5-6
5+
*
6+
* Usage:
7+
*
8+
* 1. before inclusion define PASS_NAME
9+
* 2. before inclusion define NO_* for unimplemented callbacks
10+
* NO_GENERATE_SUMMARY
11+
* NO_READ_SUMMARY
12+
* NO_WRITE_SUMMARY
13+
* NO_READ_OPTIMIZATION_SUMMARY
14+
* NO_WRITE_OPTIMIZATION_SUMMARY
15+
* NO_STMT_FIXUP
16+
* NO_FUNCTION_TRANSFORM
17+
* NO_VARIABLE_TRANSFORM
18+
* NO_GATE
19+
* NO_EXECUTE
20+
* 3. before inclusion define PROPERTIES_* and *TODO_FLAGS_* to override
21+
* the default 0 values
22+
* 4. for convenience, all the above will be undefined after inclusion!
23+
* 5. the only exported name is make_PASS_NAME_pass() to register with gcc
24+
*/
25+
26+
#ifndef PASS_NAME
27+
#error at least PASS_NAME must be defined
28+
#else
29+
#define __GCC_PLUGIN_STRINGIFY(n) #n
30+
#define _GCC_PLUGIN_STRINGIFY(n) __GCC_PLUGIN_STRINGIFY(n)
31+
#define _GCC_PLUGIN_CONCAT2(x, y) x ## y
32+
#define _GCC_PLUGIN_CONCAT3(x, y, z) x ## y ## z
33+
34+
#define __PASS_NAME_PASS_DATA(n) _GCC_PLUGIN_CONCAT2(n, _pass_data)
35+
#define _PASS_NAME_PASS_DATA __PASS_NAME_PASS_DATA(PASS_NAME)
36+
37+
#define __PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT2(n, _pass)
38+
#define _PASS_NAME_PASS __PASS_NAME_PASS(PASS_NAME)
39+
40+
#define _PASS_NAME_NAME _GCC_PLUGIN_STRINGIFY(PASS_NAME)
41+
42+
#define __MAKE_PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT3(make_, n, _pass)
43+
#define _MAKE_PASS_NAME_PASS __MAKE_PASS_NAME_PASS(PASS_NAME)
44+
45+
#ifdef NO_GENERATE_SUMMARY
46+
#define _GENERATE_SUMMARY NULL
47+
#else
48+
#define __GENERATE_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _generate_summary)
49+
#define _GENERATE_SUMMARY __GENERATE_SUMMARY(PASS_NAME)
50+
#endif
51+
52+
#ifdef NO_READ_SUMMARY
53+
#define _READ_SUMMARY NULL
54+
#else
55+
#define __READ_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _read_summary)
56+
#define _READ_SUMMARY __READ_SUMMARY(PASS_NAME)
57+
#endif
58+
59+
#ifdef NO_WRITE_SUMMARY
60+
#define _WRITE_SUMMARY NULL
61+
#else
62+
#define __WRITE_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _write_summary)
63+
#define _WRITE_SUMMARY __WRITE_SUMMARY(PASS_NAME)
64+
#endif
65+
66+
#ifdef NO_READ_OPTIMIZATION_SUMMARY
67+
#define _READ_OPTIMIZATION_SUMMARY NULL
68+
#else
69+
#define __READ_OPTIMIZATION_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _read_optimization_summary)
70+
#define _READ_OPTIMIZATION_SUMMARY __READ_OPTIMIZATION_SUMMARY(PASS_NAME)
71+
#endif
72+
73+
#ifdef NO_WRITE_OPTIMIZATION_SUMMARY
74+
#define _WRITE_OPTIMIZATION_SUMMARY NULL
75+
#else
76+
#define __WRITE_OPTIMIZATION_SUMMARY(n) _GCC_PLUGIN_CONCAT2(n, _write_optimization_summary)
77+
#define _WRITE_OPTIMIZATION_SUMMARY __WRITE_OPTIMIZATION_SUMMARY(PASS_NAME)
78+
#endif
79+
80+
#ifdef NO_STMT_FIXUP
81+
#define _STMT_FIXUP NULL
82+
#else
83+
#define __STMT_FIXUP(n) _GCC_PLUGIN_CONCAT2(n, _stmt_fixup)
84+
#define _STMT_FIXUP __STMT_FIXUP(PASS_NAME)
85+
#endif
86+
87+
#ifdef NO_FUNCTION_TRANSFORM
88+
#define _FUNCTION_TRANSFORM NULL
89+
#else
90+
#define __FUNCTION_TRANSFORM(n) _GCC_PLUGIN_CONCAT2(n, _function_transform)
91+
#define _FUNCTION_TRANSFORM __FUNCTION_TRANSFORM(PASS_NAME)
92+
#endif
93+
94+
#ifdef NO_VARIABLE_TRANSFORM
95+
#define _VARIABLE_TRANSFORM NULL
96+
#else
97+
#define __VARIABLE_TRANSFORM(n) _GCC_PLUGIN_CONCAT2(n, _variable_transform)
98+
#define _VARIABLE_TRANSFORM __VARIABLE_TRANSFORM(PASS_NAME)
99+
#endif
100+
101+
#ifdef NO_GATE
102+
#define _GATE NULL
103+
#define _HAS_GATE false
104+
#else
105+
#define __GATE(n) _GCC_PLUGIN_CONCAT2(n, _gate)
106+
#define _GATE __GATE(PASS_NAME)
107+
#define _HAS_GATE true
108+
#endif
109+
110+
#ifdef NO_EXECUTE
111+
#define _EXECUTE NULL
112+
#define _HAS_EXECUTE false
113+
#else
114+
#define __EXECUTE(n) _GCC_PLUGIN_CONCAT2(n, _execute)
115+
#define _EXECUTE __EXECUTE(PASS_NAME)
116+
#define _HAS_EXECUTE true
117+
#endif
118+
119+
#ifndef PROPERTIES_REQUIRED
120+
#define PROPERTIES_REQUIRED 0
121+
#endif
122+
123+
#ifndef PROPERTIES_PROVIDED
124+
#define PROPERTIES_PROVIDED 0
125+
#endif
126+
127+
#ifndef PROPERTIES_DESTROYED
128+
#define PROPERTIES_DESTROYED 0
129+
#endif
130+
131+
#ifndef TODO_FLAGS_START
132+
#define TODO_FLAGS_START 0
133+
#endif
134+
135+
#ifndef TODO_FLAGS_FINISH
136+
#define TODO_FLAGS_FINISH 0
137+
#endif
138+
139+
#ifndef FUNCTION_TRANSFORM_TODO_FLAGS_START
140+
#define FUNCTION_TRANSFORM_TODO_FLAGS_START 0
141+
#endif
142+
143+
#if BUILDING_GCC_VERSION >= 4009
144+
namespace {
145+
static const pass_data _PASS_NAME_PASS_DATA = {
146+
#else
147+
static struct ipa_opt_pass_d _PASS_NAME_PASS = {
148+
.pass = {
149+
#endif
150+
.type = IPA_PASS,
151+
.name = _PASS_NAME_NAME,
152+
#if BUILDING_GCC_VERSION >= 4008
153+
.optinfo_flags = OPTGROUP_NONE,
154+
#endif
155+
#if BUILDING_GCC_VERSION >= 5000
156+
#elif BUILDING_GCC_VERSION == 4009
157+
.has_gate = _HAS_GATE,
158+
.has_execute = _HAS_EXECUTE,
159+
#else
160+
.gate = _GATE,
161+
.execute = _EXECUTE,
162+
.sub = NULL,
163+
.next = NULL,
164+
.static_pass_number = 0,
165+
#endif
166+
.tv_id = TV_NONE,
167+
.properties_required = PROPERTIES_REQUIRED,
168+
.properties_provided = PROPERTIES_PROVIDED,
169+
.properties_destroyed = PROPERTIES_DESTROYED,
170+
.todo_flags_start = TODO_FLAGS_START,
171+
.todo_flags_finish = TODO_FLAGS_FINISH,
172+
#if BUILDING_GCC_VERSION < 4009
173+
},
174+
.generate_summary = _GENERATE_SUMMARY,
175+
.write_summary = _WRITE_SUMMARY,
176+
.read_summary = _READ_SUMMARY,
177+
#if BUILDING_GCC_VERSION >= 4006
178+
.write_optimization_summary = _WRITE_OPTIMIZATION_SUMMARY,
179+
.read_optimization_summary = _READ_OPTIMIZATION_SUMMARY,
180+
#endif
181+
.stmt_fixup = _STMT_FIXUP,
182+
.function_transform_todo_flags_start = FUNCTION_TRANSFORM_TODO_FLAGS_START,
183+
.function_transform = _FUNCTION_TRANSFORM,
184+
.variable_transform = _VARIABLE_TRANSFORM,
185+
#endif
186+
};
187+
188+
#if BUILDING_GCC_VERSION >= 4009
189+
class _PASS_NAME_PASS : public ipa_opt_pass_d {
190+
public:
191+
_PASS_NAME_PASS() : ipa_opt_pass_d(_PASS_NAME_PASS_DATA,
192+
g,
193+
_GENERATE_SUMMARY,
194+
_WRITE_SUMMARY,
195+
_READ_SUMMARY,
196+
_WRITE_OPTIMIZATION_SUMMARY,
197+
_READ_OPTIMIZATION_SUMMARY,
198+
_STMT_FIXUP,
199+
FUNCTION_TRANSFORM_TODO_FLAGS_START,
200+
_FUNCTION_TRANSFORM,
201+
_VARIABLE_TRANSFORM) {}
202+
203+
#ifndef NO_GATE
204+
#if BUILDING_GCC_VERSION >= 5000
205+
virtual bool gate(function *) { return _GATE(); }
206+
#else
207+
virtual bool gate(void) { return _GATE(); }
208+
#endif
209+
#endif
210+
211+
virtual opt_pass *clone() { return new _PASS_NAME_PASS(); }
212+
213+
#ifndef NO_EXECUTE
214+
#if BUILDING_GCC_VERSION >= 5000
215+
virtual unsigned int execute(function *) { return _EXECUTE(); }
216+
#else
217+
virtual unsigned int execute(void) { return _EXECUTE(); }
218+
#endif
219+
#endif
220+
};
221+
}
222+
223+
opt_pass *_MAKE_PASS_NAME_PASS(void)
224+
{
225+
return new _PASS_NAME_PASS();
226+
}
227+
#else
228+
struct opt_pass *_MAKE_PASS_NAME_PASS(void)
229+
{
230+
return &_PASS_NAME_PASS.pass;
231+
}
232+
#endif
233+
234+
/* clean up user provided defines */
235+
#undef PASS_NAME
236+
#undef NO_GENERATE_SUMMARY
237+
#undef NO_WRITE_SUMMARY
238+
#undef NO_READ_SUMMARY
239+
#undef NO_WRITE_OPTIMIZATION_SUMMARY
240+
#undef NO_READ_OPTIMIZATION_SUMMARY
241+
#undef NO_STMT_FIXUP
242+
#undef NO_FUNCTION_TRANSFORM
243+
#undef NO_VARIABLE_TRANSFORM
244+
#undef NO_GATE
245+
#undef NO_EXECUTE
246+
247+
#undef FUNCTION_TRANSFORM_TODO_FLAGS_START
248+
#undef PROPERTIES_DESTROYED
249+
#undef PROPERTIES_PROVIDED
250+
#undef PROPERTIES_REQUIRED
251+
#undef TODO_FLAGS_FINISH
252+
#undef TODO_FLAGS_START
253+
254+
/* clean up generated defines */
255+
#undef _EXECUTE
256+
#undef __EXECUTE
257+
#undef _FUNCTION_TRANSFORM
258+
#undef __FUNCTION_TRANSFORM
259+
#undef _GATE
260+
#undef __GATE
261+
#undef _GCC_PLUGIN_CONCAT2
262+
#undef _GCC_PLUGIN_CONCAT3
263+
#undef _GCC_PLUGIN_STRINGIFY
264+
#undef __GCC_PLUGIN_STRINGIFY
265+
#undef _GENERATE_SUMMARY
266+
#undef __GENERATE_SUMMARY
267+
#undef _HAS_EXECUTE
268+
#undef _HAS_GATE
269+
#undef _MAKE_PASS_NAME_PASS
270+
#undef __MAKE_PASS_NAME_PASS
271+
#undef _PASS_NAME_NAME
272+
#undef _PASS_NAME_PASS
273+
#undef __PASS_NAME_PASS
274+
#undef _PASS_NAME_PASS_DATA
275+
#undef __PASS_NAME_PASS_DATA
276+
#undef _READ_OPTIMIZATION_SUMMARY
277+
#undef __READ_OPTIMIZATION_SUMMARY
278+
#undef _READ_SUMMARY
279+
#undef __READ_SUMMARY
280+
#undef _STMT_FIXUP
281+
#undef __STMT_FIXUP
282+
#undef _VARIABLE_TRANSFORM
283+
#undef __VARIABLE_TRANSFORM
284+
#undef _WRITE_OPTIMIZATION_SUMMARY
285+
#undef __WRITE_OPTIMIZATION_SUMMARY
286+
#undef _WRITE_SUMMARY
287+
#undef __WRITE_SUMMARY
288+
289+
#endif /* PASS_NAME */
+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/*
2+
* Generator for RTL pass related boilerplate code/data
3+
*
4+
* Supports gcc 4.5-6
5+
*
6+
* Usage:
7+
*
8+
* 1. before inclusion define PASS_NAME
9+
* 2. before inclusion define NO_* for unimplemented callbacks
10+
* NO_GATE
11+
* NO_EXECUTE
12+
* 3. before inclusion define PROPERTIES_* and TODO_FLAGS_* to override
13+
* the default 0 values
14+
* 4. for convenience, all the above will be undefined after inclusion!
15+
* 5. the only exported name is make_PASS_NAME_pass() to register with gcc
16+
*/
17+
18+
#ifndef PASS_NAME
19+
#error at least PASS_NAME must be defined
20+
#else
21+
#define __GCC_PLUGIN_STRINGIFY(n) #n
22+
#define _GCC_PLUGIN_STRINGIFY(n) __GCC_PLUGIN_STRINGIFY(n)
23+
#define _GCC_PLUGIN_CONCAT2(x, y) x ## y
24+
#define _GCC_PLUGIN_CONCAT3(x, y, z) x ## y ## z
25+
26+
#define __PASS_NAME_PASS_DATA(n) _GCC_PLUGIN_CONCAT2(n, _pass_data)
27+
#define _PASS_NAME_PASS_DATA __PASS_NAME_PASS_DATA(PASS_NAME)
28+
29+
#define __PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT2(n, _pass)
30+
#define _PASS_NAME_PASS __PASS_NAME_PASS(PASS_NAME)
31+
32+
#define _PASS_NAME_NAME _GCC_PLUGIN_STRINGIFY(PASS_NAME)
33+
34+
#define __MAKE_PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT3(make_, n, _pass)
35+
#define _MAKE_PASS_NAME_PASS __MAKE_PASS_NAME_PASS(PASS_NAME)
36+
37+
#ifdef NO_GATE
38+
#define _GATE NULL
39+
#define _HAS_GATE false
40+
#else
41+
#define __GATE(n) _GCC_PLUGIN_CONCAT2(n, _gate)
42+
#define _GATE __GATE(PASS_NAME)
43+
#define _HAS_GATE true
44+
#endif
45+
46+
#ifdef NO_EXECUTE
47+
#define _EXECUTE NULL
48+
#define _HAS_EXECUTE false
49+
#else
50+
#define __EXECUTE(n) _GCC_PLUGIN_CONCAT2(n, _execute)
51+
#define _EXECUTE __EXECUTE(PASS_NAME)
52+
#define _HAS_EXECUTE true
53+
#endif
54+
55+
#ifndef PROPERTIES_REQUIRED
56+
#define PROPERTIES_REQUIRED 0
57+
#endif
58+
59+
#ifndef PROPERTIES_PROVIDED
60+
#define PROPERTIES_PROVIDED 0
61+
#endif
62+
63+
#ifndef PROPERTIES_DESTROYED
64+
#define PROPERTIES_DESTROYED 0
65+
#endif
66+
67+
#ifndef TODO_FLAGS_START
68+
#define TODO_FLAGS_START 0
69+
#endif
70+
71+
#ifndef TODO_FLAGS_FINISH
72+
#define TODO_FLAGS_FINISH 0
73+
#endif
74+
75+
#if BUILDING_GCC_VERSION >= 4009
76+
namespace {
77+
static const pass_data _PASS_NAME_PASS_DATA = {
78+
#else
79+
static struct rtl_opt_pass _PASS_NAME_PASS = {
80+
.pass = {
81+
#endif
82+
.type = RTL_PASS,
83+
.name = _PASS_NAME_NAME,
84+
#if BUILDING_GCC_VERSION >= 4008
85+
.optinfo_flags = OPTGROUP_NONE,
86+
#endif
87+
#if BUILDING_GCC_VERSION >= 5000
88+
#elif BUILDING_GCC_VERSION == 4009
89+
.has_gate = _HAS_GATE,
90+
.has_execute = _HAS_EXECUTE,
91+
#else
92+
.gate = _GATE,
93+
.execute = _EXECUTE,
94+
.sub = NULL,
95+
.next = NULL,
96+
.static_pass_number = 0,
97+
#endif
98+
.tv_id = TV_NONE,
99+
.properties_required = PROPERTIES_REQUIRED,
100+
.properties_provided = PROPERTIES_PROVIDED,
101+
.properties_destroyed = PROPERTIES_DESTROYED,
102+
.todo_flags_start = TODO_FLAGS_START,
103+
.todo_flags_finish = TODO_FLAGS_FINISH,
104+
#if BUILDING_GCC_VERSION < 4009
105+
}
106+
#endif
107+
};
108+
109+
#if BUILDING_GCC_VERSION >= 4009
110+
class _PASS_NAME_PASS : public rtl_opt_pass {
111+
public:
112+
_PASS_NAME_PASS() : rtl_opt_pass(_PASS_NAME_PASS_DATA, g) {}
113+
114+
#ifndef NO_GATE
115+
#if BUILDING_GCC_VERSION >= 5000
116+
virtual bool gate(function *) { return _GATE(); }
117+
#else
118+
virtual bool gate(void) { return _GATE(); }
119+
#endif
120+
#endif
121+
122+
virtual opt_pass *clone() { return new _PASS_NAME_PASS(); }
123+
124+
#ifndef NO_EXECUTE
125+
#if BUILDING_GCC_VERSION >= 5000
126+
virtual unsigned int execute(function *) { return _EXECUTE(); }
127+
#else
128+
virtual unsigned int execute(void) { return _EXECUTE(); }
129+
#endif
130+
#endif
131+
};
132+
}
133+
134+
opt_pass *_MAKE_PASS_NAME_PASS(void)
135+
{
136+
return new _PASS_NAME_PASS();
137+
}
138+
#else
139+
struct opt_pass *_MAKE_PASS_NAME_PASS(void)
140+
{
141+
return &_PASS_NAME_PASS.pass;
142+
}
143+
#endif
144+
145+
/* clean up user provided defines */
146+
#undef PASS_NAME
147+
#undef NO_GATE
148+
#undef NO_EXECUTE
149+
150+
#undef PROPERTIES_DESTROYED
151+
#undef PROPERTIES_PROVIDED
152+
#undef PROPERTIES_REQUIRED
153+
#undef TODO_FLAGS_FINISH
154+
#undef TODO_FLAGS_START
155+
156+
/* clean up generated defines */
157+
#undef _EXECUTE
158+
#undef __EXECUTE
159+
#undef _GATE
160+
#undef __GATE
161+
#undef _GCC_PLUGIN_CONCAT2
162+
#undef _GCC_PLUGIN_CONCAT3
163+
#undef _GCC_PLUGIN_STRINGIFY
164+
#undef __GCC_PLUGIN_STRINGIFY
165+
#undef _HAS_EXECUTE
166+
#undef _HAS_GATE
167+
#undef _MAKE_PASS_NAME_PASS
168+
#undef __MAKE_PASS_NAME_PASS
169+
#undef _PASS_NAME_NAME
170+
#undef _PASS_NAME_PASS
171+
#undef __PASS_NAME_PASS
172+
#undef _PASS_NAME_PASS_DATA
173+
#undef __PASS_NAME_PASS_DATA
174+
175+
#endif /* PASS_NAME */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/*
2+
* Generator for SIMPLE_IPA pass related boilerplate code/data
3+
*
4+
* Supports gcc 4.5-6
5+
*
6+
* Usage:
7+
*
8+
* 1. before inclusion define PASS_NAME
9+
* 2. before inclusion define NO_* for unimplemented callbacks
10+
* NO_GATE
11+
* NO_EXECUTE
12+
* 3. before inclusion define PROPERTIES_* and TODO_FLAGS_* to override
13+
* the default 0 values
14+
* 4. for convenience, all the above will be undefined after inclusion!
15+
* 5. the only exported name is make_PASS_NAME_pass() to register with gcc
16+
*/
17+
18+
#ifndef PASS_NAME
19+
#error at least PASS_NAME must be defined
20+
#else
21+
#define __GCC_PLUGIN_STRINGIFY(n) #n
22+
#define _GCC_PLUGIN_STRINGIFY(n) __GCC_PLUGIN_STRINGIFY(n)
23+
#define _GCC_PLUGIN_CONCAT2(x, y) x ## y
24+
#define _GCC_PLUGIN_CONCAT3(x, y, z) x ## y ## z
25+
26+
#define __PASS_NAME_PASS_DATA(n) _GCC_PLUGIN_CONCAT2(n, _pass_data)
27+
#define _PASS_NAME_PASS_DATA __PASS_NAME_PASS_DATA(PASS_NAME)
28+
29+
#define __PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT2(n, _pass)
30+
#define _PASS_NAME_PASS __PASS_NAME_PASS(PASS_NAME)
31+
32+
#define _PASS_NAME_NAME _GCC_PLUGIN_STRINGIFY(PASS_NAME)
33+
34+
#define __MAKE_PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT3(make_, n, _pass)
35+
#define _MAKE_PASS_NAME_PASS __MAKE_PASS_NAME_PASS(PASS_NAME)
36+
37+
#ifdef NO_GATE
38+
#define _GATE NULL
39+
#define _HAS_GATE false
40+
#else
41+
#define __GATE(n) _GCC_PLUGIN_CONCAT2(n, _gate)
42+
#define _GATE __GATE(PASS_NAME)
43+
#define _HAS_GATE true
44+
#endif
45+
46+
#ifdef NO_EXECUTE
47+
#define _EXECUTE NULL
48+
#define _HAS_EXECUTE false
49+
#else
50+
#define __EXECUTE(n) _GCC_PLUGIN_CONCAT2(n, _execute)
51+
#define _EXECUTE __EXECUTE(PASS_NAME)
52+
#define _HAS_EXECUTE true
53+
#endif
54+
55+
#ifndef PROPERTIES_REQUIRED
56+
#define PROPERTIES_REQUIRED 0
57+
#endif
58+
59+
#ifndef PROPERTIES_PROVIDED
60+
#define PROPERTIES_PROVIDED 0
61+
#endif
62+
63+
#ifndef PROPERTIES_DESTROYED
64+
#define PROPERTIES_DESTROYED 0
65+
#endif
66+
67+
#ifndef TODO_FLAGS_START
68+
#define TODO_FLAGS_START 0
69+
#endif
70+
71+
#ifndef TODO_FLAGS_FINISH
72+
#define TODO_FLAGS_FINISH 0
73+
#endif
74+
75+
#if BUILDING_GCC_VERSION >= 4009
76+
namespace {
77+
static const pass_data _PASS_NAME_PASS_DATA = {
78+
#else
79+
static struct simple_ipa_opt_pass _PASS_NAME_PASS = {
80+
.pass = {
81+
#endif
82+
.type = SIMPLE_IPA_PASS,
83+
.name = _PASS_NAME_NAME,
84+
#if BUILDING_GCC_VERSION >= 4008
85+
.optinfo_flags = OPTGROUP_NONE,
86+
#endif
87+
#if BUILDING_GCC_VERSION >= 5000
88+
#elif BUILDING_GCC_VERSION == 4009
89+
.has_gate = _HAS_GATE,
90+
.has_execute = _HAS_EXECUTE,
91+
#else
92+
.gate = _GATE,
93+
.execute = _EXECUTE,
94+
.sub = NULL,
95+
.next = NULL,
96+
.static_pass_number = 0,
97+
#endif
98+
.tv_id = TV_NONE,
99+
.properties_required = PROPERTIES_REQUIRED,
100+
.properties_provided = PROPERTIES_PROVIDED,
101+
.properties_destroyed = PROPERTIES_DESTROYED,
102+
.todo_flags_start = TODO_FLAGS_START,
103+
.todo_flags_finish = TODO_FLAGS_FINISH,
104+
#if BUILDING_GCC_VERSION < 4009
105+
}
106+
#endif
107+
};
108+
109+
#if BUILDING_GCC_VERSION >= 4009
110+
class _PASS_NAME_PASS : public simple_ipa_opt_pass {
111+
public:
112+
_PASS_NAME_PASS() : simple_ipa_opt_pass(_PASS_NAME_PASS_DATA, g) {}
113+
114+
#ifndef NO_GATE
115+
#if BUILDING_GCC_VERSION >= 5000
116+
virtual bool gate(function *) { return _GATE(); }
117+
#else
118+
virtual bool gate(void) { return _GATE(); }
119+
#endif
120+
#endif
121+
122+
virtual opt_pass *clone() { return new _PASS_NAME_PASS(); }
123+
124+
#ifndef NO_EXECUTE
125+
#if BUILDING_GCC_VERSION >= 5000
126+
virtual unsigned int execute(function *) { return _EXECUTE(); }
127+
#else
128+
virtual unsigned int execute(void) { return _EXECUTE(); }
129+
#endif
130+
#endif
131+
};
132+
}
133+
134+
opt_pass *_MAKE_PASS_NAME_PASS(void)
135+
{
136+
return new _PASS_NAME_PASS();
137+
}
138+
#else
139+
struct opt_pass *_MAKE_PASS_NAME_PASS(void)
140+
{
141+
return &_PASS_NAME_PASS.pass;
142+
}
143+
#endif
144+
145+
/* clean up user provided defines */
146+
#undef PASS_NAME
147+
#undef NO_GATE
148+
#undef NO_EXECUTE
149+
150+
#undef PROPERTIES_DESTROYED
151+
#undef PROPERTIES_PROVIDED
152+
#undef PROPERTIES_REQUIRED
153+
#undef TODO_FLAGS_FINISH
154+
#undef TODO_FLAGS_START
155+
156+
/* clean up generated defines */
157+
#undef _EXECUTE
158+
#undef __EXECUTE
159+
#undef _GATE
160+
#undef __GATE
161+
#undef _GCC_PLUGIN_CONCAT2
162+
#undef _GCC_PLUGIN_CONCAT3
163+
#undef _GCC_PLUGIN_STRINGIFY
164+
#undef __GCC_PLUGIN_STRINGIFY
165+
#undef _HAS_EXECUTE
166+
#undef _HAS_GATE
167+
#undef _MAKE_PASS_NAME_PASS
168+
#undef __MAKE_PASS_NAME_PASS
169+
#undef _PASS_NAME_NAME
170+
#undef _PASS_NAME_PASS
171+
#undef __PASS_NAME_PASS
172+
#undef _PASS_NAME_PASS_DATA
173+
#undef __PASS_NAME_PASS_DATA
174+
175+
#endif /* PASS_NAME */

‎scripts/link-vmlinux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ else
180180
fi;
181181

182182
# final build of init/
183-
${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
183+
${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}"
184184

185185
kallsymso=""
186186
kallsyms_vmlinux=""

‎scripts/package/builddeb

+1
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ fi
329329
(cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles"
330330
(cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles"
331331
(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles"
332+
(cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles"
332333
destdir=$kernel_headers_dir/usr/src/linux-headers-$version
333334
mkdir -p "$destdir"
334335
(cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -)

0 commit comments

Comments
 (0)
Please sign in to comment.