Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 Jan 1997 10:00:06 -0800
From:      John Polstra <jdp@polstra.com>
To:        roberto@keltia.freenix.fr (Ollivier Robert)
Cc:        hackers@freebsd.org
Subject:   Re: ld with -R weirdness 
Message-ID:  <199701071800.KAA16413@austin.polstra.com>
In-Reply-To: Your message of "Tue, 07 Jan 1997 07:02:23 %2B0100." <Mutt.19970107070223.roberto@keltia.freenix.fr> 
References:  <Mutt.19970105234525.roberto@keltia.freenix.fr> <199701062345.PAA10680@austin.polstra.com>  <Mutt.19970107070223.roberto@keltia.freenix.fr> 

next in thread | previous in thread | raw e-mail | index | archive | help
> > For security reasons, LD_LIBRARY_PATH is ignored for setuid and setgid
> > programs.
> 
> Except that when I'm testing this, the program is not yet installed and
> still belongs to me:

OK, in that case LD_LIBRARY_PATH is not the problem.  The problem is
that you specified the library as "libperl.so.3.19" instead of "-lperl".

> > 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").
> 
> It is recorded in a wrong way IMHO
> 
>   Shared object dependencies:
>       -llibperl.so.3.19  version 0.0
>       -lm                version 2.0
>       -lc                version 3.0
>       -lcrypt            version 2.0

It is recorded correctly, but "ldd -v" is printing it out incorrectly.
That is a bug in ldd.  I'll fix it as soon as I have time.  To help me
remember, it might be a good idea to send a PR about it.

> Even if it were recorded as libperl.so.3.19, it should be able to
> find it with LD_LIBRARY_PATH no ?

No.  The linker distinguishes between libraries specified as "-lxxx"
and libraries specified as file names.  Each shared object dependency
has a flag "sod_library" that is set only if the library was
specified as "-lxxx".  (See LINK(5) and "/usr/include/link.h".)
The search rules are used only for those libraries.  The others
are interpreted as pathnames.  If you want the dynamic linker to
search for a library, you must specify it as "-lxxx".

> > 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".
> 
> It seems to work the same way with and without the ','.

Yes, but it you use it contrary to the manual page, there is no
guarantee it will still work next week, or even tomorrow.
--
   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?199701071800.KAA16413>