otool 与 lldb 图像列表:附加库来自哪里?

问题描述 投票:0回答:1

我想找出为什么我的程序使用

libsqlite3.dylib
, 当我不链接它时。

otool -L my/program
显示:

    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2420.0.0)
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 2420.0.0)
    /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration (compatibility version 1.0.0, current version 1300.100.9)
    /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 61123.100.169)
    @rpath/QtConcurrent.framework/Versions/5/QtConcurrent (compatibility version 5.15.0, current version 5.15.9)
    @rpath/QtBluetooth.framework/Versions/5/QtBluetooth (compatibility version 5.15.0, current version 5.15.9)
    @rpath/QtSvg.framework/Versions/5/QtSvg (compatibility version 5.15.0, current version 5.15.9)
    @rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.15.0, current version 5.15.9)
    @rpath/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.15.0, current version 5.15.9)
    @rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.15.0, current version 5.15.9)
    @rpath/QtQmlModels.framework/Versions/5/QtQmlModels (compatibility version 5.15.0, current version 5.15.9)
    @rpath/QtQml.framework/Versions/5/QtQml (compatibility version 5.15.0, current version 5.15.9)
    @rpath/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.15.0, current version 5.15.9)
    @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.15.0, current version 5.15.9)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1700.255.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2)

这看起来正是我与我的程序链接的内容。

但是如果我运行

lldb my/program
,然后
image list
before 在调试器中运行我的程序,我会得到 338 共享库,包括
/usr/lib/libsqlite3.dylib

看起来

lldb
是正确的,因为在调试过程中我看到使用
libsqlite3.dylib
而不是静态链接的sqlite3。

那么为什么在程序执行之前

otool -L
不匹配
lldb image list
,所以没有人调用
dlopen
或类似的东西?

xcode macos lldb otool
1个回答
0
投票

lldb 从二进制文件中的加载命令开始 - 它仅列出二进制文件的直接依赖项。但它并不止于此,然后它会查找每个二进制文件的直接依赖项,读取它们的加载命令,然后继续遍历依赖项树,直到枚举所有启动时依赖项。

otool 仅呈现二进制文件的直接依赖关系,但预启动 lldb 呈现其依赖关系的关闭。

由于加载所有这些库的目的是为了让您可以列出函数、设置断点、反汇编函数等。更有用的是呈现 lldb 可以计算出将在进程中加载的所有内容,而不仅仅是直接依赖项。

© www.soinside.com 2019 - 2024. All rights reserved.