GCC 4.1 / HP-UX 11.23 上的静态/全局构造函数
快速总结: 许多现有代码可以在 gcc 4.1、aCC、VisualAge 和 MSVC 下的众多平台上正常运行。我目前正在努力在 HP-UX 上实现这一点。
输出由多个 (8-10) 个共享库组成。
现在一切都编译得很好,但是当尝试运行任何测试应用程序时,它们会立即在某些全局构造函数中出现段错误。事实上,gdb 甚至无法让我知道这个实际的全局对象在哪里。 si_code 是 SEGV_ACCERR - 对象的权限无效,并且“this”指针始终为 0
初始化是如何调用空对象的 ctor 的?这是 gcc 的全局初始化概念和 HP 的概念(使用 HP 的 ld)之间的冲突吗?
在诊断这个问题时你会去哪里?遗憾的是,我无法将这个问题简化为重现该问题的任何类型的测试用例
Quick summary:
Lots of existing code that works fine on numerous platforms under gcc 4.1, aCC, VisualAge, and MSVC. I am working on getting this up to snuff on HP-UX currently.
The output consists of multiple (8-10) shared libraries.
Everything compiles fine now, but when attempting to run any test apps, they immediately segfault in some global constructor. In fact, gdb can't even get me info on where this actual global object is. The si_code is SEGV_ACCERR - Invalid Permissions for object and the 'this' pointer is always 0
How is it that initialization is calling the ctor of an object that is null? Is this a conflict between gcc's notion of global initialization and HP's notion of it (using HP's ld)?
Where would you go from here in terms of diagnosing this? Sadly, I cannot reduce this problem to any sort of test case that reproduces the issue
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我首先在可执行文件、目标文件和共享库上运行 objdump。寻找可疑的东西,例如虚拟地址为 0(即 NULL)的数据段。
对于共享库,加载器的工作就是进行运行时链接,也许 HP-UX 加载器没有重新定位它应该重新定位的东西。
另外,请查看 GNU ld 信息页面。 CONSTRUCTORS 选项下列出了一些可能有用的信息。不同的对象格式的操作方式不同。
I would start by running
objdump
on the executable files and object files and shared libraries. Look for suspicious things like data segments whose virtual address is 0 (i.e. NULL).With shared libraries, it is the job of the loader to do run-time linking, maybe the HP-UX loader isn't relocating something it should be.
Also, look at the GNU
ld
info pages. There's some potentially useful information listed under the CONSTRUCTORS option. Different object formats operate differently.有关共享库的编译和链接命令行是什么?请务必使用
"g++ -fPIC -c ..."
编译对象,并使用"g++ -fPIC -shared ..."
和 链接它们不直接使用“ld -b ...”
。g++
可能会链接到其他运行时支持代码,这在HP-UX
上可能是必需的。What are your compile and link command lines for the shared libraries in question? Be sure to compile objects with
"g++ -fPIC -c ..."
, and link them with"g++ -fPIC -shared ..."
, and not directly with"ld -b ..."
.g++
may link in additional runtime support code, which may be required onHP-UX
.