-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_list
More file actions
executable file
·85 lines (58 loc) · 1.77 KB
/
process_list
File metadata and controls
executable file
·85 lines (58 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
set -x
count=0
LIST=$1
LIBRARY=$2
H_FILE=$3
AR=ar
OBJCOPY=objcopy
ELF_ARCH=i386:x86-64
ELF_FORMAT=elf64-x86-64
mkdir -p build
rm -f ${LIBRARY} ${H_FILE} build/$$
while read -r file args && [ ! -z "$file" ] ; do
cfn="src/${file}"
fn="build/${file}"
rm -f "$fn"
# we can't do .gz
# tboot can't do .gz
# hopefully xen can
if [ $count -lt 2 ]; then
if ! gzip -d < "$cfn" > "$fn"; then
/bin/cp -f "$cfn" "$fn"
fi
else
/bin/cp -f "$cfn" "$fn"
fi
in_sym=$( echo /binary/${fn} | tr ' ./-' ____ )
sym=$( echo payload/${file} | tr ' ./-' ____ )
${OBJCOPY} -I binary -O ${ELF_FORMAT} -B ${ELF_ARCH} --redefine-sym ${in_sym}_start=${sym}_start --redefine-sym ${in_sym}_end=${sym}_end "${fn}" "build/${file}.o"
${AR} rcs ${LIBRARY} "build/${file}.o"
rm -f "build/${file}.o"
echo "extern uint8_t ${sym}_start[], ${sym}_end[];" >> ${H_FILE}
echo " { \\" >> build/$$
echo " uint64_t len = ((size_t) ${sym}_end) - ((size_t) ${sym}_start); \\" >> build/$$
echo " b = (size_t) ${sym}_start; \\" >> build/$$
echo " /* memcpy((void *) b, ${sym}_start, len); */ \\" >> build/$$
echo " p[${count}].mod_start = (uint32_t) b; \\" >> build/$$
echo " p[${count}].mod_end = (uint32_t) (b + len) ; \\" >> build/$$
echo " /* b += len + 4095; */ \\" >> build/$$
echo " /* b &= ~(4095ULL); */ \\" >> build/$$
if [ -z "$args" ]; then
echo " p[${count}].cmdline = 0; \\" >> build/$$
else
echo " p[${count}].cmdline = (uint32_t) (size_t) (void *) \"${args}\"; \\" >> build/$$
fi
echo " p[${count}].pad = 0; \\" >> build/$$
echo " } \\" >> build/$$
echo "\\" >> build/$$
count=$[ $count + 1]
done < ${LIST}
cat << EOF >> ${H_FILE}
#define PAYLOAD_INIT(p,b) \\
EOF
cat build/$$ >> ${H_FILE}
rm -f build/$$
cat << EOF >> ${H_FILE}
#define PAYLOAD_NUM $count
EOF