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

j0k
  • 22,600
  • 28
  • 79
  • 90
phrakture
  • 21
  • 2
  • 1
    Bit of an update: On a whim, I added a printf to the ctor which was failing (it was previously empty). When next I tried a sample app, it crashed at a DIFFERENT global constructor... so I repeated and the same happened. Is it possible that something is optimizing empty constructors away? That doesn't seem logical, but this *is* HP-UX – phrakture Sep 29 '09 at 00:03

2 Answers2

1

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
  • 48,337
  • 13
  • 89
  • 105
0

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
  • 199,314
  • 34
  • 295
  • 362
  • 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 Sep 29 '09 at 15:16