From owner-freebsd-hackers Mon Jan 6 15:48:31 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id PAA11088 for hackers-outgoing; Mon, 6 Jan 1997 15:48:31 -0800 (PST) Received: from mail.crl.com (mail.crl.com [165.113.1.22]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id PAA11073 for ; Mon, 6 Jan 1997 15:48:24 -0800 (PST) Received: from austin.polstra.com by mail.crl.com with SMTP id AA01911 (5.65c/IDA-1.5 for ); Mon, 6 Jan 1997 15:48:18 -0800 Received: (from jdp@localhost) by austin.polstra.com (8.8.3/8.8.3) id PAA10672; Mon, 6 Jan 1997 15:45:34 -0800 (PST) To: freebsd-hackers@freebsd.org Path: not-for-mail From: jdp@polstra.com (John Polstra) Newsgroups: polstra.freebsd.hackers Subject: Re: ld with -R weirdness Date: 6 Jan 1997 15:45:33 -0800 Organization: Polstra & Co., Seattle, WA Lines: 59 Distribution: local Message-Id: <5as2qt$add@austin.polstra.com> References: Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In article , Ollivier Robert wrote: > In suidperl case, the command line given to gcc (then ld) is the following: > > cc -L/usr/local/lib -Wl,-R,/usr/local/lib/perl5/i386-freebsd/5.00319/CORE > -o suidperl perlmain.o sperl.o lib/auto/DynaLoader/DynaLoader.a > libperl.so.3.19 `cat ext.libs` -lm -lc -lcrypt > > The problem is that afterward, ld.so is NOT able to find libperl.so.3.19... > > 608 [23:40] roberto@keltia:/build/perl5.003_10> ( cd lib ; ldd ../suidperl) > ../suidperl: > libperl.so.3.19 (0x0) > -lm.2 => /usr/lib/libm.so.2.0 (0x8025000) > -lc.3 => /usr/lib/libc.so.3.0 (0x803c000) > -lcrypt.2 => /usr/lib/libcrypt.so.2.0 (0x80ad000) > > Even WITH LD_LIBRARY_PATH defined... For security reasons, LD_LIBRARY_PATH is ignored for setuid and setgid programs. > When I patch the Makefile to have > > cc -L/usr/local/lib -Wl,-R,/usr/local/lib/perl5/i386-freebsd/5.00319/CORE > -o suidperl perlmain.o sperl.o lib/auto/DynaLoader/DynaLoader.a > -lperl `cat ext.libs` -lm -lc -lcrypt > > It works ! If you specify the library name explicitly ("libperl.so.3.19"), it is recorded as a direct reference to that particular file, and no searching is done. Directories are searched only if you specify the library generically ("-lperl"). > Looking inside the suidperl executable, I find the following weird strings: > > o/usr/local/lib/perl5/i386-freebsd/5.00319/CORE > libperl.so.3.19 > crypt > > Where does the 'o' before the path come from ? This is not anything to worry about. The string begins with the "/" character. The byte before the string happens to contain a value which is the same as the ASCII for "o". Every byte contains _some_ value, and there is a reasonably high probability that any given byte will contain the ASCII code for a printable character. I should mention one other thing. If LD(1) is to be believed, there should be no space between ld's "-R" option and the "record-library-search-path" that follows it. (Just like the "-L" option.) You probably should remove the "," after "-Wl,-R". John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Self-knowledge is always bad news." -- John Barth