0025-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch 1.5 KB

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