[PATCH 2/3] PR4886: Send build-id data of module/kernel in runtime.

Wenji Huang wenji.huang@oracle.com
Sun Sep 28 02:24:00 GMT 2008


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



More information about the Systemtap mailing list