RTL_ENTRY_POINT value and dlsym error number set problem

Mohammed Saeed. Khoory Mohammed.Khoory at eiast.ae
Mon Aug 18 09:05:47 UTC 2014


I'll try to answer as much as I understand, but I might be wrong as I'm not an official developer of RTL. Please correct me if I'm wrong.

> Hi~
> When link application, I pass entry symbol for application(ex. rtems-ld -e app_main). But in "rtems_rap_load()" function, Call dlsym() function like this. 
> ini = dlsym (app->handle, RTL_ENTRY_POINT);
> fini = dlsym (app->handle, RTL_ENTRY_POINT);
> and RTL_ENTRY_POINT is defined like this.
> #if (RTL_GLUE(__USER_LABEL_PREFIX__, 1) == RTL_GLUE(_, 1))
>   #define RTL_ENTRY_POINT "_rtems"
> #else
>   #define RTL_ENTRY_POINT "rtems"
> #endif
> Why pass entry symbol of application when application link?

The RAP format is intended to be used for self-contained applications (i.e. executables, not only libraries). The standard for these applications is to have an entry point function named "rtems".  If you specify a different entry point to rtems-ld, then it's not an "RTEMS application", so you will need to specify your symbol to dlsym as well. You can replace RTL_ENTRY_POINT with whatever symbol you're using as the entry point if you need.

> And second,
> If can't find entry point symbol when rap loading, any error is not set. 
> In rtems_rap_load function,
>     init = dlsym (app->handle, RTL_ENTRY_POINT);
>     if (!init)
>     {
>       rtems_rap_get_rtl_error ();
>       rtems_rap_app_free (app);
>       rtems_rap_unlock ();
>       return false;
>     }
> When failed search RTL_ENTRY_POINT, any error is not set. But call rtems_rap_get_rtl_error().

I'm not sure, but the only error that can happen with dlsym is that the symbol is not found, in which it just returns null. There's no need to set an RTL error because the function either finds the symbol or it doesn't.

> Please check this problem. 
> Thank you for your answer!
> Regards,

I hope this helps! 

More information about the users mailing list