|
发表于 2008-2-21 12:42:04
|
显示全部楼层
除了 2 楼所说的方法外, 也可以通过环境变量或给 /lib/ld-linux.so.2 传参数来在运行时临时改变查找路径. 看下面几个命令
- [yun@localhost ~]$ echo "hello" # 这是默认查找路径下的结果, 一切正常
- hello
- [yun@localhost ~]$ /lib/ld-linux.so.2 # 对, 就是要直接运行
- Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]
- You have invoked `ld.so', the helper program for shared library executables.
- This program usually lives in the file `/lib/ld.so', and special directives
- in executable files using ELF shared libraries tell the system's program
- loader to load the helper program from this file. This helper program loads
- the shared libraries needed by the program executable, prepares the program
- to run, and runs it. You may invoke this helper program directly from the
- command line to load and run an ELF executable file; this is like executing
- that file itself, but always uses this helper program from the file you
- specified, instead of the helper program file specified in the executable
- file you run. This is mostly of use for maintainers to test new versions
- of this helper program; chances are you did not intend to run this program.
- --list list all dependencies and how they are resolved
- --verify verify that given object really is a dynamically linked
- object we can handle
- --library-path PATH use given PATH instead of content of the environment
- variable LD_LIBRARY_PATH
- --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names
- in LIST
- [yun@localhost ~]$ /lib/ld-linux.so.2 --library-path / echo "hello" # 指定查找路径 (只) 为 "/", 因此会找不到库而无法运行
- echo: error while loading shared libraries: echo: cannot open shared object file
复制代码
更具体的请参见 man ld.so |
|