Skip to main content

RTS 173 when calling Functions belonging to shared library loaded with dlopen

  • February 15, 2013
  • 0 replies
  • 0 views

This article explains that an RTS error 173 occurs if the flag RTLD_GLOBAL of dlopen API is not used.

Problem:

When a program loads a shared library with dlopen API and later loads functions belonging to this library the following error occurs:

RTS error 173 (Called program file not found in drive/directory)

Why is this happening?

Resolution:

This RTS error 173 occurs if the flag RTLD_GLOBAL of dlopen API is not used. This RTS error 173 is normal in regards to the definition of RTLD_GLOBAL flag.

RTLD_GLOBAL allows symbols in the module being loaded to be visible when resolving symbols used by other dlopen calls. These symbols will also be visible when the main application is opened with dlopen(NULL, mode).

dlopen API: http://publib16.boulder.ibm.com/doc_link/en_US/a_doc_lib/libs/basetrf1/dlopen.htm

The demonstration attached just reproduces the RTS 173 described here.

In function libsoAentryA() of libsoa.c,

comment the line hdl = dlopen(soToLoad,RTLD_NOW);

and uncomment the line /*hdl = dlopen(soToLoad,RTLD_NOW | RTLD_GLOBAL);*/

to make the demonstration work

void libsoAentryA()

{

void *hdl = 0;

char * soToLoad = "libsob.so\\0";

printf("\\n*--> libsoAentryA load library %s",soToLoad);

/*hdl = dlopen(soToLoad,RTLD_NOW | RTLD_GLOBAL);*/ <ß--- libsob loaded with the dlopen function

hdl = dlopen(soToLoad,RTLD_NOW);

Old KB# 14161