On Tue, Jul 28, 2009 at 02:49:40PM +0800, Weijun Wang wrote:
> Nicolas Williams wrote:
> > On Tue, Jul 28, 2009 at 12:02:54PM +0800, Weijun Wang wrote:
> >> So it seems I cannot build a binary which works with both of them. Is
> > 
> > Correct.
> 
> So even if I link with one at build time, the output still works with
> only one of Solaris and MIT binaries.

The header file defines the ABI.  If you use one implementation's
headers at compile time, then you must use that implementation's library
at run-time.

> > But why are you trying to be able to use both?  Just build against the
> > Solaris libkrb5 and be done.  No dlopen() required (Java will have to
> > dlopen your JNI, but your JNI should not have to dlopen() libkrb5).
> 
> This means the build machine must install Solaris 8/07 or later, but our
> release engineers may prefer an older version so that JDK can be used on
> more systems. So my ideal process is including a copy of krb5.h inside
> JDK and dlopen() the .so.

I see.  But wouldn't a JNI that fails to dlopen because of missing
dependencies also fail to load into Java?  If so, and if the Java
Kerberos code can recover, then do that.

You'd still have the problem that you'd like to build on earlier
releases of S10, which means you'd have to use dlopen() in your JNI,
yes, and copy the krb5 header files from a newer S10 system into your
build system.

And I see why you were trying MIT krb5: you needed at least headers for
S10 updates that lack the public krb5 API.  I guess that you also want
to deliver a private copy of MIT libkrb5 with your JNI.  Can you
describe exactly what you're trying to do?

Or you could have two builds for S10: one for updates that don't have a
public krb5 API, and one for updates that do.  I'm guessing you won't
want to do that, but you should consider it.

> > (The biggest difference between the Solaris and MIT krb5 APIs and ABIs
> > relates to krb5_keyblock.  It's a long story, and it's been told more
> > than once on various mailing lists.)
> 
> Is there a trick that I can detect what the current binary structure is?

Most likely, yes.  You'd have to find at least one symbol that is in
Solaris' libkrb5, but that is very unlikely to ever appear in MIT
libkrb5 (or vice-versa).  The key issue is that a large number of
structures' sizes and layouts are part of the two ABIs, so you'd have to
carefully check which ones differ.  Most likely only krb5_keyblock
differs (it's larger on Solaris, having extra fields on the end).  If
only krb5_keyblock differs then you can probably get away with having
very little conditional code to deal with the Solaris<->MIT krb5 ABI
differences.

But I strongly recommend that you don't bother with that.  Just copy the
krb5 headers from a newer S10 system into your build system, build and
use dlopen() as you suggest.  Although first see what happens when you
try to load a JNI whose ELF dependencies cannot be satisfied (see
above).

Nico
-- 

Reply via email to