commit 17ee540dd61113fe4f557f191db3480db875cca1 Author: Mark Wielaard Date: Wed Apr 18 15:00:24 2018 +0200 Make kernel DWARF unwinder work with ksalr. The .debug_frame loaded from disk is already relocated against the expected load offset of the kernel, but the actual static (load) address might be different (with kaslr). So adjust the startLoc for that difference when reading any address from the unwind table. diff --git a/runtime/unwind.c b/runtime/unwind.c index 3a2d991..4c360d2 100644 --- a/runtime/unwind.c +++ b/runtime/unwind.c @@ -724,10 +724,15 @@ adjustStartLoc (unsigned long startLoc, dbug_unwind(2, "adjustStartLoc=%lx, ptrType=%s, m=%s, s=%s eh=%d\n", startLoc, _stp_eh_enc_name(ptrType), m->path, s->name, is_ehframe); if (startLoc == 0 - || strcmp (m->name, "kernel") == 0 || (strcmp (s->name, ".absolute") == 0 && !is_ehframe)) return startLoc; + /* The .debug_frame loaded from disk is already relocated against the + expected load offset of the kernel, but the actual static (load) + address might be different (with kaslr). */ + if (strcmp (m->name, "kernel") == 0) + return startLoc - s->sec_load_offset + s->static_addr; + /* eh_frame data has been loaded in the kernel, so readjust offset. */ if (is_ehframe) { dbug_unwind(2, "eh_frame=%lx, eh_frame_addr=%lx\n", (unsigned long) m->eh_frame, m->eh_frame_addr);