]> sourceware.org Git - systemtap.git/commitdiff
PR6503 part 1: separate out _stp_kmodule_update_address
authorFrank Ch. Eigler <fche@redhat.com>
Wed, 31 Aug 2011 15:52:29 +0000 (11:52 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Thu, 1 Sep 2011 21:09:05 +0000 (17:09 -0400)
* runtime/sym.c (_stp_kmodule_update_address): New function, body
  pulled from river at ...
* runtime/transport/symbols.c (_stp_do_relocation): Chop into two bits.

runtime/sym.c
runtime/sym.h
runtime/transport/symbols.c

index 752cf22cda02092da4f3a633237706ba90c2ac7b..99f42ad65d5ba777c150bbe4f96765dca3e35b9b 100644 (file)
@@ -507,4 +507,42 @@ static void _stp_print_addr(unsigned long address, int flags,
 
 /** @} */
 
+
+
+/* Update the given module/section's offset value.  Assume that there
+   is no need for locking or for super performance.  NB: this is only
+   for kernel modules, which exist singly at run time.  User-space
+   modules (executables, shared libraries) exist at different
+   addresses in different processes, so are tracked in the
+   _stp_tf_vma_map. */
+static void _stp_kmodule_update_address(const char* module,
+                                        const char* reloc,
+                                        unsigned long address)
+{
+  unsigned mi, si;
+        
+  for (mi=0; mi<_stp_num_modules; mi++)
+    {
+      if (strcmp (_stp_modules[mi]->name, module))
+        continue;
+
+      if (!strcmp (".note.gnu.build-id", reloc)) {
+        _stp_modules[mi]->notes_sect = address;   /* cache this particular address  */
+      }
+
+      for (si=0; si<_stp_modules[mi]->num_sections; si++)
+        {
+          if (strcmp (_stp_modules[mi]->sections[si].name, reloc))
+            continue;
+          else
+            {
+              _stp_modules[mi]->sections[si].static_addr = address;
+              break;
+            }
+        } /* loop over sections */
+    } /* loop over modules */
+}
+
+
+
 #endif /* _STP_SYM_C_ */
index ba64d89cea3498467c3297f3a4bf7df929c1aff2..b80b9ffd0fb0476762132de7c1bf4478b2b88ab4 100644 (file)
@@ -117,5 +117,8 @@ static unsigned long _stp_umodule_relocate (const char *module,
                                            unsigned long offset,
                                            struct task_struct *tsk);
 static struct _stp_module *_stp_get_unwind_info (unsigned long addr);
+static void _stp_kmodule_update_address(const char* module,
+                                        const char* section,
+                                        unsigned long offset);
 
 #endif /* _STP_SYM_H_ */
index d82fb7bced3447580a37595e0a783a8d03b24114..c1193fee4882b67dfb251abb34d89bc7a16aa09c 100644 (file)
@@ -27,7 +27,6 @@ static void _stp_do_relocation(const char __user *buf, size_t count)
 {
   static struct _stp_msg_relocation msg; /* by protocol, never concurrently used */
   static struct _stp13_msg_relocation msg13; /* ditto */
-  unsigned mi, si;
 
   /* PR12612: Let's try to be compatible with systemtap modules being
      compiled by new systemtap, but loaded (staprun'd) by an older
@@ -63,33 +62,7 @@ static void _stp_do_relocation(const char __user *buf, size_t count)
       _stp_kretprobe_trampoline += (unsigned long) msg.address;
   }
 
-  /* Save the relocation value.  XXX: While keeping the data here is
-     fine for the kernel address space ("kernel" and "*.ko" modules),
-     it is NOT fine for user-space apps.  They need a separate
-     relocation values for each address space, since the same shared
-     libraries/executables can be mapped in at different
-     addresses.  */
-
-  for (mi=0; mi<_stp_num_modules; mi++)
-    {
-      if (strcmp (_stp_modules[mi]->name, msg.module))
-        continue;
-
-      if (!strcmp (".note.gnu.build-id", msg.reloc)) {
-        _stp_modules[mi]->notes_sect = msg.address;   /* cache this particular address  */
-      }
-
-      for (si=0; si<_stp_modules[mi]->num_sections; si++)
-        {
-          if (strcmp (_stp_modules[mi]->sections[si].name, msg.reloc))
-            continue;
-          else
-            {
-              _stp_modules[mi]->sections[si].static_addr = msg.address;
-              break;
-            }
-        } /* loop over sections */
-    } /* loop over modules */
+  _stp_kmodule_update_address(msg.module, msg.reloc, msg.address);
 }
 
 #endif /* _STP_SYMBOLS_C_ */
This page took 0.031654 seconds and 5 git commands to generate.