title: IAR initializer function placement
body: <p>Does anybody know how to deal with the following problem:<br>
  I have an IAR Embedded workbench. The project is using the SDRAM for running it's code and Flash ROM too. The code for SDRAM is loaded from SD Card. However, in SDRAM there are also some data stored, like global or static variables. Some of them have to be initialized. The initialization step, the <code>iar_data_init3</code> function call, goes after the <code>low_level_init</code> function. So the problem is that for initialization of some of the variables in SDRAM, the initializer function is called from <code>iar_data_init3</code>, the code of which is inside of the SDRAM itself. Which is wrong because the loading of SDRAM code from SD Card is not yet done.</p>
  
  <p>I have tried manual initialization as described in the C/C++ development guide, but this didn't help.</p>
  
  <p>The function which is called is <code>__sti__routine</code>, which provides initialization of variables. All of these functions are generated by IAR. Is there any way to tell the linker to put the initializer functions to Flash ROM?</p>
  
  <p><strong>EDIT 1:</strong> 
  Here is information from IAR manual for C/C++. 
  It is an example of how to use manual initialization.</p>
  
  <p>In the linker config file:</p>
  
  <pre><code>initialize manually { section MYSECTION };
  </code></pre>
  
  <p>Then IAR documentation says:</p>
  
  <p>you can use this source code example to initialize the section:</p>
  
  <pre><code>#pragma section = "MYSECTION"
  #pragma section = "MYSECTION_init"
  void DoInit()
  {
  char * from = __section_begin("MYSECTION_init");
  char * to = __section_begin("MYSECTION");
  memcpy(to, from, __section_size("MYSECTION"));
  }
  </code></pre>
  
  <p>I can't understand however, first of all, 
  what is the difference between 
  MYSECTION_init and MYSECTION.
  Aslo, if I have a global variable: </p>
  
  <pre><code>SomeClass myclass;
  </code></pre>
  
  <p>And it should be placed in SDRAM,
  then how does the initialization is done for it? I want to manually initialize the variable, 
  and place that initializing functions to flash ROM. (the problem is that by placing variable to SDRAM it's initializing function also is placed to SDRAM).</p>