博客
关于我
Linux:ldd命令详解
阅读量:800 次
发布时间:2023-02-05

本文共 720 字,大约阅读时间需要 2 分钟。

ldd工具:打印程序依赖的共享库列表

语法

ldd(选项)(参数)

其中,选项参数具体如下:

选项

  • --version:显示指令版本号
  • -v:详细信息模式,打印所有相关信息
  • -u:打印未使用的直接依赖
  • -d:执行重定位和报告丢失对象
  • -r:执行数据对象和函数重定位,报告丢失对象和函数
  • --help:显示帮助信息

参数

  • 文件:指定可执行程序或文库

工作原理

ldd并非可执行程序,而是一个 shell 脚本。其工作原理基于设置一系列环境变量(如 LD_TRACE_LOADED_OBJECTSLD_WARN 等)。当 LD_TRACE_LOADED_OBJECTS 设置为非空值时,可执行程序运行时会仅显示模块的依赖信息而不实际执行程序。

ldd通过 ld-linux.so(elf动态库的装载器)实现其功能。ld-linux.so 在程序运行前获得控制权,因此当上述环境变量设置时,ldd会展示可执行模块的依赖关系。实际上,可以直接调用 ld-linux.so 模块进行类似操作,例如:

/lib/ld-linux.so.2 --list program(相当于 ldd program

示例使用

# 打印可执行程序的直接依赖export LD_TRACE_LOADED_OBJECTS=1./your_program# 显示详细依赖信息(推荐使用)export LD_VERBOSE=1export LD_TRACE_LOADED_OBJECTS=1./your_program

注意事项

  • 文件路径:请确保提供的文件路径正确,避免出现 file not found 错误。
  • 环境变量:请谨慎设置相关环境变量,以免影响系统正常功能。

转载地址:http://bwufk.baihongyu.com/

你可能感兴趣的文章
NMF(非负矩阵分解)
查看>>
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named 'pandads'
查看>>