Why does the Bare Bones tutorial use ELF?

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
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Why does the Bare Bones tutorial use ELF?

Post by gsingh2011 »

The Bare Bones tutorial uses the ELF file format. What is the benefit of this as opposed to another format?
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: Why does the Bare Bones tutorial use ELF?

Post by zhiayang »

gsingh2011 wrote:The Bare Bones tutorial uses the ELF file format. What is the benefit of this as opposed to another format?
I may be wrong, and there may be more benefits than this.

1. ELF is widely supported. It provides a means of 'checking' the integrity (as secure a simple 4-byte magic header is) of the file.
2. It has debugging symbols, for example symbol tables, that enable debugging externally, and for doing a backtrace internally.
3. With the .dyn* and .reloc sections, it can make dynamic loading much simpler.

I suggest searching for these things on google. We are not here to answer your simple questions. Please, at least post some findings or other things.
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Re: Why does the Bare Bones tutorial use ELF?

Post by gsingh2011 »

Googling gives me a description of the format, but not why one would use this format over another. And why someone use this format for OSDev might be a different answer than using the format for an executable. But thanks for your input. If anyone has any other benefits of using ELF, I'd like to know.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: Why does the Bare Bones tutorial use ELF?

Post by zhiayang »

gsingh2011 wrote:Googling gives me a description of the format, but not why one would use this format over another. And why someone use this format for OSDev might be a different answer than using the format for an executable. But thanks for your input. If anyone has any other benefits of using ELF, I'd like to know.
The third benefit doesn't really apply for the actual OS executable, but rather for programs that you might load *from* your OS, later on.

1. ELF is widely supported. *MAYBE*, you might be able to run a linux program on your OS, if you provide all the system calls and libraries it needs, without re-compiling, IF your OS is fully POSIX compliant.

2. Again, debugging and backtracking is very valuable in OSDev to determine where your OS went wrong.
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: Why does the Bare Bones tutorial use ELF?

Post by gravaera »

Yo:
requimrar wrote:I suggest searching for these things on google. We are not here to answer your simple questions (?). Please, at least post some findings or other things.
I feel as if this post was completely unedifying, useless, tasteless, and laced with condescension.

@OP:

From a purely practical point of view, we recommend ELF for several reasons:
  • In the PE/COFF specification, you will find in the legal preamble, clauses which limit the use of PE that may apply to competing products such as kernels. I do not remember exactly what the clause was, or why I felt that it clashed with the aim of using PE for competing kernel development, but when I read it, it was fairly obvious that the clause did clash.
  • There is a subtle (and imho, healthy) bias toward a mostly Unix/POSIX development environment for all documentation on the site.
  • The majority of GNU compiler stack programs and accompanying tools very seamlessly work with ELF.
  • The majority of people in the community use ELF.
  • The majority of the documentation you will find publicly available will be POSIX/GNU biased: you'll encounter a lot of documentation on Linux when trying to do research on a lot of topics.
The first point may or may not be one of the most significant reasons for ELF being used on the wiki, but whether or not it was, I'd like to suggest that you make it one of your foremost considerations when choosing your own format.

--Peace out,
gravaera
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Why does the Bare Bones tutorial use ELF?

Post by Owen »

Additionally, the Bare Bones tutorials are designed to work with GNU GRUB. GRUB expects you to use ELF; using other formats uses a mechanism which is defined by the Multiboot specification itself to be a kludge.
Post Reply