title: program execution is not started at main()
body: <p>I developed many years in C and only now discovered that a program can execute code prior to main() function.
  Here is a code example</p>
  
  <pre><code>int generateNum(){
      // Some malicious code here...
      return 5;
  }
  
  static int someArray[] = {generateNum(),generateNum()}  
  
  int main(){
       // Some code here...
  }
  </code></pre>
  
  <p>The function <code>generateNum()</code> is called twice before <code>main()</code>.</p>
  
  <p>My questions are </p>
  
  <ol>
  <li>Who calls generateNum()? I know that on Windows it is crtexe()</li>
  <li>Is this behavior standardized on different platforms: Windows/Linux/Android/iOS?</li>
  <li>How can I get more information about this behavior? I want to search in Google, but I don't know how to describe it. </li>
  <li>Can I do anything I want inside the generateNum()? I mean, can I call malloc()? What about fopen() and fwrite()?  Can I open a socket and send information over UDP? Eventually I can abuse this function and even call to main() from it :-)</li>
  </ol>