diff options
author | fche <fche> | 2007-03-21 01:58:10 +0000 |
---|---|---|
committer | fche <fche> | 2007-03-21 01:58:10 +0000 |
commit | 840489846051292305b56243feba9807ba06039e (patch) | |
tree | dff5fc8d30d0060c8bd734e4ba3d1eb80b207d40 /runtime/sym.c | |
parent | 6fa8d6e2a8378bfaee0e8e1af8cc707b4e14aab3 (diff) | |
download | systemtap-steved-840489846051292305b56243feba9807ba06039e.tar.gz systemtap-steved-840489846051292305b56243feba9807ba06039e.tar.xz systemtap-steved-840489846051292305b56243feba9807ba06039e.zip |
2007-03-20 Frank Ch. Eigler <fche@elastic.org>
PR 4224.
* tapsets.cxx (add_probe_point): Make kernel implicitly relocated
relative to the _stext symbol.
(dwarf_derived_probe ctor, emit_module_decls): Cooperate.
(lookup_symbol_address): New function.
(dwarf_builder::build): Call it thrice.
(in_kprobes_function): Simplify.
* session.h (systemtap_session): Rename cached symbol addresses.
* translate.cxx, elaborate.cxx: Corresponding tweaks.
2007-03-20 Frank Ch. Eigler <fche@elastic.org>
PR 4224.
* sym.c (_stp_module_relocate): Support kernel relocations.
2007-03-20 Frank Ch. Eigler <fche@elastic.org>
* symbols.c (_stp_do_symbols): Add cautionary blurb for important
setup of _stp_modules[0]->text.
Diffstat (limited to 'runtime/sym.c')
-rw-r--r-- | runtime/sym.c | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/runtime/sym.c b/runtime/sym.c index a5bc0195..70efd82d 100644 --- a/runtime/sym.c +++ b/runtime/sym.c @@ -34,24 +34,44 @@ static unsigned long _stp_module_relocate (const char *module, const char *secti if (last) { if (!strcmp (module, last->name) && !strcmp (section, last_sec->symbol)) { - STP_UNLOCK_MODULES; - return offset + last_sec->addr; + /* XXX: But is this enough protection? What if the module `last' is + unloaded sometime between the last relocate call and this one? Do + the last/last_sec pointers become invalid to traverse like that? */ + STP_UNLOCK_MODULES; + return offset + last_sec->addr; } } /* need to scan all modules */ - for (i = 1; i < _stp_num_modules; i++) { /* XXX: why start at i=1? */ - last = _stp_modules[i]; - if (strcmp(module, last->name)) - continue; - for (j = 0; j < (int)last->num_sections; j++) { - last_sec = &last->sections[j]; - if (!strcmp (section, last_sec->symbol)) { - STP_UNLOCK_MODULES; - return offset + last_sec->addr; - } - } - } + if (! strcmp (module, "kernel")) + { + STP_UNLOCK_MODULES; + + /* See also transport/symbols.c (_stp_do_symbols). */ + if (strcmp (section, "_stext")) + return 0; + else + return offset + _stp_modules[0]->text; + + /* NB: we could also use _stp_kallsyms_lookup_name (section); */ + /* If _stp_kallsyms_lookup_name also returned the symbol, + we could set last & last_sym and take some advantage of + caching. But OTOH the advantage would be tiny in comparison + to the hard-coded calculation above. */ + } + else /* relocatable module */ + for (i = 1; i < _stp_num_modules; i++) { /* skip over [0]=kernel */ + last = _stp_modules[i]; + if (strcmp(module, last->name)) + continue; + for (j = 0; j < (int)last->num_sections; j++) { + last_sec = &last->sections[j]; + if (!strcmp (section, last_sec->symbol)) { + STP_UNLOCK_MODULES; + return offset + last_sec->addr; + } + } + } STP_UNLOCK_MODULES; last = NULL; return 0; @@ -65,7 +85,7 @@ static unsigned long _stp_kallsyms_lookup_name(const char *name) while (num--) { if (strcmp(name, s->symbol) == 0) - return s->addr; + return s->addr; s++; } return 0; |