使用 debuginfo 编译时,链接器 (ld) 在 Mac OS X 上崩溃,但在不使用 debuginfo 的情况下工作正常

发布于 2024-10-08 22:43:11 字数 1179 浏览 3 评论 0原文

我正在雪豹机器 (10.6.5) 上工作,并且正在寻找 C++ 应用程序中的错误。但是,我无法使用 g++ -O0 -g 构建我们的应用程序,因为链接器崩溃:

g++-4.0 -arch i386 -arch x86_64 ...  -dynamic -bundle -o SOMELIB.dylib <SOME OBJECTS>...
collect2: ld terminated with signal 11 [Segmentation fault]
collect2: ld terminated with signal 11 [Segmentation fault]

我猜这两次崩溃是因为有两个“-arch”标志。 我设法获得了一个核心文件,其中表示崩溃发生在

(gdb) bt
#0  0x000000010001a2eb in Linker::synthesizeDebugNotes ()
#1  0x0000000100024cc5 in Linker::collectDebugInfo ()
#2  0x0000000100028198 in Linker::link ()
#3  0x000000010002a9eb in main ()

有了这个提示,我从编译器标志中删除了“-g”,一切都构建得很好。此外,我们的大多数东西都可以使用“-g”构建良好,但只有两个大模块(.dylibs)不能,所以我没有这些模块的调试信息。而且,具有讽刺意味的是,该错误就潜伏在这些 dylib 之一中。

该错误很可能是由于未初始化的内存使用造成的,因为它很少出现,并且在 valgrind 下运行应用程序表明存在一些未初始化的内存引用,但由于缺少 debuginfo,它只是说它发生在模块 XXX 内( dylib 我无法使用“-g”进行编译)

因此,我尝试从Apple的开源网站下载ld实用程序,但我发现(就像那个家伙),它不会构建,因为缺少对 Mac 特定版本的 libunwind 的依赖,Apple 不会放弃该版本。因此我无法重新编译链接器。

那么下一个问题是——我现在应该做什么?我真的想避免联系Mac支持...

ld版本是“ld64 97.17”,XCode是3.2.5,gcc是4.0.1。

我真的需要一些指导......

I'm working on a snow leopard machine (10.6.5) and I'm hunting a bug in our C++ application. However, I can't build our app with g++ -O0 -g, because the linker crashes:

g++-4.0 -arch i386 -arch x86_64 ...  -dynamic -bundle -o SOMELIB.dylib <SOME OBJECTS>...
collect2: ld terminated with signal 11 [Segmentation fault]
collect2: ld terminated with signal 11 [Segmentation fault]

I guess the two crashes are because there are two "-arch" flags.
I managed to get a core file, which said the crash occurs in

(gdb) bt
#0  0x000000010001a2eb in Linker::synthesizeDebugNotes ()
#1  0x0000000100024cc5 in Linker::collectDebugInfo ()
#2  0x0000000100028198 in Linker::link ()
#3  0x000000010002a9eb in main ()

With this hint, I removed '-g' from the compiler flags, and everything builds fine. Moreover, most of our stuff builds fine with '-g', but just two of the big modules (.dylibs) don't, so I'm left with no debuginfo for those. And, ironically, the bug lurks just there, in one of these dylibs.

The bug is most likely due to an uninitialized memory use, as it manifests rarely, and running the app under valgrind reveals that there are a few uninitialized memory refences, but because of the missing debuginfo, it just says it happens inside module XXX (the dylib I can't compile with "-g")

So, I tried to download the ld utility from Apple's open source website, but I found (just like that guy) that it won't build because of a missing dependency to a Mac-specific version of libunwind, which Apple won't give away. Thus I can't recompile the linker.

So the next question is - what should I do now? I really wanted to avoid contacting Mac support...

ld version is "ld64 97.17", XCode is 3.2.5, gcc is 4.0.1.

I really need some directions...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文