RTL_ENTRY_POINT value and dlsym error number set problem
Peng Fan
van.freenix at gmail.com
Mon Aug 18 13:10:25 UTC 2014
On 08/18/2014 05:05 PM, Mohammed Saeed. Khoory wrote:
> Hi,
>
> 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.
>
Currently the entry symbol is "rtems" or "_rtems", thus function `int rtems(xxxx) {xxx}` is the beginning and you should define this function in source files.
You may change "xx app_main(xxx)" to "int rtems(int argc, char **argv)". U may remove --entry/-e option, it has no effect for u rap file currently, but remember to define the entry function 'int rtems(int argc, char **argv)'
>>
>> 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().
You may execute "rtl-trace set all" or "rtl-trace set load load-sect symbol reloc" in shell to see the loading detail.
>
> 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!
Regards,
Peng.
> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users
>
More information about the users
mailing list