diff options
Diffstat (limited to 'elf/dl-fini.c')
-rw-r--r-- | elf/dl-fini.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/elf/dl-fini.c b/elf/dl-fini.c index 61dedd5168..fd22bc0a4d 100644 --- a/elf/dl-fini.c +++ b/elf/dl-fini.c @@ -87,18 +87,41 @@ _dl_fini (void) memmove (&maps[j] + 1, &maps[j], (k - j) * sizeof (struct link_map *)); - maps[j] = here; + maps[j++] = here; break; } else ++runp; } + + if (__builtin_expect (maps[k]->l_reldeps != NULL, 0)) + { + unsigned int m = maps[k]->l_reldepsact; + struct link_map **relmaps = maps[k]->l_reldeps; + + while (m-- > 0) + { + if (relmaps[m] == l) + { + struct link_map *here = maps[k]; + + /* Move it now. */ + memmove (&maps[j] + 1, + &maps[j], + (k - j) * sizeof (struct link_map *)); + maps[j] = here; + + break; + } + + } + } } } /* `maps' now contains the objects in the right order. Now call the - destructors. We have the process this array from the front. */ + destructors. We have to process this array from the front. */ for (i = 0; i < nloaded; ++i) { l = maps[i]; |