]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: convert relative probepoint relocation addresses to absolute
authorRandy Dunlap <randy.dunlap@oracle.com>
Tue, 28 Jun 2011 00:17:17 +0000 (17:17 -0700)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 29 Jun 2015 21:39:52 +0000 (22:39 +0100)
This should have been done by the top-level Makefile, but it must
have a dependency problem since the generated vmlinux_info.S has
the correct info in it but the vmlinux_info.o file does not AND
the .S file was created AFTER the .o file.

Also convert calls to dtrace stub RETs to NOPs.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
kernel/dtrace/sdt_register.c

index d91d19224989f2baecf00bce45eef3ea344c3433..f3ffcbe67bdafa0fdba429c0345a7b80867356dd 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/sdt.h>
 #include <linux/slab.h>
 #include <asm-generic/bitsperlong.h>
+#include <asm-generic/sections.h>
 
 ///#include <sys/types.h>
 ///#include <sys/param.h>
@@ -57,6 +58,19 @@ static int sdt_reloc_resolve(struct module *mp, char *symname, uint8_t *instr)
        }
        memcpy(sdp->sdpd_name, symname, strlen(symname) + 1);
 
+       /* FIXME:
+        * instr is still relative, not absolute; for some reason,
+        * vmlinux_info.S shows absolute addresses but it is not being
+        * rebuilt again when needed, so vmlinux_info.o still contains
+        * relative addresses.
+        * Hack this for now by adding _stext to instr, but this should
+        * not be necessary.
+        */
+       /* convert relative instr to absolute */
+       if ((unsigned long)instr < 0x1000000000000000UL)
+               instr = (uint8_t *)((unsigned long)instr +
+                                       (unsigned long)_stext);
+
        /* TBD: use a kernel list? */
        sdp->sdpd_offset = (uintptr_t)instr;
        sdp->sdpd_next = mp->sdt_probes;
@@ -65,12 +79,10 @@ static int sdt_reloc_resolve(struct module *mp, char *symname, uint8_t *instr)
        DPRINTK("sdt_probes -> 0x%p\n", mp->sdt_probes);
        DPRINTK("this probe: instr offset=0x%lx, next ptr=0x%p, probe_name=%s\n",
                sdp->sdpd_offset, sdp->sdpd_next, sdp->sdpd_name);
-#if 0
-       // NOT YET SAFE, since instr is relative, not absolute //
+
        /* TBD: need a safer write-to-exec-memory ? */
        for (i = 0; i < SDT_NOPS; i++)
                instr[i - 1] = SDT_NOP;
-#endif
 
        return 0;
 }