Static / Global Constructors on GCC 4.1 / HP-UX 11.23

Brief summary: Lots of existing code that works great on many platforms under gcc 4.1, aCC, VisualAge and MSVC. I am currently working on pulling tobacco on it to HP-UX.

The output consists of multiple (8-10) shared libraries.

Everything compiles fine now, but when trying to run any test applications they immediately segfault in some kind of global constructor. In fact, gdb cannot even get information about where this actual global object is located. Si_code - SEGV_ACCERR - Invalid object permissions and 'this' pointer is always 0

How does this initialization call the ctor of an object that is null? Is this a conflict between gcc's notion of global initialization and HP's understanding of it (using HP ld)?

Where would you go next in terms of diagnosing this? Unfortunately I am unable to reduce this issue to any type of test case that reproduces the issue.

+2


source to share


2 answers


I would start by running objdump

in executables and object files and shared libraries. Look for suspicious things, such as data segments whose virtual address is 0 (i.e. NULL).

In shared libraries, the loader's job is to do the load at runtime, perhaps the HP-UX loader isn't moving what it should be.



Also, check out the GNU information pages ld

. There is potentially useful information listed under the CONSTRUCTORS option. Different object formats work in different ways.

+1


source


What are your command lines for compilation and links for shared libraries? Remember to compile the objects with "g++ -fPIC -c ..."

and link them with "g++ -fPIC -shared ..."

, not directly with "ld -b ..."

. g++

may reference additional runtime support code that may be required on HP-UX

.



0


source







All Articles