auto make System.map to C header file

简介: #!/bin/bash # auto make System.map to C header file # 说明: # 该脚本主要是将Linux内核生成的System.map文件中的符号、地址存入结构体中, # 目前认为也许可以在内核驱动中直接调用对应的函数。
#!/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_

 

目录
相关文章
|
3月前
|
Docker 容器
ADD failed: file not found in build context or excluded by .dockerignore: stat irap_rule_center: fil
ADD failed: file not found in build context or excluded by .dockerignore: stat irap_rule_center: fil
遍历字符串,String line = xxx for(int i = 0;i<line.length();i++){system.out.println(line.chartAt(i)); 单个
遍历字符串,String line = xxx for(int i = 0;i<line.length();i++){system.out.println(line.chartAt(i)); 单个
|
7月前
channelSftp.put(InputStream src, String dst, int mode);里的mode都是什么类型的
【5月更文挑战第15天】channelSftp.put(InputStream src, String dst, int mode);里的mode都是什么类型的
141 2
|
7月前
|
Linux Windows
WARNING: UNPROTECTED PRIVATE KEY FILE!
WARNING: UNPROTECTED PRIVATE KEY FILE!
67 0
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
|
Python
Python POST data should be bytes, an iterable of bytes, or a file object. It ...
Python POST data should be bytes, an iterable of bytes, or a file object. It ...
120 0
Could not initialize English chunker/Could not load file from classpath: ‘/en-token.bin‘
Could not initialize English chunker/Could not load file from classpath: ‘/en-token.bin‘
104 0
|
Linux
编译OpenJDK8:error: control reaches end of non-void function [-Werror=return-type]
编译OpenJDK8:error: control reaches end of non-void function [-Werror=return-type]
190 0
checking build system type... ./config.guess: unable to guess system type/you must specify one
checking build system type... ./config.guess: unable to guess system type/you must specify one
168 0
|
程序员 算法框架/工具 Caffe
解决办法:error: 'size_t' does not name a type、unknown type name 'size_t'
解决办法:error: 'size_t' does not name a type、unknown type name 'size_t'
751 0