title: How to access a variable from linker script in rust code?
body: <p>following is the snippet of linker script.</p>
  <pre><code>.data :
  {
      *(.data*)
  }
  &gt; ram
  . = ALIGN(4);
  
  /* Set Stack after code &amp; data */
  _stack_start = .;
  </code></pre>
  <p>How can I access the <strong>_stack_start</strong> (start address for stack) in my rust (without std library) ?</p>
  <pre class="lang-rust prettyprint-override"><code>#![no_std]
  #![no_main]
  #![allow(dead_code)]
  
  #[no_mangle]
  pub fn _start() {
      // let sp: i32 = _stack_start; -&gt; **This causes compilation error**
  
      type FnPtr = fn() -&gt; ();
      let th: FnPtr = trap_handler;
  
      unsafe {
          asm!(&quot;csrw mtvec, {}&quot; ,
              in(reg) th);
      }
  
      loop {}
  }
  </code></pre>