Index: uspace/lib/c/generic/rtld/module.c
===================================================================
--- uspace/lib/c/generic/rtld/module.c	(revision 634e020ca4b381b0399365dd09c5ca7895e43a1c)
+++ uspace/lib/c/generic/rtld/module.c	(revision 57c2a87b03a0b6c08cef4f64f0cf52a7d8b38b62)
@@ -117,5 +117,5 @@
 		}
 	}
-	
+
 	return NULL; /* Not found */
 }
@@ -127,5 +127,5 @@
  * Currently this trivially tries to load '/<name>'.
  */
-module_t *module_load(rtld_t *rtld, const char *name)
+module_t *module_load(rtld_t *rtld, const char *name, mlflags_t flags)
 {
 	elf_finfo_t info;
@@ -133,6 +133,6 @@
 	module_t *m;
 	int rc;
-	
-	m = malloc(sizeof(module_t));
+
+	m = calloc(1, sizeof(module_t));
 	if (!m) {
 		printf("malloc failed\n");
@@ -141,4 +141,6 @@
 
 	m->rtld = rtld;
+	if ((flags & mlf_local) != 0)
+		m->local = true;
 
 	if (str_size(name) > NAME_BUF_SIZE - 2) {
@@ -185,5 +187,5 @@
 /** Load all modules on which m (transitively) depends.
  */
-void module_load_deps(module_t *m)
+void module_load_deps(module_t *m, mlflags_t flags)
 {
 	elf_dyn_t *dp;
@@ -230,6 +232,6 @@
 			dm = module_find(m->rtld, dep_name);
 			if (!dm) {
-				dm = module_load(m->rtld, dep_name);
-				module_load_deps(dm);
+				dm = module_load(m->rtld, dep_name, flags);
+				module_load_deps(dm, flags);
 			}
 
Index: uspace/lib/c/generic/rtld/rtld.c
===================================================================
--- uspace/lib/c/generic/rtld/rtld.c	(revision 634e020ca4b381b0399365dd09c5ca7895e43a1c)
+++ uspace/lib/c/generic/rtld/rtld.c	(revision 57c2a87b03a0b6c08cef4f64f0cf52a7d8b38b62)
@@ -80,4 +80,6 @@
 	prog_mod.dyn.soname = "[program]";
 	prog_mod.rtld = env;
+	prog_mod.exec = true;
+	prog_mod.local = false;
 
 	/* Initialize list of loaded modules */
@@ -96,5 +98,5 @@
 
 	DPRINTF("Load all program dependencies\n");
-	module_load_deps(&prog_mod);
+	module_load_deps(&prog_mod, 0);
 
 	/*
Index: uspace/lib/c/generic/rtld/symbol.c
===================================================================
--- uspace/lib/c/generic/rtld/symbol.c	(revision 634e020ca4b381b0399365dd09c5ca7895e43a1c)
+++ uspace/lib/c/generic/rtld/symbol.c	(revision 57c2a87b03a0b6c08cef4f64f0cf52a7d8b38b62)
@@ -112,11 +112,9 @@
  * @param name		Name of the symbol to search for.
  * @param start		Module in which to start the search..
- * @param flags		@c ssf_none or @c ssf_noroot to not look for the symbol
- *			in @a start
  * @param mod		(output) Will be filled with a pointer to the module 
  *			that contains the symbol.
  */
 elf_symbol_t *symbol_bfs_find(const char *name, module_t *start,
-    symbol_search_flags_t flags, module_t **mod)
+    module_t **mod)
 {
 	module_t *m, *dm;
@@ -150,12 +148,10 @@
 
 		/* If ssf_noroot is specified, do not look in start module */
-		if (m != start || (flags & ssf_noroot) == 0) { 
-			s = def_find_in_module(name, m);
-			if (s != NULL) {
-				/* Symbol found */
-				sym = s;
-				*mod = m;
-				break;
-			}
+		s = def_find_in_module(name, m);
+		if (s != NULL) {
+			/* Symbol found */
+			sym = s;
+			*mod = m;
+			break;
 		}
 
@@ -189,11 +185,10 @@
  *
  * By definition in System V ABI, if module origin has the flag DT_SYMBOLIC,
- * origin is searched first. Otherwise, or if the symbol hasn't been found,
- * the module dependency graph is searched breadth-first, beginning
- * from the executable program.
+ * origin is searched first. Otherwise, search global modules in the default
+ * order.
  *
  * @param name		Name of the symbol to search for.
  * @param origin	Module in which the dependency originates.
- * @param flags		@c ssf_none or @c ssf_noroot to not look for the symbol
+ * @param flags		@c ssf_none or @c ssf_noexec to not look for the symbol
  *			in the executable program.
  * @param mod		(output) Will be filled with a pointer to the module 
@@ -205,26 +200,51 @@
 	elf_symbol_t *s;
 
-	if (origin->dyn.symbolic) {
-		/* 
+	DPRINTF("symbol_def_find('%s', origin='%s'\n",
+	    name, origin->dyn.soname);
+	if (origin->dyn.symbolic && (!origin->exec || (flags & ssf_noexec) == 0)) {
+		DPRINTF("symbolic->find '%s' in module '%s'\n", name, origin->dyn.soname);
+		/*
 		 * Origin module has a DT_SYMBOLIC flag.
 		 * Try this module first
 		 */
-		 s = def_find_in_module(name, origin);
-		 if (s != NULL) {
+		s = def_find_in_module(name, origin);
+		if (s != NULL) {
 			/* Found */
 			*mod = origin;
 			return s;
-		 }
+		}
 	}
 
 	/* Not DT_SYMBOLIC or no match. Now try other locations. */
 
-	if (origin->rtld->program) {
-		/* Program is dynamic -- start with program as root. */
-		return symbol_bfs_find(name, origin->rtld->program, flags, mod);
-	} else {
-		/* Program is static -- start with @a origin as root. */
-		return symbol_bfs_find(name, origin, ssf_none, mod);
-	}
+	list_foreach(origin->rtld->modules, modules_link, module_t, m) {
+		DPRINTF("module '%s' local?\n", m->dyn.soname);
+		if (!m->local && (!m->exec || (flags & ssf_noexec) == 0)) {
+			DPRINTF("!local->find '%s' in module '%s'\n", name, m->dyn.soname);
+			s = def_find_in_module(name, m);
+			if (s != NULL) {
+				/* Found */
+				*mod = m;
+				return s;
+			}
+		}
+	}
+
+	/* Finally, try origin. */
+
+	DPRINTF("try finding '%s' in origin '%s'\n", name,
+	    origin->dyn.soname);
+
+	if (!origin->exec || (flags & ssf_noexec) == 0) {
+		s = def_find_in_module(name, origin);
+		if (s != NULL) {
+			/* Found */
+			*mod = origin;
+			return s;
+		}
+	}
+
+	DPRINTF("'%s' not found\n", name);
+	return NULL;
 }
 
