1

I have 2 application lets say A1 ,A2 shared one shared object(lets say lib1) which loaded in application at runtime. A1 load lib1 using dlopen successfully. Now A2 wants to load library. Can A2?(as lib1 loaded in A1 address space). What if A1 load using RTLD_LOCAL. Can A2 load lib?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Suri
  • 391
  • 2
  • 4
  • 9
  • 2
    Shared libraries wouldn't be very useful if that didn't work. You'd only ever be able to start one non-static process on your computer, all others would fail because they can't load libc. – Mat May 09 '12 at 05:35

1 Answers1

3

Yes, of course. From the Wikipedia article on libraries:

A shared library or shared object is a file that is intended to be shared by executable files and further shared objects files

In other words, the whole reason they're called "shared" is because more than one executable is using them.

From the docs for RTLD_LOCAL:

Symbols defined in this library are not made available to resolve references in subsequently loaded libraries.

The RTLD_LOCAL flag to dlopen() simply indicates that when A1 loads lib1, if it defines, say, a function f1(), and then A1 loads lib2, it can't use the f1() from lib1, because that was loaded local.

ckhan
  • 4,132