Operating System - HP-UX
1847448 Members
3154 Online
110265 Solutions
New Discussion

Re: exec format error while running JVM using C sl

 
Rajeev_11
New Member

exec format error while running JVM using C sl

Hi,

I am new to HP-UX programming, so your patience is greatly appreciated if I there is a trivial issue here.
I am compiling a simple C shared library for HP-UX 11i that initializes the JVM using JNI_CreateJVM and destroys it after using DestroyJavaVM.

I have set the SHLIB_PATH, LD_LIBRARY_PATH env. variables to point to /opt/java1.4/jre/lib/PA_RISC2.0 and /opt/java1.4/jre/lib/PA_RISC2.0/server.

However, I receive a "exec format error" message when I make a JNI call in my shared library.

I am using a 64-bit HP-UX I compiled my program using the following statements (please correct me if I am wrong):

cc +z -c -I.. -I. -I/opt/java1.4/include -I/opt/java1.4/include/hp-ux -Ae +DAporta
ble +ESsfc +ESlit -DHP11 +u1 invokejvm.c

ld -s -b -L/opt/java1.4/jre/lib/PA_RISC2.0 -L/opt/java1.4/jre/lib/PA_RISC2.0/server -ljava -o libinvokejvm.sl invokejvm.o

The library compiles and links with no errors or warnings.

Has someone encountered this issue before? If yes, please let me know any steps you have taken to evade this error. Thanks.

model : 9000/800/L3000-7x (server)
CPU : (2) PA8600 750 MHz (PA-RISC 2.0)
RAM : 4 GB
OS : HP-UX B.11.11 (64-bit)
JVM : Java 1.4.1.03 (/opt/java1.4/bin/java)
5 REPLIES 5
Steve Steel
Honored Contributor

Re: exec format error while running JVM using C sl

Hi


What is the compiler you have


Maybe problem with using both cfront and aCC libs

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Rajeev_11
New Member

Re: exec format error while running JVM using C sl

Thanks for your response. I have discovered that the shared library is not being able to load to the appropriate shared libraries in the system.

I have managed to run a few tools on the shared library that I have generated. Here is some output that may help in determining the problem:

> odump -sllibload libueEditSharedData.sl
Shared Library Load List for libueEditStatusData.sl:

Order Name

0 libueEditStatusData.sl
1 ^ /opt/java1.4/jre/lib/PA_RISC2.0/server/libjvm.sl
2 ^ ^ /usr/lib/libpthread.1
3 ^ ^ /usr/lib/libdld.2
4 ^ ^ /usr/lib/libm.2
5 ^ ^ /usr/lib/librt.2
6 ^ ^ /usr/lib/libcl.2
7 ^ ^ ^ /usr/lib/libdld.2
8 ^ ^ ^ /usr/lib/libisamstub.1
9 ^ ^ /usr/lib/libCsup.2
10 ^ /opt/java1.4/jre/lib/PA_RISC2.0/libjava.sl
11 ^ ^ /opt/java1.4/jre/lib/PA_RISC2.0/server/libjvm.sl
12 ^ ^ ^ /usr/lib/libpthread.1
13 ^ ^ ^ /usr/lib/libdld.2
14 ^ ^ ^ /usr/lib/libm.2
15 ^ ^ ^ /usr/lib/librt.2
16 ^ ^ ^ /usr/lib/libcl.2
17 ^ ^ ^ ^ /usr/lib/libdld.2
18 ^ ^ ^ ^ /usr/lib/libisamstub.1
19 ^ ^ ^ /usr/lib/libCsup.2
20 ^ ^ /opt/java1.4/jre/lib/PA_RISC2.0/libverify.sl
21 ^ ^ ^ /opt/java1.4/jre/lib/PA_RISC2.0/server/libjvm.sl
22 ^ ^ ^ ^ /usr/lib/libpthread.1
23 ^ ^ ^ ^ /usr/lib/libdld.2
24 ^ ^ ^ ^ /usr/lib/libm.2
25 ^ ^ ^ ^ /usr/lib/librt.2
26 ^ ^ ^ ^ /usr/lib/libcl.2
27 ^ ^ ^ ^ ^ /usr/lib/libdld.2
28 ^ ^ ^ ^ ^ /usr/lib/libisamstub.1
29 ^ ^ ^ ^ /usr/lib/libCsup.2
30 ^ ^ ^ /usr/lib/libc.2
31 ^ ^ ^ ^ /usr/lib/libdld.2
32 ^ ^ /usr/lib/libdld.2
33 ^ ^ /usr/lib/libc.2
34 ^ ^ ^ /usr/lib/libdld.2


> ldd libueEditStatusData.sl


/opt/java1.4/jre/lib/PA_RISC2.0/libjava.sl => /opt/java1.4/jre/lib/PA_
RISC2.0/libjava.sl
/usr/lib/libc.2 => /usr/lib/libc.2
/usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/libc.2 => /usr/lib/libc.2
/usr/lib/libdld.2 => /usr/lib/libdld.2
../../../build/HP_UX/lib/PA_RISC2.0/libverify.sl => /opt/java1.4/jre
/lib/PA_RISC2.0/libverify.sl
/usr/lib/libc.2 => /usr/lib/libc.2
/CLO/Components/JAVA_12/Src/build/HP_UX/lib/PA_RISC2.0/server/libjvm.sl
=> /opt/java1.4/jre/lib/PA_RISC2.0/server/libjvm.sl
/usr/lib/libCsup.2 => /usr/lib/libCsup.2
/usr/lib/libcl.2 => /usr/lib/libcl.2
/usr/lib/libisamstub.1 => /usr/lib/libisamstub.1
/usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/librt.2 => /usr/lib/librt.2
/usr/lib/libm.2 => /usr/lib/libm.2
/usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/libpthread.1 => /usr/lib/libpthread.1
/CLO/Components/JAVA_12/Src/build/HP_UX/lib/PA_RISC2.0/server/libjvm.sl
=> /opt/java1.4/jre/lib/PA_RISC2.0/server/libjvm.sl
/opt/java1.4/jre/lib/PA_RISC2.0/server/libjvm.sl => /opt/java1.4/jre
/lib/PA_RISC2.0/server/libjvm.sl

> fastbind

fastbind: Exec format error
fastbind: End of file encountered during read.

FYI, I am using the standard HP-UX 11i compiler (cc or cc_bundled) that comes with the default installation.

Does anyone know if patch PHSS_30968 might aid in resolving this issue?

Thank you for your help.
Ermin Borovac
Honored Contributor

Re: exec format error while running JVM using C sl

From what I understand you are trying to run fastbind on the shared library. I think you are supposed to run fastbind on the final executable instead.

To perform fastbind during compile you can option +fb to linker (ld) or -Wl,+fb to compiler (cc).
Rajeev_11
New Member

Re: exec format error while running JVM using C sl

I apologize for the typo.

The command I ran is: fastbind libueEditStatusData.sl

I have also noticed that whenever I run fastbind on a shared lib, it returns the exec format error. I am thinking that I am incorrectly using fastbind.

Can anyone tell me how to do a static linkage to the libraries listed in the odump ?
Ermin Borovac
Honored Contributor

Re: exec format error while running JVM using C sl

I'm not sure why you are using fastbind on a shared library. fastbind is used to improve start-up time of programs that are linked with shared libraries. It caches information inside executable file, and that helps dynamic loader which uses this cached information instead of searching for symbols.

Back to your original problem with 'exec format error' when making JNI call in your shared library. Does it also come up with error message saying that "can't shl_load() a library containing Thread Local Storage" etc?

To overcome this problem you can define environment variable LD_PRELOAD and set it to full path to the library dld.sl is complaining about.

$ LD_PRELOAD=/opt/java1.4/jre/lib/PA_RISC2.0/server/libjvm.sl

Your dynamic loader must be up to date to support LD_PRELOAD. Check man page for dld.sl , if there are references to LD_PRELOAD all the chances are it will work.