diff options
Diffstat (limited to 'scripts/gcc-plugins')
| -rw-r--r-- | scripts/gcc-plugins/Kconfig | 20 | ||||
| -rw-r--r-- | scripts/gcc-plugins/arm_ssp_per_task_plugin.c | 27 | ||||
| -rw-r--r-- | scripts/gcc-plugins/cyc_complexity_plugin.c | 69 | ||||
| -rw-r--r-- | scripts/gcc-plugins/gcc-common.h | 132 | ||||
| -rw-r--r-- | scripts/gcc-plugins/gcc-generate-gimple-pass.h | 19 | ||||
| -rw-r--r-- | scripts/gcc-plugins/gcc-generate-ipa-pass.h | 19 | ||||
| -rw-r--r-- | scripts/gcc-plugins/gcc-generate-rtl-pass.h | 19 | ||||
| -rw-r--r-- | scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h | 19 | ||||
| -rw-r--r-- | scripts/gcc-plugins/structleak_plugin.c | 2 | 
9 files changed, 9 insertions, 317 deletions
diff --git a/scripts/gcc-plugins/Kconfig b/scripts/gcc-plugins/Kconfig index ab9eb4cbe33a..51d81c3f03d6 100644 --- a/scripts/gcc-plugins/Kconfig +++ b/scripts/gcc-plugins/Kconfig @@ -19,24 +19,10 @@ menuconfig GCC_PLUGINS  if GCC_PLUGINS -config GCC_PLUGIN_CYC_COMPLEXITY -	bool "Compute the cyclomatic complexity of a function" if EXPERT -	depends on !COMPILE_TEST	# too noisy -	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). - -	  Enabling this plugin reports the complexity to stderr during the -	  build. It mainly serves as a simple example of how to create a -	  gcc plugin for the kernel. -  config GCC_PLUGIN_SANCOV  	bool +	# Plugin can be removed once the kernel only supports GCC 6+ +	depends on !CC_HAS_SANCOV_TRACE_PC  	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 @@ -83,8 +69,6 @@ config GCC_PLUGIN_RANDSTRUCT  	  the existing seed and will be removed by a make mrproper or  	  make distclean. -	  Note that the implementation requires gcc 4.7 or newer. -  	  This plugin was ported from grsecurity/PaX. More information at:  	   * https://grsecurity.net/  	   * https://pax.grsecurity.net/ diff --git a/scripts/gcc-plugins/arm_ssp_per_task_plugin.c b/scripts/gcc-plugins/arm_ssp_per_task_plugin.c index 8c1af9bdcb1b..7328d037f975 100644 --- a/scripts/gcc-plugins/arm_ssp_per_task_plugin.c +++ b/scripts/gcc-plugins/arm_ssp_per_task_plugin.c @@ -4,7 +4,7 @@  __visible int plugin_is_GPL_compatible; -static unsigned int sp_mask, canary_offset; +static unsigned int canary_offset;  static unsigned int arm_pertask_ssp_rtl_execute(void)  { @@ -13,7 +13,7 @@ static unsigned int arm_pertask_ssp_rtl_execute(void)  	for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {  		const char *sym;  		rtx body; -		rtx mask, masked_sp; +		rtx current;  		/*  		 * Find a SET insn involving a SYMBOL_REF to __stack_chk_guard @@ -30,19 +30,13 @@ static unsigned int arm_pertask_ssp_rtl_execute(void)  		/*  		 * Replace the source of the SET insn with an expression that -		 * produces the address of the copy of the stack canary value -		 * stored in struct thread_info +		 * produces the address of the current task's stack canary value  		 */ -		mask = GEN_INT(sext_hwi(sp_mask, GET_MODE_PRECISION(Pmode))); -		masked_sp = gen_reg_rtx(Pmode); +		current = gen_reg_rtx(Pmode); -		emit_insn_before(gen_rtx_set(masked_sp, -					     gen_rtx_AND(Pmode, -							 stack_pointer_rtx, -							 mask)), -				 insn); +		emit_insn_before(gen_load_tp_hard(current), insn); -		SET_SRC(body) = gen_rtx_PLUS(Pmode, masked_sp, +		SET_SRC(body) = gen_rtx_PLUS(Pmode, current,  					     GEN_INT(canary_offset));  	}  	return 0; @@ -72,7 +66,6 @@ __visible int plugin_init(struct plugin_name_args *plugin_info,  	const char * const plugin_name = plugin_info->base_name;  	const int argc = plugin_info->argc;  	const struct plugin_argument *argv = plugin_info->argv; -	int tso = 0;  	int i;  	if (!plugin_default_version_check(version, &gcc_version)) { @@ -91,11 +84,6 @@ __visible int plugin_init(struct plugin_name_args *plugin_info,  			return 1;  		} -		if (!strcmp(argv[i].key, "tso")) { -			tso = atoi(argv[i].value); -			continue; -		} -  		if (!strcmp(argv[i].key, "offset")) {  			canary_offset = atoi(argv[i].value);  			continue; @@ -105,9 +93,6 @@ __visible int plugin_init(struct plugin_name_args *plugin_info,  		return 1;  	} -	/* create the mask that produces the base of the stack */ -	sp_mask = ~((1U << (12 + tso)) - 1); -  	PASS_INFO(arm_pertask_ssp_rtl, "expand", 1, PASS_POS_INSERT_AFTER);  	register_callback(plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP, diff --git a/scripts/gcc-plugins/cyc_complexity_plugin.c b/scripts/gcc-plugins/cyc_complexity_plugin.c deleted file mode 100644 index 73124c2b3edd..000000000000 --- a/scripts/gcc-plugins/cyc_complexity_plugin.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2011-2016 by Emese Revfy <re.emese@gmail.com> - * Licensed under the GPL v2, or (at your option) v3 - * - * Homepage: - * https://github.com/ephox-gcc-plugins/cyclomatic_complexity - * - * https://en.wikipedia.org/wiki/Cyclomatic_complexity - * The complexity M is then defined as: - * M = E - N + 2P - * where - * - *  E = the number of edges of the graph - *  N = the number of nodes of the graph - *  P = the number of connected components (exit nodes). - * - * Usage (4.5 - 5): - * $ make clean; make run - */ - -#include "gcc-common.h" - -__visible int plugin_is_GPL_compatible; - -static struct plugin_info cyc_complexity_plugin_info = { -	.version	= "20160225", -	.help		= "Cyclomatic Complexity\n", -}; - -static unsigned int cyc_complexity_execute(void) -{ -	int complexity; -	expanded_location xloc; - -	/* M = E - N + 2P */ -	complexity = n_edges_for_fn(cfun) - n_basic_blocks_for_fn(cfun) + 2; - -	xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl)); -	fprintf(stderr, "Cyclomatic Complexity %d %s:%s\n", complexity, -		xloc.file, DECL_NAME_POINTER(current_function_decl)); - -	return 0; -} - -#define PASS_NAME cyc_complexity - -#define NO_GATE -#define TODO_FLAGS_FINISH TODO_dump_func - -#include "gcc-generate-gimple-pass.h" - -__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) -{ -	const char * const plugin_name = plugin_info->base_name; - -	PASS_INFO(cyc_complexity, "ssa", 1, PASS_POS_INSERT_AFTER); - -	if (!plugin_default_version_check(version, &gcc_version)) { -		error(G_("incompatible gcc/plugin versions")); -		return 1; -	} - -	register_callback(plugin_name, PLUGIN_INFO, NULL, -				&cyc_complexity_plugin_info); -	register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, -				&cyc_complexity_pass_info); - -	return 0; -} diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h index 0c087614fc3e..9a1895747b15 100644 --- a/scripts/gcc-plugins/gcc-common.h +++ b/scripts/gcc-plugins/gcc-common.h @@ -27,9 +27,7 @@  #include "except.h"  #include "function.h"  #include "toplev.h" -#if BUILDING_GCC_VERSION >= 5000  #include "expr.h" -#endif  #include "basic-block.h"  #include "intl.h"  #include "ggc.h" @@ -39,11 +37,7 @@  #include "params.h"  #endif -#if BUILDING_GCC_VERSION <= 4009 -#include "pointer-set.h" -#else  #include "hash-map.h" -#endif  #if BUILDING_GCC_VERSION >= 7000  #include "memmodel.h" @@ -92,16 +86,13 @@  #include "stmt.h"  #include "gimplify.h"  #include "gimple.h" -#include "tree-ssa-operands.h"  #include "tree-phinodes.h"  #include "tree-cfg.h"  #include "gimple-iterator.h"  #include "gimple-ssa.h"  #include "ssa-iterators.h" -#if BUILDING_GCC_VERSION >= 5000  #include "builtins.h" -#endif  /* missing from basic_block.h... */  void debug_dominance_info(enum cdi_direction dir); @@ -152,125 +143,6 @@ struct register_pass_info NAME##_pass_info = {	\  #define TODO_dump_func 0  #define TODO_dump_cgraph 0 -#if BUILDING_GCC_VERSION <= 4009 -#define TODO_verify_il 0 -#define AVAIL_INTERPOSABLE AVAIL_OVERWRITABLE - -#define section_name_prefix LTO_SECTION_NAME_PREFIX -#define fatal_error(loc, gmsgid, ...) fatal_error((gmsgid), __VA_ARGS__) - -rtx emit_move_insn(rtx x, rtx y); - -typedef struct rtx_def rtx_insn; - -static inline const char *get_decl_section_name(const_tree decl) -{ -	if (DECL_SECTION_NAME(decl) == NULL_TREE) -		return NULL; - -	return TREE_STRING_POINTER(DECL_SECTION_NAME(decl)); -} - -static inline void set_decl_section_name(tree node, const char *value) -{ -	if (value) -		DECL_SECTION_NAME(node) = build_string(strlen(value) + 1, value); -	else -		DECL_SECTION_NAME(node) = NULL; -} -#endif - -#if BUILDING_GCC_VERSION == 4009 -typedef struct gimple_statement_asm gasm; -typedef struct gimple_statement_base gassign; -typedef struct gimple_statement_call gcall; -typedef struct gimple_statement_base gcond; -typedef struct gimple_statement_base gdebug; -typedef struct gimple_statement_base ggoto; -typedef struct gimple_statement_phi gphi; -typedef struct gimple_statement_base greturn; - -static inline gasm *as_a_gasm(gimple stmt) -{ -	return as_a<gasm>(stmt); -} - -static inline const gasm *as_a_const_gasm(const_gimple stmt) -{ -	return as_a<const gasm>(stmt); -} - -static inline gassign *as_a_gassign(gimple stmt) -{ -	return stmt; -} - -static inline const gassign *as_a_const_gassign(const_gimple stmt) -{ -	return stmt; -} - -static inline gcall *as_a_gcall(gimple stmt) -{ -	return as_a<gcall>(stmt); -} - -static inline const gcall *as_a_const_gcall(const_gimple stmt) -{ -	return as_a<const gcall>(stmt); -} - -static inline gcond *as_a_gcond(gimple stmt) -{ -	return stmt; -} - -static inline const gcond *as_a_const_gcond(const_gimple stmt) -{ -	return stmt; -} - -static inline gdebug *as_a_gdebug(gimple stmt) -{ -	return stmt; -} - -static inline const gdebug *as_a_const_gdebug(const_gimple stmt) -{ -	return stmt; -} - -static inline ggoto *as_a_ggoto(gimple stmt) -{ -	return stmt; -} - -static inline const ggoto *as_a_const_ggoto(const_gimple stmt) -{ -	return stmt; -} - -static inline gphi *as_a_gphi(gimple stmt) -{ -	return as_a<gphi>(stmt); -} - -static inline const gphi *as_a_const_gphi(const_gimple stmt) -{ -	return as_a<const gphi>(stmt); -} - -static inline greturn *as_a_greturn(gimple stmt) -{ -	return stmt; -} - -static inline const greturn *as_a_const_greturn(const_gimple stmt) -{ -	return stmt; -} -#endif -  #define TODO_ggc_collect 0  #define NODE_SYMBOL(node) (node)  #define NODE_DECL(node) (node)->decl @@ -282,7 +154,7 @@ static inline opt_pass *get_pass_for_id(int id)  	return g->get_passes()->get_pass_for_id(id);  } -#if BUILDING_GCC_VERSION >= 5000 && BUILDING_GCC_VERSION < 6000 +#if BUILDING_GCC_VERSION < 6000  /* gimple related */  template <>  template <> @@ -292,7 +164,6 @@ inline bool is_a_helper<const gassign *>::test(const_gimple gs)  }  #endif -#if BUILDING_GCC_VERSION >= 5000  #define TODO_verify_ssa TODO_verify_il  #define TODO_verify_flow TODO_verify_il  #define TODO_verify_stmts TODO_verify_il @@ -533,7 +404,6 @@ static inline void ipa_remove_stmt_references(symtab_node *referring_node, gimpl  {  	referring_node->remove_stmt_references(stmt);  } -#endif  #if BUILDING_GCC_VERSION < 6000  #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning)	\ diff --git a/scripts/gcc-plugins/gcc-generate-gimple-pass.h b/scripts/gcc-plugins/gcc-generate-gimple-pass.h index 51780828734e..503c07496396 100644 --- a/scripts/gcc-plugins/gcc-generate-gimple-pass.h +++ b/scripts/gcc-plugins/gcc-generate-gimple-pass.h @@ -78,17 +78,6 @@ static const pass_data _PASS_NAME_PASS_DATA = {  		.type			= GIMPLE_PASS,  		.name			= _PASS_NAME_NAME,  		.optinfo_flags		= OPTGROUP_NONE, -#if BUILDING_GCC_VERSION >= 5000 -#elif BUILDING_GCC_VERSION == 4009 -		.has_gate		= _HAS_GATE, -		.has_execute		= _HAS_EXECUTE, -#else -		.gate			= _GATE, -		.execute		= _EXECUTE, -		.sub			= NULL, -		.next			= NULL, -		.static_pass_number	= 0, -#endif  		.tv_id			= TV_NONE,  		.properties_required	= PROPERTIES_REQUIRED,  		.properties_provided	= PROPERTIES_PROVIDED, @@ -102,21 +91,13 @@ public:  	_PASS_NAME_PASS() : gimple_opt_pass(_PASS_NAME_PASS_DATA, g) {}  #ifndef NO_GATE -#if BUILDING_GCC_VERSION >= 5000  	virtual bool gate(function *) { return _GATE(); } -#else -	virtual bool gate(void) { return _GATE(); } -#endif  #endif  	virtual opt_pass * clone () { return new _PASS_NAME_PASS(); }  #ifndef NO_EXECUTE -#if BUILDING_GCC_VERSION >= 5000  	virtual unsigned int execute(function *) { return _EXECUTE(); } -#else -	virtual unsigned int execute(void) { return _EXECUTE(); } -#endif  };  } diff --git a/scripts/gcc-plugins/gcc-generate-ipa-pass.h b/scripts/gcc-plugins/gcc-generate-ipa-pass.h index c34ffec035bf..1e7f064e8f6e 100644 --- a/scripts/gcc-plugins/gcc-generate-ipa-pass.h +++ b/scripts/gcc-plugins/gcc-generate-ipa-pass.h @@ -146,17 +146,6 @@ static const pass_data _PASS_NAME_PASS_DATA = {  		.type			= IPA_PASS,  		.name			= _PASS_NAME_NAME,  		.optinfo_flags		= OPTGROUP_NONE, -#if BUILDING_GCC_VERSION >= 5000 -#elif BUILDING_GCC_VERSION == 4009 -		.has_gate		= _HAS_GATE, -		.has_execute		= _HAS_EXECUTE, -#else -		.gate			= _GATE, -		.execute		= _EXECUTE, -		.sub			= NULL, -		.next			= NULL, -		.static_pass_number	= 0, -#endif  		.tv_id			= TV_NONE,  		.properties_required	= PROPERTIES_REQUIRED,  		.properties_provided	= PROPERTIES_PROVIDED, @@ -180,20 +169,12 @@ public:  			 _VARIABLE_TRANSFORM) {}  #ifndef NO_GATE -#if BUILDING_GCC_VERSION >= 5000  	virtual bool gate(function *) { return _GATE(); } -#else -	virtual bool gate(void) { return _GATE(); } -#endif  	virtual opt_pass *clone() { return new _PASS_NAME_PASS(); }  #ifndef NO_EXECUTE -#if BUILDING_GCC_VERSION >= 5000  	virtual unsigned int execute(function *) { return _EXECUTE(); } -#else -	virtual unsigned int execute(void) { return _EXECUTE(); } -#endif  #endif  };  } diff --git a/scripts/gcc-plugins/gcc-generate-rtl-pass.h b/scripts/gcc-plugins/gcc-generate-rtl-pass.h index d14614f4b139..7cd46e8d5049 100644 --- a/scripts/gcc-plugins/gcc-generate-rtl-pass.h +++ b/scripts/gcc-plugins/gcc-generate-rtl-pass.h @@ -78,17 +78,6 @@ static const pass_data _PASS_NAME_PASS_DATA = {  		.type			= RTL_PASS,  		.name			= _PASS_NAME_NAME,  		.optinfo_flags		= OPTGROUP_NONE, -#if BUILDING_GCC_VERSION >= 5000 -#elif BUILDING_GCC_VERSION == 4009 -		.has_gate		= _HAS_GATE, -		.has_execute		= _HAS_EXECUTE, -#else -		.gate			= _GATE, -		.execute		= _EXECUTE, -		.sub			= NULL, -		.next			= NULL, -		.static_pass_number	= 0, -#endif  		.tv_id			= TV_NONE,  		.properties_required	= PROPERTIES_REQUIRED,  		.properties_provided	= PROPERTIES_PROVIDED, @@ -102,21 +91,13 @@ public:  	_PASS_NAME_PASS() : rtl_opt_pass(_PASS_NAME_PASS_DATA, g) {}  #ifndef NO_GATE -#if BUILDING_GCC_VERSION >= 5000  	virtual bool gate(function *) { return _GATE(); } -#else -	virtual bool gate(void) { return _GATE(); } -#endif  #endif  	virtual opt_pass *clone() { return new _PASS_NAME_PASS(); }  #ifndef NO_EXECUTE -#if BUILDING_GCC_VERSION >= 5000  	virtual unsigned int execute(function *) { return _EXECUTE(); } -#else -	virtual unsigned int execute(void) { return _EXECUTE(); } -#endif  #endif  };  } diff --git a/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h b/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h index ef6f4c2cb6fa..33093ccc947a 100644 --- a/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h +++ b/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h @@ -78,17 +78,6 @@ static const pass_data _PASS_NAME_PASS_DATA = {  		.type			= SIMPLE_IPA_PASS,  		.name			= _PASS_NAME_NAME,  		.optinfo_flags		= OPTGROUP_NONE, -#if BUILDING_GCC_VERSION >= 5000 -#elif BUILDING_GCC_VERSION == 4009 -		.has_gate		= _HAS_GATE, -		.has_execute		= _HAS_EXECUTE, -#else -		.gate			= _GATE, -		.execute		= _EXECUTE, -		.sub			= NULL, -		.next			= NULL, -		.static_pass_number	= 0, -#endif  		.tv_id			= TV_NONE,  		.properties_required	= PROPERTIES_REQUIRED,  		.properties_provided	= PROPERTIES_PROVIDED, @@ -102,21 +91,13 @@ public:  	_PASS_NAME_PASS() : simple_ipa_opt_pass(_PASS_NAME_PASS_DATA, g) {}  #ifndef NO_GATE -#if BUILDING_GCC_VERSION >= 5000  	virtual bool gate(function *) { return _GATE(); } -#else -	virtual bool gate(void) { return _GATE(); } -#endif  #endif  	virtual opt_pass *clone() { return new _PASS_NAME_PASS(); }  #ifndef NO_EXECUTE -#if BUILDING_GCC_VERSION >= 5000  	virtual unsigned int execute(function *) { return _EXECUTE(); } -#else -	virtual unsigned int execute(void) { return _EXECUTE(); } -#endif  #endif  };  } diff --git a/scripts/gcc-plugins/structleak_plugin.c b/scripts/gcc-plugins/structleak_plugin.c index d7190e443a14..74e319288389 100644 --- a/scripts/gcc-plugins/structleak_plugin.c +++ b/scripts/gcc-plugins/structleak_plugin.c @@ -103,10 +103,8 @@ static void finish_type(void *event_data, void *data)  	if (type == NULL_TREE || type == error_mark_node)  		return; -#if BUILDING_GCC_VERSION >= 5000  	if (TREE_CODE(type) == ENUMERAL_TYPE)  		return; -#endif  	if (TYPE_USERSPACE(type))  		return;  | 
