From owner-freebsd-current Tue Feb 22 14:21:10 2000 Delivered-To: freebsd-current@freebsd.org Received: from Stalker.Alfacom.net (SAT.Alfacom.net [207.241.164.112]) by hub.freebsd.org (Postfix) with ESMTP id 45DA637B7AB for ; Tue, 22 Feb 2000 14:20:42 -0800 (PST) (envelope-from vkushnir@Alfacom.net) Received: from kushnir1.kiev.ua (dup-50.alfacom.net [62.244.36.50]) by Stalker.Alfacom.net (8.9.0/8.9.0) with ESMTP id AAA24825 for ; Wed, 23 Feb 2000 00:20:30 +0200 (EET) Received: from localhost (volodya@localhost) by kushnir1.kiev.ua (8.9.3/8.9.3) with ESMTP id AAA08327 for ; Wed, 23 Feb 2000 00:20:22 +0200 (EET) (envelope-from volodya@kushnir1.kiev.ua) Date: Wed, 23 Feb 2000 00:20:21 +0200 (EET) From: Vladimir Kushnir To: current@FreeBSD.ORG Subject: Re: "Interesting" failure mode for static linking with shared libs. In-Reply-To: <20000222090142.A29249@cons.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Actually, this is a (minor) bug in binutils (see patch below): ELF interpreteu is defined as /usr/lib/libc.so.1 rather than (here) /usr/libexec/ld-elf.so.1 On Tue, 22 Feb 2000, Martin Cracauer wrote: > In <32351.951188747@zippy.cdrom.com>, Jordan K. Hubbard wrote: > > root@zippy-> cc -fPIC -c stub.c > > root@zippy-> ld -shared -o stub.so stub.o > > root@zippy-> cc -static test.c -o test stub.so > > root@zippy-> ./test > > ELF interpreter /usr/lib/libc.so.1 not found > > Abort trap > > root@zippy-> cc -static test.c -o test stub.o > > root@zippy-> ./test > > Now in the client, calling doit() > > You have reached the stub. Please leave a message. > > As a workaround for a static binary, you should be able to use > -Xlinker -Bstatic > instead of > -static > > -static links the libs statically and also leaves out the dynamic > loading code from the binary. > > The former leaves the dynamic loading code in the binary, but links > the libs statically. You have a slightly bigger binary, but you don't > need the libs at runtime and you are resistent against changed/faked > libs, which might do the job you want static linking for. > > Martin > Regards, Vladimir --- /usr/src/contrib/binutils/bfd/elf32-i386.c.orig Tue Feb 9 21:57:33 1999 +++ /usr/src/contrib/binutils/bfd/elf32-i386.c Tue Feb 9 21:55:53 1999 @@ -249,7 +249,7 @@ /* The name of the dynamic interpreter. This is put in the .interp section. */ -#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1" +#define ELF_DYNAMIC_INTERPRETER "/usr/libexec/ld-elf.so.1" /* The size in bytes of an entry in the procedure linkage table. */ --- /usr/src/contrib/binutils/bfd/elf64-alpha.c.orig Wed Feb 10 00:39:39 1999 +++ /usr/src/contrib/binutils/bfd/elf64-alpha.c Wed Feb 10 00:40:05 1999 @@ -1018,7 +1018,7 @@ #define MAX_GOT_ENTRIES (64*1024 / 8) -#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so" +#define ELF_DYNAMIC_INTERPRETER "/usr/libexec/ld-elf.so.1" /* Handle an Alpha specific section when reading an object file. This is called when elfcode.h finds a section with an unknown type. -- ===========================|======================= Vladimir Kushnir | vkushnir@Alfacom.net | Powered by FreeBSD kushnir@ap3.bitp.kiev.ua | To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message