Hi,
I'm in an OS course at university and am trying to implement a few extra features for fun. The OS is coded in C.
Our OS is just a guest on a host OS and we don't deal with hardware.
My aim is to load echo.so stored on the guest OS filesystem using libdl or something similar in order to run 'programs' that aren't hard-coded into our OS.
I know it's not quite how real OSes work but most teams are just hardcoding.
Currently I am loading echo.so from the host OS memory but this isn't quite as neat!
Loading of dynamic library in guest os
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: Loading of dynamic library in guest os
What exactly is the relationship between the host and guest? Is the host running some sort of VM containing the guest, or is it just running a process containing the guest?
Re: Loading of dynamic library in guest os
It's just a process within the host OS, using ucontexts to emulate multiple processes within.
Re: Loading of dynamic library in guest os
This does not make any sense. How is that an OS then? You cannot directly load the echo.so from the disk because of protection. The only way you can do it is use the host system functions, which is against the point.
- Griwes
- Member
- Posts: 374
- Joined: Sat Jul 30, 2011 10:07 am
- Libera.chat IRC: Griwes
- Location: Wrocław/Racibórz, Poland
- Contact:
Re: Loading of dynamic library in guest os
I think this doesn't quite match the definition of an OS:Our OS is just a guest on a host OS and we don't deal with hardware.
An operating system (OS) is a collection of software that manages computer hardware resources and provides common services for computer programs.
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
Re: Loading of dynamic library in guest os
We're emulating hardware so we have a loopback filesystem and we have to write our own driver. We have to manage file descriptors that point to different sorts of fake 'physical objects'.
The difference is we're not managing real physical hardware. If not strictly OS coding it would be closer to it than anything else.
The difference is we're not managing real physical hardware. If not strictly OS coding it would be closer to it than anything else.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Loading of dynamic library in guest os
Bottom line, its an academic kludge meant to teach the concepts without ever getting close to being the real thing as well as keeping the local sysadmins in peaceful mode.
I'm not too familiar with dylib, but either you load the .so from the fake filesystem into memory and find a way to pass it to dylib instead of having it load it from the non-fake filesystem on its own, or you manually parse the file and shove its bits into memory at the desired locations. Which options are actually viable probably depends on the actual wording of the assignment.
I'm not too familiar with dylib, but either you load the .so from the fake filesystem into memory and find a way to pass it to dylib instead of having it load it from the non-fake filesystem on its own, or you manually parse the file and shove its bits into memory at the desired locations. Which options are actually viable probably depends on the actual wording of the assignment.
Re: Loading of dynamic library in guest os
Thanks anyway! The spec is open to us to do whatever we want really, and I just thought it would be cool to have this done. Sorry to bother you all!