Loading of dynamic library in guest os

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
shaananc
Posts: 4
Joined: Fri Nov 02, 2012 10:18 am

Loading of dynamic library in guest os

Post by shaananc »

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!
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: Loading of dynamic library in guest os

Post by NickJohnson »

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?
shaananc
Posts: 4
Joined: Fri Nov 02, 2012 10:18 am

Re: Loading of dynamic library in guest os

Post by shaananc »

It's just a process within the host OS, using ucontexts to emulate multiple processes within.
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: Loading of dynamic library in guest os

Post by mariuszp »

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.
User avatar
Griwes
Member
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

Post by Griwes »

Our OS is just a guest on a host OS and we don't deal with hardware.
I think this doesn't quite match the definition of an OS:
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
shaananc
Posts: 4
Joined: Fri Nov 02, 2012 10:18 am

Re: Loading of dynamic library in guest os

Post by shaananc »

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.
User avatar
Combuster
Member
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

Post by Combuster »

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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
shaananc
Posts: 4
Joined: Fri Nov 02, 2012 10:18 am

Re: Loading of dynamic library in guest os

Post by shaananc »

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!
Post Reply