title: Why does GCC put calls to constructors of global instances into different sections (depending on the target)?
body: <p>I have some simple declarations of a global instances with non-empty constructors. These constructors are called during startup automatically. I am cross-compiling C++ on Linux to different microcontroller targets.</p>
  
  <hr>
  
  <p>As for</p>
  
  <ul>
  <li>arm-none-eabi-gcc-4.8.4</li>
  <li>rx-elf-gcc-4.8-GNURX_v14.03 (GCC 4.8.3)</li>
  </ul>
  
  <p>calls to constructors are put into the <code>.init_array</code> section. The map file looks like this:</p>
  
  <blockquote>
    <blockquote>
      <p>.init_array    0x00007cb8        0x4 libmotor.o</p>
      
      <p>.init_array    0x00007cbc        0x4 libaudio.o</p>
    </blockquote>
  </blockquote>
  
  <hr>
  
  <p>As for </p>
  
  <ul>
  <li>mips-elf-gcc-4.8.2</li>
  <li>avr-gcc-4.8.1</li>
  <li>msp430-gcc-4.6.3</li>
  </ul>
  
  <p>these calls get into the <code>.ctors</code> section:</p>
  
  <blockquote>
    <blockquote>
      <p>.ctors         0x000000009d011508        0x4 libmotor.o</p>
      
      <p>.ctors         0x000000009d01150c        0x4 libaudio.o</p>
    </blockquote>
  </blockquote>
  
  <hr>
  
  <p>Compiling was done with <code>-ffunction-sections -fdata-sections</code>, the linker got <code>--gc-sections</code>.</p>
  
  <p>All binaries work, but I'd like to put all calls into the same section (to simplify maintenance of linker scripts).</p>
  
  <ul>
  <li>Why are there different target sections?</li>
  <li>Is it possible to change the default section using a command line option?</li>
  <li>If a command line option does not exit: Is it possible to define the default section at GCC compile-time?</li>
  </ul>