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_

 

时间: 2024-08-03 22:29:58

auto make System.map to C header file的相关文章

为PHP安装imagick时出现Cannot locate header file MagickWand.h错误的解决方法_php实例

今天在新服上安装php imagick, 环境如下: php 5.4.13 ImageMagick-6.8.3-10 imagick-3.0.1 可是出错了一个问题.就是死说找不到MagickWand.h: checking for MagickWand.h header file... configure: error: Cannot locate header file MagickWand.h 可是我明明正确安装了ImageMagick的呀.GOOGLE了半天,也解决不了这个问题.后面对照

centos-DBA: Could not find necessary header file(s).

问题描述 DBA: Could not find necessary header file(s). 编译PHP,提示错误: configure: error: DBA: Could not find necessary header file(s). 详细见:https://gist.github.com/anonymous/ac9726a67198e4c0a946 有安装过gdbm cd / sudo find . -name "gdbm.h" ./usr/include/gdbm

c-Use of C runtime library internal header file

问题描述 Use of C runtime library internal header file 程序没问题,直接由V6转到VS2005,遇到的编译问题都解决了,就剩下这一个报错了,解决不了啊急 c:program files (x86)microsoft visual studiovc98crtsrcexcpt.h 31 快没饭碗了啊 解决方案 看上去是用了vc6的头文件,找出来,然后修改代码 解决方案二: 这是系统头文件吧,我是新手,可能是版本不对,或编译器不兼容? 解决方案三: VC6

解决编译imagick-3.0.1时Cannot locate header file MagickWand.h错误

解决编译imagick-3.0.1时Cannot locate header file http://www.aliyun.com/zixun/aggregation/16764.html">MagickWand.h错误 ImageMagick 6.8之后的版本目录结构改变了,我们查询到ImageMagick的结果如下 [root@localhost ~]# ll /usr/local/include/总用量 48-rw-r--r--. 1 root root  9343 6月   8 1

Linux System.map文件【转】

转自:http://blog.csdn.net/ysbj123/article/details/51233618 当运行GNU链接器gld(ld)时若使用了"-M"选项,或者使用nm命令,则会在标准输出设备(通常是屏幕)上打印出链接映像(link map)信息,即是指由链接程序产生的目标程序内存地址映像信息.其中列出了程序段装入到内存中的位置信息.具体来讲有如下信息: 目标文件及符号信息映射到内存中的位置. 公共符号如何放置. 链接中包含的所有文件成员及其引用的符号. 通常我们会把发送

System.map文件【转】

转自:http://blog.csdn.net/david104/article/details/7194185 当运行GNU链接器gld(ld)时若使用了"-M"选项,或者使用nm命令,则会在标准输出设备(通常是屏幕)上打印出链接映像(link map)信息,即是指由链接程序产生的目标程序内存地址映像信息.其中列出了程序段装入到内存中的位置信息.具体来讲有如下信息: 目标文件及符号信息映射到内存中的位置. 公共符号如何放置. 链接中包含的所有文件成员及其引用的符号. 通常我们会把发送

RTP协议全解析(H264码流和PS流)

写在前面:RTP的解析,网上找了很多资料,但是都不全,所以我力图整理出一个比较全面的解析, 其中借鉴了很多文章,我都列在了文章最后,在此表示感谢. 互联网的发展离不开大家的无私奉献,我决定从我做起,希望大家支持.   原创不易,转载请附上链接,谢谢http://blog.csdn.net/chen495810242/article/details/39207305 1.RTP Header解析                                                   

H264 NALU 使用PS封装 RTP发送

最近由于项目平台需求,要将H264 NALU封装为PS再用RTP发送,PS封装按照ISO DEC-13818-1标准.一个PS包包含PS Header, PES Header, PS system header, PS system map等. 针对H264做如下PS封装: 1.每个IDR NALU前一般都会包含SPS.PPS等NALU,因此将SPS.PPS.IDR 的NALU封装为一个PS包,包括ps头,然后加上PS system header,PS system map,PES header

oracle中file 1 block 128 corrupted/坏块恢复—system rollback坏块修复

有个数据库file 1 block 128 坏块导致数据库无法启动报错如下 该数据库版本是11.2.0.1,根据我们的经验该block是system rollback 的segment header,以下为我在正常哭查询结果SQL> select file_id,block_id,blocks from dba_extents where segment_name='SYSTEM'    FILE_ID   BLOCK_ID     BLOCKS---------- ---------- ---