title: Linker script: insert absolute address of the function to the generated code
body: <p>I have a question related to gcc's linker.</p>
  
  <p>I'm working with embedded stuff (PIC32), but PIC32's compiler and linker are based on gcc, so, main things should be common for "regular" gcc linker and PIC32 linker.</p>
  
  <p>In order to save flash space (which is often insufficient on microcontrollers) I need to put several large functions in the bootloader, and application should call these functions just by pointers.</p>
  
  <p>So, I need to create vector table in the generated code.</p>
  
  <p>I'm trying to get absolute address of the function and write it to the generated code, but still getting errors. </p>
  
  <p>In the example below I'm trying to get address of the function <code>_formatted_write</code>.</p>
  
  <p>Code:</p>
  
  <pre><code>.user_addr_table _USER_ADDR_TABLE_ADDR :
  {
     KEEP(*(.user_addr_table))
     LONG((ABSOLUTE(_formatted_write))); /* _formatted_write is a name of my function */
  } &gt; user_addr_table
  </code></pre>
  
  <p>Linker returns error: "<code>unresolvable symbol '_formatted_write' referenced in expression</code>".</p>
  
  <p>I have noticed that if I write some garbage instead of <code>_formatted_write</code>, then it returns error "<code>undefined symbol .....</code>", so, <code>_formatted_write</code> is known by linker.</p>
  
  <p>It makes me think I should perform some additional steps to make it "resolvable". But still no idea how to do that.</p>