如下:是通过proc文件系统下的:/proc/kallsyms来获取当前系统中函数get_vm_area, zap_page_range,相关宏__alloc_fd__fd_install__close_fd等
符号的地址,并通过字符匹配把获取的地址来定义函数和宏,把结果写入头文件。
#!/bin/sh
SYMS="get_vm_area zap_page_range map_kernel_range_noflush unmap_kernel_range "\
"get_files_struct put_files_struct __lock_task_sighand "\
"__alloc_fd __fd_install __close_fd can_nice "\
"security_binder_set_context_mgr security_binder_transaction "\
"security_binder_transfer_binder security_binder_transfer_file"
for sym in $SYMS; do
addr=`cat /proc/kallsyms | grep -Ee '^[0-9a-f]+ T '$sym'$' | sed -e 's/\s.*$//g'`
if [ a$addr = 'a' ]; then
echo "Error: can't find symbol $sym"
exit 1
fi
name=`echo $sym | tr '[:lower:]' '[:upper:]'`
echo "#define $name\t(void *)0x$addr"
done
阅读(1703) | 评论(0) | 转发(0) |