Welcome to the Linux Foundation Forum!

Any way to find out where a DSO was loaded from?

Is there any way for a DSO in Linux to find out where it was loaded from?

(In Windows I have the GetModuleHandle and GetModuleFilename functions to determine the full path to the library. Since I need to load other libraries from a different directory within a certain predefined hierarchy it would be convenient to have a way to get the full path to a DSO. So far I'm using an environment variable that points to the base directory.)

Thanks for any hints, Google wasn't very helpful, so far ...

Comments

  • mfillpot
    mfillpot Posts: 2,177
    I do not know the programming function to find the DSO location, but you can use the lsof (list open files) command to see what dependent files are being loaded by any application.
  • Thanks very much! I will look into this, didn't think of it.
  • mfillpot
    mfillpot Posts: 2,177
    If you can tell use what language you are programming in, then we may be able to locate the necessary programming function to obtain your required information.
  • Thanks for your answer & help!
    I use plain C for this project.
  • Okay, so the basic idea is to read the information from /proc/<PID>/maps ...
    Thanks for the hint with lsof.

Categories

Upcoming Training