One of the main advantages of ELF that contributed to its popularity is that it is extremely flexible and supports multiple address sizes (32- and 64-bit), as well as endiannesses, which means it can work on many different architectures.
Here is a diagram describing a typical ELF structure:
As we can see, it is slightly different for linkable and executable files, but in any case, it should start with a file header. It contains the 4-byte \x7F'ELF' signature at the beginning (part of the e_ident field, which will be described later), followed by several fields mainly specifying the file's format characteristics, some details of the target system, and information about other structure blocks. The size of this header can be either 52 or 64 bytes for 32- and 64-bit platforms, respectively (as for the 64-bit platforms, three of its fields are 8 bytes long in order to store 64-bit addresses, as opposed...