]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: fix elf_py TLS section handling
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 10 Nov 2021 14:30:07 +0000 (15:30 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 4 Jan 2022 14:45:45 +0000 (15:45 +0100)
... need to ignore TLS sections, their address is effectively
meaningless but can overlap other sections we actually need to access.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 3942ee1f7bc754dd0dd9ae79f89d0f2635be334f)

lib/elf_py.c

index 1c306893ad816f08d5ff31e45204f84253d28167..f230add69576323d6398bfd57419ad1363ce8ed2 100644 (file)
@@ -636,6 +636,9 @@ static Elf_Scn *elf_find_addr(struct elffile *ef, uint64_t addr, size_t *idx)
                Elf_Scn *scn = elf_getscn(ef->elf, i);
                GElf_Shdr _shdr, *shdr = gelf_getshdr(scn, &_shdr);
 
+               /* virtual address is kinda meaningless for TLS sections */
+               if (shdr->sh_flags & SHF_TLS)
+                       continue;
                if (addr < shdr->sh_addr ||
                    addr >= shdr->sh_addr + shdr->sh_size)
                        continue;