In ELF-header, value of e_ident[EI_CLASS]
can either be 1 or 2, which indicates 32-bit operating or 64-bit operating system. But from history we know that ELF first appeared in Solaris 2.0, which is released in 1993. However, widely used 32-bit processor Pentium Pro didn't appeared until 1995.
So why does ELF header has no information about 16-bit or even 8-bit information?
-
@Someprogrammerdude Thank you! I always thought people are using 16-bit architecture until Pentium. Thanks again! – JiangFeng Dec 05 '16 at 13:01
-
@Someprogrammerdude you could make that answer; care to do so? – davmac Dec 05 '16 at 13:22
2 Answers
The first "widely used" 32-bit CPU was the Intel 80386 which was much older.
Then we have the story about SUN and their SPARC architecture from around the same time-frame as the 386.
Solaris was developed by SUN for their machines in the early 1990's, close to when the first 64-bit systems started appearing actually.
ELF (acronym for the Executable and Linkable Format) was developed in the late 1980's, when all major Unix variants ran on pure or hybrid (think Motorola 68000) 32-bit systems.

- 400,186
- 35
- 402
- 621
EI_CLASS
doesn't identify an "operating system", but rather the memory model. This setting defines how various address information is encoded in the file, not necessarily how wide the target registers are.
For PC CPUs, the code loader is executed on the same CPU that will execute the program contained in the ELF file, so EI_CLASS
matches the the code format. However, ELF files are also used as a portable code / debug format, even on 8-bit and 16-bit controllers. Besides, virtually all 16-bit CPUs can address more than 64 KB of memory, so EI_CLASS
cannot be set to ELFCLASS16
for such targets (assuming such a class existed).
To sum up, it's irrelevant how much bits wide pointers are, it's only relevant how much virtual memory you can have. Of course, one could still make ELF files more compact by defining something like ELFCLASS20
(a common value for 16-bit CPUs, including Intel 8086), but, like it was already stated, 32-bit architectures were already widespread in 1993, so nobody bothered to define such a thing.

- 3,156
- 1
- 25
- 53