OpenBSD CVS

CVS log for src/libexec/ld.so/loader.c


[BACK] Up to [local] / src / libexec / ld.so

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.223 / (download) - annotate - [select for diffs], Mon Jan 22 02:08:31 2024 UTC (4 months, 2 weeks ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, HEAD
Changes since 1.222: +3 -3 lines
Diff to previous 1.222 (colored)

ugly whitespaces

Revision 1.222 / (download) - annotate - [select for diffs], Fri Jan 19 14:16:41 2024 UTC (4 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.221: +2 -21 lines
Diff to previous 1.221 (colored)

Stop initializing pinsyscall(SYS_execve in dynamic binaries that contain
a reference reaching the execve(2) stub.  The new pinsyscalls(2) that
applies to all system calls has made this redundant.

Revision 1.221 / (download) - annotate - [select for diffs], Wed Jan 17 13:00:05 2024 UTC (4 months, 3 weeks ago) by deraadt
Branch: MAIN
Changes since 1.220: +2 -2 lines
Diff to previous 1.220 (colored)

very ugly whitespaces

Revision 1.220 / (download) - annotate - [select for diffs], Tue Jan 16 19:07:31 2024 UTC (4 months, 3 weeks ago) by deraadt
Branch: MAIN
Changes since 1.219: +6 -3 lines
Diff to previous 1.219 (colored)

Read PT_OPENBSD_SYSCALLS in libc.so, and convert it to a table for
pinsyscalls(2).
ok kettenis

Revision 1.219 / (download) - annotate - [select for diffs], Sun Jan 14 09:39:03 2024 UTC (4 months, 3 weeks ago) by kettenis
Branch: MAIN
Changes since 1.218: +31 -1 lines
Diff to previous 1.218 (colored)

Whenever we have a libc major bump, we run the risk that dependent shared
libraries will request a different (major) libc version from the one
requested by the binary itself.  For various reasons loading multiple libc
versions is not a good idea, and since the introduction of msyscall(2)
support, system calls will only work when called from one of the two loaded
libcs.  This really means that when we have a libc major bump, users must
update all dynamic executables and shared libraries in the system.

However, to ease this transition, change ld.so to only load the first libc
version that we encounter (in a breadth first sense) and substitute that
libc version for all further loads of libc, even if different versions are
requested.  This is done silently since I can't come up with a good warning
message.  In practice this means the libc version requested by the
executable itself will be loaded.  This means that shared libraries may
fail to load if they use a symbol that has been removed.  But given the
constraints, this is the best that we can do.  Even when we bump the
libc major, the set of changes is typically small and most binaries and
shared libraries will continue to run and allow the user to run pkg_add -u
without any fallout.

ok deraadt@, gkoehler@

Revision 1.218 / (download) - annotate - [select for diffs], Tue Dec 19 16:13:22 2023 UTC (5 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.217: +1 -3 lines
Diff to previous 1.217 (colored)

whitespaces

Revision 1.217 / (download) - annotate - [select for diffs], Tue Dec 19 06:27:45 2023 UTC (5 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.216: +2 -2 lines
Diff to previous 1.216 (colored)

correct alignment placement

Revision 1.216 / (download) - annotate - [select for diffs], Mon Dec 18 17:19:07 2023 UTC (5 months, 3 weeks ago) by deraadt
Branch: MAIN
Changes since 1.215: +3 -3 lines
Diff to previous 1.215 (colored)

correct section the SYS_kbind syscall pin record goes into
noticed by gnezdo

Revision 1.215 / (download) - annotate - [select for diffs], Tue Dec 12 15:44:00 2023 UTC (5 months, 3 weeks ago) by deraadt
Branch: MAIN
Changes since 1.214: +24 -1 lines
Diff to previous 1.214 (colored)

To avoid kbind(2) becoming a powerful gadget, it is called inline to a
function.  Therefore we cannot create a precise pinsyscall label.  Instead
create a duplicate entry (using inline asm) to force the kernel's pinsyscall
code to skip validation, rather than labelling it illegal.  kbind(2) remains
safe because it self-protects by checking its calling address.
ok kettenis

Revision 1.214 / (download) - annotate - [select for diffs], Tue Aug 15 06:26:34 2023 UTC (9 months, 3 weeks ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.213: +2 -2 lines
Diff to previous 1.213 (colored)

Improve handling of dlopen(RTLD_TRACE) aka ldd, of a library that
is already loaded:
 * add a 'trace' argument to _dl_show_objects() and exit the
   walk-the-objects loop if you hit that traced object
 * in dlopen(), pass the trace object to _dl_show_objects()
 * also, invoke _dl_show_objects() + exit if the object was
   already opened
 * pass NULL to _dl_show_objects() for all the other calls
 * oh hey, _dl_tracelib is now superfluous: _dl_show_objects()
   should do the walk-the-objects loop only if trace is not NULL.

Problem noted by gnezdo@
ok millert@

Revision 1.213 / (download) - annotate - [select for diffs], Sat Jul 8 14:09:43 2023 UTC (11 months ago) by jasper
Branch: MAIN
Changes since 1.212: +2 -2 lines
Diff to previous 1.212 (colored)

turn an ifdef'd _dl_printf call into DL_DEB and various whitespace fixes

sure deraadt@

Revision 1.212 / (download) - annotate - [select for diffs], Mon Feb 20 00:51:57 2023 UTC (15 months, 2 weeks ago) by gnezdo
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.211: +2 -2 lines
Diff to previous 1.211 (colored)

Adjust inline !libc check to match the intent in ld.so

right, deraadt@

Revision 1.211 / (download) - annotate - [select for diffs], Sat Feb 18 01:22:50 2023 UTC (15 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.210: +18 -2 lines
Diff to previous 1.210 (colored)

Lookup the start,len of the "execve" stub in libc.so, and tell the kernel
where it is with pinsyscall().  In non-static binaries, kernel execve(2)
will now insist upon being called from that small region.  Arriving from
a different region smells like ROP methodology, and the process is killed.

Revision 1.210 / (download) - annotate - [select for diffs], Sun Jan 29 20:30:56 2023 UTC (16 months, 1 week ago) by gnezdo
Branch: MAIN
Changes since 1.209: +62 -67 lines
Diff to previous 1.209 (colored)

Accumulate intermediate imutables locally before applying

OK deraadt

Revision 1.209 / (download) - annotate - [select for diffs], Sun Dec 25 09:39:37 2022 UTC (17 months, 2 weeks ago) by visa
Branch: MAIN
Changes since 1.208: +12 -4 lines
Diff to previous 1.208 (colored)

Re-enable DT_MIPS_RLD_MAP_REL tag in ld.so

The linker now produces correct values for DT_MIPS_RLD_MAP_REL tags.

The DT_MIPS_RLD_MAP_REL offset is relative to the entry of the original
dynamic tags array. Therefore look up the tag from exe_obj->load_dyn
instead of exe_obj->Dyn.info to get the correct base address.

OK kettenis@ deraadt@

Revision 1.208 / (download) - annotate - [select for diffs], Sun Dec 18 19:33:11 2022 UTC (17 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.207: +5 -1 lines
Diff to previous 1.207 (colored)

cannot try the boot.data unmap until all the ld.script are commited, and
fixed to identify the region correctly.

Revision 1.207 / (download) - annotate - [select for diffs], Fri Dec 16 03:14:52 2022 UTC (17 months, 3 weeks ago) by deraadt
Branch: MAIN
Changes since 1.206: +1 -26 lines
Diff to previous 1.206 (colored)

delete // debug comment chunks.  If anyone wants to debug ld.so and runs
into a mimmutable related concern, you want to undo this revision to get
this debug back.  I do not consider this suitable for hiding behind a
cpp macro.

Revision 1.206 / (download) - annotate - [select for diffs], Sun Dec 4 15:55:26 2022 UTC (18 months ago) by visa
Branch: MAIN
Changes since 1.205: +2 -5 lines
Diff to previous 1.205 (colored)

ld.so: Disable DT_MIPS_RLD_MAP_REL

The linker produces incorrect values for DT_MIPS_RLD_MAP_REL tags.
Disable the handling of the tag in the dynamic loader. The linker
will be fixed in a later commit when snapshots have the updated ld.so.

Discussed with and OK kettenis@ deraadt@

Revision 1.205 / (download) - annotate - [select for diffs], Sun Dec 4 15:42:07 2022 UTC (18 months ago) by deraadt
Branch: MAIN
Changes since 1.204: +118 -3 lines
Diff to previous 1.204 (colored)

The next step for mimmutable().  ld.so figures out what regions of memory
of startup shared library mappings can be made immutable, and also does
this for dlope() RTLD_NODELETE and subsidiary libraries.  Complexity in this
diff is due to the GNU_RELRO and OPENBSD_MUTABLE sections.
Tested in snaps for about 3 weeks, with some bootstrap related pain felt in ports
ok kettenis, much help from others.

Revision 1.204 / (download) - annotate - [select for diffs], Wed Nov 9 19:50:25 2022 UTC (18 months, 4 weeks ago) by deraadt
Branch: MAIN
Changes since 1.203: +5 -3 lines
Diff to previous 1.203 (colored)

Now that dlopen() sets object->nodelete for RTLD_NODELETE, _dl_load_dep_libs()
can consider this same as the "booting" case, and instruct lower layers to
do immutability. With this change in place, the not-yet-commited
library-immutable diff leaves 1 page of libc (malloc related) and 6
non-RTLD_NODELETE libraries mutable in chrome.
Everything else is immutable, except for the program's transient memory
allocations & file mappings.  This is an unexpected result.

Revision 1.203 / (download) - annotate - [select for diffs], Tue Nov 8 13:47:22 2022 UTC (19 months ago) by deraadt
Branch: MAIN
Changes since 1.202: +2 -1 lines
Diff to previous 1.202 (colored)

In the new scheme, the main executable object needs to be marked
nodelete, so that _dl_relro() will immutable it's relro.

Revision 1.202 / (download) - annotate - [select for diffs], Tue Nov 8 06:47:31 2022 UTC (19 months ago) by deraadt
Branch: MAIN
Changes since 1.201: +7 -3 lines
Diff to previous 1.201 (colored)

Instead of unmapping boot.text, and then a future allocation could land in
the gap, mmap a fresh MAP_FIXED MAP_ANON PROT_NONE and make it immutable
for good measure
ok guenther kettenis

Revision 1.201 / (download) - annotate - [select for diffs], Mon Nov 7 10:35:26 2022 UTC (19 months ago) by deraadt
Branch: MAIN
Changes since 1.200: +4 -8 lines
Diff to previous 1.200 (colored)

dtors were broken by trying to reuse DF_1_NODELETE to hint that this
library would never unload, and could be immutable.  Pass a seperate
flag for our purposes
Noticed from regress tests by anton, ok kettenis

Revision 1.200 / (download) - annotate - [select for diffs], Sun Nov 6 12:00:20 2022 UTC (19 months ago) by deraadt
Branch: MAIN
Changes since 1.199: +13 -1 lines
Diff to previous 1.199 (colored)

TEXTREL binaries are loaded without immutable on un-writeable sections.
After text relocations are finished, these regions (in the binary) can become
immutable.
OPENBSD_MUTABLE section always overlaps writeable LOADs, so don't be afraid
of that case, it's covered.

Revision 1.199 / (download) - annotate - [select for diffs], Sun Nov 6 11:43:19 2022 UTC (19 months ago) by deraadt
Branch: MAIN
Changes since 1.198: +3 -1 lines
Diff to previous 1.198 (colored)

ld.so wants to make it's own RELRO immutable, which is obviously done
right after it does mprotect PROT_READ.

Revision 1.198 / (download) - annotate - [select for diffs], Sun Nov 6 11:38:54 2022 UTC (19 months ago) by deraadt
Branch: MAIN
Changes since 1.197: +5 -1 lines
Diff to previous 1.197 (colored)

Library RELRO sections are excluded from the immutable list, because ld.so
tweaks them quite late.  _dl_relro() is called when that work is done, and
the final mprotect PROT_READ happens.  Then we can make mark it immutable.
ok kettenis

Revision 1.197 / (download) - annotate - [select for diffs], Sun Nov 6 11:34:50 2022 UTC (19 months ago) by deraadt
Branch: MAIN
Changes since 1.196: +5 -1 lines
Diff to previous 1.196 (colored)

When loading startup libraries, pass DF_1_NODELETE to indicate these are
unloadable libraries.  This allows us make consider making parts of those
libraries immutable (in future commits)
ok guenther kettenis

Revision 1.196 / (download) - annotate - [select for diffs], Fri Oct 28 15:07:25 2022 UTC (19 months, 1 week ago) by kettenis
Branch: MAIN
Changes since 1.195: +5 -2 lines
Diff to previous 1.195 (colored)

Implement support for DT_MIPS_RLD_MAP_REL.

ok deraadt@

Revision 1.195 / (download) - annotate - [select for diffs], Sat Jan 8 06:49:41 2022 UTC (2 years, 5 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.194: +6 -7 lines
Diff to previous 1.194 (colored)

Prep .c files for removing the #includes from */archdep.h
 * replace #include "archdep.h" with #includes of what is used, pulling in
   "syscall.h", "util.h", and "archdep.h" as needed
 * delete #include <sys/syscall.h> from syscall.h
 * only pull in <sys/stat.h> to the three files that use _dl_fstat(),
   forward declare struct stat in syscall.h for the others
 * NBBY is for <sys/select.h> macros; just use '8' in dl_printf.c
 * <machine/vmparam.h> is only needed on i386; conditionalize it
 * stop using __LDPGSZ: use _MAX_PAGE_SHIFT (already used by malloc.c)
   where necessary
 * delete other bogus #includes, order legit per style: <sys/*> then
   <*/*>, then <*>, then "*"

dir.c improvement from jsg@
ok and testing assistance deraadt@

Revision 1.194 / (download) - annotate - [select for diffs], Thu Dec 23 18:50:32 2021 UTC (2 years, 5 months ago) by guenther
Branch: MAIN
Changes since 1.193: +2 -2 lines
Diff to previous 1.193 (colored)

Roll the syscalls that have an off_t argument to remove the explicit padding.
Switch libc and ld.so to the generic stubs for these calls.
WARNING: reboot to updated kernel before installing libc or ld.so!

Time for a story...

When gcc (back in 1.x days) first implemented long long, it didn't (always)
pass 64bit arguments in 'aligned' registers/stack slots, with the result that
argument offsets didn't match structure offsets.  This affected the nine system
calls that pass off_t arguments:
   ftruncate lseek mmap mquery pread preadv pwrite pwritev truncate

To avoid having to do custom ASM wrappers for those, BSD put an explicit pad
argument in so that the off_t argument would always start on a even slot and
thus be naturally aligned.  Thus those odd wrappers in lib/libc/sys/ that use
__syscall() and pass an extra '0' argument.

The ABIs for different CPUs eventually settled how things should be passed on
each and gcc 2.x followed them.  The only arch now where it helps is landisk,
which needs to skip the last argument register if it would be the first half of
a 64bit argument.  So: add new syscalls without the pad argument and on landisk
do that skipping directly in the syscall handler in the kernel.  Keep compat
support for the existing syscalls long enough for the transition.

ok deraadt@

Revision 1.193 / (download) - annotate - [select for diffs], Fri Nov 12 22:28:13 2021 UTC (2 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.192: +35 -1 lines
Diff to previous 1.192 (colored)

Add support for RELR relocations in the executable and share objects.
This doesn't affect ld.so's self-reloc, which still requires DT_REL/DT_RELA

ok kettenis@

Revision 1.192 / (download) - annotate - [select for diffs], Tue May 25 17:01:36 2021 UTC (3 years ago) by kn
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.191: +7 -4 lines
Diff to previous 1.191 (colored)

program headers: do not rely on DYNAMIC coming before GNU_RELRO

Except for some specific cases (thanks guenther) ELF mandates nothing
but the file header be at a fixed location, hence ld.so(1) must not
assume any specific order for headers, segments, etc.

Looping over the program header table to parse segment headers,
_dl_boot() creates the executable object upon DYNAMIC and expects it to
be set upon GNU_RELRO, resulting in a NULL dereference iff that order is
reversed.

Store relocation bits in temporary variables and update the executable
object once all segment headers are parsed to lift this dependency.

Under __mips__ _dl_boot() later on uses the same temporary variable, so
move nothing but the declaration out of MI code so as to not alter the
MD code's logic/behaviour.

Found while porting patchelf(1) from NixOS.

OK guenther

Revision 1.191 / (download) - annotate - [select for diffs], Tue Mar 16 18:03:06 2021 UTC (3 years, 2 months ago) by kurt
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.190: +15 -3 lines
Diff to previous 1.190 (colored)

On i386 don't attempt to map shared libraries in low memory when
a large executable's .text section crosses the 512MB exec line.

Executables that have MAXTSIZ > 64MB can map above the default
512MB exec line. When this happens, shared libs that attempt to map
into low memory will find their .data section can not be mapped. ld.so
will attempt to remap the share lib at higher addresses until it can be
mapped. For very large executables like chrome this process is very
time consuming. This change detects how much of the executable's
.text section exceeds 512MB and uses that as the initial hint for
shared libs to map into which avoids attempting to map into blocked
memory.

okay deraadt@

Revision 1.190 / (download) - annotate - [select for diffs], Tue Dec 17 03:16:07 2019 UTC (4 years, 5 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.189: +21 -32 lines
Diff to previous 1.189 (colored)

Don't look up env variables until we know we'll trust them.  Otherwise,
just delete them without looking.

ok millert@

Revision 1.177.2.1 / (download) - annotate - [select for diffs], Wed Dec 11 18:29:35 2019 UTC (4 years, 5 months ago) by deraadt
Branch: OPENBSD_6_5
Changes since 1.177: +7 -5 lines
Diff to previous 1.177 (colored) next main 1.178 (colored)

ld.so may fail to remove the LD_LIBRARY_PATH environment variable for
set-user-ID and set-group-ID executables in low memory conditions.
Reported by Qualys
This is errata 6.5/024_ldso.patch.sig

Revision 1.187.2.1 / (download) - annotate - [select for diffs], Wed Dec 11 18:29:17 2019 UTC (4 years, 5 months ago) by deraadt
Branch: OPENBSD_6_6
Changes since 1.187: +7 -5 lines
Diff to previous 1.187 (colored) next main 1.188 (colored)

ld.so may fail to remove the LD_LIBRARY_PATH environment variable for
set-user-ID and set-group-ID executables in low memory conditions.
Reported by Qualys
This is errata 6.6/013_ldso.patch.sig

Revision 1.189 / (download) - annotate - [select for diffs], Wed Dec 11 18:27:54 2019 UTC (4 years, 5 months ago) by millert
Branch: MAIN
Changes since 1.188: +7 -5 lines
Diff to previous 1.188 (colored)

ld.so may fail to remove the LD_LIBRARY_PATH environment variable for
set-user-ID and set-group-ID executables in low memory conditions.
Reported by Qualys

Revision 1.188 / (download) - annotate - [select for diffs], Sat Dec 7 22:57:47 2019 UTC (4 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.187: +13 -3 lines
Diff to previous 1.187 (colored)

Disable ltrace for objects linked with -znow, as at least on amd64, linking
that was deletes the lazy relocation trampoline which ltrace currently
depends on

problem reported by tb@
directional feedback kettenis@
ok mpi@

Revision 1.187 / (download) - annotate - [select for diffs], Fri Oct 4 17:42:16 2019 UTC (4 years, 8 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE
Branch point for: OPENBSD_6_6
Changes since 1.186: +24 -11 lines
Diff to previous 1.186 (colored)

Convert the child_list member from a linked list to a vector.

ok mpi@

Revision 1.186 / (download) - annotate - [select for diffs], Thu Oct 3 06:10:54 2019 UTC (4 years, 8 months ago) by guenther
Branch: MAIN
Changes since 1.185: +2 -4 lines
Diff to previous 1.185 (colored)

Use a better algorithm for calculating the grpsym library order.
The existing code did a full recursive walk for O(horrible).  Instead,
keep a single list of nodes plus the index of the first node whose
children haven't been scanned; lookup until that index catches the
end, appending the unscanned children of the node at the index.  This
also makes the grpsym list order match that calculated by FreeBSD and
glibc in dependency trees with inconsistent ordering of dependent libs.

To make this easier and more cache friendly, convert grpsym_list
to a vector: the size is bounded by the number of objects currently
loaded.

Other, related fixes:
 * increment the grpsym generation number _after_ pushing the loading
   object onto its grpsym list, to avoid double counting it
 * increment the grpsym generation number when building the grpsym list
   for an already loaded object that's being dlopen()ed, to avoid
   incomplete grpsym lists
 * use a more accurate test of whether an object already has a grpsym list

Prompted by a diff from Nathanael Rensen (nathanael (at) list.polymorpheus.com)
that pointed to _dl_cache_grpsym_list() as a performance bottleneck.

Much proding from robert@, sthen@, aja@, jca@
no problem reports after being in snaps
ok mpi@

Revision 1.185 / (download) - annotate - [select for diffs], Tue Aug 6 04:01:41 2019 UTC (4 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.184: +32 -1 lines
Diff to previous 1.184 (colored)

Factor out TEXTREL mprotecting from the per-arch files into _dl_rtld(),
hiding the actual grotty bits in inline functions

ok mpi@

Revision 1.184 / (download) - annotate - [select for diffs], Sun Aug 4 23:51:45 2019 UTC (4 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.183: +20 -26 lines
Diff to previous 1.183 (colored)

Simplify _dl_find_symbol().  Currently, it returns three values:
 - the symbol it found, returned via the second argument
 - the base offset of the the object it was found in, via the return value
 - optionally: the object it was found in, returned via the last argument

Instead, return a struct with the symbol and object pointers and let the
caller get the base offset from the object's obj_base member.  On at least
aarch64, amd64, mips64, powerpc, and sparc64, a two word struct like this
is passed in registers.

ok mpi@, kettenis@

Revision 1.183 / (download) - annotate - [select for diffs], Sun Jul 21 03:54:16 2019 UTC (4 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.182: +1 -30 lines
Diff to previous 1.182 (colored)

In 2004, we upgraded to binutils 2.14 with did -zcombreloc by default.
In 2013, I implemented the single-entry LRU cache that gets the maximal
symbol reuse from combreloc.  Since then, the ld.so generic relocation
symcache has been a waste of CPU and memory with 0% hit-rate, so kill it.

ok mpi@

Revision 1.182 / (download) - annotate - [select for diffs], Fri Jun 7 16:27:47 2019 UTC (5 years ago) by deraadt
Branch: MAIN
Changes since 1.181: +3 -1 lines
Diff to previous 1.181 (colored)

make gc workaround compile on non-clang

Revision 1.181 / (download) - annotate - [select for diffs], Tue Jun 4 02:35:40 2019 UTC (5 years ago) by guenther
Branch: MAIN
Changes since 1.180: +3 -1 lines
Diff to previous 1.180 (colored)

Disable the unmapping of ld.so's boot data for now, as boehm-gc apparently
follows some pointer into the middle of it.  Best to keep things working
while tracking down the wonkiness.

problem noted by naddy@

Revision 1.180 / (download) - annotate - [select for diffs], Sun May 12 23:32:42 2019 UTC (5 years ago) by guenther
Branch: MAIN
Changes since 1.179: +2 -2 lines
Diff to previous 1.179 (colored)

Indentation fix

Revision 1.179 / (download) - annotate - [select for diffs], Sat May 11 21:02:35 2019 UTC (5 years ago) by guenther
Branch: MAIN
Changes since 1.178: +4 -5 lines
Diff to previous 1.178 (colored)

Prune visited leaves when walking dependencies to call init functions in
topological sort order, reducing it to O(n) from O(2^n) (ouch!)

diff from Nathanael Rensen (nathanael(at)list.polymorpheus.com)
Much testing and pleading by robert@ and ajacoutot@
ok drahn@ mpi@

Revision 1.178 / (download) - annotate - [select for diffs], Fri May 10 13:29:21 2019 UTC (5 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.177: +83 -26 lines
Diff to previous 1.177 (colored)

ld.so boot cleanup support:
 - put functions and data which are only used before calling the executable's
   start function into their own page-aligned segments for unmapping
   (only done on amd64, arm64, armv7, powerpc, and sparc64 so far)
 - pass .init_array and .preinit_array functions an addition argument which
   is a callback to get a structure which includes a function that frees
   the boot text and data
 - sometimes delay doing RELRO processing: for a shared-object marked
   DF_1_INITFIRST do it after the object's .init_array, for the executable
   do it after the .preinit_array
 - improve test-ld.so to link against libpthread and trigger its initialization
   late
libc changes to use this will come later

ok kettenis@

Revision 1.177 / (download) - annotate - [select for diffs], Mon Dec 3 05:29:56 2018 UTC (5 years, 6 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE
Branch point for: OPENBSD_6_5
Changes since 1.176: +4 -3 lines
Diff to previous 1.176 (colored)

DT_MIPS_RLD_MAP is an offset, so relocate it when present.
This fixes handling of lld-linked executables on mips64.

problem reported by visa@ and worked out with him

Revision 1.176 / (download) - annotate - [select for diffs], Tue Nov 20 01:38:59 2018 UTC (5 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.175: +8 -6 lines
Diff to previous 1.175 (colored)

On mips64, DT_DEBUG doesn't need mprotecting if it's in the GNU_RELRO segment

ok visa@

Revision 1.175 / (download) - annotate - [select for diffs], Fri Nov 16 21:15:47 2018 UTC (5 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.174: +12 -1 lines
Diff to previous 1.174 (colored)

Finish ld.so's transition to GNU_RELRO: eliminate support for using
__got_{start,end} to find a region to mark read-only.  It was only used
for binaries that didn't have a GNU_RELRO segment, but all archs have
been using that for over a year.  Since support for insecure-PLT layouts
on powerpc and alpha have been removed, all archs handle GNU_RELRO the
same way and the support can be moved from the MD code to the MI code.

ok mpi@

Revision 1.174 / (download) - annotate - [select for diffs], Tue Oct 23 04:01:45 2018 UTC (5 years, 7 months ago) by guenther
Branch: MAIN
Changes since 1.173: +51 -16 lines
Diff to previous 1.173 (colored)

Delay processing of ld.so's own PT_GNU_RELRO section until after environment
processing and malloc initialization, and then move variables set by those
steps, including malloc's mopts structure, into the .data.rel.ro segment.
This protects more data and eliminates the extra padding of the mopts.

ok kettenis@

Revision 1.173 / (download) - annotate - [select for diffs], Mon Oct 22 01:59:08 2018 UTC (5 years, 7 months ago) by guenther
Branch: MAIN
Changes since 1.172: +11 -11 lines
Diff to previous 1.172 (colored)

Use int, not char*, for booleans

ok millert@

Revision 1.172 / (download) - annotate - [select for diffs], Fri Dec 8 05:25:20 2017 UTC (6 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.171: +2 -2 lines
Diff to previous 1.171 (colored)

Everyone knows this as ld.so, nor by the ancient name rtld.
ok guenther

Revision 1.171 / (download) - annotate - [select for diffs], Thu Oct 26 20:17:05 2017 UTC (6 years, 7 months ago) by guenther
Branch: MAIN
Changes since 1.170: +5 -1 lines
Diff to previous 1.170 (colored)

If LD_BIND_NOW is in force then all relocations are performed eagerly,
when the object is loaded.  Since kbind(2) will never be used in that
case, disable it early, before invoking any library or application code.

ok deraadt@ kettenis@

Revision 1.170 / (download) - annotate - [select for diffs], Wed Feb 8 04:34:29 2017 UTC (7 years, 4 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.169: +2 -2 lines
Diff to previous 1.169 (colored)

Provide size-generic ELF_NO_ADDR in <sys/exec_elf.h> and use that instead
of ELFDEFNNAME(NO_ADDR)

ok jca@

Revision 1.169 / (download) - annotate - [select for diffs], Tue Jan 24 07:48:36 2017 UTC (7 years, 4 months ago) by guenther
Branch: MAIN
Changes since 1.168: +20 -30 lines
Diff to previous 1.168 (colored)

On fatal errors, kill ourselves with thrkill(0,9,NULL) instead of
simply exiting, via helper functions _dl_die(), _dl_diedie(), and
_dl_oom().

prompted by a complaint from jsing@
ok jsing@ deraadt@

Revision 1.168 / (download) - annotate - [select for diffs], Mon Jan 9 22:51:04 2017 UTC (7 years, 4 months ago) by kettenis
Branch: MAIN
Changes since 1.167: +1 -20 lines
Diff to previous 1.167 (colored)

Remove dependency on __got_{start,end} symbols and look at PT_GNU_RELRO
instead.  Result in a few more pages that aren't writable on some platforms
(such as hppa).  Based on an initial diff from guenther@.

Thanks to deraadt@ for testing.

ok guenther@

Revision 1.167 / (download) - annotate - [select for diffs], Sun Aug 28 04:33:17 2016 UTC (7 years, 9 months ago) by guenther
Branch: MAIN
Changes since 1.166: +2 -2 lines
Diff to previous 1.166 (colored)

fix a comment

Revision 1.166 / (download) - annotate - [select for diffs], Tue Aug 23 06:46:17 2016 UTC (7 years, 9 months ago) by kettenis
Branch: MAIN
Changes since 1.165: +56 -22 lines
Diff to previous 1.165 (colored)

Implement support for DT_INIT_ARRAY, DT_FINI_ARRAY and DT_PREINIT_ARRAY.
Don't skip DT_INIT and DT_FINI for the main executable.  This matches what
Linux and Solaris do.

ok guenther@

Revision 1.165 / (download) - annotate - [select for diffs], Sun Aug 14 04:30:39 2016 UTC (7 years, 9 months ago) by guenther
Branch: MAIN
Changes since 1.164: +3 -3 lines
Diff to previous 1.164 (colored)

Mark the relro/got section as read-only before setting up the environment
to minimize the amount of code run without it RO.

Revision 1.164 / (download) - annotate - [select for diffs], Fri Aug 12 20:39:01 2016 UTC (7 years, 9 months ago) by deraadt
Branch: MAIN
Changes since 1.163: +2 -2 lines
Diff to previous 1.163 (colored)

the slimmed down random functions inside ld.so are strict clones of the
libc arc4random API, so call them _dl_{arc4random,arcrandombuf}
ok tedu guenther

Revision 1.163 / (download) - annotate - [select for diffs], Mon Aug 8 21:59:20 2016 UTC (7 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.162: +40 -32 lines
Diff to previous 1.162 (colored)

Look for a PT_GNU_RELRO section per object and, if present, mprotect that
range instead of the [__got_start, __got_end) range.
On many archs this will cover _DYNAMIC too, so move up the DT_DEBUG handling
to before relocations and the mprotect are done.

ok kettenis@

Revision 1.162 / (download) - annotate - [select for diffs], Mon Jul 4 21:15:06 2016 UTC (7 years, 11 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.161: +1 -17 lines
Diff to previous 1.161 (colored)

Remove prebind support: binding to symbol table indices is too fragile
for our development process.

ok kettenis@ deraadt@

Revision 1.161 / (download) - annotate - [select for diffs], Wed Jun 8 11:58:59 2016 UTC (8 years ago) by kettenis
Branch: MAIN
Changes since 1.160: +12 -1 lines
Diff to previous 1.160 (colored)

Some ELF ABIs still require a PLT that is both writable and executable.  To
avoid W^X violations, initially map such segments as writable and
non-executable, and change the mapping to non-writable and executable
after initial relocation processing.  As a side-benefit this means we no
longer depend on the __plt_start and __plt_end to make the PLT read-only
after relocation processing.

This will break binaries linked with ld -Z, most notably emacs, on some
of our architectures.

ok deraadt@, guenther@

Revision 1.160 / (download) - annotate - [select for diffs], Sun Jun 5 19:43:58 2016 UTC (8 years ago) by kettenis
Branch: MAIN
Changes since 1.159: +2 -2 lines
Diff to previous 1.159 (colored)

Avoid W^X violation when setting DT_DEBUG on mips64.

ok deraadt@

Revision 1.159 / (download) - annotate - [select for diffs], Sat May 7 19:05:23 2016 UTC (8 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.158: +18 -4 lines
Diff to previous 1.158 (colored)

Use a Thread Information Block in both single and multi-threaded programs.
This stores errno, the cancelation flags, and related bits for each thread
and is allocated by ld.so or libc.a.  This is an ABI break from 5.9-stable!

Make libpthread dlopen'able by moving the cancelation wrappers into libc
and doing locking and fork/errno handling via callbacks that libpthread
registers when it first initializes.  'errno' *must* be declared via
<errno.h> now!

Clean up libpthread's symbol exports like libc.

On powerpc, offset the TIB/TCB/TLS data from the register per the ELF spec.

Testing by various, particularly sthen@ and patrick@
ok kettenis@

Revision 1.158 / (download) - annotate - [select for diffs], Thu Mar 24 05:27:19 2016 UTC (8 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.157: +15 -3 lines
Diff to previous 1.157 (colored)

Unbreak arm and m88k: COPY relocations for weak symbols that are overloaded
with strong symbols in ld.so don't do what we need, so put definitions back
in crt0 and make ld.so update __progname like it does environ.

report and testing patrick@ jsg@

Revision 1.157 / (download) - annotate - [select for diffs], Sun Mar 20 02:29:51 2016 UTC (8 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.156: +35 -17 lines
Diff to previous 1.156 (colored)

Export environ and __progname, making the latter a copy of just the filename
portion like crt0 does.  This is prep for eliminating _dl_fixup_user_env()
Mark almost everything in resolve.h as hidden, to improve code generation.

ok kettenis@ mpi@  "good time" deraadt@

Revision 1.156 / (download) - annotate - [select for diffs], Sun Nov 15 03:41:24 2015 UTC (8 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.155: +5 -2 lines
Diff to previous 1.155 (colored)

ldd(1) sets environment variable LD_TRACE_LOADED_OBJECTS to tell ld.so
that it should show information about the program it loads, rather than
run it.  In that specific case, ld.so can pledge to "stdio rpath" to
ensure that code path in ld.so has no bugs.
Yes, a pledge in ld.so.... who'd have thought!
ok guenther

Revision 1.155 / (download) - annotate - [select for diffs], Tue Aug 18 17:34:44 2015 UTC (8 years, 9 months ago) by deraadt
Branch: MAIN
Changes since 1.154: +2 -2 lines
Diff to previous 1.154 (colored)

_dl_malloc() proto exists, do not cast result

Revision 1.154 / (download) - annotate - [select for diffs], Wed May 6 01:03:31 2015 UTC (9 years, 1 month ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.153: +3 -1 lines
Diff to previous 1.153 (colored)

Fix a memory leak in _dl_load_dep_libs()
ok otto@ guenther@

Revision 1.153 / (download) - annotate - [select for diffs], Thu Jan 22 05:48:17 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.152: +3 -3 lines
Diff to previous 1.152 (colored)

delete annoying white space that annoy

Revision 1.152 / (download) - annotate - [select for diffs], Fri Jan 16 16:18:07 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.151: +1 -2 lines
Diff to previous 1.151 (colored)

<sys/param.h> to <limits.h> conversion.  Verified binaries
ok millert, thanks to doug for process advice

Revision 1.151 / (download) - annotate - [select for diffs], Mon Nov 3 17:50:56 2014 UTC (9 years, 7 months ago) by guenther
Branch: MAIN
Changes since 1.150: +9 -18 lines
Diff to previous 1.150 (colored)

Eliminate RTLD_PROTECT_PLT: ld.so is built with -Bsymbolic so the
PLT is empty/unused.  On at least macppc and sparc64, ld.so's attempt
to mprotect its PLT could instead hit its own allocated data and
cause a segfault shortly there after.

While here, take a shot at preventing the same issue with the GOT
by checking for __got_start != __got_end.

reproduction *with ktracing* by afresh1@ provided the key data
ok miod@ deraadt@

Revision 1.150 / (download) - annotate - [select for diffs], Thu Jul 10 09:03:01 2014 UTC (9 years, 11 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.149: +5 -2 lines
Diff to previous 1.149 (colored)

check all memory allocations; ok miod@ guenther@

Revision 1.149 / (download) - annotate - [select for diffs], Sun Jul 6 19:15:16 2014 UTC (9 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.148: +2 -2 lines
Diff to previous 1.148 (colored)

allocate two things, test two pointers; ok miod@ guenther@

Revision 1.148 / (download) - annotate - [select for diffs], Sat Jun 21 08:00:23 2014 UTC (9 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.147: +7 -4 lines
Diff to previous 1.147 (colored)

Move to a non-zeroing _dl_malloc, a _dl_calloc and _dl_reallocarry and
fix _dl_strdup to return NULL instead of crash; ok deraadt@

Revision 1.147 / (download) - annotate - [select for diffs], Sun Feb 16 01:16:38 2014 UTC (10 years, 3 months ago) by martynas
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.146: +1 -188 lines
Diff to previous 1.146 (colored)

Unbreak ld.so with ssp-strong/all on sparc64 and powerpc.  With the
new SSP logic it additionally protects functions which have their
local addresses taken of, and _dl_boot_bind() gets selected.

We have to go through GOT to reach __guard_local, however it hasn't
been relocated yet.  So add boot.c and don't protect everything up
to the point until it has been relocated and no longer needs the
loff adjustment.

OK matthew@.  Full build done & tested by florian@.

Revision 1.146 / (download) - annotate - [select for diffs], Thu Jan 23 00:31:34 2014 UTC (10 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.145: +10 -17 lines
Diff to previous 1.145 (colored)

Remove LD_NORANDOM feature.  It serves no usable purpose.  Determinism
in this one specific area is not going to help debugging, because so
many other parts are non-deterministic.
ok guenthre matthew jsing

Revision 1.145 / (download) - annotate - [select for diffs], Sat Jan 18 09:08:42 2014 UTC (10 years, 4 months ago) by kettenis
Branch: MAIN
Changes since 1.144: +1 -24 lines
Diff to previous 1.144 (colored)

Make ld.so pass its cleanup handler in $2 as required by the MIPS System V
ABI, and completely remove the code that attempts to call atexit(3) directly.

Revision 1.144 / (download) - annotate - [select for diffs], Wed Dec 25 15:14:59 2013 UTC (10 years, 5 months ago) by miod
Branch: MAIN
Changes since 1.143: +2 -2 lines
Diff to previous 1.143 (colored)

Pass _dl_dtors as the csu cleanup routine on sh

Revision 1.143 / (download) - annotate - [select for diffs], Wed Dec 25 15:01:39 2013 UTC (10 years, 5 months ago) by miod
Branch: MAIN
Changes since 1.142: +2 -2 lines
Diff to previous 1.142 (colored)

Pass _dl_dtors as the csu cleanup routine on arm.

Revision 1.142 / (download) - annotate - [select for diffs], Wed Dec 25 13:06:00 2013 UTC (10 years, 5 months ago) by miod
Branch: MAIN
Changes since 1.141: +2 -4 lines
Diff to previous 1.141 (colored)

Pass _dl_dtors as the csu cleanup routine on m68k and m88k; change the
conditional in the MI code to only list the architectures left to adapt.

Revision 1.141 / (download) - annotate - [select for diffs], Wed Dec 25 11:10:02 2013 UTC (10 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.140: +3 -2 lines
Diff to previous 1.140 (colored)

Make ld.so pass its cleanup handler in %g1 as required by the SPARC System V
ABI, and stop calling atexit(4) directly from ld.so on sparc.

Revision 1.140 / (download) - annotate - [select for diffs], Mon Dec 23 22:13:03 2013 UTC (10 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.139: +3 -3 lines
Diff to previous 1.139 (colored)

Make ld.so pass its cleanup handler in %rdx as required by the AMD64 System V
ABI, and stop calling atexit(4) directly from ld.so on amd64.  Note that this
means that binaries built before the middle of november may no longer call
destructors in shared libraries implemented in C++.  Update your packages!

ok guenther@

Revision 1.139 / (download) - annotate - [select for diffs], Mon Dec 23 22:03:52 2013 UTC (10 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.138: +2 -2 lines
Diff to previous 1.138 (colored)

Make ld.so pass its cleanup handler in r7 as required by the PowerPC System V
ABI, and stop calling atexit(4) directly from ld.so on powerpc.

Revision 1.138 / (download) - annotate - [select for diffs], Mon Dec 23 21:18:57 2013 UTC (10 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.137: +3 -2 lines
Diff to previous 1.137 (colored)

Make ld.so pass its cleanup handler in v0 and stop calling atexit(4) directly
from ld.so on alpha.  Note that this means that binaries built before early
december may no longer call destructors in shared libraries implemented in
C++.  Update your packages!

Revision 1.137 / (download) - annotate - [select for diffs], Mon Dec 23 17:29:15 2013 UTC (10 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.136: +2 -2 lines
Diff to previous 1.136 (colored)

Make ld.so pass its cleanup handler in %g1 as required by the SPARC System V
ABI, and stop calling atexit(4) directly from ld.so on sparc64

Revision 1.136 / (download) - annotate - [select for diffs], Mon Dec 23 14:13:03 2013 UTC (10 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.135: +5 -5 lines
Diff to previous 1.135 (colored)

Call __cxa_atexit(3) instead of atexit(3).  Preparation for upcoming changes to
make it possible to call atexit from dynamically loaded shared objects.

Revision 1.135 / (download) - annotate - [select for diffs], Mon Dec 23 13:57:44 2013 UTC (10 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.134: +2 -6 lines
Diff to previous 1.134 (colored)

Make ld.so pass its cleanup handler in %arg1 and stop calling atiexit(4)
directly from ld.so on hppa.

Revision 1.134 / (download) - annotate - [select for diffs], Mon Dec 23 10:39:10 2013 UTC (10 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.133: +3 -1 lines
Diff to previous 1.133 (colored)

Make ld.so pass its cleanup handler in %edx as required by the i386 System V
ABI, and stop calling atexit(4) directly from ld.so on i386.

ok guenther@

Revision 1.133 / (download) - annotate - [select for diffs], Sat Jun 1 09:57:55 2013 UTC (11 years ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.132: +5 -5 lines
Diff to previous 1.132 (colored)

Introduce ltrace(1). This tool works with ld.so to inject utrace record for
each plt call, allowing to trace a binary linked against shared library at the
public function call level.

To do so, ltrace(1) sets up some environment variables to enable plt tracing
in ld.so, and invokes ktrace(2) for utrace events. ld.so will force lazy
binding and will send an utrace record in the plt resolver, without updating
the plt.

Minimal filtering capabilities are provided, inspired by Solaris' truss -u,
to limit tracing to libraries and/or symbol names. Non-traced libraries and
symbols will have the regular resolver processing, with the expected plt
update.

"Get it in" deraadt

Revision 1.132 / (download) - annotate - [select for diffs], Fri Apr 5 12:58:03 2013 UTC (11 years, 2 months ago) by kurt
Branch: MAIN
Changes since 1.131: +5 -2 lines
Diff to previous 1.131 (colored)

- Add ORIGIN, OSNAME, OSREL and PLATFORM substitution support for rpaths.
Improvements and okay matthew@, millert@, guenther@

Revision 1.131 / (download) - annotate - [select for diffs], Wed Mar 20 21:49:59 2013 UTC (11 years, 2 months ago) by kurt
Branch: MAIN
Changes since 1.130: +7 -4 lines
Diff to previous 1.130 (colored)

- Parse colon separated paths into NULL terminated arrays of string
pointers to prepare for adding rpath ORIGIN support.
okay matthew@ millert@

Revision 1.130 / (download) - annotate - [select for diffs], Fri Jan 11 21:17:07 2013 UTC (11 years, 4 months ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.129: +6 -6 lines
Diff to previous 1.129 (colored)

Proper bounds checking for DT_xxx values in _dl_boot_bind(). Turned out to be
harmless because we have full control over the array being processed, and none
of the values we set up may trigger the bug; yet this may change in the future.

ok drahn matthew@

Revision 1.129 / (download) - annotate - [select for diffs], Tue Jun 12 20:32:17 2012 UTC (11 years, 11 months ago) by matthew
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.128: +1 -13 lines
Diff to previous 1.128 (colored)

Fix loaded object sod matching: when we load libfoo.so.X.Y into
memory, we should be able to match other requests for libfoo.so.X.Z
against that same object.

ok kurt, kettenis

Revision 1.128 / (download) - annotate - [select for diffs], Tue May 8 14:32:01 2012 UTC (12 years, 1 month ago) by jsing
Branch: MAIN
Changes since 1.127: +5 -0 lines
Diff to previous 1.127 (colored)

Refuse to load ELF objects that contain a PT_TLS program header.
Otherwise the binary assumes that the requested TLS storage has been
allocated and will happily use it, resulting in unwanted memory corruption.

ok guenther@

Revision 1.127 / (download) - annotate - [select for diffs], Sun Jan 8 19:44:34 2012 UTC (12 years, 5 months ago) by kettenis
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.126: +21 -10 lines
Diff to previous 1.126 (colored)

Since PIE executables on mips64 don't have DT_MIPS_RLD_MAP, fall back on
using DT_DEBUG if DT_MIPS_RLD_MAP isn't there.  This requires us to make
.dynamic temporarily writable.  Fixes debugging of PIE execuables with gdb(1).

ok miod@

Revision 1.126 / (download) - annotate - [select for diffs], Mon Nov 28 20:59:03 2011 UTC (12 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.125: +40 -12 lines
Diff to previous 1.125 (colored)

Add support for getting some flags from DT_FLAGS_1: new flags
DF_1_NODELETE and DF_1_INITFIRST, as well as DF_1_NOW and DF_1_GLOBAL.

Committing for kurt@ who worked out the final version; ok guenther@ drahn@

Revision 1.125 / (download) - annotate - [select for diffs], Mon Jun 27 16:47:50 2011 UTC (12 years, 11 months ago) by sthen
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.124: +0 -2 lines
Diff to previous 1.124 (colored)

Backout the dynamic linker speed improvement diff for now, it still
has some issues. Discussed with various, ok drahn@

Revision 1.124 / (download) - annotate - [select for diffs], Sun May 22 22:43:47 2011 UTC (13 years ago) by drahn
Branch: MAIN
Changes since 1.123: +3 -1 lines
Diff to previous 1.123 (colored)

Dynamic linker speed improvement diff. tested by several sinc k2k11.
get it in tree now deraadt@, ok by several ports folks. Thanks for the testing.

Revision 1.123 / (download) - annotate - [select for diffs], Mon May 9 18:13:34 2011 UTC (13 years, 1 month ago) by otto
Branch: MAIN
Changes since 1.122: +1 -7 lines
Diff to previous 1.122 (colored)

Outsmart gcc4 on mips* by moving the declaration of _dl_debug_state
outside the file the call is in. Since the function is empty, gcc
optmizes the call away, breaking the gdb hook needed to resolve symbols in
lazy bound shared libs. Analysis by kettenis@; ok miod@ kettenis@

Revision 1.122 / (download) - annotate - [select for diffs], Wed Apr 6 11:36:25 2011 UTC (13 years, 2 months ago) by miod
Branch: MAIN
Changes since 1.121: +2 -2 lines
Diff to previous 1.121 (colored)

Avoid using NULL in non-pointer contexts: use 0 for integer values and '\0'
for chars.

Revision 1.121 / (download) - annotate - [select for diffs], Tue Dec 7 18:29:28 2010 UTC (13 years, 6 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.120: +2 -2 lines
Diff to previous 1.120 (colored)

Make the preload error distinct from the normal error.
ok espie@

Revision 1.120 / (download) - annotate - [select for diffs], Mon Oct 25 20:34:44 2010 UTC (13 years, 7 months ago) by kurt
Branch: MAIN
Changes since 1.119: +15 -1 lines
Diff to previous 1.119 (colored)

Search loaded libs first and add support for SONAME matching. ok drahn@

Revision 1.119 / (download) - annotate - [select for diffs], Thu Jul 1 19:25:44 2010 UTC (13 years, 11 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.118: +4 -4 lines
Diff to previous 1.118 (colored)

When generating grpsym lists, avoid duplicates without searching the
already generated list. Speeds up startup on deeply nested dlopen binaries.
ok guenther@, tested by ckuethe@ and ajacoutot@

Revision 1.118 / (download) - annotate - [select for diffs], Sat Jan 2 12:16:35 2010 UTC (14 years, 5 months ago) by kettenis
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.117: +2 -2 lines
Diff to previous 1.117 (colored)

Fix handling of hppa RELOC_IPLT relocations during 'bootstrap relocation'.

ok miod@, deraadt@, jsing@

Revision 1.117 / (download) - annotate - [select for diffs], Wed Feb 4 19:44:51 2009 UTC (15 years, 4 months ago) by kettenis
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.116: +3 -1 lines
Diff to previous 1.116 (colored)

Tag ld.so as an OpenBSD binary/library.

ok kurt@, drahn@, miod@

Revision 1.116 / (download) - annotate - [select for diffs], Thu Oct 2 20:12:08 2008 UTC (15 years, 8 months ago) by kurt
Branch: MAIN
Changes since 1.115: +2 -2 lines
Diff to previous 1.115 (colored)

Fix mmap() error checking to be correct 64-bit addresses. Consistently
use _dl_mmap_error() to check for mmap() errors. Adjust datatypes of
some local vars for 64-bit safety.

okay millert@ drahn@

Revision 1.115 / (download) - annotate - [select for diffs], Fri Jun 13 23:52:42 2008 UTC (15 years, 11 months ago) by kurt
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.114: +5 -3 lines
Diff to previous 1.114 (colored)

Pass relocated Elf_Dyn * to _dl_finalize_object(). Needed for pie
executables.  Debugged and okay drahn@

Revision 1.114 / (download) - annotate - [select for diffs], Thu Jun 12 19:50:04 2008 UTC (16 years ago) by kurt
Branch: MAIN
Changes since 1.113: +42 -19 lines
Diff to previous 1.113 (colored)

- rename _dl_boot argument loff to dyn_loff to differentiate it from
  exe_loff
- calculate minva, maxva, exe_loff for the executable for passing to
  _dl_finialize_object and completing the executable elf_object_t data.
  this fixes ldd output for the exe object and prepares for PIE support.
- calculate the interpreter path pointer in a way that allows for the
  possibility that PT_INTERP comes before PT_PHDR
- fix an off by one in the init of dl_data

input and okay drahn@

Revision 1.113 / (download) - annotate - [select for diffs], Mon May 5 02:29:02 2008 UTC (16 years, 1 month ago) by kurt
Branch: MAIN
Changes since 1.112: +8 -5 lines
Diff to previous 1.112 (colored)

Constantly fill in the program header pointer and count in elf_object_t
for all objects which simplifies phdr usage in a few places.
"go for it" drahn@

Revision 1.112 / (download) - annotate - [select for diffs], Tue Nov 27 16:42:15 2007 UTC (16 years, 6 months ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.111: +2 -2 lines
Diff to previous 1.111 (colored)

Make _dl_md_reloc_got() report errors, and take them into account.
Fixes PR #5579.

Revision 1.111 / (download) - annotate - [select for diffs], Tue Apr 3 14:33:07 2007 UTC (17 years, 2 months ago) by jason
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.110: +5 -1 lines
Diff to previous 1.110 (colored)

add support for LD_TRACE_LOADED_OBJECTS_{FMT1/FMT2/PROGNAME}.  Functionality
matches and expands on the old a.out ld.so formatting.  ok drahn

Revision 1.110 / (download) - annotate - [select for diffs], Mon Apr 2 15:24:19 2007 UTC (17 years, 2 months ago) by drahn
Branch: MAIN
Changes since 1.109: +2 -2 lines
Diff to previous 1.109 (colored)

Since the kernel allows argv[0] == NULL, dont core in ld.so
diff from Matthew Dempsky, with reminder from theo.

Revision 1.109 / (download) - annotate - [select for diffs], Sun Jan 28 21:28:23 2007 UTC (17 years, 4 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.108: +1 -13 lines
Diff to previous 1.108 (colored)

revert 1.108, the diff allowed ldd to print the load address of the binary,
however this modified variables used by C++ backtrace code which caused it
to crash. ok kettenis

Revision 1.108 / (download) - annotate - [select for diffs], Tue Nov 21 20:15:55 2006 UTC (17 years, 6 months ago) by drahn
Branch: MAIN
Changes since 1.107: +13 -1 lines
Diff to previous 1.107 (colored)

Fill in load/end address for binary.

Revision 1.100.2.1 / (download) - annotate - [select for diffs], Wed Nov 15 23:12:40 2006 UTC (17 years, 6 months ago) by brad
Branch: OPENBSD_3_9
Changes since 1.100: +3 -3 lines
Diff to previous 1.100 (colored) next main 1.101 (colored)

MFC:
Fix by deraadt@

failed to purge doubled up environment variables; found by Mark Dowd

ok deraadt@

Revision 1.103.2.1 / (download) - annotate - [select for diffs], Wed Nov 15 23:04:36 2006 UTC (17 years, 6 months ago) by brad
Branch: OPENBSD_4_0
Changes since 1.103: +3 -3 lines
Diff to previous 1.103 (colored) next main 1.104 (colored)

MFC:
Fix by deraadt@

failed to purge doubled up environment variables; found by Mark Dowd

ok deraadt@

Revision 1.107 / (download) - annotate - [select for diffs], Wed Nov 15 19:14:21 2006 UTC (17 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.106: +3 -3 lines
Diff to previous 1.106 (colored)

failed to purge doubled up environment variables; found by Mark Dowd
ok miod

Revision 1.106 / (download) - annotate - [select for diffs], Fri Nov 10 21:19:54 2006 UTC (17 years, 7 months ago) by drahn
Branch: MAIN
Changes since 1.105: +2 -2 lines
Diff to previous 1.105 (colored)

Getting much closer.

Revision 1.105 / (download) - annotate - [select for diffs], Fri Nov 10 07:44:58 2006 UTC (17 years, 7 months ago) by drahn
Branch: MAIN
Changes since 1.104: +3 -1 lines
Diff to previous 1.104 (colored)

Not quite working ld.so support for sh

Revision 1.104 / (download) - annotate - [select for diffs], Sun Sep 24 21:52:49 2006 UTC (17 years, 8 months ago) by kettenis
Branch: MAIN
Changes since 1.103: +23 -5 lines
Diff to previous 1.103 (colored)

Fill in the list of loaded segments for the main executable such that we can
unprotect them if necessary for binaries that have TEXTREL set.

ok drahn@, martin@

Revision 1.103 / (download) - annotate - [select for diffs], Mon May 8 20:37:01 2006 UTC (18 years, 1 month ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE
Branch point for: OPENBSD_4_0
Changes since 1.102: +2 -2 lines
Diff to previous 1.102 (colored)

more spacing

Revision 1.102 / (download) - annotate - [select for diffs], Mon May 8 20:34:36 2006 UTC (18 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.101: +5 -5 lines
Diff to previous 1.101 (colored)

de-space

Revision 1.101 / (download) - annotate - [select for diffs], Wed May 3 16:10:51 2006 UTC (18 years, 1 month ago) by drahn
Branch: MAIN
Changes since 1.100: +22 -5 lines
Diff to previous 1.100 (colored)

prebind - how to prelink a binary without throwing security out the window

Prelink fixes the address of libraries making 'return to libc' attacks trival,
prebind uses a different method to achieve most of the same gains, however
without adding any security conerns.

Still under development, now in-tree.

Revision 1.100 / (download) - annotate - [select for diffs], Wed Nov 9 16:41:29 2005 UTC (18 years, 7 months ago) by kurt
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE
Branch point for: OPENBSD_3_9
Changes since 1.99: +12 -6 lines
Diff to previous 1.99 (colored)

add RTLD_NOW support to dlopen and propogate -z now to dep libs.
ok drahn@

Revision 1.99 / (download) - annotate - [select for diffs], Fri Oct 21 15:24:10 2005 UTC (18 years, 7 months ago) by kurt
Branch: MAIN
Changes since 1.98: +2 -1 lines
Diff to previous 1.98 (colored)

using _dl_link_grpsym to increment refcounts made _dl_notify_unload_shlib
simpler, however it broke ldd refcount output. use _dl_link_child to
increment refcounts and adjust _dl_notify_unload_shlib to match.
work by drahn@ and myself. ok drahn@

Revision 1.98 / (download) - annotate - [select for diffs], Sun Oct 16 04:14:22 2005 UTC (18 years, 7 months ago) by kurt
Branch: MAIN
Changes since 1.97: +100 -86 lines
Diff to previous 1.97 (colored)

Consolidate dl_boot and dlopen dep lib loading into new function
_dl_load_dep_libs. Now both dl_boot and dlopen will randomize dep lib
loading, where previously only dl_boot did.

Revision 1.97 / (download) - annotate - [select for diffs], Wed Oct 12 20:36:16 2005 UTC (18 years, 8 months ago) by kurt
Branch: MAIN
Changes since 1.96: +8 -15 lines
Diff to previous 1.96 (colored)

Split grpsym_list creation away from child_list creation and change
grpsym_list order to match Sun's docs. Also corrects bugs where
grpsym_list was either not created or partially created.

Revision 1.96 / (download) - annotate - [select for diffs], Mon Oct 10 16:33:51 2005 UTC (18 years, 8 months ago) by kurt
Branch: MAIN
Changes since 1.95: +4 -4 lines
Diff to previous 1.95 (colored)

set _dl_loading_object to NULL upon entering and exiting _dl_boot and
dlopen and cleanup of related redundant code. looks fine drahn@

Revision 1.95 / (download) - annotate - [select for diffs], Sun Oct 9 04:29:13 2005 UTC (18 years, 8 months ago) by kurt
Branch: MAIN
Changes since 1.94: +3 -5 lines
Diff to previous 1.94 (colored)

introduce object ref count macros (suggested by dale). no functional
change.

Revision 1.94 / (download) - annotate - [select for diffs], Fri Oct 7 01:26:34 2005 UTC (18 years, 8 months ago) by kurt
Branch: MAIN
Changes since 1.93: +4 -4 lines
Diff to previous 1.93 (colored)

rename dload_list to grpsym_list which better represents its usage.

Revision 1.93 / (download) - annotate - [select for diffs], Thu Oct 6 21:53:10 2005 UTC (18 years, 8 months ago) by kurt
Branch: MAIN
Changes since 1.92: +13 -19 lines
Diff to previous 1.92 (colored)

separate load group references from dep lib child/dload lists. move load
group refs to own per object ref counter (grprefcount) and list
(grpref_list). corrects more complex load group ref cases and side effects
from initial implementation. design ideas and ok drahn@

Revision 1.92 / (download) - annotate - [select for diffs], Mon Oct 3 19:48:24 2005 UTC (18 years, 8 months ago) by kurt
Branch: MAIN
Changes since 1.91: +3 -2 lines
Diff to previous 1.91 (colored)

refcount corrections: count common dep libs once and centralize dep lib
refcount increments to _dl_link_sub. adjust _dl_notify_unload_shlib to
match new refcount method. ok drahn@

Revision 1.91 / (download) - annotate - [select for diffs], Wed Sep 28 18:17:42 2005 UTC (18 years, 8 months ago) by kurt
Branch: MAIN
Changes since 1.90: +1 -4 lines
Diff to previous 1.90 (colored)

remove _dl_exiting dead code

Revision 1.90 / (download) - annotate - [select for diffs], Thu Sep 22 22:33:40 2005 UTC (18 years, 8 months ago) by drahn
Branch: MAIN
Changes since 1.89: +42 -31 lines
Diff to previous 1.89 (colored)

Track if symbols are searched but missing while resolving GOT, if
any are missing exit instead of later causing an abort, ok kurt@

Revision 1.89 / (download) - annotate - [select for diffs], Wed Sep 21 23:12:09 2005 UTC (18 years, 8 months ago) by drahn
Branch: MAIN
Changes since 1.88: +3 -3 lines
Diff to previous 1.88 (colored)

Simplify the internal symbol finding API, with some cleanup, prep for
next step. ok kurt@

Revision 1.88 / (download) - annotate - [select for diffs], Mon Sep 19 02:31:04 2005 UTC (18 years, 8 months ago) by drahn
Branch: MAIN
Changes since 1.87: +8 -1 lines
Diff to previous 1.87 (colored)

simplify code by putting executable in misnamed _dlopened_child_list,
also move RTLD_NEXT/RTLD_SELF code into that code, it is a single test.
okay kurt@

Revision 1.87 / (download) - annotate - [select for diffs], Fri Sep 16 23:19:41 2005 UTC (18 years, 8 months ago) by drahn
Branch: MAIN
Changes since 1.86: +32 -19 lines
Diff to previous 1.86 (colored)

Rework symbol lookup to more closely match sun's documentation, now
treats dlopens as load groups. ok kurt@

Revision 1.86 / (download) - annotate - [select for diffs], Tue May 10 03:36:07 2005 UTC (19 years, 1 month ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.85: +90 -13 lines
Diff to previous 1.85 (colored)

Recommit the destructor order fix, now that the amd64 bug was fixed.
'no problem' pval@

Revision 1.85 / (download) - annotate - [select for diffs], Wed Apr 6 00:16:53 2005 UTC (19 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.84: +12 -89 lines
Diff to previous 1.84 (colored)

backout -- breaks at least amd64; spotted by marc

Revision 1.84 / (download) - annotate - [select for diffs], Tue Apr 5 19:29:09 2005 UTC (19 years, 2 months ago) by drahn
Branch: MAIN
Changes since 1.83: +90 -13 lines
Diff to previous 1.83 (colored)

Do a better job of running destructors in the right order.

Revision 1.83 / (download) - annotate - [select for diffs], Wed Aug 11 17:13:10 2004 UTC (19 years, 10 months ago) by pefo
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7, OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.82: +1 -3 lines
Diff to previous 1.82 (colored)

revert, should not have gone in

Revision 1.82 / (download) - annotate - [select for diffs], Wed Aug 11 17:11:45 2004 UTC (19 years, 10 months ago) by pefo
Branch: MAIN
Changes since 1.81: +3 -1 lines
Diff to previous 1.81 (colored)

mips->mips64

Revision 1.81 / (download) - annotate - [select for diffs], Thu May 27 21:59:07 2004 UTC (20 years ago) by mickey
Branch: MAIN
Changes since 1.80: +1 -9 lines
Diff to previous 1.80 (colored)

fake plabel32 relocs for dyn.init/fini instead of an evil md macro hook

Revision 1.80 / (download) - annotate - [select for diffs], Wed May 26 19:14:14 2004 UTC (20 years ago) by mickey
Branch: MAIN
Changes since 1.79: +13 -13 lines
Diff to previous 1.79 (colored)

call ctors after debugging has been setup; drahn@ ok

Revision 1.79 / (download) - annotate - [select for diffs], Tue May 25 21:48:00 2004 UTC (20 years ago) by mickey
Branch: MAIN
Changes since 1.78: +3 -2 lines
Diff to previous 1.78 (colored)

md parts for hppa

Revision 1.78 / (download) - annotate - [select for diffs], Tue May 25 20:51:03 2004 UTC (20 years ago) by mickey
Branch: MAIN
Changes since 1.77: +23 -6 lines
Diff to previous 1.77 (colored)

use md hook for calling init/fini if defined; only say running ctors/dtors if they are there; drahn@ ok

Revision 1.77 / (download) - annotate - [select for diffs], Tue May 25 18:07:20 2004 UTC (20 years ago) by mickey
Branch: MAIN
Changes since 1.76: +3 -3 lines
Diff to previous 1.76 (colored)

return object* the symbol is in for _dl_find_symbol*; drahn@ ok

Revision 1.76 / (download) - annotate - [select for diffs], Tue May 25 15:56:18 2004 UTC (20 years ago) by deraadt
Branch: MAIN
Changes since 1.75: +4 -4 lines
Diff to previous 1.75 (colored)

spacing

Revision 1.75 / (download) - annotate - [select for diffs], Mon May 24 20:24:54 2004 UTC (20 years ago) by mickey
Branch: MAIN
Changes since 1.74: +29 -29 lines
Diff to previous 1.74 (colored)

doing ldd exit asap -- move all other tasks towards after it.
call atext(_dl_dtors) at the very end -- allows debuggering it.
drahn@ ok

Revision 1.74 / (download) - annotate - [select for diffs], Mon May 24 20:16:12 2004 UTC (20 years ago) by drahn
Branch: MAIN
Changes since 1.73: +3 -3 lines
Diff to previous 1.73 (colored)

Change define used to deal with PLT protection, use postive logic not negative.
ok mickey@

Revision 1.73 / (download) - annotate - [select for diffs], Mon Feb 23 20:47:39 2004 UTC (20 years, 3 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.72: +30 -1 lines
Diff to previous 1.72 (colored)

Set the user variable environ early in ld.so so that library constructors can
properly see the environment. Fixes problem with MALLOC_OPTIONS on dynamic
executables. ok deraadt@

Revision 1.72 / (download) - annotate - [select for diffs], Tue Feb 10 14:12:22 2004 UTC (20 years, 4 months ago) by drahn
Branch: MAIN
Changes since 1.71: +3 -3 lines
Diff to previous 1.71 (colored)

Check for RTLD_TEXT_PLT define instead of an architecture specific check.

Revision 1.71 / (download) - annotate - [select for diffs], Sat Feb 7 06:00:48 2004 UTC (20 years, 4 months ago) by drahn
Branch: MAIN
Changes since 1.70: +3 -3 lines
Diff to previous 1.70 (colored)

Dynamic linker support for arm. non-lazy binding works.

Revision 1.70 / (download) - annotate - [select for diffs], Sat Oct 4 16:13:33 2003 UTC (20 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.69: +0 -11 lines
Diff to previous 1.69 (colored)

breaks on sparc

Revision 1.69 / (download) - annotate - [select for diffs], Fri Oct 3 23:03:37 2003 UTC (20 years, 8 months ago) by drahn
Branch: MAIN
Changes since 1.68: +12 -1 lines
Diff to previous 1.68 (colored)

Initialize environ before calling constructors or atexit.
Tested by tedu, no real ok.

Revision 1.68 / (download) - annotate - [select for diffs], Thu Sep 4 19:33:48 2003 UTC (20 years, 9 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.67: +31 -1 lines
Diff to previous 1.67 (colored)

Symbol cache for GOT lookup. When a symbol is found it is saved in a cache
for future lookups in the same GOT relocation table. Uses static buffer
for small symbol tables, mmap for larger ones. ok deraadt@

Revision 1.67 / (download) - annotate - [select for diffs], Tue Sep 2 15:17:51 2003 UTC (20 years, 9 months ago) by drahn
Branch: MAIN
Changes since 1.66: +7 -4 lines
Diff to previous 1.66 (colored)

Fix PR 3371, symbol lookup in dlopen()ed objects is not correct. Correct
behavior for RTLD_GLOBAL/RTLD_LOCAL is now supported. ok espie@

Revision 1.66 / (download) - annotate - [select for diffs], Wed Jul 9 21:01:10 2003 UTC (20 years, 11 months ago) by drahn
Branch: MAIN
Changes since 1.65: +5 -3 lines
Diff to previous 1.65 (colored)

changes to ld.so to be compatible with newer binutils, requires
slight changes in the startup code on most archs. ok art@ brad@

Revision 1.65 / (download) - annotate - [select for diffs], Sun Jul 6 20:03:57 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.64: +12 -9 lines
Diff to previous 1.64 (colored)

various proto, ansi, and knf repair.  tested on all architectures that
use it. (build may require make cleandir because of .depend balony)

Revision 1.64 / (download) - annotate - [select for diffs], Sun Jun 22 21:39:01 2003 UTC (20 years, 11 months ago) by drahn
Branch: MAIN
Changes since 1.63: +11 -8 lines
Diff to previous 1.63 (colored)

Dynamic linking random order fixes. This enables random library ordering.
Tested by naddy@ and others.

Revision 1.63 / (download) - annotate - [select for diffs], Mon Jun 9 16:10:03 2003 UTC (21 years ago) by deraadt
Branch: MAIN
Changes since 1.62: +1 -7 lines
Diff to previous 1.62 (colored)

pefo 3/4 licence cleanups

Revision 1.62 / (download) - annotate - [select for diffs], Tue Jun 3 18:04:08 2003 UTC (21 years ago) by drahn
Branch: MAIN
Changes since 1.61: +3 -1 lines
Diff to previous 1.61 (colored)

Disable random library ordering, this seems to be exposing bugs in other code.

Revision 1.61 / (download) - annotate - [select for diffs], Fri May 30 19:07:34 2003 UTC (21 years ago) by drahn
Branch: MAIN
Changes since 1.60: +29 -20 lines
Diff to previous 1.60 (colored)

Move env setup to its own function, works around compiler problem on sparc
LD_NORANDOM is now disabled on issetugid().

Revision 1.60 / (download) - annotate - [select for diffs], Fri May 30 16:00:43 2003 UTC (21 years ago) by deraadt
Branch: MAIN
Changes since 1.59: +2 -2 lines
Diff to previous 1.59 (colored)

knf

Revision 1.59 / (download) - annotate - [select for diffs], Fri May 30 15:58:24 2003 UTC (21 years ago) by drahn
Branch: MAIN
Changes since 1.58: +3 -1 lines
Diff to previous 1.58 (colored)

Unbreak tree for sparc, zapping ld_norandom strangely has a bad affect,
killing ld.so.

Revision 1.58 / (download) - annotate - [select for diffs], Fri May 30 03:14:12 2003 UTC (21 years ago) by drahn
Branch: MAIN
Changes since 1.57: +5 -4 lines
Diff to previous 1.57 (colored)

Fix botch in tag array indexing. deal with 0 - DT_NUM,
DT_LOPROC - DT_LOPROC+DT_PROCNUM, and no other values.

Revision 1.57 / (download) - annotate - [select for diffs], Fri May 30 01:33:05 2003 UTC (21 years ago) by drahn
Branch: MAIN
Changes since 1.56: +5 -1 lines
Diff to previous 1.56 (colored)

zap LD_NORANDOM on issetugid() binaries.

Revision 1.56 / (download) - annotate - [select for diffs], Fri May 30 01:13:53 2003 UTC (21 years ago) by drahn
Branch: MAIN
Changes since 1.55: +78 -17 lines
Diff to previous 1.55 (colored)

When loading a shared object or libraries dependant object, load them
in random order. This will reduce the possiblity of a buffer overflow
being able to predict the addresss of useful code. Can be disabled
with the LD_NORANDOM environment variable for debugging purposes.
ok deraadt.

Revision 1.55 / (download) - annotate - [select for diffs], Sat Feb 15 22:43:06 2003 UTC (21 years, 3 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3
Changes since 1.54: +28 -1 lines
Diff to previous 1.54 (colored)

After relocation is completed, remove write protection from GOT/PLT in ld.so.

Revision 1.54 / (download) - annotate - [select for diffs], Sun Feb 2 16:57:58 2003 UTC (21 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.53: +13 -20 lines
Diff to previous 1.53 (colored)

knf & ansi; drahn ok

Revision 1.53 / (download) - annotate - [select for diffs], Thu Jan 30 03:46:46 2003 UTC (21 years, 4 months ago) by drahn
Branch: MAIN
Changes since 1.52: +13 -5 lines
Diff to previous 1.52 (colored)

Change the constructor execution order to initialize dependant libraries
first. This mirrors the commit espie put in a.out ld.so recently.

Revision 1.52 / (download) - annotate - [select for diffs], Thu Nov 14 15:15:54 2002 UTC (21 years, 6 months ago) by drahn
Branch: MAIN
Changes since 1.51: +2 -2 lines
Diff to previous 1.51 (colored)

Make error messages on symbol lookup failures more useful.

Revision 1.51 / (download) - annotate - [select for diffs], Fri Oct 25 10:39:51 2002 UTC (21 years, 7 months ago) by pefo
Branch: MAIN
Changes since 1.50: +7 -44 lines
Diff to previous 1.50 (colored)

Some small fixes in MI code for mips backport. A new reloc md function,
RELOC_GOT, was added to handle mips got bootstrap reloc.

Also remove workaround used on previous versions of binutils for mips.

Revision 1.50 / (download) - annotate - [select for diffs], Mon Oct 21 16:01:55 2002 UTC (21 years, 7 months ago) by drahn
Branch: MAIN
Changes since 1.49: +5 -8 lines
Diff to previous 1.49 (colored)

Simplify the ld.so asm api, the data is available other ways.
tested by naddy@ and myself.

Revision 1.49 / (download) - annotate - [select for diffs], Fri Aug 23 23:02:48 2002 UTC (21 years, 9 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.48: +2 -2 lines
Diff to previous 1.48 (colored)

Support for i386 ELF. Not an indication that the change is going to be made,
just so that these files are maintained in the tree.

Revision 1.48 / (download) - annotate - [select for diffs], Fri Aug 23 22:57:03 2002 UTC (21 years, 9 months ago) by drahn
Branch: MAIN
Changes since 1.47: +11 -6 lines
Diff to previous 1.47 (colored)

Change arguments to _dl_find_symbol() myself, warnnotfound, and inplt into
a single flags field with bits representing each. Use defines to create
the appropriate masks.

Add a new argument sym_size to warn about symbols which have
the incorrect size. This replaces 'ifdef notyet' code which
was in several of the md files with a single version.
sym_size == 0 means do not check, and symbols of type FUNC are
not checked.

Revision 1.47 / (download) - annotate - [select for diffs], Mon Aug 12 01:05:23 2002 UTC (21 years, 10 months ago) by drahn
Branch: MAIN
Changes since 1.46: +1 -3 lines
Diff to previous 1.46 (colored)

Add support for REL type relocations, all currently supported arch
use only RELA type relocations, but that could change. ok art@

Revision 1.46 / (download) - annotate - [select for diffs], Sun Aug 11 18:41:17 2002 UTC (21 years, 10 months ago) by drahn
Branch: MAIN
Changes since 1.45: +3 -3 lines
Diff to previous 1.45 (colored)

The parameter dynp was never used, rather than pass in a dummy on most
archs and a nasty calcuation on others, remove the parameter.

Revision 1.45 / (download) - annotate - [select for diffs], Sun Aug 11 16:51:04 2002 UTC (21 years, 10 months ago) by drahn
Branch: MAIN
Changes since 1.44: +5 -5 lines
Diff to previous 1.44 (colored)

Fix for Elfbug, the Xtiherit problem which has been seen on most OpenBSD
ELF dynamic systems. This was due to an oddity in ELF where the address of
fuctions refer to the PLT address in the program, rather than the actual
function address.

Revision 1.44 / (download) - annotate - [select for diffs], Fri Aug 9 14:35:43 2002 UTC (21 years, 10 months ago) by art
Branch: MAIN
Changes since 1.43: +2 -5 lines
Diff to previous 1.43 (colored)

Simplify.

Revision 1.43 / (download) - annotate - [select for diffs], Sat Jul 27 15:40:44 2002 UTC (21 years, 10 months ago) by art
Branch: MAIN
Changes since 1.42: +1 -2 lines
Diff to previous 1.42 (colored)

I don't see the point of a return at the end of a void function.

Revision 1.42 / (download) - annotate - [select for diffs], Sat Jul 27 13:19:26 2002 UTC (21 years, 10 months ago) by art
Branch: MAIN
Changes since 1.41: +3 -3 lines
Diff to previous 1.41 (colored)

Just a skeleton for sparc. Builds, but pieces are missing and it doesn't
even get to dl_boot_bind correctly.

Revision 1.41 / (download) - annotate - [select for diffs], Wed Jul 24 04:11:10 2002 UTC (21 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.40: +4 -4 lines
Diff to previous 1.40 (colored)

ok i found it

Revision 1.40 / (download) - annotate - [select for diffs], Wed Jul 24 04:00:44 2002 UTC (21 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.39: +3 -3 lines
Diff to previous 1.39 (colored)

back out broken stuff until it is fixed

Revision 1.39 / (download) - annotate - [select for diffs], Wed Jul 24 01:05:11 2002 UTC (21 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.38: +4 -4 lines
Diff to previous 1.38 (colored)

spacing

Revision 1.38 / (download) - annotate - [select for diffs], Fri Jul 12 20:18:30 2002 UTC (21 years, 11 months ago) by drahn
Branch: MAIN
Changes since 1.37: +35 -5 lines
Diff to previous 1.37 (colored)

Change ld.so search order/method to match the a.out ld.so.

run destructors on dlclose()

Move more symbols into _dl_ private space, so that the proper (libc)
version of the function will be used.

Add readdir() functionality to perform the proper library searching.

Support DL_PRELOAD

Do not relocate symbols if ld.so is being traced (and will exit).

Misc lint cleanup.

ok art@

Revision 1.37 / (download) - annotate - [select for diffs], Sun Jul 7 08:54:50 2002 UTC (21 years, 11 months ago) by jufi
Branch: MAIN
Changes since 1.36: +6 -5 lines
Diff to previous 1.36 (colored)


typos/grammar/better words
in comments.

Revision 1.36 / (download) - annotate - [select for diffs], Wed Jun 5 23:13:55 2002 UTC (22 years ago) by art
Branch: MAIN
Changes since 1.35: +4 -1 lines
Diff to previous 1.35 (colored)

Cleanup/remove duplicate code that checks STAT_RELOC_DONE.

Revision 1.35 / (download) - annotate - [select for diffs], Tue May 28 00:34:53 2002 UTC (22 years ago) by deraadt
Branch: MAIN
Changes since 1.34: +32 -32 lines
Diff to previous 1.34 (colored)

KNF

Revision 1.34 / (download) - annotate - [select for diffs], Tue May 28 00:31:37 2002 UTC (22 years ago) by deraadt
Branch: MAIN
Changes since 1.33: +13 -13 lines
Diff to previous 1.33 (colored)

issetugid() test earlier

Revision 1.33 / (download) - annotate - [select for diffs], Tue May 28 00:30:50 2002 UTC (22 years ago) by deraadt
Branch: MAIN
Changes since 1.32: +1 -2 lines
Diff to previous 1.32 (colored)

unused variable in latest commit

Revision 1.32 / (download) - annotate - [select for diffs], Tue May 28 00:30:19 2002 UTC (22 years ago) by drahn
Branch: MAIN
Changes since 1.31: +46 -8 lines
Diff to previous 1.31 (colored)

Remove LD_LIBRARY_PATH completely from environment, as per ldconfig manpage.
ok deraadt@

Revision 1.31 / (download) - annotate - [select for diffs], Tue May 28 00:23:57 2002 UTC (22 years ago) by deraadt
Branch: MAIN
Changes since 1.30: +1 -2 lines
Diff to previous 1.30 (colored)

proto _dl_show_objects() in one place

Revision 1.30 / (download) - annotate - [select for diffs], Fri May 24 04:17:00 2002 UTC (22 years ago) by deraadt
Branch: MAIN
Changes since 1.29: +10 -10 lines
Diff to previous 1.29 (colored)

more KNF

Revision 1.29 / (download) - annotate - [select for diffs], Fri May 24 03:44:37 2002 UTC (22 years ago) by deraadt
Branch: MAIN
Changes since 1.28: +35 -55 lines
Diff to previous 1.28 (colored)

various KNF

Revision 1.28 / (download) - annotate - [select for diffs], Sun Mar 31 21:56:58 2002 UTC (22 years, 2 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.27: +5 -3 lines
Diff to previous 1.27 (colored)

Do not run static constructors when run from ldd. ok theo, art, espie, pefo

Revision 1.27 / (download) - annotate - [select for diffs], Sun Mar 17 19:02:30 2002 UTC (22 years, 2 months ago) by art
Branch: MAIN
Changes since 1.26: +12 -26 lines
Diff to previous 1.26 (colored)

Clean up building of debug_map. mips and non-mips can more
or less share the same code.

Revision 1.26 / (download) - annotate - [select for diffs], Sun Mar 17 00:22:04 2002 UTC (22 years, 2 months ago) by art
Branch: MAIN
Changes since 1.25: +2 -3 lines
Diff to previous 1.25 (colored)

Clean up the zapping of bad variables. Instead of implementing
_dl_suid_ok, just use the issetugid syscall.
ok drahn@.

Revision 1.25 / (download) - annotate - [select for diffs], Thu Mar 7 00:53:26 2002 UTC (22 years, 3 months ago) by art
Branch: MAIN
Changes since 1.24: +2 -1 lines
Diff to previous 1.24 (colored)

Add a debug printf for the entry point just before returning to MD code.

Revision 1.24 / (download) - annotate - [select for diffs], Thu Feb 21 23:17:53 2002 UTC (22 years, 3 months ago) by drahn
Branch: MAIN
Changes since 1.23: +5 -75 lines
Diff to previous 1.23 (colored)

cleanup of MD/MI ld.so (elf), most changes by art@ cleanup by me.
tested on alpha sparc64 powerpc.

Revision 1.23 / (download) - annotate - [select for diffs], Wed Sep 26 22:58:23 2001 UTC (22 years, 8 months ago) by jason
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.22: +2 -2 lines
Diff to previous 1.22 (colored)

'loff' shouldn't be const (at least not on sparc64)

Revision 1.22 / (download) - annotate - [select for diffs], Tue Sep 25 07:01:39 2001 UTC (22 years, 8 months ago) by art
Branch: MAIN
Changes since 1.21: +12 -10 lines
Diff to previous 1.21 (colored)

Zero out dl_data before populating it.
Cleaner populating of dl_data.

Revision 1.21 / (download) - annotate - [select for diffs], Mon Sep 24 23:42:25 2001 UTC (22 years, 8 months ago) by art
Branch: MAIN
Changes since 1.20: +8 -7 lines
Diff to previous 1.20 (colored)

Some voodoo for bootstrapping sparc64.

Revision 1.20 / (download) - annotate - [select for diffs], Mon Sep 24 21:35:09 2001 UTC (22 years, 8 months ago) by drahn
Branch: MAIN
Changes since 1.19: +9 -9 lines
Diff to previous 1.19 (colored)

API change between asm code and _dl_boot_bind(). Simply and
reduce number of parameters. Alpha changes coming shortly.

Revision 1.19 / (download) - annotate - [select for diffs], Sat Sep 22 04:58:18 2001 UTC (22 years, 8 months ago) by drahn
Branch: MAIN
Changes since 1.18: +1 -3 lines
Diff to previous 1.18 (colored)

Upon futher contemplation, the notion of unmaphints is just wrong.
First the maphints code is not cleaning up after itself, by leaving
a file descriptor open and trying to clean up after the dynamic linker
is done loading by removing data needed during dlopen() is nonsense.
the _dl_unmaphints() function and it's references have been removed.
_dl_maphints() now cleans up it's file descriptor before returning.
static data used later during dlopen() is left intact.

Revision 1.18 / (download) - annotate - [select for diffs], Sat Sep 15 20:44:52 2001 UTC (22 years, 8 months ago) by drahn
Branch: MAIN
Changes since 1.17: +8 -7 lines
Diff to previous 1.17 (colored)

Some cleanup in loader.c, initialize the symbol pointer with NULL,
add a missing initialization of the sym pointer.

Add some functionality which allows a program to open itself dlopen(NULL),
so that it can then look up symbols in the executable itself.
Note that the program can only access exported variables, either by
exporting all variables with the ld option -E or externally referrenced.

Fix bug in dlsym() where it would return failure when looking up symbols.
It was testing the offset of the found symbol, not if the symbol was found.

Revision 1.17 / (download) - annotate - [select for diffs], Wed Jun 13 08:40:39 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.16: +4 -8 lines
Diff to previous 1.16 (colored)

Don't do plt relocations here, move that to md code that might choose
to do lazy binding.

Revision 1.16 / (download) - annotate - [select for diffs], Wed Jun 6 12:31:52 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.15: +8 -15 lines
Diff to previous 1.15 (colored)

Replace all 'if (_dl_debug) _dl_printf(...)' with a macro.

Revision 1.15 / (download) - annotate - [select for diffs], Wed Jun 6 12:23:18 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.14: +22 -27 lines
Diff to previous 1.14 (colored)

more cleanup

Revision 1.14 / (download) - annotate - [select for diffs], Wed Jun 6 10:59:15 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.13: +95 -205 lines
Diff to previous 1.13 (colored)

Cleanup.
 - remove printfs that are only useful for the person who put them there.
 - Style.
 - dead code.
Needs much more work.

Revision 1.13 / (download) - annotate - [select for diffs], Fri Jun 1 09:20:58 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.12: +4 -3 lines
Diff to previous 1.12 (colored)

 - Allocate space for the finishing NUL in the name of ld.so.
 - some comments.

Revision 1.12 / (download) - annotate - [select for diffs], Thu May 31 13:58:24 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.11: +5 -2 lines
Diff to previous 1.11 (colored)

If we can't find atexit (because we linked against libc.a),
print a message instead of dereferencing a NULL pointer.

Revision 1.11 / (download) - annotate - [select for diffs], Thu May 31 13:53:56 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.10: +9 -9 lines
Diff to previous 1.10 (colored)

alpha needs JMPREL relocations.
various cleanups.

Revision 1.10 / (download) - annotate - [select for diffs], Mon May 28 21:38:14 2001 UTC (23 years ago) by drahn
Branch: MAIN
Changes since 1.9: +39 -2 lines
Diff to previous 1.9 (colored)

Commonize csu code for elf systems, powerpc now no longer has it's own
versions of these files.

Fixed a bug in ld.so in this, instead of scheduling the fini of each of
the shared libraries with atexit. schedule a function of ld.so itself
and it will walk all of the open libraries when the program exits.
otherwise a shared library could be dl_open()ed and then dl_close()d
and then it would not be mapped for the atexit processing.

TODO:
What if atexit is not found (process did not link against libc?)
Do shared libraries that are dl_closed have their global destructors run?

Revision 1.9 / (download) - annotate - [select for diffs], Mon May 14 22:18:19 2001 UTC (23 years, 1 month ago) by niklas
Branch: MAIN
Changes since 1.8: +42 -6 lines
Diff to previous 1.8 (colored)

Commit initial alpha bits, to facilitate in-tree dev.
This code is not yet working.

Revision 1.8 / (download) - annotate - [select for diffs], Sat May 12 10:39:54 2001 UTC (23 years, 1 month ago) by art
Branch: MAIN
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (colored)

MAP_COPY -> MAP_PRIVATE

Revision 1.7 / (download) - annotate - [select for diffs], Mon Apr 2 23:11:20 2001 UTC (23 years, 2 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.6: +50 -50 lines
Diff to previous 1.6 (colored)

Cleanup for 64bit support.
Pieces by art, niklas and me.
Only tested on powerpc.

Revision 1.6 / (download) - annotate - [select for diffs], Sat Feb 3 22:11:41 2001 UTC (23 years, 4 months ago) by drahn
Branch: MAIN
Changes since 1.5: +4 -4 lines
Diff to previous 1.5 (colored)

Previously only powerpc used the DT_INIT field to find the ctors/init
code, now that will be changed to all arch besides mips will default
to using that. mips probably would be changed to but it has not been
tested.

Revision 1.5 / (download) - annotate - [select for diffs], Tue Jan 23 15:56:39 2001 UTC (23 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.4: +2 -1 lines
Diff to previous 1.4 (colored)

fix includes

Revision 1.4 / (download) - annotate - [select for diffs], Fri Oct 13 05:21:10 2000 UTC (23 years, 8 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_2_8_BASE, OPENBSD_2_8
Changes since 1.3: +11 -68 lines
Diff to previous 1.3 (colored)

Clean up static constructor/destructor discovery and calling. Instead
of relying on magic variable names, reqire that the library provide the
_init/_fini functions so that the linker will find them and create
the DT_INIT and DT_FINI sections of the .dynamic section of the shared library.
With the shared library providing the DT_INIT function pointer, it is
now possible to just check the init field and call it if defined, if not
defined no constructors are needed. This cleans up the code in ld.so greatly.

Revision 1.3 / (download) - annotate - [select for diffs], Sun Sep 17 17:50:57 2000 UTC (23 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.2: +3 -2 lines
Diff to previous 1.2 (colored)

activate ldd, and indent some ld.so messages to make it easier to see what is going on

Revision 1.2 / (download) - annotate - [select for diffs], Mon Sep 11 02:36:37 2000 UTC (23 years, 9 months ago) by rahnds
Branch: MAIN
Changes since 1.1: +394 -108 lines
Diff to previous 1.1 (colored)

ldd compatibility (if we had ldd for this ld.so)
respect the LD_TRACE_LOADED_OBJECTS environment variable,
print loaded libraries and exit, do not execute program.

Revision 1.1.1.2 / (download) - annotate - [select for diffs] (vendor branch), Tue Jun 13 03:40:05 2000 UTC (24 years ago) by rahnds
Branch: per, dsr
CVS Tags: r20000612
Changes since 1.1.1.1: +389 -106 lines
Diff to previous 1.1.1.1 (colored)

Updated version of ld.so, contains additional functionality and fixes/
design changes required by egcs.

added support for ldconfig/ld.so.hints

changes to low level relocation code, required by egcs pic
code generation that moved global variable loads to before the
self relocation was performed. Only powerpc supported, mips code not updated.

Code cleaned up somewhat reasonably.

This code needs to be reviewed closely for significant problems
such as correctness and security.

Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Tue Jun 13 03:34:06 2000 UTC (24 years ago) by rahnds
Branch: per, dsr
CVS Tags: r19990103
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 (colored)

Initial import of ELF ld.so. This was written indepently of the gnu rtld
code and is fully BSD copyrighted.
This initial import contains a mostly working mips and partially working
powerpc version. No support for ld.so.hints or system run path exists.


Revision 1.1 / (download) - annotate - [select for diffs], Tue Jun 13 03:34:06 2000 UTC (24 years ago) by rahnds
Branch: MAIN

Initial revision

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.