summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Webb <swebb@blackberry.com>2022-07-23 16:36:31 -0400
committerStephen M. Webb <stephen.webb@bregmasoft.ca>2022-07-26 21:44:26 -0400
commit10e093db21b73e98ba8485b4b0696d330bf8dfdf (patch)
tree5245d9caa6ff535541aed9c06a52580ec3b94a21
parent958efd8150db6ea57a995f4fd07d9f707693c3d4 (diff)
downloadlibunwind-10e093db21b73e98ba8485b4b0696d330bf8dfdf.tar.gz
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.
-rw-r--r--src/dwarf/Gfind_unwind_table.c2
1 files changed, 1 insertions, 1 deletions
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;