简体   繁体   English

从 linux 共享库中剥离调试信息

[英]Strip debug info from linux shared library

I'm using GCC to compile a shared library for ARM Linux.我正在使用 GCC 为 ARM Linux 编译共享库。 Here's my compiler options from CMakeLists.txt:这是我来自 CMakeLists.txt 的编译器选项:

add_definitions( "-std=c++14 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wno-psabi -march=native -mfpu=neon" )

I've just opened the resulting .so file in a disassembler.我刚刚在反汇编程序中打开了生成的 .so 文件。 I was disappointed to see a lot of stuff there.看到那里有很多东西,我很失望。 It showed me names for everything, including all my internal classes, and functions that were never exported.它向我展示了所有东西的名称,包括我所有的内部类,以及从未导出的函数。 Even the stuff from anonymous namespaces is still there.甚至来自匿名命名空间的东西仍然存在。 On the “Exports” tab on the disassembler, I only see a dozen of functions I actually export (plus just a few extra: .init_proc .term_proc _edata __bss_end__ and call_weak_fn ).在反汇编器的“导出”选项卡上,我只看到了我实际导出的十几个函数(加上一些额外的: .init_proc .term_proc _edata __bss_end__call_weak_fn )。

On Windows, I only see these things if I have a PDB file for the module I'm disassembling.在 Windows 上,如果我有我正在拆卸的模块的 PDB 文件,我只会看到这些东西。 But I don't ship my .PDB files.但我不发送我的 .PDB 文件。

I'd like the same behavior for GCC.我希望 GCC 也有同样的行为。

Is there a way to tell GCC to stop including that debug info (=the mangled name of each and every function) in the .so file, and actually compile these things into binary addresses?有没有办法告诉 GCC 停止在 .so 文件中包含调试信息(=每个函数的重整名称),并实际将这些东西编译成二进制地址?

您需要将-Wl,--strip-debug添加到您的链接器标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM