title: Can I see functions in init and ctors
body: <p>I just a bit confused by this previous discussion about .init in 
  <a href="https://groups.google.com/forum/#!topic/gnu.gcc.help/Fit5UOU9UNs" rel="nofollow noreferrer">https://groups.google.com/forum/#!topic/gnu.gcc.help/Fit5UOU9UNs</a> 
  Because, from all the discussion I can get from internet shows that: </p>
  
  <p>using "extern int hello_init() <strong>attribute</strong> ((constructor));" will not add code into .init section but put it into a function array in .ctors, right? But If I compile the example code: </p>
  
  <pre><code>#include &lt;stdio.h&gt; 
  
  extern int hello_init() __attribute__ ((constructor)); 
  
  int hello_init() 
  { 
    printf("init hello\n"); 
    return 0; 
  } 
  </code></pre>
  
  <p>&lt;&lt;&lt;&lt;&lt; 
  if I compile it with "gcc -fPIC -shared -o libender.so test.c", using objdump -x or -d 
  I can't see .ctors section and I can't even see any calls to __do_global_ctors_aux anywhere in the file including .init section. Did recent version of GCC has change the behavior of it? Is there anyway I can see the function with attribute of constructor from the ELF files? </p>
  
  <ol start="2">
  <li>If i don't use constructor attribute and just compile it using "Wl,-init,hello_init". When I use objdump or readelf to dump the so file, I still can't see the code of hello_init in .init section. Does this flag really put the function code into .init section? if so is there any way I can use objdump or readelf to observe it? </li>
  </ol>
  
  <p>my .init section dump is always be like this(no matter compiled with Wl, -init or using constructor attribute): </p>
  
  <p>Disassembly of section .init: </p>
  
  <pre><code>00000000000005d0 &lt;_init&gt;: 
   5d0:        48 83 ec 08                  sub    $0x8,%rsp 
   5d4:        48 8b 05 05 0a 20 00         mov    0x200a05(%rip),%rax        # 200fe0 &lt;_DYNAMIC+0x1c8&gt; 
   5db:        48 85 c0                     test   %rax,%rax 
   5de:        74 05                        je     5e5 &lt;_init+0x15&gt; 
   5e0:        e8 2b 00 00 00               callq  610 &lt;__gmon_start__@plt&gt; 
   5e5:        48 83 c4 08                  add    $0x8,%rsp 
   5e9:        c3                           retq 
  </code></pre>
  
  <p>If I both used the attribute in the C file and compiled with Wl,init. I do see hello_init called twice before main. However, how I can observed them in ELF files, where didn't GCC put those function pointers? </p>