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:
Justine Tunney 2020-08-25 04:23:25 -07:00
parent 467504308a
commit f4f4caab0e
1052 changed files with 65667 additions and 7825 deletions

View file

@ -24,6 +24,39 @@
#define vzeroupper
#endif
/ Begins definition of frameless function that calls no functions.
.macro .leafprologue
#if !(defined(TINY) && !defined(__PG__))
push %rbp
mov %rsp,%rbp
#endif
.endm
/ Ends definition of frameless function that calls no functions.
.macro .leafepilogue
#if !(defined(TINY) && !defined(__PG__))
pop %rbp
#endif
ret
.endm
/ Good alignment for functions where alignment actually helps.
/ @note 16-byte
.macro .alignfunc
#ifndef __OPTIMIZE_SIZE__
.p2align 4
#endif
.endm
/ Good alignment for loops where alignment actually helps.
/ @note 16-byte if <10 padding otherwise 8-byte
.macro .alignloop
#ifndef __OPTIMIZE_SIZE__
.p2align 4,,10
.p2align 4
#endif
.endm
/ Loads Effective Address
/ Supporting security blankets
.macro plea symbol:req reg64:req reg32:req
@ -48,7 +81,7 @@
/ Loads Effective Address
/ Supporting security blankets
.macro ezlea symbol:req reg:req
#if __PIC__ + __PIE__ + __code_model_medium__ + __code_model_large__ + 0 > 1
#if __pic__ + __pie__ + __code_model_medium__ + __code_model_large__ + 0 > 1
/ lea \symbol(%rip),%r\reg
mov $\symbol,%e\reg
#else
@ -71,22 +104,6 @@
xor %ebp,%ebp
.endm
/ Begins definition of frameless function that calls no functions.
.macro .leafprologue
#if !(defined(TINY) && !defined(__PG__))
push %rbp
mov %rsp,%rbp
#endif
.endm
/ Ends definition of frameless function that calls no functions.
.macro .leafepilogue
#if !(defined(TINY) && !defined(__PG__))
pop %rbp
#endif
ret
.endm
/ Pulls source code file into ZIP portion of binary.
/
/ @param symbol is quoted path relative to root e.g. __FILE__