Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run a Linux binary under emulation #626

Open
alexis-jaksone opened this issue Feb 22, 2022 · 3 comments
Open

Run a Linux binary under emulation #626

alexis-jaksone opened this issue Feb 22, 2022 · 3 comments

Comments

@alexis-jaksone
Copy link

I was wondering if this is doable to run an x86 Linux binary directly using v86. Somthing like qemu-i386 or box86.

@copy
Copy link
Owner

copy commented Feb 22, 2022

It's technically possible, but would be quite a bit of work. I would gladly provide some pointers or review a pull request, but I don't have time to work on something big at the moment.

@alexis-jaksone
Copy link
Author

That would be great to have some pointers

@copy
Copy link
Owner

copy commented Feb 23, 2022

Sure!

  • This is the entry point for legacy system calls (int 0x80), and page faults, general protection error, etc. The latter you'll need to turn into signals. Here is the modern syscall instruction. You can just change the code and implement system calls in place for now, and we'll later figure out how to factorise the code to implement either hardware emulation or Linux syscalls.
  • For mmap/brk you probably want to use regular paging since that's what v86 implements efficiently (wasm doesn't have mmap anyway). Just initialise cr0 and cr3 like on a real OS.
  • There's a crude elf parser in src/elf.js that you can use as a starting point. I'd recommend starting with static executables and see if some changes in the elf parser or loader are necessary (most likely yes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants