ELF Format.
ELF Format.
Hey all.
Just wondering how useful it would be to have an ELF Kernel.
And if it is super useful, Any good references on how to load it correctly from Realmode?
Thanks!
~Zeii.
Just wondering how useful it would be to have an ELF Kernel.
And if it is super useful, Any good references on how to load it correctly from Realmode?
Thanks!
~Zeii.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:ELF Format.
having an ELF kernel is mainly useful if you have an ELF bootloader already and that it gives you more flexibility than a flat binary.
ELF would allow you to use your linker script to place some section at some pre-defined addresses, etc. Probably you could do the same with a COFF or a PE kernel.
ELF would allow you to use your linker script to place some section at some pre-defined addresses, etc. Probably you could do the same with a COFF or a PE kernel.
Re:ELF Format.
I just need a way to tell the real size of a program.
I can get the filesize of the kernel, but I dont have the size in memory of the Kernel.
Since, BSS isnt put in the file, I dont know how big it is, thanks to it being a flat binary.
Pype, do you know of a way I can calculate the Memory Size of the Kernel... without moving to ELF?
~Z
I can get the filesize of the kernel, but I dont have the size in memory of the Kernel.
Since, BSS isnt put in the file, I dont know how big it is, thanks to it being a flat binary.
Pype, do you know of a way I can calculate the Memory Size of the Kernel... without moving to ELF?
~Z
Re:ELF Format.
You don't.
The advantage of those fancy file formats is that they don't take any space for BSS, since you can reserve it in memory. Binary doesn't have this, so binary always (should) merge(s) the bss with .data.
The advantage of those fancy file formats is that they don't take any space for BSS, since you can reserve it in memory. Binary doesn't have this, so binary always (should) merge(s) the bss with .data.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:ELF Format.
actually, you could. You just need to declare a new location in your linker script where you will e.g. save _end_bss, and another one where you will save _end_code_and_data (see BareBones linker script, it should have statements that retrieve those).Candy wrote: You don't.
The advantage of those fancy file formats is that they don't take any space for BSS, since you can reserve it in memory. Binary doesn't have this, so binary always (should) merge(s) the bss with .data.
Re:ELF Format.
That would pretty much define a new file format, wouldn't it?Pype.Clicker wrote:actually, you could. You just need to declare a new location in your linker script where you will e.g. save _end_bss, and another one where you will save _end_code_and_data (see BareBones linker script, it should have statements that retrieve those).Candy wrote: You don't.
The advantage of those fancy file formats is that they don't take any space for BSS, since you can reserve it in memory. Binary doesn't have this, so binary always (should) merge(s) the bss with .data.
Re:ELF Format.
Well my kernel in elf format is 49 kb while in binary format is 36 so, space saved for bss is consumed some where else
What I want to know what are the advantage of my OS to support loading executable formats other than binary ???
What I want to know what are the advantage of my OS to support loading executable formats other than binary ???
To write an OS you need 2 minds one for coding and other for debugging.
Re:ELF Format.
AFAIK, it's best to do that in LD, in a linker script. There are enough linker scripts on the OS FAQ that do that, as well as on the forum itself.zeii wrote: hmm, Candy - how could I order GCC to merge BSS with Data?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:ELF Format.
There are a couple of good examples of "stripping" ELF files to the bare minimum, for many platforms. using objcopy to remove .comment sections, debugging symbols, or use a granularity for sections smaller than 4K (which is default).ces_mohab wrote: Well my kernel in elf format is 49 kb while in binary format is 36 so, space saved for bss is consumed some where else
What I want to know what are the advantage of my OS to support loading executable formats other than binary ???
Your ratio is 36KB vs 49KB, right ? (not 36B vs. 49KB).
Now, when it comes to support for user programs, there will be other advantages in a format like ELF. The fact it can store symbols, give enough info to relocate your executable or let it run independently of its location, or support run-time libraries, etc.
Re:ELF Format.
Or may be the advantage of having a magic value in the header to check that this file is really an excutable.
To write an OS you need 2 minds one for coding and other for debugging.