dlopen()

ba_f ba_f at rbg.informatik.tu-darmstadt.de
Mon Jul 6 10:46:21 CEST 2015


Am 2015-06-25 21:49, schrieb Adam Lackorzynski:
> Hi,
> 
> On Fri Jun 19, 2015 at 16:15:54 +0200, ba_f wrote:
>> is it possible to dlopen() a shared lib?
> 
> Yes.
> 
>> I'd like to execute a program that is started like this:
>> "Example: ./gen_random -d .libs/libsim.so"
>> 
>> I know how to start a program with arguments.
>> But where could i put my shared lib, and which path should i pass to 
>> the
>> executing program?
> 
> All files/modules you put in your modiles.list file entry show up under
> rom/. So it should be: ./gen_random -d rom/libsim.so
> 
> 
> 
> Adam


Ok, thanks Adam.


Yet, i have another (maybe trivial) question.

How do i build a dynamic(!) shared lib for Fiasco, which is loadable 
with dlopen()?


I tried to add the -fPIC flag in the lib Makefile, but it didn't work 
out.


[Makefile]

CPPFLAGS += -fPIC
LOADABLE_MODULE=1

include $(L4DIR)/mk/lib.mk
[/Makefile]


[c]
   dl = dlopen(rom/lib.so, RTLD_NOW);
     if (dl == NULL){
       fprintf(stderr, "dlopen failed: %s\n", dlerror());
[/c]

Output is: dlopen failed: (null)

I can assure that dlopen() finds the lib.so, because dlerror() gives an 
other output when using a different name (e.g. dlopen(rom/crap.so) ).




Greetings,

ba_f




More information about the l4-hackers mailing list