Add x86_64-linux-gnu emulator
I wanted a tiny scriptable meltdown proof way to run userspace programs and visualize how program execution impacts memory. It helps to explain how things like Actually Portable Executable works. It can show you how the GCC generated code is going about manipulating matrices and more. I didn't feel fully comfortable with Qemu and Bochs because I'm not smart enough to understand them. I wanted something like gVisor but with much stronger levels of assurances. I wanted a single binary that'll run, on all major operating systems with an embedded GPL barrier ZIP filesystem that is tiny enough to transpile to JavaScript and run in browsers too. https://justine.storage.googleapis.com/emulator625.mp4
This commit is contained in:
1 parent
467504308a
commit
f4f4caab0e
1052 files changed
+65667
-7825
No files matched your search
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
set -ex
|
||||
|
||||
rm -f o/ansi/.cosmopolitan.h o/ansi/cosmopolitan.h
|
||||
make -j12 o/ansi/cosmopolitan.h MODE=ansi
|
||||
make -j12 o//libc/crt/crt.o o//ape/ape.o o//ape/ape.lds
|
||||
make -j12 o//cosmopolitan.a
|
||||
|
||||
rm -rf o/cosmo
|
||||
mkdir -p o/cosmo
|
||||
cp o//ape/ape.o \
|
||||
o//ape/ape.lds \
|
||||
o//libc/crt/crt.o \
|
||||
o//cosmopolitan.a \
|
||||
o/cosmo
|
||||
{
|
||||
echo '#ifndef COSMOPOLITAN_H_'
|
||||
echo '#define COSMOPOLITAN_H_'
|
||||
echo '#ifdef __cplusplus'
|
||||
echo 'extern "C" {'
|
||||
echo '#endif'
|
||||
cat o/ansi/cosmopolitan.h
|
||||
echo '#ifdef __cplusplus'
|
||||
echo '} /* extern C */'
|
||||
echo '#endif'
|
||||
echo '#endif /* COSMOPOLITAN_H_ */'
|
||||
} >o/cosmo/cosmopolitan.h
|
||||
cd o/cosmo
|
||||
|
||||
cat <<EOF >HELLO.C
|
||||
int main(int argc, char *argv[]) {
|
||||
printf("hello world\n");
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
gcc -O -s -static -nostdlib -nostdinc \
|
||||
-Wl,-T,ape.lds -include cosmopolitan.h \
|
||||
-o HELLO.COM.DBG HELLO.C crt.o ape.o cosmopolitan.a
|
||||
|
||||
objcopy -SO binary HELLO.COM.DBG HELLO.COM
|
||||
ls -hal ./HELLO.COM
|
||||
./HELLO.COM
|
||||
Reference in new issue
Block a user