Rewriting Section Addresses

The addresses of all sections in the binary code are then rewritten into absolute values in the temporary

kernel/module.c for (i = 1; i < hdr->e_shnum; i++) {

/* Mark all sections sh_addr with their address in the

15e_shnum indicates the number of sections, sh_addr is the address of a section, and sh_offset is the identifier of the section in the section table as described in detail in Appendix E.

temporary image. */ sechdrs[i].sh_addr = (size_t)hdr + sechdrs[i].sh_offset;

/* Internal symbols and strings. */ if (sechdrs[i].sh_type == SHT_SYMTAB) { symindex = i;

strindex = sechdrs[i].sh_link;

strtab = (char *)hdr + sechdrs[strindex].sh_offset;

Iteration through all sections is used to find the position of the symbol table (the only section whose type is sht_symtab) and of the associated symbol string table whose section is linked with the symbol table using the ELF link feature.

Continue reading here: Finding Section Addresses

Was this article helpful?

0 0