Fix bugs and have emulator emulate itself

This commit is contained in:
Justine Tunney 2020-08-31 05:17:31 -07:00
parent 5aabacb361
commit bd29223891
111 changed files with 1283 additions and 2073 deletions

View file

@ -20,8 +20,11 @@
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/ex.h"
#include "libc/sysv/consts/fileno.h"
#include "libc/x/x.h"
#include "tool/build/lib/loader.h"
#include "tool/build/lib/machine.h"
#include "tool/build/lib/syscall.h"
struct Machine m[1];
@ -38,6 +41,15 @@ int main(int argc, char *argv[]) {
}
InitMachine(m);
LoadProgram(m, argv[1], argv + 2, environ, &elf);
m->fds.i = 3;
m->fds.n = 8;
m->fds.p = xcalloc(m->fds.n, sizeof(struct MachineFd));
m->fds.p[0].fd = STDIN_FILENO;
m->fds.p[0].cb = &kMachineFdCbHost;
m->fds.p[1].fd = STDOUT_FILENO;
m->fds.p[1].cb = &kMachineFdCbHost;
m->fds.p[2].fd = STDERR_FILENO;
m->fds.p[2].cb = &kMachineFdCbHost;
if (!(rc = setjmp(m->onhalt))) {
for (;;) {
LoadInstruction(m);