title: GCC produces unaligned function address on Cortex M3
body: <p>I just placed a function to a specific address using a section and then I output the address of that function and the result is the chosen section address + 1.
  This is what I did:</p>
  
  <pre><code>void __attribute__((section (".my_fct_address"))) Fct_Ptr_Test (void)
  {
  ...
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>void (*fct_ptr) (void);
  fct_ptr = Fct_Ptr_Test;
  printf ("0X%X\r\n", (uint32_t)(fct_ptr));
  fct_ptr ();
  </code></pre>
  
  <p>in ld-file:</p>
  
  <pre><code>.my_fct_address 0x800F000 :
   {
     KEEP(*(.my_fct_address)) /* keep my variable even if not referenced */
   } &gt; FLASH
  </code></pre>
  
  <p>The above printf statement outputs 0x800F001 and Fct_Ptr_Test is called properly</p>
  
  <p>If I set</p>
  
  <pre><code>fct_ptr = 0x800F000;
  </code></pre>
  
  <p>the system crashes.
  If I set</p>
  
  <pre><code>fct_ptr = 0x800F001;
  </code></pre>
  
  <p>everything is fine again.
  If I don't place Fct_Ptr_Test in its own section , ie let the linker place it anywhere I also get an odd address.
  Now I wonder how 0x800F001 can be a proper address on a 32 bit controller (ARM cortex M3) and what is stored in 0x800F000.
  Even more strange: map-file always shows the even addresses
  Can anybody help?</p>
  
  <p>Thanks</p>
  
  <p>Martin</p>