elf: Fix force_first handling in dlclose (bug 30981)
commit849274d48fc59bfa6db3c713c8ced8026b20f3b7
authorFlorian Weimer <fweimer@redhat.com>
Thu, 16 Nov 2023 18:55:35 +0000 (16 19:55 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 16 Nov 2023 19:16:05 +0000 (16 20:16 +0100)
tree2f92737d63b3b236acd167df35a6d2556bea4c07
parenta8dcffb30680d6db5704f9ce2fc30621ceb454e7
elf: Fix force_first handling in dlclose (bug 30981)

The force_first parameter was ineffective because the dlclose'd
object was not necessarily the first in the maps array.  Also
enable force_first handling unconditionally, regardless of namespace.
The initial object in a namespace should be destructed first, too.

The _dl_sort_maps_dfs function had early returns for relocation
dependency processing which broke force_first handling, too, and
this is fixed in this change as well.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
elf/dl-close.c
elf/dl-sort-maps.c
elf/dso-sort-tests-1.def