summaryrefslogtreecommitdiff
blob: 2e45736e3883a5f90216476e53e554fe4192e5cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Backported from 8.0.
Even if RTLD_NOLOAD is not standard, dev-libs/nss expects it.
Since it has made it to 8.0 we can afford backporting it.

--- libexec/rtld-elf/rtld.c.old	2010-01-10 18:19:50 +0100
+++ libexec/rtld-elf/rtld.c	2010-01-10 18:30:03 +0100
@@ -104,7 +104,7 @@
 static void linkmap_delete(Obj_Entry *);
 static int load_needed_objects(Obj_Entry *);
 static int load_preload_objects(void);
-static Obj_Entry *load_object(const char *, const Obj_Entry *);
+static Obj_Entry *load_object(const char *, const Obj_Entry *, int);
 static Obj_Entry *obj_from_addr(const void *);
 static void objlist_call_fini(Objlist *, int *lockstate);
 static void objlist_call_init(Objlist *, int *lockstate);
@@ -1384,7 +1384,7 @@
 
 	    while(*curpath) {
 		if (needed->obj == NULL) {
-		    needed->obj = load_object(*curpath, NULL);
+		    needed->obj = load_object(*curpath, NULL, false);
 		    curpath++;
 		    continue;
 		}
@@ -1417,7 +1417,7 @@
 
 	savech = p[len];
 	p[len] = '\0';
-	if (load_object(p, NULL) == NULL)
+	if (load_object(p, NULL, false) == NULL)
 	    return -1;	/* XXX - cleanup */
 	p[len] = savech;
 	p += len;
@@ -1434,7 +1434,7 @@
  * on failure.
  */
 static Obj_Entry *
-load_object(const char *name, const Obj_Entry *refobj)
+load_object(const char *name, const Obj_Entry *refobj, int noload)
 {
     Obj_Entry *obj;
     int fd = -1;
@@ -1480,6 +1480,8 @@
 	close(fd);
 	return obj;
     }
+    if (noload)
+	return (NULL);
 
     /* First use of this object, so we must map it in */
     obj = do_load_object(fd, name, path, &sb);
@@ -1940,12 +1942,13 @@
     Obj_Entry **old_obj_tail;
     Obj_Entry *obj;
     Objlist initlist;
-    int result, lockstate;
+    int result, lockstate, noload;
 
     LD_UTRACE(UTRACE_DLOPEN_START, NULL, NULL, 0, mode, name);
     ld_tracing = (mode & RTLD_TRACE) == 0 ? NULL : "1";
     if (ld_tracing != NULL)
 	environ = (char **)*get_program_var_addr("environ");
+    noload = mode & RTLD_NOLOAD;
 
     objlist_init(&initlist);
 
@@ -1958,7 +1961,7 @@
 	obj = obj_main;
 	obj->refcount++;
     } else {
-	obj = load_object(name, obj_main);
+	obj = load_object(name, obj_main, noload);
     }
 
     if (obj) {