DLL's

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

DLL's

Post by lukem95 »

Do you have DLL's (dynamic link library) in your OS? i want to implement a format with that can use DLL's (PE or ELF are the only two i know) and wondered if anyone had got this working, any hints/tips etc before i start?
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post by einsteinjunior »

Hi,

Actually i am using the windows PE file format in my OS.
The Dlls are mostly used as modules containing exported functions that i dynamically load(used mostly for my device drivers).
Unfortunately the web pages are not yet finished so you can chek out the source code.
But i will recommend you to read this :
http://win32assembly.online.fr/tutorials.html
The section on the PE file format helped me quite a lot in understanding.
I will try and write some tutorial on it.Nut if you are still too new in the os design business then go for the elf executable format.It also supports dynamical loadind and is easier than the PE executable format.
Good luck.
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

Im still fairly new, but have been fiddling around for almost a year or so.

I'll give that link a look. Im going to use the DLL's for the same reason you do, so that i can use my drivers in a more extensible manner.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post by einsteinjunior »

Hi,
Try the elf executable file format.
Its easier than all of the rest.
Ready4Dis
Member
Member
Posts: 571
Joined: Sat Nov 18, 2006 9:11 am

Post by Ready4Dis »

einsteinjunior wrote:Hi,
Try the elf executable file format.
Its easier than all of the rest.
I use coff in my kernel right now, it's pretty simple to understand, and I can link files in memory easily. Many files are useable, coff, a.out (which also supports 16 and 32-bit relocations if you plan on doing any vm86 work), elf (which has a 64-bit version for x86-64 cpu's, as well as the standard 32-bit version), pe (dll files are simply PE files with a specific format if i'm not mistaken), .obj files... pretty much just look around, and pick one that suits your needs. I will probably end up using a custom format when i'm done, and finish up my linker to support a.out, coff, elf32/64, etc and have my file format support 16,32 and 64-bit relocations, since no one format will do that for you, and it will be easy for me to strip useless information out of the files (like unused symbols, larger than required headers, i don't care what the file name's where when i compiled it so i can remove those symbols, etc).
As a note, a lot of people tend to use ELF because it's supported by GRUB, and is documented pretty well (or so I hear), the djgpp coff is pretty well documented as well (which is what i used to implement my reolocation and linking code).
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post by einsteinjunior »

Please can you provide me with some informations or links on the coff file format?
I am also doing some comparisons about executable file formats.
I want some more infos apart from what i got.
Ready4Dis
Member
Member
Posts: 571
Joined: Sat Nov 18, 2006 9:11 am

Post by Ready4Dis »

einsteinjunior wrote:Please can you provide me with some informations or links on the coff file format?
I am also doing some comparisons about executable file formats.
I want some more infos apart from what i got.
I typed djgpp coff file format into google, and it is the first link.
http://www.delorie.com/djgpp/doc/coff/

Microsoft uses a similar, but incompatible version of coff, so be careful if trying to use different compilers.

Just another quick link to read up a bit, and find some info on formats, has a listing of the most popular, and some links to specs.
http://my.execpc.com/~geezer/osd/exec/
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

im looking into dynamic-elf's, plus this means i can load static elfs for my Apps, rather than flat binary (which is my temporary method).

The geezer resource was very useful, that site/collection is awesome :)
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

Well (after a long break) i have gotten static ELF relocation working, i wrote the base for my code a while ago, and after a month or so break from my OS (for revision) i completed the code in about 10-15 minutes. It was remarkably easy.

I'm going to start on symbol table stuff, along with the import/export tables now. I'll post back if i have any ideas etc.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
svdmeer
Member
Member
Posts: 87
Joined: Tue May 06, 2008 9:32 am
Location: The Netherlands

Post by svdmeer »

For everyone interested in shared libraries and dynamic linking, this documentation is great: http://www.iecc.com/linker/
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post by einsteinjunior »

Yes the document comes from the book linkers and loaders.
Very nice book.You may download a copy of it at gigapedia.org
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

Has any body got dynamic linking working with the ELF format? i am struggling to see where to start with this step :S
~ Lukem95 [ Cake ]
Release: 0.08b
Image
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

lukem95 wrote:Has any body got dynamic linking working with the ELF format? i am struggling to see where to start with this step :S
Just a quick question - why do you need dynamic linking? Are you wanting it to load modules/drivers or dynamic libraries. There's a (huge) difference ;).

EDIT: But in the context of this thread, I'm going to assume dynamic libraries.

You need to keep track of all SOs loaded, where they are, etc... When loading a binary, you look in the .dyn section (which has a heap of information) and work to relocate the symbols to libraries that are in memory at that point in time.

NewOS's source code is a highly suggested read if you're stuck on dynamic linking.
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

well i was planning to use it for my drivers actually... i was going to have a common set of functions my drivers need to implement, and from that call them using their exported functions.

I shall read NewOS's source, iv just been through the specification for the nth time, and it seemed slightly clearer, i think its going to be one of those trial and error jobs though :)
~ Lukem95 [ Cake ]
Release: 0.08b
Image
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

I personally use relocation of object files (-r on the ld command line) for my drivers - I feel that dynamic linking is overkill. I basically have a "dmain" that gets called and tells the kernel whatever functions need to be exported.

Relocation still has a link step, where you resolve external references (hence it often gets confused with dynamic linking).

SO dynamic linking is more for resolving external references to the SO file, instead of from it.

(Really tired and on a caffeine high at the moment, so this might not make any sense - I'm more than happy to clarify myself if you need it).
Post Reply