views:

260

answers:

3

I have a few questions:

  • Why was a.out replaced by ELF?
  • What were the major flaws in the a.out format that led to the raise of ELF file format?
  • Earlier core dumps were based on a.out, but now they are based on ELF. What are the various advantages provided by ELF?
A: 

As I recall, one of the original problems with a.out format is that it only supported three sections: text, data, and bss. ELF allows any number (or at least many more). The a.out header format was very simple, something like:

word <magic>
word <text size>
word <data size>
word <bss size>

The ELF format, in contrast, has section headers, with names, sizes, etc.

Having more sections allows for the standard sections, but also gives us const sections, constructor sections, and even one section per function, if we want it.

Richard Pennington
This explains the differences, but doesn't explain what's so wrong with a.out or why having more sections is better
Andreas Bonini
A: 

A bit of triviality - a.out stood for Assembler OUTput and to this day, gcc will compile C code and defaults to a.out unless -o switch was used on the command line! This was a holdover from the days when code were directly translated to assembler output...nice to see legacy living on in spirit!!

Hope this helps, Best regards, Tom.

tommieb75
Notice that although gcc defaults to use the name `a.out`, the format is still ELF.
hlovdal
@hlovdal: true! :)
tommieb75
who downvoted this? obviously the downvoter does not understand! Please leave a comment on it...and don't be blindingly downvoting and *NOT* leaving a comment!
tommieb75
+2  A: 

The a.out format forced shared libraries to occupy a fixed place in memory. If you wanted to distribute an a.out shared library, you had to register its address space. This was good for performance but it didn't scale at all. See for yourself how tricky it was (linuxjournal).

By contrast, in ELF, shared libraries can be loaded anywhere in memory, and can even appear to be at different addresses to different applications running on the same computer (with the code still effectively loaded in only one place in physical memory)! In order to achieve this, in the IA-32 architecture, a register (%ebx) has to be sacrificed. A more comprehensive reference showing that shared libraries got more complicated in ELF, but that was compiler-side complexity, as opposed to programmer-side.

Pascal Cuoq