auto make System.map to C header file
Posted zengjf
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了auto make System.map to C header file相关的知识,希望对你有一定的参考价值。
#!/bin/bash # auto make System.map to C header file # 说明: # 该脚本主要是将Linux内核生成的System.map文件中的符号、地址存入结构体中, # 目前认为也许可以在内核驱动中直接调用对应的函数。以前在学习裸板开发中就有 # 使用Uboot中提供的printf来写程序的先例,那么这里应该也是可以的,不过这里没 # 有什么实用性,因为5W个函数,但这个结构体就要用掉进200kByte空间。 # # 2016-3-19 深圳 南山平山村 曾剑锋 if [ $# -ne 1 ]; then echo "USAGE:" echo " systemMap.sh <your system.Map file>" exit -1 fi cat > systemMap.h << EOF #ifndef __SYSTEM_MAP_H__ #define __SYSTEM_MAP_H__ typedef struct System_header { EOF cat $1 | awk ‘{print "\t unsigned int "$3";"}‘ | sort | uniq | grep -v "[\.&]" >> systemMap.h cat >> systemMap.h << EOF } System_header; System_header system_header = { EOF cat $1 | awk ‘{print $3 " \t= " "0x"$1","}‘ | sort -n -k1 | uniq | grep -v "[\.&]" | sed -e "s/^/\\t\./g" >> systemMap.h cat >> systemMap.h << EOF }; #endif // __SYSTEM_MAP_H__ EOF # cat systemMap.h # #ifndef __SYSTEM_MAP_H__ # #define __SYSTEM_MAP_H__ # # typedef struct System_header { # unsigned int a_aidl_bdis_tmr; # unsigned int aalg_list; # unsigned int ablkcipher_decrypt; # unsigned int ablkcipher_decrypt_done; # unsigned int ablkcipher_encrypt; # unsigned int ablkcipher_encrypt_done; # ...... # } System_header; # # System_header system_header = { # .a_aidl_bdis_tmr = 0xc0a62660, # .aalg_list = 0xc09f2a28, # .ablkcipher_decrypt = 0xc04c3568, # .ablkcipher_decrypt_done = 0xc04c1480, # .ablkcipher_encrypt = 0xc04c34d4, # .ablkcipher_encrypt_done = 0xc04c14f0, # ...... # }; # #endif // __SYSTEM_MAP_H_
以上是关于auto make System.map to C header file的主要内容,如果未能解决你的问题,请参考以下文章
centos7 安装后,意外出现Please make your choice from above ['q' to quit | 'c' to continue |
[LeetCode] 1249. Minimum Remove to Make Valid Parentheses
[LeetCode] 1249. Minimum Remove to Make Valid Parentheses