lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>> ...without having to edit linit.c. That's the point, right?
>>
>> I'm afraid there's no way to do this in ANSI C (or even in POSIX,
>> according to my reading of the dlfcn.h functions in `man dlopen`).
>>
>> You might be able to implement this yourself in a Linux-specific
>> manner using the functions from link.h, but I never tried.
>>
>> -- Hisham
>>
>
> loadlib itself is not ANSI C, but you can do it in POSIX, see[1]:
>
> The function dlopen() loads the dynamic library file named by the
> null-terminated string filename and returns an opaque "handle" for the
> dynamic library. If filename is NULL, then the returned handle is for
> the main program. If filename contains a slash ("/"), then it is
> interpreted as a (relative or absolute) pathname. Otherwise, the
> dynamic linker searches for the library as follows (see ld.so(8) for
> further details)
>
> [1]: http://linux.die.net/man/3/dlopen
>

Sorry for self-reply, but this is the better information from POSIX standard[1]:

If the value of file is 0, dlopen() shall provide a handle on a global
symbol object. This object shall provide access to the symbols from an
ordered set of objects consisting of the original program image file,
together with any objects loaded at program start-up as specified by
that process image file (for example, shared libraries), and the set
of objects loaded using a dlopen() operation together with the
RTLD_GLOBAL flag. As the latter set of objects can change during
execution, the set identified by handle can also change dynamically.

[1]: http://pubs.opengroup.org/onlinepubs/009695399/functions/dlopen.html


-- 
regards,
Xavier Wang.