From 10e093db21b73e98ba8485b4b0696d330bf8dfdf Mon Sep 17 00:00:00 2001 From: Stephen Webb Date: Sat, 23 Jul 2022 16:36:31 -0400 Subject: Find segment containing .text by flag not order The existing code was identifying the segment containing the executable code (.text section) by assuming it was effectively the first loadable segment. Th has always worked up until recently but was an invalid assumption. The right thing to do is check the segment flags to see if the execute bit is set. This change does just that. Tested on Linux x86_64, no new regressions. --- src/dwarf/Gfind_unwind_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dwarf/Gfind_unwind_table.c b/src/dwarf/Gfind_unwind_table.c index a6198ad2..4942b34f 100644 --- a/src/dwarf/Gfind_unwind_table.c +++ b/src/dwarf/Gfind_unwind_table.c @@ -73,7 +73,7 @@ dwarf_find_unwind_table (struct elf_dyn_info *edi, unw_addr_space_t as, if (phdr[i].p_vaddr + phdr[i].p_memsz > end_ip) end_ip = phdr[i].p_vaddr + phdr[i].p_memsz; - if (phdr[i].p_offset == mapoff) + if ((phdr[i].p_flags & PF_X) == PF_X) ptxt = phdr + i; if ((uintptr_t) edi->ei.image + phdr->p_filesz > max_load_addr) max_load_addr = (uintptr_t) edi->ei.image + phdr->p_filesz; -- cgit v1.2.1