blob: 02e73594a0a9b53df6e0f07bfdb5334871024c24 [file] [log] [blame]
Andrew Geissler635e0e42020-08-21 15:58:33 -05001From dffa52364f8c54c455b2459ebe83f05cb6ffc9fc Mon Sep 17 00:00:00 2001
Andrew Geissler82c905d2020-04-13 13:39:40 -05002From: Mark Hatle <mark.hatle@windriver.com>
3Date: Thu, 18 Aug 2016 14:07:58 -0500
Andrew Geissler635e0e42020-08-21 15:58:33 -05004Subject: [PATCH 24/29] elf/dl-deps.c: Make _dl_build_local_scope breadth first
Andrew Geissler82c905d2020-04-13 13:39:40 -05005
6According to the ELF specification:
7
8When resolving symbolic references, the dynamic linker examines the symbol
9tables with a breadth-first search.
10
11This function was using a depth first search. By doing so the conflict
12resolution reported to the prelinker (when LD_TRACE_PRELINKING=1 is set)
13was incorrect. This caused problems when their were various circular
14dependencies between libraries. The problem usually manifested itself by
15the wrong IFUNC being executed.
16
17[BZ# 20488]
18
19Upstream-Status: Submitted [libc-alpha]
20
21Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
22---
23 elf/dl-deps.c | 14 ++++++++++----
24 1 file changed, 10 insertions(+), 4 deletions(-)
25
26diff --git a/elf/dl-deps.c b/elf/dl-deps.c
Andrew Geissler635e0e42020-08-21 15:58:33 -050027index b5a43232a7..8aa8f37fa3 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050028--- a/elf/dl-deps.c
29+++ b/elf/dl-deps.c
30@@ -73,13 +73,19 @@ _dl_build_local_scope (struct link_map **list, struct link_map *map)
31 {
32 struct link_map **p = list;
33 struct link_map **q;
34+ struct link_map **r;
35
36 *p++ = map;
37 map->l_reserved = 1;
38- if (map->l_initfini)
39- for (q = map->l_initfini + 1; *q; ++q)
40- if (! (*q)->l_reserved)
41- p += _dl_build_local_scope (p, *q);
42+
43+ for (r = list; r < p; ++r)
44+ if ((*r)->l_initfini)
45+ for (q = (*r)->l_initfini + 1; *q; ++q)
46+ if (! (*q)->l_reserved)
47+ {
48+ *p++ = *q;
49+ (*q)->l_reserved = 1;
50+ }
51 return p - list;
52 }
53
Andrew Geissler635e0e42020-08-21 15:58:33 -050054--
552.27.0
56