Created
February 7, 2023 15:09
-
-
Save xiangchu0/028ddf4021ee60570a7728d636eb8e5e to your computer and use it in GitHub Desktop.
simple script to add symbol file information for kernel debug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
function getsym() { | |
KMOD=$1 | |
KDIR=/lib/modules/$(uname -r)/kernel/ | |
KSYS=/sys/module/${KMOD} | |
KPATH=$(find ${KDIR} -name ${KMOD}.ko -o -name ${KMOD/_/-}.ko) | |
KFILE=${KPATH/$KDIR/./} | |
echo -n "add-symbol-file $KFILE" | |
for SEC in .text .bss .data .rodata | |
do | |
if [ -f $KSYS/sections/$SEC ]; then | |
echo -en " \\\\\\n-s $SEC $(cat $KSYS/sections/$SEC)" | |
fi | |
done | |
echo -e "\n" | |
} | |
lsmod | awk "{print $1}" | while read kmod | |
do | |
getsym $kmod | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment