From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 3A3A73858406; Tue, 20 Sep 2022 10:12:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A3A73858406 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663668732; bh=sPBEALcRmsrsKwesj+UUFSTKJBKRtJybhe9wCzZ0lrw=; h=From:To:Subject:Date:From; b=c2KjMy+oVoSF+Aj9sX28kc1ZuNPIa9dd0axeCS5bgTh4gKhdU3u6L88BcX+1KS7W+ ak8JC46NX54bw0emcEKDqmb1BUO6b1f0QDk+yl3ThHER+ZyBBoCoucP9uNmszDV3fX ZvHj6btfBfGjaNiIQnkCoji2OFjKr+Tk1olA0aJ4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc/release/2.35/master] elf: Rename _dl_sort_maps parameter from skip to force_first X-Act-Checkin: glibc X-Git-Author: Florian Weimer X-Git-Refname: refs/heads/release/2.35/master X-Git-Oldrev: ff344711ea2856eb9dc1031008360ef57554e40b X-Git-Newrev: c15c0f198584ecb2d58a478d7e88b1ce5bc81df8 Message-Id: <20220920101212.3A3A73858406@sourceware.org> Date: Tue, 20 Sep 2022 10:12:12 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c15c0f198584ecb2d58a478d7e88b1ce5bc81df8 commit c15c0f198584ecb2d58a478d7e88b1ce5bc81df8 Author: Florian Weimer Date: Tue Sep 6 07:38:10 2022 +0200 elf: Rename _dl_sort_maps parameter from skip to force_first The new implementation will not be able to skip an arbitrary number of objects. Reviewed-by: Adhemerval Zanella (cherry picked from commit dbb75513f5cf9285c77c9e55777c5c35b653f890) Diff: --- elf/dl-sort-maps.c | 14 +++++++------- sysdeps/generic/ldsodefs.h | 6 ++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/elf/dl-sort-maps.c b/elf/dl-sort-maps.c index 96638d7ed1..5b550b1e94 100644 --- a/elf/dl-sort-maps.c +++ b/elf/dl-sort-maps.c @@ -27,12 +27,12 @@ If FOR_FINI is true, this is called for finishing an object. */ static void _dl_sort_maps_original (struct link_map **maps, unsigned int nmaps, - unsigned int skip, bool for_fini) + bool force_first, bool for_fini) { /* Allows caller to do the common optimization of skipping the first map, usually the main binary. */ - maps += skip; - nmaps -= skip; + maps += force_first; + nmaps -= force_first; /* A list of one element need not be sorted. */ if (nmaps <= 1) @@ -182,7 +182,7 @@ dfs_traversal (struct link_map ***rpo, struct link_map *map, static void _dl_sort_maps_dfs (struct link_map **maps, unsigned int nmaps, - unsigned int skip __attribute__ ((unused)), bool for_fini) + bool force_first __attribute__ ((unused)), bool for_fini) { for (int i = nmaps - 1; i >= 0; i--) maps[i]->l_visited = 0; @@ -286,7 +286,7 @@ _dl_sort_maps_init (void) void _dl_sort_maps (struct link_map **maps, unsigned int nmaps, - unsigned int skip, bool for_fini) + bool force_first, bool for_fini) { /* It can be tempting to use a static function pointer to store and call the current selected sorting algorithm routine, but experimentation @@ -296,9 +296,9 @@ _dl_sort_maps (struct link_map **maps, unsigned int nmaps, input cases. A simple if-case with direct function calls appears to be the fastest. */ if (__glibc_likely (GLRO(dl_dso_sort_algo) == dso_sort_algorithm_original)) - _dl_sort_maps_original (maps, nmaps, skip, for_fini); + _dl_sort_maps_original (maps, nmaps, force_first, for_fini); else - _dl_sort_maps_dfs (maps, nmaps, skip, for_fini); + _dl_sort_maps_dfs (maps, nmaps, force_first, for_fini); } #endif /* HAVE_TUNABLES. */ diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 64d7e52a39..4a5e7b63d1 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -1121,9 +1121,11 @@ extern void _dl_init (struct link_map *main_map, int argc, char **argv, initializer functions have completed. */ extern void _dl_fini (void) attribute_hidden; -/* Sort array MAPS according to dependencies of the contained objects. */ +/* Sort array MAPS according to dependencies of the contained objects. + If FORCE_FIRST, MAPS[0] keeps its place even if the dependencies + say otherwise. */ extern void _dl_sort_maps (struct link_map **maps, unsigned int nmaps, - unsigned int skip, bool for_fini) attribute_hidden; + bool force_first, bool for_fini) attribute_hidden; /* The dynamic linker calls this function before and having changing any shared object mappings. The `r_state' member of `struct r_debug'