freebsd-dev/libexec/rtld-elf
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
..
amd64 Add GNU hash support for rtld. 2012-04-30 13:31:10 +00:00
arm Add GNU hash support for rtld. 2012-04-30 13:31:10 +00:00
i386 Add GNU hash support for rtld. 2012-04-30 13:31:10 +00:00
ia64 Add GNU hash support for rtld. 2012-04-30 13:31:10 +00:00
mips Before jumping to application's entry point set ra == pc in order 2012-03-23 17:54:06 +00:00
powerpc Add GNU hash support for rtld. 2012-04-30 13:31:10 +00:00
powerpc64 Add GNU hash support for rtld. 2012-04-30 13:31:10 +00:00
sparc64 Add GNU hash support for rtld. 2012-04-30 13:31:10 +00:00
debug.c Rtld links with the specially built pic static libc library to get some 2011-08-24 20:05:13 +00:00
debug.h Use C99's varadic macro syntax instead of gcc's. 2006-03-28 18:26:47 +00:00
libmap.c open the resolved path 2012-05-05 16:37:14 +00:00
libmap.h Description from Dan: 2005-02-04 02:46:41 +00:00
Makefile Remove libssp_nonshared from the rtld linking set. The only use for the 2012-03-24 19:14:44 +00:00
malloc.c Remove the fragments which are not needed on FreeBSD. The caltech 2012-03-22 14:11:10 +00:00
map_object.c Eliminate the static buffer used to read the first page of the mapped 2012-06-14 11:20:22 +00:00
rtld_lock.c Rtld links with the specially built pic static libc library to get some 2011-08-24 20:05:13 +00:00
rtld_lock.h Implement support for ELF filters in rtld. Both normal and auxillary 2010-12-25 08:51:20 +00:00
rtld_printf.c Remove the use of toupper() from rtld_printf.c. Use of the libc function 2012-03-09 16:21:40 +00:00
rtld_printf.h Rtld links with the specially built pic static libc library to get some 2011-08-24 20:05:13 +00:00
rtld_tls.h Add support for Thread Local Storage. 2004-08-03 08:51:00 +00:00
rtld.1 Import the DragonFly BSD commit 4f0bc915b65fcf5a23214f6d221d65c80be68ad4 2012-07-15 10:53:48 +00:00
rtld.c Import the DragonFly BSD commit 4f0bc915b65fcf5a23214f6d221d65c80be68ad4 2012-07-15 10:53:48 +00:00
rtld.h Import the DragonFly BSD commit 4f0bc915b65fcf5a23214f6d221d65c80be68ad4 2012-07-15 10:53:48 +00:00
Symbol.map Implement fdlopen(3), an rtld interface to load shared object by file 2012-01-07 10:33:01 +00:00
xmalloc.c Implement xstrdup() using strlen()/xmalloc()/memcpy() already 2012-03-23 12:04:44 +00:00