[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Crash-utility] [PATCH] load_module_symbols_helper().



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.

----------------------------------------------------------
[ 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


Attachment: 0001-Add-helper-routine-for-load_module_symbols.patch
Description: Binary data


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]