Date: Mon, 22 Feb 1999 19:40:02 -0800 (PST) From: John Polstra <jdp@polstra.com> To: Archie Cobbs <archie@whistle.com> Cc: hackers@FreeBSD.ORG, (Terry Lambert) <terry@whistle.com> Subject: Re: Interesting ld.so bug Message-ID: <XFMail.990222194002.jdp@polstra.com> In-Reply-To: <199902221912.LAA76945@bubba.whistle.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Archie Cobbs wrote: > Terry Lambert writes: >> There appears to be a bug with ld.so. The following steps illustrate >> the bug: > > After some further playing around, it seems like it may be a linker > problem, or a least a problem in the way we're using it. > > Here's my test case that reproduces the problem: > > We compile a shared library "libfoo" containing these source files: > > bar.c - Containing functions bar1() and bar2(), which are > both exported. Function bar1() calls function bar2(). > > java_jni.c - Java JNI method to interface to function bar1(), > call it Java_bar1(). > > db.c - Other exported routines. The C code in this file > uses GDBM routines. NOTE: GDBM routines live in > a static library, /usr/local/lib/libgdbm.a. > > Now when we run a java class that uses the java_jni.c native method, > the call to Java_bar1() succeeds, and the call from there to bar1() > succeeds, but when bar1() tries to call bar2(), it jumps to a very > low address and segfaults. It seems that the bar2() trampoline is > using an uninitialized base address or whatever. > > NOW, if we remove "db.c" from the compilation of "libfoo.so", > then everything works! Was the code in the static libgdbm.a library compiled with -fpic? I bet it wasn't, and that's probably the problem. All code that's included in a shared library should be PIC code. John --- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Nobody ever went broke underestimating the taste of the American public." -- H. L. Mencken To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.990222194002.jdp>