How do I prepend a directory the library path when loading a core file in gdb on Linux

后端 未结 5 1476
清歌不尽
清歌不尽 2020-12-23 10:05

I have a core file generated on a remote system that I don\'t have direct access to. I also have local copies of the library files from the remote system, and the executabl

5条回答
  •  天涯浪人
    2020-12-23 10:56

    I'm not sure this is possible at all within gdb but then I'm no expert.

    However I can comment on the Linux dynamic linker. The following should print the path of all resolved shared libraries and the unresolved ones.

    ldd path/to/executable
    

    We need to know how your shared libraries were linked with your executable. To do this, use the following command:

    readelf -d path/to/executable | grep RPATH
    
    • Should the command print nothing, the dynamic linker will use standard locations plus the LD_LIBRARY_PATH environment variable to find the shared libraries.

    • If the command prints some lines, the dynamic linker will ignore LD_LIBRARY_PATH and use the hardcoded rpaths instead.

      If the listed rpaths are absolute, the only solution I know is to copy (or symlink) your libraries to the listed locations.

      If the listed rpaths are relative, they will contain a $ORIGIN which will be replaced at run time by the path of the executable. Move either the executable or the libraries to match.

    For further informations, you could start with:

    man ld.so
    

提交回复
热议问题