From df00639dbe262b8919bdf625f30d80e5b9b96346 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Mon, 7 Jul 2008 17:40:24 -0400 Subject: pass /sys/module/*/sections/* addresses to the kernel module too --- runtime/staprun/staprun.c | 90 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 7 deletions(-) (limited to 'runtime/staprun/staprun.c') diff --git a/runtime/staprun/staprun.c b/runtime/staprun/staprun.c index cef96815..664b75ee 100644 --- a/runtime/staprun/staprun.c +++ b/runtime/staprun/staprun.c @@ -22,6 +22,8 @@ #include "staprun.h" #include +#include + /* used in dbug, _err and _perr */ @@ -330,6 +332,8 @@ void send_a_relocation (const char* module, const char* reloc, unsigned long lon int send_relocation_kernel () { + int srkrc = 0; + FILE* kallsyms = fopen ("/proc/kallsyms", "r"); if (kallsyms == NULL) { @@ -338,7 +342,8 @@ int send_relocation_kernel () } else { - while (! feof(kallsyms)) + int done_with_kallsyms = 0; + while (! feof(kallsyms) && !done_with_kallsyms) { char *line = NULL; size_t linesz = 0; @@ -352,6 +357,7 @@ int send_relocation_kernel () char* symbol = NULL; int rc = sscanf (line, "%llx %c %as", &address, &type, &symbol); free (line); line=NULL; + if (symbol == NULL) continue; /* OOM? */ #ifdef __powerpc__ #define KERNEL_RELOC_SYMBOL ".__start" @@ -364,22 +370,92 @@ int send_relocation_kernel () send_a_relocation ("kernel", "_stext", address); /* We need nothing more from the kernel. */ - fclose (kallsyms); - return 0; + done_with_kallsyms=1; } - if (symbol != NULL) free (symbol); + + free (symbol); } } fclose (kallsyms); + if (!done_with_kallsyms) srkrc = -1; } - - return -1; + + return srkrc; } void send_relocation_modules () { - /* XXX */ + unsigned i; + glob_t globbuf; + int r = glob("/sys/module/*/sections/*", GLOB_PERIOD, NULL, &globbuf); + + if (r == GLOB_NOSPACE || r == GLOB_ABORTED) + return; + + for (i=0; i