freebsd-dev/libexec
Konstantin Belousov bca2f6239d Import the DragonFly BSD commit 4f0bc915b65fcf5a23214f6d221d65c80be68ad4
by John Marino <draco@marino.st>, with the following (edited) commit
message
Date: Sat, 24 Mar 2012 06:40:50 +0100
Subject: [PATCH 1/1] rtld: Implement DT_RUNPATH and -z nodefaultlib

DT_RUNPATH is incorrectly being considered as an alias of DT_RPATH.  The
purpose of DT_RUNPATH is to have two different types of rpath: one that
can be overridden by the environment variable LD_LIBRARY_PATH and one that
can't.  With the currently implementation, LD_LIBRARY_PATH will always
trump any embedded rpath or runpath tags.

Current path search order by rtld:
==================================
LD_LIBRARY_PATH
DT_RPATH / DT_RUNPATH (always the same)
ldconfig hints file (default: /var/run/ld-elf.so.hints)
/usr/lib

New path search order by rtld:
==============================
DT_RPATH of the calling object if no DT_RUNPATH
DT_RPATH of the main binary if no DT_RUNPATH and binary isn't calling obj
LD_LIBRARY_PATH
DT_RUNPATH
ldconfig hints file
/usr/lib

The new path search matches how the linux runtime loader works.  The other
major added feature is support for linker flag "-z nodefaultlib".  When
this flag is passed to the linker, rtld will skip all references to the
standard library search path ("/usr/lib" in this case but it could handle
more color delimited paths) except in DT_RPATH and DT_RUNPATH.

New path search order by rtld with -z nodefaultlib flag set:
============================================================
DT_RPATH of the calling object if no DT_RUNPATH
DT_RPATH of the main binary if no DT_RUNPATH and binary isn't calling obj
LD_LIBRARY_PATH
DT_RUNPATH
ldconfig hints file (skips all references to /usr/lib)

FreeBSD notes:
- we fixed some bugs which were submitted to DragonFly and merged there
  as commit 1ff8a2bd3eb6e5587174c6a983303ea3a79e0002;
- we added LD_LIBRARY_PATH_RPATH environment variable to switch to
  the previous behaviour of considering DT_RPATH a synonym for DT_RUNPATH;
- the FreeBSD default search path is /lib:/usr/lib and not /usr/lib.

Reviewed by:   kan
MFC after:     1 month
MFC note:      flip the ld_library_path_rpath default value for stable/9
2012-07-15 10:53:48 +00:00
..
atrun Make WARNS=6 the default for libexec/. 2010-01-02 09:50:19 +00:00
bootpd Make sure sections are sorted into conventional order. 2012-03-25 16:00:56 +00:00
comsat Make comsat(8) approximately 15% smaller. 2011-12-10 18:35:26 +00:00
fingerd Forgot to initialize the debug variable. 2010-04-01 13:16:32 +00:00
ftpd Spelling fixes for libexec/ 2012-01-07 16:09:54 +00:00
getty mdoc: terminate quoted strings. 2012-03-26 15:18:14 +00:00
lukemftpd Spelling fixes for libexec/ 2012-01-07 16:09:54 +00:00
mail.local Define several extra macros in bsd.sys.mk and sys/conf/kern.pre.mk, to 2012-02-28 18:30:18 +00:00
mknetid Replace index() and rindex() calls with strchr() and strrchr(). 2012-01-03 18:51:58 +00:00
pppoed In libexec/pppoed/pppoed.c, use the correct printf length modifier for a 2011-12-16 16:07:39 +00:00
rbootd mdoc: fix .Bl -offset. 2012-05-23 20:22:09 +00:00
revnetgroup Spelling fixes for libexec/ 2012-01-07 16:09:54 +00:00
rlogind Replace index() and rindex() calls with strchr() and strrchr(). 2012-01-03 18:51:58 +00:00
rpc.rquotad The NFS quota-reporting RPC uses 32-bit sized fields. We approximate 2010-04-25 00:05:51 +00:00
rpc.rstatd Fixed static linkage. 2010-02-26 09:41:16 +00:00
rpc.rusersd Port all apps in libexec/ from libulog to utmpx. 2010-01-13 18:28:58 +00:00
rpc.rwalld add __unused 2010-12-19 13:05:17 +00:00
rpc.sprayd Make WARNS=6 the default for libexec/. 2010-01-02 09:50:19 +00:00
rshd None of these programs actually use auth.conf. 2012-06-11 16:18:39 +00:00
rtld-aout Spelling fixes for libexec/ 2012-01-07 16:09:54 +00:00
rtld-elf Import the DragonFly BSD commit 4f0bc915b65fcf5a23214f6d221d65c80be68ad4 2012-07-15 10:53:48 +00:00
save-entropy 1. Attempt to take one bullet out of the foot-shooting gun by silently 2006-08-28 06:41:50 +00:00
smrsh Define several extra macros in bsd.sys.mk and sys/conf/kern.pre.mk, to 2012-02-28 18:30:18 +00:00
talkd Remove unneeded use of struct timezone. 2010-08-08 02:45:48 +00:00
tcpd Make WARNS=6 the default for libexec/. 2010-01-02 09:50:19 +00:00
telnetd Convert telnetd(8) to use posix_openpt(2). 2008-11-13 19:05:27 +00:00
tftp-proxy Make WARNS=6 the default for libexec/. 2010-01-02 09:50:19 +00:00
tftpd mdoc: Only use macros inside a reference block. 2012-05-23 20:29:16 +00:00
ulog-helper Do a better job at determining the username of the login session. 2012-04-19 21:12:08 +00:00
ypxfr Consistently set RPCGEN_CPP when running rpcgen, so the C preprocessor 2012-02-07 09:27:07 +00:00
Makefile Add a new library: libulog. 2009-12-03 15:48:24 +00:00
Makefile.inc Make WARNS=6 the default for libexec/. 2010-01-02 09:50:19 +00:00