From 0e90292704a55f10754cd6d41fe659857f48d893 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 27 Jun 2011 17:17:17 -0700 Subject: [PATCH] dtrace: convert relative probepoint relocation addresses to absolute 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 --- kernel/dtrace/sdt_register.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/kernel/dtrace/sdt_register.c b/kernel/dtrace/sdt_register.c index d91d19224989..f3ffcbe67bda 100644 --- a/kernel/dtrace/sdt_register.c +++ b/kernel/dtrace/sdt_register.c @@ -7,6 +7,7 @@ #include #include #include +#include ///#include ///#include @@ -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; } -- 2.50.1