public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/3] PR4886: Send build-id data of module/kernel in runtime.
@ 2008-09-28  2:24 Wenji Huang
  0 siblings, 0 replies; only message in thread
From: Wenji Huang @ 2008-09-28  2:24 UTC (permalink / raw)
  To: SystemTAP

The note section in runtime will be detected and sent to stap so that 
the relocation function can set the correct address for the section.
---
  runtime/staprun/staprun.c   |    5 +++++
  runtime/transport/symbols.c |   11 ++++++++++-
  2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/runtime/staprun/staprun.c b/runtime/staprun/staprun.c
index f8a0887..c57eb89 100644
--- a/runtime/staprun/staprun.c
+++ b/runtime/staprun/staprun.c
@@ -370,6 +370,11 @@ int send_relocation_kernel ()
          }
        fclose (kallsyms);
        if (!done_with_kallsyms) srkrc = -1;
+      /* detect note section, send flag if there
+       * NB: address=2 represents existed note, the real one in _stp_module
+      */
+      if (srkrc != -1 && !access("/sys/kernel/notes", R_OK))
+       send_a_relocation ("kernel", ".note.gnu.build-id", 2);
      }

    return srkrc;
diff --git a/runtime/transport/symbols.c b/runtime/transport/symbols.c
index 4bdd090..d4e17d0 100644
--- a/runtime/transport/symbols.c
+++ b/runtime/transport/symbols.c
@@ -51,8 +51,16 @@ static void _stp_do_relocation(const char __user 
*buf, size_t count)
        if (strcmp (_stp_modules[mi]->name, msg.module))
          continue;

+      /* update note section to represent loaded */
+      if (_stp_modules[mi]->notes_sect == 0)
+       _stp_modules[mi]->notes_sect = 1;
        for (si=0; si<_stp_modules[mi]->num_sections; si++)
          {
+          if (!strcmp (".note.gnu.build-id", msg.reloc)) {
+               _stp_modules[mi]->notes_sect = msg.address;
+               continue;
+          }
+
            if (strcmp (_stp_modules[mi]->sections[si].name, msg.reloc))
              continue;

@@ -134,7 +142,8 @@ static int _stp_section_is_interesting(const char *name)
  {
         int ret = 1;
         if (!strncmp("__", name, 2)
-           || !strncmp(".note", name, 5)
+           || (!strncmp(".note", name, 5)
+               && strncmp(".note.gnu.build-id", name, 18))
             || !strncmp(".gnu", name, 4)
             || !strncmp(".mod", name, 4))
                 ret = 0;
-- 
1.5.6

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-28  2:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-28  2:24 [PATCH 2/3] PR4886: Send build-id data of module/kernel in runtime Wenji Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).