tags:

views:

175

answers:

2

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

+1  A: 

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.

Artelius
A: 

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 on HP-UX.

Employed Russian
Yes, I am using g++ in both cases, with -fPIC -mlp64, and additional -shared -Wl,-z on the link side (plus a handful of other project specific flags)
phrakture