title: understanding the __libc_init_array
body: <p>I viewed the source code of __libc_init_array from <a href="http://newlib.sourcearchive.com/documentation/1.18.0/init_8c-source.html" rel="noreferrer">http://newlib.sourcearchive.com/documentation/1.18.0/init_8c-source.html</a> .
  <br>But I don't quite understand what this function does. </p>
  
  <p>I know that these symbols </p>
  
  <pre><code>/* These magic symbols are provided by the linker.  */
  extern void (*__preinit_array_start []) (void) __attribute__((weak));
  extern void (*__preinit_array_end []) (void) __attribute__((weak));
  extern void (*__init_array_start []) (void) __attribute__((weak));
  extern void (*__init_array_end []) (void) __attribute__((weak));
  extern void (*__fini_array_start []) (void) __attribute__((weak));
  extern void (*__fini_array_end []) (void) __attribute__((weak));
  </code></pre>
  
  <p>is defined in the linker script.
  <br>
  Part of the linker script may look like:</p>
  
  <pre><code>  .preinit_array     :
    {
      PROVIDE_HIDDEN (__preinit_array_start = .);
      KEEP (*(.preinit_array*))
      PROVIDE_HIDDEN (__preinit_array_end = .);
    } &gt;FLASH
    .init_array :
    {
      PROVIDE_HIDDEN (__init_array_start = .);
      KEEP (*(SORT(.init_array.*)))
      KEEP (*(.init_array*))
      PROVIDE_HIDDEN (__init_array_end = .);
    } &gt;FLASH
    ...
  </code></pre>
  
  <p>and then I searched with the key "init_array" in the docs of ELF-v1.1, gcc 4.7.2, ld, and codesourcery(I'm using codesourcery g++ lite) only to get nothing.
  <br><br>
  Where can I find the specification of these symbols?</p>