Kernel executable formats

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
xxchrisxx

Kernel executable formats

Post by xxchrisxx »

I know there are a few, but which is most common?
What advantages/disadvantages do each of them have have?
Slasher

Re:Kernel executable formats

Post by Slasher »

Em, I think the best thing is to choose a format to suit your needs even if its "outdated". If its the best one for what you want to do then there is no need using anything else.
Your question is vague,advantages and disadvantages depend on what you want to do.
If you tell us your plans then we will be better informed to give points
xxchrisxx

Re:Kernel executable formats

Post by xxchrisxx »

Well I hope that sometime in the future I will have an OS as capable as lets say FreeBSD or Mac OS X. I would need a format that I can use all the way up to that level... but maybe they all are capable of that ???

Other than that though, at this point, I can't say anything more about my OS as it is in it's early stages... maybe I'll need to get back to you.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Kernel executable formats

Post by Candy »

xxchrisxx wrote: Well I hope that sometime in the future I will have an OS as capable as lets say FreeBSD or Mac OS X. I would need a format that I can use all the way up to that level... but maybe they all are capable of that ???

Other than that though, at this point, I can't say anything more about my OS as it is in it's early stages... maybe I'll need to get back to you.
as for this I can only advise you to use a well-supported format, since it allows for more interoperability (compiling on any platform without using a special compiler or cross-compiler). For that I'd advise ELF since I use it myself :D but I hear PE is also quite well supported (more than ELF by some commercial compilers) so you might want to choose either of those.

If you're going to make your own compiler or something like that, you can devise your own, but not until you look at all the others you can find and explain exactly what is wrong with them.
xxchrisxx

Re:Kernel executable formats

Post by xxchrisxx »

Thanks Candy, I'm using ELF myself at the moment ;D
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Kernel executable formats

Post by Pype.Clicker »

One of the nice things that ELF offers for OS dev' is that it supports custom sections, which means that you can - for instance - have an "kinit" section which will collect {"module name", init function pointer, init level} structures from many places in the system and build a system initialisation table that you can parse easily at boot time.

To get the same functionnality with COFF, i had to write a small program that scanned sources for specially-formatted comments, which is imho much less elegant :(
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Kernel executable formats

Post by Candy »

As for that, that's exactly what I was planning on doing. It's just that, up to now, I haven't been able to find a nice way to tell GCC to put a certain function in a different section...

Do you have any ideas?
chris

Re:Kernel executable formats

Post by chris »

@Pype.Clicker, why do you use COFF instead of ELF?
Chris Giese

Re:Kernel executable formats

Post by Chris Giese »

Candy wrote: It's just that, up to now, I haven't been able to find a nice way to tell GCC to put a certain function in a different section...
http://my.execpc.com/~geezer/osd/misc/index.htm#discard

__attribute__((section ("FOO"))) works with DJGPP (COFF), MinGW (Win32 PE COFF), and GCC for Linux (ELF).
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Kernel executable formats

Post by Candy »

Thanks :D
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Kernel executable formats

Post by Pype.Clicker »

chris wrote: @Pype.Clicker, why do you use COFF instead of ELF?
i used to use COFF because it was the only supported thing under DJGPP (afaik) when i started my project. Now, i can use either ELF or COFF, and the last time i tried it (gcc 2.59.3), gcc (or maybe it was LD) refused the 'section("FOO")' thing, saying that freely named sections was not valid in COFF ...
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Kernel executable formats

Post by Candy »

Pype.Clicker wrote:
chris wrote: @Pype.Clicker, why do you use COFF instead of ELF?
i used to use COFF because it was the only supported thing under DJGPP (afaik) when i started my project. Now, i can use either ELF or COFF, and the last time i tried it (gcc 2.59.3), gcc (or maybe it was LD) refused the 'section("FOO")' thing, saying that freely named sections was not valid in COFF ...
The big question being, why don't you switch to ELF then? Or, if you have both, or have already switched, did it even cost you any trouble?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Kernel executable formats

Post by Pype.Clicker »

i now have both ... This came mainly at the cost of moving the appropriate flags into some makefile.$(OSTYPE) included, so that my main makefiles only do

Code: Select all

    nasm -f $(objformat) $< -o $@
As there are things like "-fno-leading-underscore", most of the code have been made ELF-like with tricks around for DJGPP ... however, in some cases (like the 'init' section), i'm restricted to the "lowest commonly available feature set" ...

The main difficulty has been for building custom object files (like the SFS header for the kernel or my KernelMODules) out of two different kind of input formats in a maintainable way... For the modules, for instance, i need to deal with relocation tables and symbol tables, which are quite different in both formats as you can expect, but i finally made it and now, i'm a bit more comfortable with those formats and a bit more ready to write loaders for them ...
Post Reply