@@ -47,6 +47,46 @@ TRACE_EVENT(module_load,
TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints))
);
+/* Module address offset from _stext */
+TRACE_EVENT(module_text_offsets,
+
+ TP_PROTO(struct module *mod),
+
+ TP_ARGS(mod),
+
+ TP_STRUCT__entry(
+ __string( name, mod->name )
+ __field( unsigned long, text_offset )
+ __field( unsigned int, text_size )
+ __field( unsigned long, init_offset )
+ __field( unsigned int, init_size )
+ ),
+
+ TP_fast_assign(
+ if (mod->mem[MOD_TEXT].size) {
+ __entry->text_offset = (unsigned long)mod->mem[MOD_TEXT].base
+ - (unsigned long)_stext;
+ __entry->text_size = mod->mem[MOD_TEXT].size;
+ } else {
+ __entry->text_offset = 0;
+ __entry->text_size = 0;
+ }
+ if (mod->mem[MOD_INIT_TEXT].size) {
+ __entry->init_offset = (unsigned long)mod->mem[MOD_INIT_TEXT].base
+ - (unsigned long)_stext;
+ __entry->init_size = mod->mem[MOD_INIT_TEXT].size;
+ } else {
+ __entry->init_offset = 0;
+ __entry->init_size = 0;
+ }
+ __assign_str(name);
+ ),
+
+ TP_printk("%s text_offset=0x%lx text_size=%d init_offset=0x%lx init_size=%d",
+ __get_str(name), __entry->text_offset, __entry->text_size,
+ __entry->init_offset, __entry->init_size)
+);
+
TRACE_EVENT(module_free,
TP_PROTO(struct module *mod),
@@ -3372,6 +3372,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
/* Done! */
trace_module_load(mod);
+ trace_module_text_offsets(mod);
return do_init_module(mod);