The magic shows a 02, which is translated by the readelf command as an ELF64 file. This value determines the architecture for the file. ClassĪfter the ELF type declaration, there is a Class field defined. To better understand the inner working of an ELF file, it is useful to know this header information is used. It ensures that data is correctly interpreted during linking or execution. The first 4 hexadecimal parts define that this is an ELF file (45= E,4c= L,46= F), prefixed with the 7f value. This ELF header magic provides information about the file. With the readelf command, we can look at the structure of a file and it will look something like this:Īs can be seen in this screenshot, the ELF header starts with some magic. The ELF specification is also used on Linux for the kernel itself and Linux kernel modules.ĭue to the extensible design of ELF files, the structure differs per file. Another example is shared libraries or even core dumps (those core or a.out files). We already have seen they can be used for partial pieces (object code). After all, trying out is the best way to learn and compare results.Ī common misconception is that ELF files are just for binaries or executables. Additionally, we have provided a small C program, which can you compile. If you like to test commands, copy an existing binary and use that. This blog post will share a lot of commands. The result is a binary file, which then can be executed on that specific platform and CPU type.
#How to run boot.elf full#
This object code is then linked into a full program, by using a linker tool. A compiler then translates these functions into object code. Instead of talking directly to the CPU, we use a programming language, using internal functions. A function could be something basic like opening a file on disk or showing something on the screen.
So whatever operating system we run, it needs to translate common functions to the language of the CPU, also known as machine code.