Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Feb 2000 00:20:21 +0200 (EET)
From:      Vladimir Kushnir <vkushnir@Alfacom.net>
To:        current@FreeBSD.ORG
Subject:   Re: "Interesting" failure mode for static linking with shared libs.
Message-ID:  <Pine.BSF.4.21.0002230017280.7659-100000@kushnir1.kiev.ua>
In-Reply-To: <20000222090142.A29249@cons.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0002230017280.7659-100000>