about summary refs log tree commit diff
path: root/elf/dl-deps.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/dl-deps.c')
-rw-r--r--elf/dl-deps.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/elf/dl-deps.c b/elf/dl-deps.c
index 3e49fcfe01..9fe974d982 100644
--- a/elf/dl-deps.c
+++ b/elf/dl-deps.c
@@ -38,6 +38,10 @@ _dl_map_object_deps (struct link_map *map)
   head.next = NULL;
   nlist = 1;
 
+  /* We use `l_reserved' as a mark bit to detect objects we have already
+     put in the search list and avoid adding duplicate elements later in
+     the list.  */
+  map->l_reserved = 1;
 
   /* Process each element of the search list, loading each of its immediate
      dependencies and appending them to the list as we step through it.
@@ -47,11 +51,6 @@ _dl_map_object_deps (struct link_map *map)
     {
       struct link_map *l = scanp->map;
 
-      /* We use `l_reserved' as a mark bit to detect objects we have
-         already put in the search list and avoid adding duplicate elements
-         later in the list.  */
-      l->l_reserved = 1;
-
       if (l->l_info[DT_NEEDED])
 	{
 	  const char *strtab
@@ -79,6 +78,8 @@ _dl_map_object_deps (struct link_map *map)
 		    tailp->map = dep;
 		    tailp->next = NULL;
 		    ++nlist;
+		    /* Set the mark bit that says it's already in the list.  */
+		    dep->l_reserved = 1;
 		  }
 	      }
 	}