Implement a DL_REFERENCE dlctl. To be used by the upcoming
authorkettenis <kettenis@openbsd.org>
Tue, 28 Nov 2017 17:19:47 +0000 (17:19 +0000)
committerkettenis <kettenis@openbsd.org>
Tue, 28 Nov 2017 17:19:47 +0000 (17:19 +0000)
__cxa_thread_atexit() implementation.

ok guenther@

include/dlfcn.h
libexec/ld.so/dlfcn.c

index 76e3387..431065f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dlfcn.h,v 1.13 2013/03/24 01:37:21 deraadt Exp $      */
+/*     $OpenBSD: dlfcn.h,v 1.14 2017/11/28 17:19:47 kettenis Exp $     */
 /*     $NetBSD: dlfcn.h,v 1.2 1995/06/05 19:38:00 pk Exp $     */
 
 /*
@@ -72,6 +72,7 @@ typedef       struct dl_info {
 #define DL_GETLOADADDR x
 #define DL_SETTHREADLCK        2
 #define DL_SETBINDLCK  3
+#define DL_REFERENCE   4
 
 #define        DL_LAZY         RTLD_LAZY       /* Compat */
 
index b51c50a..7995692 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dlfcn.c,v 1.98 2017/08/29 15:25:51 deraadt Exp $ */
+/*     $OpenBSD: dlfcn.c,v 1.99 2017/11/28 17:19:47 kettenis Exp $ */
 
 /*
  * Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -219,6 +219,23 @@ dlctl(void *handle, int command, void *data)
                /* made superfluous by kbind */
                retval = 0;
                break;
+       case DL_REFERENCE:
+       {
+               elf_object_t *obj;
+
+               obj = obj_from_addr(data);
+               if (obj == NULL) {
+                       _dl_errno = DL_CANT_FIND_OBJ;
+                       retval = -1;
+                       break;
+               }
+               if ((obj->status & STAT_NODELETE) == 0) {
+                       obj->opencount++;
+                       obj->status |= STAT_NODELETE;
+               }
+               retval = 0;
+               break;
+       }
        case 0x20:
                _dl_show_objects();
                retval = 0;