mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 01:21:58 +00:00
Merge branch 'merge/randstruct' into for-next/gcc-plugins
This commit is contained in:
commit
d1185a8c5d
14 changed files with 1146 additions and 9 deletions
|
@ -29,6 +29,10 @@ ifdef CONFIG_GCC_PLUGINS
|
|||
gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) += -fplugin-arg-structleak_plugin-verbose
|
||||
gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += -DSTRUCTLEAK_PLUGIN
|
||||
|
||||
gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so
|
||||
gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += -DRANDSTRUCT_PLUGIN
|
||||
gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) += -fplugin-arg-randomize_layout_plugin-performance-mode
|
||||
|
||||
GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))
|
||||
|
||||
export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR
|
||||
|
|
1
scripts/gcc-plugins/.gitignore
vendored
Normal file
1
scripts/gcc-plugins/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
randomize_layout_seed.h
|
|
@ -18,6 +18,14 @@ endif
|
|||
|
||||
export HOSTLIBS
|
||||
|
||||
$(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h
|
||||
quiet_cmd_create_randomize_layout_seed = GENSEED $@
|
||||
cmd_create_randomize_layout_seed = \
|
||||
$(CONFIG_SHELL) $(srctree)/$(src)/gen-random-seed.sh $@ $(objtree)/include/generated/randomize_layout_hash.h
|
||||
$(objtree)/$(obj)/randomize_layout_seed.h: FORCE
|
||||
$(call if_changed,create_randomize_layout_seed)
|
||||
targets = randomize_layout_seed.h randomize_layout_hash.h
|
||||
|
||||
$(HOSTLIBS)-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p)))
|
||||
always := $($(HOSTLIBS)-y)
|
||||
|
||||
|
|
|
@ -63,6 +63,13 @@
|
|||
#endif
|
||||
|
||||
#if BUILDING_GCC_VERSION >= 4006
|
||||
/*
|
||||
* The c-family headers were moved into a subdirectory in GCC version
|
||||
* 4.7, but most plugin-building users of GCC 4.6 are using the Debian
|
||||
* or Ubuntu package, which has an out-of-tree patch to move this to the
|
||||
* same location as found in 4.7 and later:
|
||||
* https://sources.debian.net/src/gcc-4.6/4.6.3-14/debian/patches/pr45078.diff/
|
||||
*/
|
||||
#include "c-family/c-common.h"
|
||||
#else
|
||||
#include "c-common.h"
|
||||
|
@ -946,4 +953,9 @@ static inline void debug_gimple_stmt(const_gimple s)
|
|||
get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
|
||||
#endif
|
||||
|
||||
#if BUILDING_GCC_VERSION < 7000
|
||||
#define SET_DECL_ALIGN(decl, align) DECL_ALIGN(decl) = (align)
|
||||
#define SET_DECL_MODE(decl, mode) DECL_MODE(decl) = (mode)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
8
scripts/gcc-plugins/gen-random-seed.sh
Normal file
8
scripts/gcc-plugins/gen-random-seed.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ ! -f "$1" ]; then
|
||||
SEED=`od -A n -t x8 -N 32 /dev/urandom | tr -d ' \n'`
|
||||
echo "const char *randstruct_seed = \"$SEED\";" > "$1"
|
||||
HASH=`echo -n "$SEED" | sha256sum | cut -d" " -f1 | tr -d ' \n'`
|
||||
echo "#define RANDSTRUCT_HASHED_SEED \"$HASH\"" > "$2"
|
||||
fi
|
1028
scripts/gcc-plugins/randomize_layout_plugin.c
Normal file
1028
scripts/gcc-plugins/randomize_layout_plugin.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue