criu/pie/gen-offsets.sh
Pavel Emelyanov b8d0d5e779 parasite: Make parasite arguments variable size
Sometimes we don't know the exact amount of data we would want
to send to parasite via args area (e.g. -- while draining fds).

Fix this, by moving the args area behind the parasite blob and
mmap-ing it with the run-time calculated size.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:11:28 +04:00

36 lines
528 B
Bash

#!/bin/sh
set -e
set -u
FILE=$1
NAME=$2
INC_GUARD=__${NAME}_h__
PREFIX=${NAME}_blob_offset__
BLOB=${NAME}_blob
OBJNAME=${FILE}.built-in.bin.o
BINARY=${FILE}.built-in.bin
AWK_CMD='$2 ~ /^[tTA]$/ { print "#define '$PREFIX'" $3 " 0x" $1; }'
cat << EOF
/* Autogenerated by $0, do not edit */
#ifndef $INC_GUARD
#define $INC_GUARD
EOF
nm $OBJNAME | grep "__export_" | 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