From f6f5a33817ac1d406c8c2687e32493cbc38ef4e7 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 10 Sep 2008 13:21:50 +0200 Subject: Feed dwarf unwinder data through _stp_mod_sec_lookup (), but disabled for now. --- runtime/unwind.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/unwind.c') diff --git a/runtime/unwind.c b/runtime/unwind.c index 21ea4559..7b19573d 100644 --- a/runtime/unwind.c +++ b/runtime/unwind.c @@ -676,6 +676,7 @@ int unwind(struct unwind_frame_info *frame) signed ptrType = -1; uleb128_t retAddrReg = 0; struct _stp_module *m; + struct _stp_section *s = NULL; struct unwind_state state; dbug_unwind(1, "pc=%lx, %lx", pc, UNW_PC(frame)); @@ -683,7 +684,7 @@ int unwind(struct unwind_frame_info *frame) if (UNW_PC(frame) == 0) return -EINVAL; - m = NULL /*_stp_get_unwind_info(pc) */; + m = _stp_mod_sec_lookup (pc, &s); if (unlikely(m == NULL)) { dbug_unwind(1, "No module found for pc=%lx", pc); return -EINVAL; -- cgit From 6b2fda5424fb9aaeabe5056fc1e7286f6c8a034a Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 10 Sep 2008 13:51:30 +0200 Subject: Record module base and use it for adjusting start locations in dwarf unwinder. --- runtime/unwind.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'runtime/unwind.c') diff --git a/runtime/unwind.c b/runtime/unwind.c index 7b19573d..db8ae664 100644 --- a/runtime/unwind.c +++ b/runtime/unwind.c @@ -550,10 +550,27 @@ static int processCFI(const u8 *start, const u8 *end, unsigned long targetLoc, s return result && ptr.p8 == end && (targetLoc == 0 || state->label == NULL); } +// This is an address inside a module, adjust. +static unsigned long +adjustStartLoc (unsigned long startLoc, + struct _stp_module *m, + struct _stp_section *s) +{ + if (startLoc && (strcmp (m->name, "kernel") != 0)) + { + startLoc = _stp_module_relocate (m->name, s->name, + startLoc); + startLoc -= m->module_base; + } + return startLoc; +} + /* If we previously created an unwind header, then use it now to binary search */ /* for the FDE corresponding to pc. */ -static u32 *_stp_search_unwind_hdr(unsigned long pc, struct _stp_module *m) +static u32 *_stp_search_unwind_hdr(unsigned long pc, + struct _stp_module *m, + struct _stp_section *s) { const u8 *ptr, *end, *hdr = m->unwind_hdr; unsigned long startLoc; @@ -600,6 +617,7 @@ static u32 *_stp_search_unwind_hdr(unsigned long pc, struct _stp_module *m) do { const u8 *cur = ptr + (num / 2) * (2 * tableSize); startLoc = read_pointer(&cur, cur + tableSize, hdr[3]); + startLoc = adjustStartLoc(startLoc, m, s); if (pc < startLoc) num /= 2; else { @@ -608,7 +626,7 @@ static u32 *_stp_search_unwind_hdr(unsigned long pc, struct _stp_module *m) } } while (startLoc && num > 1); - if (num == 1 && (startLoc = read_pointer(&ptr, ptr + tableSize, hdr[3])) != 0 && pc >= startLoc) + if (num == 1 && (startLoc = adjustStartLoc(read_pointer(&ptr, ptr + tableSize, hdr[3]), m, s)) != 0 && pc >= startLoc) fde = (void *)read_pointer(&ptr, ptr + tableSize, hdr[3]); dbug_unwind(1, "returning fde=%lx startLoc=%lx", fde, startLoc); @@ -695,7 +713,7 @@ int unwind(struct unwind_frame_info *frame) goto err; } - fde = _stp_search_unwind_hdr(pc, m); + fde = _stp_search_unwind_hdr(pc, m, s); dbug_unwind(1, "%s: fde=%lx\n", m->name, fde); /* found the fde, now set startLoc and endLoc */ @@ -705,6 +723,8 @@ int unwind(struct unwind_frame_info *frame) ptr = (const u8 *)(fde + 2); ptrType = fde_pointer_type(cie); startLoc = read_pointer(&ptr, (const u8 *)(fde + 1) + *fde, ptrType); + startLoc = adjustStartLoc(startLoc, m, s); + dbug_unwind(2, "startLoc=%lx, ptrType=%s", startLoc, _stp_eh_enc_name(ptrType)); if (!(ptrType & DW_EH_PE_indirect)) ptrType &= DW_EH_PE_FORM | DW_EH_PE_signed; @@ -734,6 +754,7 @@ int unwind(struct unwind_frame_info *frame) ptr = (const u8 *)(fde + 2); startLoc = read_pointer(&ptr, (const u8 *)(fde + 1) + *fde, ptrType); + startLoc = adjustStartLoc(startLoc, m, s); dbug_unwind(2, "startLoc=%lx, ptrType=%s", startLoc, _stp_eh_enc_name(ptrType)); if (!startLoc) continue; -- cgit From 675fb1ddeec8cd22e17ab989f8a813a375ae6226 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 10 Sep 2008 17:43:42 +0200 Subject: Rename _stp_module module_base output to dwarf_module_base and document. --- runtime/unwind.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'runtime/unwind.c') diff --git a/runtime/unwind.c b/runtime/unwind.c index db8ae664..bc8a93dc 100644 --- a/runtime/unwind.c +++ b/runtime/unwind.c @@ -550,7 +550,9 @@ static int processCFI(const u8 *start, const u8 *end, unsigned long targetLoc, s return result && ptr.p8 == end && (targetLoc == 0 || state->label == NULL); } -// This is an address inside a module, adjust. +// If this is an address inside a module, adjust for section relocation +// and the elfutils base relocation done during loading of the .dwarf_frame +// in translate.cxx. static unsigned long adjustStartLoc (unsigned long startLoc, struct _stp_module *m, @@ -560,7 +562,7 @@ adjustStartLoc (unsigned long startLoc, { startLoc = _stp_module_relocate (m->name, s->name, startLoc); - startLoc -= m->module_base; + startLoc -= m->dwarf_module_base; } return startLoc; } -- cgit