-
Notifications
You must be signed in to change notification settings - Fork 9
/
preplib
executable file
·103 lines (92 loc) · 2.59 KB
/
preplib
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
#
# create the def file for the library
# run it in the libb folder
find nix -name "*.o" \
-not -name cxxglue.o \
-not -name __eprintf.o \
-not -name assert.o \
-not -name ldiv.o \
-not -name fprintf.o \
-not -name fscanf.o \
-not -name printf.o \
-not -name scanf.o \
-not -name snprintf.o \
-not -name sprintf.o \
-not -name sscanf.o \
-not -name tmpfile.o \
-not -name tmpnam.o \
-not -name vfprintf.o \
-not -name vfscanf.o \
-not -name vprintf.o \
-not -name vscanf.o \
-not -name vsnprintf.o \
-not -name vsprintf.o \
-not -name vsscanf.o \
-not -name __vfprintf_total_size.o \
-not -name __vwfprintf_total_size.o \
-not -name tmpfile.o \
> ofiles.txt
find nix20 -name "*.o" \
-not -name swapstack.o \
-not -name __nocommandline.o \
>> ofiles.txt
find nixmain -name "*.o" >> ofiles.txt
find math -name "*.o" >> ofiles.txt
# all function names
rm -f all.def
while IFS="" read -r p || [ -n "$p" ]
do
m68k-amigaos-objdump -t "$p" | grep " 0000 01" | grep " .text" | xargs -0 | grep .text | awk '{print $6;}' >> all.def
done < ofiles.txt
cat all.def | grep . | sort > alls.def
# check for duplicates
uniq -d alls.def
# find all using some Base or internal variables
rm -f tainted.txt
while IFS="" read -r p || [ -n "$p" ]
do
x=$(m68k-amigaos-objdump -t "$p" | grep ' 0001 86\| 0000 21')
if [ "$x" != "" ]; then
m68k-amigaos-objdump -t "$p" | grep " 0000 01" | xargs -0 | awk '{print $6;}' | grep . >> tainted.txt
fi
done < ofiles.txt
fs=0
while [ $fs != $(stat --printf="%s" tainted.txt) ]; do
fs=$(stat --printf="%s" tainted.txt)
echo $fs
cp tainted.txt tainted2.txt
while IFS="" read -r p || [ -n "$p" ]
do
x=$(m68k-amigaos-objdump -t "$p" | grep -f tainted.txt)
if [ "$x" != "" ]; then
m68k-amigaos-objdump -t "$p" | grep " 0000 01" | xargs -0 | awk '{print $6;}' | grep . >> tainted2.txt
fi
done < ofiles.txt
cat tainted2.txt | grep . | sort -u > tainted.txt
rm -f tainted2.txt
done
# write libnix.def
rm -f libnix.def
while IFS="" read -r p || [ -n "$p" ]
do
if [ "$(grep $p tainted.txt)" == "" ]
then
echo .direct $p >> libnix.def
else
echo .text $p >> libnix.def
fi
done < alls.def
rm -f all.def
rm -f alls.def
rm -f tainted.txt
rm -f tainted2.txt
echo ".data ___sF" >>libnix.def
echo ".data ___errno" >>libnix.def
echo ".data __ctype_" >>libnix.def
echo ".data _environ_ptr" >>libnix.def
echo ".data ___timezone" >>libnix.def
echo ".data ___daylight" >>libnix.def
echo ".data ___tzname" >>libnix.def
echo ".data ___decimalpoint" >>libnix.def
echo ".data __impure_ptr" >>libnix.def