mirror of
https://github.com/LIV2/libnix.git
synced 2025-12-06 00:23:08 +00:00
103 lines
2.6 KiB
Bash
Executable File
103 lines
2.6 KiB
Bash
Executable File
#!/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 |