From ea15e536789fd3c06efc88e3e068b69732376be7 Mon Sep 17 00:00:00 2001 From: Alexander Lochmann Date: Mon, 1 Oct 2012 18:42:15 -0400 Subject: [PATCH] PR14555, replace kernel symbol "_stext" by a macro in runtime/k_syms.h The macro is used by the runtime as well as the compilation components. It is not guaranteed that this symbol is always called "_stext" on all archtitectures. On powerpc64 for example its name is ".__start". Stap will not run on other architectures where this symbol has a different name because the lookup for "_stext" will fail. Adjusted by to leave _stext as the relocation pseudo-section name as used by relocation basis code, and parametrizing only symbol names. --- runtime/k_syms.h | 10 ++++++++++ staprun/staprun.c | 7 +------ translate.cxx | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 runtime/k_syms.h diff --git a/runtime/k_syms.h b/runtime/k_syms.h new file mode 100644 index 000000000..5e3db1dfe --- /dev/null +++ b/runtime/k_syms.h @@ -0,0 +1,10 @@ +#ifndef _K_SYMS_H_ +#define _K_SYMS_H_ + +#ifdef __powerpc64__ +#define KERNEL_RELOC_SYMBOL ".__start" +#else +#define KERNEL_RELOC_SYMBOL "_stext" +#endif + +#endif diff --git a/staprun/staprun.c b/staprun/staprun.c index 550839305..2cd90ac08 100644 --- a/staprun/staprun.c +++ b/staprun/staprun.c @@ -23,6 +23,7 @@ #define _BSD_SOURCE #include "staprun.h" #include "../privilege.h" +#include "../runtime/k_syms.h" #include #include #include @@ -473,12 +474,6 @@ int send_a_relocation (const char* module, const char* reloc, unsigned long long } -#ifdef __powerpc64__ -#define KERNEL_RELOC_SYMBOL ".__start" -#else -#define KERNEL_RELOC_SYMBOL "_stext" -#endif - int send_relocation_kernel () { FILE* kallsyms; diff --git a/translate.cxx b/translate.cxx index dd09d44ae..25e159538 100644 --- a/translate.cxx +++ b/translate.cxx @@ -18,6 +18,7 @@ #include "dwarf_wrappers.h" #include "setupdwfl.h" #include "task_finder.h" +#include "runtime/k_syms.h" #include "dwflpp.h" #include @@ -5727,7 +5728,7 @@ dump_symbol_tables (Dwfl_Module *m, // there may have been no kernel probes set. We could // use tapsets.cxx:lookup_symbol_address(), but then // we're already iterating over the same data here... - if (! strcmp(name, "_stext")) + if (! strcmp(name, KERNEL_RELOC_SYMBOL)) { int ki; extra_offset = sym_addr; -- 2.43.5