title: Importing a symbol from C file into linker script
body: <p>I have created a section called .co_stack in my C file and have an array called pulStack to define the area. </p>
  
  <pre><code>#define STACK_SIZE       0x00003000      /*!&lt; Stack size (in Words)           */
  __attribute__ ((section(".co_stack")))
  unsigned long pulStack[STACK_SIZE];
  </code></pre>
  
  <p>My gcc linker script defining the stack section looks like this</p>
  
  <pre><code>.co_stack : {
      _fstackptr = ORIGIN(ram) + LENGTH(ram) - 4;
      _fstacksize = 0x00003000 * 4;       
      . = (_fstackptr - _fstacksize);
      *(.co_stack .co_stack.*)
  }
  </code></pre>
  
  <p>As you can see I end up defining the stack size in 2 places. 
  One as STACK_SIZE in my .c file and _fstacksize in my .ld file.</p>
  
  <p>How can I define this in just one place? </p>
  
  <p>For e.g.
  I want to create a variable pulStackSize as follows.</p>
  
  <pre><code>const unsigned long pulStackSize = sizeof(pulStack);
  </code></pre>
  
  <p>I want to define _fstacksize in .ld file as </p>
  
  <pre><code>_fstacksize = STACK_SIZE * 4;
  </code></pre>
  
  <p>If I do this, I get an error saying stack overflowed by 48K bytes.</p>
  
  <p>How can I import a symbol from .c to my .ld file ? </p>