-/* $OpenBSD: dlfcn.h,v 1.14 2017/11/28 17:19:47 kettenis Exp $ */
+/* $OpenBSD: dlfcn.h,v 1.15 2021/06/02 07:29:03 semarie Exp $ */
/* $NetBSD: dlfcn.h,v 1.2 1995/06/05 19:38:00 pk Exp $ */
/*
#define RTLD_GLOBAL 0x100
#define RTLD_LOCAL 0x000
#define RTLD_TRACE 0x200
+#define RTLD_NODELETE 0x400
/*
* Special handle arguments for dlsym().
major=96
-minor=0
+minor=1
# note: If changes were made to include/thread_private.h or if system calls
# were added/changed then librthread/shlib_version must also be updated.
-/* $OpenBSD: dlfcn.c,v 1.106 2019/10/04 17:42:16 guenther Exp $ */
+/* $OpenBSD: dlfcn.c,v 1.107 2021/06/02 07:29:03 semarie Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
int failed = 0;
int obj_flags;
- if (flags & ~(RTLD_TRACE|RTLD_LAZY|RTLD_NOW|RTLD_GLOBAL)) {
+ if (flags & ~(RTLD_TRACE|RTLD_LAZY|RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE)) {
_dl_errno = DL_INVALID_MODE;
return NULL;
}
goto loaded;
}
+ if (flags & RTLD_NODELETE)
+ object->obj_flags |= DF_1_NODELETE;
+
_dl_link_dlopen(object);
if (OBJECT_REF_CNT(object) > 1) {
+ _dl_handle_nodelete(object);
+
/* if opened but grpsym_vec has not been filled in */
if (object->grpsym_vec.len == 0)
_dl_cache_grpsym_list_setup(object);
-/* $OpenBSD: resolve.c,v 1.94 2019/10/04 17:42:16 guenther Exp $ */
+/* $OpenBSD: resolve.c,v 1.95 2021/06/02 07:29:03 semarie Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
static elf_object_t *_dl_last_object;
elf_object_t *_dl_loading_object;
-/*
- * Add a new dynamic object to the object list.
- */
void
-_dl_add_object(elf_object_t *object)
+_dl_handle_nodelete(elf_object_t *object)
{
/*
* If a .so is marked nodelete, then the entire load group that it's
object->load_object->opencount++;
object->load_object->status |= STAT_NODELETE;
}
+}
+
+/*
+ * Add a new dynamic object to the object list.
+ */
+void
+_dl_add_object(elf_object_t *object)
+{
+ _dl_handle_nodelete(object);
/*
* if this is a new object, prev will be NULL
-/* $OpenBSD: resolve.h,v 1.97 2021/03/16 18:03:06 kurt Exp $ */
+/* $OpenBSD: resolve.h,v 1.98 2021/06/02 07:29:03 semarie Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
extern char *__progname;
__BEGIN_HIDDEN_DECLS
+void _dl_handle_nodelete(elf_object_t *_object);
void _dl_add_object(elf_object_t *object);
elf_object_t *_dl_finalize_object(const char *objname, Elf_Dyn *dynp,
Elf_Phdr *phdrp, int phdrc, const int objtype, const long lbase,
-.\" $OpenBSD: dlfcn.3,v 1.30 2020/12/03 22:47:22 jmc Exp $
+.\" $OpenBSD: dlfcn.3,v 1.31 2021/06/02 07:29:03 semarie Exp $
.\" $NetBSD: dlfcn.3,v 1.3 1996/01/09 19:43:34 pk Exp $
.\"
.\" Copyright (c) 1995 Paul Kranenburg
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: December 3 2020 $
+.Dd $Mdocdate: June 2 2021 $
.Dt DLOPEN 3
.Os
.Sh NAME
If an object was opened with RTLD_LOCAL and later opened with RTLD_GLOBAL,
then it is promoted to RTLD_GLOBAL.
.Pp
+Additionally, the following flag may be ORed into the mode argument:
+.Pp
+.Bl -tag -width "RTLD_NODELETE" -compact -offset indent
+.It Sy RTLD_NODELETE
+Prevents unload of the loaded object on
+.Fn dlclose .
+.El
+.Pp
The main executable's symbols are normally invisible to
.Fn dlopen
symbol resolution.