title: getting the sh_name member in a section header elf file
body: <p>I'm trying to get the correct offset to the section name by accessing the <code>sh_name</code> member of an elf file, but it keep giving me zero, or null...</p>
  
  <p>I'm supposed to only use <code>mmap()</code> and the <code>elf.h</code> - no helper functions</p>
  
  <p>So I did: </p>
  
  <pre><code>void* map_start = mmap(0, fd_stat.st_size, PROT_READ | PROT_WRITE , MAP_SHARED, fd, 0))
  header = (Elf32_Ehdr *) map_start;  
  secoff = header-&gt;e_shoff;    
  section = (Elf32_Shdr *)(map_start + secoff); 
  </code></pre>
  
  <p>but when I do:</p>
  
  <pre><code>printf("name offset = %d\n", (section-&gt;sh_name));
  </code></pre>
  
  <p>it keeps giving me 0...
  what am I doing wrong?</p>