History log of /openbsd-current/libexec/ld.so/sod.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.37 05-Nov-2022 deraadt

The /var/run/ld.so.hints file is mapped into memory. It is never replaced,
so the mapping can be immutable.
ok kettenis


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.36 08-Jan-2022 guenther

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 tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.35 12-Dec-2017 deraadt

ld.so's syscall _dl_* API/ABI doesn't reurn errno, but -errno.
Reviewing behaviour artifacts with pledge, I discover a close(-ENOSYS)..
ok guenther


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.34 24-Jan-2017 guenther

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 tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.33 29-Oct-2015 deraadt

remove tests for LD_HINTS_VERSION_1; ok kettenis


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 18-Nov-2014 krw

Nuke some obvious #include duplications.

ok espie@ deraadt@ millert@ tedu@


Revision tags: OPENBSD_5_6_BASE
# 1.31 10-Jul-2014 otto

check all memory allocations; ok miod@ guenther@


# 1.30 09-Jul-2014 guenther

Use O_CLOEXEC to make sure fork+exec in a threaded process can't
see the fds used by dlopen()

ok otto@ miod@


# 1.29 06-Jul-2014 otto

enable -Wall, explicitly call _dl_strsep, and zap some redundant includes
ok miod@


# 1.28 21-Jun-2014 otto

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 tags: OPENBSD_5_5_BASE
# 1.27 03-Dec-2013 deraadt

stop using sys/syslimits.h directly, and use limits.h
prodded by millert


Revision tags: OPENBSD_5_4_BASE
# 1.26 20-Mar-2013 kurt

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


Revision tags: OPENBSD_5_3_BASE
# 1.25 19-Jan-2013 miod

Do not divide by zero in _dl_findhint() if there is a valid hints file but
no buckets in it (could happen if the administrator reruns ldconfig with
bogus paths). ok matthew@ kurt@ drahn


Revision tags: OPENBSD_5_2_BASE
# 1.24 12-Jun-2012 matthew

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 tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.23 02-Oct-2008 kurt

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 tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 17-Oct-2004 drahn

Fix some problems related to LD_LIBRARY_PATH parsing where it would not
correctly deal with current directory searches specified by "::", ":foo" or
"foo:"


Revision tags: OPENBSD_3_6_BASE
# 1.21 18-May-2004 mickey

fix includes scoping; drahn@ ok


Revision tags: OPENBSD_3_5_BASE
# 1.20 11-Nov-2003 drahn

Better fix to the library name parsing. now correctly handles
libpython2.2.so.0.0 vs libpython2.1.so.0.0. Clean up a potential
memory leak if the filename is not a valid library.
ok brad@


# 1.19 26-Oct-2003 drahn

Work around a problem with shared libraries named as libX-A.B.so.X.Y.
Without this patch, the standard major:minor version matching failed.
ok brad@


Revision tags: OPENBSD_3_4_BASE
# 1.18 06-Jul-2003 deraadt

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


# 1.17 08-May-2003 millert

Previously, ld.so would use a single page for mapping the hints file
and then, if that was not big enough, map the rest of it contiguously.
However, there is no guarantee that the address space after the
first mmap has not already been used by something else.

Instead, just fstat the file and map up to st_size. Also reorganized
the code a tad and added some sanity checks for st_size.

Problem tracked down by dhartmei@ and mickey@; drahn@ OK.


Revision tags: OPENBSD_3_3_BASE
# 1.16 02-Feb-2003 deraadt

branches: 1.16.2;
knf & ansi; drahn ok


Revision tags: OPENBSD_3_2_BASE
# 1.15 29-Jul-2002 art

minor formatting


# 1.14 12-Jul-2002 drahn

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@


# 1.13 27-May-2002 deraadt

KNF


# 1.12 25-May-2002 drahn

use _dl_strncmp() not strncmp(), _dl version is already present and used.


# 1.11 25-May-2002 drahn

_dl_strcmp() and _dl_strchr() exist, do not pull these routines
from libsa source.


# 1.10 24-May-2002 deraadt

more KNF


# 1.9 24-May-2002 deraadt

various KNF


Revision tags: OPENBSD_3_1_BASE
# 1.8 21-Feb-2002 drahn

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


Revision tags: OPENBSD_3_0_BASE
# 1.7 22-Sep-2001 drahn

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.


# 1.6 22-Sep-2001 drahn

The unmaphints routine should not destroy the hint mapping.
Otherwise shared modules which depend on libraries cannot find
them because the list of trusted directories has been lost.
However we need to be careful that the unmapping of the hints frees
the file descriptor, but will not free it multiple times.


# 1.5 08-Jun-2001 art

Be consistent. If we have inveted our of strlen, use it everywhere.


# 1.4 31-May-2001 art

When opening the hints file, check for error return < 0, not -1.
_dl_open is not necessarily like the regular open(2).
XXX - maybe we should check with _dl_check_error?


# 1.3 12-May-2001 art

MAP_COPY -> MAP_PRIVATE


# 1.2 11-May-2001 art

-1 -> MAP_FAILED.


# 1.1 13-Jun-2000 rahnds

branches: 1.1.1;
Initial revision


# 1.36 08-Jan-2022 guenther

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 tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.35 12-Dec-2017 deraadt

ld.so's syscall _dl_* API/ABI doesn't reurn errno, but -errno.
Reviewing behaviour artifacts with pledge, I discover a close(-ENOSYS)..
ok guenther


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.34 24-Jan-2017 guenther

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 tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.33 29-Oct-2015 deraadt

remove tests for LD_HINTS_VERSION_1; ok kettenis


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 18-Nov-2014 krw

Nuke some obvious #include duplications.

ok espie@ deraadt@ millert@ tedu@


Revision tags: OPENBSD_5_6_BASE
# 1.31 10-Jul-2014 otto

check all memory allocations; ok miod@ guenther@


# 1.30 09-Jul-2014 guenther

Use O_CLOEXEC to make sure fork+exec in a threaded process can't
see the fds used by dlopen()

ok otto@ miod@


# 1.29 06-Jul-2014 otto

enable -Wall, explicitly call _dl_strsep, and zap some redundant includes
ok miod@


# 1.28 21-Jun-2014 otto

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 tags: OPENBSD_5_5_BASE
# 1.27 03-Dec-2013 deraadt

stop using sys/syslimits.h directly, and use limits.h
prodded by millert


Revision tags: OPENBSD_5_4_BASE
# 1.26 20-Mar-2013 kurt

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


Revision tags: OPENBSD_5_3_BASE
# 1.25 19-Jan-2013 miod

Do not divide by zero in _dl_findhint() if there is a valid hints file but
no buckets in it (could happen if the administrator reruns ldconfig with
bogus paths). ok matthew@ kurt@ drahn


Revision tags: OPENBSD_5_2_BASE
# 1.24 12-Jun-2012 matthew

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 tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.23 02-Oct-2008 kurt

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 tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 17-Oct-2004 drahn

Fix some problems related to LD_LIBRARY_PATH parsing where it would not
correctly deal with current directory searches specified by "::", ":foo" or
"foo:"


Revision tags: OPENBSD_3_6_BASE
# 1.21 18-May-2004 mickey

fix includes scoping; drahn@ ok


Revision tags: OPENBSD_3_5_BASE
# 1.20 11-Nov-2003 drahn

Better fix to the library name parsing. now correctly handles
libpython2.2.so.0.0 vs libpython2.1.so.0.0. Clean up a potential
memory leak if the filename is not a valid library.
ok brad@


# 1.19 26-Oct-2003 drahn

Work around a problem with shared libraries named as libX-A.B.so.X.Y.
Without this patch, the standard major:minor version matching failed.
ok brad@


Revision tags: OPENBSD_3_4_BASE
# 1.18 06-Jul-2003 deraadt

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


# 1.17 08-May-2003 millert

Previously, ld.so would use a single page for mapping the hints file
and then, if that was not big enough, map the rest of it contiguously.
However, there is no guarantee that the address space after the
first mmap has not already been used by something else.

Instead, just fstat the file and map up to st_size. Also reorganized
the code a tad and added some sanity checks for st_size.

Problem tracked down by dhartmei@ and mickey@; drahn@ OK.


Revision tags: OPENBSD_3_3_BASE
# 1.16 02-Feb-2003 deraadt

branches: 1.16.2;
knf & ansi; drahn ok


Revision tags: OPENBSD_3_2_BASE
# 1.15 29-Jul-2002 art

minor formatting


# 1.14 12-Jul-2002 drahn

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@


# 1.13 27-May-2002 deraadt

KNF


# 1.12 25-May-2002 drahn

use _dl_strncmp() not strncmp(), _dl version is already present and used.


# 1.11 25-May-2002 drahn

_dl_strcmp() and _dl_strchr() exist, do not pull these routines
from libsa source.


# 1.10 24-May-2002 deraadt

more KNF


# 1.9 24-May-2002 deraadt

various KNF


Revision tags: OPENBSD_3_1_BASE
# 1.8 21-Feb-2002 drahn

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


Revision tags: OPENBSD_3_0_BASE
# 1.7 22-Sep-2001 drahn

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.


# 1.6 22-Sep-2001 drahn

The unmaphints routine should not destroy the hint mapping.
Otherwise shared modules which depend on libraries cannot find
them because the list of trusted directories has been lost.
However we need to be careful that the unmapping of the hints frees
the file descriptor, but will not free it multiple times.


# 1.5 08-Jun-2001 art

Be consistent. If we have inveted our of strlen, use it everywhere.


# 1.4 31-May-2001 art

When opening the hints file, check for error return < 0, not -1.
_dl_open is not necessarily like the regular open(2).
XXX - maybe we should check with _dl_check_error?


# 1.3 12-May-2001 art

MAP_COPY -> MAP_PRIVATE


# 1.2 11-May-2001 art

-1 -> MAP_FAILED.


# 1.1 13-Jun-2000 rahnds

branches: 1.1.1;
Initial revision


# 1.35 12-Dec-2017 deraadt

ld.so's syscall _dl_* API/ABI doesn't reurn errno, but -errno.
Reviewing behaviour artifacts with pledge, I discover a close(-ENOSYS)..
ok guenther


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.34 24-Jan-2017 guenther

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 tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.33 29-Oct-2015 deraadt

remove tests for LD_HINTS_VERSION_1; ok kettenis


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 18-Nov-2014 krw

Nuke some obvious #include duplications.

ok espie@ deraadt@ millert@ tedu@


Revision tags: OPENBSD_5_6_BASE
# 1.31 10-Jul-2014 otto

check all memory allocations; ok miod@ guenther@


# 1.30 09-Jul-2014 guenther

Use O_CLOEXEC to make sure fork+exec in a threaded process can't
see the fds used by dlopen()

ok otto@ miod@


# 1.29 06-Jul-2014 otto

enable -Wall, explicitly call _dl_strsep, and zap some redundant includes
ok miod@


# 1.28 21-Jun-2014 otto

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 tags: OPENBSD_5_5_BASE
# 1.27 03-Dec-2013 deraadt

stop using sys/syslimits.h directly, and use limits.h
prodded by millert


Revision tags: OPENBSD_5_4_BASE
# 1.26 20-Mar-2013 kurt

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


Revision tags: OPENBSD_5_3_BASE
# 1.25 19-Jan-2013 miod

Do not divide by zero in _dl_findhint() if there is a valid hints file but
no buckets in it (could happen if the administrator reruns ldconfig with
bogus paths). ok matthew@ kurt@ drahn


Revision tags: OPENBSD_5_2_BASE
# 1.24 12-Jun-2012 matthew

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 tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.23 02-Oct-2008 kurt

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 tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 17-Oct-2004 drahn

Fix some problems related to LD_LIBRARY_PATH parsing where it would not
correctly deal with current directory searches specified by "::", ":foo" or
"foo:"


Revision tags: OPENBSD_3_6_BASE
# 1.21 18-May-2004 mickey

fix includes scoping; drahn@ ok


Revision tags: OPENBSD_3_5_BASE
# 1.20 11-Nov-2003 drahn

Better fix to the library name parsing. now correctly handles
libpython2.2.so.0.0 vs libpython2.1.so.0.0. Clean up a potential
memory leak if the filename is not a valid library.
ok brad@


# 1.19 26-Oct-2003 drahn

Work around a problem with shared libraries named as libX-A.B.so.X.Y.
Without this patch, the standard major:minor version matching failed.
ok brad@


Revision tags: OPENBSD_3_4_BASE
# 1.18 06-Jul-2003 deraadt

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


# 1.17 08-May-2003 millert

Previously, ld.so would use a single page for mapping the hints file
and then, if that was not big enough, map the rest of it contiguously.
However, there is no guarantee that the address space after the
first mmap has not already been used by something else.

Instead, just fstat the file and map up to st_size. Also reorganized
the code a tad and added some sanity checks for st_size.

Problem tracked down by dhartmei@ and mickey@; drahn@ OK.


Revision tags: OPENBSD_3_3_BASE
# 1.16 02-Feb-2003 deraadt

branches: 1.16.2;
knf & ansi; drahn ok


Revision tags: OPENBSD_3_2_BASE
# 1.15 29-Jul-2002 art

minor formatting


# 1.14 12-Jul-2002 drahn

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@


# 1.13 27-May-2002 deraadt

KNF


# 1.12 25-May-2002 drahn

use _dl_strncmp() not strncmp(), _dl version is already present and used.


# 1.11 25-May-2002 drahn

_dl_strcmp() and _dl_strchr() exist, do not pull these routines
from libsa source.


# 1.10 24-May-2002 deraadt

more KNF


# 1.9 24-May-2002 deraadt

various KNF


Revision tags: OPENBSD_3_1_BASE
# 1.8 21-Feb-2002 drahn

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


Revision tags: OPENBSD_3_0_BASE
# 1.7 22-Sep-2001 drahn

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.


# 1.6 22-Sep-2001 drahn

The unmaphints routine should not destroy the hint mapping.
Otherwise shared modules which depend on libraries cannot find
them because the list of trusted directories has been lost.
However we need to be careful that the unmapping of the hints frees
the file descriptor, but will not free it multiple times.


# 1.5 08-Jun-2001 art

Be consistent. If we have inveted our of strlen, use it everywhere.


# 1.4 31-May-2001 art

When opening the hints file, check for error return < 0, not -1.
_dl_open is not necessarily like the regular open(2).
XXX - maybe we should check with _dl_check_error?


# 1.3 12-May-2001 art

MAP_COPY -> MAP_PRIVATE


# 1.2 11-May-2001 art

-1 -> MAP_FAILED.


# 1.1 13-Jun-2000 rahnds

branches: 1.1.1;
Initial revision