Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否存在任何方法来检测代码是否使用 -flto 编译?
示例是使用 GCC (4.9.1) 编译的 Linux 下的经典库或可执行文件,无需调试。
考虑到 LTO 信息存储在目标文件内的几个 ELF 部分中(请参阅LTO 文件部分),您可以尝试查看readelf返回的内容(例如在此答案中使用的)。
readelf
寻找.gnu.lto_.xxx条目。
.gnu.lto_.xxx