title: Printing the symbol table from elf file
body: <p>I am trying to print the symbol table from an elf file. I got the offsets of sections .symtab and .strtab ( I crosschecked with readelf). but the program is giving segmentation fault. Here is the code in question:</p>
  
  <pre><code>printf("\n\nSymbol table:");
  
  for(i=0;i&lt;symtab.sh_size/symtab.sh_entsize ;i++)
  {
      fseek(ElfFile,symtab.sh_offset+i*symtab.sh_entsize,SEEK_SET);
      fread(&amp;elfSym,1,sizeof elfSym,ElfFile);
  
      printf("\nSymbol:%s,size:%u",elfSym.st_name+strtab.sh_offset,elfSym.st_size);
  }
  </code></pre>