ERROR: could not load library "...": Exec format error

Lists: pgsql-generalpgsql-hackers
From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-general(at)postgresql(dot)org
Subject: ERROR: could not load library "...": Exec format error
Date: 2010-02-09 11:27:05
Message-ID: 4B714689.6060103@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Hi,

I have the $SUBJECT problem loading my own
module in PostgreSQL. The server is HP-UX/ia64,
PostgeSQL 8.4.2 was compiled with HP CC.
pl/PgSQL can be loaded fine.

...:/usr/local/pgsql/pgsql-cc-8.4/lib# ldd odbclink.so
libodbc.so.1 => /usr/local/pgsql/runtime/lib/libodbc.so.1
libpthread.so.1 => /usr/lib/hpux64/libpthread.so.1
libc.so.1 => /usr/lib/hpux64/libc.so.1
libdl.so.1 => /usr/lib/hpux64/libdl.so.1

"/usr/local/pgsql/runtime" is a link to "/usr/local/pgsql/pgsql-cc-8.4"

...:/usr/local/pgsql/pgsql-cc-8.4/lib# file plpgsql.so odbclink.so
plpgsql.so: ELF-64 shared object file - IA64
odbclink.so: ELF-64 shared object file - IA64

The module compilation was done using "USE_PGXS=1 gmake".

How can I solve this issue?

Thanks in advance,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/


From: Korry Douglas <korry(dot)douglas(at)enterprisedb(dot)com>
To: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: could not load library "...": Exec format error
Date: 2010-02-09 14:37:35
Message-ID: 850DF5FF-83F7-4ABE-A017-65F92176AAC1@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

> I have the $SUBJECT problem loading my own
> module in PostgreSQL. The server is HP-UX/ia64,
> PostgeSQL 8.4.2 was compiled with HP CC.
> pl/PgSQL can be loaded fine.
>
> ...:/usr/local/pgsql/pgsql-cc-8.4/lib# ldd odbclink.so
> libodbc.so.1 => /usr/local/pgsql/runtime/lib/libodbc.so.1
> libpthread.so.1 => /usr/lib/hpux64/libpthread.so.1
> libc.so.1 => /usr/lib/hpux64/libc.so.1
> libdl.so.1 => /usr/lib/hpux64/libdl.so.1
>
> "/usr/local/pgsql/runtime" is a link to "/usr/local/pgsql/pgsql-
> cc-8.4"
>
> ...:/usr/local/pgsql/pgsql-cc-8.4/lib# file plpgsql.so odbclink.so
> plpgsql.so: ELF-64 shared object file - IA64
> odbclink.so: ELF-64 shared object file - IA64
>
> The module compilation was done using "USE_PGXS=1 gmake".
>
> How can I solve this issue?

IIRC, HP/UX doesn't like to dynamic-load shared libraries that use
thread-local storage. Your shared library (odbclink.so) is linked
against libpthread.so.1 so you may be running into that problem. I
would recommend running the HP/UX equivalent of strace to capture more
information about the call to dlopen() (or perhaps shl_load(),
depending on which version of HP/UX you are using).

-- Korry

-----------------------------------------------------------------------
Korry Douglas
Senior Database Dude
EnterpriseDB Corporation
The Enterprise Postgres Company

Phone: (804)241-4301
Mobile: (620) EDB-NERD


From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: Korry Douglas <korry(dot)douglas(at)enterprisedb(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: could not load library "...": Exec format error
Date: 2010-02-09 16:25:02
Message-ID: 4B718C5E.9070206@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Korry Douglas írta:
>> I have the $SUBJECT problem loading my own
>> module in PostgreSQL. The server is HP-UX/ia64,
>> PostgeSQL 8.4.2 was compiled with HP CC.
>> pl/PgSQL can be loaded fine.
>>
>> ...:/usr/local/pgsql/pgsql-cc-8.4/lib# ldd odbclink.so
>> libodbc.so.1 => /usr/local/pgsql/runtime/lib/libodbc.so.1
>> libpthread.so.1 => /usr/lib/hpux64/libpthread.so.1
>> libc.so.1 => /usr/lib/hpux64/libc.so.1
>> libdl.so.1 => /usr/lib/hpux64/libdl.so.1
>>
>> "/usr/local/pgsql/runtime" is a link to "/usr/local/pgsql/pgsql-cc-8.4"
>>
>> ...:/usr/local/pgsql/pgsql-cc-8.4/lib# file plpgsql.so odbclink.so
>> plpgsql.so: ELF-64 shared object file - IA64
>> odbclink.so: ELF-64 shared object file - IA64
>>
>> The module compilation was done using "USE_PGXS=1 gmake".
>>
>> How can I solve this issue?
>
>
> IIRC, HP/UX doesn't like to dynamic-load shared libraries that use
> thread-local storage. Your shared library (odbclink.so) is linked
> against libpthread.so.1 so you may be running into that problem. I
> would recommend running the HP/UX equivalent of strace to capture more
> information about the call to dlopen() (or perhaps shl_load(),
> depending on which version of HP/UX you are using).

Yes, it seems you are right, I have read dlopen(3) in full on HP-UX,
this small detail is documented there. It seems I need to preload
the libraries: odbclink.so, libodbc.so.1 and all the needed libs from
the target ODBC driver... Thanks for the info.

Best regards,
Zoltán Böszörményi

>
>
> -- Korry
>
>
> -----------------------------------------------------------------------
> Korry Douglas
> Senior Database Dude
> EnterpriseDB Corporation
> The Enterprise Postgres Company
>
> Phone: (804)241-4301
> Mobile: (620) EDB-NERD
>
>

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/


From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: Korry Douglas <korry(dot)douglas(at)enterprisedb(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, PG Hackers <pgsql-hackers(at)postgresql(dot)org>, Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ERROR: could not load library "...": Exec format error
Date: 2010-02-09 22:05:55
Message-ID: 4B71DC43.7040101@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Boszormenyi Zoltan írta:
> Korry Douglas írta:
>
>>> I have the $SUBJECT problem loading my own
>>> module in PostgreSQL. The server is HP-UX/ia64,
>>> PostgeSQL 8.4.2 was compiled with HP CC.
>>> pl/PgSQL can be loaded fine.
>>>
>>> ...:/usr/local/pgsql/pgsql-cc-8.4/lib# ldd odbclink.so
>>> libodbc.so.1 => /usr/local/pgsql/runtime/lib/libodbc.so.1
>>> libpthread.so.1 => /usr/lib/hpux64/libpthread.so.1
>>> libc.so.1 => /usr/lib/hpux64/libc.so.1
>>> libdl.so.1 => /usr/lib/hpux64/libdl.so.1
>>>
>>> "/usr/local/pgsql/runtime" is a link to "/usr/local/pgsql/pgsql-cc-8.4"
>>>
>>> ...:/usr/local/pgsql/pgsql-cc-8.4/lib# file plpgsql.so odbclink.so
>>> plpgsql.so: ELF-64 shared object file - IA64
>>> odbclink.so: ELF-64 shared object file - IA64
>>>
>>> The module compilation was done using "USE_PGXS=1 gmake".
>>>
>>> How can I solve this issue?
>>>
>> IIRC, HP/UX doesn't like to dynamic-load shared libraries that use
>> thread-local storage. Your shared library (odbclink.so) is linked
>> against libpthread.so.1 so you may be running into that problem. I
>> would recommend running the HP/UX equivalent of strace to capture more
>> information about the call to dlopen() (or perhaps shl_load(),
>> depending on which version of HP/UX you are using).
>>
>
> Yes, it seems you are right, I have read dlopen(3) in full on HP-UX,
> this small detail is documented there. It seems I need to preload
> the libraries: odbclink.so, libodbc.so.1 and all the needed libs from
> the target ODBC driver... Thanks for the info.
>

Actually, I experimented with a "threaded" PostgreSQL server,
I added LDFLAGS="-lpthreads" to the PG configure options
and suddenly my module that's linked to libraries also linked
with libpthread.so started working. The dlopen(3) man page
doesn't say this as a working constellation.

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/