/** @} */
+
+
+/* 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_ */
{
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
_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_ */