Kernel Executable format

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.
adw3221
Posts: 18
Joined: Thu Aug 31, 2006 11:02 am

Kernel Executable format

Post by adw3221 »

I am going to use virtual memory and paging for my OS and some people reccomended I use an executable format instead of plan binary. My operating system is going to be portible across architectures such as the i386+, 68020+, DEC Alpha, MIPS R4000+ and the PowerPC so I would like to keeps thins orginized.

I want to have virtual memory, paging, PNP and the like. I'm really considering taking the microkernel approch but a monlithic kernel is still on the table.

Right now my kernel is being compiled into plan binary format using JLOC. I'm using NASM 0.98 and Watcom C/C++ which at first were a pain to use but thanks to Ryu making an OBJ patcher for FIXUPP (They use the OMF object file) things run ok. I have no memory manager which brings me here. Because I'm using virtual memory and paging I'm going to have to relocate my kernel (its the most logical thing to do) however being the person that I am I like to plan things out in advance so I don't hit road blocks later on. The Watcom linker can do the MZ or PE executable format but I could use the GCC LD Linker (Does that accpect OMFs) for another executable format.

I'm also going to need to code my bootloader to load the kernel and when it comes to loading executables and relocation I'm lost.

If anyone can help me at all that would be great I'm really lost when it comes to this stuff :P
niteice
Member
Member
Posts: 59
Joined: Tue Oct 03, 2006 3:49 pm

Post by niteice »

I think ELF would be good, as the spec is open and it doesn't seem terribly hard to implement. Plus it's fully designed for portability.
adw3221
Posts: 18
Joined: Thu Aug 31, 2006 11:02 am

Post by adw3221 »

ELF sounds good then. I guess the GCC LD linker can output to that format? What input object files does it take?
User avatar
gaf
Member
Member
Posts: 349
Joined: Thu Oct 21, 2004 11:00 pm
Location: Munich, Germany

Post by gaf »

ELF sounds good then. I guess the GCC LD linker can output to that format?
In general you'll have to compile a gcc toolchain for OS development. Before building this compiler target platform and output-format can be choosen. GCC supports a wide range of architecures and should run on most of those mentioned by you. Choosing ELF as the file-format sounds like a reasonable idea.

a) Install Cygwin on your system
b) Create a toolchain for your target

I remember that we already talked about this some time ago (link). The precompiled binaries I uploaded back then should still be available if you want to avoid building it youself.
What input object files does it take?
Everything but OMF ;)

The format is really old and never was much more than an extention to its 16bit predecessor. You might just update your compiler and use some more modern and powerful object-file format (ELF, COFF, PE). Have a look at the osfaq for a list of supported input formats.
Because I'm using virtual memory and paging I'm going to have to relocate my kernel
But your kernel already gets relocated to offset 0x10000 ? There are many reasons to use a proper binary-format but it's certainly not needed for virtual-addressing.

Why do you think that paging couldn't be used with a binary kernel ?

regards,
gaf
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

gaf wrote:
What input object files does it take?
Everything but OMF ;)
That's a pretty dangerous thing to say ;)
TheQuux
Member
Member
Posts: 73
Joined: Sun Oct 22, 2006 6:49 pm

Post by TheQuux »

gaf wrote:
What input object files does it take?
Everything but OMF ;)
RODFF?
User avatar
smiddy
Member
Member
Posts: 127
Joined: Sun Oct 24, 2004 11:00 pm
Location: In my cube, like a good leming. ;-)

Post by smiddy »

Unless you want to design in management of executeables, I would recommend a flatfile model, like a COM or similar, perhaps with a header that gives the expected memory needs and go from there. There's no need to get complicated unless you want to.
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

Post by kataklinger »

Well it would be good for your kernel to be in some executable format if you want to export symbols from it (you can build kernel as DLL) and save some time.
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Post by carbonBased »

TheQuux wrote:
gaf wrote:
What input object files does it take?
Everything but OMF ;)
RODFF?
You mean RDOFF[2]?

I don't believe ld supports this format, no. However, I've worked with the rdoff2 object format. It's pretty straightforward and simple (the design goal), so adding it into ld probably wouldn't be difficult.

--Jeff
adw3221
Posts: 18
Joined: Thu Aug 31, 2006 11:02 am

Post by adw3221 »

Wow thank you I will look into these. Is there an object library convertor? :P
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Post by carbonBased »

Mike359 wrote:Wow thank you I will look into these. Is there an object library convertor? :P
objcopy can be used to perform some format conversions. This is available on most linux distributions, and probably most cygwin distribs, as well.

--Jeff
martin.zielinski
Posts: 5
Joined: Mon Nov 06, 2006 2:40 pm
Location: Germany

Post by martin.zielinski »

I you're developing on windows, it should be most conveniant to use the PE format. This can be easily loaded by your booloader and a bit easier by grub.

I've built an PE loader into my os-project too and it makes the development workflow a lot smoother when you can work with the tools that you are used to, and not with tools that you _must_ choose because of a specific needed output format. In my opinion this should be the most importent base for the decision which binary format you want to use. Base it on the tools you are conveniant with and which your are used to, and than invest the little work to load your choosen format as is.

This will be the right thing in the long run.
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Post by carbonBased »

martin.zielinski wrote:I you're developing on windows, it should be most conveniant to use the PE format. This can be easily loaded by your booloader and a bit easier by grub.

I've built an PE loader into my os-project too and it makes the development workflow a lot smoother when you can work with the tools that you are used to, and not with tools that you _must_ choose because of a specific needed output format. In my opinion this should be the most importent base for the decision which binary format you want to use. Base it on the tools you are conveniant with and which your are used to, and than invest the little work to load your choosen format as is.

This will be the right thing in the long run.
While I definitely agree with your logic, I'd just like to toss out there that, imo, ELF is superior to PE. If ELF interests you, you might want to start with PE and then transition to ELF (forgive me if this is what your last point is saying, I wasn't entirely sure).

Cheers,
Jeff
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:

Post by Combuster »

PE is a complex beast, and for what i've seen the documentation isnt really good. ELF however has a good formal specification, and compared to PE its relatively easy to use. The app that loads, relocates, and starts ELF executables in my os is just over 1.8kb

If you're used to GCC, you can build an ELF cross-compiler in 15 minutes.

As for the tool argument, some IDEs allow you to choose/configure for a specific compiler/target. If you are used to Visual Studio however, then you might indeed want to stick to PE as its afaik the only thing it'll do properly.
"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 ]
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

As for the tool argument, some IDEs allow you to choose/configure for a specific compiler/target. If you are used to Visual Studio however, then you might indeed want to stick to PE as its afaik the only thing it'll do properly.
correction:
PE is the only format the MS compiler/linker will easily handle

if you want, you can use the visual studio IDE with GCC or any other command line compiler
Post Reply