diff options
Diffstat (limited to 'scripts/gcc-plugins')
| -rw-r--r-- | scripts/gcc-plugins/gcc-common.h | 4 | ||||
| -rw-r--r-- | scripts/gcc-plugins/latent_entropy_plugin.c | 4 | ||||
| -rw-r--r-- | scripts/gcc-plugins/randomize_layout_plugin.c | 24 | 
3 files changed, 15 insertions, 17 deletions
diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h index 84c730da36dd..1ae39b9f4a95 100644 --- a/scripts/gcc-plugins/gcc-common.h +++ b/scripts/gcc-plugins/gcc-common.h @@ -440,4 +440,8 @@ static inline void debug_gimple_stmt(const_gimple s)  #define SET_DECL_MODE(decl, mode)	DECL_MODE(decl) = (mode)  #endif +#if BUILDING_GCC_VERSION >= 14000 +#define last_stmt(x)			last_nondebug_stmt(x) +#endif +  #endif diff --git a/scripts/gcc-plugins/latent_entropy_plugin.c b/scripts/gcc-plugins/latent_entropy_plugin.c index 39e86be60dd2..ff0b192be91f 100644 --- a/scripts/gcc-plugins/latent_entropy_plugin.c +++ b/scripts/gcc-plugins/latent_entropy_plugin.c @@ -17,7 +17,7 @@   *	if (argc <= 1)   *		printf("%s: no command arguments :(\n", *argv);   *	else - *		printf("%s: %d command arguments!\n", *argv, args - 1); + *		printf("%s: %d command arguments!\n", *argv, argc - 1);   * }   *   * after: @@ -47,7 +47,7 @@   *		// perturb_local_entropy()   *	} else {   *		local_entropy ^= 3896280633962944730; - *		printf("%s: %d command arguments!\n", *argv, args - 1); + *		printf("%s: %d command arguments!\n", *argv, argc - 1);   *	}   *   *	// latent_entropy_execute() 4. diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c index 951b74ba1b24..746ff2d272f2 100644 --- a/scripts/gcc-plugins/randomize_layout_plugin.c +++ b/scripts/gcc-plugins/randomize_layout_plugin.c @@ -191,12 +191,14 @@ static void partition_struct(tree *fields, unsigned long length, struct partitio  static void performance_shuffle(tree *newtree, unsigned long length, ranctx *prng_state)  { -	unsigned long i, x; +	unsigned long i, x, index;  	struct partition_group size_group[length];  	unsigned long num_groups = 0;  	unsigned long randnum;  	partition_struct(newtree, length, (struct partition_group *)&size_group, &num_groups); + +	/* FIXME: this group shuffle is currently a no-op. */  	for (i = num_groups - 1; i > 0; i--) {  		struct partition_group tmp;  		randnum = ranval(prng_state) % (i + 1); @@ -206,11 +208,14 @@ static void performance_shuffle(tree *newtree, unsigned long length, ranctx *prn  	}  	for (x = 0; x < num_groups; x++) { -		for (i = size_group[x].start + size_group[x].length - 1; i > size_group[x].start; i--) { +		for (index = size_group[x].length - 1; index > 0; index--) {  			tree tmp; + +			i = size_group[x].start + index;  			if (DECL_BIT_FIELD_TYPE(newtree[i]))  				continue; -			randnum = ranval(prng_state) % (i + 1); +			randnum = ranval(prng_state) % (index + 1); +			randnum += size_group[x].start;  			// we could handle this case differently if desired  			if (DECL_BIT_FIELD_TYPE(newtree[randnum]))  				continue; @@ -273,8 +278,6 @@ static bool is_flexible_array(const_tree field)  {  	const_tree fieldtype;  	const_tree typesize; -	const_tree elemtype; -	const_tree elemsize;  	fieldtype = TREE_TYPE(field);  	typesize = TYPE_SIZE(fieldtype); @@ -282,20 +285,12 @@ static bool is_flexible_array(const_tree field)  	if (TREE_CODE(fieldtype) != ARRAY_TYPE)  		return false; -	elemtype = TREE_TYPE(fieldtype); -	elemsize = TYPE_SIZE(elemtype); -  	/* size of type is represented in bits */  	if (typesize == NULL_TREE && TYPE_DOMAIN(fieldtype) != NULL_TREE &&  	    TYPE_MAX_VALUE(TYPE_DOMAIN(fieldtype)) == NULL_TREE)  		return true; -	if (typesize != NULL_TREE && -	    (TREE_CONSTANT(typesize) && (!tree_to_uhwi(typesize) || -	     tree_to_uhwi(typesize) == tree_to_uhwi(elemsize)))) -		return true; -  	return false;  } @@ -344,8 +339,7 @@ static int relayout_struct(tree type)  	/*  	 * enforce that we don't randomize the layout of the last -	 * element of a struct if it's a 0 or 1-length array -	 * or a proper flexible array +	 * element of a struct if it's a proper flexible array  	 */  	if (is_flexible_array(newtree[num_fields - 1])) {  		has_flexarray = true;  | 
