|
|
317253 |
commit 4ae4592f1106e941023a5768d34c2381cc869631
|
|
|
317253 |
Author: Frank Ch. Eigler <fche@redhat.com>
|
|
|
317253 |
Date: Wed Aug 21 19:29:45 2019 -0400
|
|
|
317253 |
|
|
|
317253 |
PR23879, PR24875: fix task-finder-vma on f29+
|
|
|
317253 |
|
|
|
317253 |
It was reported & rediscovered that some vma-dependent runtime
|
|
|
317253 |
facilities have been broken: @vma() and *ubacktrace(). It turns out
|
|
|
317253 |
that modern gcc/ld.so links/loads binaries in slightly different ways
|
|
|
317253 |
than older toolchains. Specifically, the first page of ELF files is
|
|
|
317253 |
now loaded only r--p instead of r-xp protection flags. The
|
|
|
317253 |
_stp_vma_mmap_cb() routine now accepts the r--p case too. It now
|
|
|
317253 |
ignores the flags entirely.
|
|
|
317253 |
|
|
|
317253 |
diff --git a/runtime/vma.c b/runtime/vma.c
|
|
|
317253 |
index 7021725..02f9bf8 100644
|
|
|
317253 |
--- a/runtime/vma.c
|
|
|
317253 |
+++ b/runtime/vma.c
|
|
|
317253 |
@@ -157,10 +157,15 @@ static int _stp_vma_mmap_cb(struct stap_task_finder_target *tgt,
|
|
|
317253 |
dbug_task_vma(1,
|
|
|
317253 |
"mmap_cb: tsk %d:%d path %s, addr 0x%08lx, length 0x%08lx, offset 0x%lx, flags 0x%lx\n",
|
|
|
317253 |
tsk->pid, tsk->tgid, path, addr, length, offset, vm_flags);
|
|
|
317253 |
- // We are only interested in the first load of the whole module that
|
|
|
317253 |
- // is executable. We register whether or not we know the module,
|
|
|
317253 |
+
|
|
|
317253 |
+ // We used to be only interested in the first load of the whole module that
|
|
|
317253 |
+ // is executable. But with modern enough gcc/ld.so, executables are mapped
|
|
|
317253 |
+ // in more small pieces (r--p,r-xp,rw-p, instead of r-xp, rw-p). To establish
|
|
|
317253 |
+ // the virtual base address, we initially look for an offset=0 mapping.
|
|
|
317253 |
+ //
|
|
|
317253 |
+ // We register whether or not we know the module,
|
|
|
317253 |
// so we can later lookup the name given an address for this task.
|
|
|
317253 |
- if (path != NULL && offset == 0 && (vm_flags & VM_EXEC)
|
|
|
317253 |
+ if (path != NULL && offset == 0
|
|
|
317253 |
&& stap_find_vma_map_info(tsk, addr, NULL, NULL, NULL, NULL) != 0) {
|
|
|
317253 |
for (i = 0; i < _stp_num_modules; i++) {
|
|
|
317253 |
// PR20433: papering over possibility of NULL pointers
|