-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmk_elf_loader
executable file
·88 lines (64 loc) · 2.84 KB
/
mk_elf_loader
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
rm /tmp/tcc_js_tmp/elf_*exe /tmp/tcc_js_tmp/tcc_boot.o /tmp/tcc_js_tmp/elf_test.o
cd tcc_js
echo "building test file"
/tmp/tcc_js_tmp/tcc_10 -o /tmp/tcc_js_tmp/elf_test.o -c elf_test.c
cp bootstrappable_load.c /tmp/tcc_js_tmp/
cp bootstrap_load.c /tmp/tcc_js_tmp/
cat elf_loader_support.c elf_loader_support_cc_x86.c elf_loader.c > /tmp/tcc_js_tmp/elf_loader_all.c
# echo "building with tcc_1_7"
# /tmp/tcc_js_tmp/tcc_1_7 -r elf_loader.c --help
# mv tcc_boot.o /tmp/tcc_js_tmp/
echo "building with tcc"
tcc elf_loader.c -o /tmp/tcc_js_tmp/elf_loader_tcc.exe
echo "building with gcc"
gcc -O0 -g -c elf_loader.c -o elf_loader_gcc.o
tcc -g elf_loader_gcc.o -o /tmp/tcc_js_tmp/elf_loader_gcc.exe
rm elf_loader_gcc.o
echo "building with gcc dbg"
gcc -O0 -g -c elf_loader.c -o elf_loader_gcc.o
gcc -g elf_loader_gcc.o -o /tmp/tcc_js_tmp/elf_loader_gcc_dbg.exe
rm elf_loader_gcc.o
cd ..
cp ../mishmashvm/tcc_js_bootstrap/alt_bootstrap/stage0-posix/M2libc/x86/libc-core.M1 /tmp/tcc_js_tmp/
cp ../mishmashvm/tcc_js_bootstrap/alt_bootstrap/stage0-posix/x86/ELF-i386.hex2 /tmp/tcc_js_tmp/
cp ../mishmashvm/tcc_js_bootstrap/alt_bootstrap/stage0-posix/x86/x86_defs.M1 /tmp/tcc_js_tmp/
pushd .
cd /tmp/tcc_js_tmp/
rm out_cc_x86-0.M1 out_cc_x86-0.hex2 out_cc_x86-0-0.hex2 elf_loader_cc_x86.exe
set -e
cat bootstrap_load.c bootstrappable_load.c elf_loader_all.c > out.c
echo "M2 compile"
./M2 --architecture x86 --bootstrap-mode -f out.c -o out_M2.M1
echo "M2 assemble and link"
cat x86_defs.M1 libc-core.M1 out_M2.M1 > out_M2-0.M1
./M0 out_M2-0.M1 out_M2-0.hex2
cat ELF-i386.hex2 out_M2-0.hex2 > out_M2-0-0.hex2
./hex2-0 out_M2-0-0.hex2 elf_loader_m2.exe
echo "cc_x86 compile"
./cc_x86 out.c out_cc_x86.M1
echo "cc_x86 assemble and link"
cat x86_defs.M1 libc-core.M1 out_cc_x86.M1 > out_cc_x86-0.M1
./M0 out_cc_x86-0.M1 out_cc_x86-0.hex2
cat ELF-i386.hex2 out_cc_x86-0.hex2 > out_cc_x86-0-0.hex2
./hex2-0 out_cc_x86-0-0.hex2 elf_loader_cc_x86.exe
tcc elf_test.o -o elf_test.exe
# echo "==================================================================="
# echo "running elf loader compiled by tcc_1_7"
# ./loader_cc_x86.exe -R dummy --help
echo "==================================================================="
echo "running elf loader compiled by tcc (0.9.27)"
./elf_loader_tcc.exe --help
echo "==================================================================="
echo "running elf loader compiled by gcc"
./elf_loader_gcc.exe --help
echo "==================================================================="
echo "running elf loader compiled by cc_x86"
./elf_loader_cc_x86.exe --help
echo "==================================================================="
echo "running elf loader compiled by M2-Planet"
./elf_loader_m2.exe --help
echo "==================================================================="
echo "run the elf_test file"
./elf_test.exe
sha256sum elf*exe
sha256sum tcc_boot.o