diff options
-rw-r--r-- | libexec/ld.so/dlfcn.c | 27 | ||||
-rw-r--r-- | share/man/man3/dlfcn.3 | 12 |
2 files changed, 27 insertions, 12 deletions
diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c index 752c70a2085..ded0396992b 100644 --- a/libexec/ld.so/dlfcn.c +++ b/libexec/ld.so/dlfcn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dlfcn.c,v 1.31 2003/09/04 19:33:48 drahn Exp $ */ +/* $OpenBSD: dlfcn.c,v 1.32 2003/09/25 21:56:20 millert Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -235,28 +235,33 @@ _dl_unload_deps(elf_object_t *object) const char * dlerror(void) { + const char *errmsg; + switch (_dl_errno) { case 0: /* NO ERROR */ - return (NULL); + errmsg = NULL; case DL_NOT_FOUND: - return ("File not found"); + errmsg = "File not found"; case DL_CANT_OPEN: - return ("Can't open file"); + errmsg = "Can't open file"; case DL_NOT_ELF: - return ("File not an ELF object"); + errmsg = "File not an ELF object"; case DL_CANT_OPEN_REF: - return ("Can't open referenced object"); + errmsg = "Can't open referenced object"; case DL_CANT_MMAP: - return ("Can't map ELF object"); + errmsg = "Can't map ELF object"; case DL_INVALID_HANDLE: - return ("Invalid handle"); + errmsg = "Invalid handle"; case DL_NO_SYMBOL: - return ("Unable to resolve symbol"); + errmsg = "Unable to resolve symbol"; case DL_INVALID_CTL: - return ("Invalid dlctl() command"); + errmsg = "Invalid dlctl() command"; default: - return ("Unknown error"); + errmsg = "Unknown error"; } + + _dl_errno = 0; + return (errmsg); } void diff --git a/share/man/man3/dlfcn.3 b/share/man/man3/dlfcn.3 index a7b681fbb5a..4a03872ad84 100644 --- a/share/man/man3/dlfcn.3 +++ b/share/man/man3/dlfcn.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dlfcn.3,v 1.14 2002/12/30 13:51:59 millert Exp $ +.\" $OpenBSD: dlfcn.3,v 1.15 2003/09/25 21:56:20 millert Exp $ .\" $NetBSD: dlfcn.3,v 1.3 1996/01/09 19:43:34 pk Exp $ .\" .\" Copyright (c) 1995 Paul Kranenburg @@ -121,6 +121,16 @@ This interface is .Fn dlerror returns a character string representing the most recent error that has occurred while processing one of the other functions described here. +If no dynamic linking errors have occurred since the last invocation of +.Fn dlerror , +.Fn dlerror +returns +.Dv NULL . +Thus, invoking +.Fn dlerror +a second time, immediately following a prior invocation, will result in +.Dv NULL +being returned. .Sh SEE ALSO .Xr ld 1 , .Xr ld.so 1 , |