----- Original Message -----
Hi Dave,
I wuold like to send one more patch which is helper of load_module_symbols().
(Simplified usage by resolving some module parameters at API inside.)
This is useful for dynamic module loading from extension modules
to be coordinated with previous ikconfig patch.
Also add new env CRASH_MODULE_PATH which can use from setenv() or export.
If load_module_symbols_helper() result is wrong, set this env properly.
[ remaining issues ]
- Search basic kernel module path to be installed
Try some closer path to default but enough or right?
- .gnu.linkonce.this_module section
In x86_64, module name '-' is changed with '_' in this section.
Is this conversion arch depend? or Any other specific chars?
Thanks,
Toshi.
This patch has way too much duplication of effort.
For example, why not do something simple like this in kernel.c?:
diff -r1.244 kernel.c
3626a3627,3640
int
load_module_symbols_helper(char *name)
{
char *objfile;
ulong address;
if (is_module_name(name, &address, NULL) &&
(objfile = find_module_objfile(name, NULL, NULL))) {
do_module_cmd(LOAD_SPECIFIED_MODULE_SYMBOLS, name, address, objfile,
NULL);
return TRUE;
}
return FALSE;
}
To test it, I patched test.c like this:
diff -r1.4 test.c
42c42
< ;
---
load_module_symbols_helper(args[optind]);
And verified that it works like so:
crash> test ext3
MODULE NAME SIZE OBJECT FILE
ffffffff8806ae00 ext3 168017
/lib/modules/2.6.18-128.el5/kernel/fs/ext3/ext3.ko
crash>
Then you could also apply your "CRASH_MODULE_PATH" concept to
the module_objfile_search() function, which does the same kind
of thing for the various possible directory trees. That way,
the non-standard CRASH_MODULE_PATH could be used by the "mod"
command as well.
Dave
----------------------------------------------------------
[ Test code image ]
#include <defs.h>
static int kvm_done, kvm_intel_done;
void kvm_symbol_setup(void)
{
/* dummy: structs or global symbols of KVM initilize */
kvm_done = 1;
}
void kvm_intel_symbol_setup(void)
{
/* dummy: structs or global symbols of VMX initilize */
kvm_intel_done = 1;
}
static void __attribute__((constructor))
module_load_test(void)
{
int ikconfig;
read_in_kernel_config(IKCFG_SETUP);
ikconfig = get_kernel_config("KVM", NULL);
if (ikconfig == IKCONFIG_Y)
kvm_symbol_setup();
else if (ikconfig == IKCONFIG_M)
if (load_module_symbols_helper("kvm", "arch/x86/kvm"))
kvm_symbol_setup();
ikconfig = get_kernel_config("KVM_INTEL", NULL);
if (ikconfig == IKCONFIG_Y)
kvm_intel_symbol_setup();
else if (ikconfig == IKCONFIG_M)
if (load_module_symbols_helper("kvm-intel", "arch/x86/kvm"))
kvm_intel_symbol_setup();
if (kvm_done)
fprintf(fp, "kvm module symbols loaded\n");
if (kvm_intel_done)
fprintf(fp, "kvm-intel module symbols loaded\n");
}
static void __attribute__((destructor))
module_load_test_fin(void)
{
read_in_kernel_config(IKCFG_FREE);
}
[ Result ]
crash> mod | grep kvm
ffffffffa008dba0 kvm 175160 (not loaded) [CONFIG_KALLSYMS]
ffffffffa00a4c40 kvm_intel 39368 (not loaded) [CONFIG_KALLSYMS]
crash> extend test.so
kvm module symbols loaded
kvm-intel module symbols loaded
extend: ./test.so: no commands registered: shared object unloaded
crash> mod | grep kvm
ffffffffa008dba0 kvm 175160
/lib/modules/2.6.35/kernel/arch/x86/kvm/kvm.ko
ffffffffa00a4c40 kvm_intel 39368
/lib/modules/2.6.35/kernel/arch/x86/kvm/kvm-intel.ko
Toshikazu Nakayama (1):
Add helper routine for load_module_symbols().
crash-5.1.1/defs.h | 1 +
crash-5.1.1/symbols.c | 89
+++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 90 insertions(+), 0 deletions(-)
--
1.7.4.rc2
--
Crash-utility mailing list
Crash-utility(a)redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility