We help IT Professionals succeed at work.

dlopen() question

jseba asked
i have a question about dlopen() function:
when i call it several times in a program the same data segment is loaded each time or just an instance for each one.
This is: if i load a library and change a variable inside it, and then i load it again and access this symbol, i have the value that i gave it previously or this references another memory address.
Watch Question

Yes, If you do it in the same program. In fact It seems that  when you open it the second time it is not reopened, the existing copy is used.

No, if you do it in different instances/programs.

Radu-Adrian Feurdean
BrainBench Linux MVP

     yeah. If u r opening it on the same process on any number of time, u will get the same handle so the values would not change.

   ACTUALLY what happens is, when your trying to open that same library on the same process again, you will get same handle which you got when you opened it previously ( first time ). so the values Remains Same.
     It will NOT reference any other memory location, it remains same until the life time of that process OR untill you use dlclose() .

     I strongy belive that, it might have cleared your doubts.
       dhana sekar

Explore More ContentExplore courses, solutions, and other research materials related to this topic.