Subject: bin/9284: ld.elf_so is built incorrectly if LD_RUN_PATH is set
To: None <gnats-bugs@gnats.netbsd.org>
From: maximum entropy <entropy@zippy.bernstein.com>
List: netbsd-bugs
Date: 01/23/2000 23:48:38
>Number:         9284
>Category:       bin
>Synopsis:       ld.elf_so is built incorrectly if LD_RUN_PATH is set
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 23 23:48:00 2000
>Last-Modified:
>Originator:     maximum entropy
>Organization:
	
>Release:        <NetBSD-current source date>20000123
>Environment:
	
System: NetBSD zippy.bernstein.com 1.4Q NetBSD 1.4Q (ZIPPY) #0: Sun Jan 23 15:58:53 EST 2000 entropy@zippy.bernstein.com:/usr/src/sys/arch/i386/compile/ZIPPY i386


>Description:
	

If LD_RUN_PATH is set to /usr/pkg/lib when ld.elf_so is built, the
resulting ld.elf_so will cause all dynamically linked programs to fail
with a segmentation violation.

I don't know if any other setting of LD_RUN_PATH could cause it to
fail, but I strongly suspect that it would.

I only experienced this bug on i386, but I suspect it would affect any
ELF platform.

>How-To-Repeat:
	

cd /usr/src/libexec/ld.elf_so
setenv LD_RUN_PATH /usr/pkg/lib
make cleandir && make dependall && make install
su # or any other dynamically linked program

>Fix:
	

Apply this patch to the Makefile for ld.elf_so, to explicitly unset
LD_RUN_PATH before linking.

--- /usr/src/libexec/ld.elf_so/Makefile-orig	Mon Jan 24 02:38:09 2000
+++ /usr/src/libexec/ld.elf_so/Makefile	Mon Jan 24 02:37:02 2000
@@ -41,7 +41,7 @@
 .PATH: $M
 
 ${PROG}: ${OBJS} ${DPADD}
-	${LD} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
+	LD_RUN_PATH= ${LD} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
 .endif
 
 MKMAN=	no
>Audit-Trail:
>Unformatted: