Skip site navigation (1)Skip section navigation (2)
Date:      6 Jan 1997 15:45:33 -0800
From:      jdp@polstra.com (John Polstra)
To:        freebsd-hackers@freebsd.org
Subject:   Re: ld with -R weirdness
Message-ID:  <5as2qt$add@austin.polstra.com>
References:  <Mutt.19970105234525.roberto@keltia.freenix.fr>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <Mutt.19970105234525.roberto@keltia.freenix.fr>,
Ollivier Robert <roberto@keltia.freenix.fr> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5as2qt$add>