forked from notaz/ia32rtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_mkpubinc.sh
executable file
·48 lines (41 loc) · 984 Bytes
/
run_mkpubinc.sh
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
#!/bin/sh
set -e
public_inc=$1
asm=$2
c_list=$3
echo -n > $public_inc
cat $asm | fromdos | sed -e \
'1,/^_rdata.*segment/d;/^_data.*\<ends\>/q;/^[[:blank:];]/d;/^;/d;/^_r\?data\>/d;' | awk '{print $1}' | \
while read a; do
test -z "$a" && continue
case $a in
__IMPORT_DESCRIPTOR*)
continue
;;
_data)
continue
;;
*)
;;
esac
echo "_$a equ $a" >> $public_inc
echo "PUBLIC _$a" >> $public_inc
done
if test -n "$c_list"; then
# make a list of functions in asm
grep '\<endp\>' $asm | awk '{print $1}' | grep -v '\<rm_' \
> ${asm}_funcs || true
echo "; funcs called from C" >> $public_inc
cat $c_list | \
while read a; do
name=`echo $a | awk -F@ '{print $1}'`
n=`grep "\<$name\>" ${asm}_funcs` || \
n=`grep "\<_$name\>" ${asm}_funcs` || true
if test -z "$n"; then
echo "\"$name\" is expected to be in asm, but was not found"
rm $public_inc
exit 1
fi
echo "PUBLIC $n" >> $public_inc
done
fi