How to emulate Linux program?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
danaprakoso5
Posts: 2
Joined: Mon Jun 04, 2018 9:39 pm

How to emulate Linux program?

Post by danaprakoso5 »

Hello, I am a beginner OS developer and I want to know how to emulate Linux program? I want to port some nice program for Linux. I already created simple Linux program to display text using printf() function, and then I compile it with GCC for Linux, now how can I make the text be displayed in screen of emulator (same as writing text to memory address 0xB8000)?? Thanks.
pat
Member
Member
Posts: 36
Joined: Tue Apr 03, 2018 2:44 pm
Libera.chat IRC: patv

Re: How to emulate Linux program?

Post by pat »

I'm confused, do you want to emulate or port? Emulating means you don't change the program but instead modify your OS to provide a similar-ish environment that the program expects, while porting means you modify the program itself to work in your OS. Assuming the former, that depends greatly on how far along your OS is, so we need more details. You're going to need an ELF loader and support the system calls the program expects, some amount of libc unless the program was statically linked etc. Tell us more about the state of your OS and what you're trying to do.
Image is my operating system.

"...not because [it is] easy, but because [it is] hard; because that goal will serve to organize and measure the best of [my] energies and skills..."
m712
Posts: 8
Joined: Wed Feb 22, 2017 4:57 pm
Libera.chat IRC: m712

Re: How to emulate Linux program?

Post by m712 »

From what I can gather, he wants to port a program that prints hello world, that he wrote in Linux to an x86 emulator. I recommend you start from here before doing anything.
danaprakoso5
Posts: 2
Joined: Mon Jun 04, 2018 9:39 pm

Re: How to emulate Linux program?

Post by danaprakoso5 »

I mean, how to run Linux program (that is already compiled in Linux machine) to run in my OS?
simeonz
Member
Member
Posts: 360
Joined: Fri Aug 19, 2016 10:28 pm

Re: How to emulate Linux program?

Post by simeonz »

danaprakoso5 wrote:I mean, how to run Linux program (that is already compiled in Linux machine) to run in my OS?
You need to have a dynamic linker/loader that is capable of loading elf files, as well as versions of the dynamic libraries that the executable uses, built for your platform, but binary compatible with the originals. The latter includes the libc library at minimum, but may include many others - libnss, libgcc, etc.
Post Reply