This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Problem with -c and -shared in gcj



Hi all,

Got the latest egcs and libgcj to test out automated dynamic class loading 
from .so files. For some reason the .so's are not being found, however. 
After a lot of gruntwork I narrowed it down to this: dlopen() (from 
sys_dl_open() in libltdl) is getting the error
	./JavaMicroBench.so: ELF file's phentsize not the expected size
(where JavaMicroBench.so is, obviously, the .so corresponding to the class
I'm trying to load.) 

I produced this .so file with the command
	gcj -c -shared -o JavaMicroBench.so JavaMicroBench.java
Just like Tom's recent e-mail showed:
	http://sourceware.cygnus.com/ml/java-discuss/2000-q1/msg00213.html

Well, it turns out that using -c and -shared at the same time actually 
produces a *static* object, not a *shared* one. In other words,
	gcj -c -shared -o JavaMicroBench.so JavaMicroBench.java
Actually produces a normal ".o" file -- even though we used "-shared".

Probably just an option-parsing bug in gcj or egcs. ANYWAY, Jeff Sturm 
pointed out correctly that -c and -shared shouldn't both work at the same
time. My guess is that Tom's example worked for him because he had a .class
or something else sitting around which was being found after the load of the
(badly formed) .so failed - am I right?

So dynamic class loading works fine if I do
	gcj -shared -o JavaMicroBench.so JavaMicroBench.java
	gij JavaMicroBench

It loads the .so file on demand and runs the class from there - bitchin'!

Matt Welsh

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]