I myself could figure out the answer :). Although coding took a lot of time. Here's how to do it if someone wants to direct it to the future - Each binary usually contains three String tables -
1. .dynstr 2. .shstrtab 3. .strtab
In the above question, we are dealing with .shstrtab, which when expanded means - Section Header STRING TABLE. After reading the ELF header, we find the next field in the ELF header - e_shstrndx. This is the index in which we can find .shstrtab. The following formula can be used to calculate how this is done -
offset = ((elfHdr.e_shstrndx)*elfHdr.e_shentsize)+elfHdr.e_shoff
The value of each parameter is
elfHdr.e_shstrndx = index where we can find .shstrtab elfHdr.e_shentsize = Size of each Section Header elfHdr.e_shoff = Offset at which section header starts.
Samir baid
source share