summaryrefslogtreecommitdiffstats
path: root/scripts/gcc-plugins/gen-random-seed.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gcc-plugins/gen-random-seed.sh')
-rw-r--r--scripts/gcc-plugins/gen-random-seed.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/gcc-plugins/gen-random-seed.sh b/scripts/gcc-plugins/gen-random-seed.sh
new file mode 100644
index 000000000000..7514850f4815
--- /dev/null
+++ b/scripts/gcc-plugins/gen-random-seed.sh
@@ -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