#ifndef __A_OUT_GNU_H__
#define __A_OUT_GNU_H__#define __GNU_EXEC_MACROS__#ifndef __STRUCT_EXEC_OVERRIDE__//定义执行文件结构
struct exec
{unsigned long a_info;      /* Use macros N_MAGIC, etc for access */unsigned a_text;        /* length of text, in bytes */unsigned a_data;      /* length of data, in bytes */unsigned a_bss;       /* length of uninitialized data area for file, in bytes */unsigned a_syms;      /* length of symbol table data in file, in bytes */unsigned a_entry;        /* start address */unsigned a_trsize;       /* length of relocation info for text, in bytes */unsigned a_drsize;        /* length of relocation info for data, in bytes */
};#endif /* __STRUCT_EXEC_OVERRIDE__ *///机器类型设定
/* these go in the N_MACHTYPE field */
enum machine_type {
#if defined (M_OLDSUN2)M__OLDSUN2 = M_OLDSUN2,
#elseM_OLDSUN2 = 0,
#endif
#if defined (M_68010)M__68010 = M_68010,
#elseM_68010 = 1,
#endif
#if defined (M_68020)M__68020 = M_68020,
#elseM_68020 = 2,
#endif
#if defined (M_SPARC)M__SPARC = M_SPARC,
#elseM_SPARC = 3,
#endif/* skip a bunch so we don't run into any of sun's numbers */M_386 = 100,
};//定义MAGIC地址为32位的有效值。0-16位
#if !defined (N_MAGIC)
#define N_MAGIC(exec) ((exec).a_info & 0xffff)
#endif//获取机器类型 16-23位
#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))//标记 24-31位
#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)//设定Magic,机器类型,标记
#define N_SET_INFO(exec, magic, type, flags) \((exec).a_info = ((magic) & 0xffff) \| (((int)(type) & 0xff) << 16) \| (((flags) & 0xff) << 24))//单独设定Magic值
#define N_SET_MAGIC(exec, magic) \((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))//设定机器类型
#define N_SET_MACHTYPE(exec, machtype) \((exec).a_info = \((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))//设定机器标记
#define N_SET_FLAGS(exec, flags) \((exec).a_info = \((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))//不纯净的执行方式
/* Code indicating object file or impure executable.  */
#define OMAGIC 0407//纯净的执行方式
/* Code indicating pure executable.  */
#define NMAGIC 0410//需求页执行方式
/* Code indicating demand-paged executable.  */
#define ZMAGIC 0413//带有头文件的需求页执行方式
/* This indicates a demand-paged executable with the header in the text. The first page is unmapped to help trap NULL pointer references */
#define QMAGIC 0314//核心文件执行方式
/* Code indicating core file.  */
#define CMAGIC 0421//判断是不是没有定义的执行方式 1为该执行方式没有定义 0为已经定义的执行方式
#if !defined (N_BADMAG)
#define N_BADMAG(x)   (N_MAGIC(x) != OMAGIC    \&& N_MAGIC(x) != NMAGIC   \&& N_MAGIC(x) != ZMAGIC \&& N_MAGIC(x) != QMAGIC)
#endif//获取1024空间存放程序信息后的剩余的大小。
#define _N_HDROFF(x) (1024 - sizeof (struct exec))//获取TEXT文本的偏移地址
//如果为按需求页执行方式(ZMAGIC); 剩余文本空间为1024;
//如果为带有头文件的需求页执行方式(QMAGIC); 剩余文本空间为0;
//如果2者都不是 剩余文本空间为执行程序空间的大小;
#if !defined (N_TXTOFF)
#define N_TXTOFF(x) \(N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \(N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
#endif//获取DATA数据的偏移地址
#if !defined (N_DATOFF)
#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
#endif//获取重新配置Text数据的偏移地址
#if !defined (N_TRELOFF)
#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
#endif//获取重新配置dat啊数据的偏移地址
#if !defined (N_DRELOFF)
#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
#endif//获取标志表数据的偏移地址
#if !defined (N_SYMOFF)
#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
#endif//获取BSS数据的偏移地址
#if !defined (N_STROFF)
#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
#endif//TEXT地址 如果为 带有头文件的需求页执行方式 地址为4096  不是为0
/* Address of text segment in memory after it is loaded.  */
#if !defined (N_TXTADDR)
#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
#endif//段的大小设定
/* Address of data segment in memory after it is loaded.Note that it is up to you to define SEGMENT_SIZEon machines not listed here.  */
#if defined(vax) || defined(hp300) || defined(pyr)
#define SEGMENT_SIZE page_size
#endif
#ifdef  sony
#define SEGMENT_SIZE    0x2000  //8192
#endif  /* Sony.  */
#ifdef is68k
#define SEGMENT_SIZE 0x20000   //131072
#endif
#if defined(m68k) && defined(PORTAR)
#define PAGE_SIZE 0x400              //1024
#define SEGMENT_SIZE PAGE_SIZE       //4096
#endif//linux段的大小设定 1024
#ifdef linux
#include <linux/page.h>
#define SEGMENT_SIZE    1024
#endif//段的大小。需要段X×每个段的大小
#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))//执行程序Text文件的结束点。
#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)//获取执行程序DATA数据的地址
//如果为不纯净的执行方式 在TEXT文件结束点;
//如果为非 地址为X的TEXT位置×每个段的大小
#ifndef N_DATADDR
#define N_DATADDR(x) \(N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \: (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
#endif/* Address of bss segment in memory after it is loaded.  */
//获取执行程序BSS数据的地址
#if !defined (N_BSSADDR)
#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
#endif//定义nList列表结构
#if !defined (N_NLIST_DECLARED)
struct nlist {union {char *n_name;struct nlist *n_next;long n_strx;} n_un;                 //统一4位的unionunsigned char n_type;  //列表类型char n_other;          //列表它项short n_desc;          //减少值unsigned long n_value; //列表值
};
#endif /* no N_NLIST_DECLARED.  *///定义必要的宏!
#if !defined (N_UNDF)
#define N_UNDF 0
#endif
#if !defined (N_ABS)
#define N_ABS 2
#endif
#if !defined (N_TEXT)
#define N_TEXT 4
#endif
#if !defined (N_DATA)
#define N_DATA 6
#endif
#if !defined (N_BSS)
#define N_BSS 8
#endif
#if !defined (N_FN)
#define N_FN 15
#endif#if !defined (N_EXT)
#define N_EXT 1
#endif
#if !defined (N_TYPE)
#define N_TYPE 036
#endif
#if !defined (N_STAB)
#define N_STAB 0340
#endif/* The following type indicates the definition of a symbol as beingan indirect reference to another symbol.  The other symbolappears as an undefined reference, immediately following this symbol.Indirection is asymmetrical.  The other symbol's value will be usedto satisfy requests for the indirect symbol, but not vice versa.If the other symbol does not have a definition, libraries willbe searched to find a definition.  */
#define N_INDR 0xa/* The following symbols refer to set elements.All the N_SET[ATDB] symbols with the same name form one set.Space is allocated for the set in the text section, and each setelement's value is stored into one word of the space.The first word of the space is the length of the set (number of elements).The address of the set is made into an N_SETV symbolwhose name is the same as the name of the set.This symbol acts like a N_DATA global symbolin that it can satisfy undefined external references.  *///元素标记
/* These appear as input to LD, in a .o file.  */
#define N_SETA  0x14        /* Absolute set element symbol */
#define N_SETT  0x16        /* Text set element symbol */
#define N_SETD  0x18        /* Data set element symbol */
#define N_SETB  0x1A        /* Bss set element symbol *//* This is output from LD.  */
#define N_SETV  0x1C        /* Pointer to set vector in data area.  */#if !defined (N_RELOCATION_INFO_DECLARED)
/* This structure describes a single relocation to be performed.The text-relocation section of the file is a vector of these structures,all of which apply to the text section.Likewise, the data-relocation section applies to the data section.  *///重新分配信息结构8位,2整数大小
struct relocation_info
{//重新分配地址/* Address (within segment) to be relocated.  */int r_address;//标号数/* The meaning of r_symbolnum depends on r_extern.  */unsigned int r_symbolnum:24;//pcrel偏移位/* Nonzero means value is a pc-relative offsetand it should be relocated for changes in its own addressas well as for changes in the symbol or section specified.  */unsigned int r_pcrel:1;//分配域的长度/* Length (as exponent of 2) of the field to be relocated.Thus, a value of 2 indicates 1<<2 bytes.  */unsigned int r_length:2;//扩展位/* 1 => relocate with value of symbol.r_symbolnum is the index of the symbolin file's the symbol table.0 => relocate with the address of a segment.r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS(the N_EXT bit may be set also, but signifies nothing).  */ unsigned int r_extern:1;//pad值/* Four bits that aren't used, but when writing an object fileit is desirable to clear them.  */
#ifdef NS32Kunsigned r_bsr:1;unsigned r_disp:1;unsigned r_pad:2;
#elseunsigned int r_pad:4;
#endif
};
#endif /* no N_RELOCATION_INFO_DECLARED.  */#endif /* __A_OUT_GNU_H__ */

a.out.h 头文件分析 \linux-1.0\linux\include\linux\a.out.h相关推荐

  1. linux内核中链表代码分析---list.h头文件分析(二)【转】

    转自:http://blog.chinaunix.net/uid-30254565-id-5637598.html linux内核中链表代码分析---list.h头文件分析(二) 16年2月28日16 ...

  2. linux内核中链表代码分析---list.h头文件分析(一)

    linux内核中链表代码分析---list.h头文件分析(一) 16年2月27日17:13:14 在学习数据结构时,有一个重要的知识点就是链表.对于链表的一些基本操作,它的最好学习资料就是内核中的li ...

  3. 4.4 ipu_param_mem.h头文件分析

    1.下面这两个结构体是本文件的核心结构体. struct ipu_ch_param_word { uint32_t data[5]; uint32_t res[3]; }; struct ipu_ch ...

  4. HAL层,.sensors.h 头文件分析

    Google为Sensor提供了统一的HAL接口,不同的硬件厂商需要根据该接口来实现并完成具体的硬件抽象层, Android中Sensor的HAL接口定义在:hardware/libhardware/ ...

  5. c语言中的stdbool.h头文件,【C语言】中的stdbool.h头文件

    C语言中的stdbool.h头文件 一.相关基础知识 二.具体内容 Win7下安装的VS2015中的stdbool.h的位置为: F:\Program Files (x86)\Microsoft Vi ...

  6. graphic头文件函数_graphics.h头文件

    graphics.h头文件是一款tc操作必备组件.graphics.h头文件主要是运行在win8.win7操作系统上,为用户提供了非常多函数类型,用户只需使用tc编译就可以使用这个软件,是用户进行tc ...

  7. string类 string.h头文件 cstring头文件区别以及读取一行字符串总结

    以前一直分不清string类  string.h头文件 cstring头文件的去别,今天ce了一发才稍微弄懂了. 首先C语言中只有string.h头文件,string.h包含了一些字符数组和字符串的函 ...

  8. C语言不要重复包含.h头文件和.c文件

    1.不要重复包含头文件 --以上出自<C语言程序设计:现代方法(第2版)> f3.h //#ifndef AE_OK #define AE_OK 0 typedef int ngx_int ...

  9. Android JNI入门第四篇——jni头文件分析

    转载请标明出处: http://blog.csdn.net/michael1112/article/details/56666407 江东橘子的博客 一. 首先写了java文件: public cla ...

最新文章

  1. thinkphp 视图(二)变量输出、赋值和替换
  2. c++ :静态函数的应用
  3. 【转载保存】Netty实现单客户端多连接程序
  4. mysql 内部安全性_MySQL数据库的内部以及外部安全性简介
  5. nginx学习文档之二 配置负载均衡-windows配置负载均衡
  6. 我的世界java生存命令方块,我的世界作弊码大全(命令大全) MC命令方块指令
  7. 01_博图默认变量和DB块变量导入昆仑通态触摸屏
  8. axure中继器案例
  9. it行业发展前景怎么样?互联网寒潮来袭是真的吗?
  10. CATIA 安装Service Pack 时出错 检查完整性失败
  11. Ubuntu Women:女娃玩电脑不输纯爷们!
  12. jre包括jvm和java核心类库_包含JVM标准实现及Java核心类库
  13. 【网络经济与企业管理】选择题,错题
  14. Ubuntu设置中没有网络标识(设置中缺少网络设置(Wired))
  15. Vue中实现点击当前行变色
  16. 水面垃圾收集器在线监测项目案例
  17. Nginx系列教程(六)| 手把手教你搭建 LNMP 架构并部署天空网络电影系统
  18. 机器学习推导合集02-SVM简明入门1-硬边界SVM的建模过程
  19. 小技巧:如何让你办公更高效(技巧大集合持续更新中)!
  20. GSMA宣布了首批2017世界移动大会-上海主题演讲嘉宾名单

热门文章

  1. RHEL 5服务篇—常用网络配置命令
  2. MacOS下MySQL配置
  3. ECMAScript 6 -- let和const命令
  4. [javaSE] 看博客学习java并发编程
  5. java 常用工具类的使用一
  6. jquery插件开发导读
  7. 搭建LNMP遇到的问题
  8. java中原始数据文件的输入
  9. 【转】建立公用程序库,提升软件开发生产力
  10. 深度学习之递归神经网络(Recurrent Neural Network,RNN)