title: Tool to clearly visualize Memory Layout of a C Program
body: <p>Suppose I am having this code:</p>
  
  <pre><code>int main() {
      int var1;  
      char *ptr = malloc(5 * sizeof(char));  
      //...........  
      do_something();  
      //...........    
      return 0;  
  }
  </code></pre>
  
  <p>We know that the actual memory layout will be divided into segments like: <code>.text</code>, <code>.bss</code>, <code>.data</code>, <code>.heap</code>, <code>.stack</code>. </p>
  
  <p>I know how to use <code>objdump</code>, <code>readelf</code>, etc. But, I want to get a better view of the memory stack, where I can see things like:</p>
  
  <pre><code>.heap       ptr  
  .stack      do_something()  
  .text       main()  
  .bss        var1  
  </code></pre>
  
  <p>The main point is: The actual variable names are missing from the output of <code>objdump</code>, <code>readelf</code> etc.</p>
  
  <p>I am compiling this code with <code>-g</code>, thus retaining the symbol table.</p>
  
  <p>Then, why am I not able to see the memory layout with local/global variable names included?</p>
  
  <p><code>objdump -x</code> shows the names of the variables if type is <code>static</code> otherwise not. Why?</p>