Skip to content

Commit

Permalink
gcc-plugins: remove code for GCC versions older than 4.9
Browse files Browse the repository at this point in the history
Documentation/process/changes.rst says the minimal GCC version is 4.9.
Hence, BUILDING_GCC_VERSION is greater than or equal to 4009.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20201202134929.99883-1-masahiroy@kernel.org
  • Loading branch information
Masahiro Yamada authored and Kees Cook committed Dec 4, 2020
1 parent b650545 commit af2d222
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 505 deletions.
407 changes: 0 additions & 407 deletions scripts/gcc-plugins/gcc-common.h

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions scripts/gcc-plugins/gcc-generate-gimple-pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,11 @@
#define TODO_FLAGS_FINISH 0
#endif

#if BUILDING_GCC_VERSION >= 4009
namespace {
static const pass_data _PASS_NAME_PASS_DATA = {
#else
static struct gimple_opt_pass _PASS_NAME_PASS = {
.pass = {
#endif
.type = GIMPLE_PASS,
.name = _PASS_NAME_NAME,
#if BUILDING_GCC_VERSION >= 4008
.optinfo_flags = OPTGROUP_NONE,
#endif
#if BUILDING_GCC_VERSION >= 5000
#elif BUILDING_GCC_VERSION == 4009
.has_gate = _HAS_GATE,
Expand All @@ -102,12 +95,8 @@ static struct gimple_opt_pass _PASS_NAME_PASS = {
.properties_destroyed = PROPERTIES_DESTROYED,
.todo_flags_start = TODO_FLAGS_START,
.todo_flags_finish = TODO_FLAGS_FINISH,
#if BUILDING_GCC_VERSION < 4009
}
#endif
};

#if BUILDING_GCC_VERSION >= 4009
class _PASS_NAME_PASS : public gimple_opt_pass {
public:
_PASS_NAME_PASS() : gimple_opt_pass(_PASS_NAME_PASS_DATA, g) {}
Expand All @@ -128,7 +117,6 @@ class _PASS_NAME_PASS : public gimple_opt_pass {
#else
virtual unsigned int execute(void) { return _EXECUTE(); }
#endif
#endif
};
}

Expand Down
23 changes: 0 additions & 23 deletions scripts/gcc-plugins/gcc-generate-ipa-pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,11 @@
#define FUNCTION_TRANSFORM_TODO_FLAGS_START 0
#endif

#if BUILDING_GCC_VERSION >= 4009
namespace {
static const pass_data _PASS_NAME_PASS_DATA = {
#else
static struct ipa_opt_pass_d _PASS_NAME_PASS = {
.pass = {
#endif
.type = IPA_PASS,
.name = _PASS_NAME_NAME,
#if BUILDING_GCC_VERSION >= 4008
.optinfo_flags = OPTGROUP_NONE,
#endif
#if BUILDING_GCC_VERSION >= 5000
#elif BUILDING_GCC_VERSION == 4009
.has_gate = _HAS_GATE,
Expand All @@ -170,23 +163,8 @@ static struct ipa_opt_pass_d _PASS_NAME_PASS = {
.properties_destroyed = PROPERTIES_DESTROYED,
.todo_flags_start = TODO_FLAGS_START,
.todo_flags_finish = TODO_FLAGS_FINISH,
#if BUILDING_GCC_VERSION < 4009
},
.generate_summary = _GENERATE_SUMMARY,
.write_summary = _WRITE_SUMMARY,
.read_summary = _READ_SUMMARY,
#if BUILDING_GCC_VERSION >= 4006
.write_optimization_summary = _WRITE_OPTIMIZATION_SUMMARY,
.read_optimization_summary = _READ_OPTIMIZATION_SUMMARY,
#endif
.stmt_fixup = _STMT_FIXUP,
.function_transform_todo_flags_start = FUNCTION_TRANSFORM_TODO_FLAGS_START,
.function_transform = _FUNCTION_TRANSFORM,
.variable_transform = _VARIABLE_TRANSFORM,
#endif
};

#if BUILDING_GCC_VERSION >= 4009
class _PASS_NAME_PASS : public ipa_opt_pass_d {
public:
_PASS_NAME_PASS() : ipa_opt_pass_d(_PASS_NAME_PASS_DATA,
Expand All @@ -206,7 +184,6 @@ class _PASS_NAME_PASS : public ipa_opt_pass_d {
virtual bool gate(function *) { return _GATE(); }
#else
virtual bool gate(void) { return _GATE(); }
#endif
#endif

virtual opt_pass *clone() { return new _PASS_NAME_PASS(); }
Expand Down
17 changes: 0 additions & 17 deletions scripts/gcc-plugins/gcc-generate-rtl-pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,11 @@
#define TODO_FLAGS_FINISH 0
#endif

#if BUILDING_GCC_VERSION >= 4009
namespace {
static const pass_data _PASS_NAME_PASS_DATA = {
#else
static struct rtl_opt_pass _PASS_NAME_PASS = {
.pass = {
#endif
.type = RTL_PASS,
.name = _PASS_NAME_NAME,
#if BUILDING_GCC_VERSION >= 4008
.optinfo_flags = OPTGROUP_NONE,
#endif
#if BUILDING_GCC_VERSION >= 5000
#elif BUILDING_GCC_VERSION == 4009
.has_gate = _HAS_GATE,
Expand All @@ -102,12 +95,8 @@ static struct rtl_opt_pass _PASS_NAME_PASS = {
.properties_destroyed = PROPERTIES_DESTROYED,
.todo_flags_start = TODO_FLAGS_START,
.todo_flags_finish = TODO_FLAGS_FINISH,
#if BUILDING_GCC_VERSION < 4009
}
#endif
};

#if BUILDING_GCC_VERSION >= 4009
class _PASS_NAME_PASS : public rtl_opt_pass {
public:
_PASS_NAME_PASS() : rtl_opt_pass(_PASS_NAME_PASS_DATA, g) {}
Expand Down Expand Up @@ -136,12 +125,6 @@ opt_pass *_MAKE_PASS_NAME_PASS(void)
{
return new _PASS_NAME_PASS();
}
#else
struct opt_pass *_MAKE_PASS_NAME_PASS(void)
{
return &_PASS_NAME_PASS.pass;
}
#endif

/* clean up user provided defines */
#undef PASS_NAME
Expand Down
17 changes: 0 additions & 17 deletions scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,11 @@
#define TODO_FLAGS_FINISH 0
#endif

#if BUILDING_GCC_VERSION >= 4009
namespace {
static const pass_data _PASS_NAME_PASS_DATA = {
#else
static struct simple_ipa_opt_pass _PASS_NAME_PASS = {
.pass = {
#endif
.type = SIMPLE_IPA_PASS,
.name = _PASS_NAME_NAME,
#if BUILDING_GCC_VERSION >= 4008
.optinfo_flags = OPTGROUP_NONE,
#endif
#if BUILDING_GCC_VERSION >= 5000
#elif BUILDING_GCC_VERSION == 4009
.has_gate = _HAS_GATE,
Expand All @@ -102,12 +95,8 @@ static struct simple_ipa_opt_pass _PASS_NAME_PASS = {
.properties_destroyed = PROPERTIES_DESTROYED,
.todo_flags_start = TODO_FLAGS_START,
.todo_flags_finish = TODO_FLAGS_FINISH,
#if BUILDING_GCC_VERSION < 4009
}
#endif
};

#if BUILDING_GCC_VERSION >= 4009
class _PASS_NAME_PASS : public simple_ipa_opt_pass {
public:
_PASS_NAME_PASS() : simple_ipa_opt_pass(_PASS_NAME_PASS_DATA, g) {}
Expand Down Expand Up @@ -136,12 +125,6 @@ opt_pass *_MAKE_PASS_NAME_PASS(void)
{
return new _PASS_NAME_PASS();
}
#else
struct opt_pass *_MAKE_PASS_NAME_PASS(void)
{
return &_PASS_NAME_PASS.pass;
}
#endif

/* clean up user provided defines */
#undef PASS_NAME
Expand Down
12 changes: 0 additions & 12 deletions scripts/gcc-plugins/latent_entropy_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name,
bool *no_add_attrs)
{
tree type;
#if BUILDING_GCC_VERSION <= 4007
VEC(constructor_elt, gc) *vals;
#else
vec<constructor_elt, va_gc> *vals;
#endif

switch (TREE_CODE(*node)) {
default:
Expand Down Expand Up @@ -181,11 +177,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name,
if (fld)
break;

#if BUILDING_GCC_VERSION <= 4007
vals = VEC_alloc(constructor_elt, gc, nelt);
#else
vec_alloc(vals, nelt);
#endif

for (fld = lst; fld; fld = TREE_CHAIN(fld)) {
tree random_const, fld_t = TREE_TYPE(fld);
Expand Down Expand Up @@ -225,11 +217,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name,
elt_size_int = TREE_INT_CST_LOW(elt_size);
nelt = array_size_int / elt_size_int;

#if BUILDING_GCC_VERSION <= 4007
vals = VEC_alloc(constructor_elt, gc, nelt);
#else
vec_alloc(vals, nelt);
#endif

for (i = 0; i < nelt; i++) {
tree cst = size_int(i);
Expand Down
4 changes: 0 additions & 4 deletions scripts/gcc-plugins/randomize_layout_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,16 +590,12 @@ static void register_attributes(void *event_data, void *data)
randomize_layout_attr.name = "randomize_layout";
randomize_layout_attr.type_required = true;
randomize_layout_attr.handler = handle_randomize_layout_attr;
#if BUILDING_GCC_VERSION >= 4007
randomize_layout_attr.affects_type_identity = true;
#endif

no_randomize_layout_attr.name = "no_randomize_layout";
no_randomize_layout_attr.type_required = true;
no_randomize_layout_attr.handler = handle_randomize_layout_attr;
#if BUILDING_GCC_VERSION >= 4007
no_randomize_layout_attr.affects_type_identity = true;
#endif

randomize_considered_attr.name = "randomize_considered";
randomize_considered_attr.type_required = true;
Expand Down
6 changes: 0 additions & 6 deletions scripts/gcc-plugins/sancov_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ static void sancov_start_unit(void __unused *gcc_data, void __unused *user_data)
nothrow_attr = tree_cons(get_identifier("nothrow"), NULL, NULL);
decl_attributes(&sancov_fndecl, nothrow_attr, 0);
gcc_assert(TREE_NOTHROW(sancov_fndecl));
#if BUILDING_GCC_VERSION > 4005
leaf_attr = tree_cons(get_identifier("leaf"), NULL, NULL);
decl_attributes(&sancov_fndecl, leaf_attr, 0);
#endif
}

__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
Expand All @@ -106,11 +104,7 @@ __visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gc
};

/* BBs can be split afterwards?? */
#if BUILDING_GCC_VERSION >= 4009
PASS_INFO(sancov, "asan", 0, PASS_POS_INSERT_BEFORE);
#else
PASS_INFO(sancov, "nrv", 1, PASS_POS_INSERT_BEFORE);
#endif

if (!plugin_default_version_check(version, &gcc_version)) {
error(G_("incompatible gcc/plugin versions"));
Expand Down
4 changes: 1 addition & 3 deletions scripts/gcc-plugins/stackleak_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ static bool is_alloca(gimple stmt)
if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
return true;

#if BUILDING_GCC_VERSION >= 4007
if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
return true;
#endif

return false;
}
Expand Down Expand Up @@ -322,7 +320,7 @@ static void remove_stack_tracking_gcall(void)

/* Delete the stackleak_track_stack() call */
delete_insn_and_edges(insn);
#if BUILDING_GCC_VERSION >= 4007 && BUILDING_GCC_VERSION < 8000
#if BUILDING_GCC_VERSION < 8000
if (GET_CODE(next) == NOTE &&
NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
insn = next;
Expand Down
4 changes: 0 additions & 4 deletions scripts/gcc-plugins/structleak_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ static void register_attributes(void *event_data, void *data)
{
user_attr.name = "user";
user_attr.handler = handle_user_attribute;
#if BUILDING_GCC_VERSION >= 4007
user_attr.affects_type_identity = true;
#endif

register_attribute(&user_attr);
}
Expand Down Expand Up @@ -137,11 +135,9 @@ static void initialize(tree var)
if (!gimple_assign_single_p(stmt))
continue;
rhs1 = gimple_assign_rhs1(stmt);
#if BUILDING_GCC_VERSION >= 4007
/* ... of a non-clobbering expression... */
if (TREE_CLOBBER_P(rhs1))
continue;
#endif
/* ... to our variable... */
if (gimple_get_lhs(stmt) != var)
continue;
Expand Down

0 comments on commit af2d222

Please sign in to comment.