From owner-freebsd-hackers Wed Feb 24 22: 6:17 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from rah.star-gate.com (rah.star-gate.com [209.249.129.138]) by hub.freebsd.org (Postfix) with ESMTP id 26A8A14CEE for ; Wed, 24 Feb 1999 22:06:14 -0800 (PST) (envelope-from hasty@rah.star-gate.com) Received: from rah.star-gate.com (localhost.star-gate.com [127.0.0.1]) by rah.star-gate.com (8.9.1/8.8.8) with ESMTP id WAA71554; Wed, 24 Feb 1999 22:04:16 -0800 (PST) (envelope-from hasty@rah.star-gate.com) Message-Id: <199902250604.WAA71554@rah.star-gate.com> X-Mailer: exmh version 2.0.2 2/24/98 To: John Polstra Cc: Archie Cobbs , terry@whistle.com, hackers@FreeBSD.ORG Subject: Re: Interesting ld.so bug In-reply-to: Your message of "Wed, 24 Feb 1999 19:00:29 PST." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 24 Feb 1999 22:04:16 -0800 From: Amancio Hasty Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, I made sure prior to your posting that libgdbm.a was compiled with -fPIC that failed;consequently, I made libdbm a shared library (libdbm compiled with -fPIC ) and kaffe failed with the exact symptom. Amancio > Archie Cobbs wrote: > > John Polstra writes: > >> > 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. > > Hey, you never responded to that. Could you try rebuilding > libgdbm.a with -fpic and see if it fixes the problem? > > > Actually, now something else is going on.. here's some more info: > > > > With db.c Without db.c > > --------- ------------ > > > > RTLD_LAZY fails works! > > > > RTLD_NOW fails fails > > > > Terry thinks there is a screwup in RTLD_NOW in that it's failing > > to recurse. > > I don't think that's it. The code is correct as far as I can see. > The relocation function isn't supposed to recurse -- it simply loops > over all objects that have been loaded since the last time it ran, > relocating each one of them. The recursion was done prior to that, > in load_needed_objects(). > > Any time lazy binding works when immediate binding fails, it's most > likely because the program doesn't ever actually call the problematic > function. So it never has to be bound, therefore the bug isn't > encountered. > > > However, this can be worked around by adding this to the build > > of the library (discoverd by Amancio): > > > > -export-dynamic -lgdbm -lc > > If you are building a shared library, don't link it against non-PIC > static libraries. It kills performance at best, and at worst it is > asking for trouble. You should be using "-lc_pic" here, and libgdbm > needs to have PIC object files in it. > > The --export-dynamic thing might be a clue, but it's awfully hard > for me to tell. There's no way I can duplicate the problem in any > reasonable amount of time based on the description you guys have given > me. Every time I think of trying it, I start to wonder if this is a > trick -- like maybe I'm on Candid Camera, or America's Funniest Home > Videos. "Now let's see if we can get him to attempt constructing THIS > test case, *snicker* *giggle* ..." :-) > > Could you try to distill the test case down to a set of files packed > all together into one gzipped tar file smaller than 2 MB, with a > Makefile such that I can type "make" to build it and "./test" to run > it, and I don't have to install anything into root-owned directories? > That's the only way I'm going to be able to do anything on this one. > > 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message