SHT_NULL
section in ELF
?From the ELF specification:
SHT_NULL
: This value marks the section header as inactive; it does not have an associated section. Other members of the section header have undefined values.
The ELF header's e_shoff member indicates the byte offset from the beginning of the file to the section header table. The e_shnum member indicates how many entries that the section header table contains.
The ELF header is always located at the beginning of the ELF file. It describes the ELF file organization and contains the actual sizes of the object file control structures. The initial bytes of an ELF header specify how the file is to be interpreted.
A section header is a structure of fixed size and format, consisting of the following fields, or members: sh_name. Specifies the section name. The value of this field is an index into the section header string table section, wherein it indicates the beginning of a null-terminated string that names the section. sh_type.
To find them the ELF header is used, which is located at the very start of the file. The first bytes contain the elf magic "\x7fELF" , followed by the class ID (32 or 64 bit ELF file), the data format ID (little endian/big endian), the machine type, etc. Finally, the entry point of this file is at address 0x0.
One "use" of SHT_NULL
is that it is mandatory for the first header table entry (index 0, named SHN_UNDEF
), which is magic.
This is documented on the System V ABI Update (recommended by the LSB):
If the number of sections is greater than or equal to SHN_LORESERVE (0xff00), e_shnum has the value SHN_UNDEF (0) and the actual number of section header table entries is contained in the sh_size field of the section header at index 0 (otherwise, the sh_size member of the initial entry contains 0).
and:
Other section type values are reserved. As mentioned before, the section header for index 0 (SHN_UNDEF) exists, even though the index marks undefined section references. This entry holds the following.
followed by a table that specifies what each entry of he section header means in that special case. In particular, sh_type
must be SHT_NULL
.
From the above, this first section seems to exist to allow a large number of sections to be encoded, but I haven't tested kernel and compiler support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With