mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-30 02:40:11 +08:00
Merge pull request #1474 from KayGuoWhu/master
[Translated]20140807 Linux FAQs with Answers--How to check what libraries are used by a program or process on Linux.md
This commit is contained in:
commit
67940e5af5
@ -1,45 +0,0 @@
|
|||||||
[translating by KayGuoWhu]
|
|
||||||
Linux FAQs with Answers--How to check what libraries are used by a program or process on Linux
|
|
||||||
================================================================================
|
|
||||||
> **Question**: I would like to know which shared libraries are loaded at run-time when I invoke a particular executable. Is there any way to identify shared library dependencies of a program executable or a running process on Linux?
|
|
||||||
|
|
||||||
### Check shared library dependencies of a program executable ###
|
|
||||||
|
|
||||||
To find out what libraries a particular executable depends on, you can use ldd command. This command invokes dynamic linker to find out library dependencies of an executable.
|
|
||||||
|
|
||||||
$ ldd /path/to/program
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Note that it is NOT recommended to run ldd with any untrusted third-party executable because some versions of ldd may directly invoke the executable to identify its library dependencies, which can be security risk.
|
|
||||||
|
|
||||||
Instead, a safer way to show library dependencies of an unknown application binary is to use the following command.
|
|
||||||
|
|
||||||
$ objdump -p /path/to/program | grep NEEDED
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Check shared library dependencies of a running process
|
|
||||||
|
|
||||||
If you want to find out what shared libraries are loaded by a running process, you can use pldd command, which shows all shared objects loaded into a process at run-time.
|
|
||||||
|
|
||||||
$ sudo pldd <PID>
|
|
||||||
|
|
||||||
Note that you need root privilege to run pldd command.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Alternatively, a command line utility called pmap, which reports memory map of a process, can also show shared library dependencies of a running process.
|
|
||||||
|
|
||||||
$ sudo pmap <PID>
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: http://ask.xmodulo.com/check-library-dependency-program-process-linux.html
|
|
||||||
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
|
@ -0,0 +1,45 @@
|
|||||||
|
Linux有问必答--如何查看Linux上程序或进程用到的库
|
||||||
|
================================================================================
|
||||||
|
> **问题**:我想知道当我调用一个特定的可执行文件在运行时载入了哪些共享库。是否有方法可以明确Linux上可执行程序或运行进程的共享库依赖关系?
|
||||||
|
|
||||||
|
|
||||||
|
### 查看可执行程序的共享库依赖关系 ###
|
||||||
|
|
||||||
|
要找出某个特定可执行依赖的库,可以使用ldd命令。这个命令调用动态链接器去找到程序的库文件依赖关系。
|
||||||
|
|
||||||
|
$ ldd /path/to/program
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
注意并不推荐为任何不可信的第三方可执行程序运行ldd,因为某些版本的ldd可能会直接调用可执行程序来明确其库文件依赖关系,这样可能不安全。
|
||||||
|
|
||||||
|
取而代之的是用一个更安全的方式来显示一个未知应用程序二进制文件的库文件依赖,使用如下命令:
|
||||||
|
|
||||||
|
$ objdump -p /path/to/program | grep NEEDED
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
查看运行进程的共享库依赖关系(注:这里缺少###的标题格式?)
|
||||||
|
|
||||||
|
如果你想要找出被一个运行中的进程载入的共享库,你可以使用pldd命令,它会显示出在运行时被载入一个进程里的所有共享对象。
|
||||||
|
|
||||||
|
$ sudo pldd <PID>
|
||||||
|
|
||||||
|
注意你需要root权限去执行pldd命令。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
或者,也可以选择一个叫做pmap的命令行工具。它报告一个进程的内存映射,也能显示出运行进程的库文件依赖。
|
||||||
|
|
||||||
|
$ sudo pmap <PID>
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: http://ask.xmodulo.com/check-library-dependency-program-process-linux.html
|
||||||
|
|
||||||
|
译者:[KayGuoWhu](https://github.com/KayGuoWhu)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user