Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
station
V2EX  ›  Linux

多个版本的库,如何知道系统加载的是那个版本?

  •  
  •   station · Jan 7, 2017 · 2590 views
    This topic created in 3439 days ago, the information mentioned may be changed or developed.
    例如,我系统里有 libz.so.1.2.7 和 libz.so.1.2.8


    /lib64/libz.so.1.2.7: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=ea8e45dc8e395cc5e26890470112d97a1f1e0b65, stripped


    libz.so.1.2.8: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=2421ab648709f7d0b2047e8e638118a0020dff2f, not stripped


    not stripped 和 stripped 有什么区别 ? 如何生成 stripped 的库
    5 replies    2017-01-08 07:58:17 +08:00
    julyclyde
        1
    julyclyde  
       Jan 7, 2017
    没有“系统加载了哪个”这一说
    只能看某个程序运行的时候链接了哪个
    lhbc
        2
    lhbc  
       Jan 7, 2017   ❤️ 1
    1. Linux 内核不会加载这些库
    2. 库是给核心之外的程序用的。你要知道某个程序加载的是哪个库,用 ldd /path/to/bin/file
    3. stripped 搜索一下就有介绍了。自己编译的程序建议用 strip 去掉这些内容
    P0P
        3
    P0P  
       Jan 7, 2017
    1. ldd
    2.strip
    julyclyde
        4
    julyclyde  
       Jan 8, 2017   ❤️ 1
    @lhbc 准确的说 ldd 只是“妄图”加载哪个版本。实际情况得看 /proc/PID/maps
    lhbc
        5
    lhbc  
       Jan 8, 2017 via iPhone   ❤️ 1
    @julyclyde 嗯,对。可能因为不同用户或者启动脚本 /配置里的 LD_LIBRARY_PATH 不同,会加载不一样的库。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4753 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 95ms · UTC 09:57 · PVG 17:57 · LAX 02:57 · JFK 05:57
    ♥ Do have faith in what you're doing.