title: Access symbols defined in the linker script by application
body: <p>In my linker script file, I have defined two symbols</p>
  <pre><code>define symbol _region_RAM_start__     = 0xC0000000;
  define symbol _region_RAM_end__       = 0xC00fffff; 
  </code></pre>
  <p>and then I have exported them as well as shown below</p>
  <pre><code>export symbol _region_RAM_start__;
  export symbol _region_RAM_end__;
  </code></pre>
  <p>From the application code, I try to access these symbols</p>
  <pre><code>extern const unsigned int _region_RAM_start__;
  extern const unsigned int _region_RAM_end__;
  ....
  int GetRAMSize()
  {
      int size = 0;
      unsigned int address_1 = _region_RAM_start__;
      unsigned int address_2 = _region_RAM_end__;
      size = address_2 - address_1 + 1U;
      return size;
  }
  </code></pre>
  <p>Now, I expected the return value to be 0x00100000, however, all I get is 0.
  So, when I turned to the debugger, I noticed that <code>_region_RAM_start__</code> and <code>_region_RAM_end__</code> have the values 0xC0000000 and 0xC00fffff respectively, but <code>address_1</code> and <code>address_2</code> have the value 0.</p>
  <p>The compiler optimization is set to &quot;None&quot;. This has been bugging me for a while now. Is there something very obvious I am missing here <em>(other than &quot;I should not be doing this in the first place&quot;)</em>?</p>
  <p><strong>Solution</strong>
  Thanks to n.m. for the answer</p>
  <pre><code>  unsigned int address_1 = (unsigned int) (&amp;_region_RAM_start__);
  </code></pre>
  <p>Otherwise <code>address_1</code> and <code>address_2</code> both contain garbage values (i.e. values available at the address 0xC0000000 and 0xC00fffff respectivly, but garbage from the point of view of this code)</p>