# Linux Kernel Module Cheat

#### 3.4.3. Bypass lx-symbols

Useless, but a good way to show how hardcore you are. Disable `lx-symbols` with:

    ./run-gdb --no-lxsymbols

From inside guest:

    insmod timer.ko
    cat /proc/modules

as mentioned at:

- https://stackoverflow.com/questions/6384605/how-to-get-address-of-a-kernel-module-loaded-using-insmod/6385818

- https://unix.stackexchange.com/questions/194405/get-base-address-and-size-of-a-loaded-kernel-module

This will give a line of form:

    fops 2327 0 - Live 0xfffffffa00000000

And then tell GDB where the module was loaded with:

    Ctrl-C
    add-symbol-file ../../../rootfs_overlay/x86_64/timer.ko 0xffffffffc0000000
    0xffffffffc0000000

Alternatively, if the module panics before you can read `/proc/modules`, there is a pr_debug which shows the load address:

    echo 8 > /proc/sys/kernel/printk
    echo 'file kernel/module.c +p' > /sys/kernel/debug/dynamic_debug/control
    ./linux/myinsmod.out hello.ko

And then search for a line of type:

    [   84.877482]  0xfffffffa00000000 .text

Tested on 4f4749148273c282e80b58c59db1b47049e190bf + 1.