【发布时间】:2021-11-24 02:21:09
【问题描述】:
我很好奇,决定在我为 Linux (Ubuntu 20.04) 编译的 Rust 应用程序上运行 file 命令。为什么可执行文件“动态链接”?我虽然默认情况下 Rust 二进制文件是静态链接的。
$ file my_hello_world_app
my_hello_world_app: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[xxHash]=5ddb20be333a274e, with debug_info, not stripped
我测试了几个 Rust bin 应用程序,最后一个是通过 cargo new ... 创建的全新 hello-world 应用程序,并简单地使用 cargo build --release 构建。我还测试了两个不同的链接器:默认链接器和 LLD。在所有情况下,file 命令都显示为“动态链接”。
【问题讨论】: