Create a new task from a différent binary

dsnejko wrote on Sunday, December 13, 2009:

I am using CodeWarrior and ColdFire port. All linking is done with assembler so my macro would not work for your toolchain. I have a common file included on both sides. It describes table offsets and  macros for table insertion and calling. Something like this, name it lib_links.inc:  
<pre><code>
    .public _xTaskCreate
    .public _vTaskDelay

   INSERT_LINK: .macro  ref
.org   OFFSET&&ref
.long  ref
   .endm 

    JUMP_LINK:      .macro ref
&&ref:          move.l  _LIB_LINK_TABLE  + OFFSET&&ref, a0
                jmp  (a0)
                    .endm
</code></pre>

The kernel build includes an assembler file similar to:
<pre><code>

.global _LIB_LINK_TABLE
    .include lib_links.inc

.text
_LIB_LINK_TABLE:
_LIB_LINK_TABLE_START:
_FREERTOS_LINK_TABLE:
   INSERT_LINK _xTaskCreate
   INSERT_LINK _vTaskDelay
</code></pre>
The application build includes an assembler file similar to:
<pre><code>
   .extern _LIB_LINK_TABLE
   .include lib_links.inc

   .text
_LIB_LINK_TABLE_APP:
    JUMP_LINK _xTaskCreate
    JUMP_LINK _vTaskDelay
</code></pre>

\_LIB\_LINK\_TABLE is a segment created in the linker command file at fixed location and known for the kernel and the app.