Chinaunix首页 | 论坛 | 博客
  • 博客访问: 141447
  • 博文数量: 25
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 232
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-04 16:25
文章分类

全部博文(25)

文章存档

2019年(1)

2018年(1)

2017年(14)

2015年(9)

我的朋友

分类: 嵌入式

2017-07-12 09:42:19

如下:是通过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
阅读(1663) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~