criu/gen-offsets.sh
Kir Kolyshkin ce7780179b gen-offsets.sh: error out if something goes wrong
In addition, add target rm if script has failed.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 12:12:17 +04:00

35 lines
478 B
Bash

#!/bin/sh
set -e
set -u
NAME=$1
INC_GUARD=__${NAME}_h__
PREFIX=${NAME}_blob_offset__
BLOB=${NAME}_blob
OBJNAME=${NAME}.o
BINARY=${NAME}.bin
AWK_CMD='$2 ~ /^[tT]$/ { print "#define '$PREFIX'" $3 " 0x" $1; }'
cat << EOF
/* Autogenerated by $0, do not edit */
#ifndef $INC_GUARD
#define $INC_GUARD
EOF
nm $OBJNAME | tr . _ | awk "$AWK_CMD"
cat << EOF
static char $BLOB[] = {
EOF
hexdump -v -e '"\t" 8/1 "0x%02x, " "\n"' $BINARY
cat << EOF
};
#endif /* $INC_GUARD */
EOF