Is there a way to do dynamic loading using the 'rtems_task_create' function?

Chris Johns chrisj at rtems.org
Wed Aug 2 02:19:44 UTC 2017


On 02/08/2017 11:19, jaeho jo wrote:
> Hi
> I have two question on dynamic load
> 
> 1. Is there a way to do dynamic loading using the 'rtems_task_create' function?
> 

Creating a task and dynamically loading code are separate things and they have
no relationship to each other. It is your application that needs to provide the
functionality to brings those two separate pieces together in a way you want.

>     In my method, I used 'dlsym' to get the address where that symbol is loaded
> into memory and call the task using function pointer
> 
>     [my code]
>         typedef int (*call_t)(int argc, char* argv[]);
>         ...
>         call = dlsym (handle, call_symbol);
>         call(argc,argv);
>         ...

You need to decide on the design you want to have. You can wrap your code shown
above inside a common thread body or you can call create inside the dynamically
loaded code. The second approach would seem more flexible because the
dynamically loaded code can be changed as needed with out effecting the base image.

> *
> *
> 2. I used 'rtems-ld' to create a RAP and set entry point with option '-e'
> 
>    Also, I called 'dlopen', 'dlsym' to load task dynamically in source code level.
> 
>    In 'dlsym', I need to set entry point(symbol),which is the same as the entry
> point used in 'rtems-ld'
>    I think this is a duplicate command.
> 
>    Is there a way to improve it?

I am not sure I follow. If you set and entry point in the loaded code it should
be called for you. The entry point should be a symbol in the RAP file. From here
you can call any symbol in the loaded code directly or the base image if you
have the symbol in the symbol table. I am not sure why you need to play with the
symbols.

Chris



More information about the users mailing list