title: How to list functions present in object file?
body: <p>I am trying to understand the compiling and linking process in C/C++. I know that the source files are first converted into object files by the compiler. The linker then generated libraries or executables from the object files.</p>
  
  <p>I am trying to first read the information in object files. Here is the program I have written for experimentation.</p>
  
  <p>func.h</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  void beautifulprint(char *str);
  </code></pre>
  
  <p>func.cpp</p>
  
  <pre><code>#include "stdafx.h"
  #include "func.h"
  
  using namespace std;
  
  void beautifulprint(char *str) {
      cout &lt;&lt; "*** " &lt;&lt; str &lt;&lt; " ***" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>TestApp.cpp</p>
  
  <pre><code>#include "stdafx.h"
  #include "func.h"
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      beautifulprint("Hello, world!");
  
      return 0;
  }
  </code></pre>
  
  <p>After building the project in VS 2010 I get func.obj. I assumed that somewhere in func.obj there should be a reference for beautifulprint function. I ran the below for both debug and release versions of func.obj</p>
  
  <pre><code>dumpbin /HEADERS func.obj &gt; funchead.txt
  </code></pre>
  
  <p>Below is the output.</p>
  
  <p>Debug version (Full output not included as it is very large)</p>
  
  <pre><code>...
  
  SECTION HEADER #41
     .text name
         0 physical address
         0 virtual address
        78 size of raw data
      5B94 file pointer to raw data (00005B94 to 00005C0B)
      5C0C file pointer to relocation table
         0 file pointer to line numbers
         A number of relocations
         0 number of line numbers
  60501020 flags
           Code
           COMDAT; sym= "void __cdecl beautifulprint(char *)" (?beautifulprint@@YAXPAD@Z)
           16 byte align
           Execute Read
  
  SECTION HEADER #42
  .debug$S name
         0 physical address
         0 virtual address
        E8 size of raw data
      5C70 file pointer to raw data (00005C70 to 00005D57)
      5D58 file pointer to relocation table
         0 file pointer to line numbers
         7 number of relocations
         0 number of line numbers
  42101040 flags
           Initialized Data
           COMDAT (no symbol)
           Discardable
           1 byte align
           Read Only
  
  ...
  </code></pre>
  
  <p>Release version (Complete output!)</p>
  
  <pre><code>Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  
  Dump of file func.obj
  
  File Type: ANONYMOUS OBJECT
  
  ANON OBJECT HEADER VALUES
                 1 version
               14C machine (x86)
          50213733 time date stamp Tue Aug 07 16:41:39 2012
                   ClassID: {0CB3FE38-D9A5-4DAB-AC9B-D6B6222653C2}
               2D1 size
                 0 flags
  </code></pre>
  
  <p>And here are my questions. As expected, func.obj Debug version has a reference to beautifulprint. But to my astonishment there is no reference to beautifulprint in Release version? How would the linker know that this function is present in the object file. </p>
  
  <p>Also why does the debug obj version have functions from iostream? Shouldn't these be present in some standard library instead of this obj?</p>
  
  <p><strong>Edit</strong>: I directly opened the release func.obj in VS 2010 in Hex format. I searched for beautifulprint and its  present on the right hand side (ASCII) column. It means the reference is present. Why does dumpbin not show it? I need some tool to view it in human readable format.</p>