So I was able to get the sh_name using the Elf tutorial here: http://wiki.osdev.org/ELF_Tutorial and this question: getting the sh_name member in a section header elf file, but when using the same method to get the rest of the fields in the section header, I don't get the same output as I do when I call readelf -S
on the object file I'm analyzing. I'm printing out a casted string of the following:
sh_strtab_p + shdr[i].sh_offset
and I'm getting nothing when I do. Is it an issue of casting? Am I supposed to be casting it as an int instead or something similar? I thought it was going to be a string format since I assumed sh_strtab
was the associated string table to the section header.