Get elf sections offsets
I'm trying to get the offset and the data of each sections of an elf file. I already have the sections names with this code: #include <elf.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> int filesize(int fd) { return (lseek(fd, 0, SEEK_END)); } void print_section(Elf64_Shdr *shdr, char *strTab, int shNum) { int i; for(i = 0; i < shNum; i++) printf("%02d: %s\n", i, &strTab[shdr[i].sh_name]); } int main(int ac, char **av) { void *data; Elf64_Ehdr *elf; Elf64_Shdr *shdr; int fd; char *strtab; fd = open(av[1], O_RDONLY); data = mmap(NULL, filesize(fd), PROT_READ,