0002-lib-fix-elf_py-TLS-section-handling.patch 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. From 3942ee1f7bc754dd0dd9ae79f89d0f2635be334f Mon Sep 17 00:00:00 2001
  2. From: David Lamparter <equinox@opensourcerouting.org>
  3. Date: Wed, 10 Nov 2021 15:30:07 +0100
  4. Subject: [PATCH] lib: fix elf_py TLS section handling
  5. ... need to ignore TLS sections, their address is effectively
  6. meaningless but can overlap other sections we actually need to access.
  7. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
  8. [Retrieved from:
  9. https://github.com/FRRouting/frr/commit/3942ee1f7bc754dd0dd9ae79f89d0f2635be334f]
  10. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  11. ---
  12. lib/elf_py.c | 3 +++
  13. 1 file changed, 3 insertions(+)
  14. diff --git a/lib/elf_py.c b/lib/elf_py.c
  15. index 1c306893ad8..f230add6957 100644
  16. --- a/lib/elf_py.c
  17. +++ b/lib/elf_py.c
  18. @@ -636,6 +636,9 @@ static Elf_Scn *elf_find_addr(struct elffile *ef, uint64_t addr, size_t *idx)
  19. Elf_Scn *scn = elf_getscn(ef->elf, i);
  20. GElf_Shdr _shdr, *shdr = gelf_getshdr(scn, &_shdr);
  21. + /* virtual address is kinda meaningless for TLS sections */
  22. + if (shdr->sh_flags & SHF_TLS)
  23. + continue;
  24. if (addr < shdr->sh_addr ||
  25. addr >= shdr->sh_addr + shdr->sh_size)
  26. continue;